]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
block: move integrity handling out of <linux/blkdev.h>
authorChristoph Hellwig <hch@lst.de>
Mon, 20 Sep 2021 12:33:27 +0000 (14:33 +0200)
committerJens Axboe <axboe@kernel.dk>
Mon, 18 Oct 2021 12:17:02 +0000 (06:17 -0600)
Split the integrity/metadata handling definitions out into a new header.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Link: https://lore.kernel.org/r/20210920123328.1399408-17-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
24 files changed:
block/bdev.c
block/bio-integrity.c
block/blk-core.c
block/blk-integrity.c
block/blk-merge.c
block/blk-mq.c
block/keyslot-manager.c
block/t10-pi.c
drivers/md/dm-bio-record.h
drivers/md/dm-crypt.c
drivers/md/dm-table.c
drivers/md/md.c
drivers/nvdimm/core.c
drivers/nvme/host/core.c
drivers/nvme/host/pci.c
drivers/nvme/host/rdma.c
drivers/nvme/target/io-cmd-bdev.c
drivers/nvme/target/rdma.c
drivers/scsi/scsi_lib.c
drivers/scsi/sd_dif.c
drivers/scsi/virtio_scsi.c
drivers/target/target_core_iblock.c
include/linux/blk-integrity.h [new file with mode: 0644]
include/linux/blkdev.h

index 485a258b0ab37ee7cab7b9e28411dd0032f19830..93b1188d7e58d47f447f0e3c6369aa482fdde559 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/major.h>
 #include <linux/device_cgroup.h>
 #include <linux/blkdev.h>
+#include <linux/blk-integrity.h>
 #include <linux/backing-dev.h>
 #include <linux/module.h>
 #include <linux/blkpg.h>
index 6b47cddbbca175bbf7ce419b00c4b68f138b4d01..21234ff966d9ba370f95915ad08b95b64711a62c 100644 (file)
@@ -6,7 +6,7 @@
  * Written by: Martin K. Petersen <martin.petersen@oracle.com>
  */
 
-#include <linux/blkdev.h>
+#include <linux/blk-integrity.h>
 #include <linux/mempool.h>
 #include <linux/export.h>
 #include <linux/bio.h>
index 4d8f5fe915887e1dc17f4ebe58482293945edddd..d2c6caadef891b84608ea2831999a89b0590676a 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/blkdev.h>
 #include <linux/blk-mq.h>
 #include <linux/blk-pm.h>
+#include <linux/blk-integrity.h>
 #include <linux/highmem.h>
 #include <linux/mm.h>
 #include <linux/pagemap.h>
index 16d5d5338392a22ac6fd41bc93025943b22a7138..cef534a7cbc98c81b186ce8f52b4ae08047cb70d 100644 (file)
@@ -6,7 +6,7 @@
  * Written by: Martin K. Petersen <martin.petersen@oracle.com>
  */
 
-#include <linux/blkdev.h>
+#include <linux/blk-integrity.h>
 #include <linux/backing-dev.h>
 #include <linux/mempool.h>
 #include <linux/bio.h>
index 39f210da399a62c4053c8db2377d4f099351176b..5b4f23014df8a9af80c0969b97d916140e958153 100644 (file)
@@ -6,6 +6,7 @@
 #include <linux/module.h>
 #include <linux/bio.h>
 #include <linux/blkdev.h>
+#include <linux/blk-integrity.h>
 #include <linux/scatterlist.h>
 
 #include <trace/events/block.h>
index 0fefe00cebd4e5d019f702ef5f462cec788b7397..2539ba976949cc525421ff9c3a76a74f8ceaee43 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/backing-dev.h>
 #include <linux/bio.h>
 #include <linux/blkdev.h>
+#include <linux/blk-integrity.h>
 #include <linux/kmemleak.h>
 #include <linux/mm.h>
 #include <linux/init.h>
index 2c4a55bea6ca1e6a4edfbc49154e0f9f52bf86b1..1792159d12d1813869d14ff8859f8f332ee19397 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/wait.h>
 #include <linux/blkdev.h>
