ocfs2-devel.oss.oracle.com archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] ocfs2: Use b_folio in ocfs2_symlink_get_block()
@ 2025-02-13 18:37 Matthew Wilcox (Oracle)
  2025-02-13 18:37 ` [PATCH 2/2] ocfs2: Remove reference to bh->b_page Matthew Wilcox (Oracle)
  2025-02-13 18:58 ` [PATCH 1/2] ocfs2: Use b_folio in ocfs2_symlink_get_block() Matthew Wilcox
  0 siblings, 2 replies; 3+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-02-13 18:37 UTC (permalink / raw)
  To: Joseph Qi
  Cc: Matthew Wilcox (Oracle), Mark Tinguely, ocfs2-devel,
	linux-fsdevel

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(-)

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);
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] ocfs2: Remove reference to bh->b_page
  2025-02-13 18:37 [PATCH 1/2] ocfs2: Use b_folio in ocfs2_symlink_get_block() Matthew Wilcox (Oracle)
@ 2025-02-13 18:37 ` Matthew Wilcox (Oracle)
  2025-02-13 18:58 ` [PATCH 1/2] ocfs2: Use b_folio in ocfs2_symlink_get_block() Matthew Wilcox
  1 sibling, 0 replies; 3+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-02-13 18:37 UTC (permalink / raw)
  To: Joseph Qi
  Cc: Matthew Wilcox (Oracle), Mark Tinguely, ocfs2-devel,
	linux-fsdevel

Buffer heads are attached to folios, not to pages.  Also
flush_dcache_page() is now deprecated in favour of flush_dcache_folio().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/ocfs2/quota_global.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ocfs2/quota_global.c b/fs/ocfs2/quota_global.c
index 15d9acd456ec..e85b1ccf81be 100644
--- a/fs/ocfs2/quota_global.c
+++ b/fs/ocfs2/quota_global.c
@@ -273,7 +273,7 @@ ssize_t ocfs2_quota_write(struct super_block *sb, int type,
 	if (new)
 		memset(bh->b_data, 0, sb->s_blocksize);
 	memcpy(bh->b_data + offset, data, len);
-	flush_dcache_page(bh->b_page);
+	flush_dcache_folio(bh->b_folio);
 	set_buffer_uptodate(bh);
 	unlock_buffer(bh);
 	ocfs2_set_buffer_uptodate(INODE_CACHE(gqinode), bh);
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] ocfs2: Use b_folio in ocfs2_symlink_get_block()
  2025-02-13 18:37 [PATCH 1/2] ocfs2: Use b_folio in ocfs2_symlink_get_block() Matthew Wilcox (Oracle)
  2025-02-13 18:37 ` [PATCH 2/2] ocfs2: Remove reference to bh->b_page Matthew Wilcox (Oracle)
@ 2025-02-13 18:58 ` Matthew Wilcox
  1 sibling, 0 replies; 3+ messages in thread
From: Matthew Wilcox @ 2025-02-13 18:58 UTC (permalink / raw)
  To: Joseph Qi; +Cc: Mark Tinguely, ocfs2-devel, linux-fsdevel

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-02-13 18:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-13 18:37 [PATCH 1/2] ocfs2: Use b_folio in ocfs2_symlink_get_block() Matthew Wilcox (Oracle)
2025-02-13 18:37 ` [PATCH 2/2] ocfs2: Remove reference to bh->b_page Matthew Wilcox (Oracle)
2025-02-13 18:58 ` [PATCH 1/2] ocfs2: Use b_folio in ocfs2_symlink_get_block() Matthew Wilcox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).