Commit 022bfbc0 authored by Hugh Dickins's avatar Hugh Dickins Committed by Andy Grover

[PATCH] loop sendfile retval

Buffer I/O error on device loop: its use of sendfile is (trivially)
broken - retval is usually count done, only an error when negative.

This code (like the old one) does not correctly handle partial reads.

Nearby spinlocking clearly bogus, delete instead of remarking on it.
parent e36c5243
...@@ -304,21 +304,16 @@ do_lo_receive(struct loop_device *lo, ...@@ -304,21 +304,16 @@ do_lo_receive(struct loop_device *lo,
{ {
struct lo_read_data cookie; struct lo_read_data cookie;
struct file *file; struct file *file;
int error; int retval;
cookie.lo = lo; cookie.lo = lo;
cookie.data = kmap(bvec->bv_page) + bvec->bv_offset; cookie.data = kmap(bvec->bv_page) + bvec->bv_offset;
cookie.bsize = bsize; cookie.bsize = bsize;
/* umm, what does this lock actually try to protect? */
spin_lock_irq(&lo->lo_lock);
file = lo->lo_backing_file; file = lo->lo_backing_file;
spin_unlock_irq(&lo->lo_lock); retval = file->f_op->sendfile(file, &pos, bvec->bv_len,
error = file->f_op->sendfile(file, &pos, bvec->bv_len,
lo_read_actor, &cookie); lo_read_actor, &cookie);
kunmap(bvec->bv_page); kunmap(bvec->bv_page);
return error; return (retval < 0)? retval: 0;
} }
static int static int
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment