All of lore.kernel.org
 help / color / mirror / Atom feed
From: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
To: linux-ext4@vger.kernel.org
Cc: riteshh@linux.ibm.com, jack@suse.cz, tytso@mit.edu,
	Harshad Shirwadkar <harshadshirwadkar@gmail.com>
Subject: [PATCH v3 3/6] ext4: mark inode dirty before grabbing i_data_sem in ext4_setattr
Date: Tue, 19 Apr 2022 10:31:40 -0700	[thread overview]
Message-ID: <20220419173143.3564144-4-harshads@google.com> (raw)
In-Reply-To: <20220419173143.3564144-1-harshads@google.com>

From: Harshad Shirwadkar <harshadshirwadkar@gmail.com>

Mark inode dirty first and then grab i_data_sem in ext4_setattr().

Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
---
 fs/ext4/inode.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index e88940251afd..6eae0804c6fd 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -5455,11 +5455,12 @@ int ext4_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,
 					(attr->ia_size > 0 ? attr->ia_size - 1 : 0) >>
 					inode->i_sb->s_blocksize_bits);
 
-			down_write(&EXT4_I(inode)->i_data_sem);
-			EXT4_I(inode)->i_disksize = attr->ia_size;
 			rc = ext4_mark_inode_dirty(handle, inode);
 			if (!error)
 				error = rc;
+			down_write(&EXT4_I(inode)->i_data_sem);
+			EXT4_I(inode)->i_disksize = attr->ia_size;
+
 			/*
 			 * We have to update i_size under i_data_sem together
 			 * with i_disksize to avoid races with writeback code
-- 
2.36.0.rc0.470.gd361397f0d-goog


  parent reply	other threads:[~2022-04-19 17:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-19 17:31 [PATCH v3 0/6] ext4: improve commit path performance for fast commit Harshad Shirwadkar
2022-04-19 17:31 ` [PATCH v3 1/6] ext4: convert i_fc_lock to spinlock Harshad Shirwadkar
2022-04-27 15:58   ` Jan Kara
2022-04-19 17:31 ` [PATCH v3 2/6] ext4: for committing inode, make ext4_fc_track_inode wait Harshad Shirwadkar
2022-04-27 15:50   ` Jan Kara
2022-05-19 14:28     ` harshad shirwadkar
2022-05-19 16:11       ` Jan Kara
2022-04-19 17:31 ` Harshad Shirwadkar [this message]
2022-04-27 16:02   ` [PATCH v3 3/6] ext4: mark inode dirty before grabbing i_data_sem in ext4_setattr Jan Kara
2022-04-19 17:31 ` [PATCH v3 4/6] ext4: rework fast commit commit path Harshad Shirwadkar
2022-04-19 17:31 ` [PATCH v3 5/6] ext4: drop i_fc_updates from inode fc info Harshad Shirwadkar
2022-04-19 17:31 ` [PATCH v3 6/6] ext4: update code documentation Harshad Shirwadkar

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=20220419173143.3564144-4-harshads@google.com \
    --to=harshadshirwadkar@gmail.com \
    --cc=jack@suse.cz \
    --cc=linux-ext4@vger.kernel.org \
    --cc=riteshh@linux.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.