+#include <linux/blk-integrity.h>
 
 struct blk_ksm_keyslot {
        atomic_t slot_refs;
index 00c203b2a921e013129a958e997507937f90447a..25a52a2a09a885023b66a54777c262fc1f30b355 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #include <linux/t10-pi.h>
-#include <linux/blkdev.h>
+#include <linux/blk-integrity.h>
 #include <linux/crc-t10dif.h>
 #include <linux/module.h>
 #include <net/checksum.h>
index a3b71350eec84e5210fc976f3a1b048987e9ddd9..745e3ab4aa0af1449852aca186e1a081fb38ab84 100644 (file)
@@ -8,6 +8,7 @@
 #define DM_BIO_RECORD_H
 
 #include <linux/bio.h>
+#include <linux/blk-integrity.h>
 
 /*
  * There are lots of mutable fields in the bio struct that get
index 916b7da16de25ab79080616f61c8a835fce2edf4..292f7896f73332a9c467b25e7dfec7d6dd5b85e3 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/key.h>
 #include <linux/bio.h>
 #include <linux/blkdev.h>
+#include <linux/blk-integrity.h>
 #include <linux/mempool.h>
 #include <linux/slab.h>
 #include <linux/crypto.h>
index 2111daaacabaf9efd133230a056d4b37870d819f..1fa4d5582dca51e2a6e294ecb54ab43138f2f56b 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/module.h>
 #include <linux/vmalloc.h>
 #include <linux/blkdev.h>
+#include <linux/blk-integrity.h>
 #include <linux/namei.h>
 #include <linux/ctype.h>
 #include <linux/string.h>
index 1b9bc8dbd95d784280a1ae8f4e8a34efa4aeafd3..ec09083ff0eff5fe71488a4b6d8123f48108f55d 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/sched/signal.h>
 #include <linux/kthread.h>
 #include <linux/blkdev.h>
+#include <linux/blk-integrity.h>
 #include <linux/badblocks.h>
 #include <linux/sysctl.h>
 #include <linux/seq_file.h>
index 7de592d7eff4587189ca64ad9da6efa87928d66f..6a45fa91e8a3ee22aa1a71244663c821f3cfe2c3 100644 (file)
@@ -7,6 +7,7 @@
 #include <linux/export.h>
 #include <linux/module.h>
 #include <linux/blkdev.h>
+#include <linux/blk-integrity.h>
 #include <linux/device.h>
 #include <linux/ctype.h>
 #include <linux/ndctl.h>
index f8dd664b2eda52f377a1b30e707a5e36b0e6a66d..3d444b13cd697b8515053811d64909da9e2129bf 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <linux/blkdev.h>
 #include <linux/blk-mq.h>
+#include <linux/blk-integrity.h>
 #include <linux/compat.h>
 #include <linux/delay.h>
 #include <linux/errno.h>
index 149ecf73df384b2091a7f22df1308713c2bbd90a..896328271471b2e334de3f887a3b37e6d7464e24 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/blkdev.h>
 #include <linux/blk-mq.h>
 #include <linux/blk-mq-pci.h>
+#include <linux/blk-integrity.h>
 #include <linux/dmi.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
index 042c594bc57e21915363acee1521c473d217a0cb..40317e1b918353913b9b90093e252261ba77d2c7 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/atomic.h>
 #include <linux/blk-mq.h>
 #include <linux/blk-mq-rdma.h>
+#include <linux/blk-integrity.h>
 #include <linux/types.h>
 #include <linux/list.h>
 #include <linux/mutex.h>
index 0fc2781ab97080ebf9dcf1b2b0f1b5787b95ba06..6139e1de50a66e6f082bb112abf08f21ccc2fdb1 100644 (file)
@@ -5,6 +5,7 @@
  */
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 #include <linux/blkdev.h>
+#include <linux/blk-integrity.h>
 #include <linux/module.h>
 #include "nvmet.h"
 
index 891174ccd44bb3cd1a96042313b7e7e79282cb82..38d1f292ecc201264979e277f1d9df8303d071c4 100644 (file)
@@ -5,6 +5,7 @@
  */
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 #include <linux/atomic.h>
+#include <linux/blk-integrity.h>
 #include <linux/ctype.h>
 #include <linux/delay.h>
 #include <linux/err.h>
index 572673873ddf847f10761c4f2c68e69f6d3430f0..33fd9a01330ce4607d7016d31e1a80734e63a752 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/hardirq.h>
 #include <linux/scatterlist.h>
 #include <linux/blk-mq.h>
+#include <linux/blk-integrity.h>
 #include <linux/ratelimit.h>
 #include <asm/unaligned.h>
 
index 4cadb26070a8f5c816220cb1fd96ad0639c7c218..349950616adc504925e39ad3950308f7190d7ab9 100644 (file)
@@ -6,7 +6,7 @@
  * Written by: Martin K. Petersen <martin.petersen@oracle.com>
  */
 
-#include <linux/blkdev.h>
+#include <linux/blk-integrity.h>
 #include <linux/t10-pi.h>
 
 #include <scsi/scsi.h>
index 07d0250f17c3a4a16a28ea5d930ac1df058bc6bf..b8455fcbf18b6cdeb98ed46e7a1292dcc9da62ad 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/virtio_scsi.h>
 #include <linux/cpu.h>
 #include <linux/blkdev.h>
+#include <linux/blk-integrity.h>
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_device.h>
 #include <scsi/scsi_cmnd.h>
index 4069a1edcfa34d8e25162e5062d8e311c743046c..d39b87e2ed100ebe31a474e2d202aaa3364e1bce 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/timer.h>
 #include <linux/fs.h>
 #include <linux/blkdev.h>
+#include <linux/blk-integrity.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/bio.h>
diff --git a/include/linux/blk-integrity.h b/include/linux/blk-integrity.h
new file mode 100644 (file)
index 0000000..8a038ea
--- /dev/null
@@ -0,0 +1,183 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_BLK_INTEGRITY_H
+#define _LINUX_BLK_INTEGRITY_H
+
+#include <linux/blk-mq.h>
+
+struct request;
+
+enum blk_integrity_flags {
+       BLK_INTEGRITY_VERIFY            = 1 << 0,
+       BLK_INTEGRITY_GENERATE          = 1 << 1,
+       BLK_INTEGRITY_DEVICE_CAPABLE    = 1 << 2,
+       BLK_INTEGRITY_IP_CHECKSUM       = 1 << 3,
+};
+
+struct blk_integrity_iter {
+       void                    *prot_buf;
+       void                    *data_buf;
+       sector_t                seed;
+       unsigned int            data_size;
+       unsigned short          interval;
+       const char              *disk_name;
+};
+
+typedef blk_status_t (integrity_processing_fn) (struct blk_integrity_iter *);
+typedef void (integrity_prepare_fn) (struct request *);
+typedef void (integrity_complete_fn) (struct request *, unsigned int);
+
+struct blk_integrity_profile {
+       integrity_processing_fn         *generate_fn;
+       integrity_processing_fn         *verify_fn;
+       integrity_prepare_fn            *prepare_fn;
+       integrity_complete_fn           *complete_fn;
+       const char                      *name;
+};
+
+#ifdef CONFIG_BLK_DEV_INTEGRITY
+void blk_integrity_register(struct gendisk *, struct blk_integrity *);
+void blk_integrity_unregister(struct gendisk *);
+int blk_integrity_compare(struct gendisk *, struct gendisk *);
+int blk_rq_map_integrity_sg(struct request_queue *, struct bio *,
+                                  struct scatterlist *);
+int blk_rq_count_integrity_sg(struct request_queue *, struct bio *);
+
+static inline struct blk_integrity *blk_get_integrity(struct gendisk *disk)
+{
+       struct blk_integrity *bi = &disk->queue->integrity;
+
+       if (!bi->profile)
+               return NULL;
+
+       return bi;
+}
+
+static inline struct blk_integrity *
+bdev_get_integrity(struct block_device *bdev)
+{
+       return blk_get_integrity(bdev->bd_disk);
+}
+
+static inline bool
+blk_integrity_queue_supports_integrity(struct request_queue *q)
+{
+       return q->integrity.profile;
+}
+
+static inline void blk_queue_max_integrity_segments(struct request_queue *q,
+                                                   unsigned int segs)
+{
+       q->limits.max_integrity_segments = segs;
+}
+
+static inline unsigned short
+queue_max_integrity_segments(const struct request_queue *q)
+{
+       return q->limits.max_integrity_segments;
+}
+
+/**
+ * bio_integrity_intervals - Return number of integrity intervals for a bio
+ * @bi:                blk_integrity profile for device
+ * @sectors:   Size of the bio in 512-byte sectors
+ *
+ * Description: The block layer calculates everything in 512 byte
+ * sectors but integrity metadata is done in terms of the data integrity
+ * interval size of the storage device.  Convert the block layer sectors
+ * to the appropriate number of integrity intervals.
+ */
+static inline unsigned int bio_integrity_intervals(struct blk_integrity *bi,
+                                                  unsigned int sectors)
+{
+       return sectors >> (bi->interval_exp - 9);
+}
+
+static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi,
+                                              unsigned int sectors)
+{
+       return bio_integrity_intervals(bi, sectors) * bi->tuple_size;
+}
+
+static inline bool blk_integrity_rq(struct request *rq)
+{
+       return rq->cmd_flags & REQ_INTEGRITY;
+}
+
+/*
+ * Return the first bvec that contains integrity data.  Only drivers that are
+ * limited to a single integrity segment should use this helper.
+ */
+static inline struct bio_vec *rq_integrity_vec(struct request *rq)
+{
+       if (WARN_ON_ONCE(queue_max_integrity_segments(rq->q) > 1))
+               return NULL;
+       return rq->bio->bi_integrity->bip_vec;
+}
+#else /* CONFIG_BLK_DEV_INTEGRITY */
+static inline int blk_rq_count_integrity_sg(struct request_queue *q,
+                                           struct bio *b)
+{
+       return 0;
+}
+static inline int blk_rq_map_integrity_sg(struct request_queue *q,
+                                         struct bio *b,
+                                         struct scatterlist *s)
+{
+       return 0;
+}
+static inline struct blk_integrity *bdev_get_integrity(struct block_device *b)
+{
+       return NULL;
+}
+static inline struct blk_integrity *blk_get_integrity(struct gendisk *disk)
+{
+       return NULL;
+}
+static inline bool
+blk_integrity_queue_supports_integrity(struct request_queue *q)
+{
+       return false;
+}
+static inline int blk_integrity_compare(struct gendisk *a, struct gendisk *b)
+{
+       return 0;
+}
+static inline void blk_integrity_register(struct gendisk *d,
+                                        struct blk_integrity *b)
+{
+}
+static inline void blk_integrity_unregister(struct gendisk *d)
+{
+}
+static inline void blk_queue_max_integrity_segments(struct request_queue *q,
+                                                   unsigned int segs)
+{
+}
+static inline unsigned short
+queue_max_integrity_segments(const struct request_queue *q)
+{
+       return 0;
+}
+
+static inline unsigned int bio_integrity_intervals(struct blk_integrity *bi,
+                                                  unsigned int sectors)
+{
+       return 0;
+}
+
+static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi,
+                                              unsigned int sectors)
+{
+       return 0;
+}
+static inline int blk_integrity_rq(struct request *rq)
+{
+       return 0;
+}
+
+static inline struct bio_vec *rq_integrity_vec(struct request *rq)
+{
+       return NULL;
+}
+#endif /* CONFIG_BLK_DEV_INTEGRITY */
+#endif /* _LINUX_BLK_INTEGRITY_H */
index be534040ca9c3b83099b3cdc71a241d66a2a6c9b..56e60e5c09d07d7c9c11462b69e3d39e7921efa0 100644 (file)
@@ -1555,189 +1555,6 @@ int kblockd_mod_delayed_work_on(int cpu, struct delayed_work *dwork, unsigned lo
 #define MODULE_ALIAS_BLOCKDEV_MAJOR(major) \
        MODULE_ALIAS("block-major-" __stringify(major) "-*")
 
-#if defined(CONFIG_BLK_DEV_INTEGRITY)
-
-enum blk_integrity_flags {
-       BLK_INTEGRITY_VERIFY            = 1 << 0,
-       BLK_INTEGRITY_GENERATE          = 1 << 1,
-       BLK_INTEGRITY_DEVICE_CAPABLE    = 1 << 2,
-       BLK_INTEGRITY_IP_CHECKSUM       = 1 << 3,
-};
-
-struct blk_integrity_iter {
-       void                    *prot_buf;
-       void                    *data_buf;
-       sector_t                seed;
-       unsigned int            data_size;
-       unsigned short          interval;
-       const char              *disk_name;
-};
-
-typedef blk_status_t (integrity_processing_fn) (struct blk_integrity_iter *);
-typedef void (integrity_prepare_fn) (struct request *);
-typedef void (integrity_complete_fn) (struct request *, unsigned int);
-
-struct blk_integrity_profile {
-       integrity_processing_fn         *generate_fn;
-       integrity_processing_fn         *verify_fn;
-       integrity_prepare_fn            *prepare_fn;
-       integrity_complete_fn           *complete_fn;
-       const char                      *name;
-};
-
-extern void blk_integrity_register(struct gendisk *, struct blk_integrity *);
-extern void blk_integrity_unregister(struct gendisk *);
-extern int blk_integrity_compare(struct gendisk *, struct gendisk *);
-extern int blk_rq_map_integrity_sg(struct request_queue *, struct bio *,
-                                  struct scatterlist *);
-extern int blk_rq_count_integrity_sg(struct request_queue *, struct bio *);
-
-static inline struct blk_integrity *blk_get_integrity(struct gendisk *disk)
-{
-       struct blk_integrity *bi = &disk->queue->integrity;
-
-       if (!bi->profile)
-               return NULL;
-
-       return bi;
-}
-
-static inline
-struct blk_integrity *bdev_get_integrity(struct block_device *bdev)
-{
-       return blk_get_integrity(bdev->bd_disk);
-}
-
-static inline bool
-blk_integrity_queue_supports_integrity(struct request_queue *q)
-{
-       return q->integrity.profile;
-}
-
-static inline bool blk_integrity_rq(struct request *rq)
-{
-       return rq->cmd_flags & REQ_INTEGRITY;
-}
-
-static inline void blk_queue_max_integrity_segments(struct request_queue *q,
-                                                   unsigned int segs)
-{
-       q->limits.max_integrity_segments = segs;
-}
-
-static inline unsigned short
-queue_max_integrity_segments(const struct request_queue *q)
-{
-       return q->limits.max_integrity_segments;
-}
-
-/**
- * bio_integrity_intervals - Return number of integrity intervals for a bio
- * @bi:                blk_integrity profile for device
- * @sectors:   Size of the bio in 512-byte sectors
- *
- * Description: The block layer calculates everything in 512 byte
- * sectors but integrity metadata is done in terms of the data integrity
- * interval size of the storage device.  Convert the block layer sectors
- * to the appropriate number of integrity intervals.
- */
-static inline unsigned int bio_integrity_intervals(struct blk_integrity *bi,
-                                                  unsigned int sectors)
-{
-       return sectors >> (bi->interval_exp - 9);
-}
-
-static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi,
-                                              unsigned int sectors)
-{
-       return bio_integrity_intervals(bi, sectors) * bi->tuple_size;
-}
-
-/*
- * Return the first bvec that contains integrity data.  Only drivers that are
- * limited to a single integrity segment should use this helper.
- */
-static inline struct bio_vec *rq_integrity_vec(struct request *rq)
-{
-       if (WARN_ON_ONCE(queue_max_integrity_segments(rq->q) > 1))
-               return NULL;
-       return rq->bio->bi_integrity->bip_vec;
-}
-
-#else /* CONFIG_BLK_DEV_INTEGRITY */
-
-struct bio;
-struct block_device;
-struct gendisk;
-struct blk_integrity;
-
-static inline int blk_integrity_rq(struct request *rq)
-{
-       return 0;
-}
-static inline int blk_rq_count_integrity_sg(struct request_queue *q,
-                                           struct bio *b)
-{
-       return 0;
-}
-static inline int blk_rq_map_integrity_sg(struct request_queue *q,
-                                         struct bio *b,
-                                         struct scatterlist *s)
-{
-       return 0;
-}
-static inline struct blk_integrity *bdev_get_integrity(struct block_device *b)
-{
-       return NULL;
-}
-static inline struct blk_integrity *blk_get_integrity(struct gendisk *disk)
-{
-       return NULL;
-}
-static inline bool
-blk_integrity_queue_supports_integrity(struct request_queue *q)
-{
-       return false;
-}
-static inline int blk_integrity_compare(struct gendisk *a, struct gendisk *b)
-{
-       return 0;
-}
-static inline void blk_integrity_register(struct gendisk *d,
-                                        struct blk_integrity *b)
-{
-}
-static inline void blk_integrity_unregister(struct gendisk *d)
-{
-}
-static inline void blk_queue_max_integrity_segments(struct request_queue *q,
-                                                   unsigned int segs)
-{
-}
-static inline unsigned short queue_max_integrity_segments(const struct request_queue *q)
-{
-       return 0;
-}
-
-static inline unsigned int bio_integrity_intervals(struct blk_integrity *bi,
-                                                  unsigned int sectors)
-{
-       return 0;
-}
-
-static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi,
-                                              unsigned int sectors)
-{
-       return 0;
-}
-
-static inline struct bio_vec *rq_integrity_vec(struct request *rq)
-{
-       return NULL;
-}
-
-#endif /* CONFIG_BLK_DEV_INTEGRITY */
-
 #ifdef CONFIG_BLK_INLINE_ENCRYPTION
 
 bool blk_ksm_register(struct blk_keyslot_manager *ksm, struct request_queue *q);