From: Curt Wohlgemuth <curtw@google.com>
To: Yongqiang Yang <xiaoqiangnk@gmail.com>
Cc: Andreas Dilger <adilger@dilger.ca>,
linux-ext4@vger.kernel.org, jim@meyering.net, cmm@us.ibm.com,
hughd@google.com, tytso@mit.edu
Subject: Re: [PATCH v3] ext4: Don't set PageUptodate in ext4_end_bio()
Date: Tue, 26 Apr 2011 08:37:19 -0700 [thread overview]
Message-ID: <BANLkTikKNY4ksntoxVEEyTAhKOC-ymng8A@mail.gmail.com> (raw)
In-Reply-To: <BANLkTinuX21XfDCsrH0M8htB6Nkzo4kO=A@mail.gmail.com>
On Mon, Apr 25, 2011 at 11:59 PM, Yongqiang Yang <xiaoqiangnk@gmail.com> wrote:
> On Tue, Apr 26, 2011 at 12:32 PM, Curt Wohlgemuth <curtw@google.com> wrote:
>> On Mon, Apr 25, 2011 at 5:58 PM, Andreas Dilger <adilger@dilger.ca> wrote:
>>> On 2011-04-25, at 5:20 PM, Curt Wohlgemuth wrote:
>>>> On Mon, Apr 25, 2011 at 3:45 PM, Curt Wohlgemuth <curtw@google.com> wrote:
>>>>> On Mon, Apr 25, 2011 at 3:40 PM, Andreas Dilger <adilger@dilger.ca> wrote:
>>>>>> On 2011-04-25, at 2:23 PM, Curt Wohlgemuth wrote:
>>>>>>> In the bio completion routine, we should not be setting
>>>>>>> PageUptodate at all -- it's set at sys_write() time, and is
>>>>>>> unaffected by success/failure of the write to disk.
>>>>>>>
>>>>>>> This can cause a page corruption bug when
>>>>>>>
>>>>>>> block size < page size
>>>>>>>
>>>>>>> @@ -203,46 +203,29 @@ static void ext4_end_bio(struct bio *bio, int error)
>>>>>>> - /*
>>>>>>> - * If this is a partial write which happened to make
>>>>>>> - * all buffers uptodate then we can optimize away a
>>>>>>> - * bogus readpage() for the next read(). Here we
>>>>>>> - * 'discover' whether the page went uptodate as a
>>>>>>> - * result of this (potentially partial) write.
>>>>>>> - */
>>>>>>> - if (!partial_write)
>>>>>>> - SetPageUptodate(page);
>>>>>>> -
>>>>>>
>>>>>> I think this is the important part of the code - if there is a read-after-write for a file that was written in "blocksize" units (blocksize < pagesize), does the page get set uptodate when all of the blocks have been written and/or the writing is at EOF? Otherwise, a read-after-write will always cause data to be fetched from disk needlessly, even though the uptodate information is already in cache.
>>>>>
>>>>> Hmm, that's a good question. I would kind of doubt that the page
>>>>> would be marked uptodate when the final block was written, and this
>>>>> might be what the code above was trying to do. It wasn't doing it
>>>>> correctly :-), but it might have possibly avoided the extra read when
>>>>> it there was no error.
>>>>>
>>>>> I'll look at this some more, and see if I can't test for your scenario
>>>>> above. Perhaps at least checking that all BHs in the page are mapped
>>>>> + uptodate => SetPageUptodate would not be out of line.
>>>>
>>>> My testing is now showing the read coming through after writing to the
>>>> 4 blocks of a 4K file, using 1K blocksize.
>>>
>>> Sorry, but could you please clarify? Does "read coming through" mean that there is an IO sent to the disk, or that the page is uptodate and the read is handled from the page cache?
>>
>> Wow, even I don't understand what I wrote above...
>>
>> What I meant to write was: In my experiments, I do *not* see a read
>> going down to disk after the writes for the individual blocks. I
>> basically did this:
>>
>> ---------------------------
>> dd if=/dev/zero of=bar bs=1k count=1 seek=3 conv=notrunc
>> dd if=/dev/zero of=bar bs=1k count=1 seek=0 conv=notrunc
>> dd if=/dev/zero of=bar bs=1k count=1 seek=1 conv=notrunc
>> dd if=/dev/zero of=bar bs=1k count=1 seek=2 conv=notrunc
>>
>> sync
> try to evict all cache pages
> echo 1 > proc/sys/vm/drop_caches
But this won't prove anything. Andreas was worried about an
extraneous read from disk when the page in the page cache was in fact
up to date. If we evict the page cache, then we *better* read from
disk...
Curt
>
>>
>> dd if=bar of=foo bs=1k count=4
>> ---------------------------
>>
>>>
>>>> And it seems to me that
>>>> this is taken care of in __block_commit_write(), which is called from
>>>> all the .write_end callbacks for ext4, at least.
>>>
>>> It does indeed look like that should be handling this case. It would be good to verify that this is still true with your patch, just in case theory and reality don't align.
>>
>> I see the same *non-read from disk* with 1k blocks both with my patch,
>> and with a vanilla kernel.
>>
>> Thanks,
>> Curt
>>
>>>
>>> Cheers, Andreas
>>>
>>>
>>>
>>>
>>>
>>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>
>
>
>
> --
> Best Wishes
> Yongqiang Yang
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2011-04-26 15:37 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-25 20:23 [PATCH v3] ext4: Don't set PageUptodate in ext4_end_bio() Curt Wohlgemuth
2011-04-25 22:40 ` Andreas Dilger
2011-04-25 22:45 ` Curt Wohlgemuth
2011-04-25 23:20 ` Curt Wohlgemuth
2011-04-26 0:58 ` Andreas Dilger
2011-04-26 4:32 ` Curt Wohlgemuth
2011-04-26 6:59 ` Yongqiang Yang
2011-04-26 15:37 ` Curt Wohlgemuth [this message]
2011-04-26 15:52 ` Yongqiang Yang
2011-04-26 7:41 ` Yongqiang Yang
2011-04-26 12:19 ` Ted Ts'o
2011-05-10 17:41 ` Hugh Dickins
2011-05-10 19:17 ` Ted Ts'o
2011-05-10 19:45 ` Hugh Dickins
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=BANLkTikKNY4ksntoxVEEyTAhKOC-ymng8A@mail.gmail.com \
--to=curtw@google.com \
--cc=adilger@dilger.ca \
--cc=cmm@us.ibm.com \
--cc=hughd@google.com \
--cc=jim@meyering.net \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
--cc=xiaoqiangnk@gmail.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;
as well as URLs for NNTP newsgroup(s).