Skip to content

Commit 1e414ad

Browse files
author
Al Viro
committed
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 <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent 3371fa2 commit 1e414ad

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

fs/namespace.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,8 @@ int mnt_get_write_access(struct vfsmount *m)
526526
* the same CPU as the task that is spinning here.
527527
*/
528528
preempt_enable();
529-
lock_mount_hash();
530-
unlock_mount_hash();
529+
read_seqlock_excl(&mount_lock);
530+
read_sequnlock_excl(&mount_lock);
531531
preempt_disable();
532532
}
533533
}
@@ -671,7 +671,7 @@ EXPORT_SYMBOL(mnt_drop_write_file);
671671
* a call to mnt_unhold_writers() in order to stop preventing write access to
672672
* @mnt.
673673
*
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
675675
* setting WRITE_HOLD.
676676
* Return: On success 0 is returned.
677677
* On error, -EBUSY is returned.
@@ -716,7 +716,8 @@ static inline int mnt_hold_writers(struct mount *mnt)
716716
*
717717
* This function can only be called after a call to mnt_hold_writers().
718718
*
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().
720721
*/
721722
static inline void mnt_unhold_writers(struct mount *mnt)
722723
{
@@ -770,7 +771,8 @@ int sb_prepare_remount_readonly(struct super_block *sb)
770771
if (atomic_long_read(&sb->s_remove_count))
771772
return -EBUSY;
772773

773-
lock_mount_hash();
774+
guard(mount_locked_reader)();
775+
774776
for (struct mount *m = sb->s_mounts; m; m = m->mnt_next_for_sb) {
775777
if (!(m->mnt.mnt_flags & MNT_READONLY)) {
776778
err = mnt_hold_writers(m);
@@ -787,7 +789,6 @@ int sb_prepare_remount_readonly(struct super_block *sb)
787789
if (test_write_hold(m))
788790
clear_write_hold(m);
789791
}
790-
unlock_mount_hash();
791792

792793
return err;
793794
}
@@ -1226,9 +1227,8 @@ static void setup_mnt(struct mount *m, struct dentry *root)
12261227
m->mnt_mountpoint = m->mnt.mnt_root;
12271228
m->mnt_parent = m;
12281229

1229-
lock_mount_hash();
1230+
guard(mount_locked_reader)();
12301231
mnt_add_instance(m, s);
1231-
unlock_mount_hash();
12321232
}
12331233

12341234
/**

0 commit comments

Comments
 (0)