Data processing method and device, storage equipment and storage medium

By using a double cache structure to process write requests in the storage device, the problems of write conflicts and frequent rewritten are solved, the read and write performance of the storage device and the host write efficiency are improved, and the service life of the flash memory chip is extended.

CN119002815AActive Publication Date: 2024-11-22DAPUSTOR CORP

Patent Information

Application Number
CN202411140940.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-19
Publication Date
2024-11-22
Estimated Expiration
2044-08-19

AI Technical Summary

Technical Problem

The write performance of existing storage devices is limited by the memory read and write performance. Frequent data write and read out lead to a degradation in the host's write performance, and the performance efficiency of the storage device is inefficient due to write conflicts and frequent rewritten writing.

Method used

Using a double cache structure, the main control chip determines whether there is a conflict in the LBA in the data writing request. If it exists, the data will be written to the second cache. After the conflict is eliminated, it will be written to the first cache, and finally transmitted to the flash memory chip. Multi-level storage structure alleviates write conflicts and reduces the frequency of read and write in memory data.

Benefits of technology

It improves the overall read and write performance of the storage device, optimizes the write efficiency of the host, extends the service life of the flash memory chip, and reduces the delay caused by write conflicts.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119002815A_ABST
    Figure CN119002815A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a data processing method and device, storage equipment and a storage medium. The method and device are used for optimizing the writing performance and efficiency of the storage equipment. The method provided by the embodiment of the invention comprises the following steps: receiving a data writing request, wherein the data writing request comprises a logical block address LBA of a first cache to be accessed and target data; judging whether the target data has a writing conflict in the first cache or not according to the LBA; if the writing conflict exists, writing the target data into a second cache; and if the target data written into the second cache does not have the writing conflict in the first cache, transmitting the target data written into the second cache to the first cache, so that the main control chip transmits the target data written into the first cache to the flash memory chip. By performing data conflict processing among different caches, the memory read-write frequency of the storage device is reduced, and the write performance of the host is improved, so that the problem that the write performance of the storage device and the host is limited in the prior art is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of data storage technology, and in particular to a data processing method, apparatus, storage device, and storage medium. Background Art

[0002] Storage devices are often used to read and write storage data. The write data transmitted by the host needs to be transferred to the memory DDR of the storage device through the main control chip of the storage device, and then the write data in the memory of the storage device is written into the flash memory chip of the storage device.

[0003] The method for implementing the above-mentioned data writing in the prior art requires allocating a memory space specifically for temporarily storing write data from the memory of the storage device. The data to be written is transmitted to the memory of the storage device through the main control chip. The software program in the storage device will manage, group and handle conflicts for the write data temporarily stored in the memory, and finally write into the flash memory particles and release the above-mentioned memory space specifically for temporarily storing write data.

[0004] However, in the prior art, the write performance of storage devices and hosts is mainly limited by the read and write performance of the storage device memory. Frequent writing and reading of write data in the storage device memory will cause the host write performance to be only half of the memory performance, that is, the read and write directions each account for half of the performance, thus causing the host write performance efficiency to decrease. Summary of the invention

[0005] Based on the above problems, the embodiments of the present application provide a data processing method, apparatus, storage device and storage medium, the purpose of which is to optimize the host write performance.

[0006] In a first aspect, an embodiment of the present application provides a data processing method, which is applied to a storage device, wherein the storage device includes a main control chip, a first cache, a second cache, and a flash memory chip, and the method includes:

[0007] Receive a data write request, wherein the data write request includes a logical block address (LBA, Logical Block Address) of a first cache to be accessed and target data;

[0008] Determining whether there is a write conflict for the target data in the first cache according to the LBA;

[0009] If there is a write conflict, writing the target data into the second cache;

[0010] Determining whether target data written into the second cache has a write conflict in the first cache according to the LBA;

[0011] If there is no write conflict, the target data written into the second cache is transferred to the first cache, so that the main control chip of the storage device transfers the target data written into the first cache to the flash memory chip.

[0012] In one embodiment, after determining whether the target data has a write conflict in the first cache according to the LBA, the method further includes:

[0013] If there is no write conflict, the target data is written into the first cache, so that the main control chip of the storage device transfers the target data written into the first cache to the flash memory chip.

[0014] In one embodiment, after writing the target data into the second cache if there is a write conflict, the method further includes:

[0015] If the target data is unaligned data and the starting address of the target data is continuous with the ending address of the written data of the LBA, the target data written into the second cache is transferred to the first cache, so that the main control chip of the storage device transfers the target data written into the first cache to the flash memory chip.

[0016] In one embodiment, determining whether there is a write conflict for the target data in the first cache according to the LBA includes:

[0017] In response to the received multiple data write requests, determining whether LBAs of the multiple data write requests overlap;

[0018] If the LBAs of the multiple data write requests overlap, the received data write requests are executed sequentially;

[0019] If the LBAs of the multiple data write requests do not overlap, the received data write requests are executed simultaneously.

[0020] In one embodiment, determining whether there is a write conflict for the target data in the first cache according to the LBA includes:

