aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGu Zheng <guz.fnst@cn.fujitsu.com>2014-07-01 12:36:47 -0400
committerJens Axboe <axboe@fb.com>2014-07-01 12:36:47 -0400
commitcbcd1054a1fd2aa980fc11ff28e436fc4aaa2d54 (patch)
treeba7302637859ce48e703a4bd2c3ce7c7d2a27175
parentadd703fda981b9719d37f371498b9f129acbd997 (diff)
bio-integrity: add "bip_max_vcnt" into struct bio_integrity_payload
Commit 08778795 ("block: Fix nr_vecs for inline integrity vectors") from Martin introduces the function bip_integrity_vecs(get the useful vectors) to fix the issue about nr_vecs for inline integrity vectors that reported by David Milburn. But it seems that bip_integrity_vecs() will return the wrong number if the bio is not based on any bio_set for some reason(bio->bi_pool == NULL), because in that case, the bip_inline_vecs[0] is malloced directly. So here we add the bip_max_vcnt to record the count of vector slots, and cleanup the function bip_integrity_vecs(). Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com> Cc: Martin K. Petersen <martin.petersen@oracle.com> Cc: Kent Overstreet <kmo@daterainc.com> Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r--block/bio-integrity.c12
-rw-r--r--include/linux/bio.h1
2 files changed, 4 insertions, 9 deletions
diff --git a/block/bio-integrity.c b/block/bio-integrity.c
index 9e241063a616..bc423f7b02da 100644
--- a/block/bio-integrity.c
+++ b/block/bio-integrity.c
@@ -70,8 +70,10 @@ struct bio_integrity_payload *bio_integrity_alloc(struct bio *bio,
70 bs->bvec_integrity_pool); 70 bs->bvec_integrity_pool);
71 if (!bip->bip_vec) 71 if (!bip->bip_vec)
72 goto err; 72 goto err;
73 bip->bip_max_vcnt = bvec_nr_vecs(idx);
73 } else { 74 } else {
74 bip->bip_vec = bip->bip_inline_vecs; 75 bip->bip_vec = bip->bip_inline_vecs;
76 bip->bip_max_vcnt = inline_vecs;
75 } 77 }
76 78
77 bip->bip_slab = idx; 79 bip->bip_slab = idx;
@@ -114,14 +116,6 @@ void bio_integrity_free(struct bio *bio)
114} 116}
115EXPORT_SYMBOL(bio_integrity_free); 117EXPORT_SYMBOL(bio_integrity_free);
116 118
117static inline unsigned int bip_integrity_vecs(struct bio_integrity_payload *bip)
118{
119 if (bip->bip_slab == BIO_POOL_NONE)
120 return BIP_INLINE_VECS;
121
122 return bvec_nr_vecs(bip->bip_slab);
123}
124
125/** 119/**
126 * bio_integrity_add_page - Attach integrity metadata 120 * bio_integrity_add_page - Attach integrity metadata
127 * @bio: bio to update 121 * @bio: bio to update
@@ -137,7 +131,7 @@ int bio_integrity_add_page(struct bio *bio, struct page *page,
137 struct bio_integrity_payload *bip = bio->bi_integrity; 131 struct bio_integrity_payload *bip = bio->bi_integrity;
138 struct bio_vec *iv; 132 struct bio_vec *iv;
139 133
140 if (bip->bip_vcnt >= bip_integrity_vecs(bip)) { 134 if (bip->bip_vcnt >= bip->bip_max_vcnt) {
141 printk(KERN_ERR "%s: bip_vec full\n", __func__); 135 printk(KERN_ERR "%s: bip_vec full\n", __func__);
142 return 0; 136 return 0;
143 } 137 }
diff --git a/include/linux/bio.h b/include/linux/bio.h
index d2633ee099d9..b39e5000ff58 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -308,6 +308,7 @@ struct bio_integrity_payload {
308 308
309 unsigned short bip_slab; /* slab the bip came from */ 309 unsigned short bip_slab; /* slab the bip came from */
310 unsigned short bip_vcnt; /* # of integrity bio_vecs */ 310 unsigned short bip_vcnt; /* # of integrity bio_vecs */
311 unsigned short bip_max_vcnt; /* integrity bio_vec slots */
311 unsigned bip_owns_buf:1; /* should free bip_buf */ 312 unsigned bip_owns_buf:1; /* should free bip_buf */
312 313
313 struct work_struct bip_work; /* I/O completion */ 314 struct work_struct bip_work; /* I/O completion */