[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAOzc2pze8XFUE_h-bLzO-P7i6sKc7RF0vnFF+Tjuw7KU=X4hOg@mail.gmail.com>
Date: Mon, 17 Oct 2022 13:12:53 -0700
From: Vishal Moola <vishal.moola@...il.com>
To: Matthew Wilcox <willy@...radead.org>
Cc: akpm@...ux-foundation.org, hughd@...gle.com,
linux-fsdevel@...r.kernel.org, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 1/2] filemap: find_lock_entries() now updates start offset
On Mon, Oct 17, 2022 at 12:43 PM Matthew Wilcox <willy@...radead.org> wrote:
>
> On Mon, Oct 17, 2022 at 12:37:48PM -0700, Vishal Moola wrote:
> > On Mon, Oct 17, 2022 at 9:56 AM Matthew Wilcox <willy@...radead.org> wrote:
> > >
> > > On Mon, Oct 17, 2022 at 09:17:59AM -0700, Vishal Moola (Oracle) wrote:
> > > > +++ b/mm/shmem.c
> > > > @@ -932,21 +932,18 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend,
> > > >
> > > > folio_batch_init(&fbatch);
> > > > index = start;
> > > > - while (index < end && find_lock_entries(mapping, index, end - 1,
> > > > + while (index < end && find_lock_entries(mapping, &index, end - 1,
> > >
> > > Sorry for not spotting this in earlier revisions, but this is wrong.
> > > Before, find_lock_entries() would go up to (end - 1) and then the
> > > index++ at the end of the loop would increment index to "end", causing
> > > the loop to terminate. Now we don't increment index any more, so the
> > > condition is wrong.
> >
> > The condition is correct. Index maintains the exact same behavior.
> > If a find_lock_entries() finds a folio, index is set to be directly after
> > the last page in that folio, or simply incrementing for a value entry.
> > The only time index is not changed at all is when find_lock_entries()
> > finds no folios, which is the same as the original behavior as well.
>
> Uh, right. I had the wrong idea in my head that index wouldn't increase
> past end-1, but of course it can.
>
> > > I suggest just removing the 'index < end" half of the condition.
> >
> > I hadn't thought about it earlier but this index < end check seems
> > unnecessary anyways. If index > end then find_lock_entries()
> > shouldn't find any folios which would cause the loop to terminate.
> >
> > I could send an updated version getting rid of the "index < end"
> > condition as well if you would like?
>
> Something to consider is that if end is 0 then end-1 is -1, which is
> effectively infinity, and we'll do the wrong thing? So maybe just
> leave it alone, and go with v3 as-is?
Yeah in that case find_lock_entries() would definitely do the
wrong thing. I was thinking the "end-1" could be replaced with
"end" as well as removing the "index < end". But that would
change the behavior of the function(s) to now deal with
end inclusive rather than exclusive which may or may not
be problematic. Considering that I don't see any compelling
reason to eliminate the "index < end" condition.
I say we go with v3 as-is if there are no problems.
Powered by blists - more mailing lists