lib/nvme: cuse device avoid using signals

This patch uses lowlevel fuse functions to process messages to
eliminate the need to use signals to interrupt blocking read
operation in fuse_session_loop().

  Fixes #1032

Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/473233 (master)

(cherry picked from commit 88808c5ab7)
Change-Id: Ie9c9ea76cc135c383f5757864aa2d84ac9eb3da3
Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/478348
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Tomasz Kulasek 2019-11-04 18:06:46 +01:00 committed by Tomasz Zawadzki
parent 1c8d673f75
commit 848927d96a
2 changed files with 49 additions and 3 deletions

View File

@ -623,6 +623,10 @@ cuse_thread(void *arg)
const char *dev_info_argv[] = { devname_arg };
struct cuse_info ci;
int multithreaded;
int rc;
struct fuse_buf buf = { .mem = NULL };
struct pollfd fds;
int timeout_msecs = 500;
spdk_unaffinitize_thread();
@ -646,7 +650,22 @@ cuse_thread(void *arg)
}
SPDK_NOTICELOG("fuse session for device %s created\n", cuse_device->dev_name);
fuse_session_loop(cuse_device->session);
/* Receive and process fuse requests */
fds.fd = fuse_session_fd(cuse_device->session);
fds.events = POLLIN;
while (!fuse_session_exited(cuse_device->session)) {
rc = poll(&fds, 1, timeout_msecs);
if (rc <= 0) {
continue;
}
rc = fuse_session_receive_buf(cuse_device->session, &buf);
if (rc > 0) {
fuse_session_process_buf(cuse_device->session, &buf);
}
}
free(buf.mem);
fuse_session_reset(cuse_device->session);
end:
cuse_lowlevel_teardown(cuse_device->session);
@ -691,14 +710,12 @@ cuse_nvme_ctrlr_stop(struct cuse_device *ctrlr_device)
TAILQ_FOREACH_SAFE(ns_device, &ctrlr_device->ns_devices, tailq, tmp) {
fuse_session_exit(ns_device->session);
pthread_kill(ns_device->tid, SIGHUP);
pthread_join(ns_device->tid, NULL);
TAILQ_REMOVE(&ctrlr_device->ns_devices, ns_device, tailq);
free(ns_device);
}
fuse_session_exit(ctrlr_device->session);
pthread_kill(ctrlr_device->tid, SIGHUP);
pthread_join(ctrlr_device->tid, NULL);
TAILQ_REMOVE(&g_ctrlr_ctx_head, ctrlr_device, tailq);
free(ctrlr_device);

View File

@ -23,6 +23,10 @@ $rpc_py bdev_nvme_cuse_register -n Nvme0 -p spdk/nvme0
sleep 5
if [ ! -c /dev/spdk/nvme0 ]; then
return 1
fi
$rpc_py bdev_get_bdevs
$rpc_py bdev_nvme_get_controllers
@ -43,6 +47,31 @@ for ctrlr in $(ls /dev/spdk/nvme?); do
${NVME_CMD} reset $ctrlr
done
if [ ! -c /dev/spdk/nvme0 ]; then
return 1
fi
$rpc_py bdev_nvme_cuse_unregister -n Nvme0
sleep 1
if [ -c /dev/spdk/nvme0 ]; then
return 1
fi
$rpc_py bdev_nvme_cuse_register -n Nvme0 -p spdk/nvme1
sleep 1
if [ ! -c /dev/spdk/nvme1 ]; then
return 1
fi
$rpc_py bdev_nvme_cuse_unregister -n Nvme0
sleep 1
if [ -c /dev/spdk/nvme1 ]; then
return 1
fi
$rpc_py bdev_nvme_detach_controller Nvme0
trap - SIGINT SIGTERM EXIT
kill $spdk_tgt_pid