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