Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1bcea355 authored by Anand Jain's avatar Anand Jain Committed by Chris Mason
Browse files

Btrfs: write_buf is now callable outside send.c



Developing service cmds needs it.

Signed-off-by: default avatarAnand Jain <anand.jain@oracle.com>
parent b4f359ab
Loading
Loading
Loading
Loading
+6 −5
Original line number Original line Diff line number Diff line
@@ -386,7 +386,7 @@ static struct btrfs_path *alloc_path_for_send(void)
	return path;
	return path;
}
}


static int write_buf(struct send_ctx *sctx, const void *buf, u32 len)
int write_buf(struct file *filp, const void *buf, u32 len, loff_t *off)
{
{
	int ret;
	int ret;
	mm_segment_t old_fs;
	mm_segment_t old_fs;
@@ -396,8 +396,7 @@ static int write_buf(struct send_ctx *sctx, const void *buf, u32 len)
	set_fs(KERNEL_DS);
	set_fs(KERNEL_DS);


	while (pos < len) {
	while (pos < len) {
		ret = vfs_write(sctx->send_filp, (char *)buf + pos, len - pos,
		ret = vfs_write(filp, (char *)buf + pos, len - pos, off);
				&sctx->send_off);
		/* TODO handle that correctly */
		/* TODO handle that correctly */
		/*if (ret == -ERESTARTSYS) {
		/*if (ret == -ERESTARTSYS) {
			continue;
			continue;
@@ -553,7 +552,8 @@ static int send_header(struct send_ctx *sctx)
	strcpy(hdr.magic, BTRFS_SEND_STREAM_MAGIC);
	strcpy(hdr.magic, BTRFS_SEND_STREAM_MAGIC);
	hdr.version = cpu_to_le32(BTRFS_SEND_STREAM_VERSION);
	hdr.version = cpu_to_le32(BTRFS_SEND_STREAM_VERSION);


	return write_buf(sctx, &hdr, sizeof(hdr));
	return write_buf(sctx->send_filp, &hdr, sizeof(hdr),
					&sctx->send_off);
}
}


/*
/*
@@ -590,7 +590,8 @@ static int send_cmd(struct send_ctx *sctx)
	crc = crc32c(0, (unsigned char *)sctx->send_buf, sctx->send_size);
	crc = crc32c(0, (unsigned char *)sctx->send_buf, sctx->send_size);
	hdr->crc = cpu_to_le32(crc);
	hdr->crc = cpu_to_le32(crc);


	ret = write_buf(sctx, sctx->send_buf, sctx->send_size);
	ret = write_buf(sctx->send_filp, sctx->send_buf, sctx->send_size,
					&sctx->send_off);


	sctx->total_send_size += sctx->send_size;
	sctx->total_send_size += sctx->send_size;
	sctx->cmd_send_size[le16_to_cpu(hdr->cmd)] += sctx->send_size;
	sctx->cmd_send_size[le16_to_cpu(hdr->cmd)] += sctx->send_size;
+1 −0
Original line number Original line Diff line number Diff line
@@ -130,4 +130,5 @@ enum {


#ifdef __KERNEL__
#ifdef __KERNEL__
long btrfs_ioctl_send(struct file *mnt_file, void __user *arg);
long btrfs_ioctl_send(struct file *mnt_file, void __user *arg);
int write_buf(struct file *filp, const void *buf, u32 len, loff_t *off);
#endif
#endif