Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * Process version 3 NFS requests. |
| 4 | * |
| 5 | * Copyright (C) 1996, 1997, 1998 Olaf Kirch <okir@monad.swb.de> |
| 6 | */ |
| 7 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | #include <linux/fs.h> |
| 9 | #include <linux/ext2_fs.h> |
Qinghuang Feng | 12214cb | 2009-01-12 03:13:53 +0800 | [diff] [blame] | 10 | #include <linux/magic.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | |
Boaz Harrosh | 9a74af2 | 2009-12-03 20:30:56 +0200 | [diff] [blame] | 12 | #include "cache.h" |
| 13 | #include "xdr3.h" |
J. Bruce Fields | 0a3adad | 2009-11-04 18:12:35 -0500 | [diff] [blame] | 14 | #include "vfs.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | |
| 16 | #define NFSDDBG_FACILITY NFSDDBG_PROC |
| 17 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | static int nfs3_ftypes[] = { |
| 19 | 0, /* NF3NON */ |
| 20 | S_IFREG, /* NF3REG */ |
| 21 | S_IFDIR, /* NF3DIR */ |
| 22 | S_IFBLK, /* NF3BLK */ |
| 23 | S_IFCHR, /* NF3CHR */ |
| 24 | S_IFLNK, /* NF3LNK */ |
| 25 | S_IFSOCK, /* NF3SOCK */ |
| 26 | S_IFIFO, /* NF3FIFO */ |
| 27 | }; |
| 28 | |
| 29 | /* |
| 30 | * NULL call. |
| 31 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 32 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 33 | nfsd3_proc_null(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | { |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 35 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | /* |
| 39 | * Get a file's attributes |
| 40 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 41 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 42 | nfsd3_proc_getattr(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 44 | struct nfsd_fhandle *argp = rqstp->rq_argp; |
| 45 | struct nfsd3_attrstat *resp = rqstp->rq_resp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | |
| 47 | dprintk("nfsd: GETATTR(3) %s\n", |
David Shaw | a334de2 | 2006-01-06 00:19:58 -0800 | [diff] [blame] | 48 | SVCFH_fmt(&argp->fh)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | |
| 50 | fh_copy(&resp->fh, &argp->fh); |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 51 | resp->status = fh_verify(rqstp, &resp->fh, 0, |
| 52 | NFSD_MAY_NOP | NFSD_MAY_BYPASS_GSS_ON_ROOT); |
| 53 | if (resp->status != nfs_ok) |
| 54 | goto out; |
David Shaw | a334de2 | 2006-01-06 00:19:58 -0800 | [diff] [blame] | 55 | |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 56 | resp->status = fh_getattr(&resp->fh, &resp->stat); |
| 57 | out: |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 58 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | /* |
| 62 | * Set a file's attributes |
| 63 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 64 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 65 | nfsd3_proc_setattr(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 67 | struct nfsd3_sattrargs *argp = rqstp->rq_argp; |
| 68 | struct nfsd3_attrstat *resp = rqstp->rq_resp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | |
| 70 | dprintk("nfsd: SETATTR(3) %s\n", |
| 71 | SVCFH_fmt(&argp->fh)); |
| 72 | |
| 73 | fh_copy(&resp->fh, &argp->fh); |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 74 | resp->status = nfsd_setattr(rqstp, &resp->fh, &argp->attrs, |
| 75 | argp->check_guard, argp->guardtime); |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 76 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | /* |
| 80 | * Look up a path name component |
| 81 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 82 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 83 | nfsd3_proc_lookup(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 85 | struct nfsd3_diropargs *argp = rqstp->rq_argp; |
| 86 | struct nfsd3_diropres *resp = rqstp->rq_resp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | |
| 88 | dprintk("nfsd: LOOKUP(3) %s %.*s\n", |
| 89 | SVCFH_fmt(&argp->fh), |
| 90 | argp->len, |
| 91 | argp->name); |
| 92 | |
| 93 | fh_copy(&resp->dirfh, &argp->fh); |
| 94 | fh_init(&resp->fh, NFS3_FHSIZE); |
| 95 | |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 96 | resp->status = nfsd_lookup(rqstp, &resp->dirfh, |
| 97 | argp->name, argp->len, |
| 98 | &resp->fh); |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 99 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | /* |
| 103 | * Check file access |
| 104 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 105 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 106 | nfsd3_proc_access(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 108 | struct nfsd3_accessargs *argp = rqstp->rq_argp; |
| 109 | struct nfsd3_accessres *resp = rqstp->rq_resp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | |
| 111 | dprintk("nfsd: ACCESS(3) %s 0x%x\n", |
| 112 | SVCFH_fmt(&argp->fh), |
| 113 | argp->access); |
| 114 | |
| 115 | fh_copy(&resp->fh, &argp->fh); |
| 116 | resp->access = argp->access; |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 117 | resp->status = nfsd_access(rqstp, &resp->fh, &resp->access, NULL); |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 118 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | /* |
| 122 | * Read a symlink. |
| 123 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 124 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 125 | nfsd3_proc_readlink(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | { |
Chuck Lever | 224c1c8 | 2020-10-24 12:51:18 -0400 | [diff] [blame] | 127 | struct nfsd_fhandle *argp = rqstp->rq_argp; |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 128 | struct nfsd3_readlinkres *resp = rqstp->rq_resp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | |
| 130 | dprintk("nfsd: READLINK(3) %s\n", SVCFH_fmt(&argp->fh)); |
| 131 | |
| 132 | /* Read the symlink. */ |
| 133 | fh_copy(&resp->fh, &argp->fh); |
| 134 | resp->len = NFS3_MAXPATHLEN; |
Chuck Lever | 9a9c892 | 2020-10-22 15:18:40 -0400 | [diff] [blame] | 135 | resp->pages = rqstp->rq_next_page++; |
| 136 | resp->status = nfsd_readlink(rqstp, &resp->fh, |
| 137 | page_address(*resp->pages), &resp->len); |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 138 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | /* |
| 142 | * Read a portion of a file. |
| 143 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 144 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 145 | nfsd3_proc_read(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 147 | struct nfsd3_readargs *argp = rqstp->rq_argp; |
| 148 | struct nfsd3_readres *resp = rqstp->rq_resp; |
Chuck Lever | be63bd2 | 2020-10-20 14:34:40 -0400 | [diff] [blame] | 149 | u32 max_blocksize = svc_max_payload(rqstp); |
| 150 | unsigned int len; |
| 151 | int v; |
| 152 | |
| 153 | argp->count = min_t(u32, argp->count, max_blocksize); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | |
J. Bruce Fields | 18b631f | 2010-11-29 15:28:10 -0500 | [diff] [blame] | 155 | dprintk("nfsd: READ(3) %s %lu bytes at %Lu\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | SVCFH_fmt(&argp->fh), |
| 157 | (unsigned long) argp->count, |
J. Bruce Fields | 18b631f | 2010-11-29 15:28:10 -0500 | [diff] [blame] | 158 | (unsigned long long) argp->offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | |
Chuck Lever | be63bd2 | 2020-10-20 14:34:40 -0400 | [diff] [blame] | 160 | v = 0; |
| 161 | len = argp->count; |
Chuck Lever | cc9bcda | 2020-10-22 15:23:50 -0400 | [diff] [blame] | 162 | resp->pages = rqstp->rq_next_page; |
Chuck Lever | be63bd2 | 2020-10-20 14:34:40 -0400 | [diff] [blame] | 163 | while (len > 0) { |
| 164 | struct page *page = *(rqstp->rq_next_page++); |
| 165 | |
| 166 | rqstp->rq_vec[v].iov_base = page_address(page); |
| 167 | rqstp->rq_vec[v].iov_len = min_t(unsigned int, len, PAGE_SIZE); |
| 168 | len -= rqstp->rq_vec[v].iov_len; |
| 169 | v++; |
| 170 | } |
| 171 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | /* Obtain buffer pointer for payload. |
| 173 | * 1 (status) + 22 (post_op_attr) + 1 (count) + 1 (eof) |
| 174 | * + 1 (xdr opaque byte count) = 26 |
| 175 | */ |
Chuck Lever | be63bd2 | 2020-10-20 14:34:40 -0400 | [diff] [blame] | 176 | resp->count = argp->count; |
Jeff Layton | cd123012 | 2007-05-09 02:34:50 -0700 | [diff] [blame] | 177 | svc_reserve_auth(rqstp, ((1 + NFS3_POST_OP_ATTR_WORDS + 3)<<2) + resp->count +4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | |
| 179 | fh_copy(&resp->fh, &argp->fh); |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 180 | resp->status = nfsd_read(rqstp, &resp->fh, argp->offset, |
Chuck Lever | be63bd2 | 2020-10-20 14:34:40 -0400 | [diff] [blame] | 181 | rqstp->rq_vec, v, &resp->count, &resp->eof); |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 182 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | } |
| 184 | |
| 185 | /* |
| 186 | * Write data to a file |
| 187 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 188 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 189 | nfsd3_proc_write(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 191 | struct nfsd3_writeargs *argp = rqstp->rq_argp; |
| 192 | struct nfsd3_writeres *resp = rqstp->rq_resp; |
David Shaw | 31dec25 | 2009-03-05 20:16:14 -0500 | [diff] [blame] | 193 | unsigned long cnt = argp->len; |
Chuck Lever | 8154ef2 | 2018-03-27 10:54:07 -0400 | [diff] [blame] | 194 | unsigned int nvecs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | |
J. Bruce Fields | 18b631f | 2010-11-29 15:28:10 -0500 | [diff] [blame] | 196 | dprintk("nfsd: WRITE(3) %s %d bytes at %Lu%s\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | SVCFH_fmt(&argp->fh), |
| 198 | argp->len, |
J. Bruce Fields | 18b631f | 2010-11-29 15:28:10 -0500 | [diff] [blame] | 199 | (unsigned long long) argp->offset, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | argp->stable? " stable" : ""); |
| 201 | |
| 202 | fh_copy(&resp->fh, &argp->fh); |
| 203 | resp->committed = argp->stable; |
Chuck Lever | dae9a6c | 2021-09-30 17:06:21 -0400 | [diff] [blame] | 204 | nvecs = svc_fill_write_vector(rqstp, &argp->payload); |
Chuck Lever | 6a2f774 | 2021-12-21 11:52:06 -0500 | [diff] [blame] | 205 | |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 206 | resp->status = nfsd_write(rqstp, &resp->fh, argp->offset, |
| 207 | rqstp->rq_vec, nvecs, &cnt, |
| 208 | resp->committed, resp->verf); |
David Shaw | 31dec25 | 2009-03-05 20:16:14 -0500 | [diff] [blame] | 209 | resp->count = cnt; |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 210 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | } |
| 212 | |
| 213 | /* |
| 214 | * With NFSv3, CREATE processing is a lot easier than with NFSv2. |
| 215 | * At least in theory; we'll see how it fares in practice when the |
| 216 | * first reports about SunOS compatibility problems start to pour in... |
| 217 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 218 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 219 | nfsd3_proc_create(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 221 | struct nfsd3_createargs *argp = rqstp->rq_argp; |
| 222 | struct nfsd3_diropres *resp = rqstp->rq_resp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | svc_fh *dirfhp, *newfhp = NULL; |
| 224 | struct iattr *attr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | |
| 226 | dprintk("nfsd: CREATE(3) %s %.*s\n", |
| 227 | SVCFH_fmt(&argp->fh), |
| 228 | argp->len, |
| 229 | argp->name); |
| 230 | |
| 231 | dirfhp = fh_copy(&resp->dirfh, &argp->fh); |
| 232 | newfhp = fh_init(&resp->fh, NFS3_FHSIZE); |
| 233 | attr = &argp->attrs; |
| 234 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | /* Unfudge the mode bits */ |
| 236 | attr->ia_mode &= ~S_IFMT; |
| 237 | if (!(attr->ia_valid & ATTR_MODE)) { |
| 238 | attr->ia_valid |= ATTR_MODE; |
| 239 | attr->ia_mode = S_IFREG; |
| 240 | } else { |
| 241 | attr->ia_mode = (attr->ia_mode & ~S_IFMT) | S_IFREG; |
| 242 | } |
| 243 | |
| 244 | /* Now create the file and set attributes */ |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 245 | resp->status = do_nfsd_create(rqstp, dirfhp, argp->name, argp->len, |
| 246 | attr, newfhp, argp->createmode, |
| 247 | (u32 *)argp->verf, NULL, NULL); |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 248 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | /* |
| 252 | * Make directory. This operation is not idempotent. |
| 253 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 254 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 255 | nfsd3_proc_mkdir(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 257 | struct nfsd3_createargs *argp = rqstp->rq_argp; |
| 258 | struct nfsd3_diropres *resp = rqstp->rq_resp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 259 | |
| 260 | dprintk("nfsd: MKDIR(3) %s %.*s\n", |
| 261 | SVCFH_fmt(&argp->fh), |
| 262 | argp->len, |
| 263 | argp->name); |
| 264 | |
| 265 | argp->attrs.ia_valid &= ~ATTR_SIZE; |
| 266 | fh_copy(&resp->dirfh, &argp->fh); |
| 267 | fh_init(&resp->fh, NFS3_FHSIZE); |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 268 | resp->status = nfsd_create(rqstp, &resp->dirfh, argp->name, argp->len, |
| 269 | &argp->attrs, S_IFDIR, 0, &resp->fh); |
Chuck Lever | 43a9aa6 | 2010-07-06 16:53:34 -0400 | [diff] [blame] | 270 | fh_unlock(&resp->dirfh); |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 271 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | } |
| 273 | |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 274 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 275 | nfsd3_proc_symlink(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 277 | struct nfsd3_symlinkargs *argp = rqstp->rq_argp; |
| 278 | struct nfsd3_diropres *resp = rqstp->rq_resp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 280 | if (argp->tlen == 0) { |
| 281 | resp->status = nfserr_inval; |
| 282 | goto out; |
| 283 | } |
| 284 | if (argp->tlen > NFS3_MAXPATHLEN) { |
| 285 | resp->status = nfserr_nametoolong; |
| 286 | goto out; |
| 287 | } |
Chuck Lever | 38a7031 | 2018-03-27 10:54:21 -0400 | [diff] [blame] | 288 | |
| 289 | argp->tname = svc_fill_symlink_pathname(rqstp, &argp->first, |
Chuck Lever | 11b4d66 | 2018-07-27 11:19:10 -0400 | [diff] [blame] | 290 | page_address(rqstp->rq_arg.pages[0]), |
Chuck Lever | 38a7031 | 2018-03-27 10:54:21 -0400 | [diff] [blame] | 291 | argp->tlen); |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 292 | if (IS_ERR(argp->tname)) { |
| 293 | resp->status = nfserrno(PTR_ERR(argp->tname)); |
| 294 | goto out; |
| 295 | } |
Chuck Lever | 38a7031 | 2018-03-27 10:54:21 -0400 | [diff] [blame] | 296 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | dprintk("nfsd: SYMLINK(3) %s %.*s -> %.*s\n", |
| 298 | SVCFH_fmt(&argp->ffh), |
| 299 | argp->flen, argp->fname, |
| 300 | argp->tlen, argp->tname); |
| 301 | |
| 302 | fh_copy(&resp->dirfh, &argp->ffh); |
| 303 | fh_init(&resp->fh, NFS3_FHSIZE); |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 304 | resp->status = nfsd_symlink(rqstp, &resp->dirfh, argp->fname, |
| 305 | argp->flen, argp->tname, &resp->fh); |
Chuck Lever | 11b4d66 | 2018-07-27 11:19:10 -0400 | [diff] [blame] | 306 | kfree(argp->tname); |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 307 | out: |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 308 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | } |
| 310 | |
| 311 | /* |
| 312 | * Make socket/fifo/device. |
| 313 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 314 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 315 | nfsd3_proc_mknod(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 317 | struct nfsd3_mknodargs *argp = rqstp->rq_argp; |
| 318 | struct nfsd3_diropres *resp = rqstp->rq_resp; |
Al Viro | c4d987b | 2006-10-19 23:29:00 -0700 | [diff] [blame] | 319 | int type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | dev_t rdev = 0; |
| 321 | |
| 322 | dprintk("nfsd: MKNOD(3) %s %.*s\n", |
| 323 | SVCFH_fmt(&argp->fh), |
| 324 | argp->len, |
| 325 | argp->name); |
| 326 | |
| 327 | fh_copy(&resp->dirfh, &argp->fh); |
| 328 | fh_init(&resp->fh, NFS3_FHSIZE); |
| 329 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | if (argp->ftype == NF3CHR || argp->ftype == NF3BLK) { |
| 331 | rdev = MKDEV(argp->major, argp->minor); |
| 332 | if (MAJOR(rdev) != argp->major || |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 333 | MINOR(rdev) != argp->minor) { |
| 334 | resp->status = nfserr_inval; |
| 335 | goto out; |
| 336 | } |
| 337 | } else if (argp->ftype != NF3SOCK && argp->ftype != NF3FIFO) { |
Chuck Lever | 66d60e3 | 2020-10-23 10:41:12 -0400 | [diff] [blame] | 338 | resp->status = nfserr_badtype; |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 339 | goto out; |
| 340 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | |
| 342 | type = nfs3_ftypes[argp->ftype]; |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 343 | resp->status = nfsd_create(rqstp, &resp->dirfh, argp->name, argp->len, |
| 344 | &argp->attrs, type, rdev, &resp->fh); |
Chuck Lever | 43a9aa6 | 2010-07-06 16:53:34 -0400 | [diff] [blame] | 345 | fh_unlock(&resp->dirfh); |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 346 | out: |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 347 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | } |
| 349 | |
| 350 | /* |
| 351 | * Remove file/fifo/socket etc. |
| 352 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 353 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 354 | nfsd3_proc_remove(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 356 | struct nfsd3_diropargs *argp = rqstp->rq_argp; |
| 357 | struct nfsd3_attrstat *resp = rqstp->rq_resp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | |
| 359 | dprintk("nfsd: REMOVE(3) %s %.*s\n", |
| 360 | SVCFH_fmt(&argp->fh), |
| 361 | argp->len, |
| 362 | argp->name); |
| 363 | |
| 364 | /* Unlink. -S_IFDIR means file must not be a directory */ |
| 365 | fh_copy(&resp->fh, &argp->fh); |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 366 | resp->status = nfsd_unlink(rqstp, &resp->fh, -S_IFDIR, |
| 367 | argp->name, argp->len); |
Chuck Lever | 43a9aa6 | 2010-07-06 16:53:34 -0400 | [diff] [blame] | 368 | fh_unlock(&resp->fh); |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 369 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 | } |
| 371 | |
| 372 | /* |
| 373 | * Remove a directory |
| 374 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 375 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 376 | nfsd3_proc_rmdir(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 377 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 378 | struct nfsd3_diropargs *argp = rqstp->rq_argp; |
| 379 | struct nfsd3_attrstat *resp = rqstp->rq_resp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 380 | |
| 381 | dprintk("nfsd: RMDIR(3) %s %.*s\n", |
| 382 | SVCFH_fmt(&argp->fh), |
| 383 | argp->len, |
| 384 | argp->name); |
| 385 | |
| 386 | fh_copy(&resp->fh, &argp->fh); |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 387 | resp->status = nfsd_unlink(rqstp, &resp->fh, S_IFDIR, |
| 388 | argp->name, argp->len); |
Chuck Lever | 43a9aa6 | 2010-07-06 16:53:34 -0400 | [diff] [blame] | 389 | fh_unlock(&resp->fh); |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 390 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | } |
| 392 | |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 393 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 394 | nfsd3_proc_rename(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 396 | struct nfsd3_renameargs *argp = rqstp->rq_argp; |
| 397 | struct nfsd3_renameres *resp = rqstp->rq_resp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 398 | |
| 399 | dprintk("nfsd: RENAME(3) %s %.*s ->\n", |
| 400 | SVCFH_fmt(&argp->ffh), |
| 401 | argp->flen, |
| 402 | argp->fname); |
| 403 | dprintk("nfsd: -> %s %.*s\n", |
| 404 | SVCFH_fmt(&argp->tfh), |
| 405 | argp->tlen, |
| 406 | argp->tname); |
| 407 | |
| 408 | fh_copy(&resp->ffh, &argp->ffh); |
| 409 | fh_copy(&resp->tfh, &argp->tfh); |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 410 | resp->status = nfsd_rename(rqstp, &resp->ffh, argp->fname, argp->flen, |
| 411 | &resp->tfh, argp->tname, argp->tlen); |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 412 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | } |
| 414 | |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 415 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 416 | nfsd3_proc_link(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 417 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 418 | struct nfsd3_linkargs *argp = rqstp->rq_argp; |
| 419 | struct nfsd3_linkres *resp = rqstp->rq_resp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | |
| 421 | dprintk("nfsd: LINK(3) %s ->\n", |
| 422 | SVCFH_fmt(&argp->ffh)); |
| 423 | dprintk("nfsd: -> %s %.*s\n", |
| 424 | SVCFH_fmt(&argp->tfh), |
| 425 | argp->tlen, |
| 426 | argp->tname); |
| 427 | |
| 428 | fh_copy(&resp->fh, &argp->ffh); |
| 429 | fh_copy(&resp->tfh, &argp->tfh); |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 430 | resp->status = nfsd_link(rqstp, &resp->tfh, argp->tname, argp->tlen, |
| 431 | &resp->fh); |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 432 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 433 | } |
| 434 | |
Chuck Lever | 40116eb | 2020-11-17 09:50:23 -0500 | [diff] [blame] | 435 | static void nfsd3_init_dirlist_pages(struct svc_rqst *rqstp, |
| 436 | struct nfsd3_readdirres *resp, |
Chuck Lever | 53b1119 | 2021-12-16 11:12:11 -0500 | [diff] [blame] | 437 | u32 count) |
Chuck Lever | 40116eb | 2020-11-17 09:50:23 -0500 | [diff] [blame] | 438 | { |
Chuck Lever | 7f87fc2 | 2020-10-22 19:46:58 -0400 | [diff] [blame] | 439 | struct xdr_buf *buf = &resp->dirlist; |
| 440 | struct xdr_stream *xdr = &resp->xdr; |
| 441 | |
Chuck Lever | 53b1119 | 2021-12-16 11:12:11 -0500 | [diff] [blame] | 442 | count = clamp(count, (u32)(XDR_UNIT * 2), svc_max_payload(rqstp)); |
Chuck Lever | 40116eb | 2020-11-17 09:50:23 -0500 | [diff] [blame] | 443 | |
Chuck Lever | 7f87fc2 | 2020-10-22 19:46:58 -0400 | [diff] [blame] | 444 | memset(buf, 0, sizeof(*buf)); |
Chuck Lever | 40116eb | 2020-11-17 09:50:23 -0500 | [diff] [blame] | 445 | |
Chuck Lever | 7f87fc2 | 2020-10-22 19:46:58 -0400 | [diff] [blame] | 446 | /* Reserve room for the NULL ptr & eof flag (-2 words) */ |
| 447 | buf->buflen = count - XDR_UNIT * 2; |
| 448 | buf->pages = rqstp->rq_next_page; |
Chuck Lever | 53b1119 | 2021-12-16 11:12:11 -0500 | [diff] [blame] | 449 | rqstp->rq_next_page += (buf->buflen + PAGE_SIZE - 1) >> PAGE_SHIFT; |
Chuck Lever | 7f87fc2 | 2020-10-22 19:46:58 -0400 | [diff] [blame] | 450 | |
| 451 | /* This is xdr_init_encode(), but it assumes that |
| 452 | * the head kvec has already been consumed. */ |
| 453 | xdr_set_scratch_buffer(xdr, NULL, 0); |
| 454 | xdr->buf = buf; |
| 455 | xdr->page_ptr = buf->pages; |
| 456 | xdr->iov = NULL; |
| 457 | xdr->p = page_address(*buf->pages); |
Chuck Lever | 53b1119 | 2021-12-16 11:12:11 -0500 | [diff] [blame] | 458 | xdr->end = (void *)xdr->p + min_t(u32, buf->buflen, PAGE_SIZE); |
Chuck Lever | 7f87fc2 | 2020-10-22 19:46:58 -0400 | [diff] [blame] | 459 | xdr->rqst = NULL; |
Chuck Lever | 40116eb | 2020-11-17 09:50:23 -0500 | [diff] [blame] | 460 | } |
| 461 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | /* |
| 463 | * Read a portion of a directory. |
| 464 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 465 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 466 | nfsd3_proc_readdir(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 468 | struct nfsd3_readdirargs *argp = rqstp->rq_argp; |
| 469 | struct nfsd3_readdirres *resp = rqstp->rq_resp; |
Chuck Lever | 0a8f37f | 2020-11-10 10:24:39 -0500 | [diff] [blame] | 470 | loff_t offset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 471 | |
| 472 | dprintk("nfsd: READDIR(3) %s %d bytes at %d\n", |
| 473 | SVCFH_fmt(&argp->fh), |
| 474 | argp->count, (u32) argp->cookie); |
| 475 | |
Chuck Lever | 40116eb | 2020-11-17 09:50:23 -0500 | [diff] [blame] | 476 | nfsd3_init_dirlist_pages(rqstp, resp, argp->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 478 | fh_copy(&resp->fh, &argp->fh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 479 | resp->common.err = nfs_ok; |
Chuck Lever | 7f87fc2 | 2020-10-22 19:46:58 -0400 | [diff] [blame] | 480 | resp->cookie_offset = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 481 | resp->rqstp = rqstp; |
Chuck Lever | 0a8f37f | 2020-11-10 10:24:39 -0500 | [diff] [blame] | 482 | offset = argp->cookie; |
Chuck Lever | 0a8f37f | 2020-11-10 10:24:39 -0500 | [diff] [blame] | 483 | resp->status = nfsd_readdir(rqstp, &resp->fh, &offset, |
Chuck Lever | 7f87fc2 | 2020-10-22 19:46:58 -0400 | [diff] [blame] | 484 | &resp->common, nfs3svc_encode_entry3); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | memcpy(resp->verf, argp->verf, 8); |
Chuck Lever | a161e6c | 2020-11-10 09:57:14 -0500 | [diff] [blame] | 486 | nfs3svc_encode_cookie3(resp, offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 487 | |
Chuck Lever | 76ed0dd | 2021-01-15 09:28:44 -0500 | [diff] [blame] | 488 | /* Recycle only pages that were part of the reply */ |
| 489 | rqstp->rq_next_page = resp->xdr.page_ptr + 1; |
| 490 | |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 491 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 492 | } |
| 493 | |
| 494 | /* |
| 495 | * Read a portion of a directory, including file handles and attrs. |
| 496 | * For now, we choose to ignore the dircount parameter. |
| 497 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 498 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 499 | nfsd3_proc_readdirplus(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 501 | struct nfsd3_readdirargs *argp = rqstp->rq_argp; |
| 502 | struct nfsd3_readdirres *resp = rqstp->rq_resp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 503 | loff_t offset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 504 | |
| 505 | dprintk("nfsd: READDIR+(3) %s %d bytes at %d\n", |
| 506 | SVCFH_fmt(&argp->fh), |
| 507 | argp->count, (u32) argp->cookie); |
| 508 | |
Chuck Lever | 40116eb | 2020-11-17 09:50:23 -0500 | [diff] [blame] | 509 | nfsd3_init_dirlist_pages(rqstp, resp, argp->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 510 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | fh_copy(&resp->fh, &argp->fh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 512 | resp->common.err = nfs_ok; |
Chuck Lever | 7f87fc2 | 2020-10-22 19:46:58 -0400 | [diff] [blame] | 513 | resp->cookie_offset = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 514 | resp->rqstp = rqstp; |
| 515 | offset = argp->cookie; |
Rajesh Ghanekar | 18c01ab | 2014-08-01 22:17:30 -0400 | [diff] [blame] | 516 | |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 517 | resp->status = fh_verify(rqstp, &resp->fh, S_IFDIR, NFSD_MAY_NOP); |
| 518 | if (resp->status != nfs_ok) |
| 519 | goto out; |
Rajesh Ghanekar | 18c01ab | 2014-08-01 22:17:30 -0400 | [diff] [blame] | 520 | |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 521 | if (resp->fh.fh_export->ex_flags & NFSEXP_NOREADDIRPLUS) { |
| 522 | resp->status = nfserr_notsupp; |
| 523 | goto out; |
| 524 | } |
Rajesh Ghanekar | 18c01ab | 2014-08-01 22:17:30 -0400 | [diff] [blame] | 525 | |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 526 | resp->status = nfsd_readdir(rqstp, &resp->fh, &offset, |
Chuck Lever | 7f87fc2 | 2020-10-22 19:46:58 -0400 | [diff] [blame] | 527 | &resp->common, nfs3svc_encode_entryplus3); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 528 | memcpy(resp->verf, argp->verf, 8); |
Chuck Lever | a161e6c | 2020-11-10 09:57:14 -0500 | [diff] [blame] | 529 | nfs3svc_encode_cookie3(resp, offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 530 | |
Chuck Lever | 76ed0dd | 2021-01-15 09:28:44 -0500 | [diff] [blame] | 531 | /* Recycle only pages that were part of the reply */ |
| 532 | rqstp->rq_next_page = resp->xdr.page_ptr + 1; |
| 533 | |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 534 | out: |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 535 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 536 | } |
| 537 | |
| 538 | /* |
| 539 | * Get file system stats |
| 540 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 541 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 542 | nfsd3_proc_fsstat(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 543 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 544 | struct nfsd_fhandle *argp = rqstp->rq_argp; |
| 545 | struct nfsd3_fsstatres *resp = rqstp->rq_resp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 546 | |
| 547 | dprintk("nfsd: FSSTAT(3) %s\n", |
| 548 | SVCFH_fmt(&argp->fh)); |
| 549 | |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 550 | resp->status = nfsd_statfs(rqstp, &argp->fh, &resp->stats, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 551 | fh_put(&argp->fh); |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 552 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 553 | } |
| 554 | |
| 555 | /* |
| 556 | * Get file system info |
| 557 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 558 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 559 | nfsd3_proc_fsinfo(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 560 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 561 | struct nfsd_fhandle *argp = rqstp->rq_argp; |
| 562 | struct nfsd3_fsinfores *resp = rqstp->rq_resp; |
Greg Banks | 7adae48 | 2006-10-04 02:15:47 -0700 | [diff] [blame] | 563 | u32 max_blocksize = svc_max_payload(rqstp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 564 | |
| 565 | dprintk("nfsd: FSINFO(3) %s\n", |
| 566 | SVCFH_fmt(&argp->fh)); |
| 567 | |
Greg Banks | 7adae48 | 2006-10-04 02:15:47 -0700 | [diff] [blame] | 568 | resp->f_rtmax = max_blocksize; |
| 569 | resp->f_rtpref = max_blocksize; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 570 | resp->f_rtmult = PAGE_SIZE; |
Greg Banks | 7adae48 | 2006-10-04 02:15:47 -0700 | [diff] [blame] | 571 | resp->f_wtmax = max_blocksize; |
| 572 | resp->f_wtpref = max_blocksize; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 573 | resp->f_wtmult = PAGE_SIZE; |
NeilBrown | f875a79 | 2019-03-07 09:49:46 +1100 | [diff] [blame] | 574 | resp->f_dtpref = max_blocksize; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 575 | resp->f_maxfilesize = ~(u32) 0; |
| 576 | resp->f_properties = NFS3_FSF_DEFAULT; |
| 577 | |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 578 | resp->status = fh_verify(rqstp, &argp->fh, 0, |
| 579 | NFSD_MAY_NOP | NFSD_MAY_BYPASS_GSS_ON_ROOT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 580 | |
| 581 | /* Check special features of the file system. May request |
| 582 | * different read/write sizes for file systems known to have |
| 583 | * problems with large blocks */ |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 584 | if (resp->status == nfs_ok) { |
Al Viro | fc64005 | 2016-04-10 01:33:30 -0400 | [diff] [blame] | 585 | struct super_block *sb = argp->fh.fh_dentry->d_sb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 586 | |
| 587 | /* Note that we don't care for remote fs's here */ |
Qinghuang Feng | 12214cb | 2009-01-12 03:13:53 +0800 | [diff] [blame] | 588 | if (sb->s_magic == MSDOS_SUPER_MAGIC) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 589 | resp->f_properties = NFS3_FSF_BILLYBOY; |
| 590 | } |
| 591 | resp->f_maxfilesize = sb->s_maxbytes; |
| 592 | } |
| 593 | |
| 594 | fh_put(&argp->fh); |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 595 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 596 | } |
| 597 | |
| 598 | /* |
| 599 | * Get pathconf info for the specified file |
| 600 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 601 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 602 | nfsd3_proc_pathconf(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 603 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 604 | struct nfsd_fhandle *argp = rqstp->rq_argp; |
| 605 | struct nfsd3_pathconfres *resp = rqstp->rq_resp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 606 | |
| 607 | dprintk("nfsd: PATHCONF(3) %s\n", |
| 608 | SVCFH_fmt(&argp->fh)); |
| 609 | |
| 610 | /* Set default pathconf */ |
| 611 | resp->p_link_max = 255; /* at least */ |
| 612 | resp->p_name_max = 255; /* at least */ |
| 613 | resp->p_no_trunc = 0; |
| 614 | resp->p_chown_restricted = 1; |
| 615 | resp->p_case_insensitive = 0; |
| 616 | resp->p_case_preserving = 1; |
| 617 | |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 618 | resp->status = fh_verify(rqstp, &argp->fh, 0, NFSD_MAY_NOP); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 | |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 620 | if (resp->status == nfs_ok) { |
Al Viro | fc64005 | 2016-04-10 01:33:30 -0400 | [diff] [blame] | 621 | struct super_block *sb = argp->fh.fh_dentry->d_sb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 622 | |
| 623 | /* Note that we don't care for remote fs's here */ |
| 624 | switch (sb->s_magic) { |
| 625 | case EXT2_SUPER_MAGIC: |
| 626 | resp->p_link_max = EXT2_LINK_MAX; |
| 627 | resp->p_name_max = EXT2_NAME_LEN; |
| 628 | break; |
Qinghuang Feng | 12214cb | 2009-01-12 03:13:53 +0800 | [diff] [blame] | 629 | case MSDOS_SUPER_MAGIC: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | resp->p_case_insensitive = 1; |
| 631 | resp->p_case_preserving = 0; |
| 632 | break; |
| 633 | } |
| 634 | } |
| 635 | |
| 636 | fh_put(&argp->fh); |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 637 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 638 | } |
| 639 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 640 | /* |
| 641 | * Commit a file (range) to stable storage. |
| 642 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 643 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 644 | nfsd3_proc_commit(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 646 | struct nfsd3_commitargs *argp = rqstp->rq_argp; |
| 647 | struct nfsd3_commitres *resp = rqstp->rq_resp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 648 | |
| 649 | dprintk("nfsd: COMMIT(3) %s %u@%Lu\n", |
| 650 | SVCFH_fmt(&argp->fh), |
| 651 | argp->count, |
| 652 | (unsigned long long) argp->offset); |
| 653 | |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 654 | if (argp->offset > NFS_OFFSET_MAX) { |
| 655 | resp->status = nfserr_inval; |
| 656 | goto out; |
| 657 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 658 | |
| 659 | fh_copy(&resp->fh, &argp->fh); |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 660 | resp->status = nfsd_commit(rqstp, &resp->fh, argp->offset, |
| 661 | argp->count, resp->verf); |
| 662 | out: |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 663 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 664 | } |
| 665 | |
| 666 | |
| 667 | /* |
| 668 | * NFSv3 Server procedures. |
| 669 | * Only the results of non-idempotent operations are cached. |
| 670 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 671 | #define nfs3svc_encode_attrstatres nfs3svc_encode_attrstat |
| 672 | #define nfs3svc_encode_wccstatres nfs3svc_encode_wccstat |
| 673 | #define nfsd3_mkdirargs nfsd3_createargs |
| 674 | #define nfsd3_readdirplusargs nfsd3_readdirargs |
| 675 | #define nfsd3_fhandleargs nfsd_fhandle |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 676 | #define nfsd3_attrstatres nfsd3_attrstat |
| 677 | #define nfsd3_wccstatres nfsd3_attrstat |
| 678 | #define nfsd3_createres nfsd3_diropres |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 679 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 680 | #define ST 1 /* status*/ |
| 681 | #define FH 17 /* filehandle with length */ |
| 682 | #define AT 21 /* attributes */ |
| 683 | #define pAT (1+AT) /* post attributes - conditional */ |
| 684 | #define WC (7+pAT) /* WCC attributes */ |
| 685 | |
Christoph Hellwig | 860bda2 | 2017-05-12 16:11:49 +0200 | [diff] [blame] | 686 | static const struct svc_procedure nfsd_procedures3[22] = { |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 687 | [NFS3PROC_NULL] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 688 | .pc_func = nfsd3_proc_null, |
Chuck Lever | 788f718 | 2020-11-05 14:48:29 -0500 | [diff] [blame] | 689 | .pc_decode = nfssvc_decode_voidarg, |
| 690 | .pc_encode = nfssvc_encode_voidres, |
| 691 | .pc_argsize = sizeof(struct nfsd_voidargs), |
| 692 | .pc_ressize = sizeof(struct nfsd_voidres), |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 693 | .pc_cachetype = RC_NOCACHE, |
| 694 | .pc_xdrressize = ST, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 695 | .pc_name = "NULL", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 696 | }, |
| 697 | [NFS3PROC_GETATTR] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 698 | .pc_func = nfsd3_proc_getattr, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 699 | .pc_decode = nfs3svc_decode_fhandleargs, |
Chuck Lever | 2c42f80 | 2020-10-21 11:58:41 -0400 | [diff] [blame] | 700 | .pc_encode = nfs3svc_encode_getattrres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 701 | .pc_release = nfs3svc_release_fhandle, |
Chuck Lever | 9575363 | 2020-10-20 14:30:02 -0400 | [diff] [blame] | 702 | .pc_argsize = sizeof(struct nfsd_fhandle), |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 703 | .pc_ressize = sizeof(struct nfsd3_attrstatres), |
| 704 | .pc_cachetype = RC_NOCACHE, |
| 705 | .pc_xdrressize = ST+AT, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 706 | .pc_name = "GETATTR", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 707 | }, |
| 708 | [NFS3PROC_SETATTR] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 709 | .pc_func = nfsd3_proc_setattr, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 710 | .pc_decode = nfs3svc_decode_sattrargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 711 | .pc_encode = nfs3svc_encode_wccstatres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 712 | .pc_release = nfs3svc_release_fhandle, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 713 | .pc_argsize = sizeof(struct nfsd3_sattrargs), |
| 714 | .pc_ressize = sizeof(struct nfsd3_wccstatres), |
| 715 | .pc_cachetype = RC_REPLBUFF, |
| 716 | .pc_xdrressize = ST+WC, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 717 | .pc_name = "SETATTR", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 718 | }, |
| 719 | [NFS3PROC_LOOKUP] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 720 | .pc_func = nfsd3_proc_lookup, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 721 | .pc_decode = nfs3svc_decode_diropargs, |
Chuck Lever | 5cf3533 | 2020-10-22 14:46:58 -0400 | [diff] [blame] | 722 | .pc_encode = nfs3svc_encode_lookupres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 723 | .pc_release = nfs3svc_release_fhandle2, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 724 | .pc_argsize = sizeof(struct nfsd3_diropargs), |
| 725 | .pc_ressize = sizeof(struct nfsd3_diropres), |
| 726 | .pc_cachetype = RC_NOCACHE, |
| 727 | .pc_xdrressize = ST+FH+pAT+pAT, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 728 | .pc_name = "LOOKUP", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 729 | }, |
| 730 | [NFS3PROC_ACCESS] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 731 | .pc_func = nfsd3_proc_access, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 732 | .pc_decode = nfs3svc_decode_accessargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 733 | .pc_encode = nfs3svc_encode_accessres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 734 | .pc_release = nfs3svc_release_fhandle, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 735 | .pc_argsize = sizeof(struct nfsd3_accessargs), |
| 736 | .pc_ressize = sizeof(struct nfsd3_accessres), |
| 737 | .pc_cachetype = RC_NOCACHE, |
| 738 | .pc_xdrressize = ST+pAT+1, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 739 | .pc_name = "ACCESS", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 740 | }, |
| 741 | [NFS3PROC_READLINK] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 742 | .pc_func = nfsd3_proc_readlink, |
Chuck Lever | 224c1c8 | 2020-10-24 12:51:18 -0400 | [diff] [blame] | 743 | .pc_decode = nfs3svc_decode_fhandleargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 744 | .pc_encode = nfs3svc_encode_readlinkres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 745 | .pc_release = nfs3svc_release_fhandle, |
Chuck Lever | 224c1c8 | 2020-10-24 12:51:18 -0400 | [diff] [blame] | 746 | .pc_argsize = sizeof(struct nfsd_fhandle), |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 747 | .pc_ressize = sizeof(struct nfsd3_readlinkres), |
| 748 | .pc_cachetype = RC_NOCACHE, |
| 749 | .pc_xdrressize = ST+pAT+1+NFS3_MAXPATHLEN/4, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 750 | .pc_name = "READLINK", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 751 | }, |
| 752 | [NFS3PROC_READ] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 753 | .pc_func = nfsd3_proc_read, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 754 | .pc_decode = nfs3svc_decode_readargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 755 | .pc_encode = nfs3svc_encode_readres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 756 | .pc_release = nfs3svc_release_fhandle, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 757 | .pc_argsize = sizeof(struct nfsd3_readargs), |
| 758 | .pc_ressize = sizeof(struct nfsd3_readres), |
| 759 | .pc_cachetype = RC_NOCACHE, |
| 760 | .pc_xdrressize = ST+pAT+4+NFSSVC_MAXBLKSIZE/4, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 761 | .pc_name = "READ", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 762 | }, |
| 763 | [NFS3PROC_WRITE] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 764 | .pc_func = nfsd3_proc_write, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 765 | .pc_decode = nfs3svc_decode_writeargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 766 | .pc_encode = nfs3svc_encode_writeres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 767 | .pc_release = nfs3svc_release_fhandle, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 768 | .pc_argsize = sizeof(struct nfsd3_writeargs), |
| 769 | .pc_ressize = sizeof(struct nfsd3_writeres), |
| 770 | .pc_cachetype = RC_REPLBUFF, |
| 771 | .pc_xdrressize = ST+WC+4, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 772 | .pc_name = "WRITE", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 773 | }, |
| 774 | [NFS3PROC_CREATE] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 775 | .pc_func = nfsd3_proc_create, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 776 | .pc_decode = nfs3svc_decode_createargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 777 | .pc_encode = nfs3svc_encode_createres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 778 | .pc_release = nfs3svc_release_fhandle2, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 779 | .pc_argsize = sizeof(struct nfsd3_createargs), |
| 780 | .pc_ressize = sizeof(struct nfsd3_createres), |
| 781 | .pc_cachetype = RC_REPLBUFF, |
| 782 | .pc_xdrressize = ST+(1+FH+pAT)+WC, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 783 | .pc_name = "CREATE", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 784 | }, |
| 785 | [NFS3PROC_MKDIR] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 786 | .pc_func = nfsd3_proc_mkdir, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 787 | .pc_decode = nfs3svc_decode_mkdirargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 788 | .pc_encode = nfs3svc_encode_createres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 789 | .pc_release = nfs3svc_release_fhandle2, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 790 | .pc_argsize = sizeof(struct nfsd3_mkdirargs), |
| 791 | .pc_ressize = sizeof(struct nfsd3_createres), |
| 792 | .pc_cachetype = RC_REPLBUFF, |
| 793 | .pc_xdrressize = ST+(1+FH+pAT)+WC, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 794 | .pc_name = "MKDIR", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 795 | }, |
| 796 | [NFS3PROC_SYMLINK] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 797 | .pc_func = nfsd3_proc_symlink, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 798 | .pc_decode = nfs3svc_decode_symlinkargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 799 | .pc_encode = nfs3svc_encode_createres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 800 | .pc_release = nfs3svc_release_fhandle2, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 801 | .pc_argsize = sizeof(struct nfsd3_symlinkargs), |
| 802 | .pc_ressize = sizeof(struct nfsd3_createres), |
| 803 | .pc_cachetype = RC_REPLBUFF, |
| 804 | .pc_xdrressize = ST+(1+FH+pAT)+WC, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 805 | .pc_name = "SYMLINK", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 806 | }, |
| 807 | [NFS3PROC_MKNOD] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 808 | .pc_func = nfsd3_proc_mknod, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 809 | .pc_decode = nfs3svc_decode_mknodargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 810 | .pc_encode = nfs3svc_encode_createres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 811 | .pc_release = nfs3svc_release_fhandle2, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 812 | .pc_argsize = sizeof(struct nfsd3_mknodargs), |
| 813 | .pc_ressize = sizeof(struct nfsd3_createres), |
| 814 | .pc_cachetype = RC_REPLBUFF, |
| 815 | .pc_xdrressize = ST+(1+FH+pAT)+WC, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 816 | .pc_name = "MKNOD", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 817 | }, |
| 818 | [NFS3PROC_REMOVE] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 819 | .pc_func = nfsd3_proc_remove, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 820 | .pc_decode = nfs3svc_decode_diropargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 821 | .pc_encode = nfs3svc_encode_wccstatres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 822 | .pc_release = nfs3svc_release_fhandle, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 823 | .pc_argsize = sizeof(struct nfsd3_diropargs), |
| 824 | .pc_ressize = sizeof(struct nfsd3_wccstatres), |
| 825 | .pc_cachetype = RC_REPLBUFF, |
| 826 | .pc_xdrressize = ST+WC, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 827 | .pc_name = "REMOVE", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 828 | }, |
| 829 | [NFS3PROC_RMDIR] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 830 | .pc_func = nfsd3_proc_rmdir, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 831 | .pc_decode = nfs3svc_decode_diropargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 832 | .pc_encode = nfs3svc_encode_wccstatres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 833 | .pc_release = nfs3svc_release_fhandle, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 834 | .pc_argsize = sizeof(struct nfsd3_diropargs), |
| 835 | .pc_ressize = sizeof(struct nfsd3_wccstatres), |
| 836 | .pc_cachetype = RC_REPLBUFF, |
| 837 | .pc_xdrressize = ST+WC, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 838 | .pc_name = "RMDIR", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 839 | }, |
| 840 | [NFS3PROC_RENAME] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 841 | .pc_func = nfsd3_proc_rename, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 842 | .pc_decode = nfs3svc_decode_renameargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 843 | .pc_encode = nfs3svc_encode_renameres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 844 | .pc_release = nfs3svc_release_fhandle2, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 845 | .pc_argsize = sizeof(struct nfsd3_renameargs), |
| 846 | .pc_ressize = sizeof(struct nfsd3_renameres), |
| 847 | .pc_cachetype = RC_REPLBUFF, |
| 848 | .pc_xdrressize = ST+WC+WC, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 849 | .pc_name = "RENAME", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 850 | }, |
| 851 | [NFS3PROC_LINK] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 852 | .pc_func = nfsd3_proc_link, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 853 | .pc_decode = nfs3svc_decode_linkargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 854 | .pc_encode = nfs3svc_encode_linkres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 855 | .pc_release = nfs3svc_release_fhandle2, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 856 | .pc_argsize = sizeof(struct nfsd3_linkargs), |
| 857 | .pc_ressize = sizeof(struct nfsd3_linkres), |
| 858 | .pc_cachetype = RC_REPLBUFF, |
| 859 | .pc_xdrressize = ST+pAT+WC, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 860 | .pc_name = "LINK", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 861 | }, |
| 862 | [NFS3PROC_READDIR] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 863 | .pc_func = nfsd3_proc_readdir, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 864 | .pc_decode = nfs3svc_decode_readdirargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 865 | .pc_encode = nfs3svc_encode_readdirres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 866 | .pc_release = nfs3svc_release_fhandle, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 867 | .pc_argsize = sizeof(struct nfsd3_readdirargs), |
| 868 | .pc_ressize = sizeof(struct nfsd3_readdirres), |
| 869 | .pc_cachetype = RC_NOCACHE, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 870 | .pc_name = "READDIR", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 871 | }, |
| 872 | [NFS3PROC_READDIRPLUS] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 873 | .pc_func = nfsd3_proc_readdirplus, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 874 | .pc_decode = nfs3svc_decode_readdirplusargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 875 | .pc_encode = nfs3svc_encode_readdirres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 876 | .pc_release = nfs3svc_release_fhandle, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 877 | .pc_argsize = sizeof(struct nfsd3_readdirplusargs), |
| 878 | .pc_ressize = sizeof(struct nfsd3_readdirres), |
| 879 | .pc_cachetype = RC_NOCACHE, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 880 | .pc_name = "READDIRPLUS", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 881 | }, |
| 882 | [NFS3PROC_FSSTAT] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 883 | .pc_func = nfsd3_proc_fsstat, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 884 | .pc_decode = nfs3svc_decode_fhandleargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 885 | .pc_encode = nfs3svc_encode_fsstatres, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 886 | .pc_argsize = sizeof(struct nfsd3_fhandleargs), |
| 887 | .pc_ressize = sizeof(struct nfsd3_fsstatres), |
| 888 | .pc_cachetype = RC_NOCACHE, |
| 889 | .pc_xdrressize = ST+pAT+2*6+1, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 890 | .pc_name = "FSSTAT", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 891 | }, |
| 892 | [NFS3PROC_FSINFO] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 893 | .pc_func = nfsd3_proc_fsinfo, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 894 | .pc_decode = nfs3svc_decode_fhandleargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 895 | .pc_encode = nfs3svc_encode_fsinfores, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 896 | .pc_argsize = sizeof(struct nfsd3_fhandleargs), |
| 897 | .pc_ressize = sizeof(struct nfsd3_fsinfores), |
| 898 | .pc_cachetype = RC_NOCACHE, |
| 899 | .pc_xdrressize = ST+pAT+12, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 900 | .pc_name = "FSINFO", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 901 | }, |
| 902 | [NFS3PROC_PATHCONF] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 903 | .pc_func = nfsd3_proc_pathconf, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 904 | .pc_decode = nfs3svc_decode_fhandleargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 905 | .pc_encode = nfs3svc_encode_pathconfres, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 906 | .pc_argsize = sizeof(struct nfsd3_fhandleargs), |
| 907 | .pc_ressize = sizeof(struct nfsd3_pathconfres), |
| 908 | .pc_cachetype = RC_NOCACHE, |
| 909 | .pc_xdrressize = ST+pAT+6, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 910 | .pc_name = "PATHCONF", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 911 | }, |
| 912 | [NFS3PROC_COMMIT] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 913 | .pc_func = nfsd3_proc_commit, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 914 | .pc_decode = nfs3svc_decode_commitargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 915 | .pc_encode = nfs3svc_encode_commitres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 916 | .pc_release = nfs3svc_release_fhandle, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 917 | .pc_argsize = sizeof(struct nfsd3_commitargs), |
| 918 | .pc_ressize = sizeof(struct nfsd3_commitres), |
| 919 | .pc_cachetype = RC_NOCACHE, |
| 920 | .pc_xdrressize = ST+WC+2, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 921 | .pc_name = "COMMIT", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 922 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 923 | }; |
| 924 | |
Christoph Hellwig | 7fd38af | 2017-05-08 23:40:27 +0200 | [diff] [blame] | 925 | static unsigned int nfsd_count3[ARRAY_SIZE(nfsd_procedures3)]; |
Christoph Hellwig | e967918 | 2017-05-12 16:21:37 +0200 | [diff] [blame] | 926 | const struct svc_version nfsd_version3 = { |
| 927 | .vs_vers = 3, |
| 928 | .vs_nproc = 22, |
| 929 | .vs_proc = nfsd_procedures3, |
| 930 | .vs_dispatch = nfsd_dispatch, |
| 931 | .vs_count = nfsd_count3, |
| 932 | .vs_xdrsize = NFS3_SVC_XDRSIZE, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 933 | }; |