2021-06-03 02:07:48

by Ritesh Harjani

[permalink] [raw]
Subject: [PATCH] ext4: Remove duplicate definition of ext4_xattr_ibody_inline_set()

ext4_xattr_ibody_inline_set() & ext4_xattr_ibody_set() have the exact
same definition. Hence remove ext4_xattr_ibody_set() and all it's call
references. Convert the callers of it to call ext4_xattr_ibody_inline_set()
instead.

Signed-off-by: Ritesh Harjani <[email protected]>
---
fs/ext4/xattr.c | 32 ++++----------------------------
1 file changed, 4 insertions(+), 28 deletions(-)

diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 10ba4b24a0aa..88bb5d0fb9fc 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -2214,30 +2214,6 @@ int ext4_xattr_ibody_inline_set(handle_t *handle, struct inode *inode,
return 0;
}

-static int ext4_xattr_ibody_set(handle_t *handle, struct inode *inode,
- struct ext4_xattr_info *i,
- struct ext4_xattr_ibody_find *is)
-{
- struct ext4_xattr_ibody_header *header;
- struct ext4_xattr_search *s = &is->s;
- int error;
-
- if (EXT4_I(inode)->i_extra_isize == 0)
- return -ENOSPC;
- error = ext4_xattr_set_entry(i, s, handle, inode, false /* is_block */);
- if (error)
- return error;
- header = IHDR(inode, ext4_raw_inode(&is->iloc));
- if (!IS_LAST_ENTRY(s->first)) {
- header->h_magic = cpu_to_le32(EXT4_XATTR_MAGIC);
- ext4_set_inode_state(inode, EXT4_STATE_XATTR);
- } else {
- header->h_magic = cpu_to_le32(0);
- ext4_clear_inode_state(inode, EXT4_STATE_XATTR);
- }
- return 0;
-}
-
static int ext4_xattr_value_same(struct ext4_xattr_search *s,
struct ext4_xattr_info *i)
{
@@ -2365,7 +2341,7 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,

if (!value) {
if (!is.s.not_found)
- error = ext4_xattr_ibody_set(handle, inode, &i, &is);
+ error = ext4_xattr_ibody_inline_set(handle, inode, &i, &is);
else if (!bs.s.not_found)
error = ext4_xattr_block_set(handle, inode, &i, &bs);
} else {
@@ -2381,7 +2357,7 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
EXT4_XATTR_MIN_LARGE_EA_SIZE(inode->i_sb->s_blocksize)))
i.in_inode = 1;
retry_inode:
- error = ext4_xattr_ibody_set(handle, inode, &i, &is);
+ error = ext4_xattr_ibody_inline_set(handle, inode, &i, &is);
if (!error && !bs.s.not_found) {
i.value = NULL;
error = ext4_xattr_block_set(handle, inode, &i, &bs);
@@ -2396,7 +2372,7 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
error = ext4_xattr_block_set(handle, inode, &i, &bs);
if (!error && !is.s.not_found) {
i.value = NULL;
- error = ext4_xattr_ibody_set(handle, inode, &i,
+ error = ext4_xattr_ibody_inline_set(handle, inode, &i,
&is);
} else if (error == -ENOSPC) {
/*
@@ -2591,7 +2567,7 @@ static int ext4_xattr_move_to_block(handle_t *handle, struct inode *inode,
goto out;

/* Remove the chosen entry from the inode */
- error = ext4_xattr_ibody_set(handle, inode, &i, is);
+ error = ext4_xattr_ibody_inline_set(handle, inode, &i, is);
if (error)
goto out;

--
2.31.1


2021-06-24 14:13:39

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH] ext4: Remove duplicate definition of ext4_xattr_ibody_inline_set()

On Thu, Jun 03, 2021 at 07:33:02AM +0530, Ritesh Harjani wrote:
> ext4_xattr_ibody_inline_set() & ext4_xattr_ibody_set() have the exact
> same definition. Hence remove ext4_xattr_ibody_set() and all it's call
> references. Convert the callers of it to call ext4_xattr_ibody_inline_set()
> instead.
>
> Signed-off-by: Ritesh Harjani <[email protected]>

Thanks, applied. I modified the patch to preserve
ext4_xattr_ibody_set() and remove ext4_xattr_ibody_inline_set()
instead, to make things clearer; otherwise people would wonder why the
non-inline functions were calling ext4_xattr_ibody_inline_set().

- Ted