blk-flush: fix invalid BUG_ON in blk_insert_flush
[linux-2.6.git] / block / blk-integrity.c
index 885cbb5..129b9e2 100644 (file)
@@ -30,6 +30,8 @@
 
 static struct kmem_cache *integrity_cachep;
 
+static const char *bi_unsupported_name = "unsupported";
+
 /**
  * blk_rq_count_integrity_sg - Count number of integrity scatterlist elements
  * @q:         request queue
@@ -358,6 +360,14 @@ static struct kobj_type integrity_ktype = {
        .release        = blk_integrity_release,
 };
 
+bool blk_integrity_is_initialized(struct gendisk *disk)
+{
+       struct blk_integrity *bi = blk_get_integrity(disk);
+
+       return (bi && bi->name && strcmp(bi->name, bi_unsupported_name) != 0);
+}
+EXPORT_SYMBOL(blk_integrity_is_initialized);
+
 /**
  * blk_integrity_register - Register a gendisk as being integrity-capable
  * @disk:      struct gendisk pointer to make integrity-aware
@@ -407,7 +417,7 @@ int blk_integrity_register(struct gendisk *disk, struct blk_integrity *template)
                bi->get_tag_fn = template->get_tag_fn;
                bi->tag_size = template->tag_size;
        } else
-               bi->name = "unsupported";
+               bi->name = bi_unsupported_name;
 
        return 0;
 }
@@ -432,7 +442,6 @@ void blk_integrity_unregister(struct gendisk *disk)
        kobject_uevent(&bi->kobj, KOBJ_REMOVE);
        kobject_del(&bi->kobj);
        kobject_put(&bi->kobj);
-       kmem_cache_free(integrity_cachep, bi);
        disk->integrity = NULL;
 }
 EXPORT_SYMBOL(blk_integrity_unregister);