From nobody Fri Dec 19 07:51:49 2025 Received: from ssh247.corpemail.net (ssh247.corpemail.net [210.51.61.247]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BAB2721639A for ; Mon, 17 Feb 2025 09:31:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.51.61.247 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739784718; cv=none; b=k8udl/ZEzXTsecnYyZznqtt69eehlL4rd0RMKP8W50+c6pUnzLGyltR22k0V/+iLEbPyQekTrNw2pLfx5xGBApOp/pH0CTT0Xqt4XMFKDPAWV6wTY8Bl25X19psF4AliRNVfQWXG8iGg1ufcj36CawQ0+VFQdDkMAK8JQPpM4Os= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739784718; c=relaxed/simple; bh=nw34p0kUOprw/9zU0R4qhsKxSlou6Sfwx7PrPs90/OM=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=fgfFIKUEBNmS9PX2cgviaXeD0hOC5vqIoyTt89ZyYMtGeMybH/kyumiU/8L5TL1W8VTMVQL/iIcUr+o3vPMPL+jGHGE+zGvNU5dI7Iu86IBbYjQCKDETgWpnvSwzQhWSnEYQZxvYGvfNhUGze3fT/7+282PZtJe3No3R5NdZNqQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=inspur.com; spf=pass smtp.mailfrom=inspur.com; arc=none smtp.client-ip=210.51.61.247 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=inspur.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=inspur.com Received: from ssh247.corpemail.net by ssh247.corpemail.net ((D)) with ASMTP (SSL) id PDX00143; Mon, 17 Feb 2025 17:31:43 +0800 Received: from localhost.localdomain (10.94.10.240) by jtjnmail201604.home.langchao.com (10.100.2.4) with Microsoft SMTP Server id 15.1.2507.39; Mon, 17 Feb 2025 17:31:42 +0800 From: Bo Liu To: , CC: , , Bo Liu Subject: [v2] erofs: get rid of erofs_kmap_type Date: Mon, 17 Feb 2025 04:31:41 -0500 Message-ID: <20250217093141.2659-1-liubo03@inspur.com> X-Mailer: git-send-email 2.18.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 tUid: 202521717314390236f9de244629bbe98a4a41f0267b2 X-Abuse-Reports-To: service@corp-email.com Abuse-Reports-To: service@corp-email.com X-Complaints-To: service@corp-email.com X-Report-Abuse-To: service@corp-email.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since EROFS_KMAP_ATOMIC is no longer valid, get rid of erofs_kmap_type too. Signed-off-by: Bo Liu Reviewed-by: Chao Yu Reviewed-by: Gao Xiang --- fs/erofs/data.c | 17 ++++++++--------- fs/erofs/dir.c | 2 +- fs/erofs/fileio.c | 2 +- fs/erofs/fscache.c | 2 +- fs/erofs/inode.c | 6 +++--- fs/erofs/internal.h | 10 ++-------- fs/erofs/namei.c | 2 +- fs/erofs/super.c | 8 ++++---- fs/erofs/xattr.c | 12 ++++++------ fs/erofs/zdata.c | 4 ++-- fs/erofs/zmap.c | 6 +++--- 11 files changed, 32 insertions(+), 39 deletions(-) diff --git a/fs/erofs/data.c b/fs/erofs/data.c index 0cd6b5c4df98..1d2cb0fa1baf 100644 --- a/fs/erofs/data.c +++ b/fs/erofs/data.c @@ -25,8 +25,7 @@ void erofs_put_metabuf(struct erofs_buf *buf) buf->page =3D NULL; } =20 -void *erofs_bread(struct erofs_buf *buf, erofs_off_t offset, - enum erofs_kmap_type type) +void *erofs_bread(struct erofs_buf *buf, erofs_off_t offset, bool need_kma= p) { pgoff_t index =3D offset >> PAGE_SHIFT; struct folio *folio =3D NULL; @@ -43,10 +42,10 @@ void *erofs_bread(struct erofs_buf *buf, erofs_off_t of= fset, return folio; } buf->page =3D folio_file_page(folio, index); - if (!buf->base && type =3D=3D EROFS_KMAP) - buf->base =3D kmap_local_page(buf->page); - if (type =3D=3D EROFS_NO_KMAP) + if (!need_kmap) return NULL; + if (!buf->base) + buf->base =3D kmap_local_page(buf->page); return buf->base + (offset & ~PAGE_MASK); } =20 @@ -65,10 +64,10 @@ void erofs_init_metabuf(struct erofs_buf *buf, struct s= uper_block *sb) } =20 void *erofs_read_metabuf(struct erofs_buf *buf, struct super_block *sb, - erofs_off_t offset, enum erofs_kmap_type type) + erofs_off_t offset, bool need_kmap) { erofs_init_metabuf(buf, sb); - return erofs_bread(buf, offset, type); + return erofs_bread(buf, offset, need_kmap); } =20 static int erofs_map_blocks_flatmode(struct inode *inode, @@ -135,7 +134,7 @@ int erofs_map_blocks(struct inode *inode, struct erofs_= map_blocks *map) pos =3D ALIGN(erofs_iloc(inode) + vi->inode_isize + vi->xattr_isize, unit) + unit * chunknr; =20 - kaddr =3D erofs_read_metabuf(&buf, sb, pos, EROFS_KMAP); + kaddr =3D erofs_read_metabuf(&buf, sb, pos, true); if (IS_ERR(kaddr)) { err =3D PTR_ERR(kaddr); goto out; @@ -312,7 +311,7 @@ static int erofs_iomap_begin(struct inode *inode, loff_= t offset, loff_t length, struct erofs_buf buf =3D __EROFS_BUF_INITIALIZER; =20 iomap->type =3D IOMAP_INLINE; - ptr =3D erofs_read_metabuf(&buf, sb, mdev.m_pa, EROFS_KMAP); + ptr =3D erofs_read_metabuf(&buf, sb, mdev.m_pa, true); if (IS_ERR(ptr)) return PTR_ERR(ptr); iomap->inline_data =3D ptr; diff --git a/fs/erofs/dir.c b/fs/erofs/dir.c index c3b90abdee37..1d3bb8746ab1 100644 --- a/fs/erofs/dir.c +++ b/fs/erofs/dir.c @@ -58,7 +58,7 @@ static int erofs_readdir(struct file *f, struct dir_conte= xt *ctx) struct erofs_dirent *de; unsigned int nameoff, maxsize; =20 - de =3D erofs_bread(&buf, dbstart, EROFS_KMAP); + de =3D erofs_bread(&buf, dbstart, true); if (IS_ERR(de)) { erofs_err(sb, "fail to readdir of logical block %u of nid %llu", erofs_blknr(sb, dbstart), EROFS_I(dir)->nid); diff --git a/fs/erofs/fileio.c b/fs/erofs/fileio.c index 0ffd1c63beeb..bec4b56b3826 100644 --- a/fs/erofs/fileio.c +++ b/fs/erofs/fileio.c @@ -112,7 +112,7 @@ static int erofs_fileio_scan_folio(struct erofs_fileio = *io, struct folio *folio) void *src; =20 src =3D erofs_read_metabuf(&buf, inode->i_sb, - map->m_pa + ofs, EROFS_KMAP); + map->m_pa + ofs, true); if (IS_ERR(src)) { err =3D PTR_ERR(src); break; diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c index ce3d8737df85..9c9129bca346 100644 --- a/fs/erofs/fscache.c +++ b/fs/erofs/fscache.c @@ -276,7 +276,7 @@ static int erofs_fscache_data_read_slice(struct erofs_f= scache_rq *req) size_t size =3D map.m_llen; void *src; =20 - src =3D erofs_read_metabuf(&buf, sb, map.m_pa, EROFS_KMAP); + src =3D erofs_read_metabuf(&buf, sb, map.m_pa, true); if (IS_ERR(src)) return PTR_ERR(src); =20 diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c index d4b89407822a..4936bd43c438 100644 --- a/fs/erofs/inode.c +++ b/fs/erofs/inode.c @@ -42,7 +42,7 @@ static int erofs_read_inode(struct inode *inode) blkaddr =3D erofs_blknr(sb, inode_loc); ofs =3D erofs_blkoff(sb, inode_loc); =20 - kaddr =3D erofs_read_metabuf(&buf, sb, erofs_pos(sb, blkaddr), EROFS_KMAP= ); + kaddr =3D erofs_read_metabuf(&buf, sb, erofs_pos(sb, blkaddr), true); if (IS_ERR(kaddr)) { erofs_err(sb, "failed to get inode (nid: %llu) page, err %ld", vi->nid, PTR_ERR(kaddr)); @@ -82,8 +82,8 @@ static int erofs_read_inode(struct inode *inode) goto err_out; } memcpy(copied, dic, gotten); - kaddr =3D erofs_read_metabuf(&buf, sb, erofs_pos(sb, blkaddr + 1), - EROFS_KMAP); + kaddr =3D erofs_read_metabuf(&buf, sb, + erofs_pos(sb, blkaddr + 1), true); if (IS_ERR(kaddr)) { erofs_err(sb, "failed to get inode payload block (nid: %llu), err %ld", vi->nid, PTR_ERR(kaddr)); diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index 686d835eb533..f955793146f4 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -199,11 +199,6 @@ enum { EROFS_ZIP_CACHE_READAROUND }; =20 -enum erofs_kmap_type { - EROFS_NO_KMAP, /* don't map the buffer */ - EROFS_KMAP, /* use kmap_local_page() to map the buffer */ -}; - struct erofs_buf { struct address_space *mapping; struct file *file; @@ -387,11 +382,10 @@ void *erofs_read_metadata(struct super_block *sb, str= uct erofs_buf *buf, erofs_off_t *offset, int *lengthp); void erofs_unmap_metabuf(struct erofs_buf *buf); void erofs_put_metabuf(struct erofs_buf *buf); -void *erofs_bread(struct erofs_buf *buf, erofs_off_t offset, - enum erofs_kmap_type type); +void *erofs_bread(struct erofs_buf *buf, erofs_off_t offset, bool need_kma= p); void erofs_init_metabuf(struct erofs_buf *buf, struct super_block *sb); void *erofs_read_metabuf(struct erofs_buf *buf, struct super_block *sb, - erofs_off_t offset, enum erofs_kmap_type type); + erofs_off_t offset, bool need_kmap); int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *dev); int erofs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, u64 start, u64 len); diff --git a/fs/erofs/namei.c b/fs/erofs/namei.c index c94d0c1608a8..f7cf4f41af28 100644 --- a/fs/erofs/namei.c +++ b/fs/erofs/namei.c @@ -100,7 +100,7 @@ static void *erofs_find_target_block(struct erofs_buf *= target, struct erofs_dirent *de; =20 buf.mapping =3D dir->i_mapping; - de =3D erofs_bread(&buf, erofs_pos(dir->i_sb, mid), EROFS_KMAP); + de =3D erofs_bread(&buf, erofs_pos(dir->i_sb, mid), true); if (!IS_ERR(de)) { const int nameoff =3D nameoff_from_disk(de->nameoff, bsz); const int ndirents =3D nameoff / sizeof(*de); diff --git a/fs/erofs/super.c b/fs/erofs/super.c index 827b62665649..3dc86d931ef1 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -94,7 +94,7 @@ void *erofs_read_metadata(struct super_block *sb, struct = erofs_buf *buf, int len, i, cnt; =20 *offset =3D round_up(*offset, 4); - ptr =3D erofs_bread(buf, *offset, EROFS_KMAP); + ptr =3D erofs_bread(buf, *offset, true); if (IS_ERR(ptr)) return ptr; =20 @@ -110,7 +110,7 @@ void *erofs_read_metadata(struct super_block *sb, struc= t erofs_buf *buf, for (i =3D 0; i < len; i +=3D cnt) { cnt =3D min_t(int, sb->s_blocksize - erofs_blkoff(sb, *offset), len - i); - ptr =3D erofs_bread(buf, *offset, EROFS_KMAP); + ptr =3D erofs_bread(buf, *offset, true); if (IS_ERR(ptr)) { kfree(buffer); return ptr; @@ -141,7 +141,7 @@ static int erofs_init_device(struct erofs_buf *buf, str= uct super_block *sb, struct erofs_deviceslot *dis; struct file *file; =20 - dis =3D erofs_read_metabuf(buf, sb, *pos, EROFS_KMAP); + dis =3D erofs_read_metabuf(buf, sb, *pos, true); if (IS_ERR(dis)) return PTR_ERR(dis); =20 @@ -255,7 +255,7 @@ static int erofs_read_superblock(struct super_block *sb) void *data; int ret; =20 - data =3D erofs_read_metabuf(&buf, sb, 0, EROFS_KMAP); + data =3D erofs_read_metabuf(&buf, sb, 0, true); if (IS_ERR(data)) { erofs_err(sb, "cannot read erofs superblock"); return PTR_ERR(data); diff --git a/fs/erofs/xattr.c b/fs/erofs/xattr.c index df2777e05661..9cf84717a92e 100644 --- a/fs/erofs/xattr.c +++ b/fs/erofs/xattr.c @@ -81,7 +81,7 @@ static int erofs_init_inode_xattrs(struct inode *inode) it.pos =3D erofs_iloc(inode) + vi->inode_isize; =20 /* read in shared xattr array (non-atomic, see kmalloc below) */ - it.kaddr =3D erofs_bread(&it.buf, it.pos, EROFS_KMAP); + it.kaddr =3D erofs_bread(&it.buf, it.pos, true); if (IS_ERR(it.kaddr)) { ret =3D PTR_ERR(it.kaddr); goto out_unlock; @@ -102,7 +102,7 @@ static int erofs_init_inode_xattrs(struct inode *inode) it.pos +=3D sizeof(struct erofs_xattr_ibody_header); =20 for (i =3D 0; i < vi->xattr_shared_count; ++i) { - it.kaddr =3D erofs_bread(&it.buf, it.pos, EROFS_KMAP); + it.kaddr =3D erofs_bread(&it.buf, it.pos, true); if (IS_ERR(it.kaddr)) { kfree(vi->xattr_shared_xattrs); vi->xattr_shared_xattrs =3D NULL; @@ -183,7 +183,7 @@ static int erofs_xattr_copy_to_buffer(struct erofs_xatt= r_iter *it, void *src; =20 for (processed =3D 0; processed < len; processed +=3D slice) { - it->kaddr =3D erofs_bread(&it->buf, it->pos, EROFS_KMAP); + it->kaddr =3D erofs_bread(&it->buf, it->pos, true); if (IS_ERR(it->kaddr)) return PTR_ERR(it->kaddr); =20 @@ -286,7 +286,7 @@ static int erofs_getxattr_foreach(struct erofs_xattr_it= er *it) =20 /* 2. handle xattr name */ for (processed =3D 0; processed < entry.e_name_len; processed +=3D slice)= { - it->kaddr =3D erofs_bread(&it->buf, it->pos, EROFS_KMAP); + it->kaddr =3D erofs_bread(&it->buf, it->pos, true); if (IS_ERR(it->kaddr)) return PTR_ERR(it->kaddr); =20 @@ -330,7 +330,7 @@ static int erofs_xattr_iter_inline(struct erofs_xattr_i= ter *it, it->pos =3D erofs_iloc(inode) + vi->inode_isize + xattr_header_sz; =20 while (remaining) { - it->kaddr =3D erofs_bread(&it->buf, it->pos, EROFS_KMAP); + it->kaddr =3D erofs_bread(&it->buf, it->pos, true); if (IS_ERR(it->kaddr)) return PTR_ERR(it->kaddr); =20 @@ -367,7 +367,7 @@ static int erofs_xattr_iter_shared(struct erofs_xattr_i= ter *it, for (i =3D 0; i < vi->xattr_shared_count; ++i) { it->pos =3D erofs_pos(sb, sbi->xattr_blkaddr) + vi->xattr_shared_xattrs[i] * sizeof(__le32); - it->kaddr =3D erofs_bread(&it->buf, it->pos, EROFS_KMAP); + it->kaddr =3D erofs_bread(&it->buf, it->pos, true); if (IS_ERR(it->kaddr)) return PTR_ERR(it->kaddr); =20 diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c index d771e06db738..ad674eee400a 100644 --- a/fs/erofs/zdata.c +++ b/fs/erofs/zdata.c @@ -832,7 +832,7 @@ static int z_erofs_pcluster_begin(struct z_erofs_fronte= nd *fe) } else { void *mptr; =20 - mptr =3D erofs_read_metabuf(&map->buf, sb, map->m_pa, EROFS_NO_KMAP); + mptr =3D erofs_read_metabuf(&map->buf, sb, map->m_pa, false); if (IS_ERR(mptr)) { ret =3D PTR_ERR(mptr); erofs_err(sb, "failed to get inline data %d", ret); @@ -967,7 +967,7 @@ static int z_erofs_read_fragment(struct super_block *sb= , struct folio *folio, buf.mapping =3D packed_inode->i_mapping; for (; cur < end; cur +=3D cnt, pos +=3D cnt) { cnt =3D min(end - cur, sb->s_blocksize - erofs_blkoff(sb, pos)); - src =3D erofs_bread(&buf, pos, EROFS_KMAP); + src =3D erofs_bread(&buf, pos, true); if (IS_ERR(src)) { erofs_put_metabuf(&buf); return PTR_ERR(src); diff --git a/fs/erofs/zmap.c b/fs/erofs/zmap.c index 689437e99a5a..75daac513050 100644 --- a/fs/erofs/zmap.c +++ b/fs/erofs/zmap.c @@ -31,7 +31,7 @@ static int z_erofs_load_full_lcluster(struct z_erofs_mapr= ecorder *m, struct z_erofs_lcluster_index *di; unsigned int advise; =20 - di =3D erofs_read_metabuf(&m->map->buf, inode->i_sb, pos, EROFS_KMAP); + di =3D erofs_read_metabuf(&m->map->buf, inode->i_sb, pos, true); if (IS_ERR(di)) return PTR_ERR(di); m->lcn =3D lcn; @@ -146,7 +146,7 @@ static int z_erofs_load_compact_lcluster(struct z_erofs= _maprecorder *m, else return -EOPNOTSUPP; =20 - in =3D erofs_read_metabuf(&m->map->buf, m->inode->i_sb, pos, EROFS_KMAP); + in =3D erofs_read_metabuf(&m->map->buf, m->inode->i_sb, pos, true); if (IS_ERR(in)) return PTR_ERR(in); =20 @@ -561,7 +561,7 @@ static int z_erofs_fill_inode_lazy(struct inode *inode) goto out_unlock; =20 pos =3D ALIGN(erofs_iloc(inode) + vi->inode_isize + vi->xattr_isize, 8); - h =3D erofs_read_metabuf(&buf, sb, pos, EROFS_KMAP); + h =3D erofs_read_metabuf(&buf, sb, pos, true); if (IS_ERR(h)) { err =3D PTR_ERR(h); goto out_unlock; --=20 2.31.1