History

NFS: Don't zap caches on fallocate()

This patch adds a GETATTR to the end of ALLOCATE and DEALLOCATE operations so we can set the updated inode size and change attribute directly. DEALLOCATE will still need to release pagecache pages, so nfs42_proc_deallocate() now calls truncate_pagecache_range() before contacting the server.

Anna Schumaker committed 11 years ago

Commit 9a519401 parent 8c18d765 files · +39 −10Browse files

Unified · Split

5 files
  1. fs/nfs/inode.c +0 −1
  2. fs/nfs/nfs42proc.c +19 −4
  3. fs/nfs/nfs42xdr.c +16 −4
  4. fs/nfs/nfs4file.c +0 −1
  5. include/linux/nfs_xdr.h +4 −0
fs/nfs/inode.c+0−1
@@ -199,7 +199,6 @@ void nfs_zap_caches(struct inode *inode) · 198 unmodified lines
199 nfs_zap_caches_locked(inode);199 nfs_zap_caches_locked(inode);
200 spin_unlock(&inode->i_lock);200 spin_unlock(&inode->i_lock);
201}201}
202EXPORT_SYMBOL_GPL(nfs_zap_caches);
203 202
204void nfs_zap_mapping(struct inode *inode, struct address_space *mapping)203void nfs_zap_mapping(struct inode *inode, struct address_space *mapping)
205{204{
fs/nfs/nfs42proc.c+19−4
@@ -36,13 +36,16 @@ static int _nfs42_proc_fallocate(struct rpc_message *msg, struct file *filep, · 35 unmodified lines
36 loff_t offset, loff_t len)36 loff_t offset, loff_t len)
37{37{
38 struct inode *inode = file_inode(filep);38 struct inode *inode = file_inode(filep);
39 struct nfs_server *server = NFS_SERVER(inode);
39 struct nfs42_falloc_args args = {40 struct nfs42_falloc_args args = {
40 .falloc_fh = NFS_FH(inode),41 .falloc_fh = NFS_FH(inode),
41 .falloc_offset = offset,42 .falloc_offset = offset,
42 .falloc_length = len,43 .falloc_length = len,
44 .falloc_bitmask = server->cache_consistency_bitmask,
45 };
46 struct nfs42_falloc_res res = {
47 .falloc_server = server,
43 };48 };
44 struct nfs42_falloc_res res;
45 struct nfs_server *server = NFS_SERVER(inode);
46 int status;49 int status;
47 50
48 msg->rpc_argp = &args;51 msg->rpc_argp = &args;
@@ -52,8 +55,17 @@ static int _nfs42_proc_fallocate(struct rpc_message *msg, struct file *filep, · 3 unmodified lines
52 if (status)55 if (status)
53 return status;56 return status;
54 57
55 return nfs4_call_sync(server->client, server, msg,58 res.falloc_fattr = nfs_alloc_fattr();
56 &args.seq_args, &res.seq_res, 0);59 if (!res.falloc_fattr)
60 return -ENOMEM;
61
62 status = nfs4_call_sync(server->client, server, msg,
63 &args.seq_args, &res.seq_res, 0);
64 if (status == 0)
65 status = nfs_post_op_update_inode(inode, res.falloc_fattr);
66
67 kfree(res.falloc_fattr);
68 return status;
57}69}
58 70
59static int nfs42_proc_fallocate(struct rpc_message *msg, struct file *filep,71static int nfs42_proc_fallocate(struct rpc_message *msg, struct file *filep,
@@ -101,7 +113,10 @@ int nfs42_proc_deallocate(struct file *filep, loff_t offset, loff_t len) · 41 unmodified lines
101 if (!nfs_server_capable(inode, NFS_CAP_DEALLOCATE))113 if (!nfs_server_capable(inode, NFS_CAP_DEALLOCATE))
102 return -EOPNOTSUPP;114 return -EOPNOTSUPP;
103 115
116 nfs_wb_all(inode);
104 err = nfs42_proc_fallocate(&msg, filep, offset, len);117 err = nfs42_proc_fallocate(&msg, filep, offset, len);
118 if (err == 0)
119 truncate_pagecache_range(inode, offset, (offset + len) -1);
105 if (err == -EOPNOTSUPP)120 if (err == -EOPNOTSUPP)
106 NFS_SERVER(inode)->caps &= ~NFS_CAP_DEALLOCATE;121 NFS_SERVER(inode)->caps &= ~NFS_CAP_DEALLOCATE;
107 return err;122 return err;
fs/nfs/nfs42xdr.c+16−4
@@ -25,16 +25,20 @@ · 24 unmodified lines
25 25
26#define NFS4_enc_allocate_sz (compound_encode_hdr_maxsz + \26#define NFS4_enc_allocate_sz (compound_encode_hdr_maxsz + \
27 encode_putfh_maxsz + \27 encode_putfh_maxsz + \
28 encode_allocate_maxsz)28 encode_allocate_maxsz + \
29 encode_getattr_maxsz)
29#define NFS4_dec_allocate_sz (compound_decode_hdr_maxsz + \30#define NFS4_dec_allocate_sz (compound_decode_hdr_maxsz + \
30 decode_putfh_maxsz + \31 decode_putfh_maxsz + \
31 decode_allocate_maxsz)32 decode_allocate_maxsz + \
33 decode_getattr_maxsz)
32#define NFS4_enc_deallocate_sz (compound_encode_hdr_maxsz + \34#define NFS4_enc_deallocate_sz (compound_encode_hdr_maxsz + \
33 encode_putfh_maxsz + \35 encode_putfh_maxsz + \
34 encode_deallocate_maxsz)36 encode_deallocate_maxsz + \
37 encode_getattr_maxsz)
35#define NFS4_dec_deallocate_sz (compound_decode_hdr_maxsz + \38#define NFS4_dec_deallocate_sz (compound_decode_hdr_maxsz + \
36 decode_putfh_maxsz + \39 decode_putfh_maxsz + \
37 decode_deallocate_maxsz)40 decode_deallocate_maxsz + \
41 decode_getattr_maxsz)
38#define NFS4_enc_seek_sz (compound_encode_hdr_maxsz + \42#define NFS4_enc_seek_sz (compound_encode_hdr_maxsz + \
39 encode_putfh_maxsz + \43 encode_putfh_maxsz + \
40 encode_seek_maxsz)44 encode_seek_maxsz)
@@ -92,6 +96,7 @@ static void nfs4_xdr_enc_allocate(struct rpc_rqst *req, · 51 unmodified lines
92 encode_sequence(xdr, &args->seq_args, &hdr);96 encode_sequence(xdr, &args->seq_args, &hdr);
93 encode_putfh(xdr, args->falloc_fh, &hdr);97 encode_putfh(xdr, args->falloc_fh, &hdr);
94 encode_allocate(xdr, args, &hdr);98 encode_allocate(xdr, args, &hdr);
99 encode_getfattr(xdr, args->falloc_bitmask, &hdr);
95 encode_nops(&hdr);100 encode_nops(&hdr);
96}101}
97 102
@@ -110,6 +115,7 @@ static void nfs4_xdr_enc_deallocate(struct rpc_rqst *req, · 12 unmodified lines
110 encode_sequence(xdr, &args->seq_args, &hdr);115 encode_sequence(xdr, &args->seq_args, &hdr);
111 encode_putfh(xdr, args->falloc_fh, &hdr);116 encode_putfh(xdr, args->falloc_fh, &hdr);
112 encode_deallocate(xdr, args, &hdr);117 encode_deallocate(xdr, args, &hdr);
118 encode_getfattr(xdr, args->falloc_bitmask, &hdr);
113 encode_nops(&hdr);119 encode_nops(&hdr);
114}120}
115 121
@@ -183,6 +189,9 @@ static int nfs4_xdr_dec_allocate(struct rpc_rqst *rqstp, · 67 unmodified lines
183 if (status)189 if (status)
184 goto out;190 goto out;
185 status = decode_allocate(xdr, res);191 status = decode_allocate(xdr, res);
192 if (status)
193 goto out;
194 decode_getfattr(xdr, res->falloc_fattr, res->falloc_server);
186out:195out:
187 return status;196 return status;
188}197}
@@ -207,6 +216,9 @@ static int nfs4_xdr_dec_deallocate(struct rpc_rqst *rqstp, · 18 unmodified lines
207 if (status)216 if (status)
208 goto out;217 goto out;
209 status = decode_deallocate(xdr, res);218 status = decode_deallocate(xdr, res);
219 if (status)
220 goto out;
221 decode_getfattr(xdr, res->falloc_fattr, res->falloc_server);
210out:222out:
211 return status;223 return status;
212}224}
fs/nfs/nfs4file.c+0−1
@@ -165,7 +165,6 @@ static long nfs42_fallocate(struct file *filep, int mode, loff_t offset, loff_t · 164 unmodified lines
165 ret = nfs42_proc_allocate(filep, offset, len);165 ret = nfs42_proc_allocate(filep, offset, len);
166 mutex_unlock(&inode->i_mutex);166 mutex_unlock(&inode->i_mutex);
167 167
168 nfs_zap_caches(inode);
169 return ret;168 return ret;
170}169}
171#endif /* CONFIG_NFS_V4_2 */170#endif /* CONFIG_NFS_V4_2 */
include/linux/nfs_xdr.h+4−0
@@ -1273,11 +1273,15 @@ struct nfs42_falloc_args { · 1272 unmodified lines
1273 nfs4_stateid falloc_stateid;1273 nfs4_stateid falloc_stateid;
1274 u64 falloc_offset;1274 u64 falloc_offset;
1275 u64 falloc_length;1275 u64 falloc_length;
1276 const u32 *falloc_bitmask;
1276};1277};
1277 1278
1278struct nfs42_falloc_res {1279struct nfs42_falloc_res {
1279 struct nfs4_sequence_res seq_res;1280 struct nfs4_sequence_res seq_res;
1280 unsigned int status;1281 unsigned int status;
1282
1283 struct nfs_fattr *falloc_fattr;
1284 const struct nfs_server *falloc_server;
1281};1285};
1282 1286
1283struct nfs42_seek_args {1287struct nfs42_seek_args {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t