]>
Commit | Line | Data |
---|---|---|
b9b7e71a | 1 | diff -Nur linux-2.4.16/drivers/block/loop.c linux-int-2.4.16/drivers/block/loop.c |
2 | --- linux-2.4.16/drivers/block/loop.c Mon Nov 19 23:48:02 2001 | |
3 | +++ linux-int-2.4.16/drivers/block/loop.c Tue Dec 4 16:05:50 2001 | |
4 | @@ -85,7 +85,7 @@ | |
5 | * Transfer functions | |
6 | */ | |
7 | static int transfer_none(struct loop_device *lo, int cmd, char *raw_buf, | |
8 | - char *loop_buf, int size, int real_block) | |
9 | + char *loop_buf, int size, loop_iv_t IV) | |
10 | { | |
11 | if (raw_buf != loop_buf) { | |
12 | if (cmd == READ) | |
13 | @@ -98,7 +98,7 @@ | |
14 | } | |
15 | ||
16 | static int transfer_xor(struct loop_device *lo, int cmd, char *raw_buf, | |
17 | - char *loop_buf, int size, int real_block) | |
18 | + char *loop_buf, int size, loop_iv_t IV) | |
19 | { | |
20 | char *in, *out, *key; | |
21 | int i, keysize; | |
22 | @@ -186,7 +186,7 @@ | |
23 | len = bh->b_size; | |
24 | data = bh->b_data; | |
25 | while (len > 0) { | |
26 | - int IV = index * (PAGE_CACHE_SIZE/bsize) + offset/bsize; | |
27 | + const loop_iv_t IV = (index << (PAGE_CACHE_SHIFT - LOOP_IV_SECTOR_BITS)) + (offset >> LOOP_IV_SECTOR_BITS); | |
28 | int transfer_result; | |
29 | ||
30 | size = PAGE_CACHE_SIZE - offset; | |
31 | @@ -244,7 +244,7 @@ | |
32 | unsigned long count = desc->count; | |
33 | struct lo_read_data *p = (struct lo_read_data*)desc->buf; | |
34 | struct loop_device *lo = p->lo; | |
35 | - int IV = page->index * (PAGE_CACHE_SIZE/p->bsize) + offset/p->bsize; | |
36 | + const loop_iv_t IV = (page->index << (PAGE_CACHE_SHIFT - LOOP_IV_SECTOR_BITS)) + (offset >> LOOP_IV_SECTOR_BITS); | |
37 | ||
38 | if (size > count) | |
39 | size = count; | |
40 | @@ -296,20 +296,6 @@ | |
41 | return bs; | |
42 | } | |
43 | ||
44 | -static inline unsigned long loop_get_iv(struct loop_device *lo, | |
45 | - unsigned long sector) | |
46 | -{ | |
47 | - int bs = loop_get_bs(lo); | |
48 | - unsigned long offset, IV; | |
49 | - | |
50 | - IV = sector / (bs >> 9) + lo->lo_offset / bs; | |
51 | - offset = ((sector % (bs >> 9)) << 9) + lo->lo_offset % bs; | |
52 | - if (offset >= bs) | |
53 | - IV++; | |
54 | - | |
55 | - return IV; | |
56 | -} | |
57 | - | |
58 | static int do_bh_filebacked(struct loop_device *lo, struct buffer_head *bh, int rw) | |
59 | { | |
60 | loff_t pos; | |
61 | @@ -455,7 +441,7 @@ | |
62 | { | |
63 | struct buffer_head *bh = NULL; | |
64 | struct loop_device *lo; | |
65 | - unsigned long IV; | |
66 | + loop_iv_t IV; | |
67 | ||
68 | if (!buffer_locked(rbh)) | |
69 | BUG(); | |
70 | @@ -502,7 +488,7 @@ | |
71 | * piggy old buffer on original, and submit for I/O | |
72 | */ | |
73 | bh = loop_get_buffer(lo, rbh); | |
74 | - IV = loop_get_iv(lo, rbh->b_rsector); | |
75 | + IV = rbh->b_rsector + (lo->lo_offset >> LOOP_IV_SECTOR_BITS); | |
76 | if (rw == WRITE) { | |
77 | set_bit(BH_Dirty, &bh->b_state); | |
78 | if (lo_do_transfer(lo, WRITE, bh->b_data, rbh->b_data, | |
79 | @@ -539,7 +525,7 @@ | |
80 | bh->b_end_io(bh, !ret); | |
81 | } else { | |
82 | struct buffer_head *rbh = bh->b_private; | |
83 | - unsigned long IV = loop_get_iv(lo, rbh->b_rsector); | |
84 | + const loop_iv_t IV = rbh->b_rsector + (lo->lo_offset >> LOOP_IV_SECTOR_BITS); | |
85 | ||
86 | ret = lo_do_transfer(lo, READ, bh->b_data, rbh->b_data, | |
87 | bh->b_size, IV); | |
88 | diff -Nur linux-2.4.16/include/linux/loop.h linux-int-2.4.16/include/linux/loop.h | |
89 | --- linux-2.4.16/include/linux/loop.h Mon Sep 17 22:16:30 2001 | |
90 | +++ linux-int-2.4.16/include/linux/loop.h Tue Dec 4 16:06:03 2001 | |
91 | @@ -17,6 +17,12 @@ | |
92 | ||
93 | #ifdef __KERNEL__ | |
94 | ||
95 | +/* definitions for IV metric */ | |
96 | +#define LOOP_IV_SECTOR_BITS 9 | |
97 | +#define LOOP_IV_SECTOR_SIZE (1 << LOOP_IV_SECTOR_BITS) | |
98 | + | |
99 | +typedef int loop_iv_t; | |
100 | + | |
101 | /* Possible states of device */ | |
102 | enum { | |
103 | Lo_unbound, | |
104 | @@ -24,6 +30,12 @@ | |
105 | Lo_rundown, | |
106 | }; | |
107 | ||
108 | +struct loop_device; | |
109 | + | |
110 | +typedef int (* transfer_proc_t)(struct loop_device *, int cmd, | |
111 | + char *raw_buf, char *loop_buf, int size, | |
112 | + loop_iv_t IV); | |
113 | + | |
114 | struct loop_device { | |
115 | int lo_number; | |
116 | int lo_refcnt; | |
117 | @@ -32,9 +44,7 @@ | |
118 | int lo_encrypt_type; | |
119 | int lo_encrypt_key_size; | |
120 | int lo_flags; | |
121 | - int (*transfer)(struct loop_device *, int cmd, | |
122 | - char *raw_buf, char *loop_buf, int size, | |
123 | - int real_block); | |
124 | + transfer_proc_t transfer; | |
125 | char lo_name[LO_NAME_SIZE]; | |
126 | char lo_encrypt_key[LO_KEY_SIZE]; | |
127 | __u32 lo_init[2]; | |
128 | @@ -58,17 +68,13 @@ | |
129 | atomic_t lo_pending; | |
130 | }; | |
131 | ||
132 | -typedef int (* transfer_proc_t)(struct loop_device *, int cmd, | |
133 | - char *raw_buf, char *loop_buf, int size, | |
134 | - int real_block); | |
135 | - | |
136 | static inline int lo_do_transfer(struct loop_device *lo, int cmd, char *rbuf, | |
137 | - char *lbuf, int size, int rblock) | |
138 | + char *lbuf, int size, loop_iv_t IV) | |
139 | { | |
140 | if (!lo->transfer) | |
141 | return 0; | |
142 | ||
143 | - return lo->transfer(lo, cmd, rbuf, lbuf, size, rblock); | |
144 | + return lo->transfer(lo, cmd, rbuf, lbuf, size, IV); | |
145 | } | |
146 | #endif /* __KERNEL__ */ | |
147 | ||
148 | @@ -122,6 +128,8 @@ | |
149 | #define LO_CRYPT_IDEA 6 | |
150 | #define LO_CRYPT_DUMMY 9 | |
151 | #define LO_CRYPT_SKIPJACK 10 | |
152 | +#define LO_CRYPT_AES 16 /* loop-AES */ | |
153 | +#define LO_CRYPT_CRYPTOAPI 18 /* international crypto patch */ | |
154 | #define MAX_LO_CRYPT 20 | |
155 | ||
156 | #ifdef __KERNEL__ | |
157 | @@ -129,7 +137,7 @@ | |
158 | struct loop_func_table { | |
159 | int number; /* filter type */ | |
160 | int (*transfer)(struct loop_device *lo, int cmd, char *raw_buf, | |
161 | - char *loop_buf, int size, int real_block); | |
162 | + char *loop_buf, int size, loop_iv_t IV); | |
163 | int (*init)(struct loop_device *, struct loop_info *); | |
164 | /* release is called from loop_unregister_transfer or clr_fd */ | |
165 | int (*release)(struct loop_device *); |