History

block: split struct bio_integrity_payload

Many of the fields in struct bio_integrity_payload are only needed for the default integrity buffer in the block layer, and the variable sized array at the end of the structure makes it very hard to embed into caller allocated structures. Reduce struct bio_integrity_payload to the minimal structure needed in common code and create two separate containing structures for the automatically generated payload and the caller allocated payload. The latter is a simple wrapper for struct bio_integrity_payload and the bvecs, while the former contains the additional fields moved out of struct bio_integrity_payload. Always use a dedicated mempool for automatic integrity metadata instead of depending on bio_set that is submitter controlled and thus often doesn't have the mempool initialized and stop using mempools for the submitter buffers as they aren't in the NOIO I/O submission path where we need to guarantee forward progress.

Christoph Hellwig committed 1 year ago

Commit 105ca2a1 parent e51679111 files · +80 −188Browse files

Unified · Split

11 files
  1. block/bio-integrity-auto.c +52 −23
  2. block/bio-integrity.c +22 −85
  3. block/bio.c +0 −6
  4. block/blk.h +1 −1
  5. block/t10-pi.c +3 −3
  6. drivers/md/dm-integrity.c +0 −12
  7. drivers/md/dm-table.c +0 −6
  8. drivers/md/md.c +0 −13
  9. drivers/target/target_core_iblock.c +0 −12
  10. include/linux/bio-integrity.h +2 −23
  11. include/linux/bio.h +0 −4
