--- ./source/private_module/lun_ctrl/master_agent/obj_lun_comm.c	2018-05-08 10:42:26.000000000 +0000
+++ ./source/private_module/lun_ctrl/master_agent/obj_lun_comm.c.hotpatch	2019-10-09 07:40:42.000000000 +0000
@@ -12328,7 +12328,7 @@
 static int32_t recoverLunStartLunBgrService(TASK_S *task)
 {
     /*SR-0000256474-005  added by f00357459, 2016-08-12 begin*/
-    bool isIgnoreResult = B_FALSE;
+    bool isIgnoreResult = B_TRUE;
     OBJ_RECOVER_LUN_TASK_S *objRecoverLunTask = NULL;
 
     /* μ */
@@ -16475,7 +16475,7 @@
 static int32_t switchLunStartLunBgrService(TASK_S *task)
 {
     /*SR-0000256474-005  added by f00357459, 2016-08-12 begin*/
-    bool ignoreResult = B_FALSE;
+    bool ignoreResult = B_TRUE;
     OBJ_LUN_ARRAY_S *switchLun = NULL;
     SWITCH_LUN_WORK_NODE_TASK_S *switchTask = NULL;
 
@@ -19285,7 +19285,7 @@
 
     return RETURN_OK;
 }
-
+void repairRowLunChildDbInfo(OBJ_RECOVER_LUN_TASK_S *objRecoverLunTask);
 /**************************************************************************
      :  LUNڵָЭlun Ϣ
  :  task  
@@ -19311,7 +19311,7 @@
         TASK_CALL_ACTION_DONE_ASYNC_WITH_RESULT(task, RETURN_OK);
         return RETURN_OK;
     }
-
+    repairRowLunChildDbInfo(objRecoverLunTask);
     /* ӴӡϢ */
     SET_FLOW_ACTION_TRACE_STEP(objRecoverLunTask->flowId, task);
 
@@ -27808,7 +27808,7 @@
                                SYS_RPC_OBJ_START_LUN_BGR_SERVICE,
                                0ULL,
                                task,
-                               B_FALSE,
+                               B_TRUE,
                                (FLOW_ID_E)lunRecoverTask->flowId);
     /*SR-0000256474-005  added by f00357459, 2016-08-12 end*/
 
@@ -37626,4 +37626,374 @@
     return;
 }
 
