mirror of https://gitee.com/openkylin/linux.git
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>
This commit is contained in:
parent
c6fe625493
commit
6e88256e19
|
@ -459,12 +459,10 @@ static int ovl_parse_opt(char *opt, struct ovl_config *config)
|
||||||
#define OVL_WORKDIR_NAME "work"
|
#define OVL_WORKDIR_NAME "work"
|
||||||
#define OVL_INDEXDIR_NAME "index"
|
#define OVL_INDEXDIR_NAME "index"
|
||||||
|
|
||||||
static struct dentry *ovl_workdir_create(struct super_block *sb,
|
static struct dentry *ovl_workdir_create(struct ovl_fs *ufs,
|
||||||
struct ovl_fs *ufs,
|
|
||||||
struct dentry *dentry,
|
|
||||||
const char *name, bool persist)
|
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 vfsmount *mnt = ufs->upper_mnt;
|
||||||
struct dentry *work;
|
struct dentry *work;
|
||||||
int err;
|
int err;
|
||||||
|
@ -479,7 +477,7 @@ static struct dentry *ovl_workdir_create(struct super_block *sb,
|
||||||
locked = true;
|
locked = true;
|
||||||
|
|
||||||
retry:
|
retry:
|
||||||
work = lookup_one_len(name, dentry, strlen(name));
|
work = lookup_one_len(name, ufs->workbasedir, strlen(name));
|
||||||
|
|
||||||
if (!IS_ERR(work)) {
|
if (!IS_ERR(work)) {
|
||||||
struct iattr attr = {
|
struct iattr attr = {
|
||||||
|
@ -550,7 +548,6 @@ static struct dentry *ovl_workdir_create(struct super_block *sb,
|
||||||
out_err:
|
out_err:
|
||||||
pr_warn("overlayfs: failed to create directory %s/%s (errno: %i); mounting read-only\n",
|
pr_warn("overlayfs: failed to create directory %s/%s (errno: %i); mounting read-only\n",
|
||||||
ufs->config.workdir, name, -err);
|
ufs->config.workdir, name, -err);
|
||||||
sb->s_flags |= MS_RDONLY;
|
|
||||||
work = NULL;
|
work = NULL;
|
||||||
goto out_unlock;
|
goto out_unlock;
|
||||||
}
|
}
|
||||||
|
@ -919,14 +916,12 @@ static int ovl_get_upper(struct ovl_fs *ufs, struct path *upperpath)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ovl_get_workdir(struct super_block *sb, struct ovl_fs *ufs,
|
static int ovl_get_workdir(struct ovl_fs *ufs, struct path *workpath)
|
||||||
struct path *workpath)
|
|
||||||
{
|
{
|
||||||
struct dentry *temp;
|
struct dentry *temp;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
ufs->workdir = ovl_workdir_create(sb, ufs, ufs->workbasedir,
|
ufs->workdir = ovl_workdir_create(ufs, OVL_WORKDIR_NAME, false);
|
||||||
OVL_WORKDIR_NAME, false);
|
|
||||||
if (!ufs->workdir)
|
if (!ufs->workdir)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -976,8 +971,7 @@ static int ovl_get_workdir(struct super_block *sb, struct ovl_fs *ufs,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ovl_get_indexdir(struct super_block *sb, struct ovl_fs *ufs,
|
static int ovl_get_indexdir(struct ovl_fs *ufs, struct ovl_entry *oe,
|
||||||
struct ovl_entry *oe,
|
|
||||||
struct path *upperpath)
|
struct path *upperpath)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
@ -992,8 +986,7 @@ static int ovl_get_indexdir(struct super_block *sb, struct ovl_fs *ufs,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
ufs->indexdir = ovl_workdir_create(sb, ufs, ufs->workbasedir,
|
ufs->indexdir = ovl_workdir_create(ufs, OVL_INDEXDIR_NAME, true);
|
||||||
OVL_INDEXDIR_NAME, true);
|
|
||||||
if (ufs->indexdir) {
|
if (ufs->indexdir) {
|
||||||
/* Verify upper root is index dir origin */
|
/* Verify upper root is index dir origin */
|
||||||
err = ovl_verify_origin(ufs->indexdir, ufs->upper_mnt,
|
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)
|
if (err)
|
||||||
goto out_err;
|
goto out_err;
|
||||||
|
|
||||||
err = ovl_get_workdir(sb, ufs, &workpath);
|
err = ovl_get_workdir(ufs, &workpath);
|
||||||
if (err)
|
if (err)
|
||||||
goto out_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_stack_depth = ufs->upper_mnt->mnt_sb->s_stack_depth;
|
||||||
sb->s_time_gran = ufs->upper_mnt->mnt_sb->s_time_gran;
|
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) {
|
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)
|
if (err)
|
||||||
goto out_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 */
|
/* Show index=off/on in /proc/mounts for any of the reasons above */
|
||||||
|
|
Loading…
Reference in New Issue