diff mbox series

[14/23] ocfs2: Convert ocfs2_map_page_blocks() to ocfs2_map_folio_blocks()

Message ID 20241205171653.3179945-15-willy@infradead.org (mailing list archive)
State New
Headers show
Series Convert ocfs2 to use folios | expand

Commit Message

Matthew Wilcox (Oracle) Dec. 5, 2024, 5:16 p.m. UTC
From: Mark Tinguely <mark.tinguely@oracle.com>

All callers now have a folio, so pass it in instead of converting
folio->page->folio.

Signed-off-by: Mark Tinguely <mark.tinguely@oracle.com>
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/ocfs2/alloc.c |  2 +-
 fs/ocfs2/aops.c  | 18 ++++++++----------
 fs/ocfs2/aops.h  |  2 +-
 3 files changed, 10 insertions(+), 12 deletions(-)

Comments

Joseph Qi Dec. 14, 2024, 2:28 p.m. UTC | #1
On 2024/12/6 01:16, Matthew Wilcox (Oracle) wrote:
> From: Mark Tinguely <mark.tinguely@oracle.com>
> 
> All callers now have a folio, so pass it in instead of converting
> folio->page->folio.
> 
> Signed-off-by: Mark Tinguely <mark.tinguely@oracle.com>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>

Looks good.
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>

