mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* hidden assumptions in generic_file_write
@ 2003-02-17 15:00 Muli Ben-Yehuda
  2003-02-17 15:39 ` Roman Zippel
  0 siblings, 1 reply; 2+ messages in thread
From: Muli Ben-Yehuda @ 2003-02-17 15:00 UTC (permalink / raw)
  To: lkml; +Cc: Avi Teperman, Muli Ben-Yehuda

Hi, 

Looking at the following code of generic_file_write(), in 2.4, it
looks like there is a hidden assumption on the behavior of
prepare_write() and commit_write() about the behaviour of the file
system specific prepare_write() and commit_write() functions.

		do {
                .....
                kaddr = kmap(page);
                status = mapping->a_ops->prepare_write(file, page, offset, offset+bytes);
                if (status)
                        goto sync_failure;
                page_fault = __copy_from_user(kaddr+offset, buf, bytes);
                flush_dcache_page(page);
                status = mapping->a_ops->commit_write(file, page, offset, offset+bytes);
                if (page_fault)
                        goto fail_write;
                if (!status)
                        status = bytes;

                if (status >= 0) {
                        written += status;
                        count -= status;
                        pos += status;
                        buf += status;
                }
unlock:
                kunmap(page);
                /* Mark it unlocked again and drop the page.. */
                SetPageReferenced(page);
                UnlockPage(page);
                page_cache_release(page);

                if (status < 0)
                        break;
        } while (count);
done:
        ......

Since the data is copied to the page after prepare_write() returns, it 
seems that the assumption is that prepare_write() is synchronous and
the page was already read into memory in case it was not there.

Also, after commit_write(), the code immediately falls through unlock 
which unlocks the page. Since a page is locked during IO, it seems
that commit_write() is synchronous and the page was already written
when it returns.

Can anyone clarify if these two assumptions are correct? if not, where
are we misinterpreting the code? 

Regards, 
Muli Ben-Yehuda, 
Avi Teperman 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-02-17 15:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-17 15:00 hidden assumptions in generic_file_write Muli Ben-Yehuda
2003-02-17 15:39 ` Roman Zippel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®