Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/fs/nfsd/nfs4callback.c |
| 3 | * |
| 4 | * Copyright (c) 2001 The Regents of the University of Michigan. |
| 5 | * All rights reserved. |
| 6 | * |
| 7 | * Kendrick Smith <kmsmith@umich.edu> |
| 8 | * Andy Adamson <andros@umich.edu> |
| 9 | * |
| 10 | * Redistribution and use in source and binary forms, with or without |
| 11 | * modification, are permitted provided that the following conditions |
| 12 | * are met: |
| 13 | * |
| 14 | * 1. Redistributions of source code must retain the above copyright |
| 15 | * notice, this list of conditions and the following disclaimer. |
| 16 | * 2. Redistributions in binary form must reproduce the above copyright |
| 17 | * notice, this list of conditions and the following disclaimer in the |
| 18 | * documentation and/or other materials provided with the distribution. |
| 19 | * 3. Neither the name of the University nor the names of its |
| 20 | * contributors may be used to endorse or promote products derived |
| 21 | * from this software without specific prior written permission. |
| 22 | * |
| 23 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 24 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 25 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 26 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
| 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 30 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 31 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 32 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 33 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 34 | */ |
| 35 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | #include <linux/module.h> |
| 37 | #include <linux/list.h> |
| 38 | #include <linux/inet.h> |
| 39 | #include <linux/errno.h> |
| 40 | #include <linux/delay.h> |
Alexey Dobriyan | e8edc6e | 2007-05-21 01:22:52 +0400 | [diff] [blame] | 41 | #include <linux/sched.h> |
J. Bruce Fields | 2b47eec | 2007-07-27 18:06:50 -0400 | [diff] [blame] | 42 | #include <linux/kthread.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | #include <linux/sunrpc/xdr.h> |
| 44 | #include <linux/sunrpc/svc.h> |
| 45 | #include <linux/sunrpc/clnt.h> |
Andy Adamson | 38524ab | 2009-09-10 12:25:59 +0300 | [diff] [blame] | 46 | #include <linux/sunrpc/svcsock.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | #include <linux/nfsd/nfsd.h> |
| 48 | #include <linux/nfsd/state.h> |
| 49 | #include <linux/sunrpc/sched.h> |
| 50 | #include <linux/nfs4.h> |
| 51 | |
| 52 | #define NFSDDBG_FACILITY NFSDDBG_PROC |
| 53 | |
| 54 | #define NFSPROC4_CB_NULL 0 |
| 55 | #define NFSPROC4_CB_COMPOUND 1 |
Andy Adamson | 38524ab | 2009-09-10 12:25:59 +0300 | [diff] [blame] | 56 | #define NFS4_STATEID_SIZE 16 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | /* Index of predefined Linux callback client operations */ |
| 59 | |
| 60 | enum { |
Benny Halevy | 4be36ca | 2009-09-10 12:25:46 +0300 | [diff] [blame] | 61 | NFSPROC4_CLNT_CB_NULL = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | NFSPROC4_CLNT_CB_RECALL, |
Andy Adamson | 38524ab | 2009-09-10 12:25:59 +0300 | [diff] [blame] | 63 | NFSPROC4_CLNT_CB_SEQUENCE, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | }; |
| 65 | |
| 66 | enum nfs_cb_opnum4 { |
| 67 | OP_CB_RECALL = 4, |
Andy Adamson | 38524ab | 2009-09-10 12:25:59 +0300 | [diff] [blame] | 68 | OP_CB_SEQUENCE = 11, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | }; |
| 70 | |
| 71 | #define NFS4_MAXTAGLEN 20 |
| 72 | |
| 73 | #define NFS4_enc_cb_null_sz 0 |
| 74 | #define NFS4_dec_cb_null_sz 0 |
| 75 | #define cb_compound_enc_hdr_sz 4 |
| 76 | #define cb_compound_dec_hdr_sz (3 + (NFS4_MAXTAGLEN >> 2)) |
Andy Adamson | 38524ab | 2009-09-10 12:25:59 +0300 | [diff] [blame] | 77 | #define sessionid_sz (NFS4_MAX_SESSIONID_LEN >> 2) |
| 78 | #define cb_sequence_enc_sz (sessionid_sz + 4 + \ |
| 79 | 1 /* no referring calls list yet */) |
| 80 | #define cb_sequence_dec_sz (op_dec_sz + sessionid_sz + 4) |
| 81 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | #define op_enc_sz 1 |
| 83 | #define op_dec_sz 2 |
| 84 | #define enc_nfs4_fh_sz (1 + (NFS4_FHSIZE >> 2)) |
Benny Halevy | 0ac68d1 | 2007-07-17 04:04:37 -0700 | [diff] [blame] | 85 | #define enc_stateid_sz (NFS4_STATEID_SIZE >> 2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | #define NFS4_enc_cb_recall_sz (cb_compound_enc_hdr_sz + \ |
Andy Adamson | 38524ab | 2009-09-10 12:25:59 +0300 | [diff] [blame] | 87 | cb_sequence_enc_sz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | 1 + enc_stateid_sz + \ |
| 89 | enc_nfs4_fh_sz) |
| 90 | |
| 91 | #define NFS4_dec_cb_recall_sz (cb_compound_dec_hdr_sz + \ |
Andy Adamson | 38524ab | 2009-09-10 12:25:59 +0300 | [diff] [blame] | 92 | cb_sequence_dec_sz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | op_dec_sz) |
| 94 | |
Ricardo Labiaga | 132f977 | 2009-09-10 12:26:12 +0300 | [diff] [blame] | 95 | struct nfs4_rpc_args { |
| 96 | void *args_op; |
| 97 | struct nfsd4_cb_sequence args_seq; |
| 98 | }; |
| 99 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | /* |
| 101 | * Generic encode routines from fs/nfs/nfs4xdr.c |
| 102 | */ |
Al Viro | f00f328 | 2006-10-19 23:29:01 -0700 | [diff] [blame] | 103 | static inline __be32 * |
| 104 | xdr_writemem(__be32 *p, const void *ptr, int nbytes) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | { |
| 106 | int tmp = XDR_QUADLEN(nbytes); |
| 107 | if (!tmp) |
| 108 | return p; |
| 109 | p[tmp-1] = 0; |
| 110 | memcpy(p, ptr, nbytes); |
| 111 | return p + tmp; |
| 112 | } |
| 113 | |
| 114 | #define WRITE32(n) *p++ = htonl(n) |
| 115 | #define WRITEMEM(ptr,nbytes) do { \ |
| 116 | p = xdr_writemem(p, ptr, nbytes); \ |
| 117 | } while (0) |
| 118 | #define RESERVE_SPACE(nbytes) do { \ |
| 119 | p = xdr_reserve_space(xdr, nbytes); \ |
Harvey Harrison | 8e24eea | 2008-04-30 00:55:09 -0700 | [diff] [blame] | 120 | if (!p) dprintk("NFSD: RESERVE_SPACE(%d) failed in function %s\n", (int) (nbytes), __func__); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | BUG_ON(!p); \ |
| 122 | } while (0) |
| 123 | |
| 124 | /* |
| 125 | * Generic decode routines from fs/nfs/nfs4xdr.c |
| 126 | */ |
| 127 | #define DECODE_TAIL \ |
| 128 | status = 0; \ |
| 129 | out: \ |
| 130 | return status; \ |
| 131 | xdr_error: \ |
| 132 | dprintk("NFSD: xdr error! (%s:%d)\n", __FILE__, __LINE__); \ |
| 133 | status = -EIO; \ |
| 134 | goto out |
| 135 | |
| 136 | #define READ32(x) (x) = ntohl(*p++) |
| 137 | #define READ64(x) do { \ |
| 138 | (x) = (u64)ntohl(*p++) << 32; \ |
| 139 | (x) |= ntohl(*p++); \ |
| 140 | } while (0) |
| 141 | #define READTIME(x) do { \ |
| 142 | p++; \ |
| 143 | (x.tv_sec) = ntohl(*p++); \ |
| 144 | (x.tv_nsec) = ntohl(*p++); \ |
| 145 | } while (0) |
| 146 | #define READ_BUF(nbytes) do { \ |
| 147 | p = xdr_inline_decode(xdr, nbytes); \ |
| 148 | if (!p) { \ |
Greg Banks | 3e3b480 | 2006-10-02 02:17:41 -0700 | [diff] [blame] | 149 | dprintk("NFSD: %s: reply buffer overflowed in line %d.\n", \ |
Harvey Harrison | 8e24eea | 2008-04-30 00:55:09 -0700 | [diff] [blame] | 150 | __func__, __LINE__); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | return -EIO; \ |
| 152 | } \ |
| 153 | } while (0) |
| 154 | |
| 155 | struct nfs4_cb_compound_hdr { |
Andy Adamson | 38524ab | 2009-09-10 12:25:59 +0300 | [diff] [blame] | 156 | /* args */ |
| 157 | u32 ident; /* minorversion 0 only */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | u32 nops; |
Andy Adamson | ef52bff | 2009-06-16 04:20:50 +0300 | [diff] [blame] | 159 | __be32 *nops_p; |
Andy Adamson | ab52ae6 | 2009-06-16 04:20:53 +0300 | [diff] [blame] | 160 | u32 minorversion; |
Andy Adamson | 38524ab | 2009-09-10 12:25:59 +0300 | [diff] [blame] | 161 | /* res */ |
| 162 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | u32 taglen; |
Andy Adamson | ef52bff | 2009-06-16 04:20:50 +0300 | [diff] [blame] | 164 | char *tag; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | }; |
| 166 | |
| 167 | static struct { |
| 168 | int stat; |
| 169 | int errno; |
| 170 | } nfs_cb_errtbl[] = { |
| 171 | { NFS4_OK, 0 }, |
| 172 | { NFS4ERR_PERM, EPERM }, |
| 173 | { NFS4ERR_NOENT, ENOENT }, |
| 174 | { NFS4ERR_IO, EIO }, |
| 175 | { NFS4ERR_NXIO, ENXIO }, |
| 176 | { NFS4ERR_ACCESS, EACCES }, |
| 177 | { NFS4ERR_EXIST, EEXIST }, |
| 178 | { NFS4ERR_XDEV, EXDEV }, |
| 179 | { NFS4ERR_NOTDIR, ENOTDIR }, |
| 180 | { NFS4ERR_ISDIR, EISDIR }, |
| 181 | { NFS4ERR_INVAL, EINVAL }, |
| 182 | { NFS4ERR_FBIG, EFBIG }, |
| 183 | { NFS4ERR_NOSPC, ENOSPC }, |
| 184 | { NFS4ERR_ROFS, EROFS }, |
| 185 | { NFS4ERR_MLINK, EMLINK }, |
| 186 | { NFS4ERR_NAMETOOLONG, ENAMETOOLONG }, |
| 187 | { NFS4ERR_NOTEMPTY, ENOTEMPTY }, |
| 188 | { NFS4ERR_DQUOT, EDQUOT }, |
| 189 | { NFS4ERR_STALE, ESTALE }, |
| 190 | { NFS4ERR_BADHANDLE, EBADHANDLE }, |
| 191 | { NFS4ERR_BAD_COOKIE, EBADCOOKIE }, |
| 192 | { NFS4ERR_NOTSUPP, ENOTSUPP }, |
| 193 | { NFS4ERR_TOOSMALL, ETOOSMALL }, |
| 194 | { NFS4ERR_SERVERFAULT, ESERVERFAULT }, |
| 195 | { NFS4ERR_BADTYPE, EBADTYPE }, |
| 196 | { NFS4ERR_LOCKED, EAGAIN }, |
| 197 | { NFS4ERR_RESOURCE, EREMOTEIO }, |
| 198 | { NFS4ERR_SYMLINK, ELOOP }, |
| 199 | { NFS4ERR_OP_ILLEGAL, EOPNOTSUPP }, |
| 200 | { NFS4ERR_DEADLOCK, EDEADLK }, |
| 201 | { -1, EIO } |
| 202 | }; |
| 203 | |
| 204 | static int |
| 205 | nfs_cb_stat_to_errno(int stat) |
| 206 | { |
| 207 | int i; |
| 208 | for (i = 0; nfs_cb_errtbl[i].stat != -1; i++) { |
| 209 | if (nfs_cb_errtbl[i].stat == stat) |
| 210 | return nfs_cb_errtbl[i].errno; |
| 211 | } |
| 212 | /* If we cannot translate the error, the recovery routines should |
| 213 | * handle it. |
| 214 | * Note: remaining NFSv4 error codes have values > 10000, so should |
| 215 | * not conflict with native Linux error codes. |
| 216 | */ |
| 217 | return stat; |
| 218 | } |
| 219 | |
| 220 | /* |
| 221 | * XDR encode |
| 222 | */ |
| 223 | |
Andy Adamson | ef52bff | 2009-06-16 04:20:50 +0300 | [diff] [blame] | 224 | static void |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | encode_cb_compound_hdr(struct xdr_stream *xdr, struct nfs4_cb_compound_hdr *hdr) |
| 226 | { |
Al Viro | f00f328 | 2006-10-19 23:29:01 -0700 | [diff] [blame] | 227 | __be32 * p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | |
| 229 | RESERVE_SPACE(16); |
| 230 | WRITE32(0); /* tag length is always 0 */ |
Andy Adamson | ab52ae6 | 2009-06-16 04:20:53 +0300 | [diff] [blame] | 231 | WRITE32(hdr->minorversion); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | WRITE32(hdr->ident); |
Andy Adamson | ef52bff | 2009-06-16 04:20:50 +0300 | [diff] [blame] | 233 | hdr->nops_p = p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | WRITE32(hdr->nops); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | } |
| 236 | |
Andy Adamson | ef52bff | 2009-06-16 04:20:50 +0300 | [diff] [blame] | 237 | static void encode_cb_nops(struct nfs4_cb_compound_hdr *hdr) |
| 238 | { |
| 239 | *hdr->nops_p = htonl(hdr->nops); |
| 240 | } |
| 241 | |
| 242 | static void |
| 243 | encode_cb_recall(struct xdr_stream *xdr, struct nfs4_delegation *dp, |
| 244 | struct nfs4_cb_compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | { |
Al Viro | f00f328 | 2006-10-19 23:29:01 -0700 | [diff] [blame] | 246 | __be32 *p; |
J. Bruce Fields | b53d40c | 2009-05-01 19:50:00 -0400 | [diff] [blame] | 247 | int len = dp->dl_fh.fh_size; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | |
J. Bruce Fields | b53d40c | 2009-05-01 19:50:00 -0400 | [diff] [blame] | 249 | RESERVE_SPACE(12+sizeof(dp->dl_stateid) + len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | WRITE32(OP_CB_RECALL); |
J. Bruce Fields | b53d40c | 2009-05-01 19:50:00 -0400 | [diff] [blame] | 251 | WRITE32(dp->dl_stateid.si_generation); |
| 252 | WRITEMEM(&dp->dl_stateid.si_opaque, sizeof(stateid_opaque_t)); |
J. Bruce Fields | 6707bd3 | 2009-05-01 19:57:46 -0400 | [diff] [blame] | 253 | WRITE32(0); /* truncate optimization not implemented */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | WRITE32(len); |
J. Bruce Fields | b53d40c | 2009-05-01 19:50:00 -0400 | [diff] [blame] | 255 | WRITEMEM(&dp->dl_fh.fh_base, len); |
Andy Adamson | ef52bff | 2009-06-16 04:20:50 +0300 | [diff] [blame] | 256 | hdr->nops++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | } |
| 258 | |
Benny Halevy | 2af7358 | 2009-09-10 12:26:51 +0300 | [diff] [blame^] | 259 | static void |
| 260 | encode_cb_sequence(struct xdr_stream *xdr, struct nfsd4_cb_sequence *args, |
| 261 | struct nfs4_cb_compound_hdr *hdr) |
| 262 | { |
| 263 | __be32 *p; |
| 264 | |
| 265 | if (hdr->minorversion == 0) |
| 266 | return; |
| 267 | |
| 268 | RESERVE_SPACE(1 + NFS4_MAX_SESSIONID_LEN + 20); |
| 269 | |
| 270 | WRITE32(OP_CB_SEQUENCE); |
| 271 | WRITEMEM(args->cbs_clp->cl_sessionid.data, NFS4_MAX_SESSIONID_LEN); |
| 272 | WRITE32(args->cbs_clp->cl_cb_seq_nr); |
| 273 | WRITE32(0); /* slotid, always 0 */ |
| 274 | WRITE32(0); /* highest slotid always 0 */ |
| 275 | WRITE32(0); /* cachethis always 0 */ |
| 276 | WRITE32(0); /* FIXME: support referring_call_lists */ |
| 277 | hdr->nops++; |
| 278 | } |
| 279 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | static int |
Al Viro | f00f328 | 2006-10-19 23:29:01 -0700 | [diff] [blame] | 281 | nfs4_xdr_enc_cb_null(struct rpc_rqst *req, __be32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | { |
| 283 | struct xdr_stream xdrs, *xdr = &xdrs; |
| 284 | |
| 285 | xdr_init_encode(&xdrs, &req->rq_snd_buf, p); |
| 286 | RESERVE_SPACE(0); |
| 287 | return 0; |
| 288 | } |
| 289 | |
| 290 | static int |
J. Bruce Fields | b53d40c | 2009-05-01 19:50:00 -0400 | [diff] [blame] | 291 | nfs4_xdr_enc_cb_recall(struct rpc_rqst *req, __be32 *p, struct nfs4_delegation *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | { |
| 293 | struct xdr_stream xdr; |
| 294 | struct nfs4_cb_compound_hdr hdr = { |
J. Bruce Fields | b53d40c | 2009-05-01 19:50:00 -0400 | [diff] [blame] | 295 | .ident = args->dl_ident, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | }; |
| 297 | |
| 298 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
| 299 | encode_cb_compound_hdr(&xdr, &hdr); |
Andy Adamson | ef52bff | 2009-06-16 04:20:50 +0300 | [diff] [blame] | 300 | encode_cb_recall(&xdr, args, &hdr); |
| 301 | encode_cb_nops(&hdr); |
| 302 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | } |
| 304 | |
| 305 | |
| 306 | static int |
| 307 | decode_cb_compound_hdr(struct xdr_stream *xdr, struct nfs4_cb_compound_hdr *hdr){ |
Al Viro | f00f328 | 2006-10-19 23:29:01 -0700 | [diff] [blame] | 308 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | |
| 310 | READ_BUF(8); |
| 311 | READ32(hdr->status); |
| 312 | READ32(hdr->taglen); |
| 313 | READ_BUF(hdr->taglen + 4); |
| 314 | hdr->tag = (char *)p; |
| 315 | p += XDR_QUADLEN(hdr->taglen); |
| 316 | READ32(hdr->nops); |
| 317 | return 0; |
| 318 | } |
| 319 | |
| 320 | static int |
| 321 | decode_cb_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected) |
| 322 | { |
Al Viro | f00f328 | 2006-10-19 23:29:01 -0700 | [diff] [blame] | 323 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | u32 op; |
| 325 | int32_t nfserr; |
| 326 | |
| 327 | READ_BUF(8); |
| 328 | READ32(op); |
| 329 | if (op != expected) { |
| 330 | dprintk("NFSD: decode_cb_op_hdr: Callback server returned " |
| 331 | " operation %d but we issued a request for %d\n", |
| 332 | op, expected); |
| 333 | return -EIO; |
| 334 | } |
| 335 | READ32(nfserr); |
| 336 | if (nfserr != NFS_OK) |
| 337 | return -nfs_cb_stat_to_errno(nfserr); |
| 338 | return 0; |
| 339 | } |
| 340 | |
Benny Halevy | 2af7358 | 2009-09-10 12:26:51 +0300 | [diff] [blame^] | 341 | /* |
| 342 | * Our current back channel implmentation supports a single backchannel |
| 343 | * with a single slot. |
| 344 | */ |
| 345 | static int |
| 346 | decode_cb_sequence(struct xdr_stream *xdr, struct nfsd4_cb_sequence *res, |
| 347 | struct rpc_rqst *rqstp) |
| 348 | { |
| 349 | struct nfs4_sessionid id; |
| 350 | int status; |
| 351 | u32 dummy; |
| 352 | __be32 *p; |
| 353 | |
| 354 | if (res->cbs_minorversion == 0) |
| 355 | return 0; |
| 356 | |
| 357 | status = decode_cb_op_hdr(xdr, OP_CB_SEQUENCE); |
| 358 | if (status) |
| 359 | return status; |
| 360 | |
| 361 | /* |
| 362 | * If the server returns different values for sessionID, slotID or |
| 363 | * sequence number, the server is looney tunes. |
| 364 | */ |
| 365 | status = -ESERVERFAULT; |
| 366 | |
| 367 | READ_BUF(NFS4_MAX_SESSIONID_LEN + 16); |
| 368 | memcpy(id.data, p, NFS4_MAX_SESSIONID_LEN); |
| 369 | p += XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN); |
| 370 | if (memcmp(id.data, res->cbs_clp->cl_sessionid.data, |
| 371 | NFS4_MAX_SESSIONID_LEN)) { |
| 372 | dprintk("%s Invalid session id\n", __func__); |
| 373 | goto out; |
| 374 | } |
| 375 | READ32(dummy); |
| 376 | if (dummy != res->cbs_clp->cl_cb_seq_nr) { |
| 377 | dprintk("%s Invalid sequence number\n", __func__); |
| 378 | goto out; |
| 379 | } |
| 380 | READ32(dummy); /* slotid must be 0 */ |
| 381 | if (dummy != 0) { |
| 382 | dprintk("%s Invalid slotid\n", __func__); |
| 383 | goto out; |
| 384 | } |
| 385 | /* FIXME: process highest slotid and target highest slotid */ |
| 386 | status = 0; |
| 387 | out: |
| 388 | return status; |
| 389 | } |
| 390 | |
| 391 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 392 | static int |
Al Viro | f00f328 | 2006-10-19 23:29:01 -0700 | [diff] [blame] | 393 | nfs4_xdr_dec_cb_null(struct rpc_rqst *req, __be32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 | { |
| 395 | return 0; |
| 396 | } |
| 397 | |
| 398 | static int |
Al Viro | f00f328 | 2006-10-19 23:29:01 -0700 | [diff] [blame] | 399 | nfs4_xdr_dec_cb_recall(struct rpc_rqst *rqstp, __be32 *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 400 | { |
| 401 | struct xdr_stream xdr; |
| 402 | struct nfs4_cb_compound_hdr hdr; |
| 403 | int status; |
| 404 | |
| 405 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); |
| 406 | status = decode_cb_compound_hdr(&xdr, &hdr); |
| 407 | if (status) |
| 408 | goto out; |
| 409 | status = decode_cb_op_hdr(&xdr, OP_CB_RECALL); |
| 410 | out: |
| 411 | return status; |
| 412 | } |
| 413 | |
| 414 | /* |
| 415 | * RPC procedure tables |
| 416 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 417 | #define PROC(proc, call, argtype, restype) \ |
| 418 | [NFSPROC4_CLNT_##proc] = { \ |
| 419 | .p_proc = NFSPROC4_CB_##call, \ |
| 420 | .p_encode = (kxdrproc_t) nfs4_xdr_##argtype, \ |
| 421 | .p_decode = (kxdrproc_t) nfs4_xdr_##restype, \ |
Chuck Lever | 2bea90d | 2007-03-29 16:47:53 -0400 | [diff] [blame] | 422 | .p_arglen = NFS4_##argtype##_sz, \ |
| 423 | .p_replen = NFS4_##restype##_sz, \ |
Chuck Lever | cc0175c | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 424 | .p_statidx = NFSPROC4_CB_##call, \ |
| 425 | .p_name = #proc, \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | } |
| 427 | |
NeilBrown | fd39ca9 | 2005-06-23 22:04:03 -0700 | [diff] [blame] | 428 | static struct rpc_procinfo nfs4_cb_procedures[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | PROC(CB_NULL, NULL, enc_cb_null, dec_cb_null), |
| 430 | PROC(CB_RECALL, COMPOUND, enc_cb_recall, dec_cb_recall), |
| 431 | }; |
| 432 | |
NeilBrown | fd39ca9 | 2005-06-23 22:04:03 -0700 | [diff] [blame] | 433 | static struct rpc_version nfs_cb_version4 = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 434 | .number = 1, |
Tobias Klauser | e8c96f8 | 2006-03-24 03:15:34 -0800 | [diff] [blame] | 435 | .nrprocs = ARRAY_SIZE(nfs4_cb_procedures), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 436 | .procs = nfs4_cb_procedures |
| 437 | }; |
| 438 | |
| 439 | static struct rpc_version * nfs_cb_version[] = { |
| 440 | NULL, |
| 441 | &nfs_cb_version4, |
| 442 | }; |
| 443 | |
Olga Kornievskaia | ff7d975 | 2008-03-28 16:04:56 -0400 | [diff] [blame] | 444 | static struct rpc_program cb_program; |
| 445 | |
| 446 | static struct rpc_stat cb_stats = { |
| 447 | .program = &cb_program |
| 448 | }; |
| 449 | |
| 450 | #define NFS4_CALLBACK 0x40000000 |
| 451 | static struct rpc_program cb_program = { |
| 452 | .name = "nfs4_cb", |
| 453 | .number = NFS4_CALLBACK, |
| 454 | .nrvers = ARRAY_SIZE(nfs_cb_version), |
| 455 | .version = nfs_cb_version, |
| 456 | .stats = &cb_stats, |
Olga Kornievskaia | 61054b1 | 2008-12-23 16:19:00 -0500 | [diff] [blame] | 457 | .pipe_dir_name = "/nfsd4_cb", |
Olga Kornievskaia | ff7d975 | 2008-03-28 16:04:56 -0400 | [diff] [blame] | 458 | }; |
| 459 | |
J. Bruce Fields | 595947a | 2009-03-05 17:18:10 -0500 | [diff] [blame] | 460 | static int max_cb_time(void) |
| 461 | { |
| 462 | return max(NFSD_LEASE_TIME/10, (time_t)1) * HZ; |
| 463 | } |
| 464 | |
J. Bruce Fields | 2b47eec | 2007-07-27 18:06:50 -0400 | [diff] [blame] | 465 | /* Reference counting, callback cleanup, etc., all look racy as heck. |
| 466 | * And why is cb_set an atomic? */ |
| 467 | |
J. Bruce Fields | e1cab5a5 | 2009-02-23 10:45:27 -0800 | [diff] [blame] | 468 | int setup_callback_client(struct nfs4_client *clp) |
J. Bruce Fields | 2b47eec | 2007-07-27 18:06:50 -0400 | [diff] [blame] | 469 | { |
J. Bruce Fields | c237dc0 | 2009-04-29 19:09:19 -0400 | [diff] [blame] | 470 | struct nfs4_cb_conn *cb = &clp->cl_cb_conn; |
Chuck Lever | ae5c794 | 2006-08-22 20:06:21 -0400 | [diff] [blame] | 471 | struct rpc_timeout timeparms = { |
J. Bruce Fields | 595947a | 2009-03-05 17:18:10 -0500 | [diff] [blame] | 472 | .to_initval = max_cb_time(), |
| 473 | .to_retries = 0, |
Chuck Lever | ae5c794 | 2006-08-22 20:06:21 -0400 | [diff] [blame] | 474 | }; |
Chuck Lever | ae5c794 | 2006-08-22 20:06:21 -0400 | [diff] [blame] | 475 | struct rpc_create_args args = { |
| 476 | .protocol = IPPROTO_TCP, |
Jeff Layton | aa9a4ec | 2009-08-14 12:57:57 -0400 | [diff] [blame] | 477 | .address = (struct sockaddr *) &cb->cb_addr, |
| 478 | .addrsize = cb->cb_addrlen, |
Chuck Lever | ae5c794 | 2006-08-22 20:06:21 -0400 | [diff] [blame] | 479 | .timeout = &timeparms, |
Olga Kornievskaia | ff7d975 | 2008-03-28 16:04:56 -0400 | [diff] [blame] | 480 | .program = &cb_program, |
Benny Halevy | d5b337b | 2008-09-28 09:21:26 +0300 | [diff] [blame] | 481 | .prognumber = cb->cb_prog, |
Chuck Lever | ae5c794 | 2006-08-22 20:06:21 -0400 | [diff] [blame] | 482 | .version = nfs_cb_version[1]->number, |
Olga Kornievskaia | 61054b1 | 2008-12-23 16:19:00 -0500 | [diff] [blame] | 483 | .authflavor = clp->cl_flavor, |
Olga Kornievskaia | b6b6152 | 2008-06-09 16:51:31 -0400 | [diff] [blame] | 484 | .flags = (RPC_CLNT_CREATE_NOPING | RPC_CLNT_CREATE_QUIET), |
Olga Kornievskaia | 608207e | 2008-12-23 16:17:40 -0500 | [diff] [blame] | 485 | .client_name = clp->cl_principal, |
Chuck Lever | ae5c794 | 2006-08-22 20:06:21 -0400 | [diff] [blame] | 486 | }; |
J. Bruce Fields | 63c8671 | 2007-10-25 19:00:26 -0400 | [diff] [blame] | 487 | struct rpc_clnt *client; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | |
J. Bruce Fields | 418cd20 | 2009-02-22 15:52:13 -0800 | [diff] [blame] | 489 | if (!clp->cl_principal && (clp->cl_flavor >= RPC_AUTH_GSS_KRB5)) |
J. Bruce Fields | e1cab5a5 | 2009-02-23 10:45:27 -0800 | [diff] [blame] | 490 | return -EINVAL; |
Olga Kornievskaia | 608207e | 2008-12-23 16:17:40 -0500 | [diff] [blame] | 491 | |
Chuck Lever | ae5c794 | 2006-08-22 20:06:21 -0400 | [diff] [blame] | 492 | /* Create RPC client */ |
J. Bruce Fields | 63c8671 | 2007-10-25 19:00:26 -0400 | [diff] [blame] | 493 | client = rpc_create(&args); |
J. Bruce Fields | e1cab5a5 | 2009-02-23 10:45:27 -0800 | [diff] [blame] | 494 | if (IS_ERR(client)) { |
J. Bruce Fields | a601cae | 2009-02-22 16:43:45 -0800 | [diff] [blame] | 495 | dprintk("NFSD: couldn't create callback client: %ld\n", |
| 496 | PTR_ERR(client)); |
J. Bruce Fields | e1cab5a5 | 2009-02-23 10:45:27 -0800 | [diff] [blame] | 497 | return PTR_ERR(client); |
| 498 | } |
| 499 | cb->cb_client = client; |
| 500 | return 0; |
J. Bruce Fields | a601cae | 2009-02-22 16:43:45 -0800 | [diff] [blame] | 501 | |
| 502 | } |
| 503 | |
J. Bruce Fields | ecdd03b | 2009-02-23 19:35:22 -0800 | [diff] [blame] | 504 | static void warn_no_callback_path(struct nfs4_client *clp, int reason) |
| 505 | { |
| 506 | dprintk("NFSD: warning: no callback path to client %.*s: error %d\n", |
| 507 | (int)clp->cl_name.len, clp->cl_name.data, reason); |
| 508 | } |
| 509 | |
J. Bruce Fields | e300a63 | 2009-03-05 15:01:11 -0500 | [diff] [blame] | 510 | static void nfsd4_cb_probe_done(struct rpc_task *task, void *calldata) |
| 511 | { |
| 512 | struct nfs4_client *clp = calldata; |
| 513 | |
| 514 | if (task->tk_status) |
| 515 | warn_no_callback_path(clp, task->tk_status); |
| 516 | else |
J. Bruce Fields | c237dc0 | 2009-04-29 19:09:19 -0400 | [diff] [blame] | 517 | atomic_set(&clp->cl_cb_conn.cb_set, 1); |
J. Bruce Fields | e300a63 | 2009-03-05 15:01:11 -0500 | [diff] [blame] | 518 | put_nfs4_client(clp); |
| 519 | } |
| 520 | |
| 521 | static const struct rpc_call_ops nfsd4_cb_probe_ops = { |
| 522 | .rpc_call_done = nfsd4_cb_probe_done, |
| 523 | }; |
| 524 | |
J. Bruce Fields | 80fc015 | 2009-09-15 18:07:35 -0400 | [diff] [blame] | 525 | static struct rpc_cred *callback_cred; |
J. Bruce Fields | 3cef9ab | 2009-02-23 21:42:10 -0800 | [diff] [blame] | 526 | |
J. Bruce Fields | 80fc015 | 2009-09-15 18:07:35 -0400 | [diff] [blame] | 527 | int set_callback_cred(void) |
| 528 | { |
| 529 | callback_cred = rpc_lookup_machine_cred(); |
| 530 | if (!callback_cred) |
| 531 | return -ENOMEM; |
| 532 | return 0; |
J. Bruce Fields | 3cef9ab | 2009-02-23 21:42:10 -0800 | [diff] [blame] | 533 | } |
| 534 | |
J. Bruce Fields | 80fc015 | 2009-09-15 18:07:35 -0400 | [diff] [blame] | 535 | |
J. Bruce Fields | e300a63 | 2009-03-05 15:01:11 -0500 | [diff] [blame] | 536 | void do_probe_callback(struct nfs4_client *clp) |
J. Bruce Fields | a601cae | 2009-02-22 16:43:45 -0800 | [diff] [blame] | 537 | { |
J. Bruce Fields | c237dc0 | 2009-04-29 19:09:19 -0400 | [diff] [blame] | 538 | struct nfs4_cb_conn *cb = &clp->cl_cb_conn; |
J. Bruce Fields | a601cae | 2009-02-22 16:43:45 -0800 | [diff] [blame] | 539 | struct rpc_message msg = { |
| 540 | .rpc_proc = &nfs4_cb_procedures[NFSPROC4_CLNT_CB_NULL], |
| 541 | .rpc_argp = clp, |
J. Bruce Fields | 80fc015 | 2009-09-15 18:07:35 -0400 | [diff] [blame] | 542 | .rpc_cred = callback_cred |
J. Bruce Fields | a601cae | 2009-02-22 16:43:45 -0800 | [diff] [blame] | 543 | }; |
J. Bruce Fields | a601cae | 2009-02-22 16:43:45 -0800 | [diff] [blame] | 544 | int status; |
| 545 | |
J. Bruce Fields | e300a63 | 2009-03-05 15:01:11 -0500 | [diff] [blame] | 546 | status = rpc_call_async(cb->cb_client, &msg, RPC_TASK_SOFT, |
| 547 | &nfsd4_cb_probe_ops, (void *)clp); |
J. Bruce Fields | e300a63 | 2009-03-05 15:01:11 -0500 | [diff] [blame] | 548 | if (status) { |
J. Bruce Fields | ecdd03b | 2009-02-23 19:35:22 -0800 | [diff] [blame] | 549 | warn_no_callback_path(clp, status); |
J. Bruce Fields | e300a63 | 2009-03-05 15:01:11 -0500 | [diff] [blame] | 550 | put_nfs4_client(clp); |
| 551 | } |
J. Bruce Fields | 63c8671 | 2007-10-25 19:00:26 -0400 | [diff] [blame] | 552 | } |
| 553 | |
| 554 | /* |
| 555 | * Set up the callback client and put a NFSPROC4_CB_NULL on the wire... |
| 556 | */ |
| 557 | void |
| 558 | nfsd4_probe_callback(struct nfs4_client *clp) |
| 559 | { |
J. Bruce Fields | ecdd03b | 2009-02-23 19:35:22 -0800 | [diff] [blame] | 560 | int status; |
J. Bruce Fields | 63c8671 | 2007-10-25 19:00:26 -0400 | [diff] [blame] | 561 | |
J. Bruce Fields | c237dc0 | 2009-04-29 19:09:19 -0400 | [diff] [blame] | 562 | BUG_ON(atomic_read(&clp->cl_cb_conn.cb_set)); |
J. Bruce Fields | 63c8671 | 2007-10-25 19:00:26 -0400 | [diff] [blame] | 563 | |
J. Bruce Fields | ecdd03b | 2009-02-23 19:35:22 -0800 | [diff] [blame] | 564 | status = setup_callback_client(clp); |
| 565 | if (status) { |
| 566 | warn_no_callback_path(clp, status); |
| 567 | return; |
| 568 | } |
| 569 | |
NeilBrown | 541e0e0 | 2006-04-10 22:55:38 -0700 | [diff] [blame] | 570 | /* the task holds a reference to the nfs4_client struct */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | atomic_inc(&clp->cl_count); |
| 572 | |
J. Bruce Fields | e300a63 | 2009-03-05 15:01:11 -0500 | [diff] [blame] | 573 | do_probe_callback(clp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 574 | } |
| 575 | |
Ricardo Labiaga | 2a1d1b5 | 2009-09-10 12:26:38 +0300 | [diff] [blame] | 576 | /* |
| 577 | * There's currently a single callback channel slot. |
| 578 | * If the slot is available, then mark it busy. Otherwise, set the |
| 579 | * thread for sleeping on the callback RPC wait queue. |
| 580 | */ |
| 581 | static int nfsd41_cb_setup_sequence(struct nfs4_client *clp, |
| 582 | struct rpc_task *task) |
| 583 | { |
| 584 | struct nfs4_rpc_args *args = task->tk_msg.rpc_argp; |
| 585 | u32 *ptr = (u32 *)clp->cl_sessionid.data; |
| 586 | int status = 0; |
| 587 | |
| 588 | dprintk("%s: %u:%u:%u:%u\n", __func__, |
| 589 | ptr[0], ptr[1], ptr[2], ptr[3]); |
| 590 | |
| 591 | if (test_and_set_bit(0, &clp->cl_cb_slot_busy) != 0) { |
| 592 | rpc_sleep_on(&clp->cl_cb_waitq, task, NULL); |
| 593 | dprintk("%s slot is busy\n", __func__); |
| 594 | status = -EAGAIN; |
| 595 | goto out; |
| 596 | } |
| 597 | |
| 598 | /* |
| 599 | * We'll need the clp during XDR encoding and decoding, |
| 600 | * and the sequence during decoding to verify the reply |
| 601 | */ |
| 602 | args->args_seq.cbs_clp = clp; |
| 603 | task->tk_msg.rpc_resp = &args->args_seq; |
| 604 | |
| 605 | out: |
| 606 | dprintk("%s status=%d\n", __func__, status); |
| 607 | return status; |
| 608 | } |
| 609 | |
| 610 | /* |
| 611 | * TODO: cb_sequence should support referring call lists, cachethis, multiple |
| 612 | * slots, and mark callback channel down on communication errors. |
| 613 | */ |
| 614 | static void nfsd4_cb_prepare(struct rpc_task *task, void *calldata) |
| 615 | { |
| 616 | struct nfs4_delegation *dp = calldata; |
| 617 | struct nfs4_client *clp = dp->dl_client; |
| 618 | struct nfs4_rpc_args *args = task->tk_msg.rpc_argp; |
| 619 | u32 minorversion = clp->cl_cb_conn.cb_minorversion; |
| 620 | int status = 0; |
| 621 | |
| 622 | args->args_seq.cbs_minorversion = minorversion; |
| 623 | if (minorversion) { |
| 624 | status = nfsd41_cb_setup_sequence(clp, task); |
| 625 | if (status) { |
| 626 | if (status != -EAGAIN) { |
| 627 | /* terminate rpc task */ |
| 628 | task->tk_status = status; |
| 629 | task->tk_action = NULL; |
| 630 | } |
| 631 | return; |
| 632 | } |
| 633 | } |
| 634 | rpc_call_start(task); |
| 635 | } |
| 636 | |
J. Bruce Fields | 63e4863 | 2009-05-01 22:36:55 -0400 | [diff] [blame] | 637 | static void nfsd4_cb_recall_done(struct rpc_task *task, void *calldata) |
| 638 | { |
| 639 | struct nfs4_delegation *dp = calldata; |
| 640 | struct nfs4_client *clp = dp->dl_client; |
| 641 | |
| 642 | switch (task->tk_status) { |
| 643 | case -EIO: |
| 644 | /* Network partition? */ |
| 645 | atomic_set(&clp->cl_cb_conn.cb_set, 0); |
| 646 | warn_no_callback_path(clp, task->tk_status); |
| 647 | case -EBADHANDLE: |
| 648 | case -NFS4ERR_BAD_STATEID: |
| 649 | /* Race: client probably got cb_recall |
| 650 | * before open reply granting delegation */ |
| 651 | break; |
| 652 | default: |
| 653 | /* success, or error we can't handle */ |
| 654 | return; |
| 655 | } |
| 656 | if (dp->dl_retries--) { |
| 657 | rpc_delay(task, 2*HZ); |
| 658 | task->tk_status = 0; |
| 659 | rpc_restart_call(task); |
| 660 | } else { |
| 661 | atomic_set(&clp->cl_cb_conn.cb_set, 0); |
| 662 | warn_no_callback_path(clp, task->tk_status); |
| 663 | } |
| 664 | } |
| 665 | |
| 666 | static void nfsd4_cb_recall_release(void *calldata) |
| 667 | { |
| 668 | struct nfs4_delegation *dp = calldata; |
| 669 | struct nfs4_client *clp = dp->dl_client; |
| 670 | |
| 671 | nfs4_put_delegation(dp); |
| 672 | put_nfs4_client(clp); |
| 673 | } |
| 674 | |
| 675 | static const struct rpc_call_ops nfsd4_cb_recall_ops = { |
Ricardo Labiaga | 2a1d1b5 | 2009-09-10 12:26:38 +0300 | [diff] [blame] | 676 | .rpc_call_prepare = nfsd4_cb_prepare, |
J. Bruce Fields | 63e4863 | 2009-05-01 22:36:55 -0400 | [diff] [blame] | 677 | .rpc_call_done = nfsd4_cb_recall_done, |
| 678 | .rpc_release = nfsd4_cb_recall_release, |
| 679 | }; |
| 680 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 681 | /* |
| 682 | * called with dp->dl_count inc'ed. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 683 | */ |
| 684 | void |
| 685 | nfsd4_cb_recall(struct nfs4_delegation *dp) |
| 686 | { |
| 687 | struct nfs4_client *clp = dp->dl_client; |
J. Bruce Fields | c237dc0 | 2009-04-29 19:09:19 -0400 | [diff] [blame] | 688 | struct rpc_clnt *clnt = clp->cl_cb_conn.cb_client; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 689 | struct rpc_message msg = { |
| 690 | .rpc_proc = &nfs4_cb_procedures[NFSPROC4_CLNT_CB_RECALL], |
J. Bruce Fields | b53d40c | 2009-05-01 19:50:00 -0400 | [diff] [blame] | 691 | .rpc_argp = dp, |
J. Bruce Fields | 80fc015 | 2009-09-15 18:07:35 -0400 | [diff] [blame] | 692 | .rpc_cred = callback_cred |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 693 | }; |
J. Bruce Fields | 63e4863 | 2009-05-01 22:36:55 -0400 | [diff] [blame] | 694 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 695 | |
J. Bruce Fields | 3aea09d | 2009-05-01 20:11:12 -0400 | [diff] [blame] | 696 | dp->dl_retries = 1; |
J. Bruce Fields | 63e4863 | 2009-05-01 22:36:55 -0400 | [diff] [blame] | 697 | status = rpc_call_async(clnt, &msg, RPC_TASK_SOFT, |
| 698 | &nfsd4_cb_recall_ops, dp); |
| 699 | if (status) { |
| 700 | put_nfs4_client(clp); |
| 701 | nfs4_put_delegation(dp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 702 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 703 | } |