From: Christoph Hellwig <hch@infradead.org>
To: Trond.Myklebust@netapp.com
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH 1/7] nfs: fix size updates for aio writes
Date: Thu, 14 Nov 2013 08:50:28 -0800 [thread overview]
Message-ID: <20131114165041.155176197@bombadil.infradead.org> (raw)
In-Reply-To: 20131114165027.355613182@bombadil.infradead.org
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>
---
fs/nfs/direct.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index d71d66c..653c2e8 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -222,12 +222,23 @@ out:
* 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.
*/
-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) {
+ loff_t pos = dreq->iocb->ki_pos + dreq->count;
long res = (long) dreq->error;
if (!res)
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);
}
complete_all(&dreq->completion);
@@ -272,7 +283,7 @@ static void nfs_direct_read_completion(struct nfs_pgio_header *hdr)
}
out_put:
if (put_dreq(dreq))
- nfs_direct_complete(dreq);
+ nfs_direct_complete(dreq, false);
hdr->release(hdr);
}
@@ -434,7 +445,7 @@ static ssize_t nfs_direct_read_schedule_iovec(struct nfs_direct_req *dreq,
}
if (put_dreq(dreq))
- nfs_direct_complete(dreq);
+ nfs_direct_complete(dreq, false);
return 0;
}
@@ -594,7 +605,7 @@ static void nfs_direct_write_schedule_work(struct work_struct *work)
break;
default:
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)
static void nfs_direct_write_complete(struct nfs_direct_req *dreq, struct inode *inode)
{
nfs_inode_dio_write_done(inode);
- nfs_direct_complete(dreq);
+ nfs_direct_complete(dreq, true);
}
#endif
--
1.7.10.4
next prev parent reply other threads:[~2013-11-14 16:50 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-14 16:50 [PATCH 0/7] direct I/O fixes Christoph Hellwig
2013-11-14 16:50 ` Christoph Hellwig [this message]
2013-11-14 16:50 ` [PATCH 2/7] nfs: defer inode_dio_done call until size update is done Christoph Hellwig
2013-11-14 16:50 ` [PATCH 3/7] nfs: increment i_dio_count for reads, too Christoph Hellwig
2013-11-14 16:50 ` [PATCH 4/7] nfs: merge nfs_direct_read into nfs_file_direct_read Christoph Hellwig
2013-11-14 16:50 ` [PATCH 5/7] nfs: merge nfs_direct_write into nfs_file_direct_write Christoph Hellwig
2013-11-14 16:50 ` [PATCH 6/7] nfs: take i_mutex during direct I/O reads Christoph Hellwig
2013-11-14 17:00 ` Chuck Lever
2013-11-15 14:29 ` Christoph Hellwig
2013-11-14 20:43 ` Trond Myklebust
2013-11-15 14:32 ` Christoph Hellwig
2013-11-15 15:23 ` Trond Myklebust
2013-11-15 15:25 ` Christoph Hellwig
2013-11-15 15:34 ` Trond Myklebust
2013-11-15 15:37 ` Christoph Hellwig
2013-11-15 16:00 ` Trond Myklebust
2013-11-14 16:50 ` [PATCH 7/7] nfs: page cache invalidation for dio Christoph Hellwig
2013-11-14 18:35 ` Jeff Layton
2013-11-15 14:28 ` Christoph Hellwig
2013-11-15 14:52 ` Jeff Layton
2013-11-15 15:02 ` Christoph Hellwig
2013-11-15 15:33 ` Jeff Layton
2014-01-21 19:21 ` Jeff Layton
2014-01-22 8:24 ` Christoph Hellwig
2014-01-22 12:04 ` Jeff Layton
2014-01-24 15:50 ` Jeff Layton
2014-01-24 15:52 ` Jeff Layton
2014-01-24 17:11 ` Trond Myklebust
2014-01-24 17:29 ` Jeff Layton
2014-01-24 17:40 ` Trond Myklebust
2014-01-24 18:00 ` Jeff Layton
2014-01-24 18:46 ` Trond Myklebust
2014-01-24 21:21 ` Jeff Layton
2014-01-25 0:39 ` Trond Myklebust
2014-01-25 0:54 ` Jeff Layton
2014-01-25 1:05 ` Trond Myklebust
2014-01-25 1:11 ` Trond Myklebust
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131114165041.155176197@bombadil.infradead.org \
--to=hch@infradead.org \
--cc=Trond.Myklebust@netapp.com \
--cc=linux-nfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).