diff mbox series

[1/2] ocfs2: Use b_folio in ocfs2_symlink_get_block()

Message ID 20250213183730.2141556-1-willy@infradead.org (mailing list archive)
State New
Headers show
Series [1/2] ocfs2: Use b_folio in ocfs2_symlink_get_block() | expand

Commit Message

Matthew Wilcox Feb. 13, 2025, 6:37 p.m. UTC
We are preparing to remove bh->b_page.  While modifying this function,
switch from kmap_atomic to kmap_local, remove the test for kmap_local
failing (it cannot), and reflow the conditional to match kernel coding
style.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/ocfs2/aops.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

Comments

Matthew Wilcox Feb. 13, 2025, 6:58 p.m. UTC | #1
On Thu, Feb 13, 2025 at 06:37:27PM +0000, Matthew Wilcox (Oracle) wrote:
>  		 * copy, the data is still good. */
> -		if (buffer_jbd(buffer_cache_bh)
> -		    && ocfs2_inode_is_new(inode)) {
> -			kaddr = kmap_atomic(bh_result->b_page);
> -			if (!kaddr) {
> -				mlog(ML_ERROR, "couldn't kmap!\n");
> -				goto bail;
> -			}
> -			memcpy(kaddr + (bh_result->b_size * iblock),
> -			       buffer_cache_bh->b_data,
> -			       bh_result->b_size);
> -			kunmap_atomic(kaddr);
> +		if (buffer_jbd(buffer_cache_bh) && ocfs2_inode_is_new(inode)) {
> +			kaddr = kmap_local_folio(bh_result->b_folio,
> +					bh_result->b_size * iblock);
> +			memcpy(kaddr, buffer_cache_bh->b_data,
> +					bh_result->b_size);
> +			kunmap_local(kaddr);
>  			set_buffer_uptodate(bh_result);

hm, now that I look at this again, I think this should actually be:

                if (buffer_jbd(buffer_cache_bh) && ocfs2_inode_is_new(inode)) {
-                       kaddr = kmap_local_folio(bh_result->b_folio,
-                                       bh_result->b_size * iblock);
-                       memcpy(kaddr, buffer_cache_bh->b_data,
+                       memcpy_to_folio(bh_result->b_folio,
+                                       bh_result->b_size * iblock,
+                                       buffer_cache_bh->b_data,
                                        bh_result->b_size);
-                       kunmap_local(kaddr);
                        set_buffer_uptodate(bh_result);

ie use the helper instead of open-coding it.  I'll send a replacement
patch.
diff mbox series

Patch

diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index 5bbeb6fbb1ac..4790e2ba1671 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -91,17 +91,12 @@  static int ocfs2_symlink_get_block(struct inode *inode, sector_t iblock,
 		 * could've happened. Since we've got a reference on
 		 * the bh, even if it commits while we're doing the
 		 * copy, the data is still good. */
-		if (buffer_jbd(buffer_cache_bh)
-		    && ocfs2_inode_is_new(inode)) {
-			kaddr = kmap_atomic(bh_result->b_page);
-			if (!kaddr) {
-				mlog(ML_ERROR, "couldn't kmap!\n");
-				goto bail;
-			}
-			memcpy(kaddr + (bh_result->b_size * iblock),
-			       buffer_cache_bh->b_data,
-			       bh_result->b_size);
-			kunmap_atomic(kaddr);
+		if (buffer_jbd(buffer_cache_bh) && ocfs2_inode_is_new(inode)) {
+			kaddr = kmap_local_folio(bh_result->b_folio,
+					bh_result->b_size * iblock);
+			memcpy(kaddr, buffer_cache_bh->b_data,
+					bh_result->b_size);
+			kunmap_local(kaddr);
 			set_buffer_uptodate(bh_result);
 		}
 		brelse(buffer_cache_bh);