> ---
>  fs/ocfs2/alloc.c |  2 +-
>  fs/ocfs2/aops.c  | 18 ++++++++----------
>  fs/ocfs2/aops.h  |  2 +-
>  3 files changed, 10 insertions(+), 12 deletions(-)
> 
> diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
> index e95fe65b6a74..cfe9535a27f9 100644
> --- a/fs/ocfs2/alloc.c
> +++ b/fs/ocfs2/alloc.c
> @@ -6817,7 +6817,7 @@ void ocfs2_map_and_dirty_page(struct inode *inode, handle_t *handle,
>  	loff_t start_byte = folio_pos(folio) + from;
>  	loff_t length = to - from;
>  
> -	ret = ocfs2_map_page_blocks(page, phys, inode, from, to, 0);
> +	ret = ocfs2_map_folio_blocks(folio, phys, inode, from, to, 0);
>  	if (ret)
>  		mlog_errno(ret);
>  
> diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
> index 9ce8debbd282..cbc8bc6d95f3 100644
> --- a/fs/ocfs2/aops.c
> +++ b/fs/ocfs2/aops.c
> @@ -560,7 +560,7 @@ static void ocfs2_clear_page_regions(struct page *page,
>  /*
>   * Nonsparse file systems fully allocate before we get to the write
>   * code. This prevents ocfs2_write() from tagging the write as an
> - * allocating one, which means ocfs2_map_page_blocks() might try to
> + * allocating one, which means ocfs2_map_folio_blocks() might try to
>   * read-in the blocks at the tail of our file. Avoid reading them by
>   * testing i_size against each block offset.
>   */
> @@ -585,11 +585,10 @@ static int ocfs2_should_read_blk(struct inode *inode, struct folio *folio,
>   *
>   * This will also skip zeroing, which is handled externally.
>   */
> -int ocfs2_map_page_blocks(struct page *page, u64 *p_blkno,
> +int ocfs2_map_folio_blocks(struct folio *folio, u64 *p_blkno,
>  			  struct inode *inode, unsigned int from,
>  			  unsigned int to, int new)
>  {
> -	struct folio *folio = page_folio(page);
>  	int ret = 0;
>  	struct buffer_head *head, *bh, *wait[2], **wait_bh = wait;
>  	unsigned int block_end, block_start;
> @@ -971,12 +970,11 @@ static int ocfs2_prepare_folio_for_write(struct inode *inode, u64 *p_blkno,
>  		map_to = map_from + user_len;
>  
>  		if (new)
> -			ret = ocfs2_map_page_blocks(page, p_blkno, inode,
> -						    cluster_start, cluster_end,
> -						    new);
> +			ret = ocfs2_map_folio_blocks(folio, p_blkno, inode,
> +					cluster_start, cluster_end, new);
>  		else
> -			ret = ocfs2_map_page_blocks(page, p_blkno, inode,
> -						    map_from, map_to, new);
> +			ret = ocfs2_map_folio_blocks(folio, p_blkno, inode,
> +					map_from, map_to, new);
>  		if (ret) {
>  			mlog_errno(ret);
>  			goto out;
> @@ -999,8 +997,8 @@ static int ocfs2_prepare_folio_for_write(struct inode *inode, u64 *p_blkno,
>  		map_from = cluster_start;
>  		map_to = cluster_end;
>  
> -		ret = ocfs2_map_page_blocks(page, p_blkno, inode,
> -					    cluster_start, cluster_end, new);
> +		ret = ocfs2_map_folio_blocks(folio, p_blkno, inode,
> +				cluster_start, cluster_end, new);
>  		if (ret) {
>  			mlog_errno(ret);
>  			goto out;
> diff --git a/fs/ocfs2/aops.h b/fs/ocfs2/aops.h
> index dcf4b0dc82c4..17ca359c6051 100644
> --- a/fs/ocfs2/aops.h
> +++ b/fs/ocfs2/aops.h
> @@ -13,7 +13,7 @@ handle_t *ocfs2_start_walk_page_trans(struct inode *inode,
>  							 unsigned from,
>  							 unsigned to);
>  
> -int ocfs2_map_page_blocks(struct page *page, u64 *p_blkno,
> +int ocfs2_map_folio_blocks(struct folio *folio, u64 *p_blkno,
>  			  struct inode *inode, unsigned int from,
>  			  unsigned int to, int new);
>
diff mbox series

Patch

diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index e95fe65b6a74..cfe9535a27f9 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -6817,7 +6817,7 @@  void ocfs2_map_and_dirty_page(struct inode *inode, handle_t *handle,
 	loff_t start_byte = folio_pos(folio) + from;
 	loff_t length = to - from;
 
-	ret = ocfs2_map_page_blocks(page, phys, inode, from, to, 0);
+	ret = ocfs2_map_folio_blocks(folio, phys, inode, from, to, 0);
 	if (ret)
 		mlog_errno(ret);
 
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index 9ce8debbd282..cbc8bc6d95f3 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -560,7 +560,7 @@  static void ocfs2_clear_page_regions(struct page *page,
 /*
  * Nonsparse file systems fully allocate before we get to the write
  * code. This prevents ocfs2_write() from tagging the write as an
- * allocating one, which means ocfs2_map_page_blocks() might try to
+ * allocating one, which means ocfs2_map_folio_blocks() might try to
  * read-in the blocks at the tail of our file. Avoid reading them by
  * testing i_size against each block offset.
  */
@@ -585,11 +585,10 @@  static int ocfs2_should_read_blk(struct inode *inode, struct folio *folio,
  *
  * This will also skip zeroing, which is handled externally.
  */
-int ocfs2_map_page_blocks(struct page *page, u64 *p_blkno,
+int ocfs2_map_folio_blocks(struct folio *folio, u64 *p_blkno,
 			  struct inode *inode, unsigned int from,
 			  unsigned int to, int new)
 {
-	struct folio *folio = page_folio(page);
 	int ret = 0;
 	struct buffer_head *head, *bh, *wait[2], **wait_bh = wait;
 	unsigned int block_end, block_start;
@@ -971,12 +970,11 @@  static int ocfs2_prepare_folio_for_write(struct inode *inode, u64 *p_blkno,
 		map_to = map_from + user_len;
 
 		if (new)
-			ret = ocfs2_map_page_blocks(page, p_blkno, inode,
-						    cluster_start, cluster_end,
-						    new);
+			ret = ocfs2_map_folio_blocks(folio, p_blkno, inode,
+					cluster_start, cluster_end, new);
 		else
-			ret = ocfs2_map_page_blocks(page, p_blkno, inode,
-						    map_from, map_to, new);
+			ret = ocfs2_map_folio_blocks(folio, p_blkno, inode,
+					map_from, map_to, new);
 		if (ret) {
 			mlog_errno(ret);
 			goto out;
@@ -999,8 +997,8 @@  static int ocfs2_prepare_folio_for_write(struct inode *inode, u64 *p_blkno,
 		map_from = cluster_start;
 		map_to = cluster_end;
 
-		ret = ocfs2_map_page_blocks(page, p_blkno, inode,
-					    cluster_start, cluster_end, new);
+		ret = ocfs2_map_folio_blocks(folio, p_blkno, inode,
+				cluster_start, cluster_end, new);
 		if (ret) {
 			mlog_errno(ret);
 			goto out;
diff --git a/fs/ocfs2/aops.h b/fs/ocfs2/aops.h
index dcf4b0dc82c4..17ca359c6051 100644
--- a/fs/ocfs2/aops.h
+++ b/fs/ocfs2/aops.h
@@ -13,7 +13,7 @@  handle_t *ocfs2_start_walk_page_trans(struct inode *inode,
 							 unsigned from,
 							 unsigned to);
 
-int ocfs2_map_page_blocks(struct page *page, u64 *p_blkno,
+int ocfs2_map_folio_blocks(struct folio *folio, u64 *p_blkno,
 			  struct inode *inode, unsigned int from,
 			  unsigned int to, int new);