nbd: Continue to read the socket even if the NBD status is not running
In order to make sure we do always response to the kernel module if there are valid commands in the socket. If we do not see this, we will see stuck request kernel info in nbd module. And the kernel will print the timeout message of nbd module again and again. Signed-off-by: Ziye Yang <ziye.yang@intel.com> Change-Id: I2ecc3e9c948231a712778f0126e2ecc6220e1d3c Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6276 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: <dongx.yi@intel.com> Reviewed-by: Xiaodong Liu <xiaodong.liu@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Community-CI: Mellanox Build Bot
This commit is contained in:
parent
e7f6ff2db6
commit
8e039ff3d2
@ -41,6 +41,7 @@
|
||||
#include "spdk/bdev.h"
|
||||
#include "spdk/endian.h"
|
||||
#include "spdk/env.h"
|
||||
#include "spdk/likely.h"
|
||||
#include "spdk/log.h"
|
||||
#include "spdk/util.h"
|
||||
#include "spdk/thread.h"
|
||||
@ -128,6 +129,8 @@ static void _nbd_fini(void *arg1);
|
||||
|
||||
static int
|
||||
nbd_submit_bdev_io(struct spdk_nbd_disk *nbd, struct nbd_io *io);
|
||||
static int
|
||||
nbd_io_recv_internal(struct spdk_nbd_disk *nbd);
|
||||
|
||||
int
|
||||
spdk_nbd_init(void)
|
||||
@ -341,6 +344,11 @@ nbd_io_xmit_check(struct spdk_nbd_disk *nbd)
|
||||
static int
|
||||
nbd_cleanup_io(struct spdk_nbd_disk *nbd)
|
||||
{
|
||||
int rc;
|
||||
|
||||
/* Try to read the remaining nbd commands in the socket */
|
||||
while ((rc = nbd_io_recv_internal(nbd)) > 0);
|
||||
|
||||
/* free io_in_recv */
|
||||
if (nbd->io_in_recv != NULL) {
|
||||
nbd_put_io(nbd, nbd->io_in_recv);
|
||||
@ -657,8 +665,12 @@ nbd_io_recv_internal(struct spdk_nbd_disk *nbd)
|
||||
io->state = NBD_IO_RECV_PAYLOAD;
|
||||
} else {
|
||||
io->state = NBD_IO_XMIT_RESP;
|
||||
if (spdk_likely(nbd->state == NBD_DISK_STATE_RUNNING)) {
|
||||
TAILQ_INSERT_TAIL(&nbd->received_io_list, io, tailq);
|
||||
} else {
|
||||
nbd_io_done(NULL, false, io);
|
||||
}
|
||||
nbd->io_in_recv = NULL;
|
||||
TAILQ_INSERT_TAIL(&nbd->received_io_list, io, tailq);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -678,8 +690,12 @@ nbd_io_recv_internal(struct spdk_nbd_disk *nbd)
|
||||
if (io->offset == io->payload_size) {
|
||||
io->offset = 0;
|
||||
io->state = NBD_IO_XMIT_RESP;
|
||||
if (spdk_likely(nbd->state == NBD_DISK_STATE_RUNNING)) {
|
||||
TAILQ_INSERT_TAIL(&nbd->received_io_list, io, tailq);
|
||||
} else {
|
||||
nbd_io_done(NULL, false, io);
|
||||
}
|
||||
nbd->io_in_recv = NULL;
|
||||
TAILQ_INSERT_TAIL(&nbd->received_io_list, io, tailq);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user