NFS: Test and Free stateid improvements
Subsystems (2)
PATCH 1/1 NFS: Test and Free stateid improvements
From: Bryan Schumaker <[email protected]>
This patch cleans up TEST_STATEID and FREE_STATEID to use the correct lock or open stateid. I also introduce sending SIGIO to applications, rather than attempting recovery, if TEST_STATEID reports that a lock has been lost.
Signed-off-by Bryan Schumaker
--- fs/nfs/nfs4_fs.h | 2 ++ fs/nfs/nfs4proc.c | 44 ++++++++++++++++++++++++++++++-------------- fs/nfs/nfs4state.c | 14 ++++++++++++++ fs/nfs/write.c | 7 +++++++ 4 files changed, 53 insertions(+), 14 deletions(-)
fs/nfs/nfs4_fs.h +2 -0
@@ -163,6 +163,7 @@ struct nfs4_lock_state {struct list_head ls_locks;/* Other lock stateids */ struct nfs4_state * ls_state;/* Pointer to open state */ #define NFS_LOCK_INITIALIZED 1 +#define NFS_LOCK_INVALID 2int ls_flags;struct nfs_seqid_counter ls_seqid;struct rpc_sequence ls_sequence;
@@ -346,6 +347,7 @@ extern struct nfs4_state * nfs4_get_open_state(struct inode *, struct nfs4_stateextern void nfs4_put_open_state (struct nfs4_state *);extern void nfs4_close_state (struct path *,struct nfs4_state *,fmode_t );extern void nfs4_close_sync (struct path *,struct nfs4_state *,fmode_t ); +extern int nfs4_validate_lock_stateid (struct nfs4_state *,struct nfs_lock_context *);extern void nfs4_state_set_mode_locked (struct nfs4_state *,fmode_t );extern void nfs4_schedule_lease_recovery (struct nfs_client *);extern void nfs4_schedule_state_manager (struct nfs_client *);
fs/nfs/nfs4proc.c +30 -14
112 lines not on this page · raw message
fs/nfs/nfs4state.c +14 -0
@@ -725,6 +725,20 @@ __nfs4_find_lock_state(struct nfs4_state *state, fl_owner_t fl_owner, pid_t fl_preturn NULL ; } +int nfs4_validate_lock_stateid (struct nfs4_state *state,struct nfs_lock_context *lock_ctx) +{ +int valid =1 ; +struct nfs4_lock_state *lock_state; + +spin_lock (&state->state_lock); + lock_state =__nfs4_find_lock_state (state, lock_ctx->lockowner, lock_ctx->pid,NFS4_ANY_LOCK_TYPE ); +if (lock_state !=NULL ) + valid = (lock_state->ls_flags &NFS_LOCK_INVALID ) ==0 ; +spin_unlock (&state->state_lock); +nfs4_put_lock_state (lock_state); +return valid; +} +/* * Return a compatible lock_state. If no initialized lock_state structure * exists, return an uninitialized one.
fs/nfs/write.c +7 -0
@@ -1114,7 +1114,14 @@ out:void nfs_write_prepare (struct rpc_task *task,void *calldata) {struct nfs_write_data *data = calldata; +struct nfs4_state *state = data->args.context->state; +struct nfs_lock_context *lock_context = data->args.lock_context; +if (!nfs4_validate_lock_stateid (state, lock_context)) { + task->tk_status = -EIO ; + task->tk_action =NULL ; +return ; + }if (nfs4_setup_sequence (NFS_SERVER (data->inode), &data->args.seq_args, &data->res.seq_res,1 , task))
Signature · 1 line
1.7.6