[0021] Acquire a pre-stored cache table; the cache table includes storage location information of the written data in the first cache;

[0022] It is determined whether there is a write conflict for the target data in the first cache according to the LBA of the first cache to be accessed and the storage location information of the data already written in the first cache.

[0023] In one embodiment, the first cache includes a plurality of logic blocks, and the step of transferring the target data written into the first cache to the flash memory chip includes:

[0024] When the storage data amount of any of the logic blocks meets a preset data amount threshold, the written data in the logic block is transferred to the flash memory chip.

[0025] In one embodiment, the first cache includes a plurality of logical blocks, each of the logical blocks includes a plurality of sectors, the flash memory chip stores a preset alignment write rule, and the target data written in the first cache is transferred to the flash memory chip, comprising:

[0026] When the cache duration of the logical block meets the preset time threshold, if the written data in the logical block does not meet the preset alignment write rule, determine a target sector that does not meet the preset alignment write rule and obtain an index of the target sector;

[0027] Acquire first supplementary data from the flash memory chip according to the storage location information of the data written in the target sector and the index of the target sector;

[0028] The first supplementary data and the written data of the logic block are combined and transmitted to the flash memory chip.

[0029] In a second aspect, an embodiment of the present application further provides a data processing device, which is applied to a storage device, wherein the storage device includes a main control chip, a first cache, a second cache, and a flash memory chip, and the data processing device includes:

[0030] A request receiving unit, configured to receive a data write request, wherein the data write request includes a logical block address LBA of a first cache to be accessed and target data;

[0031] a conflict detection unit, configured to determine whether there is a write conflict for the target data in the first cache according to the LBA;

[0032] a data transmission unit, configured to write the target data into the second cache if there is a write conflict;

[0033] The conflict detection unit is further used to determine whether the target data written into the second cache has a write conflict in the first cache according to the LBA;

[0034] The data transmission unit is further configured to transmit the target data written into the second cache to the first cache if there is no write conflict, so that the main control chip of the storage device transmits the target data written into the first cache to the flash memory chip.

[0035] In a third aspect, an embodiment of the present application further provides a storage device, comprising a main control chip, a first cache, a second cache and a flash memory chip, wherein the main control chip, the first cache, the second cache and the flash memory chip are all communicated with each other, the main control chip comprises a memory and a processor, and the main control chip implements the data processing method described in the first aspect above by running a computer program.

[0036] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the data processing method as described in the first aspect above.

[0037] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages: after receiving a data write request, it is determined whether there is a write conflict according to the LBA. If there is a write conflict in the first cache, the target data is written to the second cache, and after the conflict is eliminated, the target data is transferred to the first cache, and finally written to the flash memory chip. In this way, through a multi-level storage structure, the second cache can be flexibly used to alleviate the write conflict problem, reduce the data read and write frequency in the memory and the delay caused by the write conflict of the first cache, improve the overall read and write performance of the storage device, and thus optimize the write efficiency of the host. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0039] Figure 1 A schematic diagram of a system architecture provided for an embodiment of the present application;

[0040] Figure 2 A schematic diagram of a data processing method provided in an embodiment of the present application;

[0041] Figure 3 A schematic diagram of a data processing method provided in an embodiment of the present application;

[0042] Figure 4 A schematic diagram of the structure of a data processing device provided in an embodiment of the present application;

[0043] Figure 5 A schematic diagram of the structure of a storage device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0044] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0045] In addition, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance. It should be noted that the features in the embodiments of the present application can be combined with each other without conflict.

[0046] Storage devices are often used to read and write storage data. The write data transmitted by the host needs to be transferred to the memory of the storage device through the main control chip of the storage device, and then the write data in the memory of the storage device is written into the flash memory chip of the storage device.

[0047] Please refer to Figure 1 , Figure 1 A schematic diagram of the system architecture of a data processing system provided in an embodiment of the present application. The data processing system 100 provided in an embodiment of the present application may include a host 101 and a storage device 102, and the host may refer to a device that accesses a storage device to access data in the storage device. The host may be virtual, such as a virtual machine. The host may also be a physical device, such as a personal computer, a server, a laptop, a smart phone, a tablet computer, and the like. The storage device 102 may communicate with the host 101, and data may be written to the storage device 102 through the host 101. Among them, the storage device 102 may include a main control chip 103, a first cache 104, a second cache 105, and a flash memory chip 106, the main control chip 103 is connected to the first cache 104, the second cache 105, and the flash memory chip 106 to achieve communication, and the storage device 102 communicates with the host 101 through the main control chip 103. The main control chip 103 executes any of the following data processing methods by running a computer program or instruction.

