Skip to content

Commit 96af5af

Browse files
Ming Leiaxboe
authored andcommitted
selftests: ublk: fix write cache implementation
For loop target, write cache isn't enabled, and each write isn't be marked as DSYNC too. Fix it by enabling write cache, meantime fix FLUSH implementation by not taking LBA range into account, and there isn't such info for FLUSH command. Signed-off-by: Ming Lei <ming.lei@redhat.com> Link: https://lore.kernel.org/r/20250321004758.152572-1-ming.lei@redhat.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent beb3198 commit 96af5af

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

tools/testing/selftests/ublk/file_backed.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,7 @@ static int loop_queue_tgt_io(struct ublk_queue *q, int tag)
123123
sqe = ublk_queue_alloc_sqe(q);
124124
if (!sqe)
125125
return -ENOMEM;
126-
io_uring_prep_sync_file_range(sqe, 1 /*fds[1]*/,
127-
iod->nr_sectors << 9,
128-
iod->start_sector << 9,
129-
IORING_FSYNC_DATASYNC);
126+
io_uring_prep_fsync(sqe, 1 /*fds[1]*/, IORING_FSYNC_DATASYNC);
130127
io_uring_sqe_set_flags(sqe, IOSQE_FIXED_FILE);
131128
q->io_inflight++;
132129
sqe->user_data = build_user_data(tag, ublk_op, UBLK_IO_TGT_NORMAL, 1);
@@ -187,6 +184,7 @@ static int ublk_loop_tgt_init(struct ublk_dev *dev)
187184
struct ublk_params p = {
188185
.types = UBLK_PARAM_TYPE_BASIC | UBLK_PARAM_TYPE_DMA_ALIGN,
189186
.basic = {
187+
.attrs = UBLK_ATTR_VOLATILE_CACHE,
190188
.logical_bs_shift = 9,
191189
.physical_bs_shift = 12,
192190
.io_opt_shift = 12,

0 commit comments

Comments
 (0)