From: Miklos Szeredi <miklos@szeredi.hu>
To: Chengguang Xu <cgxu519@mykernel.net>
Cc: Miklos Szeredi <mszeredi@redhat.com>,
overlayfs <linux-unionfs@vger.kernel.org>,
Huang Jianan <huangjianan@oppo.com>
Subject: Re: [PATCH] ovl: set overlayfs inode's a_ops->direct_IO properly
Date: Thu, 7 Oct 2021 14:09:59 +0200 [thread overview]
Message-ID: <YV7jl23vPilVb3zE@miu.piliscsaba.redhat.com> (raw)
In-Reply-To: <17c469a5f3f.e5bfa83020210.6858947926351314597@mykernel.net>
On Sun, Oct 03, 2021 at 10:41:34PM +0800, Chengguang Xu wrote:
> ---- 在 星期四, 2021-09-30 20:55:54 Miklos Szeredi <miklos@szeredi.hu> 撰写 ----
> > OVL_UPPERDATA is only set after ovl_get_inode() in all callers. This
> > needs to be moved into ovl_inode_init() before calling
> > ovl_inode_set_aops() otherwise this won't work correctly for a copied
> > up file.
> >
>
> Hi Miklos,
>
> I found it's not convenient to move setting OVL_UPPERDATA into ovl_inode_init() because
If you look at the logic of the thing, then it becomes quite simple. See
following (untested) patch.
Thanks,
Miklos
---
fs/overlayfs/dir.c | 3 +--
fs/overlayfs/export.c | 5 ++---
fs/overlayfs/inode.c | 3 +++
fs/overlayfs/namei.c | 3 +--
fs/overlayfs/overlayfs.h | 1 +
5 files changed, 8 insertions(+), 7 deletions(-)
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -264,6 +264,7 @@ static int ovl_instantiate(struct dentry
struct ovl_inode_params oip = {
.upperdentry = newdentry,
.newinode = inode,
+ .metacopy = false,
};
ovl_dir_modified(dentry->d_parent, false);
@@ -287,8 +288,6 @@ static int ovl_instantiate(struct dentry
inode = ovl_get_inode(dentry->d_sb, &oip);
if (IS_ERR(inode))
return PTR_ERR(inode);
- if (inode == oip.newinode)
- ovl_set_flag(OVL_UPPERDATA, inode);
} else {
WARN_ON(ovl_inode_real(inode) != d_inode(newdentry));
dput(newdentry);
--- a/fs/overlayfs/export.c
+++ b/fs/overlayfs/export.c
@@ -290,7 +290,8 @@ static struct dentry *ovl_obtain_alias(s
struct ovl_inode_params oip = {
.lowerpath = lowerpath,
.index = index,
- .numlower = !!lower
+ .numlower = !!lower,
+ .metacopy = false, /* No NFS export support for metacopy yet */
};
/* We get overlay directory dentries with ovl_lookup_real() */
@@ -304,8 +305,6 @@ static struct dentry *ovl_obtain_alias(s
return ERR_CAST(inode);
}
- if (upper)
- ovl_set_flag(OVL_UPPERDATA, inode);
dentry = d_find_any_alias(inode);
if (dentry)
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -1155,6 +1155,9 @@ struct inode *ovl_get_inode(struct super
ino = realinode->i_ino;
fsid = lowerpath->layer->fsid;
}
+ if (upperdentry && !oip->metacopy)
+ ovl_set_flag(OVL_UPPERDATA, inode);
+
ovl_fill_inode(inode, realinode->i_mode, realinode->i_rdev);
ovl_inode_init(inode, oip, ino, fsid);
--- a/fs/overlayfs/namei.c
+++ b/fs/overlayfs/namei.c
@@ -1093,14 +1093,13 @@ struct dentry *ovl_lookup(struct inode *
.redirect = upperredirect,
.lowerdata = (ctr > 1 && !d.is_dir) ?
stack[ctr - 1].dentry : NULL,
+ .metacopy = uppermetacopy,
};
inode = ovl_get_inode(dentry->d_sb, &oip);
err = PTR_ERR(inode);
if (IS_ERR(inode))
goto out_free_oe;
- if (upperdentry && !uppermetacopy)
- ovl_set_flag(OVL_UPPERDATA, inode);
}
ovl_dentry_update_reval(dentry, upperdentry,
--- a/fs/overlayfs/overlayfs.h
+++ b/fs/overlayfs/overlayfs.h
@@ -507,6 +507,7 @@ struct ovl_inode_params {
struct dentry *upperdentry;
struct ovl_path *lowerpath;
bool index;
+ bool metacopy;
unsigned int numlower;
char *redirect;
struct dentry *lowerdata;
next prev parent reply other threads:[~2021-10-07 12:10 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-28 12:47 [PATCH] ovl: set overlayfs inode's a_ops->direct_IO properly Chengguang Xu
2021-09-30 6:52 ` Huang Jianan
2021-09-30 6:54 ` Chengguang Xu
2021-09-30 8:02 ` Miklos Szeredi
2021-09-30 8:11 ` Huang Jianan
2021-09-30 12:55 ` Miklos Szeredi
2021-10-03 14:41 ` Chengguang Xu
2021-10-07 12:09 ` Miklos Szeredi [this message]
2021-10-12 7:41 ` Chengguang Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YV7jl23vPilVb3zE@miu.piliscsaba.redhat.com \
--to=miklos@szeredi.hu \
--cc=cgxu519@mykernel.net \
--cc=huangjianan@oppo.com \
--cc=linux-unionfs@vger.kernel.org \
--cc=mszeredi@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).