--- ./source/private_module/sd/sd_debug.c	2018-02-09 07:36:26.000000000 +0000
+++ ./source/private_module/sd/sd_debug.c.hotpatch	2019-09-29 11:57:48.000000000 +0000
@@ -2646,7 +2646,7 @@
     return;
 }
 /*End Modified by w90005722 DTS2017032211092 20170411*/
-
+void SdUpdateExtLunMaxSector(int32_t argc, char *argv[]);
 /**************************************************************************
 *     :sddebugӡ豸Ϣ
 * : argc
@@ -2661,12 +2661,14 @@
     uint64_t mode = 0; 
     char      devType[SD_DEBUG_DEV_TYPE_LEN] = {'\0'};
     uint32_t uiOnfly = 0;
-
-    BDM_SET_BIT(SD_DEV_MODE_NORMAL, (void*)&mode);
+   
+    if ((argc == 3) && ((strcmp(argv[2], "setextlunmaxsector") == 0) || (strcmp(argv[2], "restoreextlunmaxsector") == 0)))
+    {
+        SdUpdateExtLunMaxSector(argc, argv);
+        return;
+    } 
     
-    UNREFERENCE_PARAM(argc);
-    UNREFERENCE_PARAM(argv);
-
+    BDM_SET_BIT(SD_DEV_MODE_NORMAL, (void*)&mode);   
     if (argc > 2)
     {
         if (0 == strncmp("disk", argv[2], strlen("disk")))
@@ -2678,8 +2680,7 @@
         { //ʾһ־ռűе
             bcollect = TRUE; 
         }
-    }
-    
+    }   
     if (TRUE == bcollect)
     {
         spin_lock(&g_sdSdlock);
@@ -2699,7 +2700,6 @@
             collectrunning = FALSE;
             return;
         }
-
         sdPrintLogBuf("*****All scsi disks*************************************\n");
         memset(devType, 0, sizeof(devType));
         sdDoDebugGetLinkInfo(SCSI_DEVICE_TYPE_DISK, devType, SD_DEBUG_DEV_TYPE_LEN, &uiOnfly);
@@ -4923,3 +4923,79 @@
 SD_USE_TRACE_POINT
 
 
+
+#define BDM_LUN_LIMIT_MAXSECTOR_504     (504)   //޸ֵ
+#define BDM_LUN_LIMIT_MAXSECTOR_1024    (1024)  //߰汾ԭֵ
+
+void SdUpdateExtLunIoLimit(SD_SCSI_DEVICE_S *dev, void *context)
+{
+    SCSI_LUN_DEVICE_S* lun = NULL;
+    SIO_QUEUE_S* queue = NULL;
+    uint32_t* maxSectorSize = NULL;
+
+    if (context == NULL) 
+    {
+        DBG_LogError(LOG_ID_SD_0223, "context is NULL.");
+        return;
+    }
+      
+    if (dev == NULL) 
+    {
+        DBG_LogError(LOG_ID_SD_0223, "Find dev failed.");
+        return;
+    }
+
+    if (dev->type != SCSI_DEVICE_TYPE_LUN) 
+    {
+        DBG_LogError(LOG_ID_SD_0223, "Device type(%d) is not ext lun, sdevId(%u).", dev->type, dev->sdevId);
+        return;
+    }
+    
+    maxSectorSize = (uint32_t*)context;
+
+    lun = SD_GENERIC_TO_LUN(dev);
+    queue = sioGetQueueByDeviceId(lun->device.sdevId);
+    if (queue == NULL) 
+    {
+        DBG_LogError(LOG_ID_SD_0223, "Find no queue, sdevId(%u).", dev->sdevId);
+        return;
+    }
+
+    queue->limits.maxSector = *maxSectorSize;
+    DBG_LogInfo(LOG_ID_SD_0223, "Set ext lun iolimit to %u.", *maxSectorSize);
+    
+    return;
+}
+
+void SdUpdateExtLunInfo(uint32_t *maxSectorSize)
+{
+    uint64_t mode = 0;  
+    BDM_SET_BIT(SD_DEV_MODE_NORMAL, (void*)&mode);
+    
+    (void)sdListForEachDevice(SCSI_DEVICE_TYPE_LUN, mode, SdUpdateExtLunIoLimit, (void*)maxSectorSize);
+}
+
+void SdUpdateExtLunMaxSector(int32_t argc, char *argv[])
+{
+    if (argc != 3) 
+    {
+        return;
+    }
+ 
+    if (strcmp(argv[2], "setextlunmaxsector") == 0)
+    {
+        uint32_t maxSectorSize = BDM_LUN_LIMIT_MAXSECTOR_504;
+ 	 	SdUpdateExtLunInfo(&maxSectorSize);
+        DBG_LogInfo(LOG_ID_SD_011A, "Set ext lun iolimit to 252KB.");
+    } 
+    else if (strcmp(argv[2], "restoreextlunmaxsector") == 0) 
+    {
+        uint32_t maxSectorSize = BDM_LUN_LIMIT_MAXSECTOR_1024;
+ 	 	SdUpdateExtLunInfo(&maxSectorSize);
+        DBG_LogInfo(LOG_ID_SD_011A, "Set ext lun iolimit to 512KB.");
+    }
+   
+    return;
+}
+
+
--- ./source/private_module/sd/sd_lun.c	2018-02-09 07:36:26.000000000 +0000
+++ ./source/private_module/sd/sd_lun.c.hotpatch	2019-09-12 06:36:55.000000000 +0000
@@ -409,7 +409,7 @@
 
     return lun;
 }
-
+void SdUpdateLunInfo(SCSI_LUN_DEVICE_S *lun);
 /**************************************************************************
 *     : 豸id(id첽)
 * : id
@@ -441,7 +441,6 @@
     DBG_LogDebug(LOG_ID_SD_0224, "SD alloc LUN id succeed, uuid(%s), LUN id(%u).", str, id);
     /*End Modified by w90004841 DTS2014051509166 20140515*/
     devEvent->sdevId = id;
-
     lun = sdInitLunDevice(event);
     if ( unlikely(NULL == lun) )
     {
@@ -449,6 +448,7 @@
         return FALSE;
     }
     sdAddDeviceToDeviceList(&lun->device, SD_DEV_MODE_IN);
+    SdUpdateLunInfo(lun);
     sdProcessLunIn(event);
 
     return TRUE;
@@ -609,3 +609,18 @@
     }
 }
 
+
+void SdUpdateLunInfo(SCSI_LUN_DEVICE_S *lun)
+{
+    SIO_QUEUE_S* queue = NULL;
+
+    queue = sioGetQueueByDeviceId(lun->device.sdevId);
+    if (queue == NULL) {
+        DBG_LogError(LOG_ID_SD_0223, "Find no queue, SdevId(%u).", lun->device.sdevId);
+        return;
+    }
+
+    queue->limits.maxSector = 504;  //FC룬޸Ϊ252KB   
+}
+
+
