Skip to contentSkip to conversation

null_blk: use page_private() accessors

PATCH New Nilay Vaish 1 participant 1 message Nov 24 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 null_blk: use page_private() accessors

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.

---

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(-)
drivers/block/null_blk/main.c +6 -6
index ec0d7ba4d938..901952e911b3 100644
@@ -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

Signature · 1 line
2.56.1.839.g22a8290db9-goog