Commit a29d7fdf authored by Anton Nayshtut's avatar Anton Nayshtut Committed by Konrad Sztyber
Browse files

fsdev/aio: aio_io_poll: correct return value



Change-Id: If2f0640a3d81f6a117d967c1c22aa028a85fd9e2
Signed-off-by: default avatarAnton Nayshtut <anayshtut@nvidia.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/25156


Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Reviewed-by: default avatarBen Walker <ben@nvidia.com>
parent a711f445
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -242,10 +242,11 @@ spdk_aio_mgr_cancel(struct spdk_aio_mgr *mgr, struct spdk_aio_mgr_io *aio)
	fsdev_aio_cancel(aio);
}

void
bool
spdk_aio_mgr_poll(struct spdk_aio_mgr *mgr)
{
	struct spdk_aio_mgr_io *aio, *tmp_aio;
	uint32_t num_completions = 0;
	TAILQ_FOREACH_SAFE(aio, &mgr->in_flight, link, tmp_aio) {
		struct spdk_aio_mgr_req *req, *tmp_req;
		TAILQ_FOREACH_SAFE(req, &aio->reqs, link, tmp_req) {
@@ -255,7 +256,7 @@ spdk_aio_mgr_poll(struct spdk_aio_mgr *mgr)
				break; /* stop checking completions for this aio */
			}

			if (!err) { /* the request completed successfull */
			if (!err) { /* the request completed successfully */
				;
			} else if (err == ECANCELED) { /* the request was canceled */
				SPDK_WARNLOG("aio processing was cancelled\n");
@@ -275,6 +276,7 @@ spdk_aio_mgr_poll(struct spdk_aio_mgr *mgr)
			/* the request processing is done */
			TAILQ_REMOVE(&aio->reqs, req, link); /* remove the req from the aio */
			TAILQ_INSERT_TAIL(&mgr->reqs.pool, req, link); /* return the req to the pool */
			num_completions++;
			if (TAILQ_EMPTY(&aio->reqs)) { /* all the aio's requests have been processed */
				SPDK_DEBUGLOG(spdk_aio_mgr_io, "aio=%p is done (data_size=%" PRIu32 ")\n", aio, aio->data_size);
				aio->clb(aio->ctx, aio->data_size, aio->err); /* call the user's callback */
@@ -283,6 +285,8 @@ spdk_aio_mgr_poll(struct spdk_aio_mgr *mgr)
			}
		}
	}

	return num_completions ? true : false;
}

void
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ struct spdk_aio_mgr_io *spdk_aio_mgr_read(struct spdk_aio_mgr *mgr, fsdev_aio_do
struct spdk_aio_mgr_io *spdk_aio_mgr_write(struct spdk_aio_mgr *mgr, fsdev_aio_done_cb clb,
		void *ctx, int fd, uint64_t offs, uint32_t size, const struct iovec *iovs, uint32_t iovcnt);
void spdk_aio_mgr_cancel(struct spdk_aio_mgr *mgr, struct spdk_aio_mgr_io *aio);
void spdk_aio_mgr_poll(struct spdk_aio_mgr *mgr);
bool spdk_aio_mgr_poll(struct spdk_aio_mgr *mgr); /* Returns true if it did some real work */
void spdk_aio_mgr_delete(struct spdk_aio_mgr *mgr);

#endif /* SPDK_AIO_MGR_H */
+6 −4
Original line number Diff line number Diff line
@@ -2005,19 +2005,21 @@ aio_io_poll(void *arg)
{
	struct aio_fsdev_io *vfsdev_io, *tmp;
	struct aio_io_channel *ch = arg;
	uint32_t num_completions = 0;
	int res = SPDK_POLLER_IDLE;

	spdk_aio_mgr_poll(ch->mgr);
	if (spdk_aio_mgr_poll(ch->mgr)) {
		res = SPDK_POLLER_BUSY;
	}

	TAILQ_FOREACH_SAFE(vfsdev_io, &ch->ios_to_complete, link, tmp) {
		struct spdk_fsdev_io *fsdev_io = aio_to_fsdev_io(vfsdev_io);

		TAILQ_REMOVE(&ch->ios_to_complete, vfsdev_io, link);
		spdk_fsdev_io_complete(fsdev_io, 0);
		num_completions++;
		res = SPDK_POLLER_BUSY;
	}

	return num_completions ? SPDK_POLLER_BUSY : SPDK_POLLER_IDLE;
	return res;
}

static int
+8 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ struct spdk_aio_mgr {
		uint32_t size;
		TAILQ_HEAD(, spdk_aio_mgr_io) pool;
	} aios;
	uint32_t num_completions;
};

static struct spdk_aio_mgr_io *
@@ -61,6 +62,8 @@ spdk_aio_mgr_io_cpl_cb(io_context_t ctx, struct iocb *iocb, long res, long res2)

	aio->clb(aio->ctx, res, -res2);

	aio->mgr->num_completions++;

	aio_mgr_put_aio(aio->mgr, aio);
}

@@ -174,15 +177,19 @@ spdk_aio_mgr_cancel(struct spdk_aio_mgr *mgr, struct spdk_aio_mgr_io *aio)
	}
}

void
bool
spdk_aio_mgr_poll(struct spdk_aio_mgr *mgr)
{
	int res;

	mgr->num_completions = 0;

	res = io_queue_run(mgr->io_ctx);
	if (res) {
		SPDK_WARNLOG("polling failed with err=%d\n", res);
	}

	return mgr->num_completions ? true : false;
}

void