aboutsummaryrefslogtreecommitdiffstats
path: root/fs/direct-io.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2016-04-07 11:52:01 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2016-05-01 19:58:39 -0400
commite259221763a40403d5bb232209998e8c45804ab8 (patch)
tree6f940ba17f38b693e495ad5267b1988dd66c9c0f /fs/direct-io.c
parentdde0c2e79848298cc25621ad080d47f94dbd7cce (diff)
fs: simplify the generic_write_sync prototype
The kiocb already has the new position, so use that. The only interesting case is AIO, where we currently don't bother updating ki_pos. We're about to free the kiocb after we're done, so we might as well update it to make everyone's life simpler. While we're at it also return the bytes written argument passed in if we were successful so that the boilerplate error switch code in the callers can go away. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/direct-io.c')
-rw-r--r--fs/direct-io.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/fs/direct-io.c b/fs/direct-io.c
index f7bcc0193dee..3bf3f20f8ecc 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -256,6 +256,7 @@ static ssize_t dio_complete(struct dio *dio, ssize_t ret, bool is_async)
256 if (dio->end_io) { 256 if (dio->end_io) {
257 int err; 257 int err;
258 258
259 // XXX: ki_pos??
259 err = dio->end_io(dio->iocb, offset, ret, dio->private); 260 err = dio->end_io(dio->iocb, offset, ret, dio->private);
260 if (err) 261 if (err)
261 ret = err; 262 ret = err;
@@ -265,15 +266,15 @@ static ssize_t dio_complete(struct dio *dio, ssize_t ret, bool is_async)
265 inode_dio_end(dio->inode); 266 inode_dio_end(dio->inode);
266 267
267 if (is_async) { 268 if (is_async) {
268 if (dio->rw & WRITE) { 269 /*
269 int err; 270 * generic_write_sync expects ki_pos to have been updated
270 271 * already, but the submission path only does this for
271 err = generic_write_sync(dio->iocb, offset, 272 * synchronous I/O.
272 transferred); 273 */
273 if (err < 0 && ret > 0) 274 dio->iocb->ki_pos += transferred;
274 ret = err;
275 }
276 275
276 if (dio->rw & WRITE)
277 ret = generic_write_sync(dio->iocb, transferred);
277 dio->iocb->ki_complete(dio->iocb, ret, 0); 278 dio->iocb->ki_complete(dio->iocb, ret, 0);
278 } 279 }
279 280