From: Al Viro <viro@zeniv.linux.org.uk>
To: Gao Xiang <hsiangkao@linux.alibaba.com>
Cc: Yu Kuai <yukuai1@huaweicloud.com>,
jack@suse.cz, hch@lst.de, brauner@kernel.org, axboe@kernel.dk,
linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org,
yi.zhang@huawei.com, yangerkun@huawei.com, yukuai3@huawei.com
Subject: erofs: mechanically convert erofs_read_metabuf() to offsets
Date: Thu, 25 Apr 2024 20:58:46 +0100 [thread overview]
Message-ID: <20240425195846.GC1031757@ZenIV> (raw)
In-Reply-To: <20240425195641.GJ2118490@ZenIV>
just lift the call of erofs_pos() into the callers; it will
collapse in most of them, but that's better done caller-by-caller.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
fs/erofs/data.c | 8 ++++----
fs/erofs/fscache.c | 2 +-
fs/erofs/inode.c | 4 ++--
fs/erofs/internal.h | 2 +-
fs/erofs/super.c | 2 +-
fs/erofs/zdata.c | 2 +-
fs/erofs/zmap.c | 6 +++---
7 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index e1a170e45c70..82a196e02b5c 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -72,10 +72,10 @@ 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_blk_t blkaddr, enum erofs_kmap_type type)
+ erofs_off_t offset, enum erofs_kmap_type type)
{
erofs_init_metabuf(buf, sb);
- return erofs_bread(buf, erofs_pos(sb, blkaddr), type);
+ return erofs_bread(buf, offset, type);
}
static int erofs_map_blocks_flatmode(struct inode *inode,
@@ -152,7 +152,7 @@ int erofs_map_blocks(struct inode *inode, struct erofs_map_blocks *map)
pos = ALIGN(erofs_iloc(inode) + vi->inode_isize +
vi->xattr_isize, unit) + unit * chunknr;
- kaddr = erofs_read_metabuf(&buf, sb, erofs_blknr(sb, pos), EROFS_KMAP);
+ kaddr = erofs_read_metabuf(&buf, sb, erofs_pos(sb, erofs_blknr(sb, pos)), EROFS_KMAP);
if (IS_ERR(kaddr)) {
err = PTR_ERR(kaddr);
goto out;
@@ -295,7 +295,7 @@ static int erofs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
iomap->type = IOMAP_INLINE;
ptr = erofs_read_metabuf(&buf, sb,
- erofs_blknr(sb, mdev.m_pa), EROFS_KMAP);
+ erofs_pos(sb, erofs_blknr(sb, mdev.m_pa)), EROFS_KMAP);
if (IS_ERR(ptr))
return PTR_ERR(ptr);
iomap->inline_data = ptr + erofs_blkoff(sb, mdev.m_pa);
diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
index 8aff1a724805..4df4617d99f2 100644
--- a/fs/erofs/fscache.c
+++ b/fs/erofs/fscache.c
@@ -282,7 +282,7 @@ static int erofs_fscache_data_read_slice(struct erofs_fscache_rq *req)
blknr = erofs_blknr(sb, map.m_pa);
size = map.m_llen;
- src = erofs_read_metabuf(&buf, sb, blknr, EROFS_KMAP);
+ src = erofs_read_metabuf(&buf, sb, erofs_pos(sb, blknr), EROFS_KMAP);
if (IS_ERR(src))
return PTR_ERR(src);
diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
index 0eb0e6f933c3..5f6439a63af7 100644
--- a/fs/erofs/inode.c
+++ b/fs/erofs/inode.c
@@ -26,7 +26,7 @@ static void *erofs_read_inode(struct erofs_buf *buf,
blkaddr = erofs_blknr(sb, inode_loc);
*ofs = erofs_blkoff(sb, inode_loc);
- kaddr = erofs_read_metabuf(buf, sb, blkaddr, EROFS_KMAP);
+ kaddr = erofs_read_metabuf(buf, sb, erofs_pos(sb, blkaddr), EROFS_KMAP);
if (IS_ERR(kaddr)) {
erofs_err(sb, "failed to get inode (nid: %llu) page, err %ld",
vi->nid, PTR_ERR(kaddr));
@@ -66,7 +66,7 @@ static void *erofs_read_inode(struct erofs_buf *buf,
goto err_out;
}
memcpy(copied, dic, gotten);
- kaddr = erofs_read_metabuf(buf, sb, blkaddr + 1,
+ kaddr = erofs_read_metabuf(buf, sb, erofs_pos(sb, blkaddr + 1),
EROFS_KMAP);
if (IS_ERR(kaddr)) {
erofs_err(sb, "failed to get inode payload block (nid: %llu), err %ld",
diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
index 12a179818897..f82a5eb79c8e 100644
--- a/fs/erofs/internal.h
+++ b/fs/erofs/internal.h
@@ -413,7 +413,7 @@ void *erofs_bread(struct erofs_buf *buf, erofs_off_t offset,
enum erofs_kmap_type type);
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_blk_t blkaddr, enum erofs_kmap_type type);
+ erofs_off_t offset, enum erofs_kmap_type type);
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/super.c b/fs/erofs/super.c
index fdefc3772620..5466118c7e2d 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -180,7 +180,7 @@ static int erofs_init_device(struct erofs_buf *buf, struct super_block *sb,
struct file *bdev_file;
void *ptr;
- ptr = erofs_read_metabuf(buf, sb, erofs_blknr(sb, *pos), EROFS_KMAP);
+ ptr = erofs_read_metabuf(buf, sb, erofs_pos(sb, erofs_blknr(sb, *pos)), EROFS_KMAP);
if (IS_ERR(ptr))
return PTR_ERR(ptr);
dis = ptr + erofs_blkoff(sb, *pos);
diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c
index 283c9c3a611d..d417e189f1a0 100644
--- a/fs/erofs/zdata.c
+++ b/fs/erofs/zdata.c
@@ -868,7 +868,7 @@ static int z_erofs_pcluster_begin(struct z_erofs_decompress_frontend *fe)
} else {
void *mptr;
- mptr = erofs_read_metabuf(&map->buf, sb, blknr, EROFS_NO_KMAP);
+ mptr = erofs_read_metabuf(&map->buf, sb, erofs_pos(sb, blknr), EROFS_NO_KMAP);
if (IS_ERR(mptr)) {
ret = PTR_ERR(mptr);
erofs_err(sb, "failed to get inline data %d", ret);
diff --git a/fs/erofs/zmap.c b/fs/erofs/zmap.c
index e313c936351d..bd8dfe8c65ae 100644
--- a/fs/erofs/zmap.c
+++ b/fs/erofs/zmap.c
@@ -34,7 +34,7 @@ static int z_erofs_load_full_lcluster(struct z_erofs_maprecorder *m,
unsigned int advise, type;
m->kaddr = erofs_read_metabuf(&m->map->buf, inode->i_sb,
- erofs_blknr(inode->i_sb, pos), EROFS_KMAP);
+ erofs_pos(inode->i_sb, erofs_blknr(inode->i_sb, pos)), EROFS_KMAP);
if (IS_ERR(m->kaddr))
return PTR_ERR(m->kaddr);
@@ -267,7 +267,7 @@ static int z_erofs_load_compact_lcluster(struct z_erofs_maprecorder *m,
out:
pos += lcn * (1 << amortizedshift);
m->kaddr = erofs_read_metabuf(&m->map->buf, inode->i_sb,
- erofs_blknr(inode->i_sb, pos), EROFS_KMAP);
+ erofs_pos(inode->i_sb, erofs_blknr(inode->i_sb, pos)), EROFS_KMAP);
if (IS_ERR(m->kaddr))
return PTR_ERR(m->kaddr);
return unpack_compacted_index(m, amortizedshift, pos, lookahead);
@@ -600,7 +600,7 @@ static int z_erofs_fill_inode_lazy(struct inode *inode)
goto out_unlock;
pos = ALIGN(erofs_iloc(inode) + vi->inode_isize + vi->xattr_isize, 8);
- kaddr = erofs_read_metabuf(&buf, sb, erofs_blknr(sb, pos), EROFS_KMAP);
+ kaddr = erofs_read_metabuf(&buf, sb, erofs_pos(sb, erofs_blknr(sb, pos)), EROFS_KMAP);
if (IS_ERR(kaddr)) {
err = PTR_ERR(kaddr);
goto out_unlock;
--
2.39.2
next prev parent reply other threads:[~2024-04-25 19:58 UTC|newest]
Thread overview: 117+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-06 9:09 [PATCH vfs.all 00/26] fs & block: remove bdev->bd_inode Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 01/26] block: move two helpers into bdev.c Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 02/26] block: remove sync_blockdev_nowait() Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 03/26] block: remove sync_blockdev_range() Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 04/26] block: prevent direct access of bd_inode Yu Kuai
2024-04-07 2:22 ` Al Viro
2024-04-07 2:37 ` Yu Kuai
2024-04-11 11:12 ` Christian Brauner
2024-04-06 9:09 ` [PATCH vfs.all 05/26] block: add a helper bdev_read_folio() Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 06/26] bcachefs: remove dead function bdev_sectors() Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 07/26] cramfs: prevent direct access of bd_inode Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 08/26] erofs: " Yu Kuai
2024-04-07 4:05 ` Al Viro
2024-04-07 4:08 ` Al Viro
2024-04-11 16:13 ` Gao Xiang
2024-04-12 1:14 ` Yu Kuai
2024-04-25 19:56 ` Al Viro
2024-04-25 19:57 ` [PATCH 1/6] erofs: switch erofs_bread() to passing offset instead of block number Al Viro
2024-04-29 3:01 ` Gao Xiang
2024-04-25 19:58 ` [PATCH 2/6] erofs_buf: store address_space instead of inode Al Viro
2024-04-29 3:01 ` Gao Xiang
2024-04-25 19:58 ` Al Viro [this message]
2024-04-25 19:59 ` [PATCH 4/6] erofs: don't align offset for erofs_read_metabuf() (simple cases) Al Viro
2024-04-25 19:59 ` [PATCH 5/6] erofs: don't round offset down for erofs_read_metabuf() Al Viro
2024-04-25 20:00 ` [PATCH 6/6] z_erofs_pcluster_begin(): don't bother with rounding position down Al Viro
2024-04-26 5:32 ` Gao Xiang
2024-05-03 4:15 ` Al Viro
2024-05-03 13:01 ` Gao Xiang
2024-05-17 2:24 ` Gao Xiang
2024-04-25 20:08 ` [PATCH vfs.all 08/26] erofs: prevent direct access of bd_inode Al Viro
2024-04-25 21:56 ` Gao Xiang
2024-04-25 22:28 ` Al Viro
2024-04-25 23:11 ` Gao Xiang
2024-04-25 23:22 ` Gao Xiang
2024-04-06 9:09 ` [PATCH vfs.all 09/26] nilfs2: " Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 10/26] gfs2: " Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 11/26] btrfs: " Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 12/26] ext4: remove block_device_ejected() Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 13/26] ext4: prevent direct access of bd_inode Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 14/26] jbd2: " Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 15/26] s390/dasd: use bdev api in dasd_format() Yu Kuai
2024-04-16 1:35 ` Al Viro
2024-04-16 8:47 ` Alexander Gordeev
2024-04-17 12:47 ` Stefan Haberland
2024-04-28 18:58 ` Al Viro
2024-04-28 23:23 ` Al Viro
2024-04-29 14:41 ` Stefan Haberland
2024-04-30 0:30 ` Al Viro
2024-04-30 11:35 ` Stefan Haberland
2024-04-06 9:09 ` [PATCH vfs.all 16/26] bcache: prevent direct access of bd_inode Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 17/26] block2mtd: " Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 18/26] scsi: use bdev helper in scsi_bios_ptable() Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 19/26] dm-vdo: convert to use bdev_file Yu Kuai
2024-04-10 10:56 ` Jan Kara
2024-04-10 17:26 ` Matthew Sakai
2024-04-10 17:40 ` Al Viro
2024-04-10 18:59 ` Matthew Sakai
2024-04-11 11:12 ` Christian Brauner
2024-04-06 9:09 ` [PATCH vfs.all 20/26] block: factor out a helper init_bdev_file() Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 21/26] block: fix module reference leakage from bdev_open_by_dev error path Yu Kuai
2024-04-11 9:16 ` (subset) " Christian Brauner
2024-04-06 9:09 ` [PATCH vfs.all 22/26] block: stash a bdev_file to read/write raw blcok_device Yu Kuai
2024-04-06 19:42 ` Al Viro
2024-04-06 20:29 ` Al Viro
2024-04-07 1:18 ` Yu Kuai
2024-04-07 1:51 ` Al Viro
2024-04-07 2:34 ` Yu Kuai
2024-04-07 3:06 ` Al Viro
2024-04-07 3:21 ` Yu Kuai
2024-04-07 4:57 ` Al Viro
2024-04-07 5:11 ` Al Viro
2024-04-07 5:21 ` Al Viro
2024-04-11 15:22 ` Matthew Wilcox
2024-04-09 4:26 ` Al Viro
2024-04-09 4:53 ` Al Viro
2024-04-09 6:22 ` Yu Kuai
2024-04-10 10:59 ` Jan Kara
2024-04-10 22:34 ` Al Viro
2024-04-11 11:56 ` Christian Brauner
2024-04-11 14:04 ` Al Viro
2024-04-11 14:49 ` Al Viro
2024-04-11 14:53 ` [PATCH 01/11] block_device: add a pointer to struct address_space (page cache of bdev) Al Viro
2024-04-11 14:53 ` [PATCH 02/11] use ->bd_mapping instead of ->bd_inode->i_mapping Al Viro
2024-04-11 14:53 ` [PATCH 03/11] grow_dev_folio(): we only want ->bd_inode->i_mapping there Al Viro
2024-04-11 14:59 ` Matthew Wilcox
2024-04-11 14:53 ` [PATCH 04/11] gfs2: more obvious initializations of mapping->host Al Viro
2024-04-11 14:53 ` [PATCH 05/11] blkdev_write_iter(): saner way to get inode and bdev Al Viro
2024-04-11 14:53 ` [PATCH 06/11] blk_ioctl_{discard,zeroout}(): we only want ->bd_inode->i_mapping here Al Viro
2024-04-11 14:53 ` [PATCH 07/11] ext4: remove block_device_ejected() Al Viro
2024-04-11 14:53 ` [PATCH 08/11] block: move two helpers into bdev.c Al Viro
2024-04-11 14:53 ` [PATCH 09/11] dm-vdo: use bdev_nr_bytes(bdev) instead of i_size_read(bdev->bd_inode) Al Viro
2024-04-11 18:04 ` Matthew Sakai
2024-04-11 14:53 ` [PATCH 10/11] bcachefs: remove dead function bdev_sectors() Al Viro
2024-04-11 14:53 ` [PATCH 11/11] block2mtd: prevent direct access of bd_inode Al Viro
2024-04-17 11:05 ` [PATCH 01/11] block_device: add a pointer to struct address_space (page cache of bdev) Christian Brauner
2024-04-12 1:38 ` [PATCH vfs.all 22/26] block: stash a bdev_file to read/write raw blcok_device Yu Kuai
2024-04-12 2:59 ` Al Viro
2024-04-12 4:41 ` Al Viro
2024-04-12 7:13 ` Al Viro
2024-04-12 9:21 ` Christian Brauner
2024-04-12 11:29 ` Al Viro
2024-04-13 15:25 ` Christian Brauner
2024-04-15 20:45 ` Al Viro
2024-04-16 6:32 ` Al Viro
2024-04-17 4:35 ` [PATCH][RFC] set_blocksize() in pktcdvd (was Re: [PATCH vfs.all 22/26] block: stash a bdev_file to read/write raw blcok_device) Al Viro
2024-04-17 13:43 ` [PATCH vfs.all 22/26] block: stash a bdev_file to read/write raw blcok_device Jan Kara
2024-04-17 15:23 ` Al Viro
2024-04-17 20:45 ` [RFC] set_blocksize() in kernel/power/swap.c (was Re: [PATCH vfs.all 22/26] block: stash a bdev_file to read/write raw blcok_device) Al Viro
2024-04-09 9:00 ` [PATCH vfs.all 22/26] block: stash a bdev_file to read/write raw blcok_device Christian Brauner
2024-04-09 10:23 ` Christian Brauner
2024-04-09 11:53 ` Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 23/26] iomap: add helpers helpers to get and set bdev Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 24/26] iomap: convert to use bdev_file Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 25/26] buffer: add helpers to get and set bdev Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 26/26] buffer: convert to use bdev_file Yu Kuai
2024-04-07 2:20 ` [PATCH vfs.all 00/26] fs & block: remove bdev->bd_inode Yu Kuai
2024-04-08 14:05 ` Jan Kara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240425195846.GC1031757@ZenIV \
--to=viro@zeniv.linux.org.uk \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=hch@lst.de \
--cc=hsiangkao@linux.alibaba.com \
--cc=jack@suse.cz \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=yangerkun@huawei.com \
--cc=yi.zhang@huawei.com \
--cc=yukuai1@huaweicloud.com \
--cc=yukuai3@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).