Commit 61c4b8fb authored by Andrew Morton's avatar Andrew Morton Committed by Russell King

[PATCH] clean up ll_rw_block()

Hardly anything uses this function, so the debug checks in there are
not of much value.

The check for bdev_readonly() should be done in submit_bio().

Local variable `major' was altogether unused.
parent 3669e824
...@@ -2429,77 +2429,32 @@ int submit_bh(int rw, struct buffer_head * bh) ...@@ -2429,77 +2429,32 @@ int submit_bh(int rw, struct buffer_head * bh)
* All of the buffers must be for the same device, and must also be a * All of the buffers must be for the same device, and must also be a
* multiple of the current approved size for the device. * multiple of the current approved size for the device.
*/ */
void ll_rw_block(int rw, int nr, struct buffer_head * bhs[]) void ll_rw_block(int rw, int nr, struct buffer_head *bhs[])
{ {
unsigned int major;
int correct_size;
int i; int i;
if (!nr)
return;
major = major(to_kdev_t(bhs[0]->b_bdev->bd_dev));
/* Determine correct block size for this device. */
correct_size = bdev_hardsect_size(bhs[0]->b_bdev);
/* Verify requested block sizes. */
for (i = 0; i < nr; i++) {
struct buffer_head *bh = bhs[i];
if (bh->b_size & (correct_size - 1)) {
printk(KERN_NOTICE "ll_rw_block: device %s: "
"only %d-char blocks implemented (%u)\n",
bdevname(bhs[0]->b_bdev),
correct_size, bh->b_size);
goto sorry;
}
}
if ((rw & WRITE) && bdev_read_only(bhs[0]->b_bdev)) {
printk(KERN_NOTICE "Can't write to read-only device %s\n",
bdevname(bhs[0]->b_bdev));
goto sorry;
}
for (i = 0; i < nr; i++) { for (i = 0; i < nr; i++) {
struct buffer_head *bh = bhs[i]; struct buffer_head *bh = bhs[i];
/* Only one thread can actually submit the I/O. */
if (test_set_buffer_locked(bh)) if (test_set_buffer_locked(bh))
continue; continue;
/* We have the buffer lock */ get_bh(bh);
atomic_inc(&bh->b_count);
bh->b_end_io = end_buffer_io_sync; bh->b_end_io = end_buffer_io_sync;
if (rw == WRITE) {
switch(rw) { if (test_clear_buffer_dirty(bh)) {
case WRITE: submit_bh(WRITE, bh);
if (!test_clear_buffer_dirty(bh)) continue;
/* Hmmph! Nothing to write */ }
goto end_io; } else {
break; if (!buffer_uptodate(bh)) {
submit_bh(READ, bh);
case READA: continue;
case READ: }
if (buffer_uptodate(bh))
/* Hmmph! Already have it */
goto end_io;
break;
default:
BUG();
end_io:
bh->b_end_io(bh, buffer_uptodate(bh));
continue;
} }
unlock_buffer(bh);
submit_bh(rw, bh); put_bh(bh);
} }
return;
sorry:
/* Make sure we don't get infinite dirty retries.. */
for (i = 0; i < nr; i++)
clear_buffer_dirty(bhs[i]);
} }
/* /*
......
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