From 7b7e6e2fb692eb3fa8d386addbc33763acf1a397 Mon Sep 17 00:00:00 2001 From: Frank Zago Date: Fri, 20 Jun 2014 12:23:26 -0500 Subject: [PATCH] LU-5252: Do not unconditionally delete the HSM event fifo The lustreapi HSM library will use a pipe if it already exists. However the deregistration will unconditionally delete that pipe, which is not correct. An admin may want to create the pipe with certain rights/ownership, which the llapi_hsm_register_event_fifo() doesn't allow. In that case, llapi_hsm_unregister_event_fifo() should not delete it. Change-Id: I487f6efea06c6f6bc88b2f838153c0239e369461 Signed-off-by: frank zago Reviewed-on: http://review.whamcloud.com/10809 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: John L. Hammond Reviewed-by: Patrick Farrell Reviewed-by: Oleg Drokin --- lustre/utils/liblustreapi_hsm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lustre/utils/liblustreapi_hsm.c b/lustre/utils/liblustreapi_hsm.c index c9b4d53..4fe6ca4 100644 --- a/lustre/utils/liblustreapi_hsm.c +++ b/lustre/utils/liblustreapi_hsm.c @@ -115,6 +115,7 @@ enum ct_event { /* initialized in llapi_hsm_register_event_fifo() */ static int llapi_hsm_event_fd = -1; +static bool created_hsm_event_fifo; static inline const char *llapi_hsm_ct_ev2str(int type) { @@ -481,6 +482,8 @@ int llapi_hsm_register_event_fifo(const char *path) "not a pipe or has a wrong mode", path); return -errno; } + } else { + created_hsm_event_fifo = true; } /* Open the FIFO for read so that the subsequent open for write @@ -529,7 +532,10 @@ int llapi_hsm_unregister_event_fifo(const char *path) if (close(llapi_hsm_event_fd) < 0) return -errno; - unlink(path); + if (created_hsm_event_fifo) { + unlink(path); + created_hsm_event_fifo = false; + } llapi_hsm_event_fd = -1; -- 1.8.3.1