lib/nbd: Set the O_NONBLOCK flag for kernel_sp_fd
Change-Id: I656be9023d7e0ccd86d1c8fbac3e2848ce61a772 Signed-off-by: Ziye Yang <ziye.yang@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5733 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: <dongx.yi@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
parent
a1d4a714b2
commit
42580f7e15
@ -968,10 +968,21 @@ nbd_enable_kernel(void *arg)
|
||||
{
|
||||
struct spdk_nbd_start_ctx *ctx = arg;
|
||||
int rc;
|
||||
int flag;
|
||||
|
||||
/* Declare device setup by this process */
|
||||
rc = ioctl(ctx->nbd->dev_fd, NBD_SET_SOCK, ctx->nbd->kernel_sp_fd);
|
||||
if (rc == -1) {
|
||||
|
||||
if (!rc) {
|
||||
flag = fcntl(ctx->nbd->kernel_sp_fd, F_GETFL);
|
||||
rc = fcntl(ctx->nbd->kernel_sp_fd, F_SETFL, flag | O_NONBLOCK);
|
||||
if (rc < 0) {
|
||||
SPDK_ERRLOG("fcntl can't set nonblocking mode for socket, fd: %d (%s)\n",
|
||||
ctx->nbd->kernel_sp_fd, spdk_strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
if (rc) {
|
||||
if (errno == EBUSY && ctx->polling_count-- > 0) {
|
||||
if (ctx->poller == NULL) {
|
||||
ctx->poller = SPDK_POLLER_REGISTER(nbd_enable_kernel, ctx,
|
||||
|
Loading…
x
Reference in New Issue
Block a user