--- ./source/private_module/spa/node_mgr/nmgr_seg_layout.c	2018-02-09 13:47:03.000000000 +0000
+++ ./source/private_module/spa/node_mgr/nmgr_seg_layout.c.hotpatch	2019-09-24 07:03:11.000000000 +0000
@@ -2164,11 +2164,9 @@
     {
         return RETURN_OK;
     }
-
     nodeInst = NMGR_REQ_GET_NMGR(msreq);
     /* ͷųɹҪڴpreallocseglist */
-    pacSegFlag = NMGR_REQ_GET_IS_PREALLOC_SEG(msreq);
-    
+    pacSegFlag = NMGR_REQ_GET_IS_PREALLOC_SEG(msreq);    
     if (pacSegFlag)
     {
         /*DBG_LogIntf_Flow(DBG_LOG_INFO, NODE_MGR_ID_01A5, TYPE_CREATE, "NodeInst 0x%llx(0x%llx:0x%llx) delete segment 0x%llx in prealloclist",
@@ -2179,7 +2177,6 @@
         NMGR_REQ_SET_SEGHDR(msreq, NULL);
         segHdr = NULL;
         spin_unlock(&nodeInst->lock); 
-
         return RETURN_OK;
     }
     
@@ -2188,15 +2185,18 @@
     orgHdr = getSegHdrByIdNoLock(nodeInst, segHdr->segId);
     if (orgHdr != segHdr)
     {
-        spin_unlock(&nodeInst->lock);
-        SPA_LIMIT_PRINT_ERROR(NODE_MGR_ID_01A3, "NodeInst 0x%llx(0x%llx:0x%llx) can not find segment 0x%llx.", 
-            nodeInst->volumeId, nodeInst->diskAddr.segId, nodeInst->diskAddr.segOff, segHdr->segId);
-        
-        return RETURN_ERROR;
+        DBG_LogDebug(NODE_MGR_ID_01A3, "NodeInst 0x%llx(0x%llx:0x%llx) can not find segment 0x%llx in allocSegList.",
+                                nodeInst->volumeId, nodeInst->diskAddr.segId, nodeInst->diskAddr.segOff, segHdr->segId);
+        orgHdr = findSegInCacheSegList(nodeInst, segHdr->segId);
+        if (orgHdr != segHdr)
+        {
+            spin_unlock(&nodeInst->lock);
+            SPA_LIMIT_PRINT_ERROR(NODE_MGR_ID_01A3, "NodeInst 0x%llx(0x%llx:0x%llx) can not find segment 0x%llx.", 
+                nodeInst->volumeId, nodeInst->diskAddr.segId, nodeInst->diskAddr.segOff, segHdr->segId);            
+            return RETURN_ERROR;
+        }
     }
 
-    /*DBG_LogIntf_Flow(DBG_LOG_INFO, NODE_MGR_ID_01A4, TYPE_CREATE, "NodeInst 0x%llx(0x%llx:0x%llx) delete segment 0x%llx really",
-        nodeInst->volumeId, nodeInst->diskAddr.segId, nodeInst->diskAddr.segOff, segHdr->segId);*/
 
     list_del(&segHdr->listNode);
     destructMemSegHdr(segHdr);
--- ./source/private_module/spa/spa_debug.c	2018-04-26 08:06:00.000000000 +0000
+++ ./source/private_module/spa/spa_debug.c.hotpatch	2019-09-24 07:03:11.000000000 +0000
@@ -5574,7 +5574,9 @@
     
     return;
 }