[0048] In an embodiment of the present application, the storage device 102 may include a solid state drive (SSD) and a mobile device (such as a mobile phone, a tablet computer), etc., and the cache for temporarily storing or managing conflicts of written data may include a first cache 104 and a second cache 105. In an embodiment of the present application, the first cache 104 may use a storage medium with a higher read and write speed, such as a static random access memory (SRAM). The first cache 104 can be understood as a hardware cache. Taking SRAM as an example, the hardware cache refers to a section of SRAM space managed by the hardware module of the storage device 102. The allocation of the SRAM space is completely automatically completed by the hardware module, and the software module is only responsible for space release. The second cache 105 can use a dynamic random access memory (DRAM), a double data rate synchronous dynamic random access memory (DDR), and the second cache 105 can be understood as a software cache. Taking DDR as an example, the software cache refers to a section of DDR space managed by software logic. The entire life cycle of the software cache, including the allocation, use, management and release of space, is controlled by the software module. Through this hierarchical caching strategy, the storage device can balance the requirements of speed and capacity to achieve high-performance and efficient data access. The flash memory chip 106 is a non-volatile storage chip used for persistent storage of data in the storage device 102, usually using NAND Flash. The main control chip 103 may include a central processing unit (CPU, Central Processing Unit / Processor), a system-level chip (SOC, System on a Chip), etc.

[0049] Under the same conditions, when only dynamic random access memory such as DDR is used as software cache, the host write performance is only about 10GB / s; when only static random access memory such as SRAM is used as hardware cache, the host write performance can reach 11GB / s. However, in the data processing method provided by the present application, by combining the first cache and the second cache (i.e., the software cache and the hardware cache are combined) to manage the conflict of the written data, the host write performance can be improved to 12GB / s. Therefore, the embodiment of the present application not only speeds up the processing speed of data writing, but also improves the write performance of the storage device and the host.

[0050] The following will further describe the various embodiments of the present application in detail in conjunction with the accompanying drawings and the system architecture of the above-mentioned data processing system.

[0051] Please refer to Figure 2 , Figure 2 The following is a flow chart of a data processing method provided in an embodiment of the present application. It should be noted that the data processing method provided in an embodiment of the present application is not based on Figure 2 The specific order below is for limitation. It should be understood that in other embodiments, the order of some steps in the data processing method of the embodiment of the present application can be interchanged according to actual needs, or some steps can be omitted or deleted.

[0052] The following will Figure 2 The specific process shown is described in detail. A data processing method provided in an embodiment of the present application includes steps S201-S205.

[0053] S201: Receive a data write request, where the data write request includes a logical block address LBA of a first cache to be accessed and target data.

[0054] In an embodiment of the present application, the data processing method can be applied to a storage device, and the data write request can be a data write request sent by a host. Exemplarily, the data write request may include an identifier of the logical partition of the first cache to be accessed, a logical block address LBA of the logical partition to be accessed, target data (including relevant information such as data size or offset), etc. The logical partition of the first cache may contain multiple LBAs, each LBA pointing to a specific storage space or data block within a logical partition. The identifier of the logical partition may be an identifier of a volume, a logical unit number (LUN, Logical Unit Number), a partition, or other logical storage unit. In addition, in order to improve the processing efficiency of critical data and critical tasks, the priority of the data write request may also be carried.

[0055] Of course, existing storage media using NAND Flash technology will use FLBA (Flatten Logic Block Address) addressing, and FLBA addressing can be regarded as a method of LBA addressing, because these storage media do not have physical heads or cylinders, but use NAND Flash to store data. Therefore, this type of storage medium is more suitable for flattened addressing methods. Using FLBA addressing can also simplify the addressing structure and improve read and write performance and efficiency. Therefore, for this addressing method, the data write request can include the logical block address FLBA of the first cache to be accessed, the target data (including relevant information such as the data size or offset), etc. It should be noted that the "logical block address LBA of the logical partition to be accessed" or the "logical block address FLBA of the first cache to be accessed" will be referred to as the "LBA to be accessed" in the following.

[0056] After receiving the data write instruction, the storage location of the target data can be determined according to the information carried by the data write instruction, that is, the storage start position and storage end position in the first cache. Among them, the cache is pre-divided into multiple logical blocks for data storage, each logical block includes multiple sectors, and the storage capacity of each sector is the same. For example, the storage capacity of each logical block is 4096 bytes (i.e. 4K), and the storage capacity of each sector is 512 bytes. For example, the starting position of logical block [0] is 0k, and the end position is 4k; the starting position of logical block [1] is 4k, and the end position is 8k.

[0057] Normally, in order to avoid omissions and errors when the storage device processes data write requests, the host usually sends these data write requests in sequence through a queue management mechanism and transmits them in a specific order; the storage device side receives and processes data write requests one by one to ensure that each request can be processed correctly to avoid data conflicts and damage.

[0058] It can be understood that, assuming that the LBA is 100 (i.e., logical block

[100] ), the sector size is 512 bytes, and the target data size is 1024 bytes (i.e., 2 sectors), the starting position and the ending position of the target data in the cache can be determined according to the target data and LBA in the data write request. For example, the starting address is calculated as: LBA*sector size=100*512=51200 bytes, and the ending address is calculated as: starting position+target data size-1=51200+1024-1=52223 bytes.

[0059] S202: Determine whether there is a write conflict in the first cache for the target data according to the LBA.

