lkml.org 
[lkml]   [2013]   [Nov]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 08/39] staging/lustre/libcfs: improve validity test for valid file descriptors
Date
From: Bob Glossman <bob.glossman@intel.com>

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 <bob.glossman@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Keith Mannthey <keith.mannthey@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: Peng Tao <bergwolf@gmail.com>
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
---
.../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


\
 
 \ /
  Last update: 2013-11-14 19:01    [W:0.115 / U:0.520 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site