nbd: Make nbd_poll return real busy/idle status
Signed-off-by: Maciej Szwed <maciej.szwed@intel.com> Change-Id: Ibced4f525b1fb8f57d493358f5b60a2d4009b5ac Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3150 Reviewed-by: Jeffry Molanus <Jeffry.molanus@gmail.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Mellanox Build Bot
This commit is contained in:
parent
42f2f01a0e
commit
5550beb879
@ -546,6 +546,7 @@ static int
|
|||||||
nbd_io_exec(struct spdk_nbd_disk *nbd)
|
nbd_io_exec(struct spdk_nbd_disk *nbd)
|
||||||
{
|
{
|
||||||
struct nbd_io *io, *io_tmp;
|
struct nbd_io *io, *io_tmp;
|
||||||
|
int io_count = 0;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -561,12 +562,14 @@ nbd_io_exec(struct spdk_nbd_disk *nbd)
|
|||||||
TAILQ_REMOVE(&nbd->received_io_list, io, tailq);
|
TAILQ_REMOVE(&nbd->received_io_list, io, tailq);
|
||||||
ret = nbd_submit_bdev_io(nbd, io);
|
ret = nbd_submit_bdev_io(nbd, io);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
break;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
io_count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return io_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -574,6 +577,7 @@ nbd_io_recv_internal(struct spdk_nbd_disk *nbd)
|
|||||||
{
|
{
|
||||||
struct nbd_io *io;
|
struct nbd_io *io;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
int received = 0;
|
||||||
|
|
||||||
if (nbd->io_in_recv == NULL) {
|
if (nbd->io_in_recv == NULL) {
|
||||||
nbd->io_in_recv = nbd_get_io(nbd);
|
nbd->io_in_recv = nbd_get_io(nbd);
|
||||||
@ -594,6 +598,7 @@ nbd_io_recv_internal(struct spdk_nbd_disk *nbd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
io->offset += ret;
|
io->offset += ret;
|
||||||
|
received = ret;
|
||||||
|
|
||||||
/* request is fully received */
|
/* request is fully received */
|
||||||
if (io->offset == sizeof(io->req)) {
|
if (io->offset == sizeof(io->req)) {
|
||||||
@ -649,6 +654,7 @@ nbd_io_recv_internal(struct spdk_nbd_disk *nbd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
io->offset += ret;
|
io->offset += ret;
|
||||||
|
received += ret;
|
||||||
|
|
||||||
/* request payload is fully received */
|
/* request payload is fully received */
|
||||||
if (io->offset == io->payload_size) {
|
if (io->offset == io->payload_size) {
|
||||||
@ -660,13 +666,13 @@ nbd_io_recv_internal(struct spdk_nbd_disk *nbd)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return received;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
nbd_io_recv(struct spdk_nbd_disk *nbd)
|
nbd_io_recv(struct spdk_nbd_disk *nbd)
|
||||||
{
|
{
|
||||||
int i, ret = 0;
|
int i, rc, ret = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* nbd server should not accept request in both soft and hard
|
* nbd server should not accept request in both soft and hard
|
||||||
@ -677,13 +683,14 @@ nbd_io_recv(struct spdk_nbd_disk *nbd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < GET_IO_LOOP_COUNT; i++) {
|
for (i = 0; i < GET_IO_LOOP_COUNT; i++) {
|
||||||
ret = nbd_io_recv_internal(nbd);
|
rc = nbd_io_recv_internal(nbd);
|
||||||
if (ret != 0) {
|
if (rc < 0) {
|
||||||
return ret;
|
return rc;
|
||||||
}
|
}
|
||||||
|
ret += rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -691,6 +698,7 @@ nbd_io_xmit_internal(struct spdk_nbd_disk *nbd)
|
|||||||
{
|
{
|
||||||
struct nbd_io *io;
|
struct nbd_io *io;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
int sent = 0;
|
||||||
|
|
||||||
io = TAILQ_FIRST(&nbd->executed_io_list);
|
io = TAILQ_FIRST(&nbd->executed_io_list);
|
||||||
if (io == NULL) {
|
if (io == NULL) {
|
||||||
@ -713,6 +721,7 @@ nbd_io_xmit_internal(struct spdk_nbd_disk *nbd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
io->offset += ret;
|
io->offset += ret;
|
||||||
|
sent = ret;
|
||||||
|
|
||||||
/* response is fully transmitted */
|
/* response is fully transmitted */
|
||||||
if (io->offset == sizeof(io->resp)) {
|
if (io->offset == sizeof(io->resp)) {
|
||||||
@ -735,23 +744,25 @@ nbd_io_xmit_internal(struct spdk_nbd_disk *nbd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
io->offset += ret;
|
io->offset += ret;
|
||||||
|
sent += ret;
|
||||||
|
|
||||||
/* read payload is fully transmitted */
|
/* read payload is fully transmitted */
|
||||||
if (io->offset == io->payload_size) {
|
if (io->offset == io->payload_size) {
|
||||||
nbd_put_io(nbd, io);
|
nbd_put_io(nbd, io);
|
||||||
return 0;
|
return sent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reinsert:
|
reinsert:
|
||||||
TAILQ_INSERT_HEAD(&nbd->executed_io_list, io, tailq);
|
TAILQ_INSERT_HEAD(&nbd->executed_io_list, io, tailq);
|
||||||
return ret;
|
return ret < 0 ? ret : sent;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
nbd_io_xmit(struct spdk_nbd_disk *nbd)
|
nbd_io_xmit(struct spdk_nbd_disk *nbd)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
int rc;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For soft disconnection, nbd server must handle all outstanding
|
* For soft disconnection, nbd server must handle all outstanding
|
||||||
@ -762,10 +773,12 @@ nbd_io_xmit(struct spdk_nbd_disk *nbd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (!TAILQ_EMPTY(&nbd->executed_io_list)) {
|
while (!TAILQ_EMPTY(&nbd->executed_io_list)) {
|
||||||
ret = nbd_io_xmit_internal(nbd);
|
rc = nbd_io_xmit_internal(nbd);
|
||||||
if (ret != 0) {
|
if (rc < 0) {
|
||||||
return ret;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret += rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -776,7 +789,7 @@ nbd_io_xmit(struct spdk_nbd_disk *nbd)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -787,22 +800,25 @@ nbd_io_xmit(struct spdk_nbd_disk *nbd)
|
|||||||
static int
|
static int
|
||||||
_nbd_poll(struct spdk_nbd_disk *nbd)
|
_nbd_poll(struct spdk_nbd_disk *nbd)
|
||||||
{
|
{
|
||||||
int rc;
|
int received, sent, executed;
|
||||||
|
|
||||||
/* transmit executed io first */
|
/* transmit executed io first */
|
||||||
rc = nbd_io_xmit(nbd);
|
sent = nbd_io_xmit(nbd);
|
||||||
if (rc < 0) {
|
if (sent < 0) {
|
||||||
return rc;
|
return sent;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = nbd_io_recv(nbd);
|
received = nbd_io_recv(nbd);
|
||||||
if (rc < 0) {
|
if (received < 0) {
|
||||||
return rc;
|
return received;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = nbd_io_exec(nbd);
|
executed = nbd_io_exec(nbd);
|
||||||
|
if (executed < 0) {
|
||||||
|
return executed;
|
||||||
|
}
|
||||||
|
|
||||||
return rc;
|
return sent + received + executed;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -818,7 +834,7 @@ nbd_poll(void *arg)
|
|||||||
spdk_nbd_stop(nbd);
|
spdk_nbd_stop(nbd);
|
||||||
}
|
}
|
||||||
|
|
||||||
return SPDK_POLLER_BUSY;
|
return rc > 0 ? SPDK_POLLER_BUSY : SPDK_POLLER_IDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
|
Loading…
Reference in New Issue
Block a user