block: factor out a blk_integrity_init helper
authorChristoph Hellwig <hch@lst.de>
Thu, 9 Jun 2022 07:33:14 +0000 (09:33 +0200)
committerChristoph Hellwig <hch@lst.de>
Thu, 9 Jun 2022 07:35:30 +0000 (09:35 +0200)
Factor out a helper from blk_integrity_register for all the action
after the blk_integrity field has been filled out.

Signed-off-by: Christoph Hellwig <hch@lst.de>
block/blk-integrity.c
include/linux/blk-integrity.h

index 2a34eeae9c08d8527972d8fb0e1048bc2bb83f25..820ee4c304f99fc818ee388c973e4135d5d01302 100644 (file)
@@ -376,6 +376,20 @@ static const struct blk_integrity_profile nop_profile = {
        .complete_fn = blk_integrity_nop_complete,
 };
 
+void blk_integrity_init(struct gendisk *disk)
+{
+       if (disk->queue->integrity.profile->verify_fn ||
+           disk->queue->integrity.profile->generate_fn)
+               blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, disk->queue);
+
+#ifdef CONFIG_BLK_INLINE_ENCRYPTION
+       if (disk->queue->crypto_profile) {
+               pr_warn("blk-integrity: Integrity and hardware inline encryption are not supported together. Disabling hardware inline encryption.\n");
+               disk->queue->crypto_profile = NULL;
+       }
+#endif
+}
+
 /**
  * blk_integrity_register - Register a gendisk as being integrity-capable
  * @disk:      struct gendisk pointer to make integrity-aware
@@ -398,16 +412,7 @@ void blk_integrity_register(struct gendisk *disk, struct blk_integrity *template
        bi->profile = template->profile ? template->profile : &nop_profile;
        bi->tuple_size = template->tuple_size;
        bi->tag_size = template->tag_size;
-
-       if (bi->profile->verify_fn || bi->profile->generate_fn)
-               blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, disk->queue);
-
-#ifdef CONFIG_BLK_INLINE_ENCRYPTION
-       if (disk->queue->crypto_profile) {
-               pr_warn("blk-integrity: Integrity and hardware inline encryption are not supported together. Disabling hardware inline encryption.\n");
-               disk->queue->crypto_profile = NULL;
-       }
-#endif
+       blk_integrity_init(disk);
 }
 EXPORT_SYMBOL(blk_integrity_register);
 
index 45fb04f9c5481476c87fd95235b1870e3e525cdf..0149efdac878155e4d5f377bd40ad72eb1f7ea3b 100644 (file)
@@ -179,4 +179,7 @@ static inline struct bio_vec *rq_integrity_vec(struct request *rq)
        return NULL;
 }
 #endif /* CONFIG_BLK_DEV_INTEGRITY */
+
+void blk_integrity_init(struct gendisk *disk);
+
 #endif /* _LINUX_BLK_INTEGRITY_H */