/* This helper just factors out common code between do_lo_send_direct_write() and do_lo_send_write().  */
static int __do_lo_send_write(struct file *file, u8 *buf, const int len, loff_t pos)
/* This helper just factors out common code between do_lo_send_direct_write() and do_lo_send_write().  */
static int __do_lo_send_write(struct file *file, u8 *buf, const int len, loff_t pos)
{
	ssize_t bw;
	mm_segment_t old_fs = get_fs();
	set_fs(get_ds());
	bw = file->f_op->write(file, buf, len, &pos);
	set_fs(old_fs);
	if (likely(bw == len))
		return 0;
	printk(KERN_ERR "loop: Write error at byte offset %llu, length %i.\n",
			(unsigned long long)pos, len);
	if (bw >= 0)
		bw = -EIO;
	return bw;
}