linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cachefiles: support multiple daemons
@ 2022-08-12  9:10 Jingbo Xu
  0 siblings, 0 replies; only message in thread
From: Jingbo Xu @ 2022-08-12  9:10 UTC (permalink / raw)
  To: dhowells, linux-cachefs; +Cc: linux-kernel, linux-fsdevel, Jingbo Xu

Currently CacheFiles can work in either the original mode caching for
network filesystems, or on-demand mode for container scenarios. Due to
the limit of singleton daemon, these two modes can not co-exist.

The current implementation can already work well in multiple daemon
mode. This patch only removes the explicit limitation, and thus enabling
the multiple daemon mdoe.

Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
---
PS:
Currently all filessytems using fscache (including network filesystems
and erofs) call fscache_acquire_volume() with @cache_name is NULL, and
thus they will be bound to the first registered cache. In this case, if
the first registered cache is in the original mode, mounting erofs will
fail since the boudn cache is not in on-demand mode.

This can be fixed by specifying the name of the cache to be bound when
calling fscache_acquire_volume(). Or adds a flag field to
fscache_acquire_volume(), specifying if the caller wants to bind a cache
in on-demand mode or not.

---
 fs/cachefiles/daemon.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
index aa4efcabb5e3..a4f70516d250 100644
--- a/fs/cachefiles/daemon.c
+++ b/fs/cachefiles/daemon.c
@@ -44,8 +44,6 @@ static int cachefiles_daemon_tag(struct cachefiles_cache *, char *);
 static int cachefiles_daemon_bind(struct cachefiles_cache *, char *);
 static void cachefiles_daemon_unbind(struct cachefiles_cache *);
 
-static unsigned long cachefiles_open;
-
 const struct file_operations cachefiles_daemon_fops = {
 	.owner		= THIS_MODULE,
 	.open		= cachefiles_daemon_open,
@@ -95,16 +93,10 @@ static int cachefiles_daemon_open(struct inode *inode, struct file *file)
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
 
-	/* the cachefiles device may only be open once at a time */
-	if (xchg(&cachefiles_open, 1) == 1)
-		return -EBUSY;
-
 	/* allocate a cache record */
 	cache = kzalloc(sizeof(struct cachefiles_cache), GFP_KERNEL);
-	if (!cache) {
-		cachefiles_open = 0;
+	if (!cache)
 		return -ENOMEM;
-	}
 
 	mutex_init(&cache->daemon_mutex);
 	init_waitqueue_head(&cache->daemon_pollwq);
@@ -169,7 +161,6 @@ void cachefiles_put_unbind_pincount(struct cachefiles_cache *cache)
 {
 	if (refcount_dec_and_test(&cache->unbind_pincount)) {
 		cachefiles_daemon_unbind(cache);
-		cachefiles_open = 0;
 		kfree(cache);
 	}
 }
-- 
2.24.4


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-08-12  9:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-12  9:10 [PATCH] cachefiles: support multiple daemons Jingbo Xu

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).