~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/blk-integrity.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #ifndef _LINUX_BLK_INTEGRITY_H
  3 #define _LINUX_BLK_INTEGRITY_H
  4 
  5 #include <linux/blk-mq.h>
  6 #include <linux/bio-integrity.h>
  7 
  8 struct request;
  9 
 10 enum blk_integrity_flags {
 11         BLK_INTEGRITY_NOVERIFY          = 1 << 0,
 12         BLK_INTEGRITY_NOGENERATE        = 1 << 1,
 13         BLK_INTEGRITY_DEVICE_CAPABLE    = 1 << 2,
 14         BLK_INTEGRITY_REF_TAG           = 1 << 3,
 15         BLK_INTEGRITY_STACKED           = 1 << 4,
 16 };
 17 
 18 const char *blk_integrity_profile_name(struct blk_integrity *bi);
 19 bool queue_limits_stack_integrity(struct queue_limits *t,
 20                 struct queue_limits *b);
 21 static inline bool queue_limits_stack_integrity_bdev(struct queue_limits *t,
 22                 struct block_device *bdev)
 23 {
 24         return queue_limits_stack_integrity(t, &bdev->bd_disk->queue->limits);
 25 }
 26 
 27 #ifdef CONFIG_BLK_DEV_INTEGRITY
 28 int blk_rq_map_integrity_sg(struct request_queue *, struct bio *,
 29                                    struct scatterlist *);
 30 int blk_rq_count_integrity_sg(struct request_queue *, struct bio *);
 31 
 32 static inline bool
 33 blk_integrity_queue_supports_integrity(struct request_queue *q)
 34 {
 35         return q->limits.integrity.tuple_size;
 36 }
 37 
 38 static inline struct blk_integrity *blk_get_integrity(struct gendisk *disk)
 39 {
 40         if (!blk_integrity_queue_supports_integrity(disk->queue))
 41                 return NULL;
 42         return &disk->queue->limits.integrity;
 43 }
 44 
 45 static inline struct blk_integrity *
 46 bdev_get_integrity(struct block_device *bdev)
 47 {
 48         return blk_get_integrity(bdev->bd_disk);
 49 }
 50 
 51 static inline unsigned short
 52 queue_max_integrity_segments(const struct request_queue *q)
 53 {
 54         return q->limits.max_integrity_segments;
 55 }
 56 
 57 /**
 58  * bio_integrity_intervals - Return number of integrity intervals for a bio
 59  * @bi:         blk_integrity profile for device
 60  * @sectors:    Size of the bio in 512-byte sectors
 61  *
 62  * Description: The block layer calculates everything in 512 byte
 63  * sectors but integrity metadata is done in terms of the data integrity
 64  * interval size of the storage device.  Convert the block layer sectors
 65  * to the appropriate number of integrity intervals.
 66  */
 67 static inline unsigned int bio_integrity_intervals(struct blk_integrity *bi,
 68                                                    unsigned int sectors)
 69 {
 70         return sectors >> (bi->interval_exp - 9);
 71 }
 72 
 73 static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi,
 74                                                unsigned int sectors)
 75 {
 76         return bio_integrity_intervals(bi, sectors) * bi->tuple_size;
 77 }
 78 
 79 static inline bool blk_integrity_rq(struct request *rq)
 80 {
 81         return rq->cmd_flags & REQ_INTEGRITY;
 82 }
 83 
 84 /*
 85  * Return the current bvec that contains the integrity data. bip_iter may be
 86  * advanced to iterate over the integrity data.
 87  */
 88 static inline struct bio_vec rq_integrity_vec(struct request *rq)
 89 {
 90         return mp_bvec_iter_bvec(rq->bio->bi_integrity->bip_vec,
 91                                  rq->bio->bi_integrity->bip_iter);
 92 }
 93 #else /* CONFIG_BLK_DEV_INTEGRITY */
 94 static inline int blk_rq_count_integrity_sg(struct request_queue *q,
 95                                             struct bio *b)
 96 {
 97         return 0;
 98 }
 99 static inline int blk_rq_map_integrity_sg(struct request_queue *q,
100                                           struct bio *b,
101                                           struct scatterlist *s)
102 {
103         return 0;
104 }
105 static inline struct blk_integrity *bdev_get_integrity(struct block_device *b)
106 {
107         return NULL;
108 }
109 static inline struct blk_integrity *blk_get_integrity(struct gendisk *disk)
110 {
111         return NULL;
112 }
113 static inline bool
114 blk_integrity_queue_supports_integrity(struct request_queue *q)
115 {
116         return false;
117 }
118 static inline unsigned short
119 queue_max_integrity_segments(const struct request_queue *q)
120 {
121         return 0;
122 }
123 
124 static inline unsigned int bio_integrity_intervals(struct blk_integrity *bi,
125                                                    unsigned int sectors)
126 {
127         return 0;
128 }
129 
130 static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi,
131                                                unsigned int sectors)
132 {
133         return 0;
134 }
135 static inline int blk_integrity_rq(struct request *rq)
136 {
137         return 0;
138 }
139 
140 static inline struct bio_vec rq_integrity_vec(struct request *rq)
141 {
142         /* the optimizer will remove all calls to this function */
143         return (struct bio_vec){ };
144 }
145 #endif /* CONFIG_BLK_DEV_INTEGRITY */
146 
147 #endif /* _LINUX_BLK_INTEGRITY_H */
148 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php