aboutsummaryrefslogtreecommitdiffstats
path: root/block
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 /block
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>
Diffstat (limited to 'block')
-rw-r--r--block/bio-integrity.c39
1 files changed, 17 insertions, 22 deletions
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