Whamcloud - gitweb
LU-5252: Do not unconditionally delete the HSM event fifo 09/10809/4
authorFrank Zago <fzago@cray.com>
Fri, 20 Jun 2014 17:23:26 +0000 (12:23 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Sun, 20 Jul 2014 18:39:00 +0000 (18:39 +0000)
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 <fzago@cray.com>
Reviewed-on: http://review.whamcloud.com/10809
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Patrick Farrell <paf@cray.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/utils/liblustreapi_hsm.c

index c9b4d53..4fe6ca4 100644 (file)
@@ -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;