aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs4xdr.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2006-06-09 09:34:22 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2006-06-09 09:34:22 -0400
commit683b57b435326eb512c7305892683b6205669448 (patch)
treeca1e526ab5b27993c0c143c37bb31e18889eeb61 /fs/nfs/nfs4xdr.c
parent8b23ea7bedb8b45a5bb56745fa3ff11018acf04e (diff)
NFSv4: Implement the fs_locations function call
NFSv4 allows for the fact that filesystems may be replicated across several servers or that they may be migrated to a backup server in case of failure of the primary server. fs_locations is an NFSv4 operation for retrieving information about the location of migrated and/or replicated filesystems. Based on an initial implementation by Jiaying Zhang <jiayingz@citi.umich.edu> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/nfs4xdr.c')
-rw-r--r--fs/nfs/nfs4xdr.c112
1 files changed, 110 insertions, 2 deletions
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 0d5794675944..7add3137b6b6 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -411,6 +411,15 @@ static int nfs_stat_to_errno(int);
411#define NFS4_dec_setacl_sz (compound_decode_hdr_maxsz + \ 411#define NFS4_dec_setacl_sz (compound_decode_hdr_maxsz + \
412 decode_putfh_maxsz + \ 412 decode_putfh_maxsz + \
413 op_decode_hdr_maxsz + nfs4_fattr_bitmap_maxsz) 413 op_decode_hdr_maxsz + nfs4_fattr_bitmap_maxsz)
414#define NFS4_enc_fs_locations_sz \
415 (compound_encode_hdr_maxsz + \
416 encode_putfh_maxsz + \
417 encode_getattr_maxsz)
418#define NFS4_dec_fs_locations_sz \
419 (compound_decode_hdr_maxsz + \
420 decode_putfh_maxsz + \
421 op_decode_hdr_maxsz + \
422 nfs4_fattr_bitmap_maxsz)
414 423
415static struct { 424static struct {
416 unsigned int mode; 425 unsigned int mode;
@@ -2003,6 +2012,38 @@ out:
2003} 2012}
2004 2013
2005/* 2014/*
2015 * Encode FS_LOCATIONS request
2016 */
2017static int nfs4_xdr_enc_fs_locations(struct rpc_rqst *req, uint32_t *p, struct nfs4_fs_locations_arg *args)
2018{
2019 struct xdr_stream xdr;
2020 struct compound_hdr hdr = {
2021 .nops = 3,
2022 };
2023 struct rpc_auth *auth = req->rq_task->tk_auth;
2024 int replen;
2025 int status;
2026
2027 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
2028 encode_compound_hdr(&xdr, &hdr);
2029 if ((status = encode_putfh(&xdr, args->dir_fh)) != 0)
2030 goto out;
2031 if ((status = encode_lookup(&xdr, args->name)) != 0)
2032 goto out;
2033 if ((status = encode_getfattr(&xdr, args->bitmask)) != 0)
2034 goto out;
2035 /* set up reply
2036 * toplevel_status + taglen + rescount + OP_PUTFH + status
2037 * + OP_LOOKUP + status + OP_GETATTR + status = 7
2038 */
2039 replen = (RPC_REPHDRSIZE + auth->au_rslack + 7) << 2;
2040 xdr_inline_pages(&req->rq_rcv_buf, replen, &args->page,
2041 0, PAGE_SIZE);
2042out:
2043 return status;
2044}
2045
2046/*
2006 * START OF "GENERIC" DECODE ROUTINES. 2047 * START OF "GENERIC" DECODE ROUTINES.
2007 * These may look a little ugly since they are imported from a "generic" 2048 * These may look a little ugly since they are imported from a "generic"
2008 * set of XDR encode/decode routines which are intended to be shared by 2049 * set of XDR encode/decode routines which are intended to be shared by
@@ -2036,7 +2077,7 @@ out:
2036 } \ 2077 } \
2037} while (0) 2078} while (0)
2038 2079
2039static int decode_opaque_inline(struct xdr_stream *xdr, uint32_t *len, char **string) 2080static int decode_opaque_inline(struct xdr_stream *xdr, unsigned int *len, char **string)
2040{ 2081{
2041 uint32_t *p; 2082 uint32_t *p;
2042 2083
@@ -2087,7 +2128,7 @@ static int decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected)
2087static int decode_ace(struct xdr_stream *xdr, void *ace, struct nfs4_client *clp) 2128static int decode_ace(struct xdr_stream *xdr, void *ace, struct nfs4_client *clp)
2088{ 2129{
2089 uint32_t *p; 2130 uint32_t *p;
2090 uint32_t strlen; 2131 unsigned int strlen;
2091 char *str; 2132 char *str;
2092 2133
2093 READ_BUF(12); 2134 READ_BUF(12);
@@ -2336,6 +2377,45 @@ static int decode_attr_files_total(struct xdr_stream *xdr, uint32_t *bitmap, uin
2336 return status; 2377 return status;
2337} 2378}
2338 2379
2380static int decode_attr_fs_locations(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fs_locations *res)
2381{
2382 int n;
2383 uint32_t *p;
2384 int status = -EIO;
2385
2386 if (unlikely(bitmap[0] & (FATTR4_WORD0_FS_LOCATIONS -1U)))
2387 goto out;
2388 status = 0;
2389 if (unlikely(!(bitmap[0] & FATTR4_WORD0_FS_LOCATIONS)))
2390 goto out;
2391 status = decode_opaque_inline(xdr, &res->fs_pathlen, &res->fs_path);
2392 if (unlikely(status != 0))
2393 goto out;
2394 READ_BUF(4);
2395 READ32(n);
2396 if (n <= 0)
2397 goto out_eio;
2398 res->nlocations = 0;
2399 while (res->nlocations < n) {
2400 struct nfs_fs_location *loc = &res->locations[res->nlocations];
2401
2402 status = decode_opaque_inline(xdr, &loc->serverlen, &loc->server);
2403 if (unlikely(status != 0))
2404 goto out_eio;
2405 status = decode_opaque_inline(xdr, &loc->rootpathlen, &loc->rootpath);
2406 if (unlikely(status != 0))
2407 goto out_eio;
2408 if (res->nlocations < NFS_FS_LOCATIONS_MAXENTRIES)
2409 res->nlocations++;
2410 }
2411out:
2412 dprintk("%s: fs_locations done, error = %d\n", __FUNCTION__, status);
2413 return status;
2414out_eio:
2415 status = -EIO;
2416 goto out;
2417}
2418
2339static int decode_attr_maxfilesize(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) 2419static int decode_attr_maxfilesize(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
2340{ 2420{
2341 uint32_t *p; 2421 uint32_t *p;
@@ -2867,6 +2947,10 @@ static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, cons
2867 goto xdr_error; 2947 goto xdr_error;
2868 if ((status = decode_attr_fileid(xdr, bitmap, &fattr->fileid)) != 0) 2948 if ((status = decode_attr_fileid(xdr, bitmap, &fattr->fileid)) != 0)
2869 goto xdr_error; 2949 goto xdr_error;
2950 if ((status = decode_attr_fs_locations(xdr, bitmap, container_of(fattr,
2951 struct nfs_fs_locations,
2952 fattr))) != 0)
2953 goto xdr_error;
2870 if ((status = decode_attr_mode(xdr, bitmap, &fattr->mode)) != 0) 2954 if ((status = decode_attr_mode(xdr, bitmap, &fattr->mode)) != 0)
2871 goto xdr_error; 2955 goto xdr_error;
2872 fattr->mode |= fmode; 2956 fattr->mode |= fmode;
@@ -4210,6 +4294,29 @@ out:
4210 return status; 4294 return status;
4211} 4295}
4212 4296
4297/*
4298 * FS_LOCATIONS request
4299 */
4300static int nfs4_xdr_dec_fs_locations(struct rpc_rqst *req, uint32_t *p, struct nfs_fs_locations *res)
4301{
4302 struct xdr_stream xdr;
4303 struct compound_hdr hdr;
4304 int status;
4305
4306 xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
4307 status = decode_compound_hdr(&xdr, &hdr);
4308 if (status != 0)
4309 goto out;
4310 if ((status = decode_putfh(&xdr)) != 0)
4311 goto out;
4312 if ((status = decode_lookup(&xdr)) != 0)
4313 goto out;
4314 xdr_enter_page(&xdr, PAGE_SIZE);
4315 status = decode_getfattr(&xdr, &res->fattr, res->server);
4316out:
4317 return status;
4318}
4319
4213uint32_t *nfs4_decode_dirent(uint32_t *p, struct nfs_entry *entry, int plus) 4320uint32_t *nfs4_decode_dirent(uint32_t *p, struct nfs_entry *entry, int plus)
4214{ 4321{
4215 uint32_t bitmap[2] = {0}; 4322 uint32_t bitmap[2] = {0};
@@ -4381,6 +4488,7 @@ struct rpc_procinfo nfs4_procedures[] = {
4381 PROC(DELEGRETURN, enc_delegreturn, dec_delegreturn), 4488 PROC(DELEGRETURN, enc_delegreturn, dec_delegreturn),
4382 PROC(GETACL, enc_getacl, dec_getacl), 4489 PROC(GETACL, enc_getacl, dec_getacl),
4383 PROC(SETACL, enc_setacl, dec_setacl), 4490 PROC(SETACL, enc_setacl, dec_setacl),
4491 PROC(FS_LOCATIONS, enc_fs_locations, dec_fs_locations),
4384}; 4492};
4385 4493
4386struct rpc_version nfs_version4 = { 4494struct rpc_version nfs_version4 = {