-
+typedef enum {HOT_PATCH_OP_DO, HOT_PATCH_OP_RESET, HOT_PATCH_OP_BUTT} HOT_PATCH_OP_E;
+void doHotPatchCmd(uint8_t opType, poolid_t poolId, uint8_t tierType, diskid_t diskId);
+bool getSpaCntParam(int32_t argc, char *argv[], uint32_t *inputType, uint8_t *opType, poolid_t *poolId, uint8_t *tierType, diskid_t *diskId);
 /**************************************************************************
      :  ӡSPAIO
  :  argc:           
@@ -5586,10 +5588,12 @@
 void spaDebugSpaCounter(int32_t argc, char *argv[])
 {
     uint32_t typeId    = 0;
-    uint32_t inputType = 0;
-    int32_t  result    = RETURN_ERROR;
-    DBG_OPT_S opt;
+    uint32_t inputType = 0;    
+    poolid_t poolId = INVALID_POOL_ID;
     bool    head = TRUE;
+    HOT_PATCH_OP_E opType = HOT_PATCH_OP_BUTT; 
+    uint8_t tierType = TIER_TYPE_BUTT; 
+    diskid_t diskId = INVALID_DISK_ID;
     
     if (argc < 2)
     {
@@ -5607,18 +5611,11 @@
         return;
     }
 
-    while ((result = DBG_GetOpt(argc, argv, "t:", &opt)) != -1)
+    if (!getSpaCntParam(argc, argv, &inputType, (uint8_t *)&opType, &poolId, &tierType, &diskId))
     {
-        if ('t' == result)
-        {
-            inputType = (poolid_t)LVOS_StrToU64(opt.szOptArg);
-        }
-        else
-        {
-            //DBG_ShowUsageAndErrMsg("%s", opt.szErrMsg);
-            DBG_PrintBuf("spa counter\n\nusage:\nspa counter [-t ?]\n\nparameter:\n[-t ?]\t\tCounter Type(0-3)\n\n");
-            return;
-        }
+        //DBG_ShowUsageAndErrMsg("%s", opt.szErrMsg);
+        DBG_PrintBuf("spa counter\n\nusage:\nspa counter [-t ?]\n\nparameter:\n[-t ?]\t\tCounter Type(0-3)\n\n");
+        return;
     }
 
     DEBUG_PARAM_CHECK_LESS_AND_RETURN(inputType, SPA_CNT_TYPE_LOGSMO);
@@ -5631,6 +5628,9 @@
         }             
     }      
 
+    
+    doHotPatchCmd((uint8_t)opType, poolId, tierType, diskId);
+
     return;
 }
 
@@ -24466,3 +24466,121 @@
     return;
 }
 
+bool getSpaCntParam(int32_t argc, char *argv[], uint32_t *inputType, uint8_t *opType, poolid_t *poolId, uint8_t *tierType, diskid_t *diskId)
+{
+    DBG_OPT_S opt;
+    int32_t  result    = RETURN_ERROR;
+    
+    while ((result = DBG_GetOpt(argc, argv, "t:o:p:d:", &opt)) != -1)
+    {
+        if ('t' == result)
+        {
+            *inputType = (poolid_t)LVOS_StrToU64(opt.szOptArg);
+            *tierType = (uint8_t)LVOS_StrToU64(opt.szOptArg);
+            continue;
+        }
+        if ('o' == result)
+        {
+            *opType = (uint8_t)LVOS_StrToU64(opt.szOptArg);
+            continue;
+        }
+        if ('p' == result)
+        {
+            *poolId = (poolid_t)LVOS_StrToU64(opt.szOptArg);
+            continue;
+        }
+        if ('d' == result)
+        {
+            *diskId = (diskid_t)LVOS_StrToU64(opt.szOptArg);
+            continue;
+        }
+        else
+        {
+            //DBG_ShowUsageAndErrMsg("%s", opt.szErrMsg);
+            DBG_PrintBuf("spa counter\n\nusage:\nspa counter [-t ?]\n\nparameter:\n[-t ?]\t\tCounter Type(0-3)\n\n");
+            return FALSE;
+        }
+    }
+
+    return TRUE;
+}
+
+typedef struct tagHOT_PATCH_CONTEXT
+{
+    int32_t result;
+    LVOS_COMPLETION_S signal;
+} HOT_PATCH_CONTEXT;
+
+void hotPatchRepairFmtLogCb(void *context, int32_t retVal)
+{
+    HOT_PATCH_CONTEXT *hotPatchCtx; 
+
+    hotPatchCtx = (HOT_PATCH_CONTEXT *)context;
+    hotPatchCtx->result = retVal;
+
+    LVOS_Complete(&hotPatchCtx->signal);  
+    
+    return ;
+}
+
+void setDiskCanNotAllocAndInsetFmtLog(poolid_t poolId, uint8_t tierType, diskid_t diskId)
+{
+    int32_t result = RETURN_ERROR;
+    HOT_PATCH_CONTEXT hotPatchCtx;
+    
+    /* ̵ѡ״̬ĳHANGUPռѡ */
+    result = changeSelectorMapDiskStatus(poolId, tierType, SELECTOR_MAP_DISK_HANGUP, &diskId, 1);
+    DBG_PrintBuf("Set disk(%u) can not alloc result : 0x%x.\n", diskId, result);
+    if (RETURN_OK != result)
+    {
+        return;
+    }
+
+    LVOS_InitCompletion(&hotPatchCtx.signal);
+
+    /* 5sٲʽlog */
+    LVOS_sleep(500);
+
+    /* δȥCKʽdisklog */
+    REPAIR_SPEC_DISK_FORMAT_LOG(poolId, diskId, hotPatchRepairFmtLogCb, &hotPatchCtx);
+
+    LVOS_WaitForCompletion(&hotPatchCtx.signal);
+    LVOS_DestroyCompletion(&hotPatchCtx.signal);
+
+    DBG_PrintBuf("Insert disk(%u) not alloc ck fmt log result : 0x%x.\n", diskId, hotPatchCtx.result);
+    
+    return;
+}
+
+void setDiskCanAlloc(poolid_t poolId, uint8_t tierType, diskid_t diskId)
+{
+    int32_t result = RETURN_ERROR;
+    
+    /* ̵ָѡ״̬ */
+    result = changeSelectorMapDiskStatus(poolId, tierType, SELECTOR_MAP_DISK_NORMAL, &diskId, 1);
+
+    DBG_PrintBuf("Set disk(%u) can alloc result : 0x%x.\n", diskId, result);
+    
+    return;
+}
+
+void doHotPatchCmd(uint8_t opType, poolid_t poolId, uint8_t tierType, diskid_t diskId)
+{
+    switch (opType)
+    {
+        case HOT_PATCH_OP_DO:
+            setDiskCanNotAllocAndInsetFmtLog(poolId, tierType, diskId);
+            break;
+        case HOT_PATCH_OP_RESET:
+            setDiskCanAlloc(poolId, tierType, diskId);
+            break;
+        default:
+            DBG_PrintBuf("Invalid hot patch optype.\n");
+            break;
+    }
+
+    return;
+}
+
+
+
