Whamcloud - gitweb
LU-15777 hsm: set changelog error for restore layout swap failure 21/47121/14
authorNikitas Angelinas <nikitas.angelinas@hpe.com>
Wed, 11 May 2022 22:54:08 +0000 (15:54 -0700)
committerOleg Drokin <green@whamcloud.com>
Tue, 4 Oct 2022 19:35:22 +0000 (19:35 +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.

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-on: https://review.whamcloud.com/c/fs/lustre-release/+/47121
Reviewed-by: Sergey Cheremencev <sergey.cheremencev@hpe.com>
Reviewed-by: Etienne AUJAMES <eaujames@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/include/uapi/linux/lustre/lustre_user.h
lustre/mdt/mdt_coordinator.c

index 341176f..83936dd 100644 (file)
@@ -44,6 +44,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
@@ -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 {
index b321d94..239629a 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>
@@ -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 */