aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/direct.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2013-11-14 11:50:28 -0500
committerTrond Myklebust <trond.myklebust@primarydata.com>2014-01-13 17:29:48 -0500
commit9811cd57f4c6b5b60ec104de68a88303717e3106 (patch)
tree9ec25d5c066e63c43ca7fc8c7dcde6d6d7baf1c2 /fs/nfs/direct.c
parent78b19bae0813bd6f921ca58490196abd101297bd (diff)
nfs: fix size updates for aio writes
nfs_file_direct_write only updates the inode size if it succeeded and returned the number of bytes written. But in the AIO case nfs_direct_wait turns the return value into -EIOCBQUEUED and we skip the size update. Instead the aio completion path should updated it, which this patch does. The implementation is a little hacky because there is no obvious way to find out we are called for a write in nfs_direct_complete. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Diffstat (limited to 'fs/nfs/direct.c')
-rw-r--r--fs/nfs/direct.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index 049b3408fb9d..ce52a9774ec1 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -222,12 +222,23 @@ out:
222 * Synchronous I/O uses a stack-allocated iocb. Thus we can't trust 222 * Synchronous I/O uses a stack-allocated iocb. Thus we can't trust
223 * the iocb is still valid here if this is a synchronous request. 223 * the iocb is still valid here if this is a synchronous request.
224 */ 224 */
225static void nfs_direct_complete(struct nfs_direct_req *dreq) 225static void nfs_direct_complete(struct nfs_direct_req *dreq, bool write)
226{ 226{
227 struct inode *inode = dreq->inode;
228
227 if (dreq->iocb) { 229 if (dreq->iocb) {
230 loff_t pos = dreq->iocb->ki_pos + dreq->count;
228 long res = (long) dreq->error; 231 long res = (long) dreq->error;
229 if (!res) 232 if (!res)
230 res = (long) dreq->count; 233 res = (long) dreq->count;
234
235 if (write) {
236 spin_lock(&inode->i_lock);
237 if (i_size_read(inode) < pos)
238 i_size_write(inode, pos);
239 spin_unlock(&inode->i_lock);
240 }
241
231 aio_complete(dreq->iocb, res, 0); 242 aio_complete(dreq->iocb, res, 0);
232 } 243 }
233 complete_all(&dreq->completion); 244 complete_all(&dreq->completion);
@@ -272,7 +283,7 @@ static void nfs_direct_read_completion(struct nfs_pgio_header *hdr)
272 } 283 }
273out_put: 284out_put:
274 if (put_dreq(dreq)) 285 if (put_dreq(dreq))
275 nfs_direct_complete(dreq); 286 nfs_direct_complete(dreq, false);
276 hdr->release(hdr); 287 hdr->release(hdr);
277} 288}
278 289
@@ -434,7 +445,7 @@ static ssize_t nfs_direct_read_schedule_iovec(struct nfs_direct_req *dreq,
434 } 445 }
435 446
436 if (put_dreq(dreq)) 447 if (put_dreq(dreq))
437 nfs_direct_complete(dreq); 448 nfs_direct_complete(dreq, false);
438 return 0; 449 return 0;
439} 450}
440 451
@@ -594,7 +605,7 @@ static void nfs_direct_write_schedule_work(struct work_struct *work)
594 break; 605 break;
595 default: 606 default:
596 nfs_inode_dio_write_done(dreq->inode); 607 nfs_inode_dio_write_done(dreq->inode);
597 nfs_direct_complete(dreq); 608 nfs_direct_complete(dreq, true);
598 } 609 }
599} 610}
600 611
@@ -611,7 +622,7 @@ static void nfs_direct_write_schedule_work(struct work_struct *work)
611static void nfs_direct_write_complete(struct nfs_direct_req *dreq, struct inode *inode) 622static void nfs_direct_write_complete(struct nfs_direct_req *dreq, struct inode *inode)
612{ 623{
613 nfs_inode_dio_write_done(inode); 624 nfs_inode_dio_write_done(inode);
614 nfs_direct_complete(dreq); 625 nfs_direct_complete(dreq, true);
615} 626}
616#endif 627#endif
617 628