mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Muli Ben-Yehuda <mulix@mulix.org>
To: lkml <linux-kernel@vger.kernel.org>
Cc: Avi Teperman <teperman@il.ibm.com>, Muli Ben-Yehuda <muli@il.ibm.com>
Subject: hidden assumptions in generic_file_write
Date: Mon, 17 Feb 2003 17:00:00 +0200	[thread overview]
Message-ID: <20030217150000.GI6014@latenight.fiasco.org.il> (raw)

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 

             reply	other threads:[~2003-02-17 14:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-17 15:00 Muli Ben-Yehuda [this message]
2003-02-17 15:39 ` Roman Zippel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030217150000.GI6014@latenight.fiasco.org.il \
    --to=mulix@mulix.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=muli@il.ibm.com \
    --cc=teperman@il.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®