nbd: place mop-up ioctl to _nbd_stop

At present, close(dev_fd) is always executed before the
return of ioctl(nbd->dev_fd, NBD_DO_IT). So when executing
these 2 ioctl commands, dev_fd is already closed.

Change-Id: I6fce73c440972af91f662f24c1fbca51a7b95d61
Signed-off-by: Xiaodong Liu <xiaodong.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/391708
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Xiaodong Liu 2017-12-14 00:29:08 -05:00 committed by Daniel Verkamp
parent 122c7db7bf
commit 998feedb17

View File

@ -229,6 +229,8 @@ _nbd_stop(struct spdk_nbd_disk *nbd)
} }
if (nbd->dev_fd >= 0) { if (nbd->dev_fd >= 0) {
ioctl(nbd->dev_fd, NBD_CLEAR_QUE);
ioctl(nbd->dev_fd, NBD_CLEAR_SOCK);
close(nbd->dev_fd); close(nbd->dev_fd);
} }
@ -512,8 +514,7 @@ nbd_start_kernel(void *arg)
/* This will block in the kernel until we close the spdk_sp_fd. */ /* This will block in the kernel until we close the spdk_sp_fd. */
ioctl(dev_fd, NBD_DO_IT); ioctl(dev_fd, NBD_DO_IT);
ioctl(dev_fd, NBD_CLEAR_QUE);
ioctl(dev_fd, NBD_CLEAR_SOCK);
pthread_exit(NULL); pthread_exit(NULL);
} }