]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - fs/namespace.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial
[karo-tx-linux.git] / fs / namespace.c
index 98ebc78b21ab7cc1678f8f40da3b9343e22d5111..e6081996c9a2f9d26525740545445630c4737583 100644 (file)
@@ -324,9 +324,7 @@ int mnt_want_write(struct vfsmount *m)
        if (mnt_is_readonly(m)) {
                mnt_dec_writers(mnt);
                ret = -EROFS;
-               goto out;
        }
-out:
        preempt_enable();
        return ret;
 }
@@ -449,6 +447,10 @@ int sb_prepare_remount_readonly(struct super_block *sb)
        struct mount *mnt;
        int err = 0;
 
+       /* Racy optimization.  Recheck the counter under MNT_WRITE_HOLD */
+       if (atomic_long_read(&sb->s_remove_count))
+               return -EBUSY;
+
        br_write_lock(vfsmount_lock);
        list_for_each_entry(mnt, &sb->s_mounts, mnt_instance) {
                if (!(mnt->mnt.mnt_flags & MNT_READONLY)) {
@@ -460,6 +462,9 @@ int sb_prepare_remount_readonly(struct super_block *sb)
                        }
                }
        }
+       if (!err && atomic_long_read(&sb->s_remove_count))
+               err = -EBUSY;
+
        if (!err) {
                sb->s_readonly_remount = 1;
                smp_wmb();