]> git.baikalelectronics.ru Git - kernel.git/commit
nfsd: ensure that seqid morphing operations are atomic wrt to copies
authorJeff Layton <jlayton@poochiereds.net>
Thu, 1 Oct 2015 13:05:50 +0000 (09:05 -0400)
committerJ. Bruce Fields <bfields@redhat.com>
Fri, 23 Oct 2015 19:57:33 +0000 (15:57 -0400)
commitd38a5da72cada393475ed19234f20b98f83f65d9
treecfde0f75348706306314749a9ac8164d0237a0d4
parentacb5bebc6d93c62641c7da8ba95e6525ecb141ab
nfsd: ensure that seqid morphing operations are atomic wrt to copies

Bruce points out that the increment of the seqid in stateids is not
serialized in any way, so it's possible for racing calls to bump it
twice and end up sending the same stateid. While we don't have any
reports of this problem it _is_ theoretically possible, and could lead
to spurious state recovery by the client.

In the current code, update_stateid is always followed by a memcpy of
that stateid, so we can combine the two operations. For better
atomicity, we add a spinlock to the nfs4_stid and hold that when bumping
the seqid and copying the stateid.

Signed-off-by: Jeff Layton <jeff.layton@primarydata.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
fs/nfsd/nfs4layouts.c
fs/nfsd/nfs4state.c
fs/nfsd/state.h