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>
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",
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: "
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);
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 */
- 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);
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);