[0060] The first cache (such as SRAM) usually has a faster read and write speed than the second cache (such as DRAM), so that it can meet the demand for fast response without conflict, reduce the number of accesses to the slower storage medium, and thus improve the efficiency of the entire data writing process. Therefore, the host writes data to the first cache first, so it is necessary to determine whether the target data has a write conflict in the first cache based on the LBA carried in the data write request.

[0061] Specifically, it can be confirmed whether the LBA of the first cache to be accessed is already occupied or being accessed in the first cache. Specifically, referring to the aforementioned example in which the starting position and the ending position in the cache can be determined based on the target data and LBA in the data write request, it can be checked whether there is already data in the range of 51200 to 52223 bytes in the first cache. Assuming that there is already data in the range of 51200 to 51600 bytes, there is a write conflict. Or if there is already data in the LBA to be accessed in the data write request, it can also be determined that there is a write conflict. This situation is understood as a conflict with the same LBA.

[0062] S203: If there is a write conflict, write the target data into the second cache.

[0063] If there is a conflict in the first cache, the target data can be selected to be temporarily stored in the second cache to avoid data loss and error. Exemplarily, based on the above example that the starting position and the ending position in the cache can be determined according to the target data and LBA in the data write request, if the first cache does not have enough continuous space to store the 1024 bytes of target data, the system may need to write part of the data to the second cache, or directly choose to transfer the entire 1024 bytes of target data to the second cache. Further, after the target data is written to the second cache, the data write request is marked as completed.

[0064] S204: Determine, based on the LBA, whether there is a write conflict in the first cache for the target data written into the second cache.

[0065] If a write conflict is confirmed in the first judgment, the target data will be temporarily written to the second cache. In the following period of time, the conflicting data in the first cache may have been flushed to the memory chip, and the original write conflict may no longer exist. Therefore, it is necessary to check again whether the conflict has been resolved, so as to write the target data back to the first cache.

[0066] S205: If there is no write conflict, the target data written into the second cache is transferred to the first cache, so that the main control chip of the storage device transfers the target data written into the first cache to the flash memory chip.

[0067] Compared with the prior art, it is necessary to first allocate a memory space (generally 4KB in size) from the memory, and then transfer the data to the allocated memory space; the main control chip will manage the data cached in the memory, group it, and handle conflicts before sending it to the back-end software to write it into the flash memory particles (i.e., flash memory chips, such as NAND Flash). After the data to be written is successfully written into the flash memory particles, the previously applied memory space will be released. If the data size does not match the divided memory space, write amplification may occur, that is, the amount of data actually written to the flash memory is greater than the original amount of data, which will reduce the service life of the memory. And each time a request is received, a write needs to be performed, and then the memory space needs to be erased or released so that the data requested next time can be written. Frequent writing and reading in the memory will also affect the service life of the memory and cause the host write performance efficiency to decrease.

[0068] The embodiment of the present application introduces the first cache and the second cache. After receiving a data write request, it is determined whether there is a write conflict in the first cache for the target data according to the LBA of the first cache to be accessed; if there is a write conflict, the target data is written to the second cache; if there is no write conflict in the first cache for the target data written to the second cache, the target data written to the second cache is transferred to the first cache, so that the main control chip transfers the target data written in the first cache to the flash memory chip. Through such a multi-level storage structure, the first cache and the second cache can be flexibly used to solve the problems of write conflict and frequent erasure, reduce the frequency of data reading and writing in the memory and the delay caused by the write conflict of the first cache, improve the overall read and write performance of the storage device, and thus optimize the write efficiency of the host.

[0069] Further, if the data write request includes a priority, and the LBA of the first cache accessed by the first data write request is accessed by the second data write request, it can be compared whether the priority of the second data write request is higher than the priority of the first data write request. If so, the first data write request will not be executed temporarily until the second data write request is marked as completed, and then the first data write request will be executed.

[0070] Please combine Figure 3 Understand the data processing method provided by the following embodiment of the present application, Figure 3 The following is a flow chart of a data processing method provided in an embodiment of the present application. It should be noted that the data processing method provided in an embodiment of the present application is not based on Figure 3 The specific order below is for limitation. It should be understood that in other embodiments, the order of some steps in the data processing method of the embodiment of the present application can be interchanged according to actual needs, or some steps can be omitted or deleted.

[0071] In one embodiment, after determining whether there is a write conflict in the target data in the first cache according to LBA, it also includes: if there is no write conflict, writing the target data into the first cache so that the main control chip of the storage device transfers the target data written into the first cache to the flash memory chip.

[0072] The first cache (such as SRAM) is used as a high-speed cache to greatly increase the speed of data writing and reading. Since the read and write speed of the first cache is much higher than that of the flash memory, writing the target data to the first cache first can improve the overall performance. In the first cache, multiple write requests and conflict management can be handled more efficiently. Flash memory chips (such as NAND Flash) have a write life limit, and frequent writes will shorten their life. By writing the data to the first cache first and reducing the frequency of direct writing to the flash memory, the service life of the flash memory chip can be extended. Furthermore, after the target data is written to the first cache, the data write request is marked as completed.

