Whamcloud - gitweb
LU-5095 hsm: Allow receiving messages to be non-blocking 20/11220/3
authorFrank Zago <fzago@cray.com>
Wed, 2 Jul 2014 16:35:18 +0000 (11:35 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 29 Aug 2014 02:28:04 +0000 (02:28 +0000)
commit211241377b543abb456b740dfda95b381798cbff
tree6b95fa6d98291526252a0c8ac913b7bf8bfe6c3e
parent7d0912488c7aadee5dba26227750f4581aacdca1
LU-5095 hsm: Allow receiving messages to be non-blocking

When using the HSM API for a copy tool, it's impossible to
properly exit an application because one thread might be
stuck in llapi_hsm_copytool_recv(), which in turn blocks
forever on a read.

So this patch expands the existing Lustre userspace HSM API
to be able to apply flags to the read side of the
communication pipe, so it can be opened with O_NONBLOCK,
and gives access to the pipe file descriptor used. (read side)

So now a program can do a poll/select, and then call
llapi_hsm_copytool_recv without blocking.

Notes: The flags passed in from the copy tool to
llapi_hsm_copytool_register are applied to the read side of
the pipe using fcntl, because we do not want to apply
the same flags to the read and write sides of the pipe.

No functionality is added for setting flags on the write
side of the pipe, since the kernel expects particular
behavior from that side of the pipe, and it seems unwise
to let user space modify it.

Additionally, this patch changes llapi_hsm_copytool_recv to
not return -EAGAIN when it finds a message for an archive
not serviced by that copytool.

Instead of returning -EAGAIN to the copy tool, which just
restarts the receive operation, this patch just loops inside
the recv function.

This is because this -EAGAIN conflicts with -EAGAIN
returned from the call to libcfs_ukuc_msg_get
which can occur when O_NONBLOCK is set.

This is a backport to b2_5

Lustre-change: http://review.whamcloud.com/10393
Lustre-commit: 35b3a429d1915ec147f01a42c4ec0526b887d1c7

Signed-off-by: Patrick Farrell <paf@cray.com>
Signed-off-by: James Nunez <james.a.nunez@intel.com>
Change-Id: I3e611d3c259de9a8c30f3939fb5e48ab88210c2e
Reviewed-on: http://review.whamcloud.com/11220
Reviewed-by: frank zago <fzago@cray.com>
Tested-by: Jenkins
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
libcfs/include/libcfs/libcfs_kernelcomm.h
libcfs/libcfs/kernel_user_comm.c
lustre/include/lustre/lustreapi.h
lustre/utils/lhsmtool_posix.c
lustre/utils/liblustreapi.c
lustre/utils/liblustreapi_hsm.c