diff options
author | Martin K. Petersen <martin.petersen@oracle.com> | 2014-09-26 19:20:01 -0400 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2014-09-27 11:14:51 -0400 |
commit | 1859308853b19c4daf4afaab910d3d52ac1ec2ff (patch) | |
tree | 3b5a3ffcb96d88320cb609883f436b33b094ac58 | |
parent | 5a2aa873059fec8b6385071d9c0802893a9b2f41 (diff) |
block: Clean up the code used to generate and verify integrity metadata
Instead of the "operate" parameter we pass in a seed value and a pointer
to a function that can be used to process the integrity metadata. The
generation function is changed to have a return value to fit into this
scheme.
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Sagi Grimberg <sagig@mellanox.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r-- | block/bio-integrity.c | 82 | ||||
-rw-r--r-- | drivers/scsi/sd_dif.c | 106 | ||||
-rw-r--r-- | include/linux/bio.h | 12 | ||||
-rw-r--r-- | include/linux/blkdev.h | 9 |
4 files changed, 94 insertions, 115 deletions
diff --git a/block/bio-integrity.c b/block/bio-integrity.c index cf40837e7710..fe4de033b34c 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c | |||
@@ -207,49 +207,37 @@ static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi, | |||
207 | } | 207 | } |
208 | 208 | ||
209 | /** | 209 | /** |
210 | * bio_integrity_generate_verify - Generate/verify integrity metadata for a bio | 210 | * bio_integrity_process - Process integrity metadata for a bio |
211 | * @bio: bio to generate/verify integrity metadata for | 211 | * @bio: bio to generate/verify integrity metadata for |
212 | * @operate: operate number, 1 for generate, 0 for verify | 212 | * @proc_fn: Pointer to the relevant processing function |
213 | */ | 213 | */ |
214 | static int bio_integrity_generate_verify(struct bio *bio, int operate) | 214 | static int bio_integrity_process(struct bio *bio, |
215 | integrity_processing_fn *proc_fn) | ||
215 | { | 216 | { |
216 | struct blk_integrity *bi = bdev_get_integrity(bio->bi_bdev); | 217 | struct blk_integrity *bi = bdev_get_integrity(bio->bi_bdev); |
217 | struct blk_integrity_exchg bix; | 218 | struct blk_integrity_iter iter; |
218 | struct bio_vec *bv; | 219 | struct bio_vec *bv; |
219 | struct bio_integrity_payload *bip = bio_integrity(bio); | 220 | struct bio_integrity_payload *bip = bio_integrity(bio); |
220 | sector_t seed; | 221 | unsigned int i, ret = 0; |
221 | unsigned int intervals, ret = 0, i; | ||
222 | void *prot_buf = page_address(bip->bip_vec->bv_page) + | 222 | void *prot_buf = page_address(bip->bip_vec->bv_page) + |
223 | bip->bip_vec->bv_offset; | 223 | bip->bip_vec->bv_offset; |
224 | 224 | ||
225 | if (operate) | 225 | iter.disk_name = bio->bi_bdev->bd_disk->disk_name; |
226 | seed = bio->bi_iter.bi_sector; | 226 | iter.interval = bi->interval; |
227 | else | 227 | iter.seed = bip_get_seed(bip); |
228 | seed = bip->bip_iter.bi_sector; | 228 | iter.prot_buf = prot_buf; |
229 | |||
230 | bix.disk_name = bio->bi_bdev->bd_disk->disk_name; | ||
231 | bix.interval = bi->interval; | ||
232 | 229 | ||
233 | bio_for_each_segment_all(bv, bio, i) { | 230 | bio_for_each_segment_all(bv, bio, i) { |
234 | void *kaddr = kmap_atomic(bv->bv_page); | 231 | void *kaddr = kmap_atomic(bv->bv_page); |
235 | bix.data_buf = kaddr + bv->bv_offset; | ||
236 | bix.data_size = bv->bv_len; | ||
237 | bix.prot_buf = prot_buf; | ||
238 | bix.seed = seed; | ||
239 | |||
240 | if (operate) | ||
241 | bi->generate_fn(&bix); | ||
242 | else { | ||
243 | ret = bi->verify_fn(&bix); | ||
244 | if (ret) { | ||
245 | kunmap_atomic(kaddr); | ||
246 | return ret; | ||
247 | } | ||
248 | } | ||
249 | 232 | ||
250 | intervals = bv->bv_len / bi->interval; | 233 | iter.data_buf = kaddr + bv->bv_offset; |
251 | seed += intervals; | 234 | iter.data_size = bv->bv_len; |
252 | prot_buf += intervals * bi->tuple_size; | 235 | |
236 | ret = proc_fn(&iter); | ||
237 | if (ret) { | ||
238 | kunmap_atomic(kaddr); | ||
239 | return ret; | ||
240 | } | ||
253 | 241 | ||
254 | kunmap_atomic(kaddr); | 242 | kunmap_atomic(kaddr); |
255 | } | 243 | } |
@@ -257,20 +245,6 @@ static int bio_integrity_generate_verify(struct bio *bio, int operate) | |||
257 | } | 245 | } |
258 | 246 | ||
259 | /** | 247 | /** |
260 | * bio_integrity_generate - Generate integrity metadata for a bio | ||
261 | * @bio: bio to generate integrity metadata for | ||
262 | * | ||
263 | * Description: Generates integrity metadata for a bio by calling the | ||
264 | * block device's generation callback function. The bio must have a | ||
265 | * bip attached with enough room to accommodate the generated | ||
266 | * integrity metadata. | ||
267 | */ | ||
268 | static void bio_integrity_generate(struct bio *bio) | ||
269 | { | ||
270 | bio_integrity_generate_verify(bio, 1); | ||
271 | } | ||
272 | |||
273 | /** | ||
274 | * bio_integrity_prep - Prepare bio for integrity I/O | 248 | * bio_integrity_prep - Prepare bio for integrity I/O |
275 | * @bio: bio to prepare | 249 | * @bio: bio to prepare |
276 | * | 250 | * |
@@ -321,7 +295,7 @@ int bio_integrity_prep(struct bio *bio) | |||
321 | 295 | ||
322 | bip->bip_owns_buf = 1; | 296 | bip->bip_owns_buf = 1; |
323 | bip->bip_iter.bi_size = len; | 297 | bip->bip_iter.bi_size = len; |
324 | bip->bip_iter.bi_sector = bio->bi_iter.bi_sector; | 298 | bip_set_seed(bip, bio->bi_iter.bi_sector); |
325 | 299 | ||
326 | /* Map it */ | 300 | /* Map it */ |
327 | offset = offset_in_page(buf); | 301 | offset = offset_in_page(buf); |
@@ -357,26 +331,13 @@ int bio_integrity_prep(struct bio *bio) | |||
357 | 331 | ||
358 | /* Auto-generate integrity metadata if this is a write */ | 332 | /* Auto-generate integrity metadata if this is a write */ |
359 | if (bio_data_dir(bio) == WRITE) | 333 | if (bio_data_dir(bio) == WRITE) |
360 | bio_integrity_generate(bio); | 334 | bio_integrity_process(bio, bi->generate_fn); |
361 | 335 | ||
362 | return 0; | 336 | return 0; |
363 | } | 337 | } |
364 | EXPORT_SYMBOL(bio_integrity_prep); | 338 | EXPORT_SYMBOL(bio_integrity_prep); |
365 | 339 | ||
366 | /** | 340 | /** |
367 | * bio_integrity_verify - Verify integrity metadata for a bio | ||
368 | * @bio: bio to verify | ||
369 | * | ||
370 | * Description: This function is called to verify the integrity of a | ||
371 | * bio. The data in the bio io_vec is compared to the integrity | ||
372 | * metadata returned by the HBA. | ||
373 | */ | ||
374 | static int bio_integrity_verify(struct bio *bio) | ||
375 | { | ||
376 | return bio_integrity_generate_verify(bio, 0); | ||
377 | } | ||
378 | |||
379 | /** | ||
380 | * bio_integrity_verify_fn - Integrity I/O completion worker | 341 | * bio_integrity_verify_fn - Integrity I/O completion worker |
381 | * @work: Work struct stored in bio to be verified | 342 | * @work: Work struct stored in bio to be verified |
382 | * | 343 | * |
@@ -389,9 +350,10 @@ static void bio_integrity_verify_fn(struct work_struct *work) | |||
389 | struct bio_integrity_payload *bip = | 350 | struct bio_integrity_payload *bip = |
390 | container_of(work, struct bio_integrity_payload, bip_work); | 351 | container_of(work, struct bio_integrity_payload, bip_work); |
391 | struct bio *bio = bip->bip_bio; | 352 | struct bio *bio = bip->bip_bio; |
353 | struct blk_integrity *bi = bdev_get_integrity(bio->bi_bdev); | ||
392 | int error; | 354 | int error; |
393 | 355 | ||
394 | error = bio_integrity_verify(bio); | 356 | error = bio_integrity_process(bio, bi->verify_fn); |
395 | 357 | ||
396 | /* Restore original bio completion handler */ | 358 | /* Restore original bio completion handler */ |
397 | bio->bi_end_io = bip->bip_end_io; | 359 | bio->bi_end_io = bip->bip_end_io; |
diff --git a/drivers/scsi/sd_dif.c b/drivers/scsi/sd_dif.c index 1600270a46e5..801c41851a01 100644 --- a/drivers/scsi/sd_dif.c +++ b/drivers/scsi/sd_dif.c | |||
@@ -53,42 +53,44 @@ static __u16 sd_dif_ip_fn(void *data, unsigned int len) | |||
53 | * Type 1 and Type 2 protection use the same format: 16 bit guard tag, | 53 | * Type 1 and Type 2 protection use the same format: 16 bit guard tag, |
54 | * 16 bit app tag, 32 bit reference tag. | 54 | * 16 bit app tag, 32 bit reference tag. |
55 | */ | 55 | */ |
56 | static void sd_dif_type1_generate(struct blk_integrity_exchg *bix, csum_fn *fn) | 56 | static void sd_dif_type1_generate(struct blk_integrity_iter *iter, csum_fn *fn) |
57 | { | 57 | { |
58 | void *buf = bix->data_buf; | 58 | void *buf = iter->data_buf; |
59 | struct sd_dif_tuple *sdt = bix->prot_buf; | 59 | struct sd_dif_tuple *sdt = iter->prot_buf; |
60 | sector_t seed = bix->seed; | 60 | sector_t seed = iter->seed; |
61 | unsigned int i; | 61 | unsigned int i; |
62 | 62 | ||
63 | for (i = 0 ; i < bix->data_size ; i += bix->interval, sdt++) { | 63 | for (i = 0 ; i < iter->data_size ; i += iter->interval, sdt++) { |
64 | sdt->guard_tag = fn(buf, bix->interval); | 64 | sdt->guard_tag = fn(buf, iter->interval); |
65 | sdt->ref_tag = cpu_to_be32(seed & 0xffffffff); | 65 | sdt->ref_tag = cpu_to_be32(seed & 0xffffffff); |
66 | sdt->app_tag = 0; | 66 | sdt->app_tag = 0; |
67 | 67 | ||
68 | buf += bix->interval; | 68 | buf += iter->interval; |
69 | seed++; | 69 | seed++; |
70 | } | 70 | } |
71 | } | 71 | } |
72 | 72 | ||
73 | static void sd_dif_type1_generate_crc(struct blk_integrity_exchg *bix) | 73 | static int sd_dif_type1_generate_crc(struct blk_integrity_iter *iter) |
74 | { | 74 | { |
75 | sd_dif_type1_generate(bix, sd_dif_crc_fn); | 75 | sd_dif_type1_generate(iter, sd_dif_crc_fn); |
76 | return 0; | ||
76 | } | 77 | } |
77 | 78 | ||
78 | static void sd_dif_type1_generate_ip(struct blk_integrity_exchg *bix) | 79 | static int sd_dif_type1_generate_ip(struct blk_integrity_iter *iter) |
79 | { | 80 | { |
80 | sd_dif_type1_generate(bix, sd_dif_ip_fn); | 81 | sd_dif_type1_generate(iter, sd_dif_ip_fn); |
82 | return 0; | ||
81 | } | 83 | } |
82 | 84 | ||
83 | static int sd_dif_type1_verify(struct blk_integrity_exchg *bix, csum_fn *fn) | 85 | static int sd_dif_type1_verify(struct blk_integrity_iter *iter, csum_fn *fn) |
84 | { | 86 | { |
85 | void *buf = bix->data_buf; | 87 | void *buf = iter->data_buf; |
86 | struct sd_dif_tuple *sdt = bix->prot_buf; | 88 | struct sd_dif_tuple *sdt = iter->prot_buf; |
87 | sector_t seed = bix->seed; | 89 | sector_t seed = iter->seed; |
88 | unsigned int i; | 90 | unsigned int i; |
89 | __u16 csum; | 91 | __u16 csum; |
90 | 92 | ||
91 | for (i = 0 ; i < bix->data_size ; i += bix->interval, sdt++) { | 93 | for (i = 0 ; i < iter->data_size ; i += iter->interval, sdt++) { |
92 | /* Unwritten sectors */ | 94 | /* Unwritten sectors */ |
93 | if (sdt->app_tag == 0xffff) | 95 | if (sdt->app_tag == 0xffff) |
94 | return 0; | 96 | return 0; |
@@ -96,36 +98,36 @@ static int sd_dif_type1_verify(struct blk_integrity_exchg *bix, csum_fn *fn) | |||
96 | if (be32_to_cpu(sdt->ref_tag) != (seed & 0xffffffff)) { | 98 | if (be32_to_cpu(sdt->ref_tag) != (seed & 0xffffffff)) { |
97 | printk(KERN_ERR | 99 | printk(KERN_ERR |
98 | "%s: ref tag error on sector %lu (rcvd %u)\n", | 100 | "%s: ref tag error on sector %lu (rcvd %u)\n", |
99 | bix->disk_name, (unsigned long)seed, | 101 | iter->disk_name, (unsigned long)seed, |
100 | be32_to_cpu(sdt->ref_tag)); | 102 | be32_to_cpu(sdt->ref_tag)); |
101 | return -EIO; | 103 | return -EIO; |
102 | } | 104 | } |
103 | 105 | ||
104 | csum = fn(buf, bix->interval); | 106 | csum = fn(buf, iter->interval); |
105 | 107 | ||
106 | if (sdt->guard_tag != csum) { | 108 | if (sdt->guard_tag != csum) { |
107 | printk(KERN_ERR "%s: guard tag error on sector %lu " \ | 109 | printk(KERN_ERR "%s: guard tag error on sector %lu " \ |
108 | "(rcvd %04x, data %04x)\n", bix->disk_name, | 110 | "(rcvd %04x, data %04x)\n", iter->disk_name, |
109 | (unsigned long)seed, | 111 | (unsigned long)seed, |
110 | be16_to_cpu(sdt->guard_tag), be16_to_cpu(csum)); | 112 | be16_to_cpu(sdt->guard_tag), be16_to_cpu(csum)); |
111 | return -EIO; | 113 | return -EIO; |
112 | } | 114 | } |
113 | 115 | ||
114 | buf += bix->interval; | 116 | buf += iter->interval; |
115 | seed++; | 117 | seed++; |
116 | } | 118 | } |
117 | 119 | ||
118 | return 0; | 120 | return 0; |
119 | } | 121 | } |
120 | 122 | ||
121 | static int sd_dif_type1_verify_crc(struct blk_integrity_exchg *bix) | 123 | static int sd_dif_type1_verify_crc(struct blk_integrity_iter *iter) |
122 | { | 124 | { |
123 | return sd_dif_type1_verify(bix, sd_dif_crc_fn); | 125 | return sd_dif_type1_verify(iter, sd_dif_crc_fn); |
124 | } | 126 | } |
125 | 127 | ||
126 | static int sd_dif_type1_verify_ip(struct blk_integrity_exchg *bix) | 128 | static int sd_dif_type1_verify_ip(struct blk_integrity_iter *iter) |
127 | { | 129 | { |
128 | return sd_dif_type1_verify(bix, sd_dif_ip_fn); | 130 | return sd_dif_type1_verify(iter, sd_dif_ip_fn); |
129 | } | 131 | } |
130 | 132 | ||
131 | static struct blk_integrity dif_type1_integrity_crc = { | 133 | static struct blk_integrity dif_type1_integrity_crc = { |
@@ -149,69 +151,71 @@ static struct blk_integrity dif_type1_integrity_ip = { | |||
149 | * Type 3 protection has a 16-bit guard tag and 16 + 32 bits of opaque | 151 | * Type 3 protection has a 16-bit guard tag and 16 + 32 bits of opaque |
150 | * tag space. | 152 | * tag space. |
151 | */ | 153 | */ |
152 | static void sd_dif_type3_generate(struct blk_integrity_exchg *bix, csum_fn *fn) | 154 | static void sd_dif_type3_generate(struct blk_integrity_iter *iter, csum_fn *fn) |
153 | { | 155 | { |
154 | void *buf = bix->data_buf; | 156 | void *buf = iter->data_buf; |
155 | struct sd_dif_tuple *sdt = bix->prot_buf; | 157 | struct sd_dif_tuple *sdt = iter->prot_buf; |
156 | unsigned int i; | 158 | unsigned int i; |
157 | 159 | ||
158 | for (i = 0 ; i < bix->data_size ; i += bix->interval, sdt++) { | 160 | for (i = 0 ; i < iter->data_size ; i += iter->interval, sdt++) { |
159 | sdt->guard_tag = fn(buf, bix->interval); | 161 | sdt->guard_tag = fn(buf, iter->interval); |
160 | sdt->ref_tag = 0; | 162 | sdt->ref_tag = 0; |
161 | sdt->app_tag = 0; | 163 | sdt->app_tag = 0; |
162 | 164 | ||
163 | buf += bix->interval; | 165 | buf += iter->interval; |
164 | } | 166 | } |
165 | } | 167 | } |
166 | 168 | ||
167 | static void sd_dif_type3_generate_crc(struct blk_integrity_exchg *bix) | 169 | static int sd_dif_type3_generate_crc(struct blk_integrity_iter *iter) |
168 | { | 170 | { |
169 | sd_dif_type3_generate(bix, sd_dif_crc_fn); | 171 | sd_dif_type3_generate(iter, sd_dif_crc_fn); |
172 | return 0; | ||
170 | } | 173 | } |
171 | 174 | ||
172 | static void sd_dif_type3_generate_ip(struct blk_integrity_exchg *bix) | 175 | static int sd_dif_type3_generate_ip(struct blk_integrity_iter *iter) |
173 | { | 176 | { |
174 | sd_dif_type3_generate(bix, sd_dif_ip_fn); | 177 | sd_dif_type3_generate(iter, sd_dif_ip_fn); |
178 | return 0; | ||
175 | } | 179 | } |
176 | 180 | ||
177 | static int sd_dif_type3_verify(struct blk_integrity_exchg *bix, csum_fn *fn) | 181 | static int sd_dif_type3_verify(struct blk_integrity_iter *iter, csum_fn *fn) |
178 | { | 182 | { |
179 | void *buf = bix->data_buf; | 183 | void *buf = iter->data_buf; |
180 | struct sd_dif_tuple *sdt = bix->prot_buf; | 184 | struct sd_dif_tuple *sdt = iter->prot_buf; |
181 | sector_t seed = bix->seed; | 185 | sector_t seed = iter->seed; |
182 | unsigned int i; | 186 | unsigned int i; |
183 | __u16 csum; | 187 | __u16 csum; |
184 | 188 | ||
185 | for (i = 0 ; i < bix->data_size ; i += bix->interval, sdt++) { | 189 | for (i = 0 ; i < iter->data_size ; i += iter->interval, sdt++) { |
186 | /* Unwritten sectors */ | 190 | /* Unwritten sectors */ |
187 | if (sdt->app_tag == 0xffff && sdt->ref_tag == 0xffffffff) | 191 | if (sdt->app_tag == 0xffff && sdt->ref_tag == 0xffffffff) |
188 | return 0; | 192 | return 0; |
189 | 193 | ||
190 | csum = fn(buf, bix->interval); | 194 | csum = fn(buf, iter->interval); |
191 | 195 | ||
192 | if (sdt->guard_tag != csum) { | 196 | if (sdt->guard_tag != csum) { |
193 | printk(KERN_ERR "%s: guard tag error on sector %lu " \ | 197 | printk(KERN_ERR "%s: guard tag error on sector %lu " \ |
194 | "(rcvd %04x, data %04x)\n", bix->disk_name, | 198 | "(rcvd %04x, data %04x)\n", iter->disk_name, |
195 | (unsigned long)seed, | 199 | (unsigned long)seed, |
196 | be16_to_cpu(sdt->guard_tag), be16_to_cpu(csum)); | 200 | be16_to_cpu(sdt->guard_tag), be16_to_cpu(csum)); |
197 | return -EIO; | 201 | return -EIO; |
198 | } | 202 | } |
199 | 203 | ||
200 | buf += bix->interval; | 204 | buf += iter->interval; |
201 | seed++; | 205 | seed++; |
202 | } | 206 | } |
203 | 207 | ||
204 | return 0; | 208 | return 0; |
205 | } | 209 | } |
206 | 210 | ||
207 | static int sd_dif_type3_verify_crc(struct blk_integrity_exchg *bix) | 211 | static int sd_dif_type3_verify_crc(struct blk_integrity_iter *iter) |
208 | { | 212 | { |
209 | return sd_dif_type3_verify(bix, sd_dif_crc_fn); | 213 | return sd_dif_type3_verify(iter, sd_dif_crc_fn); |
210 | } | 214 | } |
211 | 215 | ||
212 | static int sd_dif_type3_verify_ip(struct blk_integrity_exchg *bix) | 216 | static int sd_dif_type3_verify_ip(struct blk_integrity_iter *iter) |
213 | { | 217 | { |
214 | return sd_dif_type3_verify(bix, sd_dif_ip_fn); | 218 | return sd_dif_type3_verify(iter, sd_dif_ip_fn); |
215 | } | 219 | } |
216 | 220 | ||
217 | static struct blk_integrity dif_type3_integrity_crc = { | 221 | static struct blk_integrity dif_type3_integrity_crc = { |
@@ -310,6 +314,7 @@ void sd_dif_prepare(struct request *rq, sector_t hw_sector, | |||
310 | phys = hw_sector & 0xffffffff; | 314 | phys = hw_sector & 0xffffffff; |
311 | 315 | ||
312 | __rq_for_each_bio(bio, rq) { | 316 | __rq_for_each_bio(bio, rq) { |
317 | struct bio_integrity_payload *bip = bio_integrity(bio); | ||
313 | struct bio_vec iv; | 318 | struct bio_vec iv; |
314 | struct bvec_iter iter; | 319 | struct bvec_iter iter; |
315 | unsigned int j; | 320 | unsigned int j; |
@@ -318,9 +323,9 @@ void sd_dif_prepare(struct request *rq, sector_t hw_sector, | |||
318 | if (bio_flagged(bio, BIO_MAPPED_INTEGRITY)) | 323 | if (bio_flagged(bio, BIO_MAPPED_INTEGRITY)) |
319 | break; | 324 | break; |
320 | 325 | ||
321 | virt = bio_integrity(bio)->bip_iter.bi_sector & 0xffffffff; | 326 | virt = bip_get_seed(bip) & 0xffffffff; |
322 | 327 | ||
323 | bip_for_each_vec(iv, bio_integrity(bio), iter) { | 328 | bip_for_each_vec(iv, bip, iter) { |
324 | sdt = kmap_atomic(iv.bv_page) | 329 | sdt = kmap_atomic(iv.bv_page) |
325 | + iv.bv_offset; | 330 | + iv.bv_offset; |
326 | 331 | ||
@@ -366,12 +371,13 @@ void sd_dif_complete(struct scsi_cmnd *scmd, unsigned int good_bytes) | |||
366 | phys >>= 3; | 371 | phys >>= 3; |
367 | 372 | ||
368 | __rq_for_each_bio(bio, scmd->request) { | 373 | __rq_for_each_bio(bio, scmd->request) { |
374 | struct bio_integrity_payload *bip = bio_integrity(bio); | ||
369 | struct bio_vec iv; | 375 | struct bio_vec iv; |
370 | struct bvec_iter iter; | 376 | struct bvec_iter iter; |
371 | 377 | ||
372 | virt = bio_integrity(bio)->bip_iter.bi_sector & 0xffffffff; | 378 | virt = bip_get_seed(bip) & 0xffffffff; |
373 | 379 | ||
374 | bip_for_each_vec(iv, bio_integrity(bio), iter) { | 380 | bip_for_each_vec(iv, bip, iter) { |
375 | sdt = kmap_atomic(iv.bv_page) | 381 | sdt = kmap_atomic(iv.bv_page) |
376 | + iv.bv_offset; | 382 | + iv.bv_offset; |
377 | 383 | ||
diff --git a/include/linux/bio.h b/include/linux/bio.h index 448d8c052cb7..3fd36660fd10 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h | |||
@@ -322,6 +322,18 @@ struct bio_integrity_payload { | |||
322 | struct bio_vec *bip_vec; | 322 | struct bio_vec *bip_vec; |
323 | struct bio_vec bip_inline_vecs[0];/* embedded bvec array */ | 323 | struct bio_vec bip_inline_vecs[0];/* embedded bvec array */ |
324 | }; | 324 | }; |
325 | |||
326 | static inline sector_t bip_get_seed(struct bio_integrity_payload *bip) | ||
327 | { | ||
328 | return bip->bip_iter.bi_sector; | ||
329 | } | ||
330 | |||
331 | static inline void bip_set_seed(struct bio_integrity_payload *bip, | ||
332 | sector_t seed) | ||
333 | { | ||
334 | bip->bip_iter.bi_sector = seed; | ||
335 | } | ||
336 | |||
325 | #endif /* CONFIG_BLK_DEV_INTEGRITY */ | 337 | #endif /* CONFIG_BLK_DEV_INTEGRITY */ |
326 | 338 | ||
327 | extern void bio_trim(struct bio *bio, int offset, int size); | 339 | extern void bio_trim(struct bio *bio, int offset, int size); |
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index d364c42dbf17..24c1e055b8a7 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h | |||
@@ -1461,7 +1461,7 @@ static inline uint64_t rq_io_start_time_ns(struct request *req) | |||
1461 | #define INTEGRITY_FLAG_READ 2 /* verify data integrity on read */ | 1461 | #define INTEGRITY_FLAG_READ 2 /* verify data integrity on read */ |
1462 | #define INTEGRITY_FLAG_WRITE 4 /* generate data integrity on write */ | 1462 | #define INTEGRITY_FLAG_WRITE 4 /* generate data integrity on write */ |
1463 | 1463 | ||
1464 | struct blk_integrity_exchg { | 1464 | struct blk_integrity_iter { |
1465 | void *prot_buf; | 1465 | void *prot_buf; |
1466 | void *data_buf; | 1466 | void *data_buf; |
1467 | sector_t seed; | 1467 | sector_t seed; |
@@ -1470,12 +1470,11 @@ struct blk_integrity_exchg { | |||
1470 | const char *disk_name; | 1470 | const char *disk_name; |
1471 | }; | 1471 | }; |
1472 | 1472 | ||
1473 | typedef void (integrity_gen_fn) (struct blk_integrity_exchg *); | 1473 | typedef int (integrity_processing_fn) (struct blk_integrity_iter *); |
1474 | typedef int (integrity_vrfy_fn) (struct blk_integrity_exchg *); | ||
1475 | 1474 | ||
1476 | struct blk_integrity { | 1475 | struct blk_integrity { |
1477 | integrity_gen_fn *generate_fn; | 1476 | integrity_processing_fn *generate_fn; |
1478 | integrity_vrfy_fn *verify_fn; | 1477 | integrity_processing_fn *verify_fn; |
1479 | 1478 | ||
1480 | unsigned short flags; | 1479 | unsigned short flags; |
1481 | unsigned short tuple_size; | 1480 | unsigned short tuple_size; |