@@ -308,6 +308,19 @@ static unsigned int bvec_from_pages(struct bio_vec *bvec, struct page **pages,
return nr_bvecs;
}
+int bio_integrity_map_iter(struct bio *bio, struct iov_iter *iter)
+{
+ struct blk_integrity *bi = blk_get_integrity(bio->bi_bdev->bd_disk);
+
+ if (!bi)
+ return -EINVAL;
+
+ if (iter->count < bio_integrity_bytes(bi, bio_sectors(bio)))
+ return -EINVAL;
+
+ return bio_integrity_map_user(bio, iter, 0);
+}
+
int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter,
u32 seed)
{
@@ -353,6 +353,15 @@ static ssize_t __blkdev_direct_IO_async(struct kiocb *iocb,
task_io_account_write(bio->bi_iter.bi_size);
}
+ if (unlikely(iocb->ki_flags & IOCB_USE_META)) {
+ ret = bio_integrity_map_iter(bio, iocb->private);
+ WRITE_ONCE(iocb->private, NULL);
+ if (unlikely(ret)) {
+ bio_put(bio);
+ return ret;
+ }
+ }
+
if (iocb->ki_flags & IOCB_NOWAIT)
bio->bi_opf |= REQ_NOWAIT;
@@ -156,6 +156,8 @@ static void t10_pi_type1_prepare(struct request *rq)
/* Already remapped? */
if (bip->bip_flags & BIP_MAPPED_INTEGRITY)
break;
+ if (bip->bip_flags & BIP_INTEGRITY_USER)
+ break;
bip_for_each_vec(iv, bip, iter) {
unsigned int j;
@@ -205,6 +207,8 @@ static void t10_pi_type1_complete(struct request *rq, unsigned int nr_bytes)
struct bio_vec iv;
struct bvec_iter iter;
+ if (bip->bip_flags & BIP_INTEGRITY_USER)
+ break;
bip_for_each_vec(iv, bip, iter) {
unsigned int j;
void *p;
@@ -408,6 +412,8 @@ static void ext_pi_type1_prepare(struct request *rq)
/* Already remapped? */
if (bip->bip_flags & BIP_MAPPED_INTEGRITY)
break;
+ if (bip->bip_flags & BIP_INTEGRITY_USER)
+ break;
bip_for_each_vec(iv, bip, iter) {
unsigned int j;
@@ -723,6 +723,7 @@ static inline bool bioset_initialized(struct bio_set *bs)
for_each_bio(_bio) \
bip_for_each_vec(_bvl, _bio->bi_integrity, _iter)
+int bio_integrity_map_iter(struct bio *bio, struct iov_iter *iter);
int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter, u32 seed);
extern struct bio_integrity_payload *bio_integrity_alloc(struct bio *, gfp_t, unsigned int);
extern int bio_integrity_add_page(struct bio *, struct page *, unsigned int, unsigned int);
@@ -802,6 +803,11 @@ static inline int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter,
return -EINVAL;
}
+static inline int bio_integrity_map_iter(struct bio *bio, struct iov_iter *iter)
+{
+ return -EINVAL;
+}
+
#endif /* CONFIG_BLK_DEV_INTEGRITY */
/*