From 1da18d17cfee59a940aa9fb9d1ec00637ee48ad9 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Thu, 7 Sep 2017 11:10:22 -0700 Subject: [PATCH] scoutfs: use trylock for global server lock Shared unmount hasn't worked for a long time because we didn't have the server work woken out of blocking trying to acquire the lock. In the old lock code the wait conditions didn't test ->shutdown. dlmglue doesn't give us a reasonable way to break a caller out of a blocked lock. We could add some code to do it with a global context that'd have to wake all locks or add a call with a lock resource name, not a held lock, that'd wake that specific lock. Neither sound great. So instead we'll use trylock to get the server lock. It's guaranteed to make reasonble forward progress. The server work is already requeued with a delay to retry. While we're at it we add a global server lock instead of using the weird magical inode lock in the fs space. The server lock doesn't need keys or to participate in item cache consistency, etc. With this unmount works. All mounts will now generate regular background trylock requests. Signed-off-by: Zach Brown --- kmod/src/format.h | 1 + kmod/src/server.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/kmod/src/format.h b/kmod/src/format.h index 161b31a2..17c53a18 100644 --- a/kmod/src/format.h +++ b/kmod/src/format.h @@ -535,6 +535,7 @@ enum { #define SCOUTFS_LOCK_SCOPE_FS_ITEMS 2 #define SCOUTFS_LOCK_TYPE_GLOBAL_RENAME 1 +#define SCOUTFS_LOCK_TYPE_GLOBAL_SERVER 2 struct scoutfs_lock_name { __u8 scope; diff --git a/kmod/src/server.c b/kmod/src/server.c index d42012b0..a12da887 100644 --- a/kmod/src/server.c +++ b/kmod/src/server.c @@ -892,8 +892,9 @@ static void scoutfs_server_func(struct work_struct *work) init_waitqueue_head(&waitq); - /* lock attempt will return -ESHUTDOWN once we should not queue */ - ret = scoutfs_lock_ino(sb, DLM_LOCK_EX, 0, ~0ULL, &lock); + ret = scoutfs_lock_global(sb, DLM_LOCK_EX, SCOUTFS_LKF_TRYLOCK, + SCOUTFS_LOCK_TYPE_GLOBAL_SERVER, + &lock); if (ret) goto out;