From: Jingbo Xu <jefflexu@linux.alibaba.com>
To: dhowells@redhat.com, linux-cachefs@redhat.com
Cc: linux-kernel@vger.kernel.org, xiang@kernel.org
Subject: [PATCH RFC 3/9] cachefiles: allocate per-subdir content map files
Date: Tue, 2 Aug 2022 11:03:36 +0800 [thread overview]
Message-ID: <20220802030342.46302-4-jefflexu@linux.alibaba.com> (raw)
In-Reply-To: <20220802030342.46302-1-jefflexu@linux.alibaba.com>
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@linux.alibaba.com>
---
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
next prev parent reply other threads:[~2022-08-02 3:04 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-02 3:03 [RFC PATCH 0/9] cachefiles: content map Jingbo Xu
2022-08-02 3:03 ` [PATCH RFC 1/9] cachefiles: improve FSCACHE_COOKIE_NO_DATA_TO_READ optimization Jingbo Xu
2022-08-02 3:03 ` [PATCH RFC 2/9] cachefiles: add content map file helpers Jingbo Xu
2022-08-02 3:03 ` Jingbo Xu [this message]
2022-08-02 3:03 ` [PATCH RFC 4/9] cachefiles: alloc/load/save content map Jingbo Xu
2022-08-02 3:03 ` [PATCH RFC 5/9] cachefiles: mark content map on write to the backing file Jingbo Xu
2022-08-02 3:03 ` [PATCH RFC 6/9] cachefiles: check content map on read/write Jingbo Xu
2022-08-02 3:03 ` [PATCH RFC 7/9] cachefiles: free content map on invalidate Jingbo Xu
2022-08-02 3:03 ` [PATCH RFC 8/9] cachefiles: resize content map on resize Jingbo Xu
2022-08-02 3:03 ` [PATCH RFC 9/9] cachefiles: cull content map file on cull Jingbo 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=20220802030342.46302-4-jefflexu@linux.alibaba.com \
--to=jefflexu@linux.alibaba.com \
--cc=dhowells@redhat.com \
--cc=linux-cachefs@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=xiang@kernel.org \
/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
all inboxes | Powered by JetHome®