aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin K. Petersen <martin.petersen@oracle.com>2008-10-01 03:38:39 -0400
committerJens Axboe <jens.axboe@oracle.com>2008-10-09 02:56:21 -0400
commitad7fce93147d32ae53d25d9ea1a8ba31a239deee (patch)
treebaa8c613c1d34ec247f13b860c3bf7671b07f586
parent0c032ab889e7b20b8a5a7d09313e4aca214a15f7 (diff)
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>
-rw-r--r--block/blk-integrity.c28
-rw-r--r--include/linux/blkdev.h2
2 files changed, 15 insertions, 15 deletions
diff --git a/block/blk-integrity.c b/block/blk-integrity.c
index e3817a016a12..61a8e2f8fdd0 100644
--- a/block/blk-integrity.c
+++ b/block/blk-integrity.c
@@ -108,51 +108,51 @@ new_segment:
108EXPORT_SYMBOL(blk_rq_map_integrity_sg); 108EXPORT_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 * @bd1: Device to compare 112 * @gd1: Disk to compare
113 * @bd2: 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 */
121int blk_integrity_compare(struct block_device *bd1, struct block_device *bd2) 121int 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 }
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index bc693f5c3886..00d340b0f758 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1012,7 +1012,7 @@ struct blk_integrity {
1012 1012
1013extern int blk_integrity_register(struct gendisk *, struct blk_integrity *); 1013extern int blk_integrity_register(struct gendisk *, struct blk_integrity *);
1014extern void blk_integrity_unregister(struct gendisk *); 1014extern void blk_integrity_unregister(struct gendisk *);
1015extern int blk_integrity_compare(struct block_device *, struct block_device *); 1015extern int blk_integrity_compare(struct gendisk *, struct gendisk *);
1016extern int blk_rq_map_integrity_sg(struct request *, struct scatterlist *); 1016extern int blk_rq_map_integrity_sg(struct request *, struct scatterlist *);
1017extern int blk_rq_count_integrity_sg(struct request *); 1017extern int blk_rq_count_integrity_sg(struct request *);
1018 1018