From: Nikitas Angelinas Date: Wed, 11 May 2022 22:54:08 +0000 (-0700) Subject: LU-15777 hsm: set changelog error for restore layout swap failure X-Git-Tag: 2.15.53~185 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=refs%2Fchanges%2F21%2F47121%2F14;p=fs%2Flustre-release.git LU-15777 hsm: set changelog error for restore layout swap failure Set the error code in the changelog record generated, if the layout swap fails at the end of an HSM restore operation. Also, handle error code overflow inside hsm_set_cl_error(), so that callers don't need to do this themselves. Suggested-by: Olaf Weber Suggested-by: Sergey Cheremencev Signed-off-by: Nikitas Angelinas Change-Id: I4ed2ebffa3bc1c6a0f87ea9f13734e344f77006f HPE-bug-id: LUS-10863 Test-Parameters: testlist=sanity-hsm,sanity-pcc Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/47121 Reviewed-by: Sergey Cheremencev Reviewed-by: Etienne AUJAMES Reviewed-by: Oleg Drokin Tested-by: jenkins Tested-by: Maloo --- diff --git a/lustre/include/uapi/linux/lustre/lustre_user.h b/lustre/include/uapi/linux/lustre/lustre_user.h index 341176f..83936dd 100644 --- a/lustre/include/uapi/linux/lustre/lustre_user.h +++ b/lustre/include/uapi/linux/lustre/lustre_user.h @@ -44,6 +44,8 @@ # define __USE_ISOC99 1 # include # include /* snprintf() */ +# include /* abs() */ +# include # include # define __USE_GNU 1 @@ -1720,11 +1722,19 @@ static inline int hsm_get_cl_error(enum changelog_rec_flags clf_flags) return CLF_GET_BITS(clf_flags, CLF_HSM_ERR_H, CLF_HSM_ERR_L); } -static inline void hsm_set_cl_error(enum changelog_rec_flags *clf_flags, - unsigned int error) +static inline int hsm_set_cl_error(enum changelog_rec_flags *clf_flags, + int error) { + /* In case a negative error is given */ + error = abs(error); + + if (error > CLF_HSM_MAXERROR) + error = CLF_HSM_ERROVERFLOW; + *clf_flags = (enum changelog_rec_flags) (*clf_flags | (error << CLF_HSM_ERR_L)); + + return error == CLF_HSM_ERROVERFLOW ? -EOVERFLOW : 0; } enum changelog_rec_extra_flags { diff --git a/lustre/mdt/mdt_coordinator.c b/lustre/mdt/mdt_coordinator.c index b321d94..239629a 100644 --- a/lustre/mdt/mdt_coordinator.c +++ b/lustre/mdt/mdt_coordinator.c @@ -39,6 +39,7 @@ #define DEBUG_SUBSYSTEM S_MDS #include +#include #include #include #include @@ -1478,16 +1479,12 @@ static int hsm_cdt_request_completed(struct mdt_thread_info *mti, break; } - if (pgs->hpk_errval > CLF_HSM_MAXERROR) { - CERROR("%s: Request %#llx on "DFID - " failed, error code %d too large\n", - mdt_obd_name(mdt), - pgs->hpk_cookie, PFID(&pgs->hpk_fid), - pgs->hpk_errval); - hsm_set_cl_error(&clf_flags, CLF_HSM_ERROVERFLOW); - rc = -EINVAL; - } else { - hsm_set_cl_error(&clf_flags, pgs->hpk_errval); + rc = hsm_set_cl_error(&clf_flags, pgs->hpk_errval); + if (rc == -EOVERFLOW) { + CERROR("%s: Request %#llx on "DFID" failed, error code %d too large\n", + mdt_obd_name(mdt), pgs->hpk_cookie, + PFID(&pgs->hpk_fid), (int)abs(pgs->hpk_errval)); + rc = 0; } switch (car->car_hai->hai_action) { @@ -1592,6 +1589,7 @@ static int hsm_cdt_request_completed(struct mdt_thread_info *mti, if (cdt->cdt_policy & CDT_NORETRY_ACTION) *status = ARS_FAILED; pgs->hpk_errval = -rc; + hsm_set_cl_error(&clf_flags, pgs->hpk_errval); } } /* we have to retry, so keep layout lock */