2023-03-04 02:31:53

by yebin

[permalink] [raw]
Subject: [PATCH v3 1/2] ext4: remove set 'EXT4_STATE_MAY_INLINE_DATA' flag from ext4_find_inline_data_nolock()

From: Ye Bin <[email protected]>

As only ext4_iget_extra_inode() call ext4_find_inline_data_nolock() need
to set 'EXT4_STATE_MAY_INLINE_DATA' flag. The call in ext4_write_inline_data_end()
is there only need to update i_inline_off. So move set 'EXT4_STATE_MAY_INLINE_DATA'
flag from ext4_find_inline_data_nolock() to ext4_iget_extra_inode().

Signed-off-by: Ye Bin <[email protected]>
---
fs/ext4/inline.c | 1 -
fs/ext4/inode.c | 7 ++++++-
2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
index 2b42ececa46d..1602d74b5eeb 100644
--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -159,7 +159,6 @@ int ext4_find_inline_data_nolock(struct inode *inode)
(void *)ext4_raw_inode(&is.iloc));
EXT4_I(inode)->i_inline_size = EXT4_MIN_INLINE_DATA_SIZE +
le32_to_cpu(is.s.here->e_value_size);
- ext4_set_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA);
}
out:
brelse(is.iloc.bh);
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index d251d705c276..bf0b7dea4900 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -4797,8 +4797,13 @@ static inline int ext4_iget_extra_inode(struct inode *inode,

if (EXT4_INODE_HAS_XATTR_SPACE(inode) &&
*magic == cpu_to_le32(EXT4_XATTR_MAGIC)) {
+ int err;
+
ext4_set_inode_state(inode, EXT4_STATE_XATTR);
- return ext4_find_inline_data_nolock(inode);
+ err = ext4_find_inline_data_nolock(inode);
+ if (!err && ext4_has_inline_data(inode))
+ ext4_set_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA);
+ return err;
} else
EXT4_I(inode)->i_inline_off = 0;
return 0;
--
2.31.1



2023-03-06 12:30:14

by Jan Kara

[permalink] [raw]
Subject: Re: [PATCH v3 1/2] ext4: remove set 'EXT4_STATE_MAY_INLINE_DATA' flag from ext4_find_inline_data_nolock()

On Sat 04-03-23 10:54:57, Ye Bin wrote:
> From: Ye Bin <[email protected]>
>
> As only ext4_iget_extra_inode() call ext4_find_inline_data_nolock() need
> to set 'EXT4_STATE_MAY_INLINE_DATA' flag. The call in
> ext4_write_inline_data_end() is there only need to update i_inline_off.
> So move set 'EXT4_STATE_MAY_INLINE_DATA' flag from
> ext4_find_inline_data_nolock() to ext4_iget_extra_inode().

I'd just rephrase the changelog to be more comprehensible:

The only caller of ext4_find_inline_data_nolock() that needs setting of
EXT4_STATE_MAY_INLINE_DATA flag is ext4_iget_extra_inode(). In
ext4_write_inline_data_end() we just need to update inode->i_inline_off.
Since we are going to add one more caller that does not need to set
EXT4_STATE_MAY_INLINE_DATA, just move setting of EXT4_STATE_MAY_INLINE_DATA
out to ext4_iget_extra_inode().

Otherwise feel free to add:

Reviewed-by: Jan Kara <[email protected]>

Honza

>
> Signed-off-by: Ye Bin <[email protected]>
> ---
> fs/ext4/inline.c | 1 -
> fs/ext4/inode.c | 7 ++++++-
> 2 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
> index 2b42ececa46d..1602d74b5eeb 100644
> --- a/fs/ext4/inline.c
> +++ b/fs/ext4/inline.c
> @@ -159,7 +159,6 @@ int ext4_find_inline_data_nolock(struct inode *inode)
> (void *)ext4_raw_inode(&is.iloc));
> EXT4_I(inode)->i_inline_size = EXT4_MIN_INLINE_DATA_SIZE +
> le32_to_cpu(is.s.here->e_value_size);
> - ext4_set_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA);
> }
> out:
> brelse(is.iloc.bh);
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index d251d705c276..bf0b7dea4900 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -4797,8 +4797,13 @@ static inline int ext4_iget_extra_inode(struct inode *inode,
>
> if (EXT4_INODE_HAS_XATTR_SPACE(inode) &&
> *magic == cpu_to_le32(EXT4_XATTR_MAGIC)) {
> + int err;
> +
> ext4_set_inode_state(inode, EXT4_STATE_XATTR);
> - return ext4_find_inline_data_nolock(inode);
> + err = ext4_find_inline_data_nolock(inode);
> + if (!err && ext4_has_inline_data(inode))
> + ext4_set_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA);
> + return err;
> } else
> EXT4_I(inode)->i_inline_off = 0;
> return 0;
> --
> 2.31.1
>
--
Jan Kara <[email protected]>
SUSE Labs, CR