diff options
author | NeilBrown <neilb@suse.de> | 2006-10-17 03:10:18 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-10-17 11:18:46 -0400 |
commit | d343fce148a4eee24a907a05c4101d3268045aae (patch) | |
tree | b8a110f85050b2425ce85434c01c0eac0076472b | |
parent | 4481d1038f4116f3f5c307d919e6dc815a3acbb9 (diff) |
[PATCH] knfsd: Allow lockd to drop replies as appropriate
It is possible for the ->fopen callback from lockd into nfsd to find that an
answer cannot be given straight away (an upcall is needed) and so the request
has to be 'dropped', to be retried later. That error status is not currently
propagated back.
So:
Change nlm_fopen to return nlm error codes (rather than a private
protocol) and define a new nlm_drop_reply code.
Cause nlm_drop_reply to cause the rpc request to get rpc_drop_reply
when this error comes back.
Cause svc_process to drop a request which returns a status of
rpc_drop_reply.
[akpm@osdl.org: fix warning storm]
Cc: Marc Eshel <eshel@almaden.ibm.com>
Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | fs/lockd/svc4proc.c | 12 | ||||
-rw-r--r-- | fs/lockd/svcproc.c | 16 | ||||
-rw-r--r-- | fs/lockd/svcsubs.c | 6 | ||||
-rw-r--r-- | fs/nfsd/lockd.c | 14 | ||||
-rw-r--r-- | include/linux/lockd/bind.h | 5 | ||||
-rw-r--r-- | include/linux/lockd/xdr.h | 4 | ||||
-rw-r--r-- | include/linux/sunrpc/msg_prot.h | 4 | ||||
-rw-r--r-- | include/linux/sunrpc/xdr.h | 1 | ||||
-rw-r--r-- | net/sunrpc/svc.c | 5 |
9 files changed, 41 insertions, 26 deletions
diff --git a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c index fa370f6eb07b..399ad11b97be 100644 --- a/fs/lockd/svc4proc.c +++ b/fs/lockd/svc4proc.c | |||
@@ -96,7 +96,7 @@ nlm4svc_proc_test(struct svc_rqst *rqstp, struct nlm_args *argp, | |||
96 | 96 | ||
97 | /* Obtain client and file */ | 97 | /* Obtain client and file */ |
98 | if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file))) | 98 | if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file))) |
99 | return rpc_success; | 99 | return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; |
100 | 100 | ||
101 | /* Now check for conflicting locks */ | 101 | /* Now check for conflicting locks */ |
102 | resp->status = nlmsvc_testlock(file, &argp->lock, &resp->lock); | 102 | resp->status = nlmsvc_testlock(file, &argp->lock, &resp->lock); |
@@ -126,7 +126,7 @@ nlm4svc_proc_lock(struct svc_rqst *rqstp, struct nlm_args *argp, | |||
126 | 126 | ||
127 | /* Obtain client and file */ | 127 | /* Obtain client and file */ |
128 | if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file))) | 128 | if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file))) |
129 | return rpc_success; | 129 | return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; |
130 | 130 | ||
131 | #if 0 | 131 | #if 0 |
132 | /* If supplied state doesn't match current state, we assume it's | 132 | /* If supplied state doesn't match current state, we assume it's |
@@ -169,7 +169,7 @@ nlm4svc_proc_cancel(struct svc_rqst *rqstp, struct nlm_args *argp, | |||
169 | 169 | ||
170 | /* Obtain client and file */ | 170 | /* Obtain client and file */ |
171 | if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file))) | 171 | if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file))) |
172 | return rpc_success; | 172 | return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; |
173 | 173 | ||
174 | /* Try to cancel request. */ | 174 | /* Try to cancel request. */ |
175 | resp->status = nlmsvc_cancel_blocked(file, &argp->lock); | 175 | resp->status = nlmsvc_cancel_blocked(file, &argp->lock); |
@@ -202,7 +202,7 @@ nlm4svc_proc_unlock(struct svc_rqst *rqstp, struct nlm_args *argp, | |||
202 | 202 | ||
203 | /* Obtain client and file */ | 203 | /* Obtain client and file */ |
204 | if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file))) | 204 | if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file))) |
205 | return rpc_success; | 205 | return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; |
206 | 206 | ||
207 | /* Now try to remove the lock */ | 207 | /* Now try to remove the lock */ |
208 | resp->status = nlmsvc_unlock(file, &argp->lock); | 208 | resp->status = nlmsvc_unlock(file, &argp->lock); |
@@ -339,7 +339,7 @@ nlm4svc_proc_share(struct svc_rqst *rqstp, struct nlm_args *argp, | |||
339 | 339 | ||
340 | /* Obtain client and file */ | 340 | /* Obtain client and file */ |
341 | if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file))) | 341 | if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file))) |
342 | return rpc_success; | 342 | return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; |
343 | 343 | ||
344 | /* Now try to create the share */ | 344 | /* Now try to create the share */ |
345 | resp->status = nlmsvc_share_file(host, file, argp); | 345 | resp->status = nlmsvc_share_file(host, file, argp); |
@@ -372,7 +372,7 @@ nlm4svc_proc_unshare(struct svc_rqst *rqstp, struct nlm_args *argp, | |||
372 | 372 | ||
373 | /* Obtain client and file */ | 373 | /* Obtain client and file */ |
374 | if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file))) | 374 | if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file))) |
375 | return rpc_success; | 375 | return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; |
376 | 376 | ||
377 | /* Now try to lock the file */ | 377 | /* Now try to lock the file */ |
378 | resp->status = nlmsvc_unshare_file(host, file, argp); | 378 | resp->status = nlmsvc_unshare_file(host, file, argp); |
diff --git a/fs/lockd/svcproc.c b/fs/lockd/svcproc.c index 75b2c81bcb93..6a931f4ab75c 100644 --- a/fs/lockd/svcproc.c +++ b/fs/lockd/svcproc.c | |||
@@ -59,7 +59,7 @@ nlmsvc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp, | |||
59 | struct nlm_host *host = NULL; | 59 | struct nlm_host *host = NULL; |
60 | struct nlm_file *file = NULL; | 60 | struct nlm_file *file = NULL; |
61 | struct nlm_lock *lock = &argp->lock; | 61 | struct nlm_lock *lock = &argp->lock; |
62 | u32 error; | 62 | u32 error = 0; |
63 | 63 | ||
64 | /* nfsd callbacks must have been installed for this procedure */ | 64 | /* nfsd callbacks must have been installed for this procedure */ |
65 | if (!nlmsvc_ops) | 65 | if (!nlmsvc_ops) |
@@ -88,6 +88,8 @@ nlmsvc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp, | |||
88 | no_locks: | 88 | no_locks: |
89 | if (host) | 89 | if (host) |
90 | nlm_release_host(host); | 90 | nlm_release_host(host); |
91 | if (error) | ||
92 | return error; | ||
91 | return nlm_lck_denied_nolocks; | 93 | return nlm_lck_denied_nolocks; |
92 | } | 94 | } |
93 | 95 | ||
@@ -122,7 +124,7 @@ nlmsvc_proc_test(struct svc_rqst *rqstp, struct nlm_args *argp, | |||
122 | 124 | ||
123 | /* Obtain client and file */ | 125 | /* Obtain client and file */ |
124 | if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file))) | 126 | if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file))) |
125 | return rpc_success; | 127 | return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; |
126 | 128 | ||
127 | /* Now check for conflicting locks */ | 129 | /* Now check for conflicting locks */ |
128 | resp->status = cast_status(nlmsvc_testlock(file, &argp->lock, &resp->lock)); | 130 | resp->status = cast_status(nlmsvc_testlock(file, &argp->lock, &resp->lock)); |
@@ -153,7 +155,7 @@ nlmsvc_proc_lock(struct svc_rqst *rqstp, struct nlm_args *argp, | |||
153 | 155 | ||
154 | /* Obtain client and file */ | 156 | /* Obtain client and file */ |
155 | if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file))) | 157 | if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file))) |
156 | return rpc_success; | 158 | return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; |
157 | 159 | ||
158 | #if 0 | 160 | #if 0 |
159 | /* If supplied state doesn't match current state, we assume it's | 161 | /* If supplied state doesn't match current state, we assume it's |
@@ -196,7 +198,7 @@ nlmsvc_proc_cancel(struct svc_rqst *rqstp, struct nlm_args *argp, | |||
196 | 198 | ||
197 | /* Obtain client and file */ | 199 | /* Obtain client and file */ |
198 | if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file))) | 200 | if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file))) |
199 | return rpc_success; | 201 | return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; |
200 | 202 | ||
201 | /* Try to cancel request. */ | 203 | /* Try to cancel request. */ |
202 | resp->status = cast_status(nlmsvc_cancel_blocked(file, &argp->lock)); | 204 | resp->status = cast_status(nlmsvc_cancel_blocked(file, &argp->lock)); |
@@ -229,7 +231,7 @@ nlmsvc_proc_unlock(struct svc_rqst *rqstp, struct nlm_args *argp, | |||
229 | 231 | ||
230 | /* Obtain client and file */ | 232 | /* Obtain client and file */ |
231 | if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file))) | 233 | if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file))) |
232 | return rpc_success; | 234 | return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; |
233 | 235 | ||
234 | /* Now try to remove the lock */ | 236 | /* Now try to remove the lock */ |
235 | resp->status = cast_status(nlmsvc_unlock(file, &argp->lock)); | 237 | resp->status = cast_status(nlmsvc_unlock(file, &argp->lock)); |
@@ -368,7 +370,7 @@ nlmsvc_proc_share(struct svc_rqst *rqstp, struct nlm_args *argp, | |||
368 | 370 | ||
369 | /* Obtain client and file */ | 371 | /* Obtain client and file */ |
370 | if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file))) | 372 | if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file))) |
371 | return rpc_success; | 373 | return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; |
372 | 374 | ||
373 | /* Now try to create the share */ | 375 | /* Now try to create the share */ |
374 | resp->status = cast_status(nlmsvc_share_file(host, file, argp)); | 376 | resp->status = cast_status(nlmsvc_share_file(host, file, argp)); |
@@ -401,7 +403,7 @@ nlmsvc_proc_unshare(struct svc_rqst *rqstp, struct nlm_args *argp, | |||
401 | 403 | ||
402 | /* Obtain client and file */ | 404 | /* Obtain client and file */ |
403 | if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file))) | 405 | if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file))) |
404 | return rpc_success; | 406 | return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; |
405 | 407 | ||
406 | /* Now try to unshare the file */ | 408 | /* Now try to unshare the file */ |
407 | resp->status = cast_status(nlmsvc_unshare_file(host, file, argp)); | 409 | resp->status = cast_status(nlmsvc_unshare_file(host, file, argp)); |
diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c index c5f9113cdc70..7dac96e6c82c 100644 --- a/fs/lockd/svcsubs.c +++ b/fs/lockd/svcsubs.c | |||
@@ -135,12 +135,6 @@ out_unlock: | |||
135 | 135 | ||
136 | out_free: | 136 | out_free: |
137 | kfree(file); | 137 | kfree(file); |
138 | #ifdef CONFIG_LOCKD_V4 | ||
139 | if (nfserr == 1) | ||
140 | nfserr = nlm4_stale_fh; | ||
141 | else | ||
142 | #endif | ||
143 | nfserr = nlm_lck_denied; | ||
144 | goto out_unlock; | 138 | goto out_unlock; |
145 | } | 139 | } |
146 | 140 | ||
diff --git a/fs/nfsd/lockd.c b/fs/nfsd/lockd.c index 7b889ff15ae6..9b9e7e127c03 100644 --- a/fs/nfsd/lockd.c +++ b/fs/nfsd/lockd.c | |||
@@ -39,18 +39,20 @@ nlm_fopen(struct svc_rqst *rqstp, struct nfs_fh *f, struct file **filp) | |||
39 | fh_put(&fh); | 39 | fh_put(&fh); |
40 | rqstp->rq_client = NULL; | 40 | rqstp->rq_client = NULL; |
41 | exp_readunlock(); | 41 | exp_readunlock(); |
42 | /* nlm and nfsd don't share error codes. | 42 | /* We return nlm error codes as nlm doesn't know |
43 | * we invent: 0 = no error | 43 | * about nfsd, but nfsd does know about nlm.. |
44 | * 1 = stale file handle | ||
45 | * 2 = other error | ||
46 | */ | 44 | */ |
47 | switch (nfserr) { | 45 | switch (nfserr) { |
48 | case nfs_ok: | 46 | case nfs_ok: |
49 | return 0; | 47 | return 0; |
48 | case nfserr_dropit: | ||
49 | return nlm_drop_reply; | ||
50 | #ifdef CONFIG_LOCKD_V4 | ||
50 | case nfserr_stale: | 51 | case nfserr_stale: |
51 | return 1; | 52 | return nlm4_stale_fh; |
53 | #endif | ||
52 | default: | 54 | default: |
53 | return 2; | 55 | return nlm_lck_denied; |
54 | } | 56 | } |
55 | } | 57 | } |
56 | 58 | ||
diff --git a/include/linux/lockd/bind.h b/include/linux/lockd/bind.h index 81e3a185f951..aa50d89eacd7 100644 --- a/include/linux/lockd/bind.h +++ b/include/linux/lockd/bind.h | |||
@@ -10,6 +10,11 @@ | |||
10 | #define LINUX_LOCKD_BIND_H | 10 | #define LINUX_LOCKD_BIND_H |
11 | 11 | ||
12 | #include <linux/lockd/nlm.h> | 12 | #include <linux/lockd/nlm.h> |
13 | /* need xdr-encoded error codes too, so... */ | ||
14 | #include <linux/lockd/xdr.h> | ||
15 | #ifdef CONFIG_LOCKD_V4 | ||
16 | #include <linux/lockd/xdr4.h> | ||
17 | #endif | ||
13 | 18 | ||
14 | /* Dummy declarations */ | 19 | /* Dummy declarations */ |
15 | struct svc_rqst; | 20 | struct svc_rqst; |
diff --git a/include/linux/lockd/xdr.h b/include/linux/lockd/xdr.h index bb0a0f1caa91..66fdae3b490c 100644 --- a/include/linux/lockd/xdr.h +++ b/include/linux/lockd/xdr.h | |||
@@ -13,6 +13,8 @@ | |||
13 | #include <linux/nfs.h> | 13 | #include <linux/nfs.h> |
14 | #include <linux/sunrpc/xdr.h> | 14 | #include <linux/sunrpc/xdr.h> |
15 | 15 | ||
16 | struct svc_rqst; | ||
17 | |||
16 | #define NLM_MAXCOOKIELEN 32 | 18 | #define NLM_MAXCOOKIELEN 32 |
17 | #define NLM_MAXSTRLEN 1024 | 19 | #define NLM_MAXSTRLEN 1024 |
18 | 20 | ||
@@ -22,6 +24,8 @@ | |||
22 | #define nlm_lck_blocked __constant_htonl(NLM_LCK_BLOCKED) | 24 | #define nlm_lck_blocked __constant_htonl(NLM_LCK_BLOCKED) |
23 | #define nlm_lck_denied_grace_period __constant_htonl(NLM_LCK_DENIED_GRACE_PERIOD) | 25 | #define nlm_lck_denied_grace_period __constant_htonl(NLM_LCK_DENIED_GRACE_PERIOD) |
24 | 26 | ||
27 | #define nlm_drop_reply __constant_htonl(30000) | ||
28 | |||
25 | /* Lock info passed via NLM */ | 29 | /* Lock info passed via NLM */ |
26 | struct nlm_lock { | 30 | struct nlm_lock { |
27 | char * caller; | 31 | char * caller; |
diff --git a/include/linux/sunrpc/msg_prot.h b/include/linux/sunrpc/msg_prot.h index 1e65f2dd80e5..606cb2165232 100644 --- a/include/linux/sunrpc/msg_prot.h +++ b/include/linux/sunrpc/msg_prot.h | |||
@@ -56,7 +56,9 @@ enum rpc_accept_stat { | |||
56 | RPC_PROG_MISMATCH = 2, | 56 | RPC_PROG_MISMATCH = 2, |
57 | RPC_PROC_UNAVAIL = 3, | 57 | RPC_PROC_UNAVAIL = 3, |
58 | RPC_GARBAGE_ARGS = 4, | 58 | RPC_GARBAGE_ARGS = 4, |
59 | RPC_SYSTEM_ERR = 5 | 59 | RPC_SYSTEM_ERR = 5, |
60 | /* internal use only */ | ||
61 | RPC_DROP_REPLY = 60000, | ||
60 | }; | 62 | }; |
61 | 63 | ||
62 | enum rpc_reject_stat { | 64 | enum rpc_reject_stat { |
diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h index 953723b09bc6..ac69e5511606 100644 --- a/include/linux/sunrpc/xdr.h +++ b/include/linux/sunrpc/xdr.h | |||
@@ -74,6 +74,7 @@ struct xdr_buf { | |||
74 | #define rpc_proc_unavail __constant_htonl(RPC_PROC_UNAVAIL) | 74 | #define rpc_proc_unavail __constant_htonl(RPC_PROC_UNAVAIL) |
75 | #define rpc_garbage_args __constant_htonl(RPC_GARBAGE_ARGS) | 75 | #define rpc_garbage_args __constant_htonl(RPC_GARBAGE_ARGS) |
76 | #define rpc_system_err __constant_htonl(RPC_SYSTEM_ERR) | 76 | #define rpc_system_err __constant_htonl(RPC_SYSTEM_ERR) |
77 | #define rpc_drop_reply __constant_htonl(RPC_DROP_REPLY) | ||
77 | 78 | ||
78 | #define rpc_auth_ok __constant_htonl(RPC_AUTH_OK) | 79 | #define rpc_auth_ok __constant_htonl(RPC_AUTH_OK) |
79 | #define rpc_autherr_badcred __constant_htonl(RPC_AUTH_BADCRED) | 80 | #define rpc_autherr_badcred __constant_htonl(RPC_AUTH_BADCRED) |
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c index 2807fa0eab40..eb44ec929ca1 100644 --- a/net/sunrpc/svc.c +++ b/net/sunrpc/svc.c | |||
@@ -828,6 +828,11 @@ svc_process(struct svc_rqst *rqstp) | |||
828 | *statp = procp->pc_func(rqstp, rqstp->rq_argp, rqstp->rq_resp); | 828 | *statp = procp->pc_func(rqstp, rqstp->rq_argp, rqstp->rq_resp); |
829 | 829 | ||
830 | /* Encode reply */ | 830 | /* Encode reply */ |
831 | if (*statp == rpc_drop_reply) { | ||
832 | if (procp->pc_release) | ||
833 | procp->pc_release(rqstp, NULL, rqstp->rq_resp); | ||
834 | goto dropit; | ||
835 | } | ||
831 | if (*statp == rpc_success && (xdr = procp->pc_encode) | 836 | if (*statp == rpc_success && (xdr = procp->pc_encode) |
832 | && !xdr(rqstp, resv->iov_base+resv->iov_len, rqstp->rq_resp)) { | 837 | && !xdr(rqstp, resv->iov_base+resv->iov_len, rqstp->rq_resp)) { |
833 | dprintk("svc: failed to encode reply\n"); | 838 | dprintk("svc: failed to encode reply\n"); |