From: Jan Kara <jack@suse.cz>
To: libaokun@huaweicloud.com
Cc: linux-ext4@vger.kernel.org, tytso@mit.edu,
adilger.kernel@dilger.ca, jack@suse.cz,
linux-kernel@vger.kernel.org, kernel@pankajraghav.com,
mcgrof@kernel.org, linux-fsdevel@vger.kernel.org,
linux-mm@kvack.org, yi.zhang@huawei.com, yangerkun@huawei.com,
chengzhihao1@huawei.com, libaokun1@huawei.com
Subject: Re: [PATCH 09/25] ext4: add EXT4_LBLK_TO_B macro for logical block to bytes conversion
Date: Mon, 3 Nov 2025 09:21:38 +0100 [thread overview]
Message-ID: <ejsz6cihhpg2qdxewjgq5j26dihf5m3twingzij3iow2igrilh@hvd5mvqw466d> (raw)
In-Reply-To: <20251025032221.2905818-10-libaokun@huaweicloud.com>
On Sat 25-10-25 11:22:05, libaokun@huaweicloud.com wrote:
> From: Baokun Li <libaokun1@huawei.com>
>
> No functional changes.
>
> Signed-off-by: Baokun Li <libaokun1@huawei.com>
> Reviewed-by: Zhang Yi <yi.zhang@huawei.com>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/ext4/ext4.h | 1 +
> fs/ext4/extents.c | 2 +-
> fs/ext4/inode.c | 20 +++++++++-----------
> fs/ext4/namei.c | 8 +++-----
> fs/ext4/verity.c | 2 +-
> 5 files changed, 15 insertions(+), 18 deletions(-)
>
> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index bca6c3709673..9b236f620b3a 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h
> @@ -367,6 +367,7 @@ struct ext4_io_submit {
> blkbits))
> #define EXT4_B_TO_LBLK(inode, offset) \
> (round_up((offset), i_blocksize(inode)) >> (inode)->i_blkbits)
> +#define EXT4_LBLK_TO_B(inode, lblk) ((loff_t)(lblk) << (inode)->i_blkbits)
>
> /* Translate a block number to a cluster number */
> #define EXT4_B2C(sbi, blk) ((blk) >> (sbi)->s_cluster_bits)
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index ca5499e9412b..da640c88b863 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -4562,7 +4562,7 @@ static int ext4_alloc_file_blocks(struct file *file, ext4_lblk_t offset,
> * allow a full retry cycle for any remaining allocations
> */
> retries = 0;
> - epos = (loff_t)(map.m_lblk + ret) << blkbits;
> + epos = EXT4_LBLK_TO_B(inode, map.m_lblk + ret);
> inode_set_ctime_current(inode);
> if (new_size) {
> if (epos > new_size)
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 889761ed51dd..73c1da90b604 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -825,9 +825,8 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
> !(flags & EXT4_GET_BLOCKS_ZERO) &&
> !ext4_is_quota_file(inode) &&
> ext4_should_order_data(inode)) {
> - loff_t start_byte =
> - (loff_t)map->m_lblk << inode->i_blkbits;
> - loff_t length = (loff_t)map->m_len << inode->i_blkbits;
> + loff_t start_byte = EXT4_LBLK_TO_B(inode, map->m_lblk);
> + loff_t length = EXT4_LBLK_TO_B(inode, map->m_len);
>
> if (flags & EXT4_GET_BLOCKS_IO_SUBMIT)
> ret = ext4_jbd2_inode_add_wait(handle, inode,
> @@ -2225,7 +2224,6 @@ static int mpage_process_folio(struct mpage_da_data *mpd, struct folio *folio,
> ext4_lblk_t lblk = *m_lblk;
> ext4_fsblk_t pblock = *m_pblk;
> int err = 0;
> - int blkbits = mpd->inode->i_blkbits;
> ssize_t io_end_size = 0;
> struct ext4_io_end_vec *io_end_vec = ext4_last_io_end_vec(io_end);
>
> @@ -2251,7 +2249,8 @@ static int mpage_process_folio(struct mpage_da_data *mpd, struct folio *folio,
> err = PTR_ERR(io_end_vec);
> goto out;
> }
> - io_end_vec->offset = (loff_t)mpd->map.m_lblk << blkbits;
> + io_end_vec->offset = EXT4_LBLK_TO_B(mpd->inode,
> + mpd->map.m_lblk);
> }
> *map_bh = true;
> goto out;
> @@ -2261,7 +2260,7 @@ static int mpage_process_folio(struct mpage_da_data *mpd, struct folio *folio,
> bh->b_blocknr = pblock++;
> }
> clear_buffer_unwritten(bh);
> - io_end_size += (1 << blkbits);
> + io_end_size += i_blocksize(mpd->inode);
> } while (lblk++, (bh = bh->b_this_page) != head);
>
> io_end_vec->size += io_end_size;
> @@ -2463,7 +2462,7 @@ static int mpage_map_and_submit_extent(handle_t *handle,
> io_end_vec = ext4_alloc_io_end_vec(io_end);
> if (IS_ERR(io_end_vec))
> return PTR_ERR(io_end_vec);
> - io_end_vec->offset = ((loff_t)map->m_lblk) << inode->i_blkbits;
> + io_end_vec->offset = EXT4_LBLK_TO_B(inode, map->m_lblk);
> do {
> err = mpage_map_one_extent(handle, mpd);
> if (err < 0) {
> @@ -3503,8 +3502,8 @@ static void ext4_set_iomap(struct inode *inode, struct iomap *iomap,
> iomap->dax_dev = EXT4_SB(inode->i_sb)->s_daxdev;
> else
> iomap->bdev = inode->i_sb->s_bdev;
> - iomap->offset = (u64) map->m_lblk << blkbits;
> - iomap->length = (u64) map->m_len << blkbits;
> + iomap->offset = EXT4_LBLK_TO_B(inode, map->m_lblk);
> + iomap->length = EXT4_LBLK_TO_B(inode, map->m_len);
>
> if ((map->m_flags & EXT4_MAP_MAPPED) &&
> !ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
> @@ -3678,7 +3677,6 @@ static int ext4_iomap_alloc(struct inode *inode, struct ext4_map_blocks *map,
> unsigned int flags)
> {
> handle_t *handle;
> - u8 blkbits = inode->i_blkbits;
> int ret, dio_credits, m_flags = 0, retries = 0;
> bool force_commit = false;
>
> @@ -3737,7 +3735,7 @@ static int ext4_iomap_alloc(struct inode *inode, struct ext4_map_blocks *map,
> * i_disksize out to i_size. This could be beyond where direct I/O is
> * happening and thus expose allocated blocks to direct I/O reads.
> */
> - else if (((loff_t)map->m_lblk << blkbits) >= i_size_read(inode))
> + else if (EXT4_LBLK_TO_B(inode, map->m_lblk) >= i_size_read(inode))
> m_flags = EXT4_GET_BLOCKS_CREATE;
> else if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
> m_flags = EXT4_GET_BLOCKS_IO_CREATE_EXT;
> diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
> index 2cd36f59c9e3..78cefb7cc9a7 100644
> --- a/fs/ext4/namei.c
> +++ b/fs/ext4/namei.c
> @@ -1076,7 +1076,7 @@ static int htree_dirblock_to_tree(struct file *dir_file,
> for (; de < top; de = ext4_next_entry(de, dir->i_sb->s_blocksize)) {
> if (ext4_check_dir_entry(dir, NULL, de, bh,
> bh->b_data, bh->b_size,
> - (block<<EXT4_BLOCK_SIZE_BITS(dir->i_sb))
> + EXT4_LBLK_TO_B(dir, block)
> + ((char *)de - bh->b_data))) {
> /* silently ignore the rest of the block */
> break;
> @@ -1630,7 +1630,7 @@ static struct buffer_head *__ext4_find_entry(struct inode *dir,
> }
> set_buffer_verified(bh);
> i = search_dirblock(bh, dir, fname,
> - block << EXT4_BLOCK_SIZE_BITS(sb), res_dir);
> + EXT4_LBLK_TO_B(dir, block), res_dir);
> if (i == 1) {
> EXT4_I(dir)->i_dir_start_lookup = block;
> ret = bh;
> @@ -1710,7 +1710,6 @@ static struct buffer_head * ext4_dx_find_entry(struct inode *dir,
> struct ext4_filename *fname,
> struct ext4_dir_entry_2 **res_dir)
> {
> - struct super_block * sb = dir->i_sb;
> struct dx_frame frames[EXT4_HTREE_LEVEL], *frame;
> struct buffer_head *bh;
> ext4_lblk_t block;
> @@ -1729,8 +1728,7 @@ static struct buffer_head * ext4_dx_find_entry(struct inode *dir,
> goto errout;
>
> retval = search_dirblock(bh, dir, fname,
> - block << EXT4_BLOCK_SIZE_BITS(sb),
> - res_dir);
> + EXT4_LBLK_TO_B(dir, block), res_dir);
> if (retval == 1)
> goto success;
> brelse(bh);
> diff --git a/fs/ext4/verity.c b/fs/ext4/verity.c
> index d9203228ce97..7a980a8059bd 100644
> --- a/fs/ext4/verity.c
> +++ b/fs/ext4/verity.c
> @@ -302,7 +302,7 @@ static int ext4_get_verity_descriptor_location(struct inode *inode,
>
> end_lblk = le32_to_cpu(last_extent->ee_block) +
> ext4_ext_get_actual_len(last_extent);
> - desc_size_pos = (u64)end_lblk << inode->i_blkbits;
> + desc_size_pos = EXT4_LBLK_TO_B(inode, end_lblk);
> ext4_free_ext_path(path);
>
> if (desc_size_pos < sizeof(desc_size_disk))
> --
> 2.46.1
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2025-11-03 8:21 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-25 3:21 [PATCH 00/25] ext4: enable block size larger than page size libaokun
2025-10-25 3:21 ` [PATCH 01/25] ext4: remove page offset calculation in ext4_block_zero_page_range() libaokun
2025-11-03 7:41 ` Jan Kara
2025-10-25 3:21 ` [PATCH 02/25] ext4: remove page offset calculation in ext4_block_truncate_page() libaokun
2025-11-03 7:42 ` Jan Kara
2025-10-25 3:21 ` [PATCH 03/25] ext4: remove PAGE_SIZE checks for rec_len conversion libaokun
2025-11-03 7:43 ` Jan Kara
2025-10-25 3:22 ` [PATCH 04/25] ext4: make ext4_punch_hole() support large block size libaokun
2025-11-03 8:05 ` Jan Kara
2025-11-04 6:55 ` Baokun Li
2025-10-25 3:22 ` [PATCH 05/25] ext4: enable DIOREAD_NOLOCK by default for BS > PS as well libaokun
2025-11-03 8:06 ` Jan Kara
2025-10-25 3:22 ` [PATCH 06/25] ext4: introduce s_min_folio_order for future BS > PS support libaokun
2025-11-03 8:19 ` Jan Kara
2025-10-25 3:22 ` [PATCH 07/25] ext4: support large block size in ext4_calculate_overhead() libaokun
2025-11-03 8:14 ` Jan Kara
2025-11-03 14:37 ` Baokun Li
2025-10-25 3:22 ` [PATCH 08/25] ext4: support large block size in ext4_readdir() libaokun
2025-11-03 8:27 ` Jan Kara
2025-10-25 3:22 ` [PATCH 09/25] ext4: add EXT4_LBLK_TO_B macro for logical block to bytes conversion libaokun
2025-11-03 8:21 ` Jan Kara [this message]
2025-10-25 3:22 ` [PATCH 10/25] ext4: add EXT4_LBLK_TO_P and EXT4_P_TO_LBLK for block/page conversion libaokun
2025-11-03 8:26 ` Jan Kara
2025-11-03 14:45 ` Baokun Li
2025-11-05 8:27 ` Jan Kara
2025-10-25 3:22 ` [PATCH 11/25] ext4: support large block size in ext4_mb_load_buddy_gfp() libaokun
2025-11-05 8:46 ` Jan Kara
2025-10-25 3:22 ` [PATCH 12/25] ext4: support large block size in ext4_mb_get_buddy_page_lock() libaokun
2025-11-05 9:13 ` Jan Kara
2025-11-05 9:44 ` Baokun Li
2025-10-25 3:22 ` [PATCH 13/25] ext4: support large block size in ext4_mb_init_cache() libaokun
2025-11-05 9:18 ` Jan Kara
2025-10-25 3:22 ` [PATCH 14/25] ext4: prepare buddy cache inode for BS > PS with large folios libaokun
2025-11-05 9:19 ` Jan Kara
2025-10-25 3:22 ` [PATCH 15/25] ext4: rename 'page' references to 'folio' in multi-block allocator libaokun
2025-11-05 9:21 ` Jan Kara
2025-10-25 3:22 ` [PATCH 16/25] ext4: support large block size in ext4_mpage_readpages() libaokun
2025-11-05 9:26 ` Jan Kara
2025-10-25 3:22 ` [PATCH 17/25] ext4: support large block size in ext4_block_write_begin() libaokun
2025-11-05 9:28 ` Jan Kara
2025-10-25 3:22 ` [PATCH 18/25] ext4: support large block size in mpage_map_and_submit_buffers() libaokun
2025-11-05 9:30 ` Jan Kara
2025-10-25 3:22 ` [PATCH 19/25] ext4: support large block size in mpage_prepare_extent_to_map() libaokun
2025-11-05 9:31 ` Jan Kara
2025-10-25 3:22 ` [PATCH 20/25] ext4: support large block size in __ext4_block_zero_page_range() libaokun
2025-11-05 9:33 ` Jan Kara
2025-10-25 3:22 ` [PATCH 21/25] ext4: make online defragmentation support large block size libaokun
2025-11-05 9:50 ` Jan Kara
2025-11-05 10:48 ` Zhang Yi
2025-11-05 11:28 ` Baokun Li
2025-10-25 3:22 ` [PATCH 22/25] fs/buffer: prevent WARN_ON in __alloc_pages_slowpath() when BS > PS libaokun
2025-10-25 4:45 ` Matthew Wilcox
2025-10-25 5:13 ` Darrick J. Wong
2025-10-25 6:32 ` Baokun Li
2025-10-25 7:01 ` Zhang Yi
2025-10-25 17:56 ` Matthew Wilcox
2025-10-27 2:57 ` Baokun Li
2025-10-27 7:40 ` Christoph Hellwig
2025-10-30 21:25 ` Matthew Wilcox
2025-10-31 1:47 ` Zhang Yi
2025-10-31 1:55 ` Baokun Li
2025-10-25 6:34 ` Baokun Li
2025-10-25 3:22 ` [PATCH 23/25] jbd2: " libaokun
2025-10-25 3:22 ` [PATCH 24/25] ext4: add checks for large folio incompatibilities " libaokun
2025-11-05 9:59 ` Jan Kara
2025-10-25 3:22 ` [PATCH 25/25] ext4: enable block size larger than page size libaokun
2025-11-05 10:14 ` Jan Kara
2025-11-06 2:44 ` Baokun Li
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=ejsz6cihhpg2qdxewjgq5j26dihf5m3twingzij3iow2igrilh@hvd5mvqw466d \
--to=jack@suse.cz \
--cc=adilger.kernel@dilger.ca \
--cc=chengzhihao1@huawei.com \
--cc=kernel@pankajraghav.com \
--cc=libaokun1@huawei.com \
--cc=libaokun@huaweicloud.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mcgrof@kernel.org \
--cc=tytso@mit.edu \
--cc=yangerkun@huawei.com \
--cc=yi.zhang@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