Commit 4d5c4b46 authored by Yalong Wang's avatar Yalong Wang Committed by Tomasz Zawadzki
Browse files

lib/bdev: add dep_unblock flag in bdev_io_wait_entry



When a bdev I/O submission fails with -ENOMEM,
the request is queued in the bdev I/O wait list.
In certain cases, this I/O must be completed first
to unblock other dependent I/Os already in progress,
such as in RAID or layered bdev scenarios.

Add a new boolean field 'dep_unblock' to struct
spdk_bdev_io_wait_entry to mark such high-priority
requests. If set, the request is inserted at the
head of the wait queue instead of the tail,
allowing it to get resources earlier and
prevent potential deadlock.

Change-Id: I7892473f9a07e948c24f595ff2cf4a4bffce1543
Signed-off-by: default avatarYalong Wang <yalong9@staff.sina.com.cn>
Reviewed-on: https://review.spdk.io/c/spdk/spdk/+/26451


Tested-by: default avatarSPDK Automated Test System <spdkbot@gmail.com>
Reviewed-by: default avatarArtur Paszkiewicz <artur.paszkiewicz@solidigm.com>
Reviewed-by: default avatarChangpeng Liu <changpeliu@tencent.com>
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Community-CI: Mellanox Build Bot
parent 4e096d4e
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -2117,6 +2117,14 @@ struct spdk_bdev_io_wait_entry {
	struct spdk_bdev			*bdev;
	spdk_bdev_io_wait_cb			cb_fn;
	void					*cb_arg;
	/**
	 * When true, this I/O is critical to unblock other I/Os that
	 * holding resource and depend on the completion of this IO.
	 * If resource allocation fails such as ENOMEM,
	 * this entry should be queued at the head to avoid deadlock.
	 */
	bool					dep_unblock;
	uint8_t					pad[7];
	TAILQ_ENTRY(spdk_bdev_io_wait_entry)	link;
};

+1 −0
Original line number Diff line number Diff line
@@ -1129,6 +1129,7 @@ struct spdk_bdev_io {
	 *  must not read or write to these fields.
	 */
	struct spdk_bdev_io_internal_fields internal;
	uint8_t reserved4[56];

	/**
	 * Per I/O context for use by the bdev module.
+1 −1
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ struct spdk_nvmf_request {
	uint64_t timeout_tsc;
	uint32_t			orig_nsid;
};
SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_request) == 816, "Incorrect size");
SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_request) == 824, "Incorrect size");

enum spdk_nvmf_qpair_state {
	SPDK_NVMF_QPAIR_UNINITIALIZED = 0,
+6 −1
Original line number Diff line number Diff line
@@ -4003,6 +4003,7 @@ bdev_io_init(struct spdk_bdev_io *bdev_io,
	bdev_io->internal.get_buf_cb = NULL;
	bdev_io->internal.get_aux_buf_cb = NULL;
	bdev_io->internal.data_transfer_cpl = NULL;
	bdev_io->internal.waitq_entry.dep_unblock = false;
	bdev_io->internal.f.split = bdev_io_should_split(bdev_io);
}

@@ -7574,7 +7575,11 @@ spdk_bdev_queue_io_wait(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
		return -EINVAL;
	}

	if (entry->dep_unblock) {
		TAILQ_INSERT_HEAD(&mgmt_ch->io_wait_queue, entry, link);
	} else {
		TAILQ_INSERT_TAIL(&mgmt_ch->io_wait_queue, entry, link);
	}
	return 0;
}