From: Bob Glossman <[email protected]> File descriptor members of struct lustre_kernelcomm aren't set to anything special at start time. This leads to incorrect tests and skipping valid fd closes at stop time. Fixed by defining, setting, and testing against a specific LK_NOFD value.
Lustre-change: http://review.whamcloud.com/7275 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3683 Signed-off-by: Bob Glossman <[email protected]> Reviewed-by: John L. Hammond <[email protected]> Reviewed-by: Keith Mannthey <[email protected]> Reviewed-by: Oleg Drokin <[email protected]> Signed-off-by: Peng Tao <[email protected]> Signed-off-by: Andreas Dilger <[email protected]> --- .../include/linux/libcfs/libcfs_kernelcomm.h | 1 + .../lustre/lustre/libcfs/kernel_user_comm.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_kernelcomm.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_kernelcomm.h index 596a15f..4e12ffc 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_kernelcomm.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_kernelcomm.h @@ -97,6 +97,7 @@ extern int libcfs_kkuc_group_foreach(int group, libcfs_kkuc_cb_t cb_func, void *cb_arg); #define LK_FLG_STOP 0x01 +#define LK_NOFD -1U /* kernelcomm control structure, passed from userspace to kernel */ typedef struct lustre_kernelcomm { diff --git a/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c b/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c index 74a0db5..9e5e3cc 100644 --- a/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c +++ b/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c @@ -56,6 +56,8 @@ int libcfs_ukuc_start(lustre_kernelcomm *link, int group) { int pfd[2]; + link->lk_rfd = link->lk_wfd = LK_NOFD; + if (pipe(pfd) < 0) return -errno; @@ -69,9 +71,13 @@ int libcfs_ukuc_start(lustre_kernelcomm *link, int group) int libcfs_ukuc_stop(lustre_kernelcomm *link) { - if (link->lk_wfd > 0) + int rc; + + if (link->lk_wfd != LK_NOFD) close(link->lk_wfd); - return close(link->lk_rfd); + rc = close(link->lk_rfd); + link->lk_rfd = link->lk_wfd = LK_NOFD; + return rc; } #define lhsz sizeof(*kuch) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/

