diff options
Diffstat (limited to 'block/blk-integrity.c')
-rw-r--r-- | block/blk-integrity.c | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/block/blk-integrity.c b/block/blk-integrity.c index 03cf7179e8ef..7fbab84399e6 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c | |||
@@ -43,30 +43,32 @@ static const char *bi_unsupported_name = "unsupported"; | |||
43 | */ | 43 | */ |
44 | int blk_rq_count_integrity_sg(struct request_queue *q, struct bio *bio) | 44 | int blk_rq_count_integrity_sg(struct request_queue *q, struct bio *bio) |
45 | { | 45 | { |
46 | struct bio_vec *iv, *ivprv = NULL; | 46 | struct bio_vec iv, ivprv = { NULL }; |
47 | unsigned int segments = 0; | 47 | unsigned int segments = 0; |
48 | unsigned int seg_size = 0; | 48 | unsigned int seg_size = 0; |
49 | unsigned int i = 0; | 49 | struct bvec_iter iter; |
50 | int prev = 0; | ||
50 | 51 | ||
51 | bio_for_each_integrity_vec(iv, bio, i) { | 52 | bio_for_each_integrity_vec(iv, bio, iter) { |
52 | 53 | ||
53 | if (ivprv) { | 54 | if (prev) { |
54 | if (!BIOVEC_PHYS_MERGEABLE(ivprv, iv)) | 55 | if (!BIOVEC_PHYS_MERGEABLE(&ivprv, &iv)) |
55 | goto new_segment; | 56 | goto new_segment; |
56 | 57 | ||
57 | if (!BIOVEC_SEG_BOUNDARY(q, ivprv, iv)) | 58 | if (!BIOVEC_SEG_BOUNDARY(q, &ivprv, &iv)) |
58 | goto new_segment; | 59 | goto new_segment; |
59 | 60 | ||
60 | if (seg_size + iv->bv_len > queue_max_segment_size(q)) | 61 | if (seg_size + iv.bv_len > queue_max_segment_size(q)) |
61 | goto new_segment; | 62 | goto new_segment; |
62 | 63 | ||
63 | seg_size += iv->bv_len; | 64 | seg_size += iv.bv_len; |
64 | } else { | 65 | } else { |
65 | new_segment: | 66 | new_segment: |
66 | segments++; | 67 | segments++; |
67 | seg_size = iv->bv_len; | 68 | seg_size = iv.bv_len; |
68 | } | 69 | } |
69 | 70 | ||
71 | prev = 1; | ||
70 | ivprv = iv; | 72 | ivprv = iv; |
71 | } | 73 | } |
72 | 74 | ||
@@ -87,24 +89,25 @@ EXPORT_SYMBOL(blk_rq_count_integrity_sg); | |||
87 | int blk_rq_map_integrity_sg(struct request_queue *q, struct bio *bio, | 89 | int blk_rq_map_integrity_sg(struct request_queue *q, struct bio *bio, |
88 | struct scatterlist *sglist) | 90 | struct scatterlist *sglist) |
89 | { | 91 | { |
90 | struct bio_vec *iv, *ivprv = NULL; | 92 | struct bio_vec iv, ivprv = { NULL }; |
91 | struct scatterlist *sg = NULL; | 93 | struct scatterlist *sg = NULL; |
92 | unsigned int segments = 0; | 94 | unsigned int segments = 0; |
93 | unsigned int i = 0; | 95 | struct bvec_iter iter; |
96 | int prev = 0; | ||
94 | 97 | ||
95 | bio_for_each_integrity_vec(iv, bio, i) { | 98 | bio_for_each_integrity_vec(iv, bio, iter) { |
96 | 99 | ||
97 | if (ivprv) { | 100 | if (prev) { |
98 | if (!BIOVEC_PHYS_MERGEABLE(ivprv, iv)) | 101 | if (!BIOVEC_PHYS_MERGEABLE(&ivprv, &iv)) |
99 | goto new_segment; | 102 | goto new_segment; |
100 | 103 | ||
101 | if (!BIOVEC_SEG_BOUNDARY(q, ivprv, iv)) | 104 | if (!BIOVEC_SEG_BOUNDARY(q, &ivprv, &iv)) |
102 | goto new_segment; | 105 | goto new_segment; |
103 | 106 | ||
104 | if (sg->length + iv->bv_len > queue_max_segment_size(q)) | 107 | if (sg->length + iv.bv_len > queue_max_segment_size(q)) |
105 | goto new_segment; | 108 | goto new_segment; |
106 | 109 | ||
107 | sg->length += iv->bv_len; | 110 | sg->length += iv.bv_len; |
108 | } else { | 111 | } else { |
109 | new_segment: | 112 | new_segment: |
110 | if (!sg) | 113 | if (!sg) |
@@ -114,10 +117,11 @@ new_segment: | |||
114 | sg = sg_next(sg); | 117 | sg = sg_next(sg); |
115 | } | 118 | } |
116 | 119 | ||
117 | sg_set_page(sg, iv->bv_page, iv->bv_len, iv->bv_offset); | 120 | sg_set_page(sg, iv.bv_page, iv.bv_len, iv.bv_offset); |
118 | segments++; | 121 | segments++; |
119 | } | 122 | } |
120 | 123 | ||
124 | prev = 1; | ||
121 | ivprv = iv; | 125 | ivprv = iv; |
122 | } | 126 | } |
123 | 127 | ||