2021-11-22 03:16:41

by Chengguang Xu

[permalink] [raw]
Subject: [RFC PATCH V6 2/7] ovl: mark overlayfs inode dirty when it has upper

From: Chengguang Xu <[email protected]>

We simply mark overlayfs inode dirty when it has upper,
it's much simpler than mark dirtiness on modification.

Signed-off-by: Chengguang Xu <[email protected]>
---
fs/overlayfs/inode.c | 4 +++-
fs/overlayfs/util.c | 1 +
2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index 1f36158c7dbe..027ffc0a2539 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -778,8 +778,10 @@ void ovl_inode_init(struct inode *inode, struct ovl_inode_params *oip,
{
struct inode *realinode;

- if (oip->upperdentry)
+ if (oip->upperdentry) {
OVL_I(inode)->__upperdentry = oip->upperdentry;
+ mark_inode_dirty(inode);
+ }
if (oip->lowerpath && oip->lowerpath->dentry)
OVL_I(inode)->lower = igrab(d_inode(oip->lowerpath->dentry));
if (oip->lowerdata)
diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c
index f48284a2a896..a1922af32a13 100644
--- a/fs/overlayfs/util.c
+++ b/fs/overlayfs/util.c
@@ -421,6 +421,7 @@ void ovl_inode_update(struct inode *inode, struct dentry *upperdentry)
inode->i_private = upperinode;
__insert_inode_hash(inode, (unsigned long) upperinode);
}
+ mark_inode_dirty(inode);
}

static void ovl_dir_version_inc(struct dentry *dentry, bool impurity)
--
2.27.0




2021-11-26 09:12:12

by Jan Kara

[permalink] [raw]
Subject: Re: [RFC PATCH V6 2/7] ovl: mark overlayfs inode dirty when it has upper

On Mon 22-11-21 11:00:33, Chengguang Xu wrote:
> From: Chengguang Xu <[email protected]>
>
> We simply mark overlayfs inode dirty when it has upper,
> it's much simpler than mark dirtiness on modification.
>
> Signed-off-by: Chengguang Xu <[email protected]>
> ---
> fs/overlayfs/inode.c | 4 +++-
> fs/overlayfs/util.c | 1 +
> 2 files changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
> index 1f36158c7dbe..027ffc0a2539 100644
> --- a/fs/overlayfs/inode.c
> +++ b/fs/overlayfs/inode.c
> @@ -778,8 +778,10 @@ void ovl_inode_init(struct inode *inode, struct ovl_inode_params *oip,
> {
> struct inode *realinode;
>
> - if (oip->upperdentry)
> + if (oip->upperdentry) {
> OVL_I(inode)->__upperdentry = oip->upperdentry;
> + mark_inode_dirty(inode);
> + }
> if (oip->lowerpath && oip->lowerpath->dentry)
> OVL_I(inode)->lower = igrab(d_inode(oip->lowerpath->dentry));
> if (oip->lowerdata)

Hum, does this get called only for inodes with upper inode existing? I
suppose we do not need to track inodes that were not copied up because they
cannot be dirty? I'm sorry, my knowledge of overlayfs is rather limited so
I may be missing something basic.



Honza
--
Jan Kara <[email protected]>
SUSE Labs, CR

2021-11-26 13:09:35

by Chengguang Xu

[permalink] [raw]
Subject: Re: [RFC PATCH V6 2/7] ovl: mark overlayfs inode dirty when it has upper

---- 在 星期五, 2021-11-26 17:10:07 Jan Kara <[email protected]> 撰写 ----
> On Mon 22-11-21 11:00:33, Chengguang Xu wrote:
> > From: Chengguang Xu <[email protected]>
> >
> > We simply mark overlayfs inode dirty when it has upper,
> > it's much simpler than mark dirtiness on modification.
> >
> > Signed-off-by: Chengguang Xu <[email protected]>
> > ---
> > fs/overlayfs/inode.c | 4 +++-
> > fs/overlayfs/util.c | 1 +
> > 2 files changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
> > index 1f36158c7dbe..027ffc0a2539 100644
> > --- a/fs/overlayfs/inode.c
> > +++ b/fs/overlayfs/inode.c
> > @@ -778,8 +778,10 @@ void ovl_inode_init(struct inode *inode, struct ovl_inode_params *oip,
> > {
> > struct inode *realinode;
> >
> > - if (oip->upperdentry)
> > + if (oip->upperdentry) {
> > OVL_I(inode)->__upperdentry = oip->upperdentry;
> > + mark_inode_dirty(inode);
> > + }
> > if (oip->lowerpath && oip->lowerpath->dentry)
> > OVL_I(inode)->lower = igrab(d_inode(oip->lowerpath->dentry));
> > if (oip->lowerdata)
>
> Hum, does this get called only for inodes with upper inode existing? I
> suppose we do not need to track inodes that were not copied up because they
> cannot be dirty? I'm sorry, my knowledge of overlayfs is rather limited so
> I may be missing something basic.
>

Well, as long as overly inode has upper it can be modified without copy-up,
so we need to track all overlay inodes which have upper inode.

Thanks,
Chengguang



2021-11-26 14:36:02

by Jan Kara

[permalink] [raw]
Subject: Re: [RFC PATCH V6 2/7] ovl: mark overlayfs inode dirty when it has upper

On Fri 26-11-21 21:06:10, Chengguang Xu wrote:
> ---- 在 星期五, 2021-11-26 17:10:07 Jan Kara <[email protected]> 撰写 ----
> > On Mon 22-11-21 11:00:33, Chengguang Xu wrote:
> > > From: Chengguang Xu <[email protected]>
> > >
> > > We simply mark overlayfs inode dirty when it has upper,
> > > it's much simpler than mark dirtiness on modification.
> > >
> > > Signed-off-by: Chengguang Xu <[email protected]>
> > > ---
> > > fs/overlayfs/inode.c | 4 +++-
> > > fs/overlayfs/util.c | 1 +
> > > 2 files changed, 4 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
> > > index 1f36158c7dbe..027ffc0a2539 100644
> > > --- a/fs/overlayfs/inode.c
> > > +++ b/fs/overlayfs/inode.c
> > > @@ -778,8 +778,10 @@ void ovl_inode_init(struct inode *inode, struct ovl_inode_params *oip,
> > > {
> > > struct inode *realinode;
> > >
> > > - if (oip->upperdentry)
> > > + if (oip->upperdentry) {
> > > OVL_I(inode)->__upperdentry = oip->upperdentry;
> > > + mark_inode_dirty(inode);
> > > + }
> > > if (oip->lowerpath && oip->lowerpath->dentry)
> > > OVL_I(inode)->lower = igrab(d_inode(oip->lowerpath->dentry));
> > > if (oip->lowerdata)
> >
> > Hum, does this get called only for inodes with upper inode existing? I
> > suppose we do not need to track inodes that were not copied up because they
> > cannot be dirty? I'm sorry, my knowledge of overlayfs is rather limited so
> > I may be missing something basic.
> >
>
> Well, as long as overly inode has upper it can be modified without copy-up,
> so we need to track all overlay inodes which have upper inode.

OK, and oip->upperdentry is set only if there's upper inode, now I
understand. Thanks for explanation and feel free to add:

Reviewed-by: Jan Kara <[email protected]>

Honza
--
Jan Kara <[email protected]>
SUSE Labs, CR