summaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs4xdr.c
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@primarydata.com>2015-09-05 19:06:57 -0400
committerTrond Myklebust <trond.myklebust@primarydata.com>2015-09-07 12:36:13 -0400
commit7d160a6c462c2c690e074c173b43aad7204049ad (patch)
tree6967b9cffa27592690259622031e87e27919d61b /fs/nfs/nfs4xdr.c
parent4eae50143bcbfda819c650b7ed6739f3b6338ffc (diff)
NFSv4: Express delegation limit in units of pages
Since we're tracking modifications to the page cache on a per-page basis, it makes sense to express the limit to how much we may cache in units of pages. Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Diffstat (limited to 'fs/nfs/nfs4xdr.c')
-rw-r--r--fs/nfs/nfs4xdr.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index ff4784c54e04..788adf3897c7 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -4932,24 +4932,28 @@ static int decode_lookup(struct xdr_stream *xdr)
4932} 4932}
4933 4933
4934/* This is too sick! */ 4934/* This is too sick! */
4935static int decode_space_limit(struct xdr_stream *xdr, u64 *maxsize) 4935static int decode_space_limit(struct xdr_stream *xdr,
4936 unsigned long *pagemod_limit)
4936{ 4937{
4937 __be32 *p; 4938 __be32 *p;
4938 uint32_t limit_type, nblocks, blocksize; 4939 uint32_t limit_type, nblocks, blocksize;
4940 u64 maxsize = 0;
4939 4941
4940 p = xdr_inline_decode(xdr, 12); 4942 p = xdr_inline_decode(xdr, 12);
4941 if (unlikely(!p)) 4943 if (unlikely(!p))
4942 goto out_overflow; 4944 goto out_overflow;
4943 limit_type = be32_to_cpup(p++); 4945 limit_type = be32_to_cpup(p++);
4944 switch (limit_type) { 4946 switch (limit_type) {
4945 case 1: 4947 case NFS4_LIMIT_SIZE:
4946 xdr_decode_hyper(p, maxsize); 4948 xdr_decode_hyper(p, &maxsize);
4947 break; 4949 break;
4948 case 2: 4950 case NFS4_LIMIT_BLOCKS:
4949 nblocks = be32_to_cpup(p++); 4951 nblocks = be32_to_cpup(p++);
4950 blocksize = be32_to_cpup(p); 4952 blocksize = be32_to_cpup(p);
4951 *maxsize = (uint64_t)nblocks * (uint64_t)blocksize; 4953 maxsize = (uint64_t)nblocks * (uint64_t)blocksize;
4952 } 4954 }
4955 maxsize >>= PAGE_CACHE_SHIFT;
4956 *pagemod_limit = min_t(u64, maxsize, ULONG_MAX);
4953 return 0; 4957 return 0;
4954out_overflow: 4958out_overflow:
4955 print_overflow_msg(__func__, xdr); 4959 print_overflow_msg(__func__, xdr);
@@ -4977,7 +4981,7 @@ static int decode_rw_delegation(struct xdr_stream *xdr,
4977 break; 4981 break;
4978 case NFS4_OPEN_DELEGATE_WRITE: 4982 case NFS4_OPEN_DELEGATE_WRITE:
4979 res->delegation_type = FMODE_WRITE|FMODE_READ; 4983 res->delegation_type = FMODE_WRITE|FMODE_READ;
4980 if (decode_space_limit(xdr, &res->maxsize) < 0) 4984 if (decode_space_limit(xdr, &res->pagemod_limit) < 0)
4981 return -EIO; 4985 return -EIO;
4982 } 4986 }
4983 return decode_ace(xdr, NULL, res->server->nfs_client); 4987 return decode_ace(xdr, NULL, res->server->nfs_client);