]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
block: drop direction param from bio_integrity_copy_user()
authorCaleb Sander Mateos <csander@purestorage.com>
Tue, 3 Jun 2025 18:31:32 +0000 (12:31 -0600)
committerJens Axboe <axboe@kernel.dk>
Tue, 3 Jun 2025 18:45:45 +0000 (12:45 -0600)
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 <csander@purestorage.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Anuj Gupta <anuj20.g@samsung.com>
Link: https://lore.kernel.org/r/20250603183133.1178062-1-csander@purestorage.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/bio-integrity.c

index cb94e9be26dc21d7231ee1cd8f29cd4680b402af..10912988c8f5c735249f1228530ef1b8cafe85fa 100644 (file)
@@ -154,10 +154,9 @@ int bio_integrity_add_page(struct bio *bio, struct page *page,
 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;
@@ -168,7 +167,7 @@ static int bio_integrity_copy_user(struct bio *bio, struct bio_vec *bvec,
                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;
@@ -264,7 +263,7 @@ int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter)
        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;
 
@@ -273,11 +272,6 @@ int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter)
        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;
@@ -300,8 +294,7 @@ int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter)
                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)