Skip to content

Commit

Permalink
block: add a rq_integrity_vec helper
Browse files Browse the repository at this point in the history
This provides a nice little shortcut to get the integrity data for
drivers like NVMe that only support a single integrity segment.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Keith Busch <keith.busch@intel.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
  • Loading branch information
Christoph Hellwig committed Apr 5, 2019
1 parent 3aef3ca commit 2a876f5
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions include/linux/blkdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -1559,6 +1559,17 @@ static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi,
return bio_integrity_intervals(bi, sectors) * bi->tuple_size;
}

/*
* Return the first bvec that contains integrity data. Only drivers that are
* limited to a single integrity segment should use this helper.
*/
static inline struct bio_vec *rq_integrity_vec(struct request *rq)
{
if (WARN_ON_ONCE(queue_max_integrity_segments(rq->q) > 1))
return NULL;
return rq->bio->bi_integrity->bip_vec;
}

#else /* CONFIG_BLK_DEV_INTEGRITY */

struct bio;
Expand Down Expand Up @@ -1633,6 +1644,11 @@ static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi,
return 0;
}

static inline struct bio_vec *rq_integrity_vec(struct request *rq)
{
return NULL;
}

#endif /* CONFIG_BLK_DEV_INTEGRITY */

struct block_device_operations {
Expand Down

0 comments on commit 2a876f5

Please sign in to comment.