Skip to content

Commit 44d5bf1

Browse files
rhvgoyalMiklos Szeredi
authored andcommitted
ovl: Copy up only metadata during copy up where it makes sense
If it makes sense to copy up only metadata during copy up, do it. This is done for regular files which are not opened for WRITE. Right now ->metacopy is set to 0 always. Last patch in the series will remove the hard coded statement and enable metacopy feature. Signed-off-by: Vivek Goyal <vgoyal@redhat.com> Reviewed-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
1 parent bd64e57 commit 44d5bf1

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

fs/overlayfs/copy_up.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ struct ovl_copy_up_ctx {
388388
bool tmpfile;
389389
bool origin;
390390
bool indexed;
391+
bool metacopy;
391392
};
392393

393394
static int ovl_link_up(struct ovl_copy_up_ctx *c)
@@ -507,7 +508,7 @@ static int ovl_copy_up_inode(struct ovl_copy_up_ctx *c, struct dentry *temp)
507508
return err;
508509
}
509510

510-
if (S_ISREG(c->stat.mode)) {
511+
if (S_ISREG(c->stat.mode) && !c->metacopy) {
511512
struct path upperpath;
512513

513514
ovl_path_upper(c->dentry, &upperpath);
@@ -660,6 +661,26 @@ static int ovl_do_copy_up(struct ovl_copy_up_ctx *c)
660661
return err;
661662
}
662663

664+
static bool ovl_need_meta_copy_up(struct dentry *dentry, umode_t mode,
665+
int flags)
666+
{
667+
struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
668+
669+
/* TODO: Will enable metacopy in last patch of series */
670+
return false;
671+
672+
if (!ofs->config.metacopy)
673+
return false;
674+
675+
if (!S_ISREG(mode))
676+
return false;
677+
678+
if (flags && ((OPEN_FMODE(flags) & FMODE_WRITE) || (flags & O_TRUNC)))
679+
return false;
680+
681+
return true;
682+
}
683+
663684
static int ovl_copy_up_one(struct dentry *parent, struct dentry *dentry,
664685
int flags)
665686
{
@@ -681,6 +702,8 @@ static int ovl_copy_up_one(struct dentry *parent, struct dentry *dentry,
681702
if (err)
682703
return err;
683704

705+
ctx.metacopy = ovl_need_meta_copy_up(dentry, ctx.stat.mode, flags);
706+
684707
if (parent) {
685708
ovl_path_upper(parent, &parentpath);
686709
ctx.destdir = parentpath.dentry;

0 commit comments

Comments
 (0)