diff -Nur linux-2.4.16/drivers/block/loop.c linux-int-2.4.16/drivers/block/loop.c
--- linux-2.4.16/drivers/block/loop.c Mon Nov 19 23:48:02 2001
+++ linux-int-2.4.16/drivers/block/loop.c Tue Dec 4 16:05:50 2001
@@ -85,7 +85,7 @@
* Transfer functions
*/
static int transfer_none(struct loop_device *lo, int cmd, char *raw_buf,
- char *loop_buf, int size, int real_block)
+ char *loop_buf, int size, loop_iv_t IV)
{
if (raw_buf != loop_buf) {
if (cmd == READ)
@@ -98,7 +98,7 @@
}
static int transfer_xor(struct loop_device *lo, int cmd, char *raw_buf,
- char *loop_buf, int size, int real_block)
+ char *loop_buf, int size, loop_iv_t IV)
{
char *in, *out, *key;
int i, keysize;
@@ -186,7 +186,7 @@
len = bh->b_size;
data = bh->b_data;
while (len > 0) {
- int IV = index * (PAGE_CACHE_SIZE/bsize) + offset/bsize;
+ const loop_iv_t IV = (index << (PAGE_CACHE_SHIFT - LOOP_IV_SECTOR_BITS)) + (offset >> LOOP_IV_SECTOR_BITS);
int transfer_result;
+/* definitions for IV metric */
+#define LOOP_IV_SECTOR_BITS 9
+#define LOOP_IV_SECTOR_SIZE (1 << LOOP_IV_SECTOR_BITS)
+
+typedef int loop_iv_t;
+
/* Possible states of device */
enum {
Lo_unbound,
@@ -24,6 +30,12 @@
Lo_rundown,
};
+struct loop_device;
+
+typedef int (* transfer_proc_t)(struct loop_device *, int cmd,
+ char *raw_buf, char *loop_buf, int size,
+ loop_iv_t IV);
+
struct loop_device {
int lo_number;
int lo_refcnt;
@@ -32,9 +44,7 @@
int lo_encrypt_type;
int lo_encrypt_key_size;
int lo_flags;
- int (*transfer)(struct loop_device *, int cmd,
- char *raw_buf, char *loop_buf, int size,
- int real_block);
+ transfer_proc_t transfer;
char lo_name[LO_NAME_SIZE];
char lo_encrypt_key[LO_KEY_SIZE];
__u32 lo_init[2];
@@ -58,17 +68,13 @@
atomic_t lo_pending;
};
-typedef int (* transfer_proc_t)(struct loop_device *, int cmd,
- char *raw_buf, char *loop_buf, int size,
- int real_block);
-
static inline int lo_do_transfer(struct loop_device *lo, int cmd, char *rbuf,
- char *lbuf, int size, int rblock)
+ char *lbuf, int size, loop_iv_t IV)
{
if (!lo->transfer)
return 0;
#ifdef __KERNEL__
@@ -129,7 +137,7 @@
struct loop_func_table {
int number; /* filter type */
int (*transfer)(struct loop_device *lo, int cmd, char *raw_buf,
- char *loop_buf, int size, int real_block);
+ char *loop_buf, int size, loop_iv_t IV);
int (*init)(struct loop_device *, struct loop_info *);
/* release is called from loop_unregister_transfer or clr_fd */
int (*release)(struct loop_device *);