2021-11-22 03:16:52

by Chengguang Xu

[permalink] [raw]
Subject: [RFC PATCH V6 4/7] ovl: set 'DONTCACHE' flag for overlayfs inode

From: Chengguang Xu <[email protected]>

Set 'DONTCACHE' flag to overlayfs inode so that
upper inode to be always synced before eviction.

Signed-off-by: Chengguang Xu <[email protected]>
---
fs/overlayfs/inode.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index 027ffc0a2539..c4472299d5df 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -791,6 +791,7 @@ void ovl_inode_init(struct inode *inode, struct ovl_inode_params *oip,
ovl_copyattr(realinode, inode);
ovl_copyflags(realinode, inode);
ovl_map_ino(inode, ino, fsid);
+ d_mark_dontcache(inode);
}

static void ovl_fill_inode(struct inode *inode, umode_t mode, dev_t rdev)
--
2.27.0




2021-11-26 09:22:28

by Jan Kara

[permalink] [raw]
Subject: Re: [RFC PATCH V6 4/7] ovl: set 'DONTCACHE' flag for overlayfs inode

On Mon 22-11-21 11:00:35, Chengguang Xu wrote:
> From: Chengguang Xu <[email protected]>
>
> Set 'DONTCACHE' flag to overlayfs inode so that
> upper inode to be always synced before eviction.
>
> Signed-off-by: Chengguang Xu <[email protected]>
> ---
> fs/overlayfs/inode.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
> index 027ffc0a2539..c4472299d5df 100644
> --- a/fs/overlayfs/inode.c
> +++ b/fs/overlayfs/inode.c
> @@ -791,6 +791,7 @@ void ovl_inode_init(struct inode *inode, struct ovl_inode_params *oip,
> ovl_copyattr(realinode, inode);
> ovl_copyflags(realinode, inode);
> ovl_map_ino(inode, ino, fsid);
> + d_mark_dontcache(inode);
> }

Doesn't this effectively disable dcache for overlayfs dentries? I mean e.g.
whenever overlayfs file is closed, we will drop its dentry & inode from the
cache. Upper and lower inodes / dentries stay in cache so no disk access
should be needed to reconstruct overlayfs dentry & inode but still it may
be a bit costly? I guess others more familiar with overlayfs have to judge.

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