* [PATCH] null_blk: use page_private() accessors
@ 2026-11-24 3:36 Nilay Vaish
2026-11-24 18:52 ` Bart Van Assche
0 siblings, 1 reply; 3+ messages in thread
From: Nilay Vaish @ 2026-11-24 3:36 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Nilay Vaish
null_blk keeps the index of each backing page in page->private, reading
and writing the field directly.
struct page is being shrunk as part of the memdesc work, and its private
field is one of those that will move. Direct users have to go through
the accessors before that can happen.
Use page_private() and set_page_private() instead, like the rest of the
kernel, so that the driver no longer depends on where struct page keeps
the field.
No functional change.
Signed-off-by: Nilay Vaish <nilayvaish@google.com>
---
Notes:
This patch was written with the help of an AI coding assistant (Gemini).
Based on next-20261123.
drivers/block/null_blk/main.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
index ec0d7ba4d938..901952e911b3 100644
--- a/drivers/block/null_blk/main.c
+++ b/drivers/block/null_blk/main.c
@@ -941,7 +941,7 @@ static struct nullb_page *null_radix_tree_insert(struct nullb *nullb, u64 idx,
if (radix_tree_insert(root, idx, t_page)) {
null_free_page(t_page);
t_page = radix_tree_lookup(root, idx);
- WARN_ON(!t_page || t_page->page->private != idx);
+ WARN_ON(!t_page || page_private(t_page->page) != idx);
} else if (is_cache)
nullb->dev->curr_cache += PAGE_SIZE;
@@ -964,7 +964,7 @@ static void null_free_device_storage(struct nullb_device *dev, bool is_cache)
(void **)t_pages, pos, FREE_BATCH);
for (i = 0; i < nr_pages; i++) {
- pos = t_pages[i]->page->private;
+ pos = page_private(t_pages[i]->page);
ret = radix_tree_delete_item(root, pos, t_pages[i]);
WARN_ON(ret != t_pages[i]);
null_free_page(ret);
@@ -990,7 +990,7 @@ static struct nullb_page *__null_lookup_page(struct nullb *nullb,
root = is_cache ? &nullb->dev->cache : &nullb->dev->data;
t_page = radix_tree_lookup(root, idx);
- WARN_ON(t_page && t_page->page->private != idx);
+ WARN_ON(t_page && page_private(t_page->page) != idx);
if (t_page && (for_write || test_bit(sector_bit, t_page->bitmap)))
return t_page;
@@ -1033,7 +1033,7 @@ static struct nullb_page *null_insert_page(struct nullb *nullb,
spin_lock_irq(&nullb->lock);
idx = sector >> PAGE_SECTORS_SHIFT;
- t_page->page->private = idx;
+ set_page_private(t_page->page, idx);
t_page = null_radix_tree_insert(nullb, idx, t_page, !ignore_cache);
radix_tree_preload_end();
@@ -1053,7 +1053,7 @@ static int null_flush_cache_page(struct nullb *nullb, struct nullb_page *c_page)
struct nullb_page *t_page, *ret;
void *dst, *src;
- idx = c_page->page->private;
+ idx = page_private(c_page->page);
t_page = null_insert_page(nullb, idx << PAGE_SECTORS_SHIFT, true);
@@ -1112,7 +1112,7 @@ static int null_make_cache_space(struct nullb *nullb, unsigned long n)
* avoid race, we don't allow page free
*/
for (i = 0; i < nr_pages; i++) {
- nullb->cache_flush_pos = c_pages[i]->page->private;
+ nullb->cache_flush_pos = page_private(c_pages[i]->page);
/*
* We found the page which is being flushed to disk by other
* threads
base-commit: 3191063649dbf7c0d0b768e1f3655e4c5fc6edb5
prerequisite-patch-id: d52d42a2ec9ddc2b12b3412ec0d07254b417e60f
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] null_blk: use page_private() accessors
2026-11-24 3:36 [PATCH] null_blk: use page_private() accessors Nilay Vaish
@ 2026-11-24 18:52 ` Bart Van Assche
2026-11-25 4:54 ` Christoph Hellwig
0 siblings, 1 reply; 3+ messages in thread
From: Bart Van Assche @ 2026-11-24 18:52 UTC (permalink / raw)
To: Nilay Vaish, Jens Axboe; +Cc: linux-block
On 11/23/26 7:36 PM, Nilay Vaish wrote:
> Use page_private() and set_page_private() instead, like the rest of the
> kernel, so that the driver no longer depends on where struct page keeps
> the field.
Has it been considered to store the page index in struct nullb_page
instead of in page->private? That would remove the dependency of this
driver on page->private entirely, which seems more future-proof given
the memdesc work.
Anyway, this patch looks good to me, hence:
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] null_blk: use page_private() accessors
2026-11-24 18:52 ` Bart Van Assche
@ 2026-11-25 4:54 ` Christoph Hellwig
0 siblings, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2026-11-25 4:54 UTC (permalink / raw)
To: Bart Van Assche; +Cc: Nilay Vaish, Jens Axboe, linux-block
On Tue, Nov 24, 2026 at 10:52:34AM -0800, Bart Van Assche wrote:
> On 11/23/26 7:36 PM, Nilay Vaish wrote:
> > Use page_private() and set_page_private() instead, like the rest of the
> > kernel, so that the driver no longer depends on where struct page keeps
> > the field.
>
> Has it been considered to store the page index in struct nullb_page
> instead of in page->private? That would remove the dependency of this
> driver on page->private entirely, which seems more future-proof given
> the memdesc work.
I don't even see why the index is needed at all. At best it is to
work around the somewhat weird radix_tree_gang_lookup API.
So unless there is an urgent need to remove ->private ASAP to unblock
other word, I'd suggest to do this properly:
1) convert the pages lookup from radix to an xarray, where the
iteration returns you the index
2) remove storing the index in the page entirely
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-25 4:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 3:36 [PATCH] null_blk: use page_private() accessors Nilay Vaish
2026-11-24 18:52 ` Bart Van Assche
2026-11-25 4:54 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox