diff options
| author | Daniel Rosenberg <drosen@google.com> | 2016-10-26 15:29:51 -0700 |
|---|---|---|
| committer | Mister Oyster <oysterized@gmail.com> | 2017-04-13 12:32:14 +0200 |
| commit | bb843f06966b3bc37cdafb33ee71ee74cc8567c9 (patch) | |
| tree | 657576c5984d5c058ff6974f75ef48bb4b396368 /fs | |
| parent | 6f074d99806b7e079fcc62ed79f83646ae621b82 (diff) | |
mnt: Add filesystem private data to mount points
This starts to add private data associated directly
to mount points. The intent is to give filesystems
a sense of where they have come from, as a means of
letting a filesystem take different actions based on
this information.
Change-Id: Ie769d7b3bb2f5972afe05c1bf16cf88c91647ab2
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Diffstat (limited to 'fs')
| -rw-r--r-- | fs/namespace.c | 28 | ||||
| -rw-r--r-- | fs/pnode.c | 14 | ||||
| -rw-r--r-- | fs/pnode.h | 1 |
3 files changed, 42 insertions, 1 deletions
diff --git a/fs/namespace.c b/fs/namespace.c index 745e29706..0958e1769 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -671,6 +671,7 @@ int sb_prepare_remount_readonly(struct super_block *sb) static void free_vfsmnt(struct mount *mnt) { + kfree(mnt->mnt.data); kfree(mnt->mnt_devname); mnt_free_id(mnt); #ifdef CONFIG_SMP @@ -914,11 +915,21 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void if (!mnt) return ERR_PTR(-ENOMEM); + mnt->mnt.data = NULL; + if (type->alloc_mnt_data) { + mnt->mnt.data = type->alloc_mnt_data(); + if (!mnt->mnt.data) { + mnt_free_id(mnt); + free_vfsmnt(mnt); + return ERR_PTR(-ENOMEM); + } + } if (flags & MS_KERNMOUNT) mnt->mnt.mnt_flags = MNT_INTERNAL; root = mount_fs(type, flags, name, data); if (IS_ERR(root)) { + kfree(mnt->mnt.data); free_vfsmnt(mnt); return ERR_CAST(root); } @@ -945,6 +956,14 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root, if (!mnt) return ERR_PTR(-ENOMEM); + if (sb->s_op->clone_mnt_data) { + mnt->mnt.data = sb->s_op->clone_mnt_data(old->mnt.data); + if (!mnt->mnt.data) { + err = -ENOMEM; + goto out_free; + } + } + if (flag & (CL_SLAVE | CL_PRIVATE | CL_SHARED_TO_SLAVE)) mnt->mnt_group_id = 0; /* not a peer of original */ else @@ -1008,6 +1027,7 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root, return mnt; out_free: + kfree(mnt->mnt.data); free_vfsmnt(mnt); return ERR_PTR(err); } @@ -2012,8 +2032,14 @@ static int do_remount(struct path *path, int flags, int mnt_flags, err = change_mount_flags(path->mnt, flags); else if (!capable(CAP_SYS_ADMIN)) err = -EPERM; - else + else { err = do_remount_sb(sb, flags, data, 0); + namespace_lock(); + br_write_lock(&vfsmount_lock); + propagate_remount(mnt); + br_write_unlock(&vfsmount_lock); + namespace_unlock(); + } if (!err) { br_write_lock(&vfsmount_lock); mnt_flags |= mnt->mnt.mnt_flags & ~MNT_USER_SETTABLE_MASK; diff --git a/fs/pnode.c b/fs/pnode.c index 7cde7b666..5a75fcdf6 100644 --- a/fs/pnode.c +++ b/fs/pnode.c @@ -401,3 +401,17 @@ int propagate_umount(struct list_head *list) __propagate_umount(mnt); return 0; } + +int propagate_remount(struct mount *mnt) { + struct mount *m; + struct super_block *sb = mnt->mnt.mnt_sb; + int ret = 0; + + if (sb->s_op->copy_mnt_data) { + for (m = first_slave(mnt); m->mnt_slave.next != &mnt->mnt_slave_list; m = next_slave(m)) { + sb->s_op->copy_mnt_data(m->mnt.data, mnt->mnt.data); + } + } + + return ret; +} diff --git a/fs/pnode.h b/fs/pnode.h index 63341727c..c16a8ff79 100644 --- a/fs/pnode.h +++ b/fs/pnode.h @@ -39,6 +39,7 @@ int propagate_mnt(struct mount *, struct mountpoint *, struct mount *, struct list_head *); int propagate_umount(struct list_head *); int propagate_mount_busy(struct mount *, int); +int propagate_remount(struct mount *); void mnt_release_group_id(struct mount *); int get_dominating_id(struct mount *mnt, const struct path *root); unsigned int mnt_get_count(struct mount *mnt); |
