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

TOMOYO Linux Cross Reference
Linux/include/linux/bio-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_BIO_INTEGRITY_H
  3 #define _LINUX_BIO_INTEGRITY_H
  4 
  5 #include <linux/bio.h>
  6 
  7 enum bip_flags {
  8         BIP_BLOCK_INTEGRITY     = 1 << 0, /* block layer owns integrity data */
  9         BIP_MAPPED_INTEGRITY    = 1 << 1, /* ref tag has been remapped */
 10         BIP_CTRL_NOCHECK        = 1 << 2, /* disable HBA integrity checking */
 11         BIP_DISK_NOCHECK        = 1 << 3, /* disable disk integrity checking */
 12         BIP_IP_CHECKSUM         = 1 << 4, /* IP checksum */
 13         BIP_COPY_USER           = 1 << 5, /* Kernel bounce buffer in use */
 14 };
 15 
 16 struct bio_integrity_payload {
 17         struct bio              *bip_bio;       /* parent bio */
 18 
 19         struct bvec_iter        bip_iter;
 20 
 21         unsigned short          bip_vcnt;       /* # of integrity bio_vecs */
 22         unsigned short          bip_max_vcnt;   /* integrity bio_vec slots */
 23         unsigned short          bip_flags;      /* control flags */
 24 
 25         struct bvec_iter        bio_iter;       /* for rewinding parent bio */
 26 
 27         struct work_struct      bip_work;       /* I/O completion */
 28 
 29         struct bio_vec          *bip_vec;
 30         struct bio_vec          bip_inline_vecs[];/* embedded bvec array */
 31 };
 32 
 33 #ifdef CONFIG_BLK_DEV_INTEGRITY
 34 
 35 #define bip_for_each_vec(bvl, bip, iter)                                \
 36         for_each_bvec(bvl, (bip)->bip_vec, iter, (bip)->bip_iter)
 37 
 38 #define bio_for_each_integrity_vec(_bvl, _bio, _iter)                   \
 39         for_each_bio(_bio)                                              \
 40                 bip_for_each_vec(_bvl, _bio->bi_integrity, _iter)
 41 
 42 static inline struct bio_integrity_payload *bio_integrity(struct bio *bio)
 43 {
 44         if (bio->bi_opf & REQ_INTEGRITY)
 45                 return bio->bi_integrity;
 46 
 47         return NULL;
 48 }
 49 
 50 static inline bool bio_integrity_flagged(struct bio *bio, enum bip_flags flag)
 51 {
 52         struct bio_integrity_payload *bip = bio_integrity(bio);
 53 
 54         if (bip)
 55                 return bip->bip_flags & flag;
 56 
 57         return false;
 58 }
 59 
 60 static inline sector_t bip_get_seed(struct bio_integrity_payload *bip)
 61 {
 62         return bip->bip_iter.bi_sector;
 63 }
 64 
 65 static inline void bip_set_seed(struct bio_integrity_payload *bip,
 66                                 sector_t seed)
 67 {
 68         bip->bip_iter.bi_sector = seed;
 69 }
 70 
 71 struct bio_integrity_payload *bio_integrity_alloc(struct bio *bio, gfp_t gfp,
 72                 unsigned int nr);
 73 int bio_integrity_add_page(struct bio *bio, struct page *page, unsigned int len,
 74                 unsigned int offset);
 75 int bio_integrity_map_user(struct bio *bio, void __user *ubuf, ssize_t len, u32 seed);
 76 void bio_integrity_unmap_user(struct bio *bio);
 77 bool bio_integrity_prep(struct bio *bio);
 78 void bio_integrity_advance(struct bio *bio, unsigned int bytes_done);
 79 void bio_integrity_trim(struct bio *bio);
 80 int bio_integrity_clone(struct bio *bio, struct bio *bio_src, gfp_t gfp_mask);
 81 int bioset_integrity_create(struct bio_set *bs, int pool_size);
 82 void bioset_integrity_free(struct bio_set *bs);
 83 void bio_integrity_init(void);
 84 
 85 #else /* CONFIG_BLK_DEV_INTEGRITY */
 86 
 87 static inline struct bio_integrity_payload *bio_integrity(struct bio *bio)
 88 {
 89         return NULL;
 90 }
 91 
 92 static inline int bioset_integrity_create(struct bio_set *bs, int pool_size)
 93 {
 94         return 0;
 95 }
 96 
 97 static inline void bioset_integrity_free(struct bio_set *bs)
 98 {
 99 }
100 
101 static inline int bio_integrity_map_user(struct bio *bio, void __user *ubuf,
102                                          ssize_t len, u32 seed)
103 {
104         return -EINVAL;
105 }
106 
107 static inline void bio_integrity_unmap_user(struct bio *bio)
108 {
109 }
110 
111 static inline bool bio_integrity_prep(struct bio *bio)
112 {
113         return true;
114 }
115 
116 static inline int bio_integrity_clone(struct bio *bio, struct bio *bio_src,
117                 gfp_t gfp_mask)
118 {
119         return 0;
120 }
121 
122 static inline void bio_integrity_advance(struct bio *bio,
123                 unsigned int bytes_done)
124 {
125 }
126 
127 static inline void bio_integrity_trim(struct bio *bio)
128 {
129 }
130 
131 static inline void bio_integrity_init(void)
132 {
133 }
134 
135 static inline bool bio_integrity_flagged(struct bio *bio, enum bip_flags flag)
136 {
137         return false;
138 }
139 
140 static inline struct bio_integrity_payload *
141 bio_integrity_alloc(struct bio *bio, gfp_t gfp, unsigned int nr)
142 {
143         return ERR_PTR(-EINVAL);
144 }
145 
146 static inline int bio_integrity_add_page(struct bio *bio, struct page *page,
147                                         unsigned int len, unsigned int offset)
148 {
149         return 0;
150 }
151 #endif /* CONFIG_BLK_DEV_INTEGRITY */
152 #endif /* _LINUX_BIO_INTEGRITY_H */
153 

~ [ 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