From nobody Tue Apr 7 15:55:03 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E25C4C4332F for ; Tue, 18 Oct 2022 10:53:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229891AbiJRKx1 (ORCPT ); Tue, 18 Oct 2022 06:53:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229602AbiJRKxZ (ORCPT ); Tue, 18 Oct 2022 06:53:25 -0400 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC9D3AE231 for ; Tue, 18 Oct 2022 03:53:23 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R251e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046049;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=4;SR=0;TI=SMTPD_---0VSUzdvy_1666090395; Received: from e18g06460.et15sqa.tbsite.net(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0VSUzdvy_1666090395) by smtp.aliyun-inc.com; Tue, 18 Oct 2022 18:53:21 +0800 From: Gao Xiang To: linux-erofs@lists.ozlabs.org, Chao Yu Cc: Gao Xiang , LKML Subject: [PATCH v2] erofs: use kmap_local_page() only for erofs_bread() Date: Tue, 18 Oct 2022 18:53:13 +0800 Message-Id: <20221018105313.4940-1-hsiangkao@linux.alibaba.com> X-Mailer: git-send-email 2.24.4 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Convert all mapped erofs_bread() users to use kmap_local_page() instead of kmap() or kmap_atomic(). Signed-off-by: Gao Xiang Reviewed-by: Chao Yu --- fs/erofs/data.c | 8 ++------ fs/erofs/internal.h | 3 +-- fs/erofs/xattr.c | 8 ++++---- fs/erofs/zmap.c | 4 ++-- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/fs/erofs/data.c b/fs/erofs/data.c index fe8ac0e163f7..fe1ae80284bf 100644 --- a/fs/erofs/data.c +++ b/fs/erofs/data.c @@ -13,9 +13,7 @@ void erofs_unmap_metabuf(struct erofs_buf *buf) { if (buf->kmap_type =3D=3D EROFS_KMAP) - kunmap(buf->page); - else if (buf->kmap_type =3D=3D EROFS_KMAP_ATOMIC) - kunmap_atomic(buf->base); + kunmap_local(buf->base); buf->base =3D NULL; buf->kmap_type =3D EROFS_NO_KMAP; } @@ -54,9 +52,7 @@ void *erofs_bread(struct erofs_buf *buf, struct inode *in= ode, } if (buf->kmap_type =3D=3D EROFS_NO_KMAP) { if (type =3D=3D EROFS_KMAP) - buf->base =3D kmap(page); - else if (type =3D=3D EROFS_KMAP_ATOMIC) - buf->base =3D kmap_atomic(page); + buf->base =3D kmap_local_page(page); buf->kmap_type =3D type; } else if (buf->kmap_type !=3D type) { DBG_BUGON(1); diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index 1701df48c446..67dc8e177211 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -253,8 +253,7 @@ static inline int erofs_wait_on_workgroup_freezed(struc= t erofs_workgroup *grp) =20 enum erofs_kmap_type { EROFS_NO_KMAP, /* don't map the buffer */ - EROFS_KMAP, /* use kmap() to map the buffer */ - EROFS_KMAP_ATOMIC, /* use kmap_atomic() to map the buffer */ + EROFS_KMAP, /* use kmap_local_page() to map the buffer */ }; =20 struct erofs_buf { diff --git a/fs/erofs/xattr.c b/fs/erofs/xattr.c index 8106bcb5a38d..a62fb8a3318a 100644 --- a/fs/erofs/xattr.c +++ b/fs/erofs/xattr.c @@ -148,7 +148,7 @@ static inline int xattr_iter_fixup(struct xattr_iter *i= t) =20 it->blkaddr +=3D erofs_blknr(it->ofs); it->kaddr =3D erofs_read_metabuf(&it->buf, it->sb, it->blkaddr, - EROFS_KMAP_ATOMIC); + EROFS_KMAP); if (IS_ERR(it->kaddr)) return PTR_ERR(it->kaddr); it->ofs =3D erofs_blkoff(it->ofs); @@ -174,7 +174,7 @@ static int inline_xattr_iter_begin(struct xattr_iter *i= t, it->ofs =3D erofs_blkoff(iloc(sbi, vi->nid) + inline_xattr_ofs); =20 it->kaddr =3D erofs_read_metabuf(&it->buf, inode->i_sb, it->blkaddr, - EROFS_KMAP_ATOMIC); + EROFS_KMAP); if (IS_ERR(it->kaddr)) return PTR_ERR(it->kaddr); return vi->xattr_isize - xattr_header_sz; @@ -368,7 +368,7 @@ static int shared_getxattr(struct inode *inode, struct = getxattr_iter *it) =20 it->it.ofs =3D xattrblock_offset(sbi, vi->xattr_shared_xattrs[i]); it->it.kaddr =3D erofs_read_metabuf(&it->it.buf, sb, blkaddr, - EROFS_KMAP_ATOMIC); + EROFS_KMAP); if (IS_ERR(it->it.kaddr)) return PTR_ERR(it->it.kaddr); it->it.blkaddr =3D blkaddr; @@ -580,7 +580,7 @@ static int shared_listxattr(struct listxattr_iter *it) =20 it->it.ofs =3D xattrblock_offset(sbi, vi->xattr_shared_xattrs[i]); it->it.kaddr =3D erofs_read_metabuf(&it->it.buf, sb, blkaddr, - EROFS_KMAP_ATOMIC); + EROFS_KMAP); if (IS_ERR(it->it.kaddr)) return PTR_ERR(it->it.kaddr); it->it.blkaddr =3D blkaddr; diff --git a/fs/erofs/zmap.c b/fs/erofs/zmap.c index 0bb66927e3d0..749a5ac943f4 100644 --- a/fs/erofs/zmap.c +++ b/fs/erofs/zmap.c @@ -178,7 +178,7 @@ static int legacy_load_cluster_from_disk(struct z_erofs= _maprecorder *m, unsigned int advise, type; =20 m->kaddr =3D erofs_read_metabuf(&m->map->buf, inode->i_sb, - erofs_blknr(pos), EROFS_KMAP_ATOMIC); + erofs_blknr(pos), EROFS_KMAP); if (IS_ERR(m->kaddr)) return PTR_ERR(m->kaddr); =20 @@ -416,7 +416,7 @@ static int compacted_load_cluster_from_disk(struct z_er= ofs_maprecorder *m, out: pos +=3D lcn * (1 << amortizedshift); m->kaddr =3D erofs_read_metabuf(&m->map->buf, inode->i_sb, - erofs_blknr(pos), EROFS_KMAP_ATOMIC); + erofs_blknr(pos), EROFS_KMAP); if (IS_ERR(m->kaddr)) return PTR_ERR(m->kaddr); return unpack_compacted_index(m, amortizedshift, pos, lookahead); --=20 2.24.4