From: Jens Axboe <axboe@kernel.dk>
To: Chris Mason <clm@fb.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Dave Chinner <david@fromorbit.com>,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
Linux Memory Management List <linux-mm@kvack.org>,
Pavel Begunkov <asml.silence@gmail.com>
Subject: Re: mm: don't read i_size of inode unless we need it
Date: Wed, 27 Oct 2021 09:50:55 -0600 [thread overview]
Message-ID: <dbe0e37a-cc67-a8e4-64e5-17fbe887fa40@kernel.dk> (raw)
In-Reply-To: <9383DBC8-0C0E-4EF7-A3E3-272FFA9F14D2@fb.com>
On 10/26/21 1:11 PM, Chris Mason wrote:
>
>> On Oct 26, 2021, at 2:15 PM, Jens Axboe <axboe@kernel.dk> wrote:
>>
>> We always go through i_size_read(), and we rarely end up needing it. Push
>> the read to down where we need to check it, which avoids it for most
>> cases.
>>
>> It looks like we can even remove this check entirely, which might be
>> worth pursuing. But at least this takes it out of the hot path.
>>
>> Acked-by: Chris Mason <clm@fb.com>
>> Signed-off-by: Jens Axboe <axboe@kernel.dk>
>>
>> ---
>>
>> I came across this and wrote the patch the other day, then Pavel pointed
>> me at his original posting of a very similar patch back in August.
>> Discussed it with Chris, and it sure _seems_ like this would be fine.
>>
>> In an attempt to move the original discussion forward, here's this
>> posting.
>>
>
> I had the same concerns Dave Chinner did, but I think the i_size check
> inside generic_file_read_iter() is dead code at this point. Checking
> ki_pos against i_size was added for Btrfs:
>
> commit 66f998f611897319b555364cefd5d6e88a205866
> Author: Josef Bacik <josef@redhat.com>
> Date: Sun May 23 11:00:54 2010 -0400
>
> fs: allow short direct-io reads to be completed via buffered IO
>
> And we’ve switched to btrfs_file_read_iter(), which does the check the
> same way PavelJens have done it here.
>
> I don’t think checking i_size before or after O_DIRECT makes the race
> fundamentally different. We might return a short read at different
> times than we did before, but we won’t be returning stale/incorrect
> data.
Andrew, can you queue this one up in the mm branch?
--
Jens Axboe
next prev parent reply other threads:[~2021-10-27 15:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-26 18:15 Jens Axboe
2021-10-26 19:11 ` Chris Mason
2021-10-27 15:50 ` Jens Axboe [this message]
2021-10-28 14:19 ` Christoph Hellwig
2021-10-28 15:00 ` Jens Axboe
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=dbe0e37a-cc67-a8e4-64e5-17fbe887fa40@kernel.dk \
--to=axboe@kernel.dk \
--cc=akpm@linux-foundation.org \
--cc=asml.silence@gmail.com \
--cc=clm@fb.com \
--cc=david@fromorbit.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/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