Commit f9d132a8 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Tomasz Zawadzki
Browse files

bdev/nvme: Use bio->io_path to simplify abort command



For I/O commands bio->io_path holds an io_path it is submitted to but
for admin commands bio->io_path is cleared.

If we use bio->io_path, we can call spdk_nvme_ctrlr_cmd_abort_ext() only
for bio->io_path when bio->io_path is not NULL or regard bio to be an
admin command if bio->io_path is NULL.

Signed-off-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Change-Id: I821f6040bb7617801f86ebc67bd47057239973e4
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17821


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
parent eeaac38a
Loading
Loading
Loading
Loading
+9 −19
Original line number Diff line number Diff line
@@ -7141,7 +7141,6 @@ bdev_nvme_abort(struct nvme_bdev_channel *nbdev_ch, struct nvme_bdev_io *bio,
		struct nvme_bdev_io *bio_to_abort)
{
	struct nvme_io_path *io_path;
	struct nvme_ctrlr *nvme_ctrlr;
	int rc = 0;

	rc = bdev_nvme_abort_retry_io(nbdev_ch, bio_to_abort);
@@ -7150,33 +7149,24 @@ bdev_nvme_abort(struct nvme_bdev_channel *nbdev_ch, struct nvme_bdev_io *bio,
		return;
	}

	rc = 0;

	/* Even admin commands, they were submitted to only nvme_ctrlrs which were
	 * on any io_path. So traverse the io_path list for not only I/O commands
	 * but also admin commands.
	 */
	STAILQ_FOREACH(io_path, &nbdev_ch->io_path_list, stailq) {
		nvme_ctrlr = io_path->qpair->ctrlr;

		rc = spdk_nvme_ctrlr_cmd_abort_ext(nvme_ctrlr->ctrlr,
	io_path = bio_to_abort->io_path;
	if (io_path != NULL) {
		rc = spdk_nvme_ctrlr_cmd_abort_ext(io_path->qpair->ctrlr->ctrlr,
						   io_path->qpair->qpair,
						   bio_to_abort,
						   bdev_nvme_abort_done, bio);
		if (rc == -ENOENT) {
			/* If no command was found in I/O qpair, the target command may be
			 * admin command.
			 */
			rc = spdk_nvme_ctrlr_cmd_abort_ext(nvme_ctrlr->ctrlr,
	} else {
		STAILQ_FOREACH(io_path, &nbdev_ch->io_path_list, stailq) {
			rc = spdk_nvme_ctrlr_cmd_abort_ext(io_path->qpair->ctrlr->ctrlr,
							   NULL,
							   bio_to_abort,
							   bdev_nvme_abort_done, bio);
		}

			if (rc != -ENOENT) {
				break;
			}
		}
	}

	if (rc != 0) {
		/* If no command was found or there was any error, complete the abort