public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
Cc: linux-ext4@vger.kernel.org, tytso@mit.edu, jack@suse.cz,
	harshads@google.com
Subject: Re: [PATCH v7 9/9] ext4: hold s_fc_lock while during fast commit
Date: Mon, 16 Dec 2024 11:50:28 +0100	[thread overview]
Message-ID: <20241216105028.nb32aqzig2wmm4md@quack3> (raw)
In-Reply-To: <20240818040356.241684-11-harshadshirwadkar@gmail.com>

On Sun 18-08-24 04:03:56, Harshad Shirwadkar wrote:
> Leaving s_fc_lock in between during commit in ext4_fc_perform_commit()
> function leaves room for subtle concurrency bugs where ext4_fc_del() may
> delete an inode from the fast commit list, leaving list in an inconsistent
> state. Also, this patch converts s_fc_lock to mutex type so that it can be
> held when kmem_cache_* functions are called.
> 
> Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>

This would be easier to review if you split the patch into two - one for
mindless conversion of a spinlock into a mutex and another one for the
change when the lock is held which can have non-trivial effects.

Otherwise the patch looks good, just one nit below. With that fixed feel
free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

> @@ -1010,26 +1011,22 @@ __releases(&sbi->s_fc_lock)
^^ the sparse annotation with __acquires, __releases needs updating as
well

>  	list_for_each_entry_safe(fc_dentry, fc_dentry_n,
>  				 &sbi->s_fc_dentry_q[FC_Q_MAIN], fcd_list) {
>  		if (fc_dentry->fcd_op != EXT4_FC_TAG_CREAT) {
> -			spin_unlock(&sbi->s_fc_lock);
> -			if (!ext4_fc_add_dentry_tlv(sb, crc, fc_dentry)) {
> -				ret = -ENOSPC;
> -				goto lock_and_exit;
> -			}
> -			spin_lock(&sbi->s_fc_lock);
> +			if (!ext4_fc_add_dentry_tlv(sb, crc, fc_dentry))
> +				return -ENOSPC;
>  			continue;
>  		}
>  		/*
>  		 * With fcd_dilist we need not loop in sbi->s_fc_q to get the
> -		 * corresponding inode pointer
> +		 * corresponding inode. Also, the corresponding inode could have been
> +		 * deleted, in which case, we don't need to do anything.
>  		 */
> -		WARN_ON(list_empty(&fc_dentry->fcd_dilist));
> +		if (list_empty(&fc_dentry->fcd_dilist))
> +			continue;
>  		ei = list_first_entry(&fc_dentry->fcd_dilist,
>  				struct ext4_inode_info, i_fc_dilist);
>  		inode = &ei->vfs_inode;
>  		WARN_ON(inode->i_ino != fc_dentry->fcd_ino);
>  
> -		spin_unlock(&sbi->s_fc_lock);
> -
>  		/*
>  		 * We first write the inode and then the create dirent. This
>  		 * allows the recovery code to create an unnamed inode first

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  reply	other threads:[~2024-12-16 10:50 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-18  4:03 [PATCH] ext4: convert i_fc_lock to spinlock Harshad Shirwadkar
2024-08-18  4:03 ` [PATCH v7 0/9] Ext4 Fast Commit Performance Patchset Harshad Shirwadkar
2024-08-18  4:49   ` harshad shirwadkar
2024-08-18  4:03 ` [PATCH v7 1/9] ext4: convert i_fc_lock to spinlock Harshad Shirwadkar
2024-08-18  4:03 ` [PATCH v7 2/9] ext4: for committing inode, make ext4_fc_track_inode wait Harshad Shirwadkar
2024-12-12 22:00   ` Jan Kara
2024-12-13 15:10     ` Jan Kara
2025-04-14 16:57     ` harshad shirwadkar
2024-08-18  4:03 ` [PATCH v7 3/9] ext4: mark inode dirty before grabbing i_data_sem in ext4_setattr Harshad Shirwadkar
2024-12-12 21:57   ` Jan Kara
2024-08-18  4:03 ` [PATCH v7 4/9] ext4: rework fast commit commit path Harshad Shirwadkar
2024-12-13 15:12   ` Jan Kara
2024-08-18  4:03 ` [PATCH v7 5/9] ext4: drop i_fc_updates from inode fc info Harshad Shirwadkar
2024-08-18  4:03 ` [PATCH v7 6/9] ext4: update code documentation Harshad Shirwadkar
2024-12-13 15:15   ` Jan Kara
2024-08-18  4:03 ` [PATCH v7 7/9] ext4: temporarily elevate commit thread priority Harshad Shirwadkar
2024-08-18  4:03 ` [PATCH v7 8/9] ext4: make fast commit ineligible on ext4_reserve_inode_write failure Harshad Shirwadkar
2024-12-16 10:40   ` Jan Kara
2024-08-18  4:03 ` [PATCH v7 9/9] ext4: hold s_fc_lock while during fast commit Harshad Shirwadkar
2024-12-16 10:50   ` Jan Kara [this message]
2025-01-13 14:16   ` Baokun Li
2025-04-14 16:59     ` 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=20241216105028.nb32aqzig2wmm4md@quack3 \
    --to=jack@suse.cz \
    --cc=harshads@google.com \
    --cc=harshadshirwadkar@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox