Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nfsd4: send the special close_stateid in v4.0 replies as well

We already send it for v4.1, but RFC7530 also notes that the stateid in
the close reply is bogus.

Always send the special close stateid, even in v4.0 responses. No client
should put any meaning on it whatsoever. For now, we continue to
increment the stateid value, though that might not be necessary either.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>

authored by

Jeff Layton and committed by
J. Bruce Fields
bd2decac 3b68e6ee

+15 -4
+15 -4
fs/nfsd/nfs4state.c
··· 5521 5521 goto out; 5522 5522 5523 5523 stp->st_stid.sc_type = NFS4_CLOSED_STID; 5524 + 5525 + /* 5526 + * Technically we don't _really_ have to increment or copy it, since 5527 + * it should just be gone after this operation and we clobber the 5528 + * copied value below, but we continue to do so here just to ensure 5529 + * that racing ops see that there was a state change. 5530 + */ 5524 5531 nfs4_inc_and_copy_stateid(&close->cl_stateid, &stp->st_stid); 5525 5532 5526 5533 nfsd4_close_open_stateid(stp); 5527 5534 mutex_unlock(&stp->st_mutex); 5528 5535 5529 - /* See RFC5661 sectionm 18.2.4 */ 5530 - if (stp->st_stid.sc_client->cl_minorversion) 5531 - memcpy(&close->cl_stateid, &close_stateid, 5532 - sizeof(close->cl_stateid)); 5536 + /* v4.1+ suggests that we send a special stateid in here, since the 5537 + * clients should just ignore this anyway. Since this is not useful 5538 + * for v4.0 clients either, we set it to the special close_stateid 5539 + * universally. 5540 + * 5541 + * See RFC5661 section 18.2.4, and RFC7530 section 16.2.5 5542 + */ 5543 + memcpy(&close->cl_stateid, &close_stateid, sizeof(close->cl_stateid)); 5533 5544 5534 5545 /* put reference from nfs4_preprocess_seqid_op */ 5535 5546 nfs4_put_stid(&stp->st_stid);