Commit 0ff42a32 authored by Trond Myklebust's avatar Trond Myklebust Committed by Greg Kroah-Hartman
Browse files

NFS: Fix a race when updating an existing write



commit 76d2e389 upstream.

After nfs_lock_and_join_requests() tests for whether the request is
still attached to the mapping, nothing prevents a call to
nfs_inode_remove_request() from succeeding until we actually lock the
page group.
The reason is that whoever called nfs_inode_remove_request() doesn't
necessarily have a lock on the page group head.

So in order to avoid races, let's take the page group lock earlier in
nfs_lock_and_join_requests(), and hold it across the removal of the
request in nfs_inode_remove_request().

Reported-by: default avatarJeff Layton <jlayton@kernel.org>
Tested-by: default avatarJoe Quanaim <jdq@meta.com>
Tested-by: default avatarAndrew Steffen <aksteffen@meta.com>
Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
Fixes: bd37d6fc ("NFSv4: Convert nfs_lock_and_join_requests() to use nfs_page_find_head_request()")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent a4419861
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment