diff options
author | Miklos Szeredi <mszeredi@redhat.com> | 2017-11-10 09:39:15 +0100 |
---|---|---|
committer | Miklos Szeredi <mszeredi@redhat.com> | 2017-11-10 09:39:15 +0100 |
commit | 6e88256e197d2a3b5aa0d054e6e2f553469bf389 (patch) | |
tree | 23f5ce4f9a142476aa9e0a1745c555a06aa5feab /fs/overlayfs/super.c | |
parent | c6fe62549313555ed56b83bb8338383d78e768cb (diff) | |
download | linux-6e88256e197d2a3b5aa0d054e6e2f553469bf389.tar.bz2 |
ovl: reduce the number of arguments for ovl_workdir_create()
Remove "sb" and "dentry" arguments of ovl_workdir_create() and related
functions. Move setting MS_RDONLY flag to callers.
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to 'fs/overlayfs/super.c')
-rw-r--r-- | fs/overlayfs/super.c | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index c695ea569a99..c1344c8a9520 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -459,12 +459,10 @@ static int ovl_parse_opt(char *opt, struct ovl_config *config) #define OVL_WORKDIR_NAME "work" #define OVL_INDEXDIR_NAME "index" -static struct dentry *ovl_workdir_create(struct super_block *sb, - struct ovl_fs *ufs, - struct dentry *dentry, +static struct dentry *ovl_workdir_create(struct ovl_fs *ufs, const char *name, bool persist) { - struct inode *dir = dentry->d_inode; + struct inode *dir = ufs->workbasedir->d_inode; struct vfsmount *mnt = ufs->upper_mnt; struct dentry *work; int err; @@ -479,7 +477,7 @@ static struct dentry *ovl_workdir_create(struct super_block *sb, locked = true; retry: - work = lookup_one_len(name, dentry, strlen(name)); + work = lookup_one_len(name, ufs->workbasedir, strlen(name)); if (!IS_ERR(work)) { struct iattr attr = { @@ -550,7 +548,6 @@ out_dput: out_err: pr_warn("overlayfs: failed to create directory %s/%s (errno: %i); mounting read-only\n", ufs->config.workdir, name, -err); - sb->s_flags |= MS_RDONLY; work = NULL; goto out_unlock; } @@ -919,14 +916,12 @@ static int ovl_get_upper(struct ovl_fs *ufs, struct path *upperpath) return 0; } -static int ovl_get_workdir(struct super_block *sb, struct ovl_fs *ufs, - struct path *workpath) +static int ovl_get_workdir(struct ovl_fs *ufs, struct path *workpath) { struct dentry *temp; int err; - ufs->workdir = ovl_workdir_create(sb, ufs, ufs->workbasedir, - OVL_WORKDIR_NAME, false); + ufs->workdir = ovl_workdir_create(ufs, OVL_WORKDIR_NAME, false); if (!ufs->workdir) return 0; @@ -976,8 +971,7 @@ static int ovl_get_workdir(struct super_block *sb, struct ovl_fs *ufs, return 0; } -static int ovl_get_indexdir(struct super_block *sb, struct ovl_fs *ufs, - struct ovl_entry *oe, +static int ovl_get_indexdir(struct ovl_fs *ufs, struct ovl_entry *oe, struct path *upperpath) { int err; @@ -992,8 +986,7 @@ static int ovl_get_indexdir(struct super_block *sb, struct ovl_fs *ufs, goto out; } - ufs->indexdir = ovl_workdir_create(sb, ufs, ufs->workbasedir, - OVL_INDEXDIR_NAME, true); + ufs->indexdir = ovl_workdir_create(ufs, OVL_INDEXDIR_NAME, true); if (ufs->indexdir) { /* Verify upper root is index dir origin */ err = ovl_verify_origin(ufs->indexdir, ufs->upper_mnt, @@ -1188,10 +1181,13 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent) if (err) goto out_err; - err = ovl_get_workdir(sb, ufs, &workpath); + err = ovl_get_workdir(ufs, &workpath); if (err) goto out_err; + if (!ufs->workdir) + sb->s_flags |= MS_RDONLY; + sb->s_stack_depth = ufs->upper_mnt->mnt_sb->s_stack_depth; sb->s_time_gran = ufs->upper_mnt->mnt_sb->s_time_gran; @@ -1221,9 +1217,12 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent) } if (!(ovl_force_readonly(ufs)) && ufs->config.index) { - err = ovl_get_indexdir(sb, ufs, oe, &upperpath); + err = ovl_get_indexdir(ufs, oe, &upperpath); if (err) goto out_err; + + if (!ufs->indexdir) + sb->s_flags |= MS_RDONLY; } /* Show index=off/on in /proc/mounts for any of the reasons above */ |