Whamcloud - gitweb
LU-15777 hsm: set changelog error for restore layout swap failure
authorNikitas Angelinas <nikitas.angelinas@hpe.com>
Wed, 11 May 2022 22:54:08 +0000 (15:54 -0700)
committerAndreas Dilger <adilger@whamcloud.com>
Fri, 24 Nov 2023 09:25:50 +0000 (09:25 +0000)
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.

Lustre-change: https://review.whamcloud.com/47121
Lustre-commit: 09fe64719b888cd212b6cffe923545b7650f230f

Suggested-by: Olaf Weber <olaf.weber@hpe.com>
Suggested-by: Sergey Cheremencev <sergey.cheremencev@hpe.com>
Signed-off-by: Nikitas Angelinas <nikitas.angelinas@hpe.com>
Change-Id: I4ed2ebffa3bc1c6a0f87ea9f13734e344f77006f
HPE-bug-id: LUS-10863
Test-Parameters: testlist=sanity-hsm,sanity-pcc
Reviewed-by: Sergey Cheremencev <sergey.cheremencev@hpe.com>
Reviewed-by: Etienne AUJAMES <eaujames@ddn.com>
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/53213
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/include/uapi/linux/lustre/lustre_user.h
lustre/mdt/mdt_coordinator.c

index 103fcbe..2446a51 100644 (file)
@@ -45,6 +45,8 @@
 # define __USE_ISOC99  1
 # include <stdbool.h>
 # include <stdio.h> /* snprintf() */
+# include <stdlib.h> /* abs() */
+# include <errno.h>
 # include <sys/stat.h>
 
 # define __USE_GNU      1
@@ -1770,11 +1772,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 {
index 455778b..d17215f 100644 (file)
@@ -39,6 +39,7 @@
 #define DEBUG_SUBSYSTEM S_MDS
 
 #include <linux/kthread.h>
+#include <linux/kernel.h>
 #include <obd_support.h>
 #include <lustre_export.h>
 #include <obd.h>
@@ -1476,16 +1477,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) {
@@ -1590,6 +1587,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 */