On Wed, Mar 07, 2018 at 10:21:30AM +0200, Amir Goldstein wrote: > On Tue, Mar 6, 2018 at 10:54 PM, Vivek Goyal <vgoyal@xxxxxxxxxx> wrote: > > When a metacopy file is no longer a metacopy and data has been copied up, > > remove REDIRECT xattr. Its not needed anymore. > > > > Signed-off-by: Vivek Goyal <vgoyal@xxxxxxxxxx> > > --- > > fs/overlayfs/copy_up.c | 9 +++++++++ > > 1 file changed, 9 insertions(+) > > > > diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c > > index 0c8d2755bd25..704febd2e2fa 100644 > > --- a/fs/overlayfs/copy_up.c > > +++ b/fs/overlayfs/copy_up.c > > @@ -775,6 +775,15 @@ static int ovl_copy_up_meta_inode_data(struct ovl_copy_up_ctx *c) > > if (err) > > return err; > > > > + /* > > + * A metacopy files does not need redirect xattr once data has > > + * been copied up. > > + */ > > + err = vfs_removexattr(upperpath.dentry, OVL_XATTR_REDIRECT); > > + if (err && err != -ENODATA && err != -EOPNOTSUPP) > > + return err; > > + > > + err = 0; > > ovl_set_upperdata(d_inode(c->dentry)); > > return err; > > By intuition, I would say that removing redirect should be done after setting > upperdata flag. Not sure if it really matters in real life. > Maybe when racing a lookup of a metacopy hardlink and copy up data of > an upper alias? I have taken care of races now. All the redirect operations are done under ovl_inode->lock (especially for metacopy files). I am keeping ovl_set_upperdata() in the end. This signifies that all the operations on the file (copy up and removal of metacopy xattr and removal of redirect) are done. So IMO, we should set ovl_set_upperdata() in the end and not before removal of redirect. > > Also, it would make sense to also ovl_dentry_set_redirect(c->dentry, NULL) > probably use a helper ovl_clear_redirect() for the locking. Also took care of this in next set of patches I am planning to post soon > > But that highlights a serious problem with current patches - > Access to OVL_I(inode)->redirect is protected with parent mutex in ovl_lookup() > and additionally with dentry->d_lock in ovl_rename() > That is sufficient for directories which can only have a single dentry > alias to an > inode but not at all sufficient for non-directories. Forced taking ovl_inode->lock() when redirects need to be set on non-dir and hopefully that will take care of such races. Vivek -- To unsubscribe from this list: send the line "unsubscribe linux-unionfs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html