Whamcloud - gitweb
LU-5252 hsm: Do not unconditionally delete the HSM event fifo 21/11421/2
authorJames Nunez <james.a.nunez@intel.com>
Tue, 12 Aug 2014 17:46:50 +0000 (11:46 -0600)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 18 Aug 2014 03:39:06 +0000 (03: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.

This is a back port to b2_5.

Lustre-change: http://review.whamcloud.com/10809
Lustre-commit: 7b7e6e2fb692eb3fa8d386addbc33763acf1a397

Signed-off-by: frank zago <fzago@cray.com>
Signed-off-by: James Nunez <james.a.nunez@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>
Change-Id: I66e44f21217228c5f425e5a9312d8e381d564c7f
Reviewed-on: http://review.whamcloud.com/11421
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
lustre/utils/liblustreapi_hsm.c

index c368038..5270a91 100644 (file)
@@ -115,6 +115,7 @@ enum ct_event {
 
 /* initialized in llapi_hsm_register_event_fifo() */
 int llapi_hsm_event_fd = -1;
+static bool created_hsm_event_fifo;
 
 static inline const char *llapi_hsm_ct_ev2str(int type)
 {
@@ -469,6 +470,8 @@ int llapi_hsm_register_event_fifo(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
@@ -517,7 +520,10 @@ int llapi_hsm_unregister_event_fifo(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;