Commit e7258c1a269e0967856c81d182c286a78f5ecf15
Committed by
Jens Axboe
1 parent
f70ced0917
Exists in
ti-lsk-linux-4.1.y
and in
10 other branches
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>
Showing 3 changed files with 20 additions and 35 deletions Side-by-side Diff
Documentation/block/data-integrity.txt
... | ... | @@ -192,16 +192,6 @@ |
192 | 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 | 195 | int bio_integrity_prep(bio); |
206 | 196 | |
207 | 197 | To generate IMD for WRITE and to set up buffers for READ, the |
block/bio-integrity.c
... | ... | @@ -147,24 +147,6 @@ |
147 | 147 | } |
148 | 148 | EXPORT_SYMBOL(bio_integrity_add_page); |
149 | 149 | |
150 | -static 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 | 151 | * bio_integrity_enabled - Check whether integrity can be passed |
170 | 152 | * @bio: bio to check |
171 | 153 | |
172 | 154 | |
173 | 155 | |
174 | 156 | |
... | ... | @@ -174,16 +156,29 @@ |
174 | 156 | * set prior to calling. The functions honors the write_generate and |
175 | 157 | * read_verify flags in sysfs. |
176 | 158 | */ |
177 | -int bio_integrity_enabled(struct bio *bio) | |
159 | +bool bio_integrity_enabled(struct bio *bio) | |
178 | 160 | { |
161 | + struct blk_integrity *bi = bdev_get_integrity(bio->bi_bdev); | |
162 | + | |
179 | 163 | if (!bio_is_rw(bio)) |
180 | - return 0; | |
164 | + return false; | |
181 | 165 | |
182 | 166 | /* Already protected? */ |
183 | 167 | if (bio_integrity(bio)) |
184 | - return 0; | |
168 | + return false; | |
185 | 169 | |
186 | - return bdev_integrity_enabled(bio->bi_bdev, bio_data_dir(bio)); | |
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; | |
180 | + | |
181 | + return false; | |
187 | 182 | } |
188 | 183 | EXPORT_SYMBOL(bio_integrity_enabled); |
189 | 184 |
include/linux/bio.h
... | ... | @@ -666,7 +666,7 @@ |
666 | 666 | extern struct bio_integrity_payload *bio_integrity_alloc(struct bio *, gfp_t, unsigned int); |
667 | 667 | extern void bio_integrity_free(struct bio *); |
668 | 668 | extern int bio_integrity_add_page(struct bio *, struct page *, unsigned int, unsigned int); |
669 | -extern int bio_integrity_enabled(struct bio *bio); | |
669 | +extern bool bio_integrity_enabled(struct bio *bio); | |
670 | 670 | extern int bio_integrity_set_tag(struct bio *, void *, unsigned int); |
671 | 671 | extern int bio_integrity_get_tag(struct bio *, void *, unsigned int); |
672 | 672 | extern int bio_integrity_prep(struct bio *); |
673 | 673 | |
... | ... | @@ -685,9 +685,9 @@ |
685 | 685 | return 0; |
686 | 686 | } |
687 | 687 | |
688 | -static inline int bio_integrity_enabled(struct bio *bio) | |
688 | +static inline bool bio_integrity_enabled(struct bio *bio) | |
689 | 689 | { |
690 | - return 0; | |
690 | + return false; | |
691 | 691 | } |
692 | 692 | |
693 | 693 | static inline int bioset_integrity_create(struct bio_set *bs, int pool_size) |