diff mbox

[v2,1/3] btrfs: replace open-coded kernel_write

Message ID a6e4b5480b7e16bfcac28156381ba33fc8662570.1412114127.git.osandov@osandov.com (mailing list archive)
State New, archived
Headers show

Commit Message

Omar Sandoval Sept. 30, 2014, 10:01 p.m. UTC
write_buf used by btrfs send has what is more or less a reimplementation of
kernel_write. This also gets rid of a sparse address space warning.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
---
 fs/btrfs/send.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

Comments

Zach Brown Sept. 30, 2014, 10:19 p.m. UTC | #1
On Tue, Sep 30, 2014 at 03:01:40PM -0700, Omar Sandoval wrote:
> write_buf used by btrfs send has what is more or less a reimplementation of
> kernel_write. This also gets rid of a sparse address space warning.

Seems reasonable to me:

Reviewed-by: Zach Brown <zab@zabbo.net>

- z
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 6528aa6..f6b2ec3 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -508,32 +508,23 @@  static struct btrfs_path *alloc_path_for_send(void)
 static int write_buf(struct file *filp, const void *buf, u32 len, loff_t *off)
 {
 	int ret;
-	mm_segment_t old_fs;
 	u32 pos = 0;
 
-	old_fs = get_fs();
-	set_fs(KERNEL_DS);
-
 	while (pos < len) {
-		ret = vfs_write(filp, (char *)buf + pos, len - pos, off);
+		ret = kernel_write(filp, buf + pos, len - pos, *off);
 		/* TODO handle that correctly */
 		/*if (ret == -ERESTARTSYS) {
 			continue;
 		}*/
 		if (ret < 0)
-			goto out;
-		if (ret == 0) {
-			ret = -EIO;
-			goto out;
-		}
+			return ret;
+		if (ret == 0)
+			return -EIO;
 		pos += ret;
+		*off += ret;
 	}
 
-	ret = 0;
-
-out:
-	set_fs(old_fs);
-	return ret;
+	return 0;
 }
 
 static int tlv_put(struct send_ctx *sctx, u16 attr, const void *data, int len)