From: Matthew Wilcox <willy@infradead.org>
To: "Vishal Moola (Oracle)" <vishal.moola@gmail.com>
Cc: akpm@linux-foundation.org, hughd@google.com,
linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] filemap: find_lock_entries() now updates start offset
Date: Fri, 14 Oct 2022 04:24:01 +0100 [thread overview]
Message-ID: <Y0jWUSLY1aiVWDIb@casper.infradead.org> (raw)
In-Reply-To: <20221013225708.1879-2-vishal.moola@gmail.com>
On Thu, Oct 13, 2022 at 03:57:07PM -0700, Vishal Moola (Oracle) wrote:
> Initially, find_lock_entries() was being passed in the start offset as a
> value. That left the calculation of the offset to the callers. This led
> to complexity in the callers trying to keep track of the index.
>
> Now find_lock_entires() takes in a pointer to the start offset and
s/entires/entries/
> updates the value to be directly after the last entry found. If no entry is
> found, the offset is not changed. This gets rid of multiple hacky
> calculations that kept track of the start offset.
> @@ -2120,8 +2120,17 @@ unsigned find_lock_entries(struct address_space *mapping, pgoff_t start,
> put:
> folio_put(folio);
> }
> - rcu_read_unlock();
>
> + if (folio_batch_count(fbatch)) {
> + unsigned long nr = 1;
> + int idx = folio_batch_count(fbatch) - 1;
> +
> + folio = fbatch->folios[idx];
> + if (!xa_is_value(folio) && !folio_test_hugetlb(folio))
> + nr = folio_nr_pages(folio);
> + *start = indices[idx] + nr;
> + }
> + rcu_read_unlock();
> return folio_batch_count(fbatch);
Do we need to move the rcu_read_unlock()? Pretty sure we can do all
these calculations without it.
This all looks good. It's certainly more ergonomic to use.
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
next prev parent reply other threads:[~2022-10-14 3:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-13 22:57 [PATCH v2 0/2] Rework find_get_entries() and find_lock_entries() Vishal Moola (Oracle)
2022-10-13 22:57 ` [PATCH v2 1/2] filemap: find_lock_entries() now updates start offset Vishal Moola (Oracle)
2022-10-14 3:24 ` Matthew Wilcox [this message]
2022-10-13 22:57 ` [PATCH v2 2/2] filemap: find_get_entries() " Vishal Moola (Oracle)
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=Y0jWUSLY1aiVWDIb@casper.infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=hughd@google.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=vishal.moola@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