block/bio-integrity-auto.c+52−23
@@ -12,18 +12,34 @@ · 11 unmodified lines
12#include <linux/workqueue.h>12#include <linux/workqueue.h>
13#include "blk.h"13#include "blk.h"
14 14
15struct bio_integrity_data {
16 struct bio *bio;
17 struct bvec_iter saved_bio_iter;
18 struct work_struct work;
19 struct bio_integrity_payload bip;
20 struct bio_vec bvec;
21};
22
23static struct kmem_cache *bid_slab;
24static mempool_t bid_pool;
15static struct workqueue_struct *kintegrityd_wq;25static struct workqueue_struct *kintegrityd_wq;
16 26
17static void bio_integrity_verify_fn(struct work_struct *work)27static void bio_integrity_finish(struct bio_integrity_data *bid)
18{28{
19 struct bio_integrity_payload *bip =29 bid->bio->bi_integrity = NULL;
20 container_of(work, struct bio_integrity_payload, bip_work);30 bid->bio->bi_opf &= ~REQ_INTEGRITY;
21 struct bio *bio = bip->bip_bio;31 kfree(bvec_virt(bid->bip.bip_vec));
32 mempool_free(bid, &bid_pool);
33}
22 34
23 blk_integrity_verify(bio);35static void bio_integrity_verify_fn(struct work_struct *work)
36{
37 struct bio_integrity_data *bid =
38 container_of(work, struct bio_integrity_data, work);
39 struct bio *bio = bid->bio;
24 40
25 kfree(bvec_virt(bip->bip_vec));41 blk_integrity_verify_iter(bio, &bid->saved_bio_iter);
26 bio_integrity_free(bio);42 bio_integrity_finish(bid);
27 bio_endio(bio);43 bio_endio(bio);
28}44}
29 45
@@ -40,15 +56,16 @@ bool __bio_integrity_endio(struct bio *bio) · 10 unmodified lines
40{56{
41 struct blk_integrity *bi = blk_get_integrity(bio->bi_bdev->bd_disk);57 struct blk_integrity *bi = blk_get_integrity(bio->bi_bdev->bd_disk);
42 struct bio_integrity_payload *bip = bio_integrity(bio);58 struct bio_integrity_payload *bip = bio_integrity(bio);
59 struct bio_integrity_data *bid =
60 container_of(bip, struct bio_integrity_data, bip);
43 61
44 if (bio_op(bio) == REQ_OP_READ && !bio->bi_status && bi->csum_type) {62 if (bio_op(bio) == REQ_OP_READ && !bio->bi_status && bi->csum_type) {
45 INIT_WORK(&bip->bip_work, bio_integrity_verify_fn);63 INIT_WORK(&bid->work, bio_integrity_verify_fn);
46 queue_work(kintegrityd_wq, &bip->bip_work);64 queue_work(kintegrityd_wq, &bid->work);
47 return false;65 return false;
48 }66 }
49 67
50 kfree(bvec_virt(bip->bip_vec));68 bio_integrity_finish(bid);
51 bio_integrity_free(bio);
52 return true;69 return true;
53}70}
54 71
@@ -65,8 +82,8 @@ bool __bio_integrity_endio(struct bio *bio) · 10 unmodified lines
65 */82 */
66bool bio_integrity_prep(struct bio *bio)83bool bio_integrity_prep(struct bio *bio)
67{84{
68 struct bio_integrity_payload *bip;
69 struct blk_integrity *bi = blk_get_integrity(bio->bi_bdev->bd_disk);85 struct blk_integrity *bi = blk_get_integrity(bio->bi_bdev->bd_disk);
86 struct bio_integrity_data *bid;
70 gfp_t gfp = GFP_NOIO;87 gfp_t gfp = GFP_NOIO;
71 unsigned int len;88 unsigned int len;
72 void *buf;89 void *buf;
@@ -102,27 +119,30 @@ bool bio_integrity_prep(struct bio *bio) · 29 unmodified lines
102 return true;119 return true;
103 }120 }
104 121
122 if (WARN_ON_ONCE(bio_has_crypt_ctx(bio)))
123 return true;
124
105 /* Allocate kernel buffer for protection data */125 /* Allocate kernel buffer for protection data */
106 len = bio_integrity_bytes(bi, bio_sectors(bio));126 len = bio_integrity_bytes(bi, bio_sectors(bio));
107 buf = kmalloc(len, gfp);127 buf = kmalloc(len, gfp);
108 if (!buf)128 if (!buf)
109 goto err_end_io;129 goto err_end_io;
130 bid = mempool_alloc(&bid_pool, GFP_NOIO);
131 if (!bid)
132 goto err_free_buf;
133 bio_integrity_init(bio, &bid->bip, &bid->bvec, 1);
110 134
111 bip = bio_integrity_alloc(bio, GFP_NOIO, 1);135 bid->bio = bio;
112 if (IS_ERR(bip)) {
113 kfree(buf);
114 goto err_end_io;
115 }
116 136
117 bip->bip_flags |= BIP_BLOCK_INTEGRITY;137 bid->bip.bip_flags |= BIP_BLOCK_INTEGRITY;
118 bip_set_seed(bip, bio->bi_iter.bi_sector);138 bip_set_seed(&bid->bip, bio->bi_iter.bi_sector);
119 139
120 if (bi->csum_type == BLK_INTEGRITY_CSUM_IP)140 if (bi->csum_type == BLK_INTEGRITY_CSUM_IP)
121 bip->bip_flags |= BIP_IP_CHECKSUM;141 bid->bip.bip_flags |= BIP_IP_CHECKSUM;
122 if (bi->csum_type)142 if (bi->csum_type)
123 bip->bip_flags |= BIP_CHECK_GUARD;143 bid->bip.bip_flags |= BIP_CHECK_GUARD;
124 if (bi->flags & BLK_INTEGRITY_REF_TAG)144 if (bi->flags & BLK_INTEGRITY_REF_TAG)
125 bip->bip_flags |= BIP_CHECK_REFTAG;145 bid->bip.bip_flags |= BIP_CHECK_REFTAG;
126 146
127 if (bio_integrity_add_page(bio, virt_to_page(buf), len,147 if (bio_integrity_add_page(bio, virt_to_page(buf), len,
128 offset_in_page(buf)) < len)148 offset_in_page(buf)) < len)
@@ -132,9 +152,11 @@ bool bio_integrity_prep(struct bio *bio) · 3 unmodified lines
132 if (bio_data_dir(bio) == WRITE)152 if (bio_data_dir(bio) == WRITE)
133 blk_integrity_generate(bio);153 blk_integrity_generate(bio);
134 else154 else
135 bip->bio_iter = bio->bi_iter;155 bid->saved_bio_iter = bio->bi_iter;
136 return true;156 return true;
137 157
158err_free_buf:
159 kfree(buf);
138err_end_io:160err_end_io:
139 bio->bi_status = BLK_STS_RESOURCE;161 bio->bi_status = BLK_STS_RESOURCE;
140 bio_endio(bio);162 bio_endio(bio);
@@ -149,6 +171,13 @@ void blk_flush_integrity(void) · 8 unmodified lines
149 171
150static int __init blk_integrity_auto_init(void)172static int __init blk_integrity_auto_init(void)
151{173{
174 bid_slab = kmem_cache_create("bio_integrity_data",
175 sizeof(struct bio_integrity_data), 0,
176 SLAB_HWCACHE_ALIGN | SLAB_PANIC, NULL);
177
178 if (mempool_init_slab_pool(&bid_pool, BIO_POOL_SIZE, bid_slab))
179 panic("bio: can't create integrity pool\n");
180
152 /*181 /*
153 * kintegrityd won't block much but may burn a lot of CPU cycles.182 * kintegrityd won't block much but may burn a lot of CPU cycles.
154 * Make it highpri CPU intensive wq with max concurrency of 1.183 * Make it highpri CPU intensive wq with max concurrency of 1.
block/bio-integrity.c+22−85
@@ -7,13 +7,12 @@ · 6 unmodified lines
7 */7 */
8 8
9#include <linux/blk-integrity.h>9#include <linux/blk-integrity.h>
10#include <linux/mempool.h>
11#include <linux/export.h>
12#include <linux/bio.h>
13#include <linux/slab.h>
14#include "blk.h"10#include "blk.h"
15 11
16static struct kmem_cache *bip_slab;12struct bio_integrity_alloc {
13 struct bio_integrity_payload bip;
14 struct bio_vec bvecs[];
15};
17 16
18/**17/**
19 * bio_integrity_free - Free bio integrity payload18 * bio_integrity_free - Free bio integrity payload
@@ -23,21 +22,23 @@ static struct kmem_cache *bip_slab; · 3 unmodified lines
23 */22 */
24void bio_integrity_free(struct bio *bio)23void bio_integrity_free(struct bio *bio)
25{24{
26 struct bio_integrity_payload *bip = bio_integrity(bio);25 kfree(bio_integrity(bio));
27 struct bio_set *bs = bio->bi_pool;
28
29 if (bs && mempool_initialized(&bs->bio_integrity_pool)) {
30 if (bip->bip_vec)
31 bvec_free(&bs->bvec_integrity_pool, bip->bip_vec,
32 bip->bip_max_vcnt);
33 mempool_free(bip, &bs->bio_integrity_pool);
34 } else {
35 kfree(bip);
36 }
37 bio->bi_integrity = NULL;26 bio->bi_integrity = NULL;
38 bio->bi_opf &= ~REQ_INTEGRITY;27 bio->bi_opf &= ~REQ_INTEGRITY;
39}28}
40 29
30void bio_integrity_init(struct bio *bio, struct bio_integrity_payload *bip,
31 struct bio_vec *bvecs, unsigned int nr_vecs)
32{
33 memset(bip, 0, sizeof(*bip));
34 bip->bip_max_vcnt = nr_vecs;
35 if (nr_vecs)
36 bip->bip_vec = bvecs;
37
38 bio->bi_integrity = bip;
39 bio->bi_opf |= REQ_INTEGRITY;
40}
41
41/**42/**
42 * bio_integrity_alloc - Allocate integrity payload and attach it to bio43 * bio_integrity_alloc - Allocate integrity payload and attach it to bio
43 * @bio: bio to attach integrity metadata to44 * @bio: bio to attach integrity metadata to
@@ -52,48 +53,16 @@ struct bio_integrity_payload *bio_integrity_alloc(struct bio *bio, · 8 unmodified lines
52 gfp_t gfp_mask,53 gfp_t gfp_mask,
53 unsigned int nr_vecs)54 unsigned int nr_vecs)
54{55{
55 struct bio_integrity_payload *bip;56 struct bio_integrity_alloc *bia;
56 struct bio_set *bs = bio->bi_pool;
57 unsigned inline_vecs;
58 57
59 if (WARN_ON_ONCE(bio_has_crypt_ctx(bio)))58 if (WARN_ON_ONCE(bio_has_crypt_ctx(bio)))
60 return ERR_PTR(-EOPNOTSUPP);59 return ERR_PTR(-EOPNOTSUPP);
61 60
62 if (!bs || !mempool_initialized(&bs->bio_integrity_pool)) {61 bia = kmalloc(struct_size(bia, bvecs, nr_vecs), gfp_mask);
63 bip = kmalloc(struct_size(bip, bip_inline_vecs, nr_vecs), gfp_mask);62 if (unlikely(!bia))
64 inline_vecs = nr_vecs;
65 } else {
66 bip = mempool_alloc(&bs->bio_integrity_pool, gfp_mask);
67 inline_vecs = BIO_INLINE_VECS;
68 }
69
70 if (unlikely(!bip))
71 return ERR_PTR(-ENOMEM);63 return ERR_PTR(-ENOMEM);
72 64 bio_integrity_init(bio, &bia->bip, bia->bvecs, nr_vecs);
73 memset(bip, 0, sizeof(*bip));65 return &bia->bip;
74
75 /* always report as many vecs as asked explicitly, not inline vecs */
76 bip->bip_max_vcnt = nr_vecs;
77 if (nr_vecs > inline_vecs) {
78 bip->bip_vec = bvec_alloc(&bs->bvec_integrity_pool,
79 &bip->bip_max_vcnt, gfp_mask);
80 if (!bip->bip_vec)
81 goto err;
82 } else if (nr_vecs) {
83 bip->bip_vec = bip->bip_inline_vecs;
84 }
85
86 bip->bip_bio = bio;
87 bio->bi_integrity = bip;
88 bio->bi_opf |= REQ_INTEGRITY;
89
90 return bip;
91err:
92 if (bs && mempool_initialized(&bs->bio_integrity_pool))
93 mempool_free(bip, &bs->bio_integrity_pool);
94 else
95 kfree(bip);
96 return ERR_PTR(-ENOMEM);
97}66}
98EXPORT_SYMBOL(bio_integrity_alloc);67EXPORT_SYMBOL(bio_integrity_alloc);
99 68
@@ -467,35 +436,3 @@ int bio_integrity_clone(struct bio *bio, struct bio *bio_src, · 367 unmodified lines
467 436
468 return 0;437 return 0;
469}438}
470
471int bioset_integrity_create(struct bio_set *bs, int pool_size)
472{
473 if (mempool_initialized(&bs->bio_integrity_pool))
474 return 0;
475
476 if (mempool_init_slab_pool(&bs->bio_integrity_pool,
477 pool_size, bip_slab))
478 return -1;
479
480 if (biovec_init_pool(&bs->bvec_integrity_pool, pool_size)) {
481 mempool_exit(&bs->bio_integrity_pool);
482 return -1;
483 }
484
485 return 0;
486}
487EXPORT_SYMBOL(bioset_integrity_create);
488
489void bioset_integrity_free(struct bio_set *bs)
490{
491 mempool_exit(&bs->bio_integrity_pool);
492 mempool_exit(&bs->bvec_integrity_pool);
493}
494
495void __init bio_integrity_init(void)
496{
497 bip_slab = kmem_cache_create("bio_integrity_payload",
498 sizeof(struct bio_integrity_payload) +
499 sizeof(struct bio_vec) * BIO_INLINE_VECS,
500 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
501}
block/bio.c+0−6
@@ -1657,7 +1657,6 @@ void bioset_exit(struct bio_set *bs) · 1656 unmodified lines
1657 mempool_exit(&bs->bio_pool);1657 mempool_exit(&bs->bio_pool);
1658 mempool_exit(&bs->bvec_pool);1658 mempool_exit(&bs->bvec_pool);
1659 1659
1660 bioset_integrity_free(bs);
1661 if (bs->bio_slab)1660 if (bs->bio_slab)
1662 bio_put_slab(bs);1661 bio_put_slab(bs);
1663 bs->bio_slab = NULL;1662 bs->bio_slab = NULL;
@@ -1737,8 +1736,6 @@ static int __init init_bio(void) · 73 unmodified lines
1737 1736
1738 BUILD_BUG_ON(BIO_FLAG_LAST > 8 * sizeof_field(struct bio, bi_flags));1737 BUILD_BUG_ON(BIO_FLAG_LAST > 8 * sizeof_field(struct bio, bi_flags));
1739 1738
1740 bio_integrity_init();
1741
1742 for (i = 0; i < ARRAY_SIZE(bvec_slabs); i++) {1739 for (i = 0; i < ARRAY_SIZE(bvec_slabs); i++) {
1743 struct biovec_slab *bvs = bvec_slabs + i;1740 struct biovec_slab *bvs = bvec_slabs + i;
1744 1741
@@ -1754,9 +1751,6 @@ static int __init init_bio(void) · 9 unmodified lines
1754 BIOSET_NEED_BVECS | BIOSET_PERCPU_CACHE))1751 BIOSET_NEED_BVECS | BIOSET_PERCPU_CACHE))
1755 panic("bio: can't allocate bios\n");1752 panic("bio: can't allocate bios\n");
1756 1753
1757 if (bioset_integrity_create(&fs_bio_set, BIO_POOL_SIZE))
1758 panic("bio: can't create integrity pool\n");
1759
1760 return 0;1754 return 0;
1761}1755}
1762subsys_initcall(init_bio);1756subsys_initcall(init_bio);
block/blk.h+1−1
@@ -710,7 +710,7 @@ int bdev_open(struct block_device *bdev, blk_mode_t mode, void *holder, · 709 unmodified lines
710int bdev_permission(dev_t dev, blk_mode_t mode, void *holder);710int bdev_permission(dev_t dev, blk_mode_t mode, void *holder);
711 711
712void blk_integrity_generate(struct bio *bio);712void blk_integrity_generate(struct bio *bio);
713void blk_integrity_verify(struct bio *bio);713void blk_integrity_verify_iter(struct bio *bio, struct bvec_iter *saved_iter);
714void blk_integrity_prepare(struct request *rq);714void blk_integrity_prepare(struct request *rq);
715void blk_integrity_complete(struct request *rq, unsigned int nr_bytes);715void blk_integrity_complete(struct request *rq, unsigned int nr_bytes);
716 716
block/t10-pi.c+3−3
@@ -404,7 +404,7 @@ void blk_integrity_generate(struct bio *bio) · 403 unmodified lines
404 }404 }
405}405}
406 406
407void blk_integrity_verify(struct bio *bio)407void blk_integrity_verify_iter(struct bio *bio, struct bvec_iter *saved_iter)
408{408{
409 struct blk_integrity *bi = blk_get_integrity(bio->bi_bdev->bd_disk);409 struct blk_integrity *bi = blk_get_integrity(bio->bi_bdev->bd_disk);
410 struct bio_integrity_payload *bip = bio_integrity(bio);410 struct bio_integrity_payload *bip = bio_integrity(bio);
@@ -418,9 +418,9 @@ void blk_integrity_verify(struct bio *bio) · 7 unmodified lines
418 */418 */
419 iter.disk_name = bio->bi_bdev->bd_disk->disk_name;419 iter.disk_name = bio->bi_bdev->bd_disk->disk_name;
420 iter.interval = 1 << bi->interval_exp;420 iter.interval = 1 << bi->interval_exp;
421 iter.seed = bip->bio_iter.bi_sector;421 iter.seed = saved_iter->bi_sector;
422 iter.prot_buf = bvec_virt(bip->bip_vec);422 iter.prot_buf = bvec_virt(bip->bip_vec);
423 __bio_for_each_segment(bv, bio, bviter, bip->bio_iter) {423 __bio_for_each_segment(bv, bio, bviter, *saved_iter) {
424 void *kaddr = bvec_kmap_local(&bv);424 void *kaddr = bvec_kmap_local(&bv);
425 blk_status_t ret = BLK_STS_OK;425 blk_status_t ret = BLK_STS_OK;
426 426
drivers/md/dm-integrity.c+0−12
@@ -4808,23 +4808,11 @@ static int dm_integrity_ctr(struct dm_target *ti, unsigned int argc, char **argv · 4807 unmodified lines
4808 ti->error = "Cannot allocate bio set";4808 ti->error = "Cannot allocate bio set";
4809 goto bad;4809 goto bad;
4810 }4810 }
4811 r = bioset_integrity_create(&ic->recheck_bios, RECHECK_POOL_SIZE);
4812 if (r) {
4813 ti->error = "Cannot allocate bio integrity set";
4814 r = -ENOMEM;
4815 goto bad;
4816 }
4817 r = bioset_init(&ic->recalc_bios, 1, 0, BIOSET_NEED_BVECS);4811 r = bioset_init(&ic->recalc_bios, 1, 0, BIOSET_NEED_BVECS);
4818 if (r) {4812 if (r) {
4819 ti->error = "Cannot allocate bio set";4813 ti->error = "Cannot allocate bio set";
4820 goto bad;4814 goto bad;
4821 }4815 }
4822 r = bioset_integrity_create(&ic->recalc_bios, 1);
4823 if (r) {
4824 ti->error = "Cannot allocate bio integrity set";
4825 r = -ENOMEM;
4826 goto bad;
4827 }
4828 }4816 }
4829 4817
4830 ic->metadata_wq = alloc_workqueue("dm-integrity-metadata",4818 ic->metadata_wq = alloc_workqueue("dm-integrity-metadata",
drivers/md/dm-table.c+0−6
@@ -1081,15 +1081,9 @@ static int dm_table_alloc_md_mempools(struct dm_table *t, struct mapped_device * · 1080 unmodified lines
1081 __alignof__(struct dm_io)) + DM_IO_BIO_OFFSET;1081 __alignof__(struct dm_io)) + DM_IO_BIO_OFFSET;
1082 if (bioset_init(&pools->io_bs, pool_size, io_front_pad, bioset_flags))1082 if (bioset_init(&pools->io_bs, pool_size, io_front_pad, bioset_flags))
1083 goto out_free_pools;1083 goto out_free_pools;
1084 if (mempool_needs_integrity &&
1085 bioset_integrity_create(&pools->io_bs, pool_size))
1086 goto out_free_pools;
1087init_bs:1084init_bs:
1088 if (bioset_init(&pools->bs, pool_size, front_pad, 0))1085 if (bioset_init(&pools->bs, pool_size, front_pad, 0))
1089 goto out_free_pools;1086 goto out_free_pools;
1090 if (mempool_needs_integrity &&
1091 bioset_integrity_create(&pools->bs, pool_size))
1092 goto out_free_pools;
1093 1087
1094 t->mempools = pools;1088 t->mempools = pools;
1095 return 0;1089 return 0;
drivers/md/md.c+0−13
@@ -2359,19 +2359,6 @@ int md_integrity_register(struct mddev *mddev) · 2358 unmodified lines
2359 return 0; /* shouldn't register */2359 return 0; /* shouldn't register */
2360 2360
2361 pr_debug("md: data integrity enabled on %s\n", mdname(mddev));2361 pr_debug("md: data integrity enabled on %s\n", mdname(mddev));
2362 if (bioset_integrity_create(&mddev->bio_set, BIO_POOL_SIZE) ||
2363 (mddev->level != 1 && mddev->level != 10 &&
2364 bioset_integrity_create(&mddev->io_clone_set, BIO_POOL_SIZE))) {
2365 /*
2366 * No need to handle the failure of bioset_integrity_create,
2367 * because the function is called by md_run() -> pers->run(),
2368 * md_run calls bioset_exit -> bioset_integrity_free in case
2369 * of failure case.
2370 */
2371 pr_err("md: failed to create integrity pool for %s\n",
2372 mdname(mddev));
2373 return -EINVAL;
2374 }
2375 return 0;2362 return 0;
2376}2363}
2377EXPORT_SYMBOL(md_integrity_register);2364EXPORT_SYMBOL(md_integrity_register);
drivers/target/target_core_iblock.c+0−12
@@ -167,18 +167,6 @@ static int iblock_configure_device(struct se_device *dev) · 166 unmodified lines
167 break;167 break;
168 }168 }
169 169
170 if (dev->dev_attrib.pi_prot_type) {
171 struct bio_set *bs = &ib_dev->ibd_bio_set;
172
173 if (bioset_integrity_create(bs, IBLOCK_BIO_POOL_SIZE) < 0) {
174 pr_err("Unable to allocate bioset for PI\n");
175 ret = -ENOMEM;
176 goto out_blkdev_put;
177 }
178 pr_debug("IBLOCK setup BIP bs->bio_integrity_pool: %p\n",
179 &bs->bio_integrity_pool);
180 }
181
182 dev->dev_attrib.hw_pi_prot_type = dev->dev_attrib.pi_prot_type;170 dev->dev_attrib.hw_pi_prot_type = dev->dev_attrib.pi_prot_type;
183 return 0;171 return 0;
184 172
include/linux/bio-integrity.h+2−23
@@ -16,8 +16,6 @@ enum bip_flags { · 15 unmodified lines
16};16};
17 17
18struct bio_integrity_payload {18struct bio_integrity_payload {
19 struct bio *bip_bio; /* parent bio */
20
21 struct bvec_iter bip_iter;19 struct bvec_iter bip_iter;
22 20
23 unsigned short bip_vcnt; /* # of integrity bio_vecs */21 unsigned short bip_vcnt; /* # of integrity bio_vecs */
@@ -25,12 +23,7 @@ struct bio_integrity_payload { · 1 unmodified line
25 unsigned short bip_flags; /* control flags */23 unsigned short bip_flags; /* control flags */
26 u16 app_tag; /* application tag value */24 u16 app_tag; /* application tag value */
27 25
28 struct bvec_iter bio_iter; /* for rewinding parent bio */
29
30 struct work_struct bip_work; /* I/O completion */
31
32 struct bio_vec *bip_vec;26 struct bio_vec *bip_vec;
33 struct bio_vec bip_inline_vecs[];/* embedded bvec array */
34};27};
35 28
36#define BIP_CLONE_FLAGS (BIP_MAPPED_INTEGRITY | BIP_IP_CHECKSUM | \29#define BIP_CLONE_FLAGS (BIP_MAPPED_INTEGRITY | BIP_IP_CHECKSUM | \
@@ -74,6 +67,8 @@ static inline void bip_set_seed(struct bio_integrity_payload *bip, · 37 unmodified lines
74 bip->bip_iter.bi_sector = seed;67 bip->bip_iter.bi_sector = seed;
75}68}
76 69
70void bio_integrity_init(struct bio *bio, struct bio_integrity_payload *bip,
71 struct bio_vec *bvecs, unsigned int nr_vecs);
77struct bio_integrity_payload *bio_integrity_alloc(struct bio *bio, gfp_t gfp,72struct bio_integrity_payload *bio_integrity_alloc(struct bio *bio, gfp_t gfp,
78 unsigned int nr);73 unsigned int nr);
79int bio_integrity_add_page(struct bio *bio, struct page *page, unsigned int len,74int bio_integrity_add_page(struct bio *bio, struct page *page, unsigned int len,
@@ -85,9 +80,6 @@ bool bio_integrity_prep(struct bio *bio); · 5 unmodified lines
85void bio_integrity_advance(struct bio *bio, unsigned int bytes_done);80void bio_integrity_advance(struct bio *bio, unsigned int bytes_done);
86void bio_integrity_trim(struct bio *bio);81void bio_integrity_trim(struct bio *bio);
87int bio_integrity_clone(struct bio *bio, struct bio *bio_src, gfp_t gfp_mask);82int bio_integrity_clone(struct bio *bio, struct bio *bio_src, gfp_t gfp_mask);
88int bioset_integrity_create(struct bio_set *bs, int pool_size);
89void bioset_integrity_free(struct bio_set *bs);
90void bio_integrity_init(void);
91 83
92#else /* CONFIG_BLK_DEV_INTEGRITY */84#else /* CONFIG_BLK_DEV_INTEGRITY */
93 85
@@ -96,15 +88,6 @@ static inline struct bio_integrity_payload *bio_integrity(struct bio *bio) · 2 unmodified lines
96 return NULL;88 return NULL;
97}89}
98 90
99static inline int bioset_integrity_create(struct bio_set *bs, int pool_size)
100{
101 return 0;
102}
103
104static inline void bioset_integrity_free(struct bio_set *bs)
105{
106}
107
108static inline int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter)91static inline int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter)
109{92{
110 return -EINVAL;93 return -EINVAL;
@@ -139,10 +122,6 @@ static inline void bio_integrity_trim(struct bio *bio) · 28 unmodified lines
139{122{
140}123}
141 124
142static inline void bio_integrity_init(void)
143{
144}
145
146static inline bool bio_integrity_flagged(struct bio *bio, enum bip_flags flag)125static inline bool bio_integrity_flagged(struct bio *bio, enum bip_flags flag)
147{126{
148 return false;127 return false;
include/linux/bio.h+0−4
@@ -625,10 +625,6 @@ struct bio_set { · 624 unmodified lines
625 625
626 mempool_t bio_pool;626 mempool_t bio_pool;
627 mempool_t bvec_pool;627 mempool_t bvec_pool;
628#if defined(CONFIG_BLK_DEV_INTEGRITY)
629 mempool_t bio_integrity_pool;
630 mempool_t bvec_integrity_pool;
631#endif
632 628
633 unsigned int back_pad;629 unsigned int back_pad;
634 /*630 /*