Whamcloud - gitweb
LU-15146 mdt: mdt_lvb2reply crash fix 34/45334/3
authorAlexander Zarochentsev <c17826@cray.com>
Thu, 12 Nov 2020 16:47:36 +0000 (19:47 +0300)
committerOleg Drokin <green@whamcloud.com>
Wed, 3 Nov 2021 02:37:39 +0000 (02:37 +0000)
mdt_lvb2body may crash if res->lr_lvb_data is
not allocated, make it tolerant to not initialized
lvb_data pointer.

HPE-bug-id: LUS-9549
Signed-off-by: Alexander Zarochentsev <alexander.zarochentsev@hpe.com>
Change-Id: Ie31cbba9187f9b04b3d1f8d2abc59e0612a44b41
Reviewed-on: https://review.whamcloud.com/45334
Reviewed-by: Mike Pershin <mpershin@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andrew Perepechko <andrew.perepechko@hpe.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/mdt/mdt_io.c
lustre/mdt/mdt_lvb.c

index a0ae1b5..bf80be4 100644 (file)
@@ -1280,19 +1280,21 @@ static void mdt_lvb2reply(struct ldlm_resource *res, struct mdt_body *mb,
 
        lock_res(res);
        res_lvb = res->lr_lvb_data;
-       if (lvb)
-               *lvb = *res_lvb;
-
-       if (mb) {
-               mb->mbo_dom_size = res_lvb->lvb_size;
-               mb->mbo_dom_blocks = res_lvb->lvb_blocks;
-               mb->mbo_mtime = res_lvb->lvb_mtime;
-               mb->mbo_ctime = res_lvb->lvb_ctime;
-               mb->mbo_atime = res_lvb->lvb_atime;
-               mb->mbo_valid |= OBD_MD_FLATIME | OBD_MD_FLCTIME |
-                                OBD_MD_FLMTIME | OBD_MD_DOM_SIZE;
+       if (res_lvb) {
+               if (lvb)
+                       *lvb = *res_lvb;
+
+               if (mb) {
+                       mb->mbo_dom_size = res_lvb->lvb_size;
+                       mb->mbo_dom_blocks = res_lvb->lvb_blocks;
+                       mb->mbo_mtime = res_lvb->lvb_mtime;
+                       mb->mbo_ctime = res_lvb->lvb_ctime;
+                       mb->mbo_atime = res_lvb->lvb_atime;
+                       mb->mbo_valid |= OBD_MD_FLATIME | OBD_MD_FLCTIME |
+                                        OBD_MD_FLMTIME | OBD_MD_DOM_SIZE;
+               }
+               CDEBUG(D_DLMTRACE, "size %llu\n", res_lvb->lvb_size);
        }
-       CDEBUG(D_DLMTRACE, "size %llu\n", res_lvb->lvb_size);
        unlock_res(res);
 }
 
index 0e6079b..729cb8e 100644 (file)
@@ -155,13 +155,10 @@ int mdt_dom_lvbo_update(struct ldlm_resource *res, struct ldlm_lock *lock,
        ENTRY;
 
        /* Before going further let's check that OBD and export are healthy.
+        * The condition matches one in ptlrpc_send_reply()
         */
-       if (exp != NULL &&
-           (exp->exp_disconnected || exp->exp_failed ||
-            exp->exp_obd->obd_stopping)) {
-               CDEBUG(D_INFO, "Skip LVB update, export is %s, obd is %s\n",
-                      exp->exp_failed ? "failed" : "disconnected",
-                      exp->exp_obd->obd_stopping ? "stopping" : "OK");
+       if (exp && exp->exp_obd && exp->exp_obd->obd_fail) {
+               CDEBUG(D_INFO, "Skip LVB update, obd is failing over\n");
                RETURN(0);
        }