From: Yang Erkun <yangerkun@huawei.com>
To: linux-ext4@vger.kernel.org, tytso@mit.edu,
adilger.kernel@dilger.ca, jack@suse.cz
Cc: yi.zhang@huawei.com, libaokun1@huawei.com, yangerkun@huawei.com,
yangerkun@huaweicloud.com
Subject: [PATCH v3 3/3] ext4: cleanup for ext4_map_blocks
Date: Fri, 7 Nov 2025 19:58:10 +0800 [thread overview]
Message-ID: <20251107115810.47199-3-yangerkun@huawei.com> (raw)
In-Reply-To: <20251107115810.47199-1-yangerkun@huawei.com>
Retval from ext4_map_create_blocks means we really create some blocks,
cannot happened with m_flags without EXT4_MAP_UNWRITTEN and
EXT4_MAP_MAPPED.
Reviewed-by: Zhang Yi <yi.zhang@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Yang Erkun <yangerkun@huawei.com>
---
fs/ext4/inode.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index e8bac93ca668..3d8ada26d5cd 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -799,7 +799,13 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
down_write(&EXT4_I(inode)->i_data_sem);
retval = ext4_map_create_blocks(handle, inode, map, flags);
up_write((&EXT4_I(inode)->i_data_sem));
- if (retval > 0 && map->m_flags & EXT4_MAP_MAPPED) {
+
+ if (retval < 0)
+ ext_debug(inode, "failed with err %d\n", retval);
+ if (retval <= 0)
+ return retval;
+
+ if (map->m_flags & EXT4_MAP_MAPPED) {
ret = check_block_validity(inode, map);
if (ret != 0)
return ret;
@@ -828,12 +834,8 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
return ret;
}
}
- if (retval > 0 && (map->m_flags & EXT4_MAP_UNWRITTEN ||
- map->m_flags & EXT4_MAP_MAPPED))
- ext4_fc_track_range(handle, inode, map->m_lblk,
- map->m_lblk + map->m_len - 1);
- if (retval < 0)
- ext_debug(inode, "failed with err %d\n", retval);
+ ext4_fc_track_range(handle, inode, map->m_lblk, map->m_lblk +
+ map->m_len - 1);
return retval;
}
--
2.39.2
next prev parent reply other threads:[~2025-11-07 12:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-07 11:58 [PATCH v3 1/3] ext4: remove useless code in ext4_map_create_blocks Yang Erkun
2025-11-07 11:58 ` [PATCH v3 2/3] ext4: rename EXT4_GET_BLOCKS_PRE_IO Yang Erkun
2025-11-08 1:49 ` Baokun Li
2025-11-07 11:58 ` Yang Erkun [this message]
2025-11-08 1:54 ` [PATCH v3 3/3] ext4: cleanup for ext4_map_blocks Baokun Li
2025-11-08 1:46 ` [PATCH v3 1/3] ext4: remove useless code in ext4_map_create_blocks Baokun Li
2025-11-12 4:46 ` Zhang Yi
2025-11-12 8:30 ` yangerkun
2025-11-13 11:27 ` 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=20251107115810.47199-3-yangerkun@huawei.com \
--to=yangerkun@huawei.com \
--cc=adilger.kernel@dilger.ca \
--cc=jack@suse.cz \
--cc=libaokun1@huawei.com \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
--cc=yangerkun@huaweicloud.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