summaryrefslogtreecommitdiffstats
path: root/fs/overlayfs
diff options
context:
space:
mode:
authorAmir Goldstein <amir73il@gmail.com>2017-05-19 15:16:21 +0300
committerMiklos Szeredi <mszeredi@redhat.com>2017-07-04 22:03:18 +0200
commit02209d10709c18d552c2494df74117db09a18e05 (patch)
tree2723eb9b74069d736e264f115b8497b8e0f6cd4a /fs/overlayfs
parent7d90b853f932874f0b348858fddbd41f022179ee (diff)
downloadlinux-02209d10709c18d552c2494df74117db09a18e05.tar.bz2
ovl: factor out ovl_copy_up_inode() helper
Factor out helper for copying lower inode data and metadata to temp upper inode, that is common to copy up using O_TMPFILE and workdir. Signed-off-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to 'fs/overlayfs')
-rw-r--r--fs/overlayfs/copy_up.c46
1 files changed, 29 insertions, 17 deletions
diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
index a7941ab80c9b..81b9a44916a0 100644
--- a/fs/overlayfs/copy_up.c
+++ b/fs/overlayfs/copy_up.c
@@ -399,22 +399,11 @@ temp_err:
goto out;
}
-static int ovl_copy_up_locked(struct dentry *workdir, struct dentry *upperdir,
- struct dentry *dentry, struct path *lowerpath,
- struct kstat *stat, const char *link,
- struct kstat *pstat, bool tmpfile)
+static int ovl_copy_up_inode(struct dentry *dentry, struct dentry *temp,
+ struct path *lowerpath, struct kstat *stat)
{
- struct inode *wdir = workdir->d_inode;
- struct inode *udir = upperdir->d_inode;
- struct dentry *newdentry = NULL;
- struct dentry *temp = NULL;
int err;
- err = ovl_get_tmpfile(workdir, upperdir, dentry, stat, link, tmpfile,
- &temp);
- if (err)
- goto out;
-
if (S_ISREG(stat->mode)) {
struct path upperpath;
@@ -424,18 +413,18 @@ static int ovl_copy_up_locked(struct dentry *workdir, struct dentry *upperdir,
err = ovl_copy_up_data(lowerpath, &upperpath, stat->size);
if (err)
- goto out_cleanup;
+ return err;
}
err = ovl_copy_xattr(lowerpath->dentry, temp);
if (err)
- goto out_cleanup;
+ return err;
inode_lock(temp->d_inode);
err = ovl_set_attr(temp, stat);
inode_unlock(temp->d_inode);
if (err)
- goto out_cleanup;
+ return err;
/*
* Store identifier of lower inode in upper inode xattr to
@@ -447,9 +436,32 @@ static int ovl_copy_up_locked(struct dentry *workdir, struct dentry *upperdir,
if (S_ISDIR(stat->mode) || stat->nlink == 1) {
err = ovl_set_origin(dentry, lowerpath->dentry, temp);
if (err)
- goto out_cleanup;
+ return err;
}
+ return 0;
+}
+
+static int ovl_copy_up_locked(struct dentry *workdir, struct dentry *upperdir,
+ struct dentry *dentry, struct path *lowerpath,
+ struct kstat *stat, const char *link,
+ struct kstat *pstat, bool tmpfile)
+{
+ struct inode *wdir = workdir->d_inode;
+ struct inode *udir = upperdir->d_inode;
+ struct dentry *newdentry = NULL;
+ struct dentry *temp = NULL;
+ int err;
+
+ err = ovl_get_tmpfile(workdir, upperdir, dentry, stat, link, tmpfile,
+ &temp);
+ if (err)
+ goto out;
+
+ err = ovl_copy_up_inode(dentry, temp, lowerpath, stat);
+ if (err)
+ goto out_cleanup;
+
if (tmpfile) {
inode_lock_nested(udir, I_MUTEX_PARENT);
err = ovl_install_temp(workdir, upperdir, dentry, temp, pstat,