Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

WRITE_HOLD machinery: no need for to bump mount_lock seqcount

... neither for insertion into the list of instances, nor for
mnt_{un,}hold_writers(), nor for mnt_get_write_access() deciding
to be nice to RT during a busy-wait loop - all of that only needs
the spinlock side of mount_lock.

IOW, it's mount_locked_reader, not mount_writer.

Clarify the comment re locking rules for mnt_unhold_writers() - it's
not just that mount_lock needs to be held when calling that, it must
have been held all along since the matching mnt_hold_writers().

Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro 1e414adf 3371fa2f

+8 -8
+8 -8
fs/namespace.c
··· 526 526 * the same CPU as the task that is spinning here. 527 527 */ 528 528 preempt_enable(); 529 - lock_mount_hash(); 530 - unlock_mount_hash(); 529 + read_seqlock_excl(&mount_lock); 530 + read_sequnlock_excl(&mount_lock); 531 531 preempt_disable(); 532 532 } 533 533 } ··· 671 671 * a call to mnt_unhold_writers() in order to stop preventing write access to 672 672 * @mnt. 673 673 * 674 - * Context: This function expects lock_mount_hash() to be held serializing 674 + * Context: This function expects to be in mount_locked_reader scope serializing 675 675 * setting WRITE_HOLD. 676 676 * Return: On success 0 is returned. 677 677 * On error, -EBUSY is returned. ··· 716 716 * 717 717 * This function can only be called after a call to mnt_hold_writers(). 718 718 * 719 - * Context: This function expects lock_mount_hash() to be held. 719 + * Context: This function expects to be in the same mount_locked_reader scope 720 + * as the matching mnt_hold_writers(). 720 721 */ 721 722 static inline void mnt_unhold_writers(struct mount *mnt) 722 723 { ··· 771 770 if (atomic_long_read(&sb->s_remove_count)) 772 771 return -EBUSY; 773 772 774 - lock_mount_hash(); 773 + guard(mount_locked_reader)(); 774 + 775 775 for (struct mount *m = sb->s_mounts; m; m = m->mnt_next_for_sb) { 776 776 if (!(m->mnt.mnt_flags & MNT_READONLY)) { 777 777 err = mnt_hold_writers(m); ··· 789 787 if (test_write_hold(m)) 790 788 clear_write_hold(m); 791 789 } 792 - unlock_mount_hash(); 793 790 794 791 return err; 795 792 } ··· 1227 1226 m->mnt_mountpoint = m->mnt.mnt_root; 1228 1227 m->mnt_parent = m; 1229 1228 1230 - lock_mount_hash(); 1229 + guard(mount_locked_reader)(); 1231 1230 mnt_add_instance(m, s); 1232 - unlock_mount_hash(); 1233 1231 } 1234 1232 1235 1233 /**