switch generic_write_checks() to iocb and iter

... returning -E... upon error and amount of data left in iter after
(possible) truncation upon success.  Note, that normal case gives
a non-zero (positive) return value, so any tests for != 0 _must_ be
updated.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Conflicts:
	fs/ext4/file.c
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index 42b1fa3..c10785f 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -97,9 +97,7 @@
 	struct blk_plug plug;
 	int o_direct = io_is_direct(file);
 	int overwrite = 0;
-	size_t length = iov_iter_count(from);
 	ssize_t ret;
-	loff_t pos;
 
 	/*
 	 * Unaligned direct AIO must be serialized; see comment above
@@ -116,16 +114,10 @@
 	}
 
 	mutex_lock(&inode->i_mutex);
-	ret = generic_write_checks(file, &iocb->ki_pos, &length);
-	if (ret)
+	ret = generic_write_checks(iocb, from);
+	if (ret <= 0)
 		goto out;
 
-	if (length == 0)
-		goto out;
-
-	iov_iter_truncate(from, length);
-	pos = iocb->ki_pos;
-
 	/*
 	 * If we have encountered a bitmap-format file, the size limit
 	 * is smaller than s_maxbytes, which is for extent-mapped files.
@@ -133,19 +125,19 @@
 	if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) {
 		struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
 
-		if (pos >= sbi->s_bitmap_maxbytes) {
+		if (iocb->ki_pos >= sbi->s_bitmap_maxbytes) {
 			ret = -EFBIG;
 			goto out;
 		}
-		iov_iter_truncate(from, sbi->s_bitmap_maxbytes - pos);
+		iov_iter_truncate(from, sbi->s_bitmap_maxbytes - iocb->ki_pos);
 	}
 
 	iocb->private = &overwrite;
 	if (o_direct) {
-		length = iov_iter_count(from);
+		size_t length = iov_iter_count(from);
+		loff_t pos = iocb->ki_pos;
 		blk_start_plug(&plug);
 
-
 		/* check whether we do a DIO overwrite or not */
 		if (ext4_should_dioread_nolock(inode) && !aio_mutex &&
 		    !file->f_mapping->nrpages && pos + length <= i_size_read(inode)) {