Lines 79-84
Link Here
|
79 |
|
79 |
|
80 |
#include <asm/uaccess.h> |
80 |
#include <asm/uaccess.h> |
81 |
|
81 |
|
|
|
82 |
#define LOOP_IV_SECTOR_BITS 9 |
83 |
|
82 |
static int max_loop = 8; |
84 |
static int max_loop = 8; |
83 |
static struct loop_device *loop_dev; |
85 |
static struct loop_device *loop_dev; |
84 |
static struct gendisk **disks; |
86 |
static struct gendisk **disks; |
Lines 196-202
Link Here
|
196 |
data = kmap(bvec->bv_page) + bvec->bv_offset; |
198 |
data = kmap(bvec->bv_page) + bvec->bv_offset; |
197 |
len = bvec->bv_len; |
199 |
len = bvec->bv_len; |
198 |
while (len > 0) { |
200 |
while (len > 0) { |
199 |
sector_t IV = index * (PAGE_CACHE_SIZE/bsize) + offset/bsize; |
201 |
sector_t IV = (index << (PAGE_CACHE_SHIFT - LOOP_IV_SECTOR_BITS)) + (offset >> LOOP_IV_SECTOR_BITS); |
200 |
int transfer_result; |
202 |
int transfer_result; |
201 |
|
203 |
|
202 |
size = PAGE_CACHE_SIZE - offset; |
204 |
size = PAGE_CACHE_SIZE - offset; |
Lines 276-282
Link Here
|
276 |
unsigned long count = desc->count; |
278 |
unsigned long count = desc->count; |
277 |
struct lo_read_data *p = (struct lo_read_data*)desc->buf; |
279 |
struct lo_read_data *p = (struct lo_read_data*)desc->buf; |
278 |
struct loop_device *lo = p->lo; |
280 |
struct loop_device *lo = p->lo; |
279 |
int IV = page->index * (PAGE_CACHE_SIZE/p->bsize) + offset/p->bsize; |
281 |
int IV = (page->index << (PAGE_CACHE_SHIFT - LOOP_IV_SECTOR_BITS)) + (offset >> LOOP_IV_SECTOR_BITS); |
280 |
|
282 |
|
281 |
if (size > count) |
283 |
if (size > count) |
282 |
size = count; |
284 |
size = count; |
Lines 469-475
Link Here
|
469 |
bio_transfer(struct loop_device *lo, struct bio *to_bio, |
471 |
bio_transfer(struct loop_device *lo, struct bio *to_bio, |
470 |
struct bio *from_bio) |
472 |
struct bio *from_bio) |
471 |
{ |
473 |
{ |
472 |
unsigned long IV = loop_get_iv(lo, from_bio->bi_sector); |
474 |
unsigned long IV = from_bio->bi_sector + (lo->lo_offset >> LOOP_IV_SECTOR_BITS); |
473 |
struct bio_vec *from_bvec, *to_bvec; |
475 |
struct bio_vec *from_bvec, *to_bvec; |
474 |
char *vto, *vfrom; |
476 |
char *vto, *vfrom; |
475 |
int ret = 0, i; |
477 |
int ret = 0, i; |
Lines 530-536
Link Here
|
530 |
* piggy old buffer on original, and submit for I/O |
532 |
* piggy old buffer on original, and submit for I/O |
531 |
*/ |
533 |
*/ |
532 |
new_bio = loop_get_buffer(lo, old_bio); |
534 |
new_bio = loop_get_buffer(lo, old_bio); |
533 |
IV = loop_get_iv(lo, old_bio->bi_sector); |
535 |
IV = old_bio->bi_sector + (lo->lo_offset >> LOOP_IV_SECTOR_BITS); |
534 |
if (rw == WRITE) { |
536 |
if (rw == WRITE) { |
535 |
if (bio_transfer(lo, new_bio, old_bio)) |
537 |
if (bio_transfer(lo, new_bio, old_bio)) |
536 |
goto err; |
538 |
goto err; |