Whamcloud - gitweb
LU-5385: HSM: do not call the JSON log function if no log is open 64/11164/2
authorFrank Zago <fzago@cray.com>
Sat, 19 Jul 2014 14:21:10 +0000 (09:21 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 27 Aug 2014 01:42:44 +0000 (01:42 +0000)
llapi_hsm_log_ct_registration() and llapi_hsm_log_ct_progress() are
very expensive (fid2path+allocations). Do not let them do anything
if llapi_hsm_write_json_event() is going to discard the JSON record.

Make llapi_hsm_log_ct_registration() and llapi_hsm_log_ct_progress()
static too.

Signed-off-by: frank zago <fzago@cray.com>
Change-Id: Ib10023968a1bd021694bca6338c0a962f58da19a
Reviewed-on: http://review.whamcloud.com/11164
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: jacques-Charles Lafoucriere <jacques-charles.lafoucriere@cea.fr>
Reviewed-by: Patrick Farrell <paf@cray.com>
Reviewed-by: Faccini Bruno <bruno.faccini@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/utils/liblustreapi_hsm.c

index 4fe6ca4..09b537f 100644 (file)
@@ -171,7 +171,7 @@ static inline const char *llapi_hsm_ct_ev2str(int type)
  * \retval 0 on success.
  * \retval -errno on error.
  */
-int llapi_hsm_write_json_event(struct llapi_json_item_list **event)
+static int llapi_hsm_write_json_event(struct llapi_json_item_list **event)
 {
        int                             rc;
        char                            time_string[40];
@@ -239,14 +239,18 @@ int llapi_hsm_write_json_event(struct llapi_json_item_list **event)
  * \retval 0 on success.
  * \retval -errno on error.
  */
-int llapi_hsm_log_ct_registration(struct hsm_copytool_private **priv,
-                                 __u32 event_type)
+static int llapi_hsm_log_ct_registration(struct hsm_copytool_private **priv,
+                                        __u32 event_type)
 {
        int                             rc;
        char                            agent_uuid[UUID_MAX];
        struct hsm_copytool_private     *ct;
        struct llapi_json_item_list     *json_items;
 
+       /* Noop unless the event fd was initialized */
+       if (llapi_hsm_event_fd < 0)
+               return 0;
+
        if (priv == NULL || *priv == NULL)
                return -EINVAL;
 
@@ -344,9 +348,10 @@ out_free:
  * \retval 0 on success.
  * \retval -errno on error.
  */
-int llapi_hsm_log_ct_progress(struct hsm_copyaction_private **phcp,
-                   const struct hsm_action_item *hai, __u32 progress_type,
-                   __u64 total, __u64 current)
+static int llapi_hsm_log_ct_progress(struct hsm_copyaction_private **phcp,
+                                    const struct hsm_action_item *hai,
+                                    __u32 progress_type,
+                                    __u64 total, __u64 current)
 {
        int                             rc;
        int                             linkno = 0;
@@ -356,6 +361,10 @@ int llapi_hsm_log_ct_progress(struct hsm_copyaction_private **phcp,
        struct hsm_copyaction_private   *hcp;
        struct llapi_json_item_list     *json_items;
 
+       /* Noop unless the event fd was initialized */
+       if (llapi_hsm_event_fd < 0)
+               return 0;
+
        if (phcp == NULL || *phcp == NULL)
                return -EINVAL;