Commit fd210b7d authored by Miklos Szeredi's avatar Miklos Szeredi

ovl: move copy up lock out

Move ovl_copy_up_start()/ovl_copy_up_end() out so that it's used for both
tempfile and workdir copy ups.
Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
parent a6fb235a
...@@ -506,36 +506,17 @@ static int ovl_do_copy_up(struct ovl_copy_up_ctx *c) ...@@ -506,36 +506,17 @@ static int ovl_do_copy_up(struct ovl_copy_up_ctx *c)
/* Should we copyup with O_TMPFILE or with workdir? */ /* Should we copyup with O_TMPFILE or with workdir? */
if (S_ISREG(c->stat.mode) && ofs->tmpfile) { if (S_ISREG(c->stat.mode) && ofs->tmpfile) {
err = ovl_copy_up_start(c->dentry);
/* err < 0: interrupted, err > 0: raced with another copy-up */
if (unlikely(err)) {
pr_debug("ovl_copy_up_start(%pd2) = %i\n", c->dentry,
err);
if (err > 0)
err = 0;
goto out_done;
}
c->tmpfile = true; c->tmpfile = true;
err = ovl_copy_up_locked(c); return ovl_copy_up_locked(c);
ovl_copy_up_end(c->dentry);
goto out_done;
} }
err = -EIO; err = -EIO;
if (lock_rename(c->workdir, c->upperdir) != NULL) { if (lock_rename(c->workdir, c->upperdir) != NULL) {
pr_err("overlayfs: failed to lock workdir+upperdir\n"); pr_err("overlayfs: failed to lock workdir+upperdir\n");
goto out_unlock; } else {
}
if (ovl_dentry_upper(c->dentry)) {
/* Raced with another copy-up? Nothing to do, then... */
err = 0;
goto out_unlock;
}
err = ovl_copy_up_locked(c); err = ovl_copy_up_locked(c);
out_unlock:
unlock_rename(c->workdir, c->upperdir); unlock_rename(c->workdir, c->upperdir);
out_done: }
return err; return err;
} }
...@@ -580,8 +561,15 @@ static int ovl_copy_up_one(struct dentry *parent, struct dentry *dentry, ...@@ -580,8 +561,15 @@ static int ovl_copy_up_one(struct dentry *parent, struct dentry *dentry,
} }
ovl_do_check_copy_up(ctx.lowerpath.dentry); ovl_do_check_copy_up(ctx.lowerpath.dentry);
err = ovl_copy_up_start(dentry);
/* err < 0: interrupted, err > 0: raced with another copy-up */
if (unlikely(err)) {
if (err > 0)
err = 0;
} else {
err = ovl_do_copy_up(&ctx); err = ovl_do_copy_up(&ctx);
ovl_copy_up_end(dentry);
}
do_delayed_call(&done); do_delayed_call(&done);
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment