From: Ritesh Harjani <ritesh.list@gmail.com>
To: Jan Kara <jack@suse.cz>
Cc: Ted Tso <tytso@mit.edu>,
linux-ext4@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH 04/10] ext4: Unindent codeblock in ext4_xattr_block_set()
Date: Thu, 14 Jul 2022 17:49:59 +0530 [thread overview]
Message-ID: <20220714121959.kiyxjv7uorjup5qo@riteshh-domain> (raw)
In-Reply-To: <20220712105436.32204-4-jack@suse.cz>
On 22/07/12 12:54PM, Jan Kara wrote:
> Remove unnecessary else (and thus indentation level) from a code block
> in ext4_xattr_block_set(). It will also make following code changes
> easier. No functional changes.
The patch looks good to me. Just a note, while applying this patch on ext4-dev
tree, I found a minor conflict with below patch.
ext4: use kmemdup() to replace kmalloc + memcpy
Replace kmalloc + memcpy with kmemdup()
-ritesh
>
> CC: stable@vger.kernel.org
> Fixes: 82939d7999df ("ext4: convert to mbcache2")
> Signed-off-by: Jan Kara <jack@suse.cz>
> ---
> fs/ext4/xattr.c | 79 ++++++++++++++++++++++++-------------------------
> 1 file changed, 39 insertions(+), 40 deletions(-)
>
> diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
> index 7fc40fb1e6b3..aadfae53d055 100644
> --- a/fs/ext4/xattr.c
> +++ b/fs/ext4/xattr.c
> @@ -1850,6 +1850,8 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
> #define header(x) ((struct ext4_xattr_header *)(x))
>
> if (s->base) {
> + int offset = (char *)s->here - bs->bh->b_data;
> +
> BUFFER_TRACE(bs->bh, "get_write_access");
> error = ext4_journal_get_write_access(handle, sb, bs->bh,
> EXT4_JTR_NONE);
> @@ -1882,50 +1884,47 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
> if (error)
> goto cleanup;
> goto inserted;
> - } else {
> - int offset = (char *)s->here - bs->bh->b_data;
> + }
> + unlock_buffer(bs->bh);
> + ea_bdebug(bs->bh, "cloning");
> + s->base = kmalloc(bs->bh->b_size, GFP_NOFS);
> + error = -ENOMEM;
> + if (s->base == NULL)
> + goto cleanup;
> + memcpy(s->base, BHDR(bs->bh), bs->bh->b_size);
> + s->first = ENTRY(header(s->base)+1);
> + header(s->base)->h_refcount = cpu_to_le32(1);
> + s->here = ENTRY(s->base + offset);
> + s->end = s->base + bs->bh->b_size;
>
> - unlock_buffer(bs->bh);
> - ea_bdebug(bs->bh, "cloning");
> - s->base = kmalloc(bs->bh->b_size, GFP_NOFS);
> - error = -ENOMEM;
> - if (s->base == NULL)
> + /*
> + * If existing entry points to an xattr inode, we need
> + * to prevent ext4_xattr_set_entry() from decrementing
> + * ref count on it because the reference belongs to the
> + * original block. In this case, make the entry look
> + * like it has an empty value.
> + */
> + if (!s->not_found && s->here->e_value_inum) {
> + ea_ino = le32_to_cpu(s->here->e_value_inum);
> + error = ext4_xattr_inode_iget(inode, ea_ino,
> + le32_to_cpu(s->here->e_hash),
> + &tmp_inode);
> + if (error)
> goto cleanup;
> - memcpy(s->base, BHDR(bs->bh), bs->bh->b_size);
> - s->first = ENTRY(header(s->base)+1);
> - header(s->base)->h_refcount = cpu_to_le32(1);
> - s->here = ENTRY(s->base + offset);
> - s->end = s->base + bs->bh->b_size;
>
> - /*
> - * If existing entry points to an xattr inode, we need
> - * to prevent ext4_xattr_set_entry() from decrementing
> - * ref count on it because the reference belongs to the
> - * original block. In this case, make the entry look
> - * like it has an empty value.
> - */
> - if (!s->not_found && s->here->e_value_inum) {
> - ea_ino = le32_to_cpu(s->here->e_value_inum);
> - error = ext4_xattr_inode_iget(inode, ea_ino,
> - le32_to_cpu(s->here->e_hash),
> - &tmp_inode);
> - if (error)
> - goto cleanup;
> -
> - if (!ext4_test_inode_state(tmp_inode,
> - EXT4_STATE_LUSTRE_EA_INODE)) {
> - /*
> - * Defer quota free call for previous
> - * inode until success is guaranteed.
> - */
> - old_ea_inode_quota = le32_to_cpu(
> - s->here->e_value_size);
> - }
> - iput(tmp_inode);
> -
> - s->here->e_value_inum = 0;
> - s->here->e_value_size = 0;
> + if (!ext4_test_inode_state(tmp_inode,
> + EXT4_STATE_LUSTRE_EA_INODE)) {
> + /*
> + * Defer quota free call for previous
> + * inode until success is guaranteed.
> + */
> + old_ea_inode_quota = le32_to_cpu(
> + s->here->e_value_size);
> }
> + iput(tmp_inode);
> +
> + s->here->e_value_inum = 0;
> + s->here->e_value_size = 0;
> }
> } else {
> /* Allocate a buffer where we construct the new block. */
> --
> 2.35.3
>
next prev parent reply other threads:[~2022-07-14 12:20 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20220712104519.29887-1-jack@suse.cz>
2022-07-12 10:54 ` [PATCH 01/10] mbcache: Don't reclaim used entries Jan Kara
2022-07-14 11:47 ` Ritesh Harjani
2022-07-14 14:36 ` Jan Kara
2022-07-14 14:49 ` Ritesh Harjani
2022-07-22 13:58 ` Theodore Ts'o
2022-07-12 10:54 ` [PATCH 02/10] mbcache: Add functions to delete entry if unused Jan Kara
2022-07-14 12:15 ` Ritesh Harjani
2022-07-14 14:49 ` Jan Kara
2022-07-14 15:00 ` Ritesh Harjani
2022-07-12 10:54 ` [PATCH 03/10] ext4: Remove EA inode entry from mbcache on inode eviction Jan Kara
2022-07-12 10:54 ` [PATCH 04/10] ext4: Unindent codeblock in ext4_xattr_block_set() Jan Kara
2022-07-14 12:19 ` Ritesh Harjani [this message]
2022-07-12 10:54 ` [PATCH 05/10] ext4: Fix race when reusing xattr blocks Jan Kara
2022-07-14 12:26 ` Ritesh Harjani
2022-07-16 3:00 ` Zhihao Cheng
2022-07-25 15:23 ` Jan Kara
2022-07-26 1:14 ` Zhihao Cheng
[not found] <20220614124146.21594-1-jack@suse.cz>
2022-06-14 16:05 ` [PATCH 04/10] ext4: Unindent codeblock in ext4_xattr_block_set() 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=20220714121959.kiyxjv7uorjup5qo@riteshh-domain \
--to=ritesh.list@gmail.com \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=stable@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).