Whamcloud - gitweb
LU-4545 hsm: Always report errors to coordinator. 10/9310/2
authorHenri Doreau <henri.doreau@cea.fr>
Wed, 19 Feb 2014 14:49:41 +0000 (15:49 +0100)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 12 Mar 2014 15:05:28 +0000 (15:05 +0000)
Make sure feedback on processed items gets properly delivered to the
coordinator even if errors occur between action item delivery and
item processing initialization phase.

Signed-off-by: Henri Doreau <henri.doreau@cea.fr>
Change-Id: If1dfc88e4acb9fbd6bfb5b2d18ffdd4979944997
Reviewed-on: http://review.whamcloud.com/9310
Tested-by: Jenkins
Reviewed-by: jacques-Charles Lafoucriere <jacques-charles.lafoucriere@cea.fr>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Faccini Bruno <bruno.faccini@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/utils/lhsmtool_posix.c

index c057e68..d90b725 100644 (file)
@@ -789,8 +789,9 @@ static int ct_begin(struct hsm_copyaction_private **phcp,
 static int ct_fini(struct hsm_copyaction_private **phcp,
                   const struct hsm_action_item *hai, int hp_flags, int ct_rc)
 {
 static int ct_fini(struct hsm_copyaction_private **phcp,
                   const struct hsm_action_item *hai, int hp_flags, int ct_rc)
 {
-       char    lstr[PATH_MAX];
-       int     rc;
+       struct hsm_copyaction_private   *hcp;
+       char                             lstr[PATH_MAX];
+       int                              rc;
 
        CT_TRACE("Action completed, notifying coordinator "
                 "cookie="LPX64", FID="DFID", hp_flags=%d err=%d",
 
        CT_TRACE("Action completed, notifying coordinator "
                 "cookie="LPX64", FID="DFID", hp_flags=%d err=%d",
@@ -798,6 +799,17 @@ static int ct_fini(struct hsm_copyaction_private **phcp,
                 hp_flags, -ct_rc);
 
        ct_path_lustre(lstr, sizeof(lstr), opt.o_mnt, &hai->hai_fid);
                 hp_flags, -ct_rc);
 
        ct_path_lustre(lstr, sizeof(lstr), opt.o_mnt, &hai->hai_fid);
+
+       if (phcp == NULL || *phcp == NULL) {
+               rc = llapi_hsm_action_begin(&hcp, ctdata, hai, -1, 0, true);
+               if (rc < 0) {
+                       CT_ERROR(rc, "llapi_hsm_action_begin() on '%s' failed",
+                                lstr);
+                       return rc;
+               }
+               phcp = &hcp;
+       }
+
        rc = llapi_hsm_action_end(phcp, &hai->hai_extent, hp_flags, abs(ct_rc));
        if (rc == -ECANCELED)
                CT_ERROR(rc, "completed action on '%s' has been canceled: "
        rc = llapi_hsm_action_end(phcp, &hai->hai_extent, hp_flags, abs(ct_rc));
        if (rc == -ECANCELED)
                CT_ERROR(rc, "completed action on '%s' has been canceled: "
@@ -1047,8 +1059,7 @@ out:
        if (!(dst_fd < 0))
                close(dst_fd);
 
        if (!(dst_fd < 0))
                close(dst_fd);
 
-       if (hcp != NULL)
-               rc = ct_fini(&hcp, hai, hp_flags, rcf);
+       rc = ct_fini(&hcp, hai, hp_flags, rcf);
 
        return rc;
 }
 
        return rc;
 }
@@ -1145,8 +1156,7 @@ static int ct_restore(const struct hsm_action_item *hai, const long hal_flags)
        CT_TRACE("data restore from '%s' to '%s' done", src, dst);
 
 fini:
        CT_TRACE("data restore from '%s' to '%s' done", src, dst);
 
 fini:
-       if (hcp != NULL)
-               rc = ct_fini(&hcp, hai, hp_flags, rc);
+       rc = ct_fini(&hcp, hai, hp_flags, rc);
 
        /* object swaping is done by cdt at copy end, so close of volatile file
         * cannot be done before */
 
        /* object swaping is done by cdt at copy end, so close of volatile file
         * cannot be done before */
@@ -1196,23 +1206,7 @@ static int ct_remove(const struct hsm_action_item *hai, const long hal_flags)
        }
 
 fini:
        }
 
 fini:
-       if (hcp != NULL)
-               rc = ct_fini(&hcp, hai, 0, rc);
-
-       return rc;
-}
-
-static int ct_report_error(const struct hsm_action_item *hai, int flags,
-                          int errval)
-{
-       struct hsm_copyaction_private   *hcp;
-       int                              rc;
-
-       rc = llapi_hsm_action_begin(&hcp, ctdata, hai, -1, 0, true);
-       if (rc < 0)
-               return rc;
-
-       rc = llapi_hsm_action_end(&hcp, &hai->hai_extent, flags, abs(errval));
+       rc = ct_fini(&hcp, hai, 0, rc);
 
        return rc;
 }
 
        return rc;
 }
@@ -1265,7 +1259,7 @@ static int ct_process_item(struct hsm_action_item *hai, const long hal_flags)
                CT_ERROR(rc, "unknown action %d, on '%s'", hai->hai_action,
                         opt.o_mnt);
                err_minor++;
                CT_ERROR(rc, "unknown action %d, on '%s'", hai->hai_action,
                         opt.o_mnt);
                err_minor++;
-               ct_report_error(hai, 0, rc);
+               ct_fini(NULL, hai, 0, rc);
        }
 
        return 0;
        }
 
        return 0;