[PATCH] cachefiles: support multiple daemons

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxx>
---
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

--
Linux-cachefs mailing list
Linux-cachefs@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/linux-cachefs




[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]
  Powered by Linux