diff options
Diffstat (limited to 'block/blk-integrity.c')
-rw-r--r-- | block/blk-integrity.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/block/blk-integrity.c b/block/blk-integrity.c index 3f1a8478cc38..61a8e2f8fdd0 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c | |||
@@ -108,51 +108,51 @@ new_segment: | |||
108 | EXPORT_SYMBOL(blk_rq_map_integrity_sg); | 108 | EXPORT_SYMBOL(blk_rq_map_integrity_sg); |
109 | 109 | ||
110 | /** | 110 | /** |
111 | * blk_integrity_compare - Compare integrity profile of two block devices | 111 | * blk_integrity_compare - Compare integrity profile of two disks |
112 | * @b1: Device to compare | 112 | * @gd1: Disk to compare |
113 | * @b2: Device to compare | 113 | * @gd2: Disk to compare |
114 | * | 114 | * |
115 | * Description: Meta-devices like DM and MD need to verify that all | 115 | * Description: Meta-devices like DM and MD need to verify that all |
116 | * sub-devices use the same integrity format before advertising to | 116 | * sub-devices use the same integrity format before advertising to |
117 | * upper layers that they can send/receive integrity metadata. This | 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 | * compatible integrity formats. | 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; | 123 | struct blk_integrity *b1 = gd1->integrity; |
124 | struct blk_integrity *b2 = bd2->bd_disk->integrity; | 124 | struct blk_integrity *b2 = gd2->integrity; |
125 | 125 | ||
126 | BUG_ON(bd1->bd_disk == NULL); | 126 | if (!b1 && !b2) |
127 | BUG_ON(bd2->bd_disk == NULL); | 127 | return 0; |
128 | 128 | ||
129 | if (!b1 || !b2) | 129 | if (!b1 || !b2) |
130 | return 0; | 130 | return -1; |
131 | 131 | ||
132 | if (b1->sector_size != b2->sector_size) { | 132 | if (b1->sector_size != b2->sector_size) { |
133 | printk(KERN_ERR "%s: %s/%s sector sz %u != %u\n", __func__, | 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 | b1->sector_size, b2->sector_size); | 135 | b1->sector_size, b2->sector_size); |
136 | return -1; | 136 | return -1; |
137 | } | 137 | } |
138 | 138 | ||
139 | if (b1->tuple_size != b2->tuple_size) { | 139 | if (b1->tuple_size != b2->tuple_size) { |
140 | printk(KERN_ERR "%s: %s/%s tuple sz %u != %u\n", __func__, | 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 | b1->tuple_size, b2->tuple_size); | 142 | b1->tuple_size, b2->tuple_size); |
143 | return -1; | 143 | return -1; |
144 | } | 144 | } |
145 | 145 | ||
146 | if (b1->tag_size && b2->tag_size && (b1->tag_size != b2->tag_size)) { | 146 | if (b1->tag_size && b2->tag_size && (b1->tag_size != b2->tag_size)) { |
147 | printk(KERN_ERR "%s: %s/%s tag sz %u != %u\n", __func__, | 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 | b1->tag_size, b2->tag_size); | 149 | b1->tag_size, b2->tag_size); |
150 | return -1; | 150 | return -1; |
151 | } | 151 | } |
152 | 152 | ||
153 | if (strcmp(b1->name, b2->name)) { | 153 | if (strcmp(b1->name, b2->name)) { |
154 | printk(KERN_ERR "%s: %s/%s type %s != %s\n", __func__, | 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 | b1->name, b2->name); | 156 | b1->name, b2->name); |
157 | return -1; | 157 | return -1; |
158 | } | 158 | } |
@@ -331,7 +331,8 @@ int blk_integrity_register(struct gendisk *disk, struct blk_integrity *template) | |||
331 | return -1; | 331 | return -1; |
332 | 332 | ||
333 | if (kobject_init_and_add(&bi->kobj, &integrity_ktype, | 333 | if (kobject_init_and_add(&bi->kobj, &integrity_ktype, |
334 | &disk->dev.kobj, "%s", "integrity")) { | 334 | &disk_to_dev(disk)->kobj, |
335 | "%s", "integrity")) { | ||
335 | kmem_cache_free(integrity_cachep, bi); | 336 | kmem_cache_free(integrity_cachep, bi); |
336 | return -1; | 337 | return -1; |
337 | } | 338 | } |
@@ -375,7 +376,7 @@ void blk_integrity_unregister(struct gendisk *disk) | |||
375 | 376 | ||
376 | kobject_uevent(&bi->kobj, KOBJ_REMOVE); | 377 | kobject_uevent(&bi->kobj, KOBJ_REMOVE); |
377 | kobject_del(&bi->kobj); | 378 | kobject_del(&bi->kobj); |
378 | kobject_put(&disk->dev.kobj); | ||
379 | kmem_cache_free(integrity_cachep, bi); | 379 | kmem_cache_free(integrity_cachep, bi); |
380 | disk->integrity = NULL; | ||
380 | } | 381 | } |
381 | EXPORT_SYMBOL(blk_integrity_unregister); | 382 | EXPORT_SYMBOL(blk_integrity_unregister); |