mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-12-27 12:21:22 -05:00
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>
This commit is contained in:
@@ -526,8 +526,8 @@ int mnt_get_write_access(struct vfsmount *m)
|
||||
* the same CPU as the task that is spinning here.
|
||||
*/
|
||||
preempt_enable();
|
||||
lock_mount_hash();
|
||||
unlock_mount_hash();
|
||||
read_seqlock_excl(&mount_lock);
|
||||
read_sequnlock_excl(&mount_lock);
|
||||
preempt_disable();
|
||||
}
|
||||
}
|
||||
@@ -671,7 +671,7 @@ EXPORT_SYMBOL(mnt_drop_write_file);
|
||||
* a call to mnt_unhold_writers() in order to stop preventing write access to
|
||||
* @mnt.
|
||||
*
|
||||
* Context: This function expects lock_mount_hash() to be held serializing
|
||||
* Context: This function expects to be in mount_locked_reader scope serializing
|
||||
* setting WRITE_HOLD.
|
||||
* Return: On success 0 is returned.
|
||||
* On error, -EBUSY is returned.
|
||||
@@ -716,7 +716,8 @@ static inline int mnt_hold_writers(struct mount *mnt)
|
||||
*
|
||||
* This function can only be called after a call to mnt_hold_writers().
|
||||
*
|
||||
* Context: This function expects lock_mount_hash() to be held.
|
||||
* Context: This function expects to be in the same mount_locked_reader scope
|
||||
* as the matching mnt_hold_writers().
|
||||
*/
|
||||
static inline void mnt_unhold_writers(struct mount *mnt)
|
||||
{
|
||||
@@ -770,7 +771,8 @@ int sb_prepare_remount_readonly(struct super_block *sb)
|
||||
if (atomic_long_read(&sb->s_remove_count))
|
||||
return -EBUSY;
|
||||
|
||||
lock_mount_hash();
|
||||
guard(mount_locked_reader)();
|
||||
|
||||
for (struct mount *m = sb->s_mounts; m; m = m->mnt_next_for_sb) {
|
||||
if (!(m->mnt.mnt_flags & MNT_READONLY)) {
|
||||
err = mnt_hold_writers(m);
|
||||
@@ -787,7 +789,6 @@ int sb_prepare_remount_readonly(struct super_block *sb)
|
||||
if (test_write_hold(m))
|
||||
clear_write_hold(m);
|
||||
}
|
||||
unlock_mount_hash();
|
||||
|
||||
return err;
|
||||
}
|
||||
@@ -1226,9 +1227,8 @@ static void setup_mnt(struct mount *m, struct dentry *root)
|
||||
m->mnt_mountpoint = m->mnt.mnt_root;
|
||||
m->mnt_parent = m;
|
||||
|
||||
lock_mount_hash();
|
||||
guard(mount_locked_reader)();
|
||||
mnt_add_instance(m, s);
|
||||
unlock_mount_hash();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user