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

VFS: Clean up shared mount flag propagation

The handling of mount flags in set_mnt_shared() got a little tangled
up during previous cleanups, with the following problems:

* MNT_PNODE_MASK is defined as a literal constant when it should be a
bitwise xor of other MNT_* flags
* set_mnt_shared() clears and then sets MNT_SHARED (part of MNT_PNODE_MASK)
* MNT_PNODE_MASK could use a comment in mount.h
* MNT_PNODE_MASK is a terrible name, change to MNT_SHARED_MASK

This patch fixes these problems.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

authored by

Valerie Aurora and committed by
Al Viro
495d6c9c 2ecdc82e

+12 -3
+1 -1
fs/namespace.c
··· 1538 1538 err = do_remount_sb(sb, flags, data, 0); 1539 1539 if (!err) { 1540 1540 spin_lock(&vfsmount_lock); 1541 - mnt_flags |= path->mnt->mnt_flags & MNT_PNODE_MASK; 1541 + mnt_flags |= path->mnt->mnt_flags & MNT_PROPAGATION_MASK; 1542 1542 path->mnt->mnt_flags = mnt_flags; 1543 1543 spin_unlock(&vfsmount_lock); 1544 1544 }
+1 -1
fs/pnode.h
··· 25 25 26 26 static inline void set_mnt_shared(struct vfsmount *mnt) 27 27 { 28 - mnt->mnt_flags &= ~MNT_PNODE_MASK; 28 + mnt->mnt_flags &= ~MNT_SHARED_MASK; 29 29 mnt->mnt_flags |= MNT_SHARED; 30 30 } 31 31
+10 -1
include/linux/mount.h
··· 34 34 35 35 #define MNT_SHARED 0x1000 /* if the vfsmount is a shared mount */ 36 36 #define MNT_UNBINDABLE 0x2000 /* if the vfsmount is a unbindable mount */ 37 - #define MNT_PNODE_MASK 0x3000 /* propagation flag mask */ 37 + /* 38 + * MNT_SHARED_MASK is the set of flags that should be cleared when a 39 + * mount becomes shared. Currently, this is only the flag that says a 40 + * mount cannot be bind mounted, since this is how we create a mount 41 + * that shares events with another mount. If you add a new MNT_* 42 + * flag, consider how it interacts with shared mounts. 43 + */ 44 + #define MNT_SHARED_MASK (MNT_UNBINDABLE) 45 + #define MNT_PROPAGATION_MASK (MNT_SHARED | MNT_UNBINDABLE) 46 + 38 47 39 48 struct vfsmount { 40 49 struct list_head mnt_hash;