diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2012-03-07 13:49:12 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2012-03-07 13:49:12 -0500 |
commit | cf470c3e004efe16d73dc8ba9b29bdc9a5327cda (patch) | |
tree | 57f8f72ef5af7d33d760570bd8d78e9b0face719 | |
parent | 9cb8196839ab4ec87710526e9c43ac7f5dba69d3 (diff) |
NFSv4: Don't free the nfs4_lock_state until after the release_lockowner
Otherwise we can end up with sequence id problems if the client reuses
the owner_id before the server has processed the release_lockowner
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r-- | fs/nfs/nfs4_fs.h | 4 | ||||
-rw-r--r-- | fs/nfs/nfs4proc.c | 31 | ||||
-rw-r--r-- | fs/nfs/nfs4state.c | 8 |
3 files changed, 28 insertions, 15 deletions
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index 16373df96f90..026878cb2698 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h | |||
@@ -213,7 +213,7 @@ extern int nfs4_do_close(struct nfs4_state *state, gfp_t gfp_mask, int wait, boo | |||
213 | extern int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle); | 213 | extern int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle); |
214 | extern int nfs4_proc_fs_locations(struct inode *dir, const struct qstr *name, | 214 | extern int nfs4_proc_fs_locations(struct inode *dir, const struct qstr *name, |
215 | struct nfs4_fs_locations *fs_locations, struct page *page); | 215 | struct nfs4_fs_locations *fs_locations, struct page *page); |
216 | extern void nfs4_release_lockowner(const struct nfs4_lock_state *); | 216 | extern int nfs4_release_lockowner(struct nfs4_lock_state *); |
217 | extern const struct xattr_handler *nfs4_xattr_handlers[]; | 217 | extern const struct xattr_handler *nfs4_xattr_handlers[]; |
218 | 218 | ||
219 | #if defined(CONFIG_NFS_V4_1) | 219 | #if defined(CONFIG_NFS_V4_1) |
@@ -338,6 +338,8 @@ extern void nfs_increment_lock_seqid(int status, struct nfs_seqid *seqid); | |||
338 | extern void nfs_release_seqid(struct nfs_seqid *seqid); | 338 | extern void nfs_release_seqid(struct nfs_seqid *seqid); |
339 | extern void nfs_free_seqid(struct nfs_seqid *seqid); | 339 | extern void nfs_free_seqid(struct nfs_seqid *seqid); |
340 | 340 | ||
341 | extern void nfs4_free_lock_state(struct nfs4_lock_state *lsp); | ||
342 | |||
341 | extern const nfs4_stateid zero_stateid; | 343 | extern const nfs4_stateid zero_stateid; |
342 | 344 | ||
343 | /* nfs4xdr.c */ | 345 | /* nfs4xdr.c */ |
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 1ec05222ccbc..32e0d08a9771 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -4745,8 +4745,15 @@ out: | |||
4745 | return err; | 4745 | return err; |
4746 | } | 4746 | } |
4747 | 4747 | ||
4748 | struct nfs_release_lockowner_data { | ||
4749 | struct nfs4_lock_state *lsp; | ||
4750 | struct nfs_release_lockowner_args args; | ||
4751 | }; | ||
4752 | |||
4748 | static void nfs4_release_lockowner_release(void *calldata) | 4753 | static void nfs4_release_lockowner_release(void *calldata) |
4749 | { | 4754 | { |
4755 | struct nfs_release_lockowner_data *data = calldata; | ||
4756 | nfs4_free_lock_state(data->lsp); | ||
4750 | kfree(calldata); | 4757 | kfree(calldata); |
4751 | } | 4758 | } |
4752 | 4759 | ||
@@ -4754,24 +4761,26 @@ const struct rpc_call_ops nfs4_release_lockowner_ops = { | |||
4754 | .rpc_release = nfs4_release_lockowner_release, | 4761 | .rpc_release = nfs4_release_lockowner_release, |
4755 | }; | 4762 | }; |
4756 | 4763 | ||
4757 | void nfs4_release_lockowner(const struct nfs4_lock_state *lsp) | 4764 | int nfs4_release_lockowner(struct nfs4_lock_state *lsp) |
4758 | { | 4765 | { |
4759 | struct nfs_server *server = lsp->ls_state->owner->so_server; | 4766 | struct nfs_server *server = lsp->ls_state->owner->so_server; |
4760 | struct nfs_release_lockowner_args *args; | 4767 | struct nfs_release_lockowner_data *data; |
4761 | struct rpc_message msg = { | 4768 | struct rpc_message msg = { |
4762 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RELEASE_LOCKOWNER], | 4769 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RELEASE_LOCKOWNER], |
4763 | }; | 4770 | }; |
4764 | 4771 | ||
4765 | if (server->nfs_client->cl_mvops->minor_version != 0) | 4772 | if (server->nfs_client->cl_mvops->minor_version != 0) |
4766 | return; | 4773 | return -EINVAL; |
4767 | args = kmalloc(sizeof(*args), GFP_NOFS); | 4774 | data = kmalloc(sizeof(*data), GFP_NOFS); |
4768 | if (!args) | 4775 | if (!data) |
4769 | return; | 4776 | return -ENOMEM; |
4770 | args->lock_owner.clientid = server->nfs_client->cl_clientid; | 4777 | data->lsp = lsp; |
4771 | args->lock_owner.id = lsp->ls_seqid.owner_id; | 4778 | data->args.lock_owner.clientid = server->nfs_client->cl_clientid; |
4772 | args->lock_owner.s_dev = server->s_dev; | 4779 | data->args.lock_owner.id = lsp->ls_seqid.owner_id; |
4773 | msg.rpc_argp = args; | 4780 | data->args.lock_owner.s_dev = server->s_dev; |
4774 | rpc_call_async(server->client, &msg, 0, &nfs4_release_lockowner_ops, args); | 4781 | msg.rpc_argp = &data->args; |
4782 | rpc_call_async(server->client, &msg, 0, &nfs4_release_lockowner_ops, data); | ||
4783 | return 0; | ||
4775 | } | 4784 | } |
4776 | 4785 | ||
4777 | #define XATTR_NAME_NFSV4_ACL "system.nfs4_acl" | 4786 | #define XATTR_NAME_NFSV4_ACL "system.nfs4_acl" |
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index a58d02a0c27d..7adc46b4c7f8 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c | |||
@@ -784,7 +784,7 @@ out_free: | |||
784 | return NULL; | 784 | return NULL; |
785 | } | 785 | } |
786 | 786 | ||
787 | static void nfs4_free_lock_state(struct nfs4_lock_state *lsp) | 787 | void nfs4_free_lock_state(struct nfs4_lock_state *lsp) |
788 | { | 788 | { |
789 | struct nfs_server *server = lsp->ls_state->owner->so_server; | 789 | struct nfs_server *server = lsp->ls_state->owner->so_server; |
790 | 790 | ||
@@ -842,8 +842,10 @@ void nfs4_put_lock_state(struct nfs4_lock_state *lsp) | |||
842 | if (list_empty(&state->lock_states)) | 842 | if (list_empty(&state->lock_states)) |
843 | clear_bit(LK_STATE_IN_USE, &state->flags); | 843 | clear_bit(LK_STATE_IN_USE, &state->flags); |
844 | spin_unlock(&state->state_lock); | 844 | spin_unlock(&state->state_lock); |
845 | if (lsp->ls_flags & NFS_LOCK_INITIALIZED) | 845 | if (lsp->ls_flags & NFS_LOCK_INITIALIZED) { |
846 | nfs4_release_lockowner(lsp); | 846 | if (nfs4_release_lockowner(lsp) == 0) |
847 | return; | ||
848 | } | ||
847 | nfs4_free_lock_state(lsp); | 849 | nfs4_free_lock_state(lsp); |
848 | } | 850 | } |
849 | 851 | ||