[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1fd052ce-cd5e-60ce-e494-cbf6427d3ed3@nvidia.com>
Date: Fri, 21 Feb 2020 11:41:28 -0800
From: John Hubbard <jhubbard@...dia.com>
To: Matthew Wilcox <willy@...radead.org>
CC: <linux-fsdevel@...r.kernel.org>, <linux-mm@...ck.org>,
<linux-kernel@...r.kernel.org>, <linux-btrfs@...r.kernel.org>,
<linux-erofs@...ts.ozlabs.org>, <linux-ext4@...r.kernel.org>,
<linux-f2fs-devel@...ts.sourceforge.net>,
<cluster-devel@...hat.com>, <ocfs2-devel@....oracle.com>,
<linux-xfs@...r.kernel.org>
Subject: Re: [PATCH v7 11/24] mm: Move end_index check out of readahead loop
On 2/21/20 7:35 AM, Matthew Wilcox wrote:
> On Thu, Feb 20, 2020 at 07:50:39PM -0800, John Hubbard wrote:
>> This tiny patch made me pause, because I wasn't sure at first of the exact
>> intent of the lines above. Once I worked it out, it seemed like it might
>> be helpful (or overkill??) to add a few hints for the reader, especially since
>> there are no hints in the function's (minimal) documentation header. What
>> do you think of this?
>>
>> /*
>> * If we can't read *any* pages without going past the inodes's isize
>> * limit, give up entirely:
>> */
>> if (index > end_index)
>> return;
>>
>> /* Cap nr_to_read, in order to avoid overflowing the ULONG type: */
>> if (index + nr_to_read < index)
>> nr_to_read = ULONG_MAX - index + 1;
>>
>> /* Cap nr_to_read, to avoid reading past the inode's isize limit: */
>> if (index + nr_to_read >= end_index)
>> nr_to_read = end_index - index + 1;
>
> A little verbose for my taste ... How about this?
Mine too, actually. :) I think your version below looks good.
thanks,
--
John Hubbard
NVIDIA
>
> end_index = (isize - 1) >> PAGE_SHIFT;
> if (index > end_index)
> return;
> /* Avoid wrapping to the beginning of the file */
> if (index + nr_to_read < index)
> nr_to_read = ULONG_MAX - index + 1;
> /* Don't read past the page containing the last byte of the file */
> if (index + nr_to_read >= end_index)
> nr_to_read = end_index - index + 1;
>
Powered by blists - more mailing lists