From 631801c45cd11c1a176cf001fd24d34b98461403 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Fri, 22 Jan 2021 09:45:27 -0800 Subject: [PATCH] Don't queue lock invalidation work during shutdown The lock invalidation work function needs to be careful not to requeue itself while we're shutting down or we can be left with invalidation functions racing with shutdown. Invalidation calls igrab so we can end up with unmount warning that there are still inodes in use. Signed-off-by: Zach Brown --- kmod/src/lock.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/kmod/src/lock.c b/kmod/src/lock.c index 309a1152..6ab4081c 100644 --- a/kmod/src/lock.c +++ b/kmod/src/lock.c @@ -770,16 +770,6 @@ static void lock_invalidate_worker(struct work_struct *work) list_for_each_entry_safe(lock, tmp, &linfo->inv_list, inv_head) { nl = &lock->inv_nl; - /* skip if grace hasn't elapsed, record earliest */ - deadline = lock->grace_deadline; - if (ktime_before(now, deadline)) { - delay = min(delay, - nsecs_to_jiffies(ktime_to_ns( - ktime_sub(deadline, now)))); - scoutfs_inc_counter(linfo->sb, lock_grace_wait); - continue; - } - /* wait for reordered grant to finish */ if (lock->mode != nl->old_mode) continue; @@ -788,6 +778,15 @@ static void lock_invalidate_worker(struct work_struct *work) if (!lock_counts_match(nl->new_mode, lock->users)) continue; + /* skip if grace hasn't elapsed, record earliest */ + deadline = lock->grace_deadline; + if (!linfo->shutdown && ktime_before(now, deadline)) { + delay = min(delay, + nsecs_to_jiffies(ktime_to_ns( + ktime_sub(deadline, now)))); + scoutfs_inc_counter(linfo->sb, lock_grace_wait); + continue; + } /* set the new mode, no incompatible users during inval */ lock->mode = nl->new_mode;