[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240510114747.21548-3-ryncsn@gmail.com>
Date: Fri, 10 May 2024 19:47:37 +0800
From: Kairui Song <ryncsn@...il.com>
To: linux-mm@...ck.org
Cc: Andrew Morton <akpm@...ux-foundation.org>,
"Huang, Ying" <ying.huang@...el.com>,
Matthew Wilcox <willy@...radead.org>,
Chris Li <chrisl@...nel.org>,
Barry Song <v-songbaohua@...o.com>,
Ryan Roberts <ryan.roberts@....com>,
Neil Brown <neilb@...e.de>,
Minchan Kim <minchan@...nel.org>,
David Hildenbrand <david@...hat.com>,
Hugh Dickins <hughd@...gle.com>,
Yosry Ahmed <yosryahmed@...gle.com>,
linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org,
Kairui Song <kasong@...cent.com>,
Ryusuke Konishi <konishi.ryusuke@...il.com>,
linux-nilfs@...r.kernel.org
Subject: [PATCH v5 02/12] nilfs2: drop usage of page_index
From: Kairui Song <kasong@...cent.com>
page_index is only for mixed usage of page cache and swap cache, for
pure page cache usage, the caller can just use page->index instead.
It can't be a swap cache page here (being part of buffer head),
so just drop it. And while we are at it, optimize the code by retrieving
the offset of the buffer head within the folio directly using bh_offset,
and get rid of the loop and usage of page helpers.
Suggested-by: Matthew Wilcox <willy@...radead.org>
Signed-off-by: Kairui Song <kasong@...cent.com>
Cc: Ryusuke Konishi <konishi.ryusuke@...il.com>
Cc: linux-nilfs@...r.kernel.org
Acked-by: Ryusuke Konishi <konishi.ryusuke@...il.com>
---
fs/nilfs2/bmap.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/fs/nilfs2/bmap.c b/fs/nilfs2/bmap.c
index 383f0afa2cea..cd14ea25968c 100644
--- a/fs/nilfs2/bmap.c
+++ b/fs/nilfs2/bmap.c
@@ -450,15 +450,9 @@ int nilfs_bmap_test_and_clear_dirty(struct nilfs_bmap *bmap)
__u64 nilfs_bmap_data_get_key(const struct nilfs_bmap *bmap,
const struct buffer_head *bh)
{
- struct buffer_head *pbh;
- __u64 key;
+ loff_t pos = folio_pos(bh->b_folio) + bh_offset(bh);
- key = page_index(bh->b_page) << (PAGE_SHIFT -
- bmap->b_inode->i_blkbits);
- for (pbh = page_buffers(bh->b_page); pbh != bh; pbh = pbh->b_this_page)
- key++;
-
- return key;
+ return pos >> bmap->b_inode->i_blkbits;
}
__u64 nilfs_bmap_find_target_seq(const struct nilfs_bmap *bmap, __u64 key)
--
2.45.0
Powered by blists - more mailing lists