From: Ojaswin Mujoo <ojaswin@linux.ibm.com>
To: linux-ext4@vger.kernel.org, "Theodore Ts'o" <tytso@mit.edu>
Cc: John Garry <john.g.garry@oracle.com>,
dchinner@redhat.com, "Darrick J . Wong" <djwong@kernel.org>,
Ritesh Harjani <ritesh.list@gmail.com>,
linux-kernel@vger.kernel.org
Subject: [RFC v3 04/11] ext4: pass lblk and len explicitly to ext4_split_extent*()
Date: Mon, 24 Mar 2025 13:07:02 +0530 [thread overview]
Message-ID: <7b4e15e314dc4d247fc19c12f76bbbc66a23faa5.1742800203.git.ojaswin@linux.ibm.com> (raw)
In-Reply-To: <cover.1742800203.git.ojaswin@linux.ibm.com>
Since these functions only use the map to determine lblk and len of
the split, pass them explicitly. This is in preparation for making
them work with extent size hints cleanly.
No functional change in this patch.
Signed-off-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
---
fs/ext4/extents.c | 57 +++++++++++++++++++++++++----------------------
1 file changed, 30 insertions(+), 27 deletions(-)
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index c616a16a9f36..4e604ce6ce35 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -3347,7 +3347,8 @@ static struct ext4_ext_path *ext4_split_extent_at(handle_t *handle,
static struct ext4_ext_path *ext4_split_extent(handle_t *handle,
struct inode *inode,
struct ext4_ext_path *path,
- struct ext4_map_blocks *map,
+ ext4_lblk_t lblk,
+ unsigned int len,
int split_flag, int flags,
unsigned int *allocated)
{
@@ -3363,7 +3364,7 @@ static struct ext4_ext_path *ext4_split_extent(handle_t *handle,
ee_len = ext4_ext_get_actual_len(ex);
unwritten = ext4_ext_is_unwritten(ex);
- if (map->m_lblk + map->m_len < ee_block + ee_len) {
+ if (lblk + len < ee_block + ee_len) {
split_flag1 = split_flag & EXT4_EXT_MAY_ZEROOUT;
flags1 = flags | EXT4_GET_BLOCKS_PRE_IO;
if (unwritten)
@@ -3372,28 +3373,28 @@ static struct ext4_ext_path *ext4_split_extent(handle_t *handle,
if (split_flag & EXT4_EXT_DATA_VALID2)
split_flag1 |= EXT4_EXT_DATA_VALID1;
path = ext4_split_extent_at(handle, inode, path,
- map->m_lblk + map->m_len, split_flag1, flags1);
+ lblk + len, split_flag1, flags1);
if (IS_ERR(path))
return path;
/*
* Update path is required because previous ext4_split_extent_at
* may result in split of original leaf or extent zeroout.
*/
- path = ext4_find_extent(inode, map->m_lblk, path, flags);
+ path = ext4_find_extent(inode, lblk, path, flags);
if (IS_ERR(path))
return path;
depth = ext_depth(inode);
ex = path[depth].p_ext;
if (!ex) {
EXT4_ERROR_INODE(inode, "unexpected hole at %lu",
- (unsigned long) map->m_lblk);
+ (unsigned long) lblk);
ext4_free_ext_path(path);
return ERR_PTR(-EFSCORRUPTED);
}
unwritten = ext4_ext_is_unwritten(ex);
}
- if (map->m_lblk >= ee_block) {
+ if (lblk >= ee_block) {
split_flag1 = split_flag & EXT4_EXT_DATA_VALID2;
if (unwritten) {
split_flag1 |= EXT4_EXT_MARK_UNWRIT1;
@@ -3401,16 +3402,16 @@ static struct ext4_ext_path *ext4_split_extent(handle_t *handle,
EXT4_EXT_MARK_UNWRIT2);
}
path = ext4_split_extent_at(handle, inode, path,
- map->m_lblk, split_flag1, flags);
+ lblk, split_flag1, flags);
if (IS_ERR(path))
return path;
}
if (allocated) {
- if (map->m_lblk + map->m_len > ee_block + ee_len)
- *allocated = ee_len - (map->m_lblk - ee_block);
+ if (lblk + len > ee_block + ee_len)
+ *allocated = ee_len - (lblk - ee_block);
else
- *allocated = map->m_len;
+ *allocated = len;
}
ext4_ext_show_leaf(inode, path);
return path;
@@ -3658,8 +3659,8 @@ ext4_ext_convert_to_initialized(handle_t *handle, struct inode *inode,
}
fallback:
- path = ext4_split_extent(handle, inode, path, &split_map, split_flag,
- flags, NULL);
+ path = ext4_split_extent(handle, inode, path, split_map.m_lblk,
+ split_map.m_len, split_flag, flags, NULL);
if (IS_ERR(path))
return path;
out:
@@ -3699,11 +3700,11 @@ ext4_ext_convert_to_initialized(handle_t *handle, struct inode *inode,
* allocated pointer. Return an extent path pointer on success, or an error
* pointer on failure.
*/
-static struct ext4_ext_path *ext4_split_convert_extents(handle_t *handle,
- struct inode *inode,
- struct ext4_map_blocks *map,
- struct ext4_ext_path *path,
- int flags, unsigned int *allocated)
+static struct ext4_ext_path *
+ext4_split_convert_extents(handle_t *handle, struct inode *inode,
+ ext4_lblk_t lblk, unsigned int len,
+ struct ext4_ext_path *path, int flags,
+ unsigned int *allocated)
{
ext4_lblk_t eof_block;
ext4_lblk_t ee_block;
@@ -3712,12 +3713,12 @@ static struct ext4_ext_path *ext4_split_convert_extents(handle_t *handle,
int split_flag = 0, depth;
ext_debug(inode, "logical block %llu, max_blocks %u\n",
- (unsigned long long)map->m_lblk, map->m_len);
+ (unsigned long long)lblk, len);
eof_block = (EXT4_I(inode)->i_disksize + inode->i_sb->s_blocksize - 1)
>> inode->i_sb->s_blocksize_bits;
- if (eof_block < map->m_lblk + map->m_len)
- eof_block = map->m_lblk + map->m_len;
+ if (eof_block < lblk + len)
+ eof_block = lblk + len;
/*
* It is safe to convert extent to initialized via explicit
* zeroout only if extent is fully inside i_size or new_size.
@@ -3737,8 +3738,8 @@ static struct ext4_ext_path *ext4_split_convert_extents(handle_t *handle,
split_flag |= (EXT4_EXT_MARK_UNWRIT2 | EXT4_EXT_DATA_VALID2);
}
flags |= EXT4_GET_BLOCKS_PRE_IO;
- return ext4_split_extent(handle, inode, path, map, split_flag, flags,
- allocated);
+ return ext4_split_extent(handle, inode, path, lblk, len, split_flag,
+ flags, allocated);
}
static struct ext4_ext_path *
@@ -3773,7 +3774,7 @@ ext4_convert_unwritten_extents_endio(handle_t *handle, struct inode *inode,
inode->i_ino, (unsigned long long)ee_block, ee_len,
(unsigned long long)map->m_lblk, map->m_len);
#endif
- path = ext4_split_convert_extents(handle, inode, map, path,
+ path = ext4_split_convert_extents(handle, inode, map->m_lblk, map->m_len, path,
EXT4_GET_BLOCKS_CONVERT, NULL);
if (IS_ERR(path))
return path;
@@ -3837,8 +3838,9 @@ convert_initialized_extent(handle_t *handle, struct inode *inode,
(unsigned long long)ee_block, ee_len);
if (ee_block != map->m_lblk || ee_len > map->m_len) {
- path = ext4_split_convert_extents(handle, inode, map, path,
- EXT4_GET_BLOCKS_CONVERT_UNWRITTEN, NULL);
+ path = ext4_split_convert_extents(
+ handle, inode, map->m_lblk, map->m_len, path,
+ EXT4_GET_BLOCKS_CONVERT_UNWRITTEN, NULL);
if (IS_ERR(path))
return path;
@@ -3909,8 +3911,9 @@ ext4_ext_handle_unwritten_extents(handle_t *handle, struct inode *inode,
/* get_block() before submitting IO, split the extent */
if (flags & EXT4_GET_BLOCKS_PRE_IO) {
- path = ext4_split_convert_extents(handle, inode, map, path,
- flags | EXT4_GET_BLOCKS_CONVERT, allocated);
+ path = ext4_split_convert_extents(
+ handle, inode, map->m_lblk, map->m_len, path,
+ flags | EXT4_GET_BLOCKS_CONVERT, allocated);
if (IS_ERR(path))
return path;
/*
--
2.48.1
next prev parent reply other threads:[~2025-03-24 7:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-24 7:36 [RFC v3 00/11] ext4: Add extsize and forcealign support (groundwork for multi block atomic writes) Ojaswin Mujoo
2025-03-24 7:36 ` [RFC v3 01/11] ext4: add aligned allocation hint in mballoc Ojaswin Mujoo
2025-03-24 7:37 ` [RFC v3 02/11] ext4: allow inode preallocation for aligned alloc Ojaswin Mujoo
2025-03-24 7:37 ` [RFC v3 03/11] ext4: support for extsize hint using FS_IOC_FS(GET/SET)XATTR Ojaswin Mujoo
2025-03-24 7:37 ` Ojaswin Mujoo [this message]
2025-03-24 7:37 ` [RFC v3 05/11] ext4: add extsize hint support Ojaswin Mujoo
2025-03-24 7:37 ` [RFC v3 06/11] ext4: make extsize work with EOF allocations Ojaswin Mujoo
2025-03-24 7:37 ` [RFC v3 07/11] ext4: add ext4_map_blocks_extsize() wrapper to handle overwrites Ojaswin Mujoo
2025-03-24 7:37 ` [RFC v3 08/11] ext4: add forcealign support of mballoc Ojaswin Mujoo
2025-03-24 7:37 ` [RFC v3 09/11] ext4: add forcealign support to ext4_map_blocks Ojaswin Mujoo
2025-03-24 7:37 ` [RFC v3 10/11] ext4: add support for adding focealign via SETXATTR ioctl Ojaswin Mujoo
2025-03-24 7:37 ` [RFC v3 11/11] ext4: disallow unaligned deallocations on forcealign inodes Ojaswin Mujoo
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=7b4e15e314dc4d247fc19c12f76bbbc66a23faa5.1742800203.git.ojaswin@linux.ibm.com \
--to=ojaswin@linux.ibm.com \
--cc=dchinner@redhat.com \
--cc=djwong@kernel.org \
--cc=john.g.garry@oracle.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ritesh.list@gmail.com \
--cc=tytso@mit.edu \
/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
all inboxes | Powered by JetHome®