Skip to contentSkip to conversation

selftests: ublk: fix write cache implementation

PATCH Applied Ming Lei 2 participants 2 messages Mar 21, 2025

Subsystems (3)
lore
Share & tools
lore

Ming Lei

author
#0 lore raw

PATCH 1/1 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.

---
 tools/testing/selftests/ublk/file_backed.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
tools/testing/selftests/ublk/file_backed.c +2 -4
index 38e68b414962..8a07356eccaf 100644
@@ -123,10 +123,7 @@ static int loop_queue_tgt_io(struct ublk_queue *q, int tag)
 		sqe = ublk_queue_alloc_sqe(q);
 		if (!sqe)
 			return -ENOMEM;
-		io_uring_prep_sync_file_range(sqe, 1 /*fds[1]*/,
-				iod->nr_sectors << 9,
-				iod->start_sector << 9,
-				IORING_FSYNC_DATASYNC);
+		io_uring_prep_fsync(sqe, 1 /*fds[1]*/, IORING_FSYNC_DATASYNC);
 		io_uring_sqe_set_flags(sqe, IOSQE_FIXED_FILE);
 		q->io_inflight++;
 		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)
 	struct ublk_params p = {
 		.types = UBLK_PARAM_TYPE_BASIC | UBLK_PARAM_TYPE_DMA_ALIGN,
 		.basic = {
+			.attrs = UBLK_ATTR_VOLATILE_CACHE,
 			.logical_bs_shift	= 9,
 			.physical_bs_shift	= 12,
 			.io_opt_shift	= 12,
Signature · 1 line
2.47.1
maintainer Applied
#1 lore raw
Quoted 8 lines · Ming Lei

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.

[...]

Applied, thanks!

[1/1] selftests: ublk: fix write cache implementation

      commit: 96af5af47b5407972689929543c73a39b477c8ba

Best regards,

Signature · 1 line
Jens Axboe