All of lore.kernel.org
 help / color / mirror / Atom feed
From: harshad shirwadkar <harshadshirwadkar@gmail.com>
To: Xin Yin <yinxin.x@bytedance.com>
Cc: "Theodore Y. Ts'o" <tytso@mit.edu>,
	Andreas Dilger <adilger.kernel@dilger.ca>,
	Ext4 Developers List <linux-ext4@vger.kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] ext4: fast commit may miss file actions
Date: Fri, 7 Jan 2022 12:14:38 -0800	[thread overview]
Message-ID: <CAD+ocbxUaQMjhOof-zphqYs2MvtqtM5dLxmfxmRGrj2sORZ+sQ@mail.gmail.com> (raw)
In-Reply-To: <20220107121215.1912-3-yinxin.x@bytedance.com>

Makes sense. With this change, we don't really need
EXT4_MF_FC_COMMITTING flag anymore. So, we can drop it. But other than
that, this patch looks good.

Reviewed-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>

On Fri, Jan 7, 2022 at 4:13 AM Xin Yin <yinxin.x@bytedance.com> wrote:
>
> in the follow scenario:
> 1. jbd start transaction n
> 2. task A get new handle for transaction n+1
> 3. task A do some actions and add inode to FC_Q_MAIN fc_q
> 4. jbd complete transaction n and clear FC_Q_MAIN fc_q
> 5. task A call fsync
>
> fast commit will lost the file actions during a full commit.
>
> we should also add updates to staging queue during a full commit.
> and in ext4_fc_cleanup(), when reset a inode's fc track range, check
> it's i_sync_tid, if it bigger than current transaction tid, do not
> rest it, or we will lost the track range.
>
> Signed-off-by: Xin Yin <yinxin.x@bytedance.com>
> ---
>  fs/ext4/fast_commit.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c
> index 3673d4798af3..4cea92aec7c4 100644
> --- a/fs/ext4/fast_commit.c
> +++ b/fs/ext4/fast_commit.c
> @@ -365,7 +365,8 @@ static int ext4_fc_track_template(
>         spin_lock(&sbi->s_fc_lock);
>         if (list_empty(&EXT4_I(inode)->i_fc_list))
>                 list_add_tail(&EXT4_I(inode)->i_fc_list,
> -                               (ext4_test_mount_flag(inode->i_sb, EXT4_MF_FC_COMMITTING)) ?
> +                               (sbi->s_journal->j_flags & JBD2_FULL_COMMIT_ONGOING ||
> +                                sbi->s_journal->j_flags & JBD2_FAST_COMMIT_ONGOING) ?
>                                 &sbi->s_fc_q[FC_Q_STAGING] :
>                                 &sbi->s_fc_q[FC_Q_MAIN]);
>         spin_unlock(&sbi->s_fc_lock);
> @@ -418,7 +419,8 @@ static int __track_dentry_update(struct inode *inode, void *arg, bool update)
>         node->fcd_name.len = dentry->d_name.len;
>
>         spin_lock(&sbi->s_fc_lock);
> -       if (ext4_test_mount_flag(inode->i_sb, EXT4_MF_FC_COMMITTING))
> +       if (sbi->s_journal->j_flags & JBD2_FULL_COMMIT_ONGOING ||
> +               sbi->s_journal->j_flags & JBD2_FAST_COMMIT_ONGOING)
>                 list_add_tail(&node->fcd_list,
>                                 &sbi->s_fc_dentry_q[FC_Q_STAGING]);
>         else
> @@ -1202,7 +1204,8 @@ static void ext4_fc_cleanup(journal_t *journal, int full, tid_t tid)
>                 list_del_init(&iter->i_fc_list);
>                 ext4_clear_inode_state(&iter->vfs_inode,
>                                        EXT4_STATE_FC_COMMITTING);
> -               ext4_fc_reset_inode(&iter->vfs_inode);
> +               if (iter->i_sync_tid <= tid)
> +                       ext4_fc_reset_inode(&iter->vfs_inode);
>                 /* Make sure EXT4_STATE_FC_COMMITTING bit is clear */
>                 smp_mb();
>  #if (BITS_PER_LONG < 64)
> --
> 2.20.1
>

  reply	other threads:[~2022-01-07 20:14 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-07 12:12 [PATCH 0/2] ext4: fix issues when fast commit work with jbd Xin Yin
2022-01-07 12:12 ` [PATCH 1/2] ext4: fast commit may not fallback for ineligible commit Xin Yin
2022-01-07 20:09   ` harshad shirwadkar
2022-01-09  7:41   ` kernel test robot
2022-01-10  9:23     ` Dan Carpenter
2022-01-10  9:23     ` Dan Carpenter
2022-01-11  3:13     ` [External] " Xin Yin
2022-01-11  3:13       ` Xin Yin
2022-01-13  4:17       ` harshad shirwadkar
2022-01-13  4:17         ` harshad shirwadkar
2022-01-13  6:53         ` Xin Yin
2022-01-13  6:53           ` Xin Yin
2022-01-13  8:59           ` riteshh
2022-01-13  8:59             ` riteshh
2022-01-13  9:26             ` Xin Yin
2022-01-13  9:26               ` Xin Yin
2022-01-13 13:12               ` riteshh
2022-01-13 13:12                 ` riteshh
2022-01-13 16:27                 ` harshad shirwadkar
2022-01-13 16:27                   ` harshad shirwadkar
2022-01-14  4:44                 ` Xin Yin
2022-01-14  4:44                   ` Xin Yin
2022-01-07 12:12 ` [PATCH 2/2] ext4: fast commit may miss file actions Xin Yin
2022-01-07 20:14   ` harshad shirwadkar [this message]
2022-01-09  3:06     ` [External] " Xin Yin
2022-01-07 20:15 ` [PATCH 0/2] ext4: fix issues when fast commit work with jbd 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=CAD+ocbxUaQMjhOof-zphqYs2MvtqtM5dLxmfxmRGrj2sORZ+sQ@mail.gmail.com \
    --to=harshadshirwadkar@gmail.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tytso@mit.edu \
    --cc=yinxin.x@bytedance.com \
    /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.