[0073] In a feasible embodiment, assuming that the storage capacity of the currently set logical block is 4096 bytes (i.e., 4K), and the target data with write conflicts is a complete 4K data, in which case such complete 4K data can be understood as aligned data. Then it can be detected whether there is a write conflict in the first cache for the target data. If there is no conflict, the complete 4K target data is copied from the second cache to the first cache. If there is a conflict, the target data is marked as being flushable after the written data in the first cache that conflicts with the target data is written to the flash memory chip, and the target data is copied to the first cache. After the copy is completed, the target data can be flushed, i.e., written to the flash memory chip.

[0074] In one embodiment, if there is a write conflict, after writing the target data into the second cache, it also includes: if the target data is unaligned data and the starting address of the target data is continuous with the ending address of the written data of the LBA, the target data written into the second cache is transferred to the first cache, so that the main control chip of the storage device transfers the target data written into the first cache to the flash memory chip.

[0075] Unaligned data refers to the data whose starting address is not completely aligned with the boundary of the storage unit (such as sector or block) of the storage device. When the target data is unaligned data, it usually does not completely fill a logical block of the first cache. When the target data is transferred to the second cache, because the LBA to be accessed corresponding to the target data already has written data, there is a write conflict (i.e., the same LBA conflict), and thus the storage space corresponding to the LBA to be accessed cannot be written. However, in fact, the written data in the storage space corresponding to the LBA to be accessed does not fill the storage space corresponding to the LBA, resulting in a waste of storage space resources and a delay in data writing.

[0076] Based on the above phenomenon, the embodiment of the present application detects the starting address of the target data in the temporary second cache and the ending address of the written data in the LBA to be accessed in the first cache. If the starting address of the target data and the ending address of the written data in the first cache are continuous, this means that this part of the non-aligned data can be merged with the written data in the first cache, thereby achieving full utilization of the unfilled logical blocks in the first cache and reasonable scheduling of the target data temporarily stored in the second cache.

[0077] Exemplarily, it is assumed that a logical block LBA[0] of the first cache has the following cache information:

[0078] Total size: 4KB

[0079] Written data: 3KB, occupying the space from address 0 to address 3071 (in bytes);

[0080] Now, a data write request is received. There is a target data to be written. The information carried is as follows:

[0081] LBA to be accessed: LBA[0];

[0082] Size: 2KB

[0083] Starting address: address 3072;

[0084] In this case, the starting address (3072) of the target data is continuous with the ending address (3071) of the data written in the first cache. However, due to the write conflict of the data written in LBA[0], the target data may not be directly written into the remaining 1KB space of LBA[0], resulting in the 1KB space being unusable.

[0085] Please refer to Figure 3In the above “determine whether the target data written into the second cache can be merged with the data written into the first cache” and the upper and lower conditional relationships, in the embodiment of the present application, if it is detected that the starting address of the target data is continuous with the ending address (3071) of the data written into the first cache, the target data in the second cache can be migrated back to the first cache. Specifically, the entire 2KB of target data can be written to the next available address of LBA[0], that is, address 3072. This situation can also be understood as if it is detected that the starting address of the target data is continuous with the ending address of the data written into the first cache, then the target data in the second cache is merged with the data written into the first cache. In another feasible embodiment, if it is found that the starting address 0 of LBA[1] is occupied by other data, resulting in the inability to write the remaining 1KB of the target data (from 4096 to 5199), then the first 1KB of the target data (from 3072 to 4095) can be written to LBA[0], and the remaining 1KB of the target data can continue to be temporarily stored in the second cache. Subsequently, the system will continue to monitor the first cache. Once there is enough free space in LBA[0], the remaining 1KB of temporarily stored data will be migrated to the first cache, completing the process of writing the target data to the first cache. The main control chip of the storage device can then transfer the target data written in the first cache to the flash memory chip.

[0086] The embodiments of the present application can integrate and organize non-aligned data and target data with write conflicts, effectively and reasonably utilize storage space, reduce storage waste caused by data non-alignment, and improve data management efficiency, so that data can fill each logical block and be smoothly written into the flash memory chip, thereby reducing the fragmentation of write operations and improving write efficiency.

[0087] Please refer to Figure 3 In the step of "waiting for the conflicting LBA to complete" and its upper and lower conditional relationships, in some feasible embodiments, if the target data is non-aligned data and cannot be merged with the written data in the first cache (that is, the starting address of the target data is not continuous with the ending address of the written data in the first cache), then wait for the written data in the first cache that conflicts with the target data to be written to the flash memory chip, mark the target data as being in a flushable state, trigger the target data to be copied to the first cache, and after the copy is completed, the target data can be flushed, that is, written to the flash memory chip.

[0088] In one embodiment, determining whether there is a write conflict for target data in the first cache based on LBA includes: in response to multiple data write requests received, determining whether there is overlap in LBAs of the multiple data write requests; if there is overlap in LBAs of the multiple data write requests, executing the received data write requests sequentially; if there is no overlap in LBAs of the multiple data write requests, executing the received data write requests simultaneously.

