linux/zvol_os: convert END_IO macro to inline function

Sponsored-by: https://despairlabs.com/sponsor/
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
Signed-off-by: Rob Norris <robn@despairlabs.com>
Closes #16479
This commit is contained in:
Rob Norris 2024-08-24 21:37:30 +10:00 committed by Tony Hutter
parent 9601eeea1c
commit 701c3c1582

View File

@ -91,14 +91,16 @@ static unsigned int zvol_num_taskqs = 0;
/* /*
* Finalize our BIO or request. * Finalize our BIO or request.
*/ */
#define END_IO(zv, bio, rq, error) do { \ static inline void
if (bio) { \ zvol_end_io(struct bio *bio, struct request *rq, int error)
bio->bi_status = errno_to_bi_status(-error); \ {
bio_endio(bio); \ if (bio) {
} else { \ bio->bi_status = errno_to_bi_status(-error);
blk_mq_end_request(rq, errno_to_bi_status(error)); \ bio_endio(bio);
} \ } else {
} while (0) blk_mq_end_request(rq, errno_to_bi_status(error));
}
}
static unsigned int zvol_blk_mq_queue_depth = BLKDEV_DEFAULT_RQ; static unsigned int zvol_blk_mq_queue_depth = BLKDEV_DEFAULT_RQ;
static unsigned int zvol_actual_blk_mq_queue_depth; static unsigned int zvol_actual_blk_mq_queue_depth;
@ -250,7 +252,7 @@ zvol_write(zv_request_t *zvr)
/* Some requests are just for flush and nothing else. */ /* Some requests are just for flush and nothing else. */
if (io_size(bio, rq) == 0) { if (io_size(bio, rq) == 0) {
rw_exit(&zv->zv_suspend_lock); rw_exit(&zv->zv_suspend_lock);
END_IO(zv, bio, rq, 0); zvol_end_io(bio, rq, 0);
return; return;
} }
@ -317,7 +319,7 @@ zvol_write(zv_request_t *zvr)
blk_generic_end_io_acct(q, disk, WRITE, bio, start_time); blk_generic_end_io_acct(q, disk, WRITE, bio, start_time);
} }
END_IO(zv, bio, rq, -error); zvol_end_io(bio, rq, -error);
} }
static void static void
@ -406,7 +408,7 @@ unlock:
start_time); start_time);
} }
END_IO(zv, bio, rq, -error); zvol_end_io(bio, rq, -error);
} }
static void static void
@ -483,7 +485,7 @@ zvol_read(zv_request_t *zvr)
blk_generic_end_io_acct(q, disk, READ, bio, start_time); blk_generic_end_io_acct(q, disk, READ, bio, start_time);
} }
END_IO(zv, bio, rq, -error); zvol_end_io(bio, rq, -error);
} }
static void static void
@ -514,7 +516,7 @@ zvol_request_impl(zvol_state_t *zv, struct bio *bio, struct request *rq,
int rw = io_data_dir(bio, rq); int rw = io_data_dir(bio, rq);
if (unlikely(zv->zv_flags & ZVOL_REMOVING)) { if (unlikely(zv->zv_flags & ZVOL_REMOVING)) {
END_IO(zv, bio, rq, -SET_ERROR(ENXIO)); zvol_end_io(bio, rq, -SET_ERROR(ENXIO));
goto out; goto out;
} }
@ -533,7 +535,7 @@ zvol_request_impl(zvol_state_t *zv, struct bio *bio, struct request *rq,
(long long unsigned)offset, (long long unsigned)offset,
(long unsigned)size); (long unsigned)size);
END_IO(zv, bio, rq, -SET_ERROR(EIO)); zvol_end_io(bio, rq, -SET_ERROR(EIO));
goto out; goto out;
} }
@ -555,7 +557,7 @@ zvol_request_impl(zvol_state_t *zv, struct bio *bio, struct request *rq,
if (rw == WRITE) { if (rw == WRITE) {
if (unlikely(zv->zv_flags & ZVOL_RDONLY)) { if (unlikely(zv->zv_flags & ZVOL_RDONLY)) {
END_IO(zv, bio, rq, -SET_ERROR(EROFS)); zvol_end_io(bio, rq, -SET_ERROR(EROFS));
goto out; goto out;
} }
@ -640,7 +642,7 @@ zvol_request_impl(zvol_state_t *zv, struct bio *bio, struct request *rq,
* data and require no additional handling. * data and require no additional handling.
*/ */
if (size == 0) { if (size == 0) {
END_IO(zv, bio, rq, 0); zvol_end_io(bio, rq, 0);
goto out; goto out;
} }