zvol: Fix blk-mq sync

The zvol blk-mq codepaths would erroneously send FLUSH and TRIM
commands down the read codepath, rather than write.  This fixes
the issue, and updates the zvol_misc_fua test to verify that
sync writes are actually happening.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com>
Reviewed-by: Ameer Hamza <ahamza@ixsystems.com>
Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Closes #17761
Closes #17765
This commit is contained in:
Tony Hutter
2025-09-29 16:29:20 -07:00
committed by Brian Behlendorf
parent a9bcf4faf3
commit 9079f986ae
3 changed files with 61 additions and 20 deletions
+22 -1
View File
@@ -484,7 +484,28 @@ zvol_request_impl(zvol_state_t *zv, struct bio *bio, struct request *rq,
fstrans_cookie_t cookie = spl_fstrans_mark();
uint64_t offset = io_offset(bio, rq);
uint64_t size = io_size(bio, rq);
int rw = io_data_dir(bio, rq);
int rw;
if (rq != NULL) {
/*
* Flush & trim requests go down the zvol_write codepath. Or
* more specifically:
*
* If request is a write, or if it's op_is_sync() and not a
* read, or if it's a flush, or if it's a discard, then send the
* request down the write path.
*/
if (op_is_write(rq->cmd_flags) ||
(op_is_sync(rq->cmd_flags) && req_op(rq) != REQ_OP_READ) ||
req_op(rq) == REQ_OP_FLUSH ||
op_is_discard(rq->cmd_flags)) {
rw = WRITE;
} else {
rw = READ;
}
} else {
rw = bio_data_dir(bio);
}
if (unlikely(zv->zv_flags & ZVOL_REMOVING)) {
zvol_end_io(bio, rq, SET_ERROR(ENXIO));