[PATCH 36/41] union-mount: Increment read-only users count for read-only layer

From: Valerie Aurora
Date: Wed Oct 21 2009 - 15:24:24 EST


Union mounts want to guarantee that the read-only layer is read-only -
and stays read-only. Use the new superblock read-only user count.

XXX - Put common code in loopback and regular mounts in a function

Signed-off-by: Valerie Aurora <vaurora@xxxxxxxxxx>
---
fs/namespace.c | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/fs/namespace.c b/fs/namespace.c
index 0280e5b..505974a 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1111,6 +1111,11 @@ static int do_umount(struct vfsmount *mnt, int flags)
spin_unlock(&vfsmount_lock);
if (retval)
security_sb_umount_busy(mnt);
+ /* If this was a union mount, we are no longer a read-only
+ * user on the underlying mount */
+ if (mnt->mnt_flags & MNT_UNION)
+ mnt->mnt_parent->mnt_sb->s_readonly_users--;
+
up_write(&namespace_sem);
release_mounts(&umount_list);
return retval;
@@ -1511,6 +1516,10 @@ static int do_loopback(struct path *path, char *old_name, int recurse,
release_mounts(&umount_list);
}

+ /* If this is a union mount, add ourselves to the readonly users */
+ if (mnt_flags & MNT_UNION)
+ mnt->mnt_parent->mnt_sb->s_readonly_users++;
+
out:
up_write(&namespace_sem);
path_put(&old_path);
@@ -1730,6 +1739,10 @@ int do_add_mount(struct vfsmount *newmnt, struct path *path,
if ((err = graft_tree(newmnt, path)))
goto unlock;

+ /* If this is a union mount, add ourselves to the readonly users */
+ if (mnt_flags & MNT_UNION)
+ newmnt->mnt_parent->mnt_sb->s_readonly_users++;
+
if (fslist) /* add to the specified expiration list */
list_add_tail(&newmnt->mnt_expire, fslist);

--
1.6.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/