This is a note to let you know that I've just added the patch titled fs: dlm: fix cleanup pending ops when interrupted to the 6.1-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: fs-dlm-fix-cleanup-pending-ops-when-interrupted.patch and it can be found in the queue-6.1 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From c847f4e203046a2c93d8a1cf0348315c0b655a60 Mon Sep 17 00:00:00 2001 From: Alexander Aring <aahringo@xxxxxxxxxx> Date: Fri, 19 May 2023 11:21:25 -0400 Subject: fs: dlm: fix cleanup pending ops when interrupted From: Alexander Aring <aahringo@xxxxxxxxxx> commit c847f4e203046a2c93d8a1cf0348315c0b655a60 upstream. Immediately clean up a posix lock request if it is interrupted while waiting for a result from user space (dlm_controld.) This largely reverts the recent commit b92a4e3f86b1 ("fs: dlm: change posix lock sigint handling"). That previous commit attempted to defer lock cleanup to the point in time when a result from user space arrived. The deferred approach was not reliable because some dlm plock ops may not receive replies. Cc: stable@xxxxxxxxxxxxxxx Fixes: b92a4e3f86b1 ("fs: dlm: change posix lock sigint handling") Signed-off-by: Alexander Aring <aahringo@xxxxxxxxxx> Signed-off-by: David Teigland <teigland@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/dlm/plock.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) --- a/fs/dlm/plock.c +++ b/fs/dlm/plock.c @@ -29,8 +29,6 @@ struct plock_async_data { struct plock_op { struct list_head list; int done; - /* if lock op got interrupted while waiting dlm_controld reply */ - bool sigint; struct dlm_plock_info info; /* if set indicates async handling */ struct plock_async_data *data; @@ -166,12 +164,14 @@ int dlm_posix_lock(dlm_lockspace_t *lock spin_unlock(&ops_lock); goto do_lock_wait; } - - op->sigint = true; + list_del(&op->list); spin_unlock(&ops_lock); + log_debug(ls, "%s: wait interrupted %x %llx pid %d", __func__, ls->ls_global_id, (unsigned long long)number, op->info.pid); + do_unlock_close(&op->info); + dlm_release_plock_op(op); goto out; } @@ -433,19 +433,6 @@ static ssize_t dev_write(struct file *fi if (iter->info.fsid == info.fsid && iter->info.number == info.number && iter->info.owner == info.owner) { - if (iter->sigint) { - list_del(&iter->list); - spin_unlock(&ops_lock); - - pr_debug("%s: sigint cleanup %x %llx pid %d", - __func__, iter->info.fsid, - (unsigned long long)iter->info.number, - iter->info.pid); - do_unlock_close(&iter->info); - memcpy(&iter->info, &info, sizeof(info)); - dlm_release_plock_op(iter); - return count; - } list_del_init(&iter->list); memcpy(&iter->info, &info, sizeof(info)); if (iter->data) @@ -464,8 +451,8 @@ static ssize_t dev_write(struct file *fi else wake_up(&recv_wq); } else - log_print("%s: no op %x %llx", __func__, - info.fsid, (unsigned long long)info.number); + pr_debug("%s: no op %x %llx", __func__, + info.fsid, (unsigned long long)info.number); return count; } Patches currently in stable-queue which might be from aahringo@xxxxxxxxxx are queue-6.1/fs-dlm-return-positive-pid-value-for-f_getlk.patch queue-6.1/fs-dlm-fix-cleanup-pending-ops-when-interrupted.patch queue-6.1/fs-dlm-make-f_setlk-use-unkillable-wait_event.patch queue-6.1/fs-dlm-revert-check-required-context-while-close.patch queue-6.1/fs-dlm-fix-mismatch-of-plock-results-from-userspace.patch queue-6.1/fs-dlm-interrupt-posix-locks-only-when-process-is-killed.patch