block: drop direction param from bio_integrity_copy_user()
PATCH 1/1 block: drop direction param from bio_integrity_copy_user()
direction is determined from bio, which is already passed in. Compute op_is_write(bio_op(bio)) directly instead of converting it to an iter direction and back to a bool.
Signed-off-by Caleb Sander Mateos <[email protected]>
--- block/bio-integrity.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-)
block/bio-integrity.c +5 -12
@@ -152,25 +152,24 @@ int bio_integrity_add_page(struct bio *bio, struct page *page,return len; }EXPORT_SYMBOL (bio_integrity_add_page);static int bio_integrity_copy_user (struct bio *bio,struct bio_vec *bvec, -int nr_vecs,unsigned int len, -unsigned int direction) +int nr_vecs,unsigned int len) { -bool write = direction ==ITER_SOURCE ; +bool write =op_is_write (bio_op (bio));struct bio_integrity_payload *bip;struct iov_iter iter;void *buf;int ret; buf =kmalloc (len,GFP_KERNEL );if (!buf)return -ENOMEM ;if (write) { -iov_iter_bvec (&iter, direction, bvec, nr_vecs, len); +iov_iter_bvec (&iter,ITER_SOURCE , bvec, nr_vecs, len);if (!copy_from_iter_full (buf, len, &iter)) { ret = -EFAULT ; goto free_buf; }
@@ -262,24 +261,19 @@ int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter)struct request_queue *q =bdev_get_queue (bio->bi_bdev);unsigned int align =blk_lim_dma_alignment_and_pad (&q->limits);struct page *stack_pages[UIO_FASTIOV ], **pages = stack_pages;struct bio_vec stack_vec[UIO_FASTIOV ], *bvec = stack_vec;size_t offset, bytes = iter->count; -unsigned int direction, nr_bvecs; +unsigned int nr_bvecs;int ret, nr_vecs;bool copy;if (bio_integrity (bio))return -EINVAL ;if (bytes >>SECTOR_SHIFT >queue_max_hw_sectors (q))return -E2BIG ; -if (bio_data_dir (bio) ==READ ) - direction =ITER_DEST ; -else - direction =ITER_SOURCE ; - nr_vecs =iov_iter_npages (iter,BIO_MAX_VECS +1 );if (nr_vecs >BIO_MAX_VECS )return -E2BIG ;if (nr_vecs >UIO_FASTIOV ) { bvec =kcalloc (nr_vecs,sizeof (*bvec),GFP_KERNEL );
@@ -298,12 +292,11 @@ int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter)kvfree (pages);if (nr_bvecs >queue_max_integrity_segments (q)) copy = true;if (copy) - ret =bio_integrity_copy_user (bio, bvec, nr_bvecs, bytes, - direction); + ret =bio_integrity_copy_user (bio, bvec, nr_bvecs, bytes);else ret =bio_integrity_init_user (bio, bvec, nr_bvecs, bytes);if (ret) goto release_pages;if (bvec != stack_vec)
Signature · 1 line
2.45.2
Looks ok to me.
Reviewed-by Anuj Gupta <[email protected]>
Quoted 3 lines · Caleb Sander Mateos
direction is determined from bio, which is already passed in. Compute op_is_write(bio_op(bio)) directly instead of converting it to an iter direction and back to a bool.
Looks good.
Reviewed-by Keith Busch <[email protected]>
Quoted 5 lines · Caleb Sander Mateos
direction is determined from bio, which is already passed in. Compute op_is_write(bio_op(bio)) directly instead of converting it to an iter direction and back to a bool.
Applied, thanks!
[1/1] block: drop direction param from bio_integrity_copy_user()
commit: c09a8b00f850d3ca0af998bff1fac4a3f6d11768
Best regards,
Signature · 1 line
Jens Axboe