All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ritesh Harjani <riteshh@linux.ibm.com>
To: "Theodore Ts'o" <tytso@mit.edu>
Cc: linux-ext4@vger.kernel.org, Jan Kara <jack@suse.cz>,
	Harshad Shirwadkar <harshadshirwadkar@gmail.com>
Subject: Re: [PATCHv3 05/10] ext4: Return early for non-eligible fast_commit track events
Date: Wed, 16 Mar 2022 09:25:49 +0530	[thread overview]
Message-ID: <20220316035549.y2z73orqxio4nor4@riteshh-domain> (raw)
In-Reply-To: <YjEIj/elOQ4f9qq2@mit.edu>

On 22/03/15 05:43PM, Theodore Ts'o wrote:
> 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@linux.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.

Ohk, yes. I had missed to see the callers of __ext4_fc_track_* functions.
Thanks for catching that. I just verified all other call sites too.
It seems only with ext4_fc_track_create/link/unlink we have __ext4_fc_track_*
family of functions and ext4_rename() is the only call site of __ext4_fc_track_*.

>
> 						- 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) {
>

Maybe since I pulled these checks out of ext4_fc_track_template(), so the right
call site for these checks are __ext4_fc_track_* family of functions, if they
are present, otherwise ext4_fc_track_* functions.

But that I can consolidate in later change series when I will start working on
improving error handling for fast commit. It seems at some places we don't
properly return the errors in case of fast commit to the callers.
And I guess in past this was discussed too [1]

So in order to fix the current BUG, this change looks good to me.

[1]: https://lore.kernel.org/linux-ext4/YdYotAyQqQgI+Oo+@mit.edu/

Thanks again for catching and fixing that.
-ritesh



  reply	other threads:[~2022-03-16  3:56 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-12  5:39 [PATCHv3 00/10] ext4: Improve FC trace events Ritesh Harjani
2022-03-12  5:39 ` [PATCHv3 01/10] ext4: Remove unused enum EXT4_FC_COMMIT_FAILED Ritesh Harjani
2022-03-12  5:39 ` [PATCHv3 02/10] ext4: Fix ext4_fc_stats trace point Ritesh Harjani
2022-03-12 15:13   ` Steven Rostedt
2022-03-17 12:01   ` Sven Schnelle
2022-03-17 14:50     ` Ritesh Harjani
2022-03-17 15:22       ` Sven Schnelle
2022-03-17 16:00         ` Steven Rostedt
2022-03-17 16:11       ` Sven Schnelle
2022-03-17 17:43         ` Nathan Chancellor
2022-03-18  4:14           ` Ritesh Harjani
2022-03-18 15:32             ` Nathan Chancellor
2022-03-17 18:38         ` Steven Rostedt
2022-03-17 18:39     ` Steven Rostedt
2022-03-18 16:30       ` Steven Rostedt
2022-03-19  5:04         ` Ritesh Harjani
2022-03-12  5:39 ` [PATCHv3 03/10] ext4: Convert ext4_fc_track_dentry type events to use event class Ritesh Harjani
2022-03-12  5:39 ` [PATCHv3 04/10] ext4: Do not call FC trace event in ext4_fc_commit() if FS does not support FC Ritesh Harjani
2022-03-12  5:39 ` [PATCHv3 05/10] ext4: Return early for non-eligible fast_commit track events Ritesh Harjani
2022-03-15 21:43   ` Theodore Ts'o
2022-03-16  3:55     ` Ritesh Harjani [this message]
2022-03-12  5:39 ` [PATCHv3 06/10] ext4: Add new trace event in ext4_fc_cleanup Ritesh Harjani
2022-03-12  5:39 ` [PATCHv3 07/10] ext4: Add transaction tid info in fc_track events Ritesh Harjani
2022-03-12  5:39 ` [PATCHv3 08/10] ext4: Add commit_tid info in jbd debug log Ritesh Harjani
2022-03-12  5:39 ` [PATCHv3 09/10] ext4: Add commit tid info in ext4_fc_commit_start/stop trace events Ritesh Harjani
2022-03-12  5:39 ` [PATCHv3 10/10] ext4: Fix remaining two trace events to use same printk convention Ritesh Harjani
2022-03-13  4:45 ` [PATCHv3 00/10] ext4: Improve FC trace events Theodore Ts'o

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=20220316035549.y2z73orqxio4nor4@riteshh-domain \
    --to=riteshh@linux.ibm.com \
    --cc=harshadshirwadkar@gmail.com \
    --cc=jack@suse.cz \
    --cc=linux-ext4@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 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.