linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Incorrect(?) use of open_state->stateid in pnfs
@ 2016-10-13  7:18 NeilBrown
  2016-10-13 13:08 ` Trond Myklebust
  0 siblings, 1 reply; 3+ messages in thread
From: NeilBrown @ 2016-10-13  7:18 UTC (permalink / raw)
  To: Linux NFS Mailing List

[-- Attachment #1: Type: text/plain, Size: 1613 bytes --]


Suppose I open/create a file over pNFS and am given a WRITE delegation.
I then chmod the file (as rsync is wont to do) so the delegation is
immediately returned.
I then proceed to write, which triggers a LAYOUT_GET request.  The
stateid for that request it taken from state->stateid, which is still
the delegation stateid.  Naturally it gets NFS4ERR_BAD_STATEID.

When an OPEN is given a delegation, the delegation stateid gets copied
into ->stateid and the open stateid is left in ->open_stateid.
When the delegation is returned, this it done by inode, not open_state,
so it doesn't have easy access to reset the ->stateid.   It could find
all the open_states and fix them up I guess it ....

Other than this usage in pnfs (which dates back to commit b1f69b754e and
is, I believe, incorrect) the ->stateid is *only* used to help find the
write state to recover when an error is reported and the state needs to
be recovered (... though the usage in nfs4_do_handle_exception()
introduced by 272289a3df is a bit different).

Anyway, no other code uses it when choosing a stateid to send in a
request.  So no other code inadvertently uses the delegation stateid
after it has been returned.

How should this be fixed?

- have nfs_start_delegation_return() iterated over all open states
  and copy the open_stateid over the stateid??

- have pnfs_update_layout() use ->open_stateid rather than ->stateid ??
  I suspect that would be wrong.

- have pnfs_update_layout() use ->open_stateid if NFS_I()->delegation
  is NULL ??

Something else?

The last seems easiest, but I'm not certain it is best.

Thanks,
NeilBrown

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 800 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-10-13 22:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-13  7:18 Incorrect(?) use of open_state->stateid in pnfs NeilBrown
2016-10-13 13:08 ` Trond Myklebust
2016-10-13 21:55   ` NeilBrown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).