]> www.infradead.org Git - users/willy/pagecache.git/commitdiff
ocfs2: use memcpy_to_folio() in ocfs2_symlink_get_block()
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Thu, 13 Feb 2025 21:45:30 +0000 (21:45 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 14 Mar 2025 22:56:02 +0000 (15:56 -0700)
Replace use of kmap_atomic() with the higher-level construct
memcpy_to_folio().  This removes a use of b_page and supports large folios
as well as being easier to understand.  It also removes the check for
kmap_atomic() failing (because it can't).

Link: https://lkml.kernel.org/r/20250213214533.2242224-1-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Acked-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: Mark Tinguely <mark.tinguely@oracle.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Changwei Ge <gechangwei@live.cn>
Cc: Jun Piao <piaojun@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/ocfs2/aops.c

index 5bbeb6fbb1ac014201e549bb4f99b14234c22c21..ccf2930cd2e6c506e4bbb218b669682ececb2413 100644 (file)
@@ -46,7 +46,6 @@ static int ocfs2_symlink_get_block(struct inode *inode, sector_t iblock,
        struct buffer_head *bh = NULL;
        struct buffer_head *buffer_cache_bh = NULL;
        struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
-       void *kaddr;
 
        trace_ocfs2_symlink_get_block(
                        (unsigned long long)OCFS2_I(inode)->ip_blkno,
@@ -91,17 +90,11 @@ 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)) {
+                       memcpy_to_folio(bh_result->b_folio,
+                                       bh_result->b_size * iblock,
+                                       buffer_cache_bh->b_data,
+                                       bh_result->b_size);
                        set_buffer_uptodate(bh_result);
                }
                brelse(buffer_cache_bh);