From: Christoph Hellwig <hch@infradead.org>
To: Nilay Vaish <nilayvaish@google.com>
Cc: Jens Axboe <axboe@kernel.dk>,
Christoph Hellwig <hch@infradead.org>,
Bart Van Assche <bvanassche@acm.org>,
linux-block@vger.kernel.org
Subject: Re: [PATCH v2 2/2] null_blk: stop storing the page index in page->private
Date: Mon, 30 Nov 2026 00:03:32 -0800 [thread overview]
Message-ID: <aw0t1O8SE-jBaBKB@infradead.org> (raw)
In-Reply-To: <20261126212341.916839-3-nilayvaish@google.com>
On Thu, Nov 26, 2026 at 01:23:41PM -0800, Nilay Vaish wrote:
> Each backing page records its own index in page->private. The index was
> only needed because radix_tree_gang_lookup() returns entries without
> their indices. The XArray iteration provides the index, and every other
> user already has it at hand.
>
> Take the index from the iteration when flushing the cache, pass it to
> null_flush_cache_page(), and drop the copy kept in the page together
> with the sanity checks that compared it with the lookup index.
>
> null_blk no longer uses page->private.
>
> Suggested-by: Christoph Hellwig <hch@infradead.org>
> Signed-off-by: Nilay Vaish <nilayvaish@google.com>
> ---
>
> Notes:
> These patches were written with the help of an AI coding assistant (Gemini).
>
> drivers/block/null_blk/main.c | 24 ++++++++++--------------
> 1 file changed, 10 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
> index e073eca48655..299cf57b1c12 100644
> --- a/drivers/block/null_blk/main.c
> +++ b/drivers/block/null_blk/main.c
> @@ -961,8 +961,6 @@ static struct nullb_page *__null_lookup_page(struct nullb *nullb,
>
> xa = is_cache ? &nullb->dev->cache : &nullb->dev->data;
> t_page = xa_load(xa, idx);
> - WARN_ON(t_page && t_page->page->private != idx);
> -
> if (t_page && (for_write || test_bit(sector_bit, t_page->bitmap)))
> return t_page;
>
> @@ -1000,7 +998,6 @@ static struct nullb_page *null_insert_page(struct nullb *nullb,
> t_page = null_alloc_page();
> if (!t_page)
> goto out_lock;
> - t_page->page->private = idx;
>
> /*
> * The store has to happen under nullb->lock, where it cannot sleep.
> @@ -1026,7 +1023,6 @@ static struct nullb_page *null_insert_page(struct nullb *nullb,
> if (cur) {
> /* Somebody else inserted a page while the lock was dropped. */
> null_free_page(t_page);
> - WARN_ON(cur->page->private != idx);
> return cur;
> }
> if (!ignore_cache)
> @@ -1040,17 +1036,15 @@ static struct nullb_page *null_insert_page(struct nullb *nullb,
> return null_lookup_page(nullb, sector, true, ignore_cache);
> }
>
> -static int null_flush_cache_page(struct nullb *nullb, struct nullb_page *c_page)
> +static int null_flush_cache_page(struct nullb *nullb, struct nullb_page *c_page,
> + unsigned long idx)
> {
> int i;
> unsigned int offset;
> - u64 idx;
> struct nullb_page *t_page;
> void *dst, *src;
>
> - idx = c_page->page->private;
> -
> - t_page = null_insert_page(nullb, idx << PAGE_SECTORS_SHIFT, true);
> + t_page = null_insert_page(nullb, (sector_t)idx << PAGE_SECTORS_SHIFT, true);
Overly long line.
prev parent reply other threads:[~2026-11-30 8:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 21:23 [PATCH v2 0/2] null_blk: stop using page->private Nilay Vaish
2026-11-26 21:23 ` [PATCH v2 1/2] null_blk: convert the page stores to XArray Nilay Vaish
2026-11-30 8:01 ` Christoph Hellwig
2026-11-26 21:23 ` [PATCH v2 2/2] null_blk: stop storing the page index in page->private Nilay Vaish
2026-11-30 8:03 ` Christoph Hellwig [this message]
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=aw0t1O8SE-jBaBKB@infradead.org \
--to=hch@infradead.org \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=linux-block@vger.kernel.org \
--cc=nilayvaish@google.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