[0089] As mentioned in the above embodiments, under normal circumstances, the host usually sends these data write requests in sequence through a queue management mechanism, and transmits them in a specific order, while the storage device side receives and processes the data write requests one by one. Therefore, the following situation may occur. For example, when a first data write request is received and the data is written, a second data request is received. Then the main control chip can analyze whether the LBA carried by the second data write request is the same as or overlaps with the LBA carried by the first data write request. If it is detected that the LBA overlaps, that is, multiple requests point to the same logical block or address range, the system will execute these write requests in the order of receipt, and process the data write requests on a first-come, first-served basis to avoid overwriting previous data. If it is detected that the LBAs of the two data write requests do not overlap, that is, each request points to a different logical block or address range, the system can execute these requests simultaneously.

[0090] In this way, write conflicts can be avoided when writing data, ensuring data integrity and consistency. Even under high load or when receiving a large number of requests, data writing can be managed effectively, and the throughput of the storage device can be improved through parallel processing when the LBAs of multiple requests overlap, and unnecessary data overwriting or rewriting can be avoided through sequential processing when the LBAs of multiple requests do not overlap.

[0091] In order to ensure the accuracy and security of data writing operations, in one embodiment, whether there is a write conflict in the target data in the first cache is determined based on the LBA, including: obtaining a pre-stored cache table; the cache table includes storage location information of the written data in the first cache; and determining whether there is a write conflict in the target data in the first cache based on the LBA of the first cache to be accessed and the storage location information of the written data in the first cache.

[0092] The cache table may include the following:

[0093]

[0094] When a data write request is received, the LBA carried in the request is detected, and the LBA to be accessed is compared with the storage location information in the cache table to determine whether the target data in the data write request will overlap or conflict with the data already existing in the first cache. If the corresponding storage location information of the LBA to be accessed is not found in the cache table, that is, the LBA is not occupied, then a write operation can be performed to write the target data to the LBA position to be accessed; otherwise, it is determined that there is a write conflict, and the target data is transferred to the second cache. By using the cache table to perform conflict detection, the system can effectively handle different data write requests, optimize the use of storage resources, prevent data loss or damage, and improve the management efficiency and performance of storage devices.

[0095] In one embodiment, the first cache includes multiple logical blocks, and the target data written into the first cache is transferred to the flash memory chip, including: when the storage data amount of any logical block meets the preset data amount threshold, the written data in the logical block is transferred to the flash memory chip.

[0096] In the embodiment of the present application, in order to reduce frequent small-scale write operations and reduce the frequency of access to the flash memory chip, after receiving the data write instruction, it can be determined whether to trigger the step of taking out the written data from the logical block and writing it into the flash memory chip according to the amount of stored data in the logical block in the first cache. The preset data volume threshold defines the amount of data stored in the logical block that triggers the event of flushing the written data to the flash memory chip. If the used amount or stored data amount of a certain logical block is greater than or equal to the preset data volume threshold, the written data in the logical block is directly stored in the flash memory chip. For example, the preset data volume threshold is 4K, and the written data in LBA[0] is full of 4K, then the written data in the logical block is transferred to the flash memory chip. It should be noted that the preset data volume threshold is not specified in detail in the embodiment of the present invention, and can be set according to actual conditions.

[0097] In order to optimize storage efficiency and device performance, in one embodiment, the first cache includes multiple logical blocks, each logical block includes multiple sectors, and the flash memory chip stores a preset alignment write rule, and the target data written in the first cache is transmitted to the flash memory chip, including: when the cache duration of the logical block meets the preset time threshold, if the written data in the logical block does not meet the preset alignment write rule, determine the target sector that does not meet the preset alignment write rule and obtain the index of the target sector; obtain first supplementary data from the flash memory chip according to the storage location information of the written data in the target sector and the index of the target sector; merge the first supplementary data and the written data of the logical block, and transmit them to the flash memory chip.

[0098] Here, the preset alignment write rule may be an alignment rule in a non-volatile storage medium protocol. In the embodiment of the present application, the cache duration of each logical block may be used. If the cache duration of a logical block after writing data reaches a preset time threshold (such as 30 seconds or 1 minute), the written data of the logical block is written to the flash memory chip. Before performing a write operation, it is necessary to first determine whether the target data meets the preset alignment rule.

[0099] Specifically, for example, the preset alignment rule is 4K (i.e., set to the size of a logical block), and determine whether the starting address of the written data of each sector under the logical block is aligned or consistent with the starting address of the sector. Similarly, it is also necessary to align or consistent the ending address of the written data of each sector under the logical block with the ending address of the sector. If all sectors are aligned or consistent, they can be written to the flash memory chip. If the written data in a sector does not fill the sector, such as the ending address of the written data is not aligned or consistent with the ending address of the sector, or no data is written in a sector, the sector does not meet the preset alignment write rule. It is necessary to determine the index of the sector that does not meet the preset alignment rule, the storage location information of the written data (the storage location information includes at least one of the starting address and the ending address of the written data), and the ending address of the sector, so as to obtain supplementary data in the flash memory chip to fill the vacant place.

