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>
This commit is contained in:
Christoph Hellwig
2016-04-07 08:52:01 -07:00
committed by Al Viro
parent dde0c2e798
commit e259221763
12 changed files with 45 additions and 64 deletions

View File

@@ -1660,12 +1660,8 @@ ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from)
blk_start_plug(&plug);
ret = __generic_file_write_iter(iocb, from);
if (ret > 0) {
ssize_t err;
err = generic_write_sync(iocb, iocb->ki_pos - ret, ret);
if (err < 0)
ret = err;
}
if (ret > 0)
ret = generic_write_sync(iocb, ret);
blk_finish_plug(&plug);
return ret;
}