Data writing method and device, storage medium, storage equipment and electronic equipment
Patent Information
- Application Number
- CN202210899849.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-28
- Publication Date
- 2026-10-09
- Estimated Expiration
- 2042-07-28
AI Technical Summary
[0004]然而,双写机制造成实际的写入数据量的翻倍,增加了写放大,占用了PCIe带宽和CPU本就稀少的PCIe通道数
[0019] This specification divides the non-volatile memory in the storage device into a log area and a data area. However, this does not replace the log disk and data disk in related technologies. Instead, write operations to the log area have the highest priority in the access scheduling of the storage device, thus ensuring efficient writing to the log area. After the data writing operation is completed in the log area, the role of the log area and the data area is converted based on the update of the mapping table, so that the log area changes from its original role as a log area to a data area. Therefore, only one data write is required in the entire data writing process. This avoids the drawback of the double write mechanism that increases the amount of data written multiple times, reduces write amplification, and eliminates the need to move data from the log area to the data area, which would cause frequent data movement operations. It also reduces the probability of triggering garbage collection.
Smart Images

Figure CN115309329B_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the field of computer technology, and more particularly to a data writing method, apparatus, storage medium, storage device, and electronic device. Background Technology
[0002] Solid-state drives (SSDs) offer advantages over traditional hard disk drives (HDDs), such as faster read / write speeds, lighter weight, and lower power consumption. Their storage capacity has also significantly increased compared to their initial counterparts, gradually replacing HDDs as the mainstream non-volatile storage device. In related technologies, SSDs typically use the NVMe interface and are thus called NVMe SSDs. However, with the increasing demands for storage throughput performance, the read / write capabilities of NVMe SSDs are no longer sufficient.
[0003] With the development of solid-state drive (SSD) technology, in addition to the aforementioned NVMe SSDs, new types of SSDs with faster read / write speeds, lower latency, and higher throughput have emerged, such as those based on 3D XPoint technology. To address the shortcomings of relying solely on NVMe SSDs, related technologies employ a tiered storage approach, combining NVMe SSDs and 3D XPoint-based SSDs. Unlike the original approach where the storage engine directly writes data to the NVMe SSD, this tiered storage mechanism uses higher-performance SSDs like the 3D XPoint-based SSD as journal drives and lower-performance SSDs like the NVMe SSD as data drives. A dual-write mechanism simultaneously writes data to both the journal and data drives, and a completion notification is sent as soon as either SSD successfully completes its write (usually the journal drive completes first). Therefore, leveraging the superior low latency and high throughput of the journal drive improves overall storage throughput.
[0004] However, the dual-write mechanism doubles the actual amount of data written, increasing write amplification and consuming PCIe bandwidth and the already limited number of PCIe lanes available to the CPU. Furthermore, journal disks are not only expensive but also generate many disadvantages, such as a small number of journal disks leading to a large amount of data written to each disk, thus shortening the lifespan of the journal disk. In addition, adding a journal disk also means incurring separate management costs and resource overhead for that specific disk. Summary of the Invention
[0005] In view of the above, this specification provides a data writing method, apparatus, storage medium, storage device, and electronic device through one or more embodiments.
[0006] To achieve the above objectives, one or more embodiments of this specification provide the following technical solutions:
[0007] According to a first aspect of one or more embodiments of this specification, a data writing method is provided, applied to a controller in a storage device, the storage device further including a non-volatile memory connected to the controller, and the storage space of the non-volatile memory being divided into a log area and a data area; the controller is configured such that write operations to the log area have the highest priority in access scheduling operations to the storage device; wherein the controller is further configured to maintain a mapping table, the mapping table including a logical address column, a log area physical address column, and a data area physical address column, for recording the mapping relationship between logical addresses in the non-volatile memory, the physical addresses of the log area, and the physical addresses of the data area, the method comprising:
[0008] Receive a data write request, the data write request including the data to be written and the target logical address corresponding to the data to be written;
[0009] Determine the target physical address corresponding to the data to be written in the log area, perform a data write operation to the target physical address, and add a corresponding target mapping relationship in the mapping table. The target mapping relationship includes the target logical address recorded in the logical address column and the target physical address recorded in the log area physical address column.
[0010] Upon completion of the write operation of the data to be written, the target mapping relationship is updated to include the target physical address recorded in the physical address column of the data area.
[0011] According to a second aspect of one or more embodiments of this specification, a data writing apparatus is provided, applied to a controller in a storage device, the storage device further including a non-volatile memory connected to the controller, and the storage space of the non-volatile memory being divided into a log area and a data area; the controller is configured such that write operations to the log area have the highest priority in access scheduling operations to the storage device; wherein the controller is further configured to maintain a mapping table, the mapping table including a logical address column, a log area physical address column, and a data area physical address column, for recording the mapping relationship between logical addresses in the non-volatile memory, the physical addresses of the log area, and the physical addresses of the data area, the apparatus comprising:
[0012] A receiving unit is configured to receive a data write request, wherein the data write request includes data to be written and a target logical address corresponding to the data to be written.
[0013] The determining unit is used to determine the target physical address corresponding to the data to be written in the log area, perform a data writing operation to the target physical address, and add a corresponding target mapping relationship in the mapping table. The target mapping relationship includes the target logical address recorded in the logical address column and the target physical address recorded in the log area physical address column.
[0014] An update unit is used to update the target mapping relationship so that it includes the target physical address recorded in the physical address column of the data area when the data write operation is completed.
[0015] According to a third aspect of one or more embodiments of this specification, a computer-readable storage medium is provided that stores a computer program thereon, which, when executed by a processor, implements the steps of the method as described in the first aspect above.
[0016] According to a fourth aspect of one or more embodiments of this specification, a storage device is provided, including a controller and a non-volatile memory connected to the controller, the controller being configured to implement the steps of the method as described in the first aspect above.
[0017] According to a fifth aspect of one or more embodiments of this specification, an electronic device is provided, including a storage device as described in the fourth aspect above.
[0018] The technical solutions provided in this specification can achieve at least one of the following beneficial effects:
[0019] This specification divides the non-volatile memory in the storage device into a log area and a data area. However, this does not replace the log disk and data disk in related technologies. Instead, write operations to the log area have the highest priority in the access scheduling of the storage device, thus ensuring efficient writing to the log area. After the data writing operation is completed in the log area, the role of the log area and the data area is converted based on the update of the mapping table, so that the log area changes from its original role as a log area to a data area. Therefore, only one data write is required in the entire data writing process. This avoids the drawback of the double write mechanism that increases the amount of data written multiple times, reduces write amplification, and eliminates the need to move data from the log area to the data area, which would cause frequent data movement operations. It also reduces the probability of triggering garbage collection.
[0020] Specifically, by setting write operations to the log area to have the highest priority, write operations to the log area can be completed efficiently without being affected by other access scheduling operations. Compared with directly writing data to the data area, writing data to the log area and then converting the log area into the data area can ensure a relatively higher data writing speed.
[0021] Furthermore, since this manual eliminates the costly journal disk, high-speed data writing can be achieved using only a single type of storage device. This not only saves on the cost of using a journal disk but also frees up the PCIe bandwidth and PCIe lanes previously occupied by the journal disk, alleviating the resource constraints related to PCIe bandwidth and PCIe lanes. Moreover, no longer limited by the high price of journal disks, the electronic devices described in this manual can be equipped with a relatively larger number of storage devices with greater capacity. This significantly reduces the average amount of data written to each storage device, thereby lowering the throughput requirements for each storage device and extending its lifespan.
[0022] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this specification. Attached Figure Description
[0023] To more clearly illustrate the technical solutions in the embodiments or prior art of this specification, the drawings used in the description of the embodiments or prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this specification. For those skilled in the art, other drawings can be obtained based on these drawings.
[0024] Figure 1 This is an exemplary embodiment of an electronic device provided in this specification;
[0025] Figure 2 This is an architectural diagram of a storage device provided in an exemplary embodiment of this specification;
[0026] Figure 3 This is a flowchart of a data writing method provided in an exemplary embodiment of this specification;
[0027] Figure 4 This is a schematic diagram illustrating the partitioning of storage space in a storage device according to an exemplary embodiment of this specification;
[0028] Figure 5 This is a schematic diagram illustrating the partitioning of a log sub-region in a storage device according to an exemplary embodiment of this specification;
[0029] Figure 6 This is a schematic diagram illustrating the role transition between the log area and the data area provided in an exemplary embodiment of this specification;
[0030] Figure 7 This is a schematic diagram of the overall process of data writing and reading provided in an exemplary embodiment of this specification;
[0031] Figure 8This is a schematic structural diagram of an electronic device provided in an exemplary embodiment of this specification;
[0032] Figure 9 This is a block diagram of a data writing device provided in an exemplary embodiment of this specification. Detailed Implementation
[0033] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with one or more embodiments of this specification. Rather, they are merely examples of apparatuses and methods consistent with some aspects of one or more embodiments of this specification.
[0034] It should be noted that the steps of the corresponding methods are not necessarily performed in the order shown and described in this specification in other embodiments. In some other embodiments, the methods may include more or fewer steps than described in this specification. Furthermore, a single step described in this specification may be broken down into multiple steps in other embodiments; and multiple steps described in this specification may be combined into a single step in other embodiments.
[0035] In related technologies, based on the performance differences of different types of SSDs, multiple types of SSDs can be used to implement tiered storage. For example, NVMe SSDs and new SSDs based on 3D XPoint technology can be used simultaneously. In this case, the relatively high-performance SSDs, such as the new SSDs based on 3D XPoint technology, are used as log drives, while the relatively low-performance SSDs, such as NVMe SSDs, are used as data drives. A dual-write mechanism is used to write data to both the log drive and the data drive simultaneously, and a notification of data write completion is given once either SSD has successfully completed the write operation.
[0036] Based on the superior low latency and high throughput performance of journal disks, they are typically written to first in a dual-write mechanism, thus improving overall storage throughput performance. However, firstly, due to the dual-write mechanism, as mentioned earlier, the journal disk and data disk perform data write operations simultaneously, doubling the original data volume. This not only consumes PCIe bandwidth and the already limited number of PCIe lanes available to the CPU, but also further increases write amplification. Secondly, while journal disks offer higher performance, they are also more expensive, inevitably resulting in fewer of them being configured in a system. Because data is written to both the journal and data disks simultaneously using the dual-write mechanism, the data write volume per journal disk is larger, thus reducing the lifespan of the journal disk. Finally, during the data writing and storage process, solid-state drives (SSDs) use mechanisms such as erasure coding to check the accuracy of stored data to ensure reliability. Therefore, simultaneously checking the accuracy of data on both the journal and data disks also imposes additional management costs and resource overhead on the system.
[0037] Therefore, to solve the above problems, this specification proposes an improved data writing scheme, which will be described in detail below with reference to the embodiments.
[0038] Figure 1 This is an exemplary embodiment of an electronic device provided in this specification, such as... Figure 1 As shown, the system architecture may include a processor (such as a CPU), memory, storage device 10, and PCIe bus 11. For details regarding the processor and memory, please refer to relevant existing technologies; this specification will not elaborate further. In fact, this specification does not limit the specific parameters (such as model and type) of the processor or memory. The aforementioned electronic device can meet storage needs in various scenarios. For example, the electronic device can be used in a physical server on a standalone host, or the server can be a virtual server hosted in a host cluster (such as a cloud server), or the electronic device can be a personal PC, PDA, laptop, or even a mobile phone or wearable device, etc. This specification does not limit these applications.
[0039] Storage device 10 can be a solid-state drive (SSD). Unlike related technologies where log disks and data disks coexist, this specification allows for the simultaneous presence of multiple storage devices 10. However, these storage devices 10 can have consistent (identical or similar) performance in terms of write latency, throughput, etc., and are not required to exhibit significant performance differences similar to those between NVMe SSDs and newer SSDs based on 3D XPoint technology. Of course, in practical applications, it is not excluded that multiple storage devices 10 with significant performance differences can be simultaneously installed in electronic devices to achieve the technical solution described in this specification. However, the operation of these storage devices 10 will be significantly different from the tiered storage methods in the aforementioned related technologies. For example, storage device 10 can be pre-divided into a log area and a data area, and the controller of storage device 10 can be pre-configured with the following: write operations to the log area have the highest priority in this storage device; and the controller can update the mapping relationship within the mapping table, thereby realizing the role conversion between the log area and the data area.
[0040] The PCIe (Peripheral Component Interconnect Express) bus 11 is a tree-structured interface bus, primarily providing the CPU with a bus interface to access peripheral devices, such as network interface cards (NICs) and the aforementioned storage device 10. The PCIe bus has a certain bandwidth and number of channels. Therefore, since this specification eliminates the log disk used in related technologies and only uses a single type of storage device 10, it is equivalent to using only the data disk, thus saving the PCIe bandwidth and channels originally occupied by the log disk and alleviating competition for PCIe resources from NICs and other PCIe devices.
[0041] In the technical solution of this specification, by pre-dividing the storage device 10 into a log area and a data area, a high-efficiency working mode with the highest priority for write operations in the log area can be implemented, thereby accelerating the data writing speed. Furthermore, based on the mapping relationship of records in the update mapping table, the roles of the log area and the data area can be transformed, i.e., from the original log area to the data area, the data only needs to be written once, eliminating the need for dual writes and reducing the amount of data written. At the same time, because the expensive independent log disk is saved, the already scarce PCIe channels of the CPU are saved, and there is no need to compete with network cards and other PCIe devices for PCIe bandwidth resources.
[0042] Figure 2 This is an internal architecture diagram of a storage device provided in an exemplary embodiment of this specification. Figure 2As shown, the internal architecture of the storage device may include a controller 20, a cache device 21, and multiple storage areas 22, wherein the multiple storage areas 22 constitute a non-volatile memory 23, and the controller 20 is connected to the cache device 21 and the non-volatile memory 23 respectively.
[0043] The controller 20 can maintain preset configuration information and implement the data writing scheme disclosed in this specification based on this configuration information. For example, it can pre-divide each storage area 22 in the non-volatile memory 23 into a log area and a data area, determine that write operations to the log area have the highest priority in the access scheduling operations for the storage device, and control the mapping relationship of records in the update mapping table, thereby realizing the conversion of the roles of the log area and the data area through metadata conversion (i.e., updating the mapping relationship). The above configuration information can be pre-fixed in the firmware inside the controller 20; of course, it can also be maintained in other ways, and this specification does not limit this.
[0044] The cache device 21 can be RAM (Random Access Memory). For example, the cache device 21 can be DRAM (Dynamic Random Access Memory) with power-loss protection, or it can be SRAM (Static Random-Access Memory) with power-loss protection. In fact, this specification does not limit the specific type of cache device 21; the cache device 21 only needs to meet the high-speed data writing function. Based on this power-loss protection function, even if a system power failure occurs during the writing process, it can still ensure that the data in the cache device 21 can be successfully written to the non-volatile memory 23.
[0045] Storage region 22 can be a block in a storage device; that is, in this specification, storage region 22 can be divided based on blocks. When the non-volatile memory 23 uses NAND flash memory, the non-volatile memory 23 can contain at least one die, each die can be divided into one or more planes, each plane can contain multiple blocks, and each block further contains multiple pages. Therefore, in other embodiments, storage region 22 can also be divided based on other dimensions such as die, plane, and page, and this specification does not limit this.
[0046] Taking each storage area 22 corresponding to one block as an example, when writing data to a certain storage area 22, if there is already valid data written in that storage area 22, garbage collection (GC) may be triggered. For example, when the remaining space in the storage area 22 is less than the amount of data to be written, the valid data already written needs to be rewritten to other storage areas 22, and the original storage area 22 needs to be erased. In this specification, when the controller 20 divides the log area in the non-volatile memory 23, the log area is composed of free storage areas 22. Therefore, during the writing process in the log area, garbage collection will not be triggered, avoiding the impact of garbage collection on the data writing speed and reducing write amplification. Of course, after converting the log area to the data area by updating the mapping table, garbage collection can be performed normally on the data area, such as actively erasing blocks containing only invalid data so that they can be reused to form the log area for data writing.
[0047] For ease of description, the following is in conjunction with the appendix. Figure 3 To be continued Figure 7 This specification provides a detailed description of a data writing method.
[0048] Figure 3 This is a flowchart illustrating a data writing method provided in an exemplary embodiment of this specification. For example... Figure 3 As shown, the method is applied to a controller in a storage device, and the method includes the following steps:
[0049] Step 302: Receive a data write request, wherein the data write request includes the data to be written and the target logical address corresponding to the data to be written.
[0050] The storage device in this embodiment can be, for example, Figure 2 The architecture shown indicates that the storage device also includes non-volatile memory connected to the controller, and the storage space of the non-volatile memory can be divided as follows: Figure 4 The log area and data area are shown. Figure 4 As shown, each storage area 22 can be concurrently connected to the controller 20 via channels 1-5, etc. When the controller 20 divides the log area, each log area can simultaneously contain multiple storage areas 22 across channels. This allows the controller 20 to concurrently write data to multiple storage areas 22 via multiple channels during write operations, thereby improving data write speed. Specifically, when the same log area contains storage areas 22 across multiple channels, each channel can contain one or more storage areas 22. In one embodiment, the log area can contain one storage area 22 on each channel, ensuring that the amount of data transmitted by the controller 20 on each channel is roughly equivalent, which helps balance the data transmission load between channels.
[0051] Access scheduling operations for storage devices can include many types, and this specification does not limit them. Examples include garbage collection, write operations to the data area, read operations to the data area, and write operations to the log area. Because the controller can be configured such that write operations to the log area have the highest priority among access scheduling operations for the storage device, write operations to the log area are not interfered with by other access scheduling operations, thereby ensuring that data can be written to the log area at high speed.
[0052] The controller can be used to maintain a mapping table, which can contain a logical address column, a log area physical address column, and a data area physical address column, to record the mapping relationship between the logical address in the non-volatile memory, the physical address of the log area, and the physical address of the data area, as shown in Table 1.
[0053]
[0054] Table 1
[0055] As shown in Table 1, the header of this mapping table can include a logical address column, a log area physical address column, and a data area physical address column. Upon receiving a data write request, the data to be written and its corresponding target logical address can be obtained. For example, the target logical address could be LBA 1. LBA (Logical Block Address) refers to the logical block address, while PBA (Physics Block Address) refers to the physical block address.
[0056] Step 304: Determine the target physical address corresponding to the data to be written in the log area, perform a data write operation to the target physical address, and add a corresponding target mapping relationship in the mapping table. The target mapping relationship includes the target logical address recorded in the logical address column and the target physical address recorded in the log area physical address column.
[0057] The controller can determine the target physical address corresponding to the data to be written in the log area, and thus can perform a data write operation to the target physical address and add the corresponding target mapping relationship in the mapping table. Taking LBA 1 as an example as mentioned above, that is, the data write request includes the target logical address, which is specifically LBA 1. Then, the mapping table shown in Table 2 can be obtained.
[0058] LBA 1 <![CDATA[PBA J 1]]>
[0059] Table 2
[0060] Among them, PBAJ 1 represents the target physical address in the log area corresponding to the data to be written, as determined by the controller.
[0061] In one embodiment, the log area may include one or more log sub-areas. In this case, a log sub-area can be sequentially selected from the log area, and the physical address of the selected log sub-area can be determined as the target physical address. For example... Figure 5 As shown, the log area can include multiple log sub-areas, such as log sub-area 501 and log sub-area 502. In this case, the controller can sequentially select the physical address of log sub-area 501 as the target physical address. Assume the physical address of log sub-area 501 is PBA. J 1. At this point, the controller can determine the physical address of log sub-region 501 as the target physical address, thus obtaining the mapping table shown in Table 2. As mentioned earlier, the log sub-region can be composed of multiple storage areas across channels. Assuming that each storage area can be a block in the solid-state drive, each log sub-region can be called a SuperBlock. For example, log sub-region 501 can be called Superblock 1, and log sub-region 502 can be called Superblock 2.
[0062] Each log sub-region can include multiple free blocks across channels. As before... Figure 5 As shown, log sub-region 501 includes two free storage areas spanning multiple channels, while log sub-region 502 may include three free storage areas spanning multiple channels. In practice, the number of free storage areas included in each log sub-region can be flexibly determined according to actual needs. Of course, each log sub-region may also include the same number of free storage areas; this specification does not impose any restrictions on this. Based on the cross-channel configuration, data can be written in parallel, improving the data writing speed. Parallel reading can also be achieved in subsequent read operations. Because the log sub-region is composed of free storage areas and initially does not store data, it will not trigger the garbage collection operation mentioned earlier, thereby further accelerating data writing speed and reducing write amplification.
[0063] Step 306: After completing the write operation of the data to be written, update the target mapping relationship so that it includes the target physical address recorded in the physical address column of the data area.
[0064] After the data to be written is successfully written to the log area, the controller can update the target mapping relationship to include the target physical address recorded in the physical address column of the data area. Specifically, it can directly use the target physical address of the log area as the target physical address of the data area, that is, copy and synchronize the target physical address of the log area to the target physical address of the data area, thereby enabling the log area to realize the role transformation from log area to data area. Taking LBA 1 as an example, the following can be obtained:
[0065] The mapping table shown in Table 3.
[0066]
[0067] Table 3
[0068] As shown in Table 3, by directly copying the addresses corresponding to the physical address column of the log area to the physical address of the data area, the PBA is essentially transformed. J Copying data to the physical address column of the data area allows for a change from the log area role to the data area role, avoiding double writing of data. Since this role conversion task can be performed for each piece of data to be written, assuming that after writing the data to be written corresponding to logical address LBA 1, data to be written 2 at logical address LBA 2 and data to be written 3 at logical address LBA 3 are subsequently received, then the mapping table after the log area completes the writing of data to be written 2 and data to be written 3 can be as shown in Table 4:
[0069] LBA 1 <![CDATA[PBA J 1]]> <![CDATA[PBA J 1]]> LBA 2 <![CDATA[PBA J 2]]> <![CDATA[PBA J 2]]> LBA 3 <![CDATA[PBA J 3]]> <![CDATA[PBA J 3]]>
[0070] Table 4
[0071] After the write operation of the data to be written is completed in the log area, the physical address of the log area can be directly copied and made into the physical address of the data area. This realizes the role conversion between the data area and the log area, so that the data only needs to be written once, eliminating the need for double writing and saving data writing volume. Taking the role conversion of log sub-area 501 as an example after the log area is converted to the data area, we can get the following: Figure 6 The diagram shows a partitioning scheme. Figure 6 As shown, log sub-area 501 can change its role to become a data area by updating the mapping table, that is, by synchronously copying the physical address of the log area and using it as the physical address of the data area. The data only needs to be written once.
[0072] In one embodiment, the controller may also be configured to allow the log area to be written to but not read from. In other words, the controller only performs write operations on the log area and not read operations, allowing the log area to continuously operate in a single data write mode, which helps improve the data write speed of the log area. Simultaneously, before the log area is converted to the data area, to meet external read requests for the data written in the log area, the storage device may also include a cache device. The controller can respond to a data write request sent by the storage engine, write the data to be written to the cache device, and report a successful data write to the storage engine after the write is complete. Furthermore, the controller can determine the target physical address corresponding to the data to be written in the log area and perform a data write operation to the target physical address based on the data to be written cached in the cache device. That is, after receiving the data to be written, the controller can first write the data to the cache device; once the cache device completes the write, it is considered a successful write, thereby further accelerating the data write speed. During the process of writing data from the cache device to the log area, if an external read request is received, the controller can respond to the external read request based on the data cached in the cache device. In other words, this specification separates data reading and writing before the log area is converted into the data area. The log area performs the writing operations, and the cache device performs the reading operations. This ensures both efficient data writing to the log area and meets external reading requirements.
[0073] The aforementioned cache devices may include types such as DRAM or SRAM as described above, and this specification does not limit them. These cache devices may have power-loss protection, ensuring that even if a power outage occurs during the process of writing data from the cache device to the log area, the cache device can still guarantee that the data is successfully written to the log area, thereby ensuring a high data write success rate.
[0074] To achieve read-write separation, a cached physical address column for the temporary read address of the data to be written can be recorded in the mapping table. The log area physical address column records the temporary write address of the data to be written, and the data area physical address column records the long-term read-write address of the data to be written. When the data to be written has already been written to the target cached physical address in the cache device, the target mapping relationship can be updated to include the target cached physical address recorded in the cached physical address column, as shown in Table 5.
[0075]
[0076] Table 5
[0077] As shown in Table 5, assuming the storage device is currently performing a write operation on data to be written at logical address LBA 3, then PBA J-read3 can be considered as the target cache physical address as described above, and thus based on this target cache physical address (PBA) J-read 3) Even if the data to be written is still in the process of being written to the log area, the data reading operation can still be performed without interfering with the writing to the log area. This achieves data read-write separation, which not only ensures the efficient working mode of the log area, but also enables the reading operation of the data to be written, thus meeting external reading needs and improving the user experience.
[0078] As mentioned earlier, both the cache physical address column and the log area physical address column can be regarded as temporary address columns. Therefore, when the write operation of the data to be written is completed in the log area, the target mapping relationship can be updated to mark the physical addresses recorded in the address columns other than the logical address column and the data area physical address column as invalid, so as to release the corresponding storage space, as shown in Table 6.
[0079]
[0080] Table 6
[0081] In other words, assuming the data to be written at logical address LBA 3 has not been completely written, then the PBA in Table 6... J-read 3 will not be marked as invalid, and it can still be passed through PBA. J-read 3 corresponds to the storage location in the cache device to read the data to be written; and assuming the data to be written is successfully written to the log area, then the PBA in Table 6... J-read 3 can be marked as invalid, thus allowing access via the PBA in the physical address column of the data area. J 3. Perform data reading operations.
[0082] To gain a deeper understanding of the data writing method described in this manual, the following section refers to the appendix. Figure 7 This specification provides a detailed description of the overall process for writing and reading data. For example... Figure 7 As shown, Figure 7 This is a schematic diagram of an overall data writing and reading process provided by an exemplary embodiment of this specification, including the following steps:
[0083] Step 701, Begin.
[0084] Step 702: The storage engine sends out the data to be written and the corresponding logical address.
[0085] Step 703: After successfully writing the data to be written to the cache device, a write success message will be sent.
[0086] Because the storage device described in this specification can be configured with a cache device, the data to be written can be written to the cache device first. Once the cache device successfully writes the data, it will send a success message, thus speeding up the writing process.
[0087] Step 704: The controller writes the data to be written to the corresponding log area according to the physical address of the corresponding log area, based on the data to be written stored in the cache device.
[0088] After the cache device has finished writing the data to be written, the controller can write the data to be written stored in the cache device to the log area. Moreover, as mentioned earlier, because the log area is only written to and not read from, write operations to the log area have the highest priority, so the log area can write data at a high speed.
[0089] Step 705: Determine if the writing is complete.
[0090] If the writing is complete, proceed to step 714.
[0091] If the writing is not complete, proceed to step 706.
[0092] Step 706: Determine if a read request has been received.
[0093] If a read request is received, proceed to step 707.
[0094] If no read request is received, proceed to step 711.
[0095] Step 707: Determine whether to read the current log area data.
[0096] If reading data from the current log area, proceed to step 709.
[0097] If the data is not being read from the current log area, proceed to step 708.
[0098] Step 708: Start the data area read function to read data in parallel from the data area.
[0099] After metadata conversion, the log area can be transformed into a data area. As mentioned earlier, the data area serves as a long-term read / write zone, performing normal data reading, garbage collection, and other operations. Furthermore, because the log area can include one or more log sub-areas, and these sub-areas can encompass multiple free storage areas across channels, parallel data writing can be achieved based on these cross-channel free storage areas. Conversely, when the log area is converted into the data area, parallel data reading can be achieved based on the cross-channel storage areas, improving the data reading rate.
[0100] Step 709: Find the corresponding cache physical address based on the mapping table.
[0101] Since write operations to the log area have the highest priority and the log area is read-only (read-write separation), to meet external read demands, read-write separation can be implemented by adding the corresponding physical address of the cache device to the mapping table. Then, based on this physical address, the data to be written is read from the cache device. This not only ensures efficient writing to the log area but also simultaneously meets the user's read needs, improving the user experience. Of course, as mentioned earlier, reading from the cache device is temporary. Assuming the data to be written is successfully written to the data area, the cache physical address can then be marked as invalid, thereby releasing cache space.
[0102] Step 710: Determine whether the read operation is complete.
[0103] If the read operation is complete, proceed to step 704 to continue the write operation.
[0104] If the read operation is not completed, proceed to step 707 to determine again whether to read the current log area data.
[0105] Step 711: Determine if the device needs to be restarted.
[0106] If the device restarts, proceed to step 712.
[0107] If the device does not restart, proceed to step 704 to continue the write operation.
[0108] Step 712: Abandon the read operation and use the power-loss protection function of the cache device to write the data to be written to the corresponding log area.
[0109] Because the cache device has a power-off protection function, even if the device restarts, the data to be written can still be written to the corresponding log area.
[0110] Step 713: Determine if the writing is complete.
[0111] If the writing is not complete, proceed to step 712.
[0112] If the writing is complete, proceed to step 714.
[0113] Step 714: Use the physical address of the log area as the physical address of the data area, convert the log area to the data area, and release the cache space of the cache device.
[0114] By transforming the metadata—that is, using the physical address of the log area as the physical address of the data area—the roles of the log area and the data area are switched, so that data only needs to be written once, eliminating the need for double writing. After the log area is converted to the data area, i.e., after the data to be written is successfully written to the log area, the cache physical address corresponding to the cache device stored in the mapping table can be marked as invalid, thereby releasing the cache space of the cache device.
[0115] Step 715: Determine whether to continue writing.
[0116] If writing continues, proceed to step 703.
[0117] If no further writing is performed, proceed to step 716.
[0118] Step 716, End.
[0119] It should be noted that, due to Figure 7 The overall process shown is based on Figures 1 to 6 The embodiments described herein are integrated; therefore, for details, please refer to [link / reference]. Figures 1 to 6 The embodiments described above are sufficient, and will not be repeated here.
[0120] As can be seen from the above embodiments, this specification divides the non-volatile memory in the storage device into a log area and a data area. However, it does not replace the log disk and data disk in related technologies with the log area and data area. Instead, it only writes data to the log area. After the data writing operation is completed in the log area, the role of the log area and the data area is converted based on the update of the mapping table. This makes the log area change from its original role as a log area to the role of a data area. Therefore, only one data write is required in the entire data writing process. This avoids the defect of the double write mechanism that increases the amount of data written many times, reduces write amplification, and eliminates the need to move the data in the log area to the data area, which would cause frequent data movement operations. It also reduces the probability of triggering garbage collection.
[0121] Specifically, write operations to the log area are set to have the highest priority, which ensures that write operations to the log area can be completed efficiently without being affected by other access scheduling operations. Compared with writing data directly to the data area, writing data to the log area and then converting the log area into the data area can ensure a relatively higher data writing speed.
[0122] Furthermore, since this manual eliminates the costly journal disk, high-speed data writing can be achieved using only a single type of storage device. This not only saves on the cost of using a journal disk but also frees up the PCIe bandwidth and PCIe lanes previously occupied by the journal disk, alleviating the resource constraints related to PCIe bandwidth and PCIe lanes. Moreover, no longer limited by the high price of journal disks, the electronic devices described in this manual can be equipped with a relatively larger number of storage devices with greater capacity. This significantly reduces the average amount of data written to each storage device, thereby lowering the throughput requirements for each storage device and extending its lifespan.
[0123] Corresponding to the embodiments of the methods described above, this specification also provides embodiments of the apparatus.
[0124] Figure 8 This is a schematic structural diagram of an electronic device provided in an exemplary embodiment. Please refer to it. Figure 8 At the hardware level, the electronic device includes a processor 801, a network interface 802, memory 803, a storage device 804, and an internal bus 805, and may also include other hardware required for its functions. The storage device 804 may include a controller, non-volatile memory, and a cache device. The controller may implement a data writing device through firmware or other hardware, software, or a combination of hardware and software.
[0125] Figure 9 This is a block diagram of a data writing device provided in an exemplary embodiment, such as Figure 9 As shown, a controller is applied in a storage device, the storage device further including a non-volatile memory connected to the controller, and the storage space of the non-volatile memory is divided into a log area and a data area; the controller is configured such that write operations to the log area have the highest priority in access scheduling operations to the storage device; wherein, the controller is also used to maintain a mapping table, the mapping table including a logical address column, a log area physical address column, and a data area physical address column, for recording the mapping relationship between logical addresses in the non-volatile memory, the physical addresses of the log area, and the physical addresses of the data area, the device includes:
[0126] The receiving unit 902 is used to receive a data write request, wherein the data write request includes data to be written and a target logical address corresponding to the data to be written;
[0127] The determining unit 904 is used to determine the target physical address corresponding to the data to be written in the log area, perform a data writing operation to the target physical address, and add a corresponding target mapping relationship in the mapping table. The target mapping relationship includes the target logical address recorded in the logical address column and the target physical address recorded in the log area physical address column.
[0128] The update unit 906 is used to update the target mapping relationship so that it includes the target physical address recorded in the physical address column of the data area when the data writing operation is completed.
[0129] Optionally, the log area includes one or more log sub-areas, and the determining unit 904 is specifically used for:
[0130] A log sub-region is sequentially selected from the log region, and the physical address of the selected log sub-region is determined as the target physical address.
[0131] Optionally, each log sub-region includes multiple free storage areas across channels.
[0132] Optionally, the controller further includes the following configuration: the log area is write-only and read-only; the storage device further includes a cache device with power-loss protection; and the determining unit 904 is specifically used for:
[0133] In response to the data write request sent by the storage engine, the data to be written is written to the cache device; if the data to be written has been written to the cache device, feedback is sent to the storage engine that the data write was successful; the target physical address corresponding to the data to be written in the log area is determined, and the data write operation is performed to the target physical address according to the data to be written cached in the cache device.
[0134] Optionally, the log area physical address column is used to record the temporary write address of the data to be written, the data area physical address column is used to record the long-term read / write address of the data to be written, the mapping table further includes a cache physical address column for recording the temporary read address of the data to be written, and the device further includes:
[0135] The cache update unit 908 is used to update the target mapping relationship so that it includes the target cache physical address recorded in the cache physical address column when the data to be written has been written to the target cache physical address in the cache device.
[0136] Optionally, the device further includes:
[0137] The invalidation unit 910 is used to update the target mapping relationship to mark the physical addresses recorded in the address columns other than the logical address column and the data area physical address column as invalid when the write operation of the data to be written is completed in the log area, so as to release the corresponding storage space.
[0138] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments of the relevant methods, and will not be elaborated upon here.
[0139] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The device embodiments described above are merely illustrative. The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0140] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0141] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0142] The terminology used in one or more embodiments of this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of one or more embodiments of this specification. The singular forms “a,” “described,” and “the” used in one or more embodiments of this specification and in the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0143] It should be understood that although the terms first, second, third, etc., may be used to describe various information in one or more embodiments of this specification, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first information may also be referred to as second information without departing from the scope of one or more embodiments of this specification, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to a determination."
[0144] The above description is merely a preferred embodiment of one or more embodiments of this specification and is not intended to limit the scope of one or more embodiments of this specification. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of one or more embodiments of this specification should be included within the protection scope of one or more embodiments of this specification.
Claims
1. A data writing method, characterized in that, A controller is applied in a storage device, the storage device further including a non-volatile memory connected to the controller, and the storage space of the non-volatile memory is divided into a log area and a data area; the controller is configured such that write operations to the log area have the highest priority in access scheduling operations to the storage device; wherein the controller is also used to maintain a mapping table, the mapping table including a logical address column, a log area physical address column, and a data area physical address column, for recording the mapping relationship between logical addresses in the non-volatile memory, the physical addresses of the log area, and the physical addresses of the data area, the method including: Receive a data write request, the data write request including the data to be written and the target logical address corresponding to the data to be written; Determine the target physical address corresponding to the data to be written in the log area, perform a data write operation to the target physical address, and add a corresponding target mapping relationship in the mapping table. The target mapping relationship includes the target logical address recorded in the logical address column and the target physical address recorded in the log area physical address column. Upon completion of the write operation of the data to be written, the target mapping relationship is updated to use the target physical address recorded in the log area physical address column as the target physical address recorded in the data area physical address column.
2. The method according to claim 1, characterized in that, The log area contains one or more log sub-areas; determining the target physical address corresponding to the data to be written in the log area includes: A log sub-region is sequentially selected from the log region, and the physical address of the selected log sub-region is determined as the target physical address.
3. The method according to claim 2, characterized in that, Each log sub-region includes multiple free storage areas across channels.
4. The method according to claim 1, characterized in that, The controller is further configured such that the log area is write-only and read-only; the storage device further includes a cache device with power-loss protection; and the step of determining the target physical address corresponding to the data to be written in the log area and performing a data write operation to the target physical address includes: In response to the data write request sent by the storage engine, the data to be written is written to the cache device; If the data to be written has been written to the cache device, a message is sent to the storage engine indicating that the data write was successful. The target physical address corresponding to the data to be written in the log area is determined, and the data write operation is performed to the target physical address according to the data to be written cached in the cache device.
5. The method according to claim 4, characterized in that, The log area physical address column is used to record the temporary write address of the data to be written, the data area physical address column is used to record the long-term read / write address of the data to be written, the mapping table also includes a cache physical address column for recording the temporary read address of the data to be written, and the method further includes: If the data to be written has already been written to the cache device, update the target mapping relationship to include the target cache physical address recorded in the cache physical address column.
6. The method according to claim 1, characterized in that, The method further includes: When the write operation of the data to be written is completed in the log area, the target mapping relationship is updated to mark the physical addresses recorded in the address columns other than the logical address column and the data area physical address column as invalid, so as to release the corresponding storage space.
7. A data writing device, characterized in that, A controller is used in a storage device, the storage device further including a non-volatile memory connected to the controller, and the storage space of the non-volatile memory is divided into a log area and a data area; the controller is configured such that write operations to the log area have the highest priority in access scheduling operations to the storage device; wherein the controller is also used to maintain a mapping table, the mapping table including a logical address column, a log area physical address column, and a data area physical address column, for recording the mapping relationship between logical addresses in the non-volatile memory, the physical addresses of the log area, and the physical addresses of the data area, the device comprising: A receiving unit is configured to receive a data write request, wherein the data write request includes data to be written and a target logical address corresponding to the data to be written. The determining unit is used to determine the target physical address corresponding to the data to be written in the log area, perform a data writing operation to the target physical address, and add a corresponding target mapping relationship in the mapping table. The target mapping relationship includes the target logical address recorded in the logical address column and the target physical address recorded in the log area physical address column. An update unit is used to update the target mapping relationship after the data write operation is completed, so that the target physical address recorded in the log area physical address column is used as the target physical address recorded in the data area physical address column.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 6.
9. A storage device, characterized in that, It includes a controller and a non-volatile memory connected to the controller, the controller being used to implement the steps of the method as described in any one of claims 1 to 6.
10. An electronic device, characterized in that, Includes the storage device as described in claim 9.
Citation Information
Patent Citations
Method improving log block data tidying performance in mixed map
CN105302736A
Apparatus and Method for Operating Write-Ahead-Logging
KR1020170048084A