diff options
author | Vivek Goyal <vgoyal@redhat.com> | 2018-05-11 11:49:30 -0400 |
---|---|---|
committer | Miklos Szeredi <mszeredi@redhat.com> | 2018-07-20 03:56:09 -0400 |
commit | 4f93b426ab3930952eca6c5c456c2223a3adcbf5 (patch) | |
tree | 17fd2e4590d6c1c2823598cecca0e8700ab2d09b | |
parent | 9d3dfea3d35a3235f0f1e2ce719bb4f0b696caa2 (diff) |
ovl: Copy up meta inode data from lowest data inode
So far lower could not be a meta inode. So whenever it was time to copy up
data of a meta inode, we could copy it up from top most lower dentry.
But now lower itself can be a metacopy inode. That means data copy up
needs to take place from a data inode in metacopy inode chain. Find lower
data inode in the chain and use that for data copy up.
Introduced a helper called ovl_path_lowerdata() to find the lower data
inode chain.
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
-rw-r--r-- | fs/overlayfs/copy_up.c | 13 | ||||
-rw-r--r-- | fs/overlayfs/overlayfs.h | 1 | ||||
-rw-r--r-- | fs/overlayfs/util.c | 12 |
3 files changed, 22 insertions, 4 deletions
diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c index 7e6664d6643d..d9a8d9291358 100644 --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c | |||
@@ -519,13 +519,14 @@ static int ovl_copy_up_inode(struct ovl_copy_up_ctx *c, struct dentry *temp) | |||
519 | } | 519 | } |
520 | 520 | ||
521 | if (S_ISREG(c->stat.mode) && !c->metacopy) { | 521 | if (S_ISREG(c->stat.mode) && !c->metacopy) { |
522 | struct path upperpath; | 522 | struct path upperpath, datapath; |
523 | 523 | ||
524 | ovl_path_upper(c->dentry, &upperpath); | 524 | ovl_path_upper(c->dentry, &upperpath); |
525 | BUG_ON(upperpath.dentry != NULL); | 525 | BUG_ON(upperpath.dentry != NULL); |
526 | upperpath.dentry = temp; | 526 | upperpath.dentry = temp; |
527 | 527 | ||
528 | err = ovl_copy_up_data(&c->lowerpath, &upperpath, c->stat.size); | 528 | ovl_path_lowerdata(c->dentry, &datapath); |
529 | err = ovl_copy_up_data(&datapath, &upperpath, c->stat.size); | ||
529 | if (err) | 530 | if (err) |
530 | return err; | 531 | return err; |
531 | } | 532 | } |
@@ -706,14 +707,18 @@ static bool ovl_need_meta_copy_up(struct dentry *dentry, umode_t mode, | |||
706 | /* Copy up data of an inode which was copied up metadata only in the past. */ | 707 | /* Copy up data of an inode which was copied up metadata only in the past. */ |
707 | static int ovl_copy_up_meta_inode_data(struct ovl_copy_up_ctx *c) | 708 | static int ovl_copy_up_meta_inode_data(struct ovl_copy_up_ctx *c) |
708 | { | 709 | { |
709 | struct path upperpath; | 710 | struct path upperpath, datapath; |
710 | int err; | 711 | int err; |
711 | 712 | ||
712 | ovl_path_upper(c->dentry, &upperpath); | 713 | ovl_path_upper(c->dentry, &upperpath); |
713 | if (WARN_ON(upperpath.dentry == NULL)) | 714 | if (WARN_ON(upperpath.dentry == NULL)) |
714 | return -EIO; | 715 | return -EIO; |
715 | 716 | ||
716 | err = ovl_copy_up_data(&c->lowerpath, &upperpath, c->stat.size); | 717 | ovl_path_lowerdata(c->dentry, &datapath); |
718 | if (WARN_ON(datapath.dentry == NULL)) | ||
719 | return -EIO; | ||
720 | |||
721 | err = ovl_copy_up_data(&datapath, &upperpath, c->stat.size); | ||
717 | if (err) | 722 | if (err) |
718 | return err; | 723 | return err; |
719 | 724 | ||
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h index 2de8e11db81a..a59c546c10cf 100644 --- a/fs/overlayfs/overlayfs.h +++ b/fs/overlayfs/overlayfs.h | |||
@@ -217,6 +217,7 @@ bool ovl_dentry_weird(struct dentry *dentry); | |||
217 | enum ovl_path_type ovl_path_type(struct dentry *dentry); | 217 | enum ovl_path_type ovl_path_type(struct dentry *dentry); |
218 | void ovl_path_upper(struct dentry *dentry, struct path *path); | 218 | void ovl_path_upper(struct dentry *dentry, struct path *path); |
219 | void ovl_path_lower(struct dentry *dentry, struct path *path); | 219 | void ovl_path_lower(struct dentry *dentry, struct path *path); |
220 | void ovl_path_lowerdata(struct dentry *dentry, struct path *path); | ||
220 | enum ovl_path_type ovl_path_real(struct dentry *dentry, struct path *path); | 221 | enum ovl_path_type ovl_path_real(struct dentry *dentry, struct path *path); |
221 | struct dentry *ovl_dentry_upper(struct dentry *dentry); | 222 | struct dentry *ovl_dentry_upper(struct dentry *dentry); |
222 | struct dentry *ovl_dentry_lower(struct dentry *dentry); | 223 | struct dentry *ovl_dentry_lower(struct dentry *dentry); |
diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c index ab9a8fae0f99..32ff67fa0bfb 100644 --- a/fs/overlayfs/util.c +++ b/fs/overlayfs/util.c | |||
@@ -164,6 +164,18 @@ void ovl_path_lower(struct dentry *dentry, struct path *path) | |||
164 | } | 164 | } |
165 | } | 165 | } |
166 | 166 | ||
167 | void ovl_path_lowerdata(struct dentry *dentry, struct path *path) | ||
168 | { | ||
169 | struct ovl_entry *oe = dentry->d_fsdata; | ||
170 | |||
171 | if (oe->numlower) { | ||
172 | path->mnt = oe->lowerstack[oe->numlower - 1].layer->mnt; | ||
173 | path->dentry = oe->lowerstack[oe->numlower - 1].dentry; | ||
174 | } else { | ||
175 | *path = (struct path) { }; | ||
176 | } | ||
177 | } | ||
178 | |||
167 | enum ovl_path_type ovl_path_real(struct dentry *dentry, struct path *path) | 179 | enum ovl_path_type ovl_path_real(struct dentry *dentry, struct path *path) |
168 | { | 180 | { |
169 | enum ovl_path_type type = ovl_path_type(dentry); | 181 | enum ovl_path_type type = ovl_path_type(dentry); |