[0100] For example, if the written data is located at address 2560 to address 3000 in sector [5], then it is necessary to obtain the supplementary data corresponding to address 3001 to address 3071 of sector [5] in the flash memory chip according to the index of the sector (for example, the index of sector [5] of logical block [0] is S4), the "end address 3000" of the written data in sector [5], and the "end address 3071" of the sector, and merge them with the written data in the first cache, thereby filling the vacant part of the sector. Alternatively, if no data is written in sector [5], the supplementary data of the corresponding address can be obtained in the flash memory chip according to the index "sector [5] of logical block [0]" to fill the vacant part of the sector, and finally merge the supplementary data written in the sector with the data of other sectors, so as to achieve data alignment of each sector, that is, the entire logical block. This method not only ensures the alignment of the written data, but also improves the efficiency of data writing and the service life of the flash memory chip.

[0101] In order to implement the data processing method of the embodiment of the present application, the embodiment of the present application also provides a data processing device, which is applied to a storage device, wherein the storage device includes a main control chip, a first cache, a second cache and a flash memory chip, such as Figure 4 As shown, the data processing device includes:

[0102] A request receiving unit 401 is used to receive a data write request, wherein the data write request includes a logical block address LBA of a first cache to be accessed and target data;

[0103] A conflict detection unit 402, configured to determine whether there is a write conflict for the target data in the first cache according to the LBA;

[0104] A data transmission unit 403, configured to write the target data into the second cache if there is a write conflict;

[0105] The conflict detection unit 402 is further configured to determine, according to the LBA, whether the target data written into the second cache has a write conflict in the first cache;

[0106] The data transmission unit 403 is further configured to transmit the target data written into the second cache to the first cache if there is no write conflict, so that the main control chip of the storage device transmits the target data written into the first cache to the flash memory chip.

[0107] In one embodiment, the data transmission unit is further used to write the target data into the first cache if there is no write conflict, so that the main control chip of the storage device transfers the target data written in the first cache to the flash memory chip.

[0108] In one embodiment, the data transmission unit is also used to transfer the target data written into the second cache to the first cache if the target data is unaligned data and the starting address of the target data is continuous with the ending address of the written data of the LBA, so that the main control chip of the storage device transfers the target data written into the first cache to the flash memory chip.

[0109] In one embodiment, the device further includes: a processing unit. The processing unit is used to determine whether the LBAs of the multiple data write requests are overlapped in response to the multiple data write requests received; if the LBAs of the multiple data write requests are overlapped, the received data write requests are executed sequentially; if the LBAs of the multiple data write requests are not overlapped, the received data write requests are executed simultaneously.

[0110] In one embodiment, the device further includes: an acquisition unit. The acquisition unit is used to acquire a pre-stored cache table; the cache table includes storage location information of the written data in the first cache;

[0111] The processing unit is further configured to determine whether there is a write conflict for the target data in the first cache according to the LBA of the first cache to be accessed and the storage location information of the written data in the first cache.

[0112] In one embodiment, the data transmission unit is further configured to transmit the written data in the logic block to the flash memory chip when the storage data amount of any of the logic blocks meets a preset data amount threshold.

[0113] In one embodiment, the processing unit is further configured to, when the cache duration of the logical block satisfies a preset time threshold, determine a target sector that does not satisfy the preset alignment write rule and obtain an index of the target sector if the written data in the logical block does not satisfy the preset alignment write rule;

[0114] The acquisition unit is further used to acquire first supplementary data from the flash memory chip according to the storage location information of the data written in the target sector and the index of the target sector;

[0115] The data transmission unit is further used to merge the first supplementary data and the written data of the logic block, and transmit the merged data to the flash memory chip.

[0116] In actual application, the processing unit can be realized by the main control chip in the storage device combined with the communication interface, and the request receiving unit, conflict detection unit, data transmission unit, processing unit, and acquisition unit can be realized by the communication interface in the data processing device.

[0117] It should be noted that: the above embodiment provides a data processing device for data processing, and only uses the division of the above program modules as an example. In actual applications, the above processing can be assigned to different program modules as needed, that is, the internal structure of the device is divided into different program modules to complete all or part of the above-described processing. In addition, the data processing device and the data processing method embodiment provided in the above embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0118] Based on the hardware implementation of the above program modules, and in order to implement a data processing method provided in an embodiment of the present application, an embodiment of the present application further provides a storage device, such as Figure 5 As shown, the storage device 500 includes a main control chip 501, a first cache 502, a second cache 503 and a flash memory chip 504. The main control chip 501, the first cache 502, the second cache 503 and the flash memory chip 504 are all communicated with each other, and the main control chip 501 implements the data processing method as described in any one of the above items by running a computer program.

[0119] Of course, in actual application, the various components in the storage device 500 are coupled together through the bus system 505. It can be understood that the bus system 505 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 505 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, Figure 5 Various buses are labeled as bus system 505 .

