Commit 9811cd57 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Trond Myklebust

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: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
parent 78b19bae
...@@ -222,12 +222,23 @@ static ssize_t nfs_direct_wait(struct nfs_direct_req *dreq) ...@@ -222,12 +222,23 @@ static ssize_t nfs_direct_wait(struct nfs_direct_req *dreq)
* Synchronous I/O uses a stack-allocated iocb. Thus we can't trust * Synchronous I/O uses a stack-allocated iocb. Thus we can't trust
* the iocb is still valid here if this is a synchronous request. * the iocb is still valid here if this is a synchronous request.
*/ */
static void nfs_direct_complete(struct nfs_direct_req *dreq) static void nfs_direct_complete(struct nfs_direct_req *dreq, bool write)
{ {
struct inode *inode = dreq->inode;
if (dreq->iocb) { if (dreq->iocb) {
loff_t pos = dreq->iocb->ki_pos + dreq->count;
long res = (long) dreq->error; long res = (long) dreq->error;
if (!res) if (!res)
res = (long) dreq->count; res = (long) dreq->count;
if (write) {
spin_lock(&inode->i_lock);
if (i_size_read(inode) < pos)
i_size_write(inode, pos);
spin_unlock(&inode->i_lock);
}
aio_complete(dreq->iocb, res, 0); aio_complete(dreq->iocb, res, 0);
} }
complete_all(&dreq->completion); complete_all(&dreq->completion);
...@@ -272,7 +283,7 @@ static void nfs_direct_read_completion(struct nfs_pgio_header *hdr) ...@@ -272,7 +283,7 @@ static void nfs_direct_read_completion(struct nfs_pgio_header *hdr)
} }
out_put: out_put:
if (put_dreq(dreq)) if (put_dreq(dreq))
nfs_direct_complete(dreq); nfs_direct_complete(dreq, false);
hdr->release(hdr); hdr->release(hdr);
} }
...@@ -434,7 +445,7 @@ static ssize_t nfs_direct_read_schedule_iovec(struct nfs_direct_req *dreq, ...@@ -434,7 +445,7 @@ static ssize_t nfs_direct_read_schedule_iovec(struct nfs_direct_req *dreq,
} }
if (put_dreq(dreq)) if (put_dreq(dreq))
nfs_direct_complete(dreq); nfs_direct_complete(dreq, false);
return 0; return 0;
} }
...@@ -594,7 +605,7 @@ static void nfs_direct_write_schedule_work(struct work_struct *work) ...@@ -594,7 +605,7 @@ static void nfs_direct_write_schedule_work(struct work_struct *work)
break; break;
default: default:
nfs_inode_dio_write_done(dreq->inode); nfs_inode_dio_write_done(dreq->inode);
nfs_direct_complete(dreq); nfs_direct_complete(dreq, true);
} }
} }
...@@ -611,7 +622,7 @@ static void nfs_direct_write_schedule_work(struct work_struct *work) ...@@ -611,7 +622,7 @@ static void nfs_direct_write_schedule_work(struct work_struct *work)
static void nfs_direct_write_complete(struct nfs_direct_req *dreq, struct inode *inode) static void nfs_direct_write_complete(struct nfs_direct_req *dreq, struct inode *inode)
{ {
nfs_inode_dio_write_done(inode); nfs_inode_dio_write_done(inode);
nfs_direct_complete(dreq); nfs_direct_complete(dreq, true);
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment