summaryrefslogtreecommitdiffstatsabout
path: root/SylixOS
diff options
context:
space:
mode:
authorHanhui <hanhui@acoinfo.com>2020-10-29 13:05:06 (GMT)
committer Hanhui <hanhui@acoinfo.com>2020-10-29 13:05:06 (GMT)
commite6a5485c9a3dadff6e3ece8d703d44d3a5d432a8 (patch)
treeded1d6c4af71df077d1683307bf4c89219d2648e /SylixOS
parent9cb7c36f1be725eb2f0e4e8633c31376e834631b (diff)
downloadlibsylixos-e6a5485c9a3dadff6e3ece8d703d44d3a5d432a8.zip
libsylixos-e6a5485c9a3dadff6e3ece8d703d44d3a5d432a8.tar.gz
libsylixos-e6a5485c9a3dadff6e3ece8d703d44d3a5d432a8.tar.bz2
Improve TpsFs transaction processing speed, add number of process file descriptors quota management.
Diffstat (limited to 'SylixOS')
-rw-r--r--SylixOS/driver/pci/storage/pciStorageAta.c3
-rw-r--r--SylixOS/fs/diskCache/diskCache.c6
-rw-r--r--SylixOS/fs/diskCache/diskCache.h1
-rw-r--r--SylixOS/fs/diskCache/diskCacheLib.c150
-rw-r--r--SylixOS/fs/diskCache/diskCacheLib.h8
-rw-r--r--SylixOS/fs/diskPartition/diskPartition.c15
-rw-r--r--SylixOS/fs/tpsFs/tpsfs_port.h8
-rw-r--r--SylixOS/fs/tpsFs/tpsfs_sylixos.c48
-rw-r--r--SylixOS/fs/tpsFs/tpsfs_trans.c112
-rw-r--r--SylixOS/kernel/include/k_kernel.h2
-rw-r--r--SylixOS/loader/include/loader_vppatch.h3
-rw-r--r--SylixOS/loader/src/loader_file.c51
-rw-r--r--SylixOS/posix/resource/resource.c71
-rw-r--r--SylixOS/system/device/ahci/ahci.c4
-rw-r--r--SylixOS/system/device/ata/ata.c9
-rw-r--r--SylixOS/system/device/ata/ataCfg.h6
-rw-r--r--SylixOS/system/device/ata/ataLib.c7
-rw-r--r--SylixOS/system/device/block/blockIo.h6
-rw-r--r--SylixOS/system/include/s_option.h2
19 files changed, 418 insertions, 94 deletions
diff --git a/SylixOS/driver/pci/storage/pciStorageAta.c b/SylixOS/driver/pci/storage/pciStorageAta.c
index 91bf222..1b52745 100644
--- a/SylixOS/driver/pci/storage/pciStorageAta.c
+++ b/SylixOS/driver/pci/storage/pciStorageAta.c
@@ -228,6 +228,9 @@ static VOID pciStorageAtaCtrlIch4Delay (ATA_CTRL_HANDLE hCtrl)
ATA_IO_BYTES_READ(hCtrl, ATA_A_STATUS_ADDR(hCtrl), &ucReg, 1);
ATA_IO_BYTES_READ(hCtrl, ATA_A_STATUS_ADDR(hCtrl), &ucReg, 1);
ATA_IO_BYTES_READ(hCtrl, ATA_A_STATUS_ADDR(hCtrl), &ucReg, 1);
+ ATA_IO_BYTES_READ(hCtrl, ATA_A_STATUS_ADDR(hCtrl), &ucReg, 1);
+ ATA_IO_BYTES_READ(hCtrl, ATA_A_STATUS_ADDR(hCtrl), &ucReg, 1);
+ ATA_IO_BYTES_READ(hCtrl, ATA_A_STATUS_ADDR(hCtrl), &ucReg, 1);
}
/*********************************************************************************************************
** 函数名称: pciStorageAtaCtrlQuirk
diff --git a/SylixOS/fs/diskCache/diskCache.c b/SylixOS/fs/diskCache/diskCache.c
index 6d3bff1..fa23cf4 100644
--- a/SylixOS/fs/diskCache/diskCache.c
+++ b/SylixOS/fs/diskCache/diskCache.c
@@ -270,6 +270,12 @@ ULONG API_DiskCacheCreateEx2 (PLW_BLK_DEV pblkdDisk,
pdiskcDiskCache->DISKC_ulBytesPerSector = ulBytesPerSector;
pdiskcDiskCache->DISKC_iMaxRBurstSector = pdcattrl->DCATTR_iMaxRBurstSector;
pdiskcDiskCache->DISKC_iMaxWBurstSector = pdcattrl->DCATTR_iMaxWBurstSector;
+
+ if (pdcattrl->DCATTR_iBurstOpt & LW_DCATTR_BOPT_META_ONE_BURST) {
+ pdiskcDiskCache->DISKC_iMetaBurstSector = 1;
+ } else {
+ pdiskcDiskCache->DISKC_iMetaBurstSector = 0;
+ }
/*
* 确定 HASH 表的大小
diff --git a/SylixOS/fs/diskCache/diskCache.h b/SylixOS/fs/diskCache/diskCache.h
index c9a2ab1..2dbb870 100644
--- a/SylixOS/fs/diskCache/diskCache.h
+++ b/SylixOS/fs/diskCache/diskCache.h
@@ -77,6 +77,7 @@
#define LW_DCATTR_BOPT_CACHE_COHERENCE 0x01 /* 缓冲区需要 CACHE 一致性保障 */
#define LW_DCATTR_BOPT_PAGE_ALIGN 0x02 /* 缓冲区必须页面对齐 */
+#define LW_DCATTR_BOPT_META_ONE_BURST 0x04 /* Metadata 猝发扇区为 1 */
typedef struct {
PVOID DCATTR_pvCacheMem; /* 扇区缓存地址 */
diff --git a/SylixOS/fs/diskCache/diskCacheLib.c b/SylixOS/fs/diskCache/diskCacheLib.c
index dd76816..f42dc62 100644
--- a/SylixOS/fs/diskCache/diskCacheLib.c
+++ b/SylixOS/fs/diskCache/diskCacheLib.c
@@ -959,6 +959,131 @@ INT __diskCacheWrite (PLW_DISKCACHE_CB pdiskcDiskCache,
return (iError);
}
/*********************************************************************************************************
+** 函数名称: __diskCacheReadMeta
+** 功能描述: 读取元数据 (DISK CACHE 未加锁调用)
+** 输 入 : pdiskcDiskCache 磁盘 CACHE 控制块
+** pvBuffer 缓冲区
+** ulStartSector 起始扇区
+** ulSectorCount 连续扇区数量
+** 输 出 : ERROR CODE
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+INT __diskCacheReadMeta (PLW_DISKCACHE_CB pdiskcDiskCache,
+ VOID *pvBuffer,
+ ULONG ulStartSector,
+ ULONG ulSectorCount)
+{
+ INT i;
+ INT iError = ERROR_NONE;
+ REGISTER PLW_DISKCACHE_NODE pdiskn;
+ PCHAR pcData = (PCHAR)pvBuffer;
+ INT iMaxRBurstSector;
+
+ __LW_DISKCACHE_LOCK(pdiskcDiskCache); /* 互斥访问 */
+
+ iMaxRBurstSector = pdiskcDiskCache->DISKC_iMaxRBurstSector;
+ /* 备份触发扇区数 */
+ if(pdiskcDiskCache->DISKC_iMetaBurstSector) { /* 设置元数据猝发扇区 */
+ pdiskcDiskCache->DISKC_iMaxRBurstSector = pdiskcDiskCache->DISKC_iMetaBurstSector;
+ } else {
+ pdiskcDiskCache->DISKC_iMaxRBurstSector = min(ulSectorCount, iMaxRBurstSector);
+ }
+
+ for (i = 0; i < ulSectorCount; i++) {
+ pdiskn = __diskCacheNodeGet(pdiskcDiskCache,
+ (ulStartSector + i),
+ (INT)(ulSectorCount - i),
+ LW_TRUE);
+ if (pdiskn == LW_NULL) {
+ iError = PX_ERROR;
+ break;
+ }
+
+ __diskCacheMemcpy(pcData, pdiskn->DISKN_pcData,
+ (size_t)pdiskcDiskCache->DISKC_ulBytesPerSector); /* 拷贝数据 */
+
+ pcData += pdiskcDiskCache->DISKC_ulBytesPerSector;
+ }
+
+ pdiskcDiskCache->DISKC_iMaxRBurstSector = iMaxRBurstSector; /* 恢复触发扇区数 */
+
+ __LW_DISKCACHE_UNLOCK(pdiskcDiskCache); /* 解锁 */
+
+ return (iError);
+}
+/*********************************************************************************************************
+** 函数名称: __diskCacheWriteMeta
+** 功能描述: 写元数据 (DISK CACHE 未加锁调用)
+** 输 入 : pdiskcDiskCache 磁盘 CACHE 控制块
+** pvBuffer 缓冲区
+** ulStartSector 起始扇区
+** ulSectorCount 连续扇区数量
+** 输 出 : ERROR CODE
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+INT __diskCacheWriteMeta (PLW_DISKCACHE_CB pdiskcDiskCache,
+ VOID *pvBuffer,
+ ULONG ulStartSector,
+ ULONG ulSectorCount)
+{
+ INT i;
+ INT iError = ERROR_NONE;
+ REGISTER PLW_DISKCACHE_NODE pdiskn;
+ PCHAR pcData = (PCHAR)pvBuffer;
+ PLW_BLK_RANGE pblkrange;
+ REGISTER PLW_DISKCACHE_WP pwp = &pdiskcDiskCache->DISKC_wpWrite;
+
+ if (!pwp->DISKCWP_bParallel) {
+ __LW_DISKCACHE_PL_LOCK(pwp);
+ }
+
+ if (pdiskcDiskCache->DISKC_pblkdDisk->BLKD_pfuncBlkWrt(pdiskcDiskCache->DISKC_pblkdDisk,
+ pvBuffer, ulStartSector,
+ ulSectorCount) < 0) {
+ if (!pwp->DISKCWP_bParallel) { /* 并行处理这里可以释放锁 */
+ __LW_DISKCACHE_PL_UNLOCK(pwp);
+ }
+ return (PX_ERROR);
+ }
+
+ pblkrange->BLKR_ulStartSector = ulStartSector;
+ pblkrange->BLKR_ulEndSector = ulStartSector + ulSectorCount - 1;
+ __LW_DISKCACHE_DISK_IOCTL(pdiskcDiskCache)(pdiskcDiskCache->DISKC_pblkdDisk, FIOSYNCMETA, &pblkrange);
+
+ if (!pwp->DISKCWP_bParallel) { /* 并行处理这里可以释放锁 */
+ __LW_DISKCACHE_PL_UNLOCK(pwp);
+ }
+
+ __LW_DISKCACHE_LOCK(pdiskcDiskCache); /* 互斥访问 */
+
+ for (i = 0; i < ulSectorCount; i++) {
+ pdiskn = __diskCacheNodeGet(pdiskcDiskCache,
+ (ulStartSector + i),
+ (INT)(ulSectorCount - i),
+ LW_FALSE);
+ if (pdiskn == LW_NULL) {
+ iError = PX_ERROR;
+ break;
+ }
+
+ if (__LW_DISKCACHE_IS_DIRTY(pdiskn) != 0) {
+ __LW_DISKCACHE_CLR_DIRTY(pdiskn);
+ pdiskcDiskCache->DISKC_ulDirtyCounter--;
+ }
+
+ __diskCacheMemcpy(pdiskn->DISKN_pcData, pcData,
+ (size_t)pdiskcDiskCache->DISKC_ulBytesPerSector); /* 写入数据 */
+
+ pcData += pdiskcDiskCache->DISKC_ulBytesPerSector;
+ }
+
+ __LW_DISKCACHE_UNLOCK(pdiskcDiskCache); /* 解锁 */
+
+ return (iError);
+}
+/*********************************************************************************************************
** 函数名称: __diskCacheIoctl
** 功能描述: 通过磁盘 CACHE 控制一个磁盘
** 输 入 : pdiskcDiskCache 磁盘 CACHE 控制块
@@ -970,13 +1095,16 @@ INT __diskCacheWrite (PLW_DISKCACHE_CB pdiskcDiskCache,
*********************************************************************************************************/
INT __diskCacheIoctl (PLW_DISKCACHE_CB pdiskcDiskCache, INT iCmd, LONG lArg)
{
- REGISTER INT iError;
- REGISTER BOOL bMutex;
- PLW_BLK_RANGE pblkrange;
+ REGISTER INT iError;
+ REGISTER BOOL bMutex;
+ PLW_BLK_RANGE pblkrange;
+ PLW_BLK_METADATA pblkMeta;
- if (__LW_DISKCACHE_LOCK(pdiskcDiskCache)) { /* 互斥访问 */
- _ErrorHandle(ENXIO);
- return (PX_ERROR);
+ if ((iCmd != FIOWRMETA) && (iCmd != FIORDMETA)) {
+ if (__LW_DISKCACHE_LOCK(pdiskcDiskCache)) { /* 互斥访问 */
+ _ErrorHandle(ENXIO);
+ return (PX_ERROR);
+ }
}
switch (iCmd) {
@@ -1035,6 +1163,16 @@ INT __diskCacheIoctl (PLW_DISKCACHE_CB pdiskcDiskCache, INT iCmd, LONG lArg
__diskCacheWpSync(&pdiskcDiskCache->DISKC_wpWrite, 0); /* 等待写结束 */
break;
+ case FIORDMETA: /* 读元数据 */
+ pblkMeta = (PLW_BLK_METADATA)lArg;
+ return (__diskCacheReadMeta(pdiskcDiskCache, pblkMeta->BLKM_pucBuf,
+ pblkMeta->BLKM_ulStartSector, pblkMeta->BLKM_ulSectorCnt));
+
+ case FIOWRMETA: /* 写元数据 */
+ pblkMeta = (PLW_BLK_METADATA)lArg;
+ return (__diskCacheWriteMeta(pdiskcDiskCache, pblkMeta->BLKM_pucBuf,
+ pblkMeta->BLKM_ulStartSector, pblkMeta->BLKM_ulSectorCnt));
+
case FIODISKCHANGE: /* 磁盘发生改变 */
pdiskcDiskCache->DISKC_blkdCache.BLKD_bDiskChange = LW_TRUE;
case FIOUNMOUNT: /* 卸载卷 */
diff --git a/SylixOS/fs/diskCache/diskCacheLib.h b/SylixOS/fs/diskCache/diskCacheLib.h
index 790669c..18f5c75 100644
--- a/SylixOS/fs/diskCache/diskCacheLib.h
+++ b/SylixOS/fs/diskCache/diskCacheLib.h
@@ -39,6 +39,13 @@ extern PLW_LIST_LINE _G_plineDiskCacheHeader; /* 链表
#define __LW_DISKCACHE_UNLOCK(pdiskc) \
API_SemaphoreMPost(pdiskc->DISKC_hDiskCacheLock)
/*********************************************************************************************************
+ PIPE LINE LOCK
+*********************************************************************************************************/
+#define __LW_DISKCACHE_PL_LOCK(pwp) \
+ API_SemaphoreMPend(pwp->DISKCWP_hLock, LW_OPTION_WAIT_INFINITE)
+#define __LW_DISKCACHE_PL_UNLOCK(pwp) \
+ API_SemaphoreMPost(pwp->DISKCWP_hLock)
+/*********************************************************************************************************
DISK CACHE NODE OP
*********************************************************************************************************/
#define __LW_DISKCACHE_NODE_READ 0 /* 节点读 */
@@ -126,6 +133,7 @@ typedef struct {
INT DISKC_iMaxRBurstSector; /* 最大猝发读写扇区数量 */
INT DISKC_iMaxWBurstSector;
+ INT DISKC_iMetaBurstSector; /* 元数据读取猝发扇区数量 */
LW_DISKCACHE_WP DISKC_wpWrite; /* 并发写管线 */
PLW_LIST_RING DISKC_pringLruHeader; /* LRU 表头 */
diff --git a/SylixOS/fs/diskPartition/diskPartition.c b/SylixOS/fs/diskPartition/diskPartition.c
index 28d686f..e020ebd 100644
--- a/SylixOS/fs/diskPartition/diskPartition.c
+++ b/SylixOS/fs/diskPartition/diskPartition.c
@@ -152,8 +152,8 @@ static INT __logicDiskRd (LW_DISKPART_OPERAT *pdpoLogic,
*********************************************************************************************************/
static INT __logicDiskIoctl (LW_DISKPART_OPERAT *pdpoLogic, INT iCmd, LONG lArg)
{
- PLW_BLK_RANGE pblkrLogic;
- LW_BLK_RANGE blkrPhy;
+ LW_BLK_RANGE *pblkrLogic, blkrPhy;
+ LW_BLK_METADATA *pblkmLogic, blkmPhy;
switch (iCmd) {
@@ -167,6 +167,17 @@ static INT __logicDiskIoctl (LW_DISKPART_OPERAT *pdpoLogic, INT iCmd, LONG
return (pdpoLogic->DPT_pblkdDisk->BLKD_pfuncBlkIoctl(pdpoLogic->DPT_pblkdDisk,
iCmd,
&blkrPhy));
+
+ case FIORDMETA:
+ case FIOWRMETA:
+ pblkmLogic = (PLW_BLK_METADATA)lArg;
+ blkmPhy.BLKM_pucBuf = pblkmLogic->BLKM_pucBuf;
+ blkmPhy.BLKM_ulSectorCnt = pblkmLogic->BLKM_ulSectorCnt;
+ blkmPhy.BLKM_ulStartSector = pblkmLogic->BLKM_ulStartSector
+ + pdpoLogic->DPO_dpnEntry.DPN_ulStartSector;
+ return (pdpoLogic->DPT_pblkdDisk->BLKD_pfuncBlkIoctl(pdpoLogic->DPT_pblkdDisk,
+ iCmd,
+ &blkmPhy));
default:
return (pdpoLogic->DPT_pblkdDisk->BLKD_pfuncBlkIoctl(pdpoLogic->DPT_pblkdDisk,
diff --git a/SylixOS/fs/tpsFs/tpsfs_port.h b/SylixOS/fs/tpsFs/tpsfs_port.h
index 5dd9aa1..ac6b15b 100644
--- a/SylixOS/fs/tpsFs/tpsfs_port.h
+++ b/SylixOS/fs/tpsFs/tpsfs_port.h
@@ -59,6 +59,14 @@ typedef struct tps_dev {
INT (*DEV_Trim)(struct tps_dev *pdev,
UINT64 ui64StartSector,
UINT64 uiSectorCnt); /* Trim磁盘 */
+ INT (*DEV_WriteMeta)(struct tps_dev *pdev,
+ PUCHAR pucBuf,
+ UINT64 ui64StartSector,
+ UINT64 uiSectorCnt); /* 写元数据 */
+ INT (*DEV_ReadMeta)(struct tps_dev *pdev,
+ PUCHAR pucBuf,
+ UINT64 ui64StartSector,
+ UINT64 uiSectorCnt); /* 读元数据 */
PVOID DEV_pvPriv; /* 私有成员 */
} TPS_DEV;
typedef TPS_DEV *PTPS_DEV;
diff --git a/SylixOS/fs/tpsFs/tpsfs_sylixos.c b/SylixOS/fs/tpsFs/tpsfs_sylixos.c
index 0d6d1bc..150a6ef 100644
--- a/SylixOS/fs/tpsFs/tpsfs_sylixos.c
+++ b/SylixOS/fs/tpsFs/tpsfs_sylixos.c
@@ -311,7 +311,7 @@ static INT __tpsFsDiskSync (PTPS_DEV pdev, UINT64 ui64StartSector, UINT64 uiSec
return (__blockIoDevIoctl((INT)iDrv, FIOSYNCMETA, (LONG)&blkrange));
}
/*********************************************************************************************************
-** 函数名称: __tpsFsDiskSync
+** 函数名称: __tpsFsDiskTrim
** 功能描述: 同步扇区数据到磁盘
** pdev 设备文件
** 输 入 : ui64StartSector 起始扇区
@@ -331,6 +331,50 @@ static INT __tpsFsDiskTrim (PTPS_DEV pdev, UINT64 ui64StartSector, UINT64 uiSec
return (__blockIoDevIoctl((INT)iDrv, FIOTRIM, (LONG)&blkrange));
}
/*********************************************************************************************************
+** 函数名称: __tpsFsDiskWrMeta
+** 功能描述: 写元数据扇区
+** pdev 设备文件
+** 输 入 : pucBuf 数据缓冲区
+** ui64StartSector 起始扇区
+** uiSectorCnt 扇区数
+** 输 出 : 0 别是成功, 非0 表示失败
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+static INT __tpsFsDiskWrMeta (PTPS_DEV pdev, PUCHAR pucBuf, UINT64 ui64StartSector, UINT64 uiSectorCnt)
+{
+ INT iDrv = __tpsFsDiskIndex(pdev);
+ LW_BLK_METADATA blkrange;
+
+ blkrange.BLKM_ulStartSector = (ULONG)(ui64StartSector);
+ blkrange.BLKM_ulSectorCnt = (ULONG)(uiSectorCnt);
+ blkrange.BLKM_pucBuf = pucBuf;
+
+ return (__blockIoDevIoctl((INT)iDrv, FIOWRMETA, (LONG)&blkrange));
+}
+/*********************************************************************************************************
+** 函数名称: __tpsFsDiskRdMeta
+** 功能描述: 读元数据扇区
+** pdev 设备文件
+** 输 入 : pucBuf 数据缓冲区
+** ui64StartSector 起始扇区
+** uiSectorCnt 扇区数
+** 输 出 : 0 别是成功, 非0 表示失败
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+static INT __tpsFsDiskRdMeta (PTPS_DEV pdev, PUCHAR pucBuf, UINT64 ui64StartSector, UINT64 uiSectorCnt)
+{
+ INT iDrv = __tpsFsDiskIndex(pdev);
+ LW_BLK_METADATA blkrange;
+
+ blkrange.BLKM_ulStartSector = (ULONG)(ui64StartSector);
+ blkrange.BLKM_ulSectorCnt = (ULONG)(uiSectorCnt);
+ blkrange.BLKM_pucBuf = pucBuf;
+
+ return (__blockIoDevIoctl((INT)iDrv, FIORDMETA, (LONG)&blkrange));
+}
+/*********************************************************************************************************
** 函数名称: API_TpsFsDrvInstall
** 功能描述: 安装 TPS 文件系统驱动程序
** 输 入 :
@@ -445,6 +489,8 @@ INT API_TpsFsDevCreate (PCHAR pcName, PLW_BLK_DEV pblkd)
ptpsvol->TPSVOL_dev.DEV_WriteSector = __tpsFsDiskWrite;
ptpsvol->TPSVOL_dev.DEV_Sync = __tpsFsDiskSync;
ptpsvol->TPSVOL_dev.DEV_Trim = __tpsFsDiskTrim;
+ ptpsvol->TPSVOL_dev.DEV_WriteMeta = __tpsFsDiskWrMeta;
+ ptpsvol->TPSVOL_dev.DEV_ReadMeta = __tpsFsDiskRdMeta;
ptpsvol->TPSVOL_bForceDelete = LW_FALSE; /* 不允许强制卸载卷 */
ptpsvol->TPSVOL_iDrv = iBlkdIndex; /* 记录驱动位置 */
diff --git a/SylixOS/fs/tpsFs/tpsfs_trans.c b/SylixOS/fs/tpsFs/tpsfs_trans.c
index d3d712e..473c006 100644
--- a/SylixOS/fs/tpsFs/tpsfs_trans.c
+++ b/SylixOS/fs/tpsFs/tpsfs_trans.c
@@ -449,8 +449,8 @@ static TPS_RESULT __tpsFsGetTrans (PTPS_SUPER_BLOCK psb, PTPS_TRANS ptrans, UIN
ptranssb->TSB_uiTransSecOff = (ui64Index & ((1 << (psb->SB_uiSectorShift - TPS_TRAN_SHIFT)) - 1))
<< TPS_TRAN_SHIFT;
- if (psb->SB_dev->DEV_ReadSector(psb->SB_dev, ptranssb->TSB_pucSecBuff,
- ptranssb->TSB_ui64TransCurSec, 1) != 0) {
+ if (psb->SB_dev->DEV_ReadMeta(psb->SB_dev, ptranssb->TSB_pucSecBuff,
+ ptranssb->TSB_ui64TransCurSec, 1) != 0) {
ptrans->TRANS_iStatus = TPS_TRANS_STATUS_UNINIT;
return (TPS_ERR_BUF_WRITE);
@@ -479,9 +479,9 @@ TPS_RESULT __tpsFsLoadTransData (PTPS_TRANS ptrans)
* 循环逆序列化扇区区间列表
*/
do {
- if (psb->SB_dev->DEV_ReadSector(psb->SB_dev, psb->SB_pucSectorBuf,
- (ptrans->TRANS_uiDataSecNum + ptrans->TRANS_uiDataSecCnt - 1),
- 1) != 0) {
+ if (psb->SB_dev->DEV_ReadMeta(psb->SB_dev, psb->SB_pucSectorBuf,
+ (ptrans->TRANS_uiDataSecNum + ptrans->TRANS_uiDataSecCnt - 1),
+ 1) != 0) {
return (TPS_ERR_BUF_WRITE);
}
@@ -563,8 +563,8 @@ TPS_RESULT tpsFsTransCommitAndFree (PTPS_TRANS ptrans)
for (j = 0; j < ptrans->TRANS_pdata->TD_secareaArr[i].TD_uiSecCnt; j += ui64SecWrCnt) {
ui64SecWrCnt = min((ptrans->TRANS_pdata->TD_secareaArr[i].TD_uiSecCnt - j),
psb->SB_uiSecPerBlk);
- if (psb->SB_dev->DEV_ReadSector(psb->SB_dev, psb->SB_pucSectorBuf,
- ui64DataSecCnt + j, ui64SecWrCnt) != 0) {
+ if (psb->SB_dev->DEV_ReadMeta(psb->SB_dev, psb->SB_pucSectorBuf,
+ ui64DataSecCnt + j, ui64SecWrCnt) != 0) {
psb->SB_uiFlags |= TPS_TRANS_FAULT;
return (TPS_ERR_TRANS_COMMIT_FAULT);
}
@@ -783,8 +783,8 @@ TPS_RESULT tspFsCheckTrans (PTPS_SUPER_BLOCK psb)
return (TPS_ERR_NONE);
}
/*********************************************************************************************************
-** 函数名称: tspFsCheckTrans
-** 功能描述: 从事务链表获取数据,因为部分磁盘数据可能被缓存在事务链表中
+** 函数名称: __tpsFsTransGetData
+** 功能描述: 从未完成事务中获取数据,因为部分磁盘数据可能被缓存在事务链表中
** 输 入 : psb 超级块指针
** pucSecBuf 扇区数据缓冲区
** ui64SecNum 扇区起始
@@ -793,31 +793,33 @@ TPS_RESULT tspFsCheckTrans (PTPS_SUPER_BLOCK psb)
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-static VOID __tpsFsTransGetData (PTPS_SUPER_BLOCK psb,
- PUCHAR pucSecBuf,
- UINT64 ui64SecNum,
- UINT64 ui64SecCnt)
+static TPS_RESULT __tpsFsTransGetData (PTPS_SUPER_BLOCK psb,
+ PUCHAR pucSecBuf,
+ UINT64 ui64SecNum,
+ UINT64 ui64SecCnt)
{
INT i;
UINT64 ui64SecAreaStart;
UINT64 ui64SecAreaCnt;
UINT64 ui64DataSecCnt;
PTPS_TRANS ptrans = psb->SB_ptranssb->TSB_ptrans;
- UINT uiSecNeedCpy;
PTPS_TRANS_DATA ptrdata;
+ UINT64 ui64CurSec;
- /*
- * 遍历事务链表
- */
- while (ptrans) {
- if ((ptrans->TRANS_iStatus != TPS_TRANS_STATUS_INIT) &&
- (ptrans->TRANS_iStatus != TPS_TRANS_STATUS_COMMIT)) { /* 跳过未初始化或以完成的事务 */
- ptrans = ptrans->TRANS_pnext;
- continue;
- }
+ if ((ptrans->TRANS_iStatus != TPS_TRANS_STATUS_INIT) &&
+ (ptrans->TRANS_iStatus != TPS_TRANS_STATUS_COMMIT)) { /* 跳过未初始化或以完成的事务 */
+ return (psb->SB_dev->DEV_ReadMeta(psb->SB_dev, pucSecBuf, ui64SecNum, ui64SecCnt));
+ }
+ if (psb->SB_dev->DEV_ReadMeta(psb->SB_dev, pucSecBuf,
+ ui64SecNum, ui64SecCnt) != TPS_ERR_NONE) {
+ return (TPS_ERR_BUF_READ);
+ }
+
+ for (ui64CurSec = ui64SecNum; ui64CurSec < (ui64SecNum + ui64SecCnt); ui64CurSec++) {
ptrdata = ptrans->TRANS_pdata;
- for (i = 0; i < ptrdata->TD_uiSecAreaCnt; i++) { /* 遍历扇区区间列表 */
+ i = ptrdata->TD_uiSecAreaCnt;
+ for (i--; i >= 0; i--) { /* 遍历扇区区间列表 */
ui64SecAreaStart = ptrdata->TD_secareaArr[i].TD_ui64SecStart;
ui64DataSecCnt = ptrans->TRANS_uiDataSecNum + ptrdata->TD_secareaArr[i].TD_uiSecOff;
ui64SecAreaCnt = ptrdata->TD_secareaArr[i].TD_uiSecCnt;
@@ -825,33 +827,19 @@ static VOID __tpsFsTransGetData (PTPS_SUPER_BLOCK psb,
/*
* 是否重叠,只需处理存在重叠的扇区区间
*/
- if (max(ui64SecAreaStart, ui64SecNum) >=
- min((ui64SecAreaStart + ui64SecAreaCnt), (ui64SecNum + ui64SecCnt))) {
- continue;
- }
-
- /*
- * 计算重叠区间大小
- */
- uiSecNeedCpy = min((ui64SecAreaStart + ui64SecAreaCnt), (ui64SecNum + ui64SecCnt)) -
- max(ui64SecAreaStart, ui64SecNum);
-
- if (ui64SecAreaStart > ui64SecNum) {
- psb->SB_dev->DEV_ReadSector(psb->SB_dev,
- pucSecBuf + ((ui64SecAreaStart - ui64SecNum)
- << psb->SB_uiSectorShift),
- ui64DataSecCnt,
- uiSecNeedCpy);
- } else {
- psb->SB_dev->DEV_ReadSector(psb->SB_dev,
- pucSecBuf,
- ui64DataSecCnt + ui64SecNum - ui64SecAreaStart,
- uiSecNeedCpy);
+ if (ui64CurSec >= ui64SecAreaStart && ui64CurSec < (ui64SecAreaStart + ui64SecAreaCnt)) {
+ if (psb->SB_dev->DEV_ReadMeta(psb->SB_dev,
+ pucSecBuf + ((ui64CurSec - ui64SecNum) << psb->SB_uiSectorShift),
+ ui64DataSecCnt + (ui64CurSec - ui64SecAreaStart),
+ 1) != TPS_ERR_NONE) {
+ return (TPS_ERR_BUF_READ);
+ }
+ break;
}
}
-
- ptrans = ptrans->TRANS_pnext;
}
+
+ return (TPS_ERR_NONE);
}
/*********************************************************************************************************
** 函数名称: tspFsCheckTrans
@@ -1009,12 +997,11 @@ TPS_RESULT tpsFsTransRead (PTPS_SUPER_BLOCK psb,
if (uiSecOff != 0) { /* 起始位置不对齐 */
uiReadLen = uiSecSize - uiSecOff;
uiReadLen = min(szLen, uiReadLen);
- if (psb->SB_dev->DEV_ReadSector(psb->SB_dev, pucSecBuf, ui64SecNum, 1) != 0) {
+
+ if (__tpsFsTransGetData(psb, pucSecBuf, ui64SecNum, 1) != TPS_ERR_NONE) {
return (TPS_ERR_BUF_READ);
}
- __tpsFsTransGetData(psb, pucSecBuf, ui64SecNum, 1); /* 从事务链表获取数据 */
-
lib_memcpy(pucBuff, pucSecBuf + uiSecOff, uiReadLen);
szCompleted += uiReadLen;
@@ -1025,13 +1012,11 @@ TPS_RESULT tpsFsTransRead (PTPS_SUPER_BLOCK psb,
}
if (ui64SecCnt > 0) { /* 对齐扇区直接写缓冲区 */
- if (psb->SB_dev->DEV_ReadSector(psb->SB_dev, pucBuff + szCompleted,
- ui64SecNum, ui64SecCnt) != 0) {
+ if (__tpsFsTransGetData(psb, pucBuff + szCompleted,
+ ui64SecNum, ui64SecCnt) != TPS_ERR_NONE) {
return (TPS_ERR_BUF_READ);
}
- __tpsFsTransGetData(psb, pucBuff + szCompleted, ui64SecNum, ui64SecCnt);
-
szCompleted += (size_t)(ui64SecCnt * uiSecSize);
ui64SecNum += ui64SecCnt;
ui64SecCnt = 0;
@@ -1040,12 +1025,10 @@ TPS_RESULT tpsFsTransRead (PTPS_SUPER_BLOCK psb,
if (szCompleted < szLen) { /* 结束位置不对齐 */
uiReadLen = ((uiOff + szLen) & psb->SB_uiSectorMask);
if (uiReadLen > 0) {
- if (psb->SB_dev->DEV_ReadSector(psb->SB_dev, pucSecBuf, ui64SecNum, 1) != 0) {
+ if (__tpsFsTransGetData(psb, pucSecBuf, ui64SecNum, 1) != TPS_ERR_NONE) {
return (TPS_ERR_BUF_READ);
}
- __tpsFsTransGetData(psb, pucSecBuf, ui64SecNum, 1); /* 从事务链表获取数据 */
-
lib_memcpy(pucBuff + szCompleted, pucSecBuf, uiReadLen);
szCompleted += uiReadLen;
@@ -1102,11 +1085,10 @@ TPS_RESULT tpsFsTransWrite (PTPS_TRANS ptrans,
if (uiSecOff != 0) { /* 起始位置不对齐,先读取再写入 */
uiReadLen = uiSecSize - uiSecOff;
uiReadLen = min(szLen, uiReadLen);
- if (psb->SB_dev->DEV_ReadSector(psb->SB_dev, pucSecBuf, ui64SecNum, 1) != 0) {
- return (TPS_ERR_BUF_READ);
- }
- __tpsFsTransGetData(psb, pucSecBuf, ui64SecNum, 1); /* 从事务链表获取数据 */
+ if (__tpsFsTransGetData(psb, pucSecBuf, ui64SecNum, 1) != TPS_ERR_NONE ) {
+ return (TPS_ERR_BUF_WRITE);
+ }
lib_memcpy(pucSecBuf + uiSecOff, pucBuff, uiReadLen);
@@ -1135,12 +1117,10 @@ TPS_RESULT tpsFsTransWrite (PTPS_TRANS ptrans,
if (szCompleted < szLen) { /* 结束位置不对齐,先读取再写入 */
uiReadLen = ((uiOff + szLen) & psb->SB_uiSectorMask);
if (uiReadLen > 0) {
- if (psb->SB_dev->DEV_ReadSector(psb->SB_dev, pucSecBuf, ui64SecNum, 1) != 0) {
- return (TPS_ERR_BUF_READ);
+ if (__tpsFsTransGetData(psb, pucSecBuf, ui64SecNum, 1) != TPS_ERR_NONE) {
+ return (TPS_ERR_BUF_WRITE);
}
- __tpsFsTransGetData(psb, pucSecBuf, ui64SecNum, 1); /* 从事务链表获取数据 */
-
lib_memcpy(pucSecBuf, pucBuff + szCompleted, uiReadLen);
if (__tpsFsTransPutData(ptrans, pucSecBuf, ui64SecNum, 1) != TPS_ERR_NONE) {
diff --git a/SylixOS/kernel/include/k_kernel.h b/SylixOS/kernel/include/k_kernel.h
index 009b377..39a79b1 100644
--- a/SylixOS/kernel/include/k_kernel.h
+++ b/SylixOS/kernel/include/k_kernel.h
@@ -53,7 +53,7 @@
#define __SYLIXOS_MAJOR_VER 2
#define __SYLIXOS_MINOR_VER 0
-#define __SYLIXOS_PATCH_VER 2
+#define __SYLIXOS_PATCH_VER 3
#define __SYLIXOS_PATCH_PAD 1
/*********************************************************************************************************
diff --git a/SylixOS/loader/include/loader_vppatch.h b/SylixOS/loader/include/loader_vppatch.h
index 16a7840..7f1883a 100644
--- a/SylixOS/loader/include/loader_vppatch.h
+++ b/SylixOS/loader/include/loader_vppatch.h
@@ -99,6 +99,7 @@ typedef struct lw_ld_vproc {
pid_t VP_pidGroup; /* 组 id 号 */
LW_LIST_LINE_HEADER VP_plineThread; /* 子线程链表 */
+ ULONG VP_ulFdSize; /* 进程 fd 表大小 */
LW_FD_DESC VP_fddescTbl[LW_VP_MAX_FILES]; /* 进程 fd 表 */
BOOL VP_bKillPrepare; /* 清除进程前是否需要 release */
@@ -279,6 +280,8 @@ INT vprocIoFileRefDecArryByPid(pid_t pid, INT iFd[], INT iNum
*********************************************************************************************************/
VOID vprocIoReclaim(pid_t pid, BOOL bIsExec);
+ULONG vprocIoFileSizeGet(LW_LD_VPROC *pvproc);
+INT vprocIoFileSizeSet(LW_LD_VPROC *pvproc, ULONG ulFdSize);
/*********************************************************************************************************
进程线程堆栈
diff --git a/SylixOS/loader/src/loader_file.c b/SylixOS/loader/src/loader_file.c
index d20567f..1fe44fd 100644
--- a/SylixOS/loader/src/loader_file.c
+++ b/SylixOS/loader/src/loader_file.c
@@ -135,6 +135,7 @@ VOID vprocIoFileInit (LW_LD_VPROC *pvproc, ULONG ulExts)
pvprocFather = pvproc->VP_pvprocFather;
if (pvprocFather) { /* 如果有父亲则继承父亲所有文件*/
if (!(ulExts & POSIX_SPAWN_EXT_NO_FILE_INHERIT)) {
+ pvproc->VP_ulFdSize = pvprocFather->VP_ulFdSize;
iMax = (ulExts & POSIX_SPAWN_EXT_NO_FILE_INHERIT_EXC_STD)
? 3 : LW_VP_MAX_FILES;
_IosLock();
@@ -149,9 +150,13 @@ VOID vprocIoFileInit (LW_LD_VPROC *pvproc, ULONG ulExts)
}
}
_IosUnlock();
+
+ } else {
+ pvproc->VP_ulFdSize = LW_VP_MAX_FILES;
}
} else { /* 不存在父亲, 则继承系统的 */
+ pvproc->VP_ulFdSize = LW_VP_MAX_FILES;
_IosLock();
for (i = 0; i < 3; i++) { /* 继承标准文件描述符 */
pfdentry = _IosFileGetKernel(i, LW_FALSE);
@@ -178,6 +183,7 @@ INT vprocIoFileDupFrom (pid_t pidSrc, INT iFd)
{
INT i;
LW_LD_VPROC *pvproc;
+ LW_LD_VPROC *pvprocCur;
PLW_FD_DESC pfddesc;
PLW_FD_ENTRY pfdentry;
@@ -200,9 +206,10 @@ INT vprocIoFileDupFrom (pid_t pidSrc, INT iFd)
return (PX_ERROR);
}
- pfddesc = &__LW_VP_GET_CUR_PROC()->VP_fddescTbl[0]; /* 从本进程 0 开始搜索 */
+ pvprocCur = __LW_VP_GET_CUR_PROC();
+ pfddesc = &pvprocCur->VP_fddescTbl[0]; /* 从本进程 0 开始搜索 */
- for (i = 0; i < LW_VP_MAX_FILES; i++, pfddesc++) {
+ for (i = 0; i < pvprocCur->VP_ulFdSize; i++, pfddesc++) {
if (!pfddesc->FDDESC_pfdentry) {
pfddesc->FDDESC_pfdentry = pfdentry;
pfddesc->FDDESC_bCloExec = LW_FALSE;
@@ -594,7 +601,7 @@ INT vprocIoFileDup (PLW_FD_ENTRY pfdentry, INT iMinFd)
PLW_FD_DESC pfddesc;
LW_LD_VPROC *pvproc = __LW_VP_GET_CUR_PROC();
- for (i = iMinFd; i < LW_VP_MAX_FILES; i++, pfddesc++) {
+ for (i = iMinFd; i < pvproc->VP_ulFdSize; i++, pfddesc++) {
pfddesc = &pvproc->VP_fddescTbl[i];
if (!pfddesc->FDDESC_pfdentry) {
pfddesc->FDDESC_pfdentry = pfdentry;
@@ -619,12 +626,13 @@ INT vprocIoFileDup (PLW_FD_ENTRY pfdentry, INT iMinFd)
INT vprocIoFileDup2 (PLW_FD_ENTRY pfdentry, INT iNewFd)
{
PLW_FD_DESC pfddesc;
+ LW_LD_VPROC *pvproc = __LW_VP_GET_CUR_PROC();
- if (iNewFd < 0 || iNewFd >= LW_VP_MAX_FILES) {
+ if (iNewFd < 0 || iNewFd >= pvproc->VP_ulFdSize) {
return (PX_ERROR);
}
- pfddesc = &__LW_VP_GET_CUR_PROC()->VP_fddescTbl[iNewFd];
+ pfddesc = &pvproc->VP_fddescTbl[iNewFd];
if (!pfddesc->FDDESC_pfdentry) {
pfddesc->FDDESC_pfdentry = pfdentry;
@@ -651,7 +659,7 @@ static INT vprocIoFileDup2Ex (LW_LD_VPROC *pvproc, PLW_FD_ENTRY pfdentry, INT
{
PLW_FD_DESC pfddesc;
- if (iNewFd < 0 || iNewFd >= LW_VP_MAX_FILES) {
+ if (iNewFd < 0 || iNewFd >= pvproc->VP_ulFdSize) {
return (PX_ERROR);
}
@@ -753,6 +761,37 @@ INT vprocIoFileRefGet (INT iFd)
return (PX_ERROR);
}
+/*********************************************************************************************************
+** 函数名称: vprocIoFileSizeGet
+** 功能描述: 获取指定进程描述符表大小
+** 输 入 : pvproc 进程控制块
+** 输 出 : 描述符表大小
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+ULONG vprocIoFileSizeGet (LW_LD_VPROC *pvproc)
+{
+ return (pvproc->VP_ulFdSize);
+}
+/*********************************************************************************************************
+** 函数名称: vprocIoFileSizeSet
+** 功能描述: 设置当前进程描述符表大小
+** 输 入 : pvproc 进程控制块
+** ulFdSize 描述符表大小
+** 输 出 : ERROR or OK
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+INT vprocIoFileSizeSet (LW_LD_VPROC *pvproc, ULONG ulFdSize)
+{
+ if (ulFdSize < 3 || ulFdSize > LW_VP_MAX_FILES) {
+ return (PX_ERROR);
+ }
+
+ pvproc->VP_ulFdSize = ulFdSize;
+
+ return (ERROR_NONE);
+}
#endif /* LW_CFG_MODULELOADER_EN > 0 */
/*********************************************************************************************************
diff --git a/SylixOS/posix/resource/resource.c b/SylixOS/posix/resource/resource.c
index 99fdc0c..d8566b7 100644
--- a/SylixOS/posix/resource/resource.c
+++ b/SylixOS/posix/resource/resource.c
@@ -22,6 +22,7 @@
2013.06.13 实现 setpriority getpriority 与 nice.
setpriority 与 getpriority 优先级参数必须在 PRIO_MIN PRIO_MAX 之间. 数值越小, 优先级越高.
2014.07.04 修正 getpriority 与 setpriority 参数处理错误.
+2020.10.26 加入进程文件描述符打开数量限制.
*********************************************************************************************************/
#define __SYLIXOS_KERNEL
#include "unistd.h"
@@ -86,8 +87,41 @@ int getrusage (int who, struct rusage *r_usage)
LW_API
int getrlimit (int resource, struct rlimit *rlp)
{
+#if LW_CFG_MODULELOADER_EN > 0
+ INT iRet = PX_ERROR;
+ LW_LD_VPROC *pvproc;
+
+ if (!rlp) {
+ errno = EINVAL;
+ return (PX_ERROR);
+ }
+
+ pvproc = __LW_VP_GET_CUR_PROC();
+
+ switch (resource) {
+
+ case RLIMIT_OFILE:
+ if (pvproc) {
+ rlp->rlim_cur = (rlim_t)vprocIoFileSizeGet(pvproc);
+ rlp->rlim_max = LW_VP_MAX_FILES;
+ } else {
+ rlp->rlim_cur = LW_CFG_MAX_FILES;
+ rlp->rlim_max = LW_CFG_MAX_FILES;
+ }
+ iRet = ERROR_NONE;
+ break;
+
+ default:
+ errno = ENOSYS;
+ iRet = PX_ERROR;
+ break;
+ }
+
+ return (iRet);
+#else
errno = ENOSYS;
return (PX_ERROR);
+#endif
}
/*********************************************************************************************************
** 函数名称: setrlimit
@@ -102,8 +136,41 @@ int getrlimit (int resource, struct rlimit *rlp)
LW_API
int setrlimit (int resource, const struct rlimit *rlp)
{
+#if LW_CFG_MODULELOADER_EN > 0
+ INT iRet = PX_ERROR;
+ LW_LD_VPROC *pvproc;
+
+ if (!rlp || (rlp->rlim_max > rlp->rlim_cur)) {
+ errno = EINVAL;
+ return (PX_ERROR);
+ }
+
+ pvproc = __LW_VP_GET_CUR_PROC();
+
+ switch (resource) {
+
+ case RLIMIT_OFILE:
+ if (pvproc) {
+ iRet = vprocIoFileSizeSet(pvproc, rlp->rlim_cur);
+ if (iRet) {
+ errno = EINVAL;
+ }
+ } else {
+ errno = ENOSYS;
+ }
+ break;
+
+ default:
+ errno = ENOSYS;
+ iRet = PX_ERROR;
+ break;
+ }
+
+ return (iRet);
+#else
errno = ENOSYS;
return (PX_ERROR);
+#endif
}
/*********************************************************************************************************
** 函数名称: __gprio_hook
@@ -121,7 +188,7 @@ int setrlimit (int resource, const struct rlimit *rlp)
static void __gprio_hook (PLW_CLASS_TCB ptcb, int *ret, int which, id_t who, UINT8 *pucPriority)
{
- LW_LD_VPROC *pvproc = __LW_VP_GET_TCB_PROC(ptcb);
+ LW_LD_VPROC *pvproc = __LW_VP_GET_TCB_PROC(ptcb);
if (pvproc) {
switch (which) {
@@ -168,7 +235,7 @@ static void __gprio_hook (PLW_CLASS_TCB ptcb, int *ret, int which, id_t who,
*********************************************************************************************************/
static void __sprio_hook (PLW_CLASS_TCB ptcb, int *ret, int which, id_t who, UINT8 *pucPriority)
{
- LW_LD_VPROC *pvproc = __LW_VP_GET_TCB_PROC(ptcb);
+ LW_LD_VPROC *pvproc = __LW_VP_GET_TCB_PROC(ptcb);
if (pvproc) {
switch (which) {
diff --git a/SylixOS/system/device/ahci/ahci.c b/SylixOS/system/device/ahci/ahci.c
index b8d54a3..f32c2b8 100644
--- a/SylixOS/system/device/ahci/ahci.c
+++ b/SylixOS/system/device/ahci/ahci.c
@@ -2773,6 +2773,10 @@ static PLW_BLK_DEV __ahciBlkDevCreate (AHCI_CTRL_HANDLE hCtrl,
} else {
dcattrl.DCATTR_iPipeline = 1;
}
+
+ if (hDrive->AHCIDRIVE_bTrim != LW_TRUE) { /* 是否支持 TRIM 的 SSD */
+ dcattrl.DCATTR_iBurstOpt |= LW_DCATTR_BOPT_META_ONE_BURST;
+ }
/* 挂载设备 */
if (!hDev->AHCIDEV_pvOemdisk) {
hDev->AHCIDEV_pvOemdisk = (PVOID)API_OemDiskMount2(AHCI_MEDIA_NAME, hBlkDev, &dcattrl);
diff --git a/SylixOS/system/device/ata/ata.c b/SylixOS/system/device/ata/ata.c
index 6d91c32..7dfb5cf 100644
--- a/SylixOS/system/device/ata/ata.c
+++ b/SylixOS/system/device/ata/ata.c
@@ -1015,7 +1015,7 @@ static INT ataDriveConfig (ATA_DRV_HANDLE hCtrlDrv, UINT uiCtrl, UINT uiDriv
#if (ATA_DISK_MOUNTEX_EN > 0)
dcattrl.DCATTR_pvCacheMem = LW_NULL;
- dcattrl.DCATTR_iBurstOpt = LW_DCATTR_BOPT_CACHE_COHERENCE;
+ dcattrl.DCATTR_iBurstOpt = LW_DCATTR_BOPT_META_ONE_BURST;
if (hInfo->ATADINFO_stCacheMemSize) {
dcattrl.DCATTR_stMemSize = hInfo->ATADINFO_stCacheMemSize;
@@ -1052,12 +1052,7 @@ static INT ataDriveConfig (ATA_DRV_HANDLE hCtrlDrv, UINT uiCtrl, UINT uiDriv
dcattrl.DCATTR_iMsgCount = ATA_CACHE_MSG_CNT;
}
- if (hInfo->ATADINFO_iPipeline) {
- dcattrl.DCATTR_bParallel = LW_TRUE;
-
- } else {
- dcattrl.DCATTR_bParallel = LW_FALSE;
- }
+ dcattrl.DCATTR_bParallel = LW_FALSE;
API_OemDiskMount2(ATA_ATA_MEDIA_NAME, hBlkDev, &dcattrl);
diff --git a/SylixOS/system/device/ata/ataCfg.h b/SylixOS/system/device/ata/ataCfg.h
index 5d62915..351b8b9 100644
--- a/SylixOS/system/device/ata/ataCfg.h
+++ b/SylixOS/system/device/ata/ataCfg.h
@@ -53,14 +53,14 @@
磁盘 CACHE 参数
*********************************************************************************************************/
#define ATA_CACHE_SIZE (1 * LW_CFG_MB_SIZE) /* 磁盘缓存大小 */
-#define ATA_CACHE_BURST_RD 64 /* 读猝发参数 */
+#define ATA_CACHE_BURST_RD 32 /* 读猝发参数默认是写的一半 */
#define ATA_CACHE_BURST_WR 64 /* 写猝发参数 */
-#define ATA_CACHE_PL (LW_NCPUS) /* 并发线程数量 */
+#define ATA_CACHE_PL 1 /* 并发线程数量 */
#define ATA_CACHE_MSG_CNT ((ATA_CACHE_PL + 1) * 2) /* 管线消息队列缓存个数 */
/*********************************************************************************************************
磁盘挂载选项
*********************************************************************************************************/
-#define ATA_DISK_MOUNTEX_EN 0 /* 是否使能支持管线模式 */
+#define ATA_DISK_MOUNTEX_EN 1 /* 是否使能支持管线模式 */
/*********************************************************************************************************
扇区操作参数 (扇区缓冲区大小依赖磁盘 CACHE)
*********************************************************************************************************/
diff --git a/SylixOS/system/device/ata/ataLib.c b/SylixOS/system/device/ata/ataLib.c
index f4d2e86..822238e 100644
--- a/SylixOS/system/device/ata/ataLib.c
+++ b/SylixOS/system/device/ata/ataLib.c
@@ -615,6 +615,13 @@ VOID ataCtrlDelay (ATA_CTRL_HANDLE hCtrl)
ATA_IO_BYTES_READ(hCtrl, ATA_A_STATUS_ADDR(hCtrl), &ucReg, 1);
ATA_IO_BYTES_READ(hCtrl, ATA_A_STATUS_ADDR(hCtrl), &ucReg, 1);
ATA_IO_BYTES_READ(hCtrl, ATA_A_STATUS_ADDR(hCtrl), &ucReg, 1);
+
+ ATA_IO_BYTES_READ(hCtrl, ATA_A_STATUS_ADDR(hCtrl), &ucReg, 1);
+ ATA_IO_BYTES_READ(hCtrl, ATA_A_STATUS_ADDR(hCtrl), &ucReg, 1);
+ ATA_IO_BYTES_READ(hCtrl, ATA_A_STATUS_ADDR(hCtrl), &ucReg, 1);
+ ATA_IO_BYTES_READ(hCtrl, ATA_A_STATUS_ADDR(hCtrl), &ucReg, 1);
+ ATA_IO_BYTES_READ(hCtrl, ATA_A_STATUS_ADDR(hCtrl), &ucReg, 1);
+ ATA_IO_BYTES_READ(hCtrl, ATA_A_STATUS_ADDR(hCtrl), &ucReg, 1);
}
/*********************************************************************************************************
** 函数名称: ataDriveCommandSend
diff --git a/SylixOS/system/device/block/blockIo.h b/SylixOS/system/device/block/blockIo.h
index 6755c86..bf314e1 100644
--- a/SylixOS/system/device/block/blockIo.h
+++ b/SylixOS/system/device/block/blockIo.h
@@ -148,6 +148,12 @@ typedef struct {
} LW_BLK_RANGE;
typedef LW_BLK_RANGE *PLW_BLK_RANGE;
+typedef struct {
+ ULONG BLKM_ulStartSector; /* 起始扇区 */
+ ULONG BLKM_ulSectorCnt; /* 结束扇区 */
+ PUCHAR BLKM_pucBuf; /* 数据缓冲区 */
+} LW_BLK_METADATA;
+typedef LW_BLK_METADATA *PLW_BLK_METADATA;
#endif /* __SYLIXOS_KERNEL */
/*********************************************************************************************************
磁盘设备必须要支持的通用 FIO 命令如下:
diff --git a/SylixOS/system/include/s_option.h b/SylixOS/system/include/s_option.h
index 0b4b0a8..abc4909 100644
--- a/SylixOS/system/include/s_option.h
+++ b/SylixOS/system/include/s_option.h
@@ -126,6 +126,8 @@
#ifdef __SYLIXOS_KERNEL
#define FIOTRIM LW_OSIOW('f', 31, LW_BLK_RANGE) /* ATA TRIM command */
#define FIOSYNCMETA LW_OSIOW('f', 32, LW_BLK_RANGE) /* sync range sector to disk */
+#define FIORDMETA LW_OSIOR('f', 57, LW_BLK_METADATA) /* read metadata */
+#define FIOWRMETA LW_OSIOW('f', 58, LW_BLK_METADATA) /* write metadata */
#endif
#define FIOLABELGET LW_OSIOR('f', 33, LW_PATHB) /* get volume label */