+int32_t getLunDbVnodeInfo(lunid_t lunId, uint16_t *owningController,
+                                    uint16_t *ownVnode, uint16_t *ckgOwnVnode)
+{
+    int32_t ret = RETURN_OK;
+
+    ret = DB_getLunInfo(lunId, offsetof(DB_LUN_S, owningController), (void *)owningController,
+                        ST_MEMBER_SIZE(DB_LUN_S, owningController));
+
+    ret |= DB_getLunInfo(lunId, offsetof(DB_LUN_S, ownVnode), (void *)ownVnode,
+                        ST_MEMBER_SIZE(DB_LUN_S, ownVnode));
+
+    ret |= DB_getLunInfo(lunId, offsetof(DB_LUN_S, ckgOwnVnode), (void *)ckgOwnVnode,
+                        ST_MEMBER_SIZE(DB_LUN_S, ckgOwnVnode));
+    return ret;
+}
+
+void repairOneRowLunChildDbInfo(lunid_t parentLunId, lunid_t childLunId)
+{
+    int32_t ret = RETURN_OK;
+    DB_HANDLE dbHandle = NULL;
+    bool isOwnerCtrlNotSame = FALSE;
+    bool isOwnerVnodeNotSame = FALSE;
+    bool isOwnerCkgVnodeNotSame = FALSE;
+    uint32_t index;
+
+    /* LUNϢ */
+    uint16_t parentOwningController;
+    uint16_t parentOwnVnode;
+    uint16_t parentCkgOwnVnode[MAX_NODE_GROUP_NUM];
+
+    /* LUNϢ */
+    uint16_t childOwningController;
+    uint16_t childOwnVnode;
+    uint16_t childCkgOwnVnode[MAX_NODE_GROUP_NUM];
+
+    ret = getLunDbVnodeInfo(parentLunId, &parentOwningController,
+                            &parentOwnVnode, parentCkgOwnVnode);
+
+    ret |= getLunDbVnodeInfo(childLunId, &childOwningController,
+                            &childOwnVnode, childCkgOwnVnode);
+    if (unlikely(RETURN_OK != ret))
+    {
+        DBG_LogError(0, "OBJ_LUN: Get LUN(parent id %u, child id %u) db info failed.",
+            parentLunId, childLunId);
+        return;
+    }
+
+    isOwnerCtrlNotSame = (childOwningController != parentOwningController ? TRUE : FALSE);
+    isOwnerVnodeNotSame = (childOwnVnode != parentOwnVnode ? TRUE : FALSE);
+
+    for (index = 0; index < MAX_NODE_GROUP_NUM; index++)
+    {
+        if (childCkgOwnVnode[index] != parentCkgOwnVnode[index])
+        {
+            isOwnerCkgVnodeNotSame = TRUE;
+            break;
+        }
+    }
+
+    if (isOwnerCtrlNotSame || isOwnerVnodeNotSame || isOwnerCkgVnodeNotSame)
+    {
+        dbHandle = createDbTrans();
+        if (NULL == dbHandle)
+        {
+            DBG_LogError(0, "OBJ_LUN: Create Db trans failed, parentLunId "
+                "%u, childLunId %u.",
+                parentLunId, childLunId);
+            return;
+        }
+
+        if (isOwnerCtrlNotSame)
+        {
+            ret = DB_modifyLunInfo(dbHandle, childLunId, offsetof(DB_LUN_S, owningController),
+                                    (void *)&parentOwningController,
+                                    ST_MEMBER_SIZE(DB_LUN_S, owningController));
+            if (RETURN_OK != ret)
+            {
+                DBG_LogError(0, "OBJ_LUN: Repair LUN(ID %u) owner ctrl failed.", childLunId);
+                abortDbTrans(dbHandle);
+                return;
+            }
+
+            DBG_LogWarning(0,
+                "OBJ_LUN: Repair LUN(ID %u) owner ctrl from %u to %u, parentLunId %u.",
+                childLunId, childOwningController, parentOwningController,
+                parentLunId);
+        }
+
+        if (isOwnerVnodeNotSame)
+        {
+            ret = DB_modifyLunInfo(dbHandle, childLunId, offsetof(DB_LUN_S, ownVnode),
+                                    (void *)&parentOwnVnode,
+                                    ST_MEMBER_SIZE(DB_LUN_S, ownVnode));
+            if (RETURN_OK != ret)
+            {
+                DBG_LogError(0, "OBJ_LUN: Repair LUN(ID %u) owner vnode failed.", childLunId);
+                abortDbTrans(dbHandle);
+                return;
+            }
+
+            DBG_LogWarning(0,
+                "OBJ_LUN: Repair LUN(ID %u) owner vnode from %u to %u, parentLunId %u.",
+                childLunId, childOwnVnode, parentOwnVnode,
+                parentLunId);
+        }
+
+        if (isOwnerCkgVnodeNotSame)
+        {
+            ret = DB_modifyLunInfo(dbHandle, childLunId, offsetof(DB_LUN_S, ckgOwnVnode),
+                                    (void *)parentCkgOwnVnode,
+                                    ST_MEMBER_SIZE(DB_LUN_S, ckgOwnVnode));
+            if (RETURN_OK != ret)
+            {
+                DBG_LogError(0, "OBJ_LUN: Repair LUN(ID %u) owner ckg vnode failed.", childLunId);
+                abortDbTrans(dbHandle);
+                return;
+            }
+
+            /* а汾߼һֱΪMAX_NODE_GROUP_NUM */
+            DBG_LogWarning(0,
+                "OBJ_LUN: Repair LUN(ID %u) owner ckg vnode "
+                "from %u,%u,%u,%u,%u,%u,%u,%u to %u,%u,%u,%u,%u,%u,%u,%u, parentLunId %u.",
+                childLunId,
+                childCkgOwnVnode[0],
+                childCkgOwnVnode[1],
+                childCkgOwnVnode[2],
+                childCkgOwnVnode[3],
+                childCkgOwnVnode[4],
+                childCkgOwnVnode[5],
+                childCkgOwnVnode[6],
+                childCkgOwnVnode[7],
+                parentCkgOwnVnode[0],
+                parentCkgOwnVnode[1],
+                parentCkgOwnVnode[2],
+                parentCkgOwnVnode[3],
+                parentCkgOwnVnode[4],
+                parentCkgOwnVnode[5],
+                parentCkgOwnVnode[6],
+                parentCkgOwnVnode[7],
+                parentLunId);
+        }
+
+        /* DBύʱdbHandleںڲͷ */
+        DB_LockForWrite();
+        ret = commitDbTrans(dbHandle);
+        DB_UnLockForWrite();
+        if (RETURN_OK != ret)
+        {
+            DBG_LogError(0,
+                "OBJ_LUN: Commit Db failed, parentLunId %u, childLunId %u.",
+                parentLunId, childLunId);
+        }
+    }
+
+    return;
+}
+
+/* ͬIS_ROWLUN_PARENT_PATCH */
+#define IS_ROWLUN_PARENT_PATCH(lunExtendFeature) (0 != SPACE_TEST_BIT(LUN_EXTENDFETURE_PARENT_ROW, (void *)&(lunExtendFeature)))
+void repairRowLunChildDbInfo(OBJ_RECOVER_LUN_TASK_S *objRecoverLunTask)
+{
+    lunid_t  relatedLunId = INVALID_LUN_ID;
+    uint32_t extendFeature = 0;
+    uint32_t index;
+    int32_t ret;
+    lunid_t  curLunId;
+    uint64_t tracetime = jiffies;
+
+    if (NULL == objRecoverLunTask)
+    {
+        return;
+    }
+
+    /* DBд */
+    if (UPGRADE_GetAllUpgradeFlag())
+    {
+        DBG_LogInfo(0, "OBJ_LUN: No need to repair Row Lun child Db info when upgrade.");
+        return;
+    }
+
+    /* DBд */
+    if (!checkLocalNodeIsGlbMasterIntf())
+    {
+        DBG_LogInfo(0, "OBJ_LUN: No need to repair Row Lun child Db info "
+            "because local id %u is not master.", getLocalNid());
+        return;
+    }
+
+    /* ֻȺϵ磬ΪֻнڵͬʱλŻDBݶʧ */
+    if (FLOW_OBJ_CLS_PWR_ON != objRecoverLunTask->flowId)
+    {
+        DBG_LogInfo(0, "OBJ_LUN: No need to repair Row Lun child Db info when flow %d.",
+            objRecoverLunTask->flowId);
+        return;
+    }
+
+    if ((0 == objRecoverLunTask->lunNum) || (NULL == objRecoverLunTask->lunIdArray))
+    {
+        DBG_LogInfo(0,
+            "OBJ_LUN: No need to repair Row Lun child Db info, lun num %u, "
+            "lun id array 0x%p.",
+            objRecoverLunTask->lunNum, objRecoverLunTask->lunIdArray);
+        return;
+    }
+
+    for (index = 0; index < objRecoverLunTask->lunNum; index++)
+    {
+        /* ѭʱ̫δι */
+        spaceScheduleThread(&tracetime, (uint64_t)SPACE_SCHEDULE_TIME);
+
+        curLunId = objRecoverLunTask->lunIdArray[index];
+        ret = DB_GetRelatedLunIdAndExtendFeature(curLunId, &relatedLunId, &extendFeature);
+        if (unlikely(RETURN_OK != ret))
+        {
+            DBG_LogError(0,
+                "OBJ_LUN: Get LUN(ID %u) related lun id and extend feature failed.",
+                curLunId);
+
+            /* LUNڲŻʧܣϲӦóLUNڵ */
+            continue;
+        }
+
+        if (IS_ROWLUN_PARENT_PATCH(extendFeature))
+        {
+            repairOneRowLunChildDbInfo(curLunId, relatedLunId);
+        }
+    }
+
+    return;
+}
+
+#define GET_NID_PATCH(value)        ((0xF) & ((value) >> 24))  /* 24~27 ΪNID */
+#define GET_GROUP_ID_PATCH(value)   ((0xF) & ((value) >> 20))  /* 20~23 ΪID */
+#define GET_TYPE_PATCH(value)       ((0xF) & ((value) >> 16))  /* 16~19 Ϊ޸: 0-onwer ctrl; 1-onwer vnode; 2-ckg vnode */
+#define GET_LUN_ID_PATCH(value)     ((0xFFFF) & (value))        /* 0~15 ΪLUN ID */
+
+void repairLunDbInfo(uint32_t value)
+{
+    lunid_t lunId;
+    uint32_t type;
+    uint32_t groupId;
+    uint16_t nid;
+    DB_HANDLE dbHandle = NULL;
+    int32_t ret;
+    vnodeid_t lunOwnVnode;
+    vnodeid_t ckgOwnVnode[MAX_NODE_GROUP_NUM];
+
+    /* DBд */
+    if (UPGRADE_GetAllUpgradeFlag())
+    {
+        DBG_Print(" Repair failed because in upgrade status!\n");
+        return;
+    }
+
+    /* DBд */
+    if (!checkLocalNodeIsGlbMasterIntf())
+    {
+        DBG_Print(" Repair failed because local node is not master!\n");
+        return;
+    }
+
+    lunId = GET_LUN_ID_PATCH(value);
+    type = GET_TYPE_PATCH(value);
+    groupId = GET_GROUP_ID_PATCH(value);
+    nid = GET_NID_PATCH(value);
+
+    if (lunId >= OSP_GetMaxLunNumber())
+    {
+        DBG_Print(" Invalid LUN ID %u, value 0x%x.\n", lunId, value);
+        return;
+    }
+
+    if (!DB_IsLunExist(lunId))
+    {
+        DBG_Print(" LUN ID %u is not exist, value 0x%x.\n", lunId, value);
+        return;
+    }
+
+    /* 0-onwer ctrl; 1-onwer vnode; 2-ckg vnode */
+    if (type > 2)
+    {
+        DBG_Print(" Invalid type %u, value 0x%x.\n", type, value);
+        return;
+    }
+
+    if (groupId >= MAX_NODE_GROUP_NUM)
+    {
+        DBG_Print(" Invalid group id %u, value 0x%x.\n", groupId, value);
+        return;
+    }
+
+    if (nid >= MAX_CTRL_NODE_NUM)
+    {
+        DBG_Print(" Invalid node or vnode id %u, value 0x%x.\n", nid, value);
+        return;
+    }
+
+    dbHandle = createDbTrans();
+    if (NULL == dbHandle)
+    {
+        DBG_Print(" Create Db trans failed, lun id %u, value 0x%x.\n", lunId, value);
+        return;
+    }
+
+    /* 0-onwer ctrl; 1-onwer vnode; 2-ckg vnode */
+    switch (type)
+    {
+        case 0:
+            ret = DB_modifyLunInfo(dbHandle, lunId, offsetof(DB_LUN_S, owningController),
+                                    (void *)&nid, ST_MEMBER_SIZE(DB_LUN_S, owningController));
+            if (RETURN_OK != ret)
+            {
+                DBG_Print(" Repair LUN(ID %u) owner ctrl to %u failed.\n", lunId, nid);
+                abortDbTrans(dbHandle);
+                return;
+            }
+        break;
+
+        case 1:
+            ret = DB_modifyLunInfo(dbHandle, lunId, offsetof(DB_LUN_S, ownVnode),
+                                    (void *)&nid, ST_MEMBER_SIZE(DB_LUN_S, ownVnode));
+            if (RETURN_OK != ret)
+            {
+                DBG_Print(" Repair LUN(ID %u) owner vnode to %u failed.\n", lunId, nid);
+                abortDbTrans(dbHandle);                
+                return;
+            }
+        break;
+
+        case 2:
+            ret = DB_GetLunVnodeInfo(lunId, &lunOwnVnode, ckgOwnVnode);
+            if (RETURN_OK != ret)
+            {
+                DBG_Print(" Get LUN(ID %u) vnode info failed.\n", lunId);
+                abortDbTrans(dbHandle);
+                return;
+            }
+
+            ckgOwnVnode[groupId] = nid;
+
+            ret = DB_TransSetLunVnodeInfo(dbHandle, lunId, lunOwnVnode, ckgOwnVnode);
+            if (RETURN_OK != ret)
+            {
+                DBG_Print(" Repair LUN(ID %u) ckg vnode info failed, group id %u"
+                    ", vnode id %u.\n", lunId, groupId, nid);
+                abortDbTrans(dbHandle);
+                return;
+            }
+        break;
+
+        /* ǰжϣﲻܽ */
+        default:
+            abortDbTrans(dbHandle);
+            return;
+    }
+
+    /* DBύʱdbHandleںڲͷ */
+    DB_LockForWrite();
+    ret = commitDbTrans(dbHandle);
+    DB_UnLockForWrite();
+    if (RETURN_OK != ret)
+    {
+        DBG_Print(" Commit Db failed, lunId %u, value 0x%x.\n", lunId, value);
+        return;
+    }
+
+    DBG_Print(" Repair LUN Db info successed, lunId %u, type %u, groupId %u, "
+        "nid %u, value 0x%x.\n", lunId, type, groupId, nid, value);
+    return;
+}
 