[0120] An embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, any one of the data processing methods described above is implemented.

[0121] An embodiment of the present application further provides a computer program product having a computer program / instruction stored thereon, which, when executed by a processor, is used to implement any one of the data processing methods described above.

[0122] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0123] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0124] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0125] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0126] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a storage device (which can be a personal computer, server, solid-state hard disk, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, RandomAccess Memory), disk or optical disk and other media that can store program code.

Claims

1. A data processing method, characterized in that: Applied to a storage device, the storage device includes a main control chip, a first cache, a second cache and a flash memory chip, and the method includes: receiving a data write request, wherein the data write request includes a logical block address LBA of a first cache to be accessed and target data; Determining whether there is a write conflict for the target data in the first cache according to the LBA; If there is a write conflict, writing the target data into the second cache; Determining whether target data written into the second cache has a write conflict in the first cache according to the LBA; If there is no write conflict, the target data written into the second cache is transferred to the first cache, so that the main control chip of the storage device transfers the target data written into the first cache to the flash memory chip.

2. The data processing method according to claim 1, characterized in that: After determining whether the target data has a write conflict in the first cache according to the LBA, the method further includes: If there is no write conflict, the target data is written into the first cache, so that the main control chip of the storage device transfers the target data written into the first cache to the flash memory chip.

3. The data processing method according to claim 1, characterized in that: After writing the target data into the second cache if there is a write conflict, the method further includes: If the target data is unaligned data and the starting address of the target data is continuous with the ending address of the written data of the LBA, the target data written into the second cache is transferred to the first cache, so that the main control chip of the storage device transfers the target data written into the first cache to the flash memory chip.

4. The data processing method according to claim 1, characterized in that: The determining, according to the LBA, whether there is a write conflict for the target data in the first cache includes: In response to the received multiple data write requests, determining whether LBAs of the multiple data write requests overlap; If the LBAs of the multiple data write requests overlap, the received data write requests are executed sequentially; If the LBAs of the multiple data write requests do not overlap, the received data write requests are executed simultaneously.

5. The data processing method according to claim 1, characterized in that: The determining, according to the LBA, whether there is a write conflict for the target data in the first cache includes: Acquire a pre-stored cache table; the cache table includes storage location information of the written data in the first cache; It is determined whether there is a write conflict for the target data in the first cache according to the LBA of the first cache to be accessed and the storage location information of the data already written in the first cache.

6. The data processing method according to claim 1, characterized in that: The first cache includes a plurality of logic blocks, and the step of transferring the target data written into the first cache to the flash memory chip includes: When the storage data amount of any of the logic blocks meets a preset data amount threshold, the written data in the logic block is transferred to the flash memory chip.

7. The data processing method according to claim 1, characterized in that: The first cache includes a plurality of logic blocks, each of the logic blocks includes a plurality of sectors, the flash memory chip stores a preset alignment write rule, and the target data written in the first cache is transferred to the flash memory chip, including: When the cache duration of the logical block meets the preset time threshold, if the written data in the logical block does not meet the preset alignment write rule, determining a target sector that does not meet the preset alignment write rule and obtaining an index of the target sector; Acquire first supplementary data from the flash memory chip according to the storage location information of the data written in the target sector and the index of the target sector; The first supplementary data and the written data of the logic block are combined and transmitted to the flash memory chip.

8. A data processing device, characterized in that: Applied to a storage device, the storage device includes a main control chip, a first cache, a second cache and a flash memory chip, and the data processing device includes: A request receiving unit, configured to receive a data write request, wherein the data write request includes a logical block address LBA of a first cache to be accessed and target data; a conflict detection unit, configured to determine whether there is a write conflict for the target data in the first cache according to the LBA; a data transmission unit, configured to write the target data into the second cache if there is a write conflict; The conflict detection unit is further used to determine whether the target data written into the second cache has a write conflict in the first cache according to the LBA; The data transmission unit is further configured to transmit the target data written into the second cache to the first cache if there is no write conflict, so that the main control chip of the storage device transmits the target data written into the first cache to the flash memory chip.

9. A storage device, characterized in that: The storage device includes a main control chip, a first cache, a second cache and a flash memory chip. The main control chip, the first cache, the second cache and the flash memory chip are all communicated with each other. The main control chip implements the data processing method as described in any one of claims 1 to 7 by running a computer program.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the data processing method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Buffer to reduce write amplification of misaligned write operations

    CN112992207A

  • Data writing method, device and equipment and readable storage medium

    CN113485640A

  • EEPORM-based high-speed storage data processing method and system

    CN115292212A

  • Data request processing method and device, storage equipment and readable storage medium

    CN116048428A

  • Data caching method and device, electronic equipment and computer readable storage medium

    CN117193634A

Cited By

  • Data operation method and device, electronic equipment and storage medium

    CN120386485A

  • Cache data management method and device and storage controller

    CN120523402A

  • Cache structure, cache method, chip and electronic equipment

    CN121560820A