Commit ad7fce93147d32ae53d25d9ea1a8ba31a239deee
Committed by
Jens Axboe
1 parent
0c032ab889
Exists in
master
and in
4 other branches
block: Switch blk_integrity_compare from bdev to gendisk
The DM and MD integrity support now depends on being able to use gendisks instead of block_devices when comparing integrity profiles. Change function parameters accordingly. Also update comparison logic so that two NULL profiles are a valid configuration. Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Showing 2 changed files with 15 additions and 15 deletions Side-by-side Diff
block/blk-integrity.c
... | ... | @@ -108,51 +108,51 @@ |
108 | 108 | EXPORT_SYMBOL(blk_rq_map_integrity_sg); |
109 | 109 | |
110 | 110 | /** |
111 | - * blk_integrity_compare - Compare integrity profile of two block devices | |
112 | - * @bd1: Device to compare | |
113 | - * @bd2: Device to compare | |
111 | + * blk_integrity_compare - Compare integrity profile of two disks | |
112 | + * @gd1: Disk to compare | |
113 | + * @gd2: Disk to compare | |
114 | 114 | * |
115 | 115 | * Description: Meta-devices like DM and MD need to verify that all |
116 | 116 | * sub-devices use the same integrity format before advertising to |
117 | 117 | * upper layers that they can send/receive integrity metadata. This |
118 | - * function can be used to check whether two block devices have | |
118 | + * function can be used to check whether two gendisk devices have | |
119 | 119 | * compatible integrity formats. |
120 | 120 | */ |
121 | -int blk_integrity_compare(struct block_device *bd1, struct block_device *bd2) | |
121 | +int blk_integrity_compare(struct gendisk *gd1, struct gendisk *gd2) | |
122 | 122 | { |
123 | - struct blk_integrity *b1 = bd1->bd_disk->integrity; | |
124 | - struct blk_integrity *b2 = bd2->bd_disk->integrity; | |
123 | + struct blk_integrity *b1 = gd1->integrity; | |
124 | + struct blk_integrity *b2 = gd2->integrity; | |
125 | 125 | |
126 | - BUG_ON(bd1->bd_disk == NULL); | |
127 | - BUG_ON(bd2->bd_disk == NULL); | |
126 | + if (!b1 && !b2) | |
127 | + return 0; | |
128 | 128 | |
129 | 129 | if (!b1 || !b2) |
130 | - return 0; | |
130 | + return -1; | |
131 | 131 | |
132 | 132 | if (b1->sector_size != b2->sector_size) { |
133 | 133 | printk(KERN_ERR "%s: %s/%s sector sz %u != %u\n", __func__, |
134 | - bd1->bd_disk->disk_name, bd2->bd_disk->disk_name, | |
134 | + gd1->disk_name, gd2->disk_name, | |
135 | 135 | b1->sector_size, b2->sector_size); |
136 | 136 | return -1; |
137 | 137 | } |
138 | 138 | |
139 | 139 | if (b1->tuple_size != b2->tuple_size) { |
140 | 140 | printk(KERN_ERR "%s: %s/%s tuple sz %u != %u\n", __func__, |
141 | - bd1->bd_disk->disk_name, bd2->bd_disk->disk_name, | |
141 | + gd1->disk_name, gd2->disk_name, | |
142 | 142 | b1->tuple_size, b2->tuple_size); |
143 | 143 | return -1; |
144 | 144 | } |
145 | 145 | |
146 | 146 | if (b1->tag_size && b2->tag_size && (b1->tag_size != b2->tag_size)) { |
147 | 147 | printk(KERN_ERR "%s: %s/%s tag sz %u != %u\n", __func__, |
148 | - bd1->bd_disk->disk_name, bd2->bd_disk->disk_name, | |
148 | + gd1->disk_name, gd2->disk_name, | |
149 | 149 | b1->tag_size, b2->tag_size); |
150 | 150 | return -1; |
151 | 151 | } |
152 | 152 | |
153 | 153 | if (strcmp(b1->name, b2->name)) { |
154 | 154 | printk(KERN_ERR "%s: %s/%s type %s != %s\n", __func__, |
155 | - bd1->bd_disk->disk_name, bd2->bd_disk->disk_name, | |
155 | + gd1->disk_name, gd2->disk_name, | |
156 | 156 | b1->name, b2->name); |
157 | 157 | return -1; |
158 | 158 | } |
include/linux/blkdev.h
... | ... | @@ -1012,7 +1012,7 @@ |
1012 | 1012 | |
1013 | 1013 | extern int blk_integrity_register(struct gendisk *, struct blk_integrity *); |
1014 | 1014 | extern void blk_integrity_unregister(struct gendisk *); |
1015 | -extern int blk_integrity_compare(struct block_device *, struct block_device *); | |
1015 | +extern int blk_integrity_compare(struct gendisk *, struct gendisk *); | |
1016 | 1016 | extern int blk_rq_map_integrity_sg(struct request *, struct scatterlist *); |
1017 | 1017 | extern int blk_rq_count_integrity_sg(struct request *); |
1018 | 1018 |