aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfs4xdr.c
diff options
context:
space:
mode:
authorBryan Schumaker <bjschuma@netapp.com>2011-07-13 10:50:48 -0400
committerJ. Bruce Fields <bfields@redhat.com>2011-07-15 18:58:48 -0400
commit17456804546b78a1c13d2b934c8f50bbde141a38 (patch)
treed9585ae98e98101830068c9ab29556795a162942 /fs/nfsd/nfs4xdr.c
parente1ca12dfb1be7fe8b82ca723a9b511f7d808bf81 (diff)
NFSD: Added TEST_STATEID operation
This operation is used by the client to check the validity of a list of stateids. Signed-off-by: Bryan Schumaker <bjschuma@netapp.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfs4xdr.c')
-rw-r--r--fs/nfsd/nfs4xdr.c87
1 files changed, 84 insertions, 3 deletions
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index ef9bd6f24fc0..a8d83bd5c1d5 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -44,13 +44,14 @@
44#include <linux/namei.h> 44#include <linux/namei.h>
45#include <linux/statfs.h> 45#include <linux/statfs.h>
46#include <linux/utsname.h> 46#include <linux/utsname.h>
47#include <linux/pagemap.h>
47#include <linux/sunrpc/svcauth_gss.h> 48#include <linux/sunrpc/svcauth_gss.h>
48 49
49#include "idmap.h" 50#include "idmap.h"
50#include "acl.h" 51#include "acl.h"
51#include "xdr4.h" 52#include "xdr4.h"
52#include "vfs.h" 53#include "vfs.h"
53 54#include "state.h"
54 55
55#define NFSDDBG_FACILITY NFSDDBG_XDR 56#define NFSDDBG_FACILITY NFSDDBG_XDR
56 57
@@ -131,6 +132,22 @@ xdr_error: \
131 } \ 132 } \
132} while (0) 133} while (0)
133 134
135static void save_buf(struct nfsd4_compoundargs *argp, struct nfsd4_saved_compoundargs *savep)
136{
137 savep->p = argp->p;
138 savep->end = argp->end;
139 savep->pagelen = argp->pagelen;
140 savep->pagelist = argp->pagelist;
141}
142
143static void restore_buf(struct nfsd4_compoundargs *argp, struct nfsd4_saved_compoundargs *savep)
144{
145 argp->p = savep->p;
146 argp->end = savep->end;
147 argp->pagelen = savep->pagelen;
148 argp->pagelist = savep->pagelist;
149}
150
134static __be32 *read_buf(struct nfsd4_compoundargs *argp, u32 nbytes) 151static __be32 *read_buf(struct nfsd4_compoundargs *argp, u32 nbytes)
135{ 152{
136 /* We want more bytes than seem to be available. 153 /* We want more bytes than seem to be available.
@@ -1274,6 +1291,40 @@ nfsd4_decode_sequence(struct nfsd4_compoundargs *argp,
1274 DECODE_TAIL; 1291 DECODE_TAIL;
1275} 1292}
1276 1293
1294static __be32
1295nfsd4_decode_test_stateid(struct nfsd4_compoundargs *argp, struct nfsd4_test_stateid *test_stateid)
1296{
1297 unsigned int nbytes;
1298 stateid_t si;
1299 int i;
1300 __be32 *p;
1301 __be32 status;
1302
1303 READ_BUF(4);
1304 test_stateid->ts_num_ids = ntohl(*p++);
1305
1306 nbytes = test_stateid->ts_num_ids * sizeof(stateid_t);
1307 if (nbytes > (u32)((char *)argp->end - (char *)argp->p))
1308 goto xdr_error;
1309
1310 test_stateid->ts_saved_args = argp;
1311 save_buf(argp, &test_stateid->ts_savedp);
1312
1313 for (i = 0; i < test_stateid->ts_num_ids; i++) {
1314 status = nfsd4_decode_stateid(argp, &si);
1315 if (status)
1316 return status;
1317 }
1318
1319 status = 0;
1320out:
1321 return status;
1322xdr_error:
1323 dprintk("NFSD: xdr error (%s:%d)\n", __FILE__, __LINE__);
1324 status = nfserr_bad_xdr;
1325 goto out;
1326}
1327
1277static __be32 nfsd4_decode_reclaim_complete(struct nfsd4_compoundargs *argp, struct nfsd4_reclaim_complete *rc) 1328static __be32 nfsd4_decode_reclaim_complete(struct nfsd4_compoundargs *argp, struct nfsd4_reclaim_complete *rc)
1278{ 1329{
1279 DECODE_HEAD; 1330 DECODE_HEAD;
@@ -1393,7 +1444,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
1393 [OP_SECINFO_NO_NAME] = (nfsd4_dec)nfsd4_decode_secinfo_no_name, 1444 [OP_SECINFO_NO_NAME] = (nfsd4_dec)nfsd4_decode_secinfo_no_name,
1394 [OP_SEQUENCE] = (nfsd4_dec)nfsd4_decode_sequence, 1445 [OP_SEQUENCE] = (nfsd4_dec)nfsd4_decode_sequence,
1395 [OP_SET_SSV] = (nfsd4_dec)nfsd4_decode_notsupp, 1446 [OP_SET_SSV] = (nfsd4_dec)nfsd4_decode_notsupp,
1396 [OP_TEST_STATEID] = (nfsd4_dec)nfsd4_decode_notsupp, 1447 [OP_TEST_STATEID] = (nfsd4_dec)nfsd4_decode_test_stateid,
1397 [OP_WANT_DELEGATION] = (nfsd4_dec)nfsd4_decode_notsupp, 1448 [OP_WANT_DELEGATION] = (nfsd4_dec)nfsd4_decode_notsupp,
1398 [OP_DESTROY_CLIENTID] = (nfsd4_dec)nfsd4_decode_notsupp, 1449 [OP_DESTROY_CLIENTID] = (nfsd4_dec)nfsd4_decode_notsupp,
1399 [OP_RECLAIM_COMPLETE] = (nfsd4_dec)nfsd4_decode_reclaim_complete, 1450 [OP_RECLAIM_COMPLETE] = (nfsd4_dec)nfsd4_decode_reclaim_complete,
@@ -3166,6 +3217,36 @@ nfsd4_encode_sequence(struct nfsd4_compoundres *resp, int nfserr,
3166 return 0; 3217 return 0;
3167} 3218}
3168 3219
3220__be32
3221nfsd4_encode_test_stateid(struct nfsd4_compoundres *resp, int nfserr,
3222 struct nfsd4_test_stateid *test_stateid)
3223{
3224 struct nfsd4_compoundargs *argp;
3225 stateid_t si;
3226 __be32 *p;
3227 int i;
3228 int valid;
3229
3230 restore_buf(test_stateid->ts_saved_args, &test_stateid->ts_savedp);
3231 argp = test_stateid->ts_saved_args;
3232
3233 RESERVE_SPACE(4);
3234 *p++ = htonl(test_stateid->ts_num_ids);
3235 resp->p = p;
3236
3237 nfs4_lock_state();
3238 for (i = 0; i < test_stateid->ts_num_ids; i++) {
3239 nfsd4_decode_stateid(argp, &si);
3240 valid = nfs4_validate_stateid(&si, test_stateid->ts_has_session);
3241 RESERVE_SPACE(4);
3242 *p++ = htonl(valid);
3243 resp->p = p;
3244 }
3245 nfs4_unlock_state();
3246
3247 return nfserr;
3248}
3249
3169static __be32 3250static __be32
3170nfsd4_encode_noop(struct nfsd4_compoundres *resp, __be32 nfserr, void *p) 3251nfsd4_encode_noop(struct nfsd4_compoundres *resp, __be32 nfserr, void *p)
3171{ 3252{
@@ -3234,7 +3315,7 @@ static nfsd4_enc nfsd4_enc_ops[] = {
3234 [OP_SECINFO_NO_NAME] = (nfsd4_enc)nfsd4_encode_secinfo_no_name, 3315 [OP_SECINFO_NO_NAME] = (nfsd4_enc)nfsd4_encode_secinfo_no_name,
3235 [OP_SEQUENCE] = (nfsd4_enc)nfsd4_encode_sequence, 3316 [OP_SEQUENCE] = (nfsd4_enc)nfsd4_encode_sequence,
3236 [OP_SET_SSV] = (nfsd4_enc)nfsd4_encode_noop, 3317 [OP_SET_SSV] = (nfsd4_enc)nfsd4_encode_noop,
3237 [OP_TEST_STATEID] = (nfsd4_enc)nfsd4_encode_noop, 3318 [OP_TEST_STATEID] = (nfsd4_enc)nfsd4_encode_test_stateid,
3238 [OP_WANT_DELEGATION] = (nfsd4_enc)nfsd4_encode_noop, 3319 [OP_WANT_DELEGATION] = (nfsd4_enc)nfsd4_encode_noop,
3239 [OP_DESTROY_CLIENTID] = (nfsd4_enc)nfsd4_encode_noop, 3320 [OP_DESTROY_CLIENTID] = (nfsd4_enc)nfsd4_encode_noop,
3240 [OP_RECLAIM_COMPLETE] = (nfsd4_enc)nfsd4_encode_noop, 3321 [OP_RECLAIM_COMPLETE] = (nfsd4_enc)nfsd4_encode_noop,