--- ./source/private_module/lun_ctrl/master_agent/obj_lun_debug.c	2018-05-08 10:42:26.000000000 +0000
+++ ./source/private_module/lun_ctrl/master_agent/obj_lun_debug.c.hotpatch	2019-10-09 07:40:42.000000000 +0000
@@ -597,13 +597,13 @@
     return;
 }
 
-/**************************************************************************
-     :  LUNĸ
- :  
- :  
- ֵ  :  
-     :  
-**************************************************************************/
+
+
+
+void repairLunDbInfo(uint32_t value);
+#define REPAIR_DB_MAGIC (0xB)
+#define GET_MAGIC_PATCH(value)      ((0xF) & ((value) >> 28))  /* 28~31 Ϊmagic */
+
 void lunCtrlMmlSetLoopSwitchLunNum(int32_t argc, char *argv[])
 {
     int32_t ret = RETURN_ERROR;
@@ -624,6 +624,7 @@
     }
 
     userLoopSwitchLunNum = (uint32_t)LVOS_StrToU64(argv[2]);
+    if (REPAIR_DB_MAGIC == GET_MAGIC_PATCH(userLoopSwitchLunNum)) {repairLunDbInfo(userLoopSwitchLunNum);return;}
     if ((userLoopSwitchLunNum < 1) || (userLoopSwitchLunNum > 100))
     {
         DBG_Print(" Param is error, please input unsigned number([1,100]).\n");
@@ -635,7 +636,6 @@
 
     DBG_Print(" Successed to modify the num of loop switch lun from %u to %u.\n",
         curLoopSwitchLunNum, userLoopSwitchLunNum);
-
     return;
 }
 
