Allocate one content map file for each sub-directory under one volume, so that the cacehfilesd only needs to remove the whole sub-directory (including the content map file and backing files in the sub-directory) as usual when it's going to cull the whole sub-directory or volume. The content map file will be shared among all backing files under this same sub-directory. Signed-off-by: Jingbo Xu <jefflexu@xxxxxxxxxxxxxxxxx> --- fs/cachefiles/internal.h | 1 + fs/cachefiles/namei.c | 2 +- fs/cachefiles/volume.c | 14 ++++++++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h index 4c3ee6935811..06bde4e0e4f5 100644 --- a/fs/cachefiles/internal.h +++ b/fs/cachefiles/internal.h @@ -42,6 +42,7 @@ struct cachefiles_volume { struct fscache_volume *vcookie; /* The netfs's representation */ struct dentry *dentry; /* The volume dentry */ struct dentry *fanout[256]; /* Fanout subdirs */ + struct file *content_map[256]; /* Content map files */ }; /* diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c index 2948eea18ca2..d2d5feea64e8 100644 --- a/fs/cachefiles/namei.c +++ b/fs/cachefiles/namei.c @@ -292,7 +292,7 @@ int cachefiles_look_up_map(struct cachefiles_cache *cache, path.mnt = cache->mnt; path.dentry = dentry; - file = open_with_fake_path(&path, O_RDWR | O_LARGEFILE, + file = open_with_fake_path(&path, O_RDWR | O_LARGEFILE | O_DSYNC, d_backing_inode(dentry), cache->cache_cred); if (IS_ERR(file)) cachefiles_put_directory(dentry); diff --git a/fs/cachefiles/volume.c b/fs/cachefiles/volume.c index 89df0ba8ba5e..4decc91a8886 100644 --- a/fs/cachefiles/volume.c +++ b/fs/cachefiles/volume.c @@ -20,6 +20,7 @@ void cachefiles_acquire_volume(struct fscache_volume *vcookie) struct cachefiles_cache *cache = vcookie->cache->cache_priv; const struct cred *saved_cred; struct dentry *vdentry, *fan; + struct file *map; size_t len; char *name; bool is_new = false; @@ -73,6 +74,11 @@ void cachefiles_acquire_volume(struct fscache_volume *vcookie) if (IS_ERR(fan)) goto error_fan; volume->fanout[i] = fan; + + ret = cachefiles_look_up_map(cache, fan, &map); + if (ret) + goto error_fan; + volume->content_map[i] = map; } cachefiles_end_secure(cache, saved_cred); @@ -91,8 +97,10 @@ void cachefiles_acquire_volume(struct fscache_volume *vcookie) return; error_fan: - for (i = 0; i < 256; i++) + for (i = 0; i < 256; i++) { cachefiles_put_directory(volume->fanout[i]); + cachefiles_put_map(volume->content_map[i]); + } error_dir: cachefiles_put_directory(volume->dentry); error_name: @@ -113,8 +121,10 @@ static void __cachefiles_free_volume(struct cachefiles_volume *volume) volume->vcookie->cache_priv = NULL; - for (i = 0; i < 256; i++) + for (i = 0; i < 256; i++) { cachefiles_put_directory(volume->fanout[i]); + cachefiles_put_map(volume->content_map[i]); + } cachefiles_put_directory(volume->dentry); kfree(volume); } -- 2.27.0 -- Linux-cachefs mailing list Linux-cachefs@xxxxxxxxxx https://listman.redhat.com/mailman/listinfo/linux-cachefs