From: Henri Doreau Date: Wed, 19 Feb 2014 14:49:41 +0000 (+0100) Subject: LU-4545 hsm: Always report errors to coordinator. X-Git-Tag: 2.5.1-crt1~22 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=refs%2Fchanges%2F08%2F9708%2F3;p=fs%2Flustre-release.git LU-4545 hsm: Always report errors to coordinator. 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. Lustre commit: 344a261080d462c29cf45b075deacf793c92e197 Lustre change: http://review.whamcloud.com/9310 Change-Id: I9b79f049728d011480dd86ef6baa23e39a124634 Signed-off-by: Henri Doreau Reviewed-on: http://review.whamcloud.com/9708 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: jacques-Charles Lafoucriere Reviewed-by: Oleg Drokin --- diff --git a/lustre/utils/lhsmtool_posix.c b/lustre/utils/lhsmtool_posix.c index 860b594..812245d 100644 --- a/lustre/utils/lhsmtool_posix.c +++ b/lustre/utils/lhsmtool_posix.c @@ -787,8 +787,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) { - 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", @@ -796,6 +797,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); + + 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: " @@ -1039,8 +1051,7 @@ out: 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; } @@ -1137,8 +1148,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: - 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 */ @@ -1188,23 +1198,7 @@ static int ct_remove(const struct hsm_action_item *hai, const long hal_flags) } 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; } @@ -1257,7 +1251,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_report_error(hai, 0, rc); + ct_fini(NULL, hai, 0, rc); } return 0;