diff mbox series

null_blk: Remove accesses to page->index

Message ID 20241216160849.31739-1-willy@infradead.org (mailing list archive)
State New
Headers show
Series null_blk: Remove accesses to page->index | expand

Commit Message

Matthew Wilcox Dec. 16, 2024, 4:08 p.m. UTC
Use page->private to store the index instead of page->index.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 drivers/block/null_blk/main.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Damien Le Moal Dec. 16, 2024, 6:08 p.m. UTC | #1
On 2024/12/16 8:08, Matthew Wilcox (Oracle) wrote:
> Use page->private to store the index instead of page->index.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>

Looks OK to me.

Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Jens Axboe Dec. 16, 2024, 8:47 p.m. UTC | #2
On Mon, 16 Dec 2024 16:08:47 +0000, Matthew Wilcox (Oracle) wrote:
> Use page->private to store the index instead of page->index.
> 
> 

Applied, thanks!

[1/1] null_blk: Remove accesses to page->index
      commit: aa3339c7e313c15ec0bedd276a2019478be064bb

Best regards,
Hannes Reinecke Dec. 17, 2024, 7:24 a.m. UTC | #3
On 12/16/24 17:08, Matthew Wilcox (Oracle) wrote:
> Use page->private to store the index instead of page->index.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
>   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 3c3d8d200abb..825b738119cb 100644
> --- a/drivers/block/null_blk/main.c
> +++ b/drivers/block/null_blk/main.c
> @@ -899,7 +899,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->index != idx);
> +		WARN_ON(!t_page || t_page->page->private != idx);
>   	} else if (is_cache)
>   		nullb->dev->curr_cache += PAGE_SIZE;
>   
> @@ -922,7 +922,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->index;
> +			pos = t_pages[i]->page->private;
>   			ret = radix_tree_delete_item(root, pos, t_pages[i]);
>   			WARN_ON(ret != t_pages[i]);
>   			null_free_page(ret);
> @@ -948,7 +948,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->index != 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;
> @@ -991,7 +991,7 @@ static struct nullb_page *null_insert_page(struct nullb *nullb,
>   
>   	spin_lock_irq(&nullb->lock);
>   	idx = sector >> PAGE_SECTORS_SHIFT;
> -	t_page->page->index = idx;
> +	t_page->page->private = idx;
>   	t_page = null_radix_tree_insert(nullb, idx, t_page, !ignore_cache);
>   	radix_tree_preload_end();
>   
> @@ -1011,7 +1011,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->index;
> +	idx = c_page->page->private;
>   
>   	t_page = null_insert_page(nullb, idx << PAGE_SECTORS_SHIFT, true);
>   
> @@ -1070,7 +1070,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->index;
> +		nullb->cache_flush_pos = c_pages[i]->page->private;
>   		/*
>   		 * We found the page which is being flushed to disk by other
>   		 * threads
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
diff mbox series

Patch

diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
index 3c3d8d200abb..825b738119cb 100644
--- a/drivers/block/null_blk/main.c
+++ b/drivers/block/null_blk/main.c
@@ -899,7 +899,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->index != idx);
+		WARN_ON(!t_page || t_page->page->private != idx);
 	} else if (is_cache)
 		nullb->dev->curr_cache += PAGE_SIZE;
 
@@ -922,7 +922,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->index;
+			pos = t_pages[i]->page->private;
 			ret = radix_tree_delete_item(root, pos, t_pages[i]);
 			WARN_ON(ret != t_pages[i]);
 			null_free_page(ret);
@@ -948,7 +948,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->index != 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;
@@ -991,7 +991,7 @@  static struct nullb_page *null_insert_page(struct nullb *nullb,
 
 	spin_lock_irq(&nullb->lock);
 	idx = sector >> PAGE_SECTORS_SHIFT;
-	t_page->page->index = idx;
+	t_page->page->private = idx;
 	t_page = null_radix_tree_insert(nullb, idx, t_page, !ignore_cache);
 	radix_tree_preload_end();
 
@@ -1011,7 +1011,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->index;
+	idx = c_page->page->private;
 
 	t_page = null_insert_page(nullb, idx << PAGE_SECTORS_SHIFT, true);
 
@@ -1070,7 +1070,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->index;
+		nullb->cache_flush_pos = c_pages[i]->page->private;
 		/*
 		 * We found the page which is being flushed to disk by other
 		 * threads