diff options
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/dm-bio-record.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/md/dm-bio-record.h b/drivers/md/dm-bio-record.h index d3ec217847d6..3a8cfa2645c7 100644 --- a/drivers/md/dm-bio-record.h +++ b/drivers/md/dm-bio-record.h | |||
@@ -16,30 +16,56 @@ | |||
16 | * functions in this file help the target record and restore the | 16 | * functions in this file help the target record and restore the |
17 | * original bio state. | 17 | * original bio state. |
18 | */ | 18 | */ |
19 | |||
20 | struct dm_bio_vec_details { | ||
21 | #if PAGE_SIZE < 65536 | ||
22 | __u16 bv_len; | ||
23 | __u16 bv_offset; | ||
24 | #else | ||
25 | unsigned bv_len; | ||
26 | unsigned bv_offset; | ||
27 | #endif | ||
28 | }; | ||
29 | |||
19 | struct dm_bio_details { | 30 | struct dm_bio_details { |
20 | sector_t bi_sector; | 31 | sector_t bi_sector; |
21 | struct block_device *bi_bdev; | 32 | struct block_device *bi_bdev; |
22 | unsigned int bi_size; | 33 | unsigned int bi_size; |
23 | unsigned short bi_idx; | 34 | unsigned short bi_idx; |
24 | unsigned long bi_flags; | 35 | unsigned long bi_flags; |
36 | struct dm_bio_vec_details bi_io_vec[BIO_MAX_PAGES]; | ||
25 | }; | 37 | }; |
26 | 38 | ||
27 | static inline void dm_bio_record(struct dm_bio_details *bd, struct bio *bio) | 39 | static inline void dm_bio_record(struct dm_bio_details *bd, struct bio *bio) |
28 | { | 40 | { |
41 | unsigned i; | ||
42 | |||
29 | bd->bi_sector = bio->bi_sector; | 43 | bd->bi_sector = bio->bi_sector; |
30 | bd->bi_bdev = bio->bi_bdev; | 44 | bd->bi_bdev = bio->bi_bdev; |
31 | bd->bi_size = bio->bi_size; | 45 | bd->bi_size = bio->bi_size; |
32 | bd->bi_idx = bio->bi_idx; | 46 | bd->bi_idx = bio->bi_idx; |
33 | bd->bi_flags = bio->bi_flags; | 47 | bd->bi_flags = bio->bi_flags; |
48 | |||
49 | for (i = 0; i < bio->bi_vcnt; i++) { | ||
50 | bd->bi_io_vec[i].bv_len = bio->bi_io_vec[i].bv_len; | ||
51 | bd->bi_io_vec[i].bv_offset = bio->bi_io_vec[i].bv_offset; | ||
52 | } | ||
34 | } | 53 | } |
35 | 54 | ||
36 | static inline void dm_bio_restore(struct dm_bio_details *bd, struct bio *bio) | 55 | static inline void dm_bio_restore(struct dm_bio_details *bd, struct bio *bio) |
37 | { | 56 | { |
57 | unsigned i; | ||
58 | |||
38 | bio->bi_sector = bd->bi_sector; | 59 | bio->bi_sector = bd->bi_sector; |
39 | bio->bi_bdev = bd->bi_bdev; | 60 | bio->bi_bdev = bd->bi_bdev; |
40 | bio->bi_size = bd->bi_size; | 61 | bio->bi_size = bd->bi_size; |
41 | bio->bi_idx = bd->bi_idx; | 62 | bio->bi_idx = bd->bi_idx; |
42 | bio->bi_flags = bd->bi_flags; | 63 | bio->bi_flags = bd->bi_flags; |
64 | |||
65 | for (i = 0; i < bio->bi_vcnt; i++) { | ||
66 | bio->bi_io_vec[i].bv_len = bd->bi_io_vec[i].bv_len; | ||
67 | bio->bi_io_vec[i].bv_offset = bd->bi_io_vec[i].bv_offset; | ||
68 | } | ||
43 | } | 69 | } |
44 | 70 | ||
45 | #endif | 71 | #endif |