[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YjEIj/elOQ4f9qq2@mit.edu>
Date: Tue, 15 Mar 2022 17:43:43 -0400
From: "Theodore Ts'o" <tytso@....edu>
To: Ritesh Harjani <riteshh@...ux.ibm.com>
Cc: linux-ext4@...r.kernel.org, Jan Kara <jack@...e.cz>,
Harshad Shirwadkar <harshadshirwadkar@...il.com>
Subject: Re: [PATCHv3 05/10] ext4: Return early for non-eligible fast_commit
track events
On Sat, Mar 12, 2022 at 11:09:50AM +0530, Ritesh Harjani wrote:
> Currently ext4_fc_track_template() checks, whether the trace event
> path belongs to replay or does sb has ineligible set, if yes it simply
> returns. This patch pulls those checks before calling
> ext4_fc_track_template() in the callers of ext4_fc_track_template().
>
> Signed-off-by: Ritesh Harjani <riteshh@...ux.ibm.com>
I had to add the following patch to this commit in order to prevent a
BUG when using ext4 to mount a file system without a journal. This is
because ext4_rename() calls the __ext4_fc_track_* functions directly,
and moving the checks from __ext4_fc_track_* to ext4_fc_track_* would
result in a NULL pointer dereference.
- Ted
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 39e223f7bf64..e37da8d5cd0c 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -3891,12 +3891,19 @@ static int ext4_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
ext4_fc_mark_ineligible(old.inode->i_sb,
EXT4_FC_REASON_RENAME_DIR, handle);
} else {
+ struct super_block *sb = old.inode->i_sb;
+
if (new.inode)
ext4_fc_track_unlink(handle, new.dentry);
- __ext4_fc_track_link(handle, old.inode, new.dentry);
- __ext4_fc_track_unlink(handle, old.inode, old.dentry);
- if (whiteout)
- __ext4_fc_track_create(handle, whiteout, old.dentry);
+ if (test_opt2(sb, JOURNAL_FAST_COMMIT) &&
+ !(EXT4_SB(sb)->s_mount_state & EXT4_FC_REPLAY) &&
+ !(ext4_test_mount_flag(sb, EXT4_MF_FC_INELIGIBLE))) {
+ __ext4_fc_track_link(handle, old.inode, new.dentry);
+ __ext4_fc_track_unlink(handle, old.inode, old.dentry);
+ if (whiteout)
+ __ext4_fc_track_create(handle, whiteout,
+ old.dentry);
+ }
}
if (new.inode) {
Powered by blists - more mailing lists