aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin K. Petersen <martin.petersen@oracle.com>2014-09-26 19:19:55 -0400
committerJens Axboe <axboe@fb.com>2014-09-27 11:14:44 -0400
commite7258c1a269e0967856c81d182c286a78f5ecf15 (patch)
treebd2d5be701105d29e79fc843f091aa574ff4ebc8
parentf70ced09170761acb69840cafaace4abc72cba4b (diff)
block: Get rid of bdev_integrity_enabled()
bdev_integrity_enabled() is only used by bio_integrity_enabled(). Combine these two functions. Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Sagi Grimberg <sagig@mellanox.com> Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r--Documentation/block/data-integrity.txt10
-rw-r--r--block/bio-integrity.c39
-rw-r--r--include/linux/bio.h6
3 files changed, 20 insertions, 35 deletions
diff --git a/Documentation/block/data-integrity.txt b/Documentation/block/data-integrity.txt
index 2d735b0ae383..b4eacf48053c 100644
--- a/Documentation/block/data-integrity.txt
+++ b/Documentation/block/data-integrity.txt
@@ -192,16 +192,6 @@ will require extra work due to the application tag.
192 supported by the block device. 192 supported by the block device.
193 193
194 194
195 int bdev_integrity_enabled(block_device, int rw);
196
197 bdev_integrity_enabled() will return 1 if the block device
198 supports integrity metadata transfer for the data direction
199 specified in 'rw'.
200
201 bdev_integrity_enabled() honors the write_generate and
202 read_verify flags in sysfs and will respond accordingly.
203
204
205 int bio_integrity_prep(bio); 195 int bio_integrity_prep(bio);
206 196
207 To generate IMD for WRITE and to set up buffers for READ, the 197 To generate IMD for WRITE and to set up buffers for READ, the
diff --git a/block/bio-integrity.c b/block/bio-integrity.c
index f14b4abbebd8..36b788552c3e 100644
--- a/block/bio-integrity.c
+++ b/block/bio-integrity.c
@@ -147,24 +147,6 @@ int bio_integrity_add_page(struct bio *bio, struct page *page,
147} 147}
148EXPORT_SYMBOL(bio_integrity_add_page); 148EXPORT_SYMBOL(bio_integrity_add_page);
149 149
150static int bdev_integrity_enabled(struct block_device *bdev, int rw)
151{
152 struct blk_integrity *bi = bdev_get_integrity(bdev);
153
154 if (bi == NULL)
155 return 0;
156
157 if (rw == READ && bi->verify_fn != NULL &&
158 (bi->flags & INTEGRITY_FLAG_READ))
159 return 1;
160
161 if (rw == WRITE && bi->generate_fn != NULL &&
162 (bi->flags & INTEGRITY_FLAG_WRITE))
163 return 1;
164
165 return 0;
166}
167
168/** 150/**
169 * bio_integrity_enabled - Check whether integrity can be passed 151 * bio_integrity_enabled - Check whether integrity can be passed
170 * @bio: bio to check 152 * @bio: bio to check
@@ -174,16 +156,29 @@ static int bdev_integrity_enabled(struct block_device *bdev, int rw)
174 * set prior to calling. The functions honors the write_generate and 156 * set prior to calling. The functions honors the write_generate and
175 * read_verify flags in sysfs. 157 * read_verify flags in sysfs.
176 */ 158 */
177int bio_integrity_enabled(struct bio *bio) 159bool bio_integrity_enabled(struct bio *bio)
178{ 160{
161 struct blk_integrity *bi = bdev_get_integrity(bio->bi_bdev);
162
179 if (!bio_is_rw(bio)) 163 if (!bio_is_rw(bio))
180 return 0; 164 return false;
181 165
182 /* Already protected? */ 166 /* Already protected? */
183 if (bio_integrity(bio)) 167 if (bio_integrity(bio))
184 return 0; 168 return false;
169
170 if (bi == NULL)
171 return false;
172
173 if (bio_data_dir(bio) == READ && bi->verify_fn != NULL &&
174 (bi->flags & INTEGRITY_FLAG_READ))
175 return true;
176
177 if (bio_data_dir(bio) == WRITE && bi->generate_fn != NULL &&
178 (bi->flags & INTEGRITY_FLAG_WRITE))
179 return true;
185 180
186 return bdev_integrity_enabled(bio->bi_bdev, bio_data_dir(bio)); 181 return false;
187} 182}
188EXPORT_SYMBOL(bio_integrity_enabled); 183EXPORT_SYMBOL(bio_integrity_enabled);
189 184
diff --git a/include/linux/bio.h b/include/linux/bio.h
index b39e5000ff58..63e399b4fde5 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -666,7 +666,7 @@ struct biovec_slab {
666extern struct bio_integrity_payload *bio_integrity_alloc(struct bio *, gfp_t, unsigned int); 666extern struct bio_integrity_payload *bio_integrity_alloc(struct bio *, gfp_t, unsigned int);
667extern void bio_integrity_free(struct bio *); 667extern void bio_integrity_free(struct bio *);
668extern int bio_integrity_add_page(struct bio *, struct page *, unsigned int, unsigned int); 668extern int bio_integrity_add_page(struct bio *, struct page *, unsigned int, unsigned int);
669extern int bio_integrity_enabled(struct bio *bio); 669extern bool bio_integrity_enabled(struct bio *bio);
670extern int bio_integrity_set_tag(struct bio *, void *, unsigned int); 670extern int bio_integrity_set_tag(struct bio *, void *, unsigned int);
671extern int bio_integrity_get_tag(struct bio *, void *, unsigned int); 671extern int bio_integrity_get_tag(struct bio *, void *, unsigned int);
672extern int bio_integrity_prep(struct bio *); 672extern int bio_integrity_prep(struct bio *);
@@ -685,9 +685,9 @@ static inline int bio_integrity(struct bio *bio)
685 return 0; 685 return 0;
686} 686}
687 687
688static inline int bio_integrity_enabled(struct bio *bio) 688static inline bool bio_integrity_enabled(struct bio *bio)
689{ 689{
690 return 0; 690 return false;
691} 691}
692 692
693static inline int bioset_integrity_create(struct bio_set *bs, int pool_size) 693static inline int bioset_integrity_create(struct bio_set *bs, int pool_size)