Skip to content

Commit

Permalink
linux/zvol_os: convert END_IO macro to inline function
Browse files Browse the repository at this point in the history
Sponsored-by: https://despairlabs.com/sponsor/
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Tony Hutter <[email protected]>
Reviewed-by: Tino Reichardt <[email protected]>
Signed-off-by: Rob Norris <[email protected]>
Closes #16479
  • Loading branch information
robn authored and behlendorf committed Sep 18, 2024
1 parent dcb8e5e commit f6661d1
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions module/os/linux/zfs/zvol_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,16 @@ static unsigned int zvol_num_taskqs = 0;
/*
* Finalize our BIO or request.
*/
#define END_IO(zv, bio, rq, error) do { \
if (bio) { \
bio->bi_status = errno_to_bi_status(-error); \
bio_endio(bio); \
} else { \
blk_mq_end_request(rq, errno_to_bi_status(error)); \
} \
} while (0)
static inline void
zvol_end_io(struct bio *bio, struct request *rq, int error)
{
if (bio) {
bio->bi_status = errno_to_bi_status(-error);
bio_endio(bio);
} else {
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_actual_blk_mq_queue_depth;
Expand Down Expand Up @@ -250,7 +252,7 @@ zvol_write(zv_request_t *zvr)
/* Some requests are just for flush and nothing else. */
if (io_size(bio, rq) == 0) {
rw_exit(&zv->zv_suspend_lock);
END_IO(zv, bio, rq, 0);
zvol_end_io(bio, rq, 0);
return;
}

Expand Down Expand Up @@ -317,7 +319,7 @@ zvol_write(zv_request_t *zvr)
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
Expand Down Expand Up @@ -406,7 +408,7 @@ zvol_discard(zv_request_t *zvr)
start_time);
}

END_IO(zv, bio, rq, -error);
zvol_end_io(bio, rq, -error);
}

static void
Expand Down Expand Up @@ -483,7 +485,7 @@ zvol_read(zv_request_t *zvr)
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
Expand Down Expand Up @@ -514,7 +516,7 @@ zvol_request_impl(zvol_state_t *zv, struct bio *bio, struct request *rq,
int rw = io_data_dir(bio, rq);

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;
}

Expand All @@ -533,7 +535,7 @@ zvol_request_impl(zvol_state_t *zv, struct bio *bio, struct request *rq,
(long long unsigned)offset,
(long unsigned)size);

END_IO(zv, bio, rq, -SET_ERROR(EIO));
zvol_end_io(bio, rq, -SET_ERROR(EIO));
goto out;
}

Expand All @@ -555,7 +557,7 @@ zvol_request_impl(zvol_state_t *zv, struct bio *bio, struct request *rq,

if (rw == WRITE) {
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;
}

Expand Down Expand Up @@ -640,7 +642,7 @@ zvol_request_impl(zvol_state_t *zv, struct bio *bio, struct request *rq,
* data and require no additional handling.
*/
if (size == 0) {
END_IO(zv, bio, rq, 0);
zvol_end_io(bio, rq, 0);
goto out;
}

Expand Down

0 comments on commit f6661d1

Please sign in to comment.