From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796379933; b=vKjEo0BQX8lvMsyygcvdPJkTyK+cL7l0FjgULS1aGq/5GKwPq6xKpS/PfTF7HAVncCvW pt4bzPpb2yBaFudwkWOOQsdA+DyD1cD5KCpwV8XNgm+y2zUGef67CainJ/Ml/AHJwRIiD vEE7O6mGJTmswQhRMOhhA8eS75t8BrIsg9FqSKwIONQ6r0c9QafgIia0xr/qGOYphoJnO PherxzRGKLYqbofdrBhjvNrUocZpCO6aU0FsQlZqP/FgKJSfSUSce9aTydirnQZFouCha h2Xv05W1jOE6Ab6kYPOkE9pC5I/cVUMeiPM8dC5Bpdp8Vmwria536YT0boVN4NO+PGg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796379933; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=CeACy3dogxYSZJ9m/giA9vE+0Vwuud6boUJ0INy2xR8=; b=CVtr9qbBqf3pbBCTIRZpeq/HGvuRIfHYz/sPVfcbqy1UscUC6e8GIzfY1dMIFX7MwjOT P9pcuf7Ha3FCXi1xFe9uCI4z6ORC+Jw9EJ0NFij3+yI87TaHItM+Gz2ZX8SqkXNZIwya7 R2kyxtCATo4mAIAGsR4zI+WzDY088g6A4AZf9EPycCGhyvN6ArcTBhMGpaLDkBWqRbssD qtmxK4mSB4IpRYHq7Y/l2JFmYVTZalu2EZDRLYYlZCYjjcezaOXBKJ3sM7qtJ/r772cjo A6uoMtt2emYRb27GOWnYmk3QIcMjS3o9Ja+zm04VbDXWJTUTJ8LkzGcCipeMjR0mFgA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=zuY4KCEQ; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C9E22606A322; Fri, 4 Dec 2026 10:25:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=zuY4KCEQ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0910F1F000C2; Fri, 4 Dec 2026 10:25:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796379933; bh=CeACy3dogxYSZJ9m/giA9vE+0Vwuud6boUJ0INy2xR8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=zuY4KCEQIaShAskXerUX+12Z+8CGahuPwgMakPK0hfQhfsi08YOwMWbVua2MGQQvS cNeOio23VuWbL8s7zZ579PAEVznqcp62/sTXFpNPoZ8xs9G4OOfoc8/7ziht3NVxwh 5+ehi/m8mV5jsnOfFZUyedqwQRy2Rx/WyEeXO1uc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Olga Kornievskaia , Anna Schumaker , Sasha Levin Subject: [PATCH 7.3 032/742] NFSv4: wake blocking lock waiters when a delegated lock is released Date: Fri, 4 Dec 2026 18:58:16 +0900 Message-ID: <20261204100635.904167339@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Olga Kornievskaia [ Upstream commit e8433473eca284bc561373d0a0fff632f76aa594 ] When the client holds a delegation, _nfs4_proc_setlk() caches POSIX locks locally and never sends a LOCK to the server. It has to strip FL_SLEEP to do so, since that branch runs holding sp->so_delegreturn_mutex and nfsi->rwsem and F_SETLKW can block indefinitely. A contending waiter is therefore never placed on the VFS blocked-lock list, and locks_wake_up_blocks() does not reach it when the holder releases. The waiter blocks in nfs4_retry_setlk() on clp->cl_lock_waitq instead, whose only waker is nfs4_callback_notify_lock(). The server never saw a LOCK for a cached lock, so it does not know anyone is waiting and will never send a CB_NOTIFY_LOCK; nfs4_proc_unlck() returns early without sending LOCKU for the same reason. The waiter sleeps out the full NFS4_LOCK_MAXTIMEOUT of 30s before retrying a lock that is long free. Wake cl_lock_waitq when releasing a cached lock. The releasing thread cannot tell which waiter wants the lock, so the wakeup names only the inode; make the owner comparison in nfs4_wake_lock_waiter() conditional on cbnl_valid so that a CB_NOTIFY_LOCK still wakes exactly the owner it names. The inode restriction matters: without it every blocked locker for the server is woken, and those on non-delegated state each retry with a LOCK RPC. Fixes: a1d617d8f134 ("nfs: allow blocking locks to be awoken by lock callbacks") Assisted-by: Claude Opus 5 Signed-off-by: Olga Kornievskaia Signed-off-by: Anna Schumaker Signed-off-by: Sasha Levin --- fs/nfs/nfs4proc.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 2a27d17a86b11..bbf53366455b3 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -7292,8 +7292,15 @@ static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock * if (status != 0) goto out; /* Is this a delegated lock? */ - if (test_bit(NFS_LOCK_INITIALIZED, &lsp->ls_flags) == 0) + if (test_bit(NFS_LOCK_INITIALIZED, &lsp->ls_flags) == 0) { + struct nfs_client *clp = NFS_SERVER(inode)->nfs_client; + struct cb_notify_lock_args cbnl = { .cbnl_valid = false }; + + /* The server never saw it, so it will not notify waiters */ + nfs_copy_fh(&cbnl.cbnl_fh, NFS_FH(inode)); + __wake_up(&clp->cl_lock_waitq, TASK_NORMAL, 0, &cbnl); goto out; + } alloc_seqid = NFS_SERVER(inode)->nfs_client->cl_mvops->alloc_seqid; seqid = alloc_seqid(&lsp->ls_seqid, GFP_KERNEL); status = -ENOMEM; @@ -7713,8 +7720,14 @@ nfs4_wake_lock_waiter(wait_queue_entry_t *wait, unsigned int mode, int flags, vo struct nfs_lowner *lowner = &cbnl->cbnl_owner, *wowner = &waiter->owner; - /* Only wake if the callback was for the same owner. */ - if (lowner->id != wowner->id || lowner->s_dev != wowner->s_dev) + /* + * Only wake the owner a CB_NOTIFY_LOCK names. A lock cached + * under a delegation is released locally, and the releasing + * thread cannot tell which waiter wants it, so those wakeups + * (cbnl_valid false) name only the inode and wake them all. + */ + if (cbnl->cbnl_valid && + (lowner->id != wowner->id || lowner->s_dev != wowner->s_dev)) return 0; /* Make sure it's for the right inode */ -- 2.53.0