Data writing method, device, system, apparatus, and product
By adding priority flags to write requests and differentiating hardware queue processing, the problem of background tasks competing for storage resources with foreground tasks is solved, improving write efficiency and the data write speed of foreground tasks.
Patent Information
- Application Number
- CN202510679684.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-23
- Publication Date
- 2026-11-24
AI Technical Summary
Background tasks compete for storage resources from foreground tasks, affecting the running quality of foreground tasks.
A priority identifier is added to the write request. The block layer submits the write request directly to the first hardware queue of the storage device layer or writes it to the software queue first and then submits it to the second hardware queue based on the priority identifier. The storage device layer writes data to the write requests in the two queues.
It improves the processing efficiency of write requests, especially the writing speed of priority data, avoids background tasks competing for storage resources with foreground tasks, and improves the running quality of foreground tasks.
Smart Images

Figure CN123157124A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of storage technology, and in particular to a data writing method, apparatus, system, device and product. Background Technology
[0002] During computer operation, both foreground and background tasks require data writing. However, background tasks can compete for storage resources with foreground tasks, affecting the performance of foreground tasks. Summary of the Invention
[0003] This application provides a data writing method, apparatus, system, device, and product. The technical solution is as follows:
[0004] On one hand, embodiments of this application provide a data writing method, the method comprising:
[0005] The file system sends the first write request to the block layer;
[0006] If the first write request contains a priority identifier, the block layer submits the first write request to the first hardware queue of the storage device layer;
[0007] If the first write request does not contain the priority identifier, the block layer writes the first write request to the software queue and submits the write requests in the software queue to the second hardware queue of the storage device layer.
[0008] The storage device layer writes data to the write requests in the first hardware queue and the second hardware queue.
[0009] On the other hand, embodiments of this application provide a data writing device, the device comprising:
[0010] The processing module is used to send the first write request to the block layer through the file system;
[0011] The processing module is configured to submit the first write request to the first hardware queue of the storage device layer through the block layer if the first write request contains a priority identifier.
[0012] The processing module is configured to write the first write request into a software queue through the block layer when the first write request does not contain the priority identifier, and submit the write request in the software queue to the second hardware queue of the storage device layer.
[0013] The storage module is used to write data to the write requests in the first hardware queue and the second hardware queue through the storage device layer.
[0014] On the other hand, embodiments of this application provide a data storage system, the system comprising:
[0015] File system, block layer, and storage device layer;
[0016] The file system is used to send a first write request to the block layer;
[0017] The block layer is configured to submit the first write request to the first hardware queue of the storage device layer if the first write request contains a priority identifier.
[0018] The block layer is configured to write the first write request into a software queue if the first write request does not contain the priority identifier, and submit the write request in the software queue to the second hardware queue of the storage device layer.
[0019] The storage device layer is used to write data to the write requests in the first hardware queue and the second hardware queue.
[0020] On the other hand, embodiments of this application provide a computer device including a processor and a memory, wherein the memory stores at least one computer instruction, which is loaded and executed by the processor to implement the data writing method as described above.
[0021] On the other hand, embodiments of this application provide a computer-readable storage medium storing at least one computer instruction, which is executed by a processor to implement the data writing method as described above.
[0022] On the other hand, embodiments of this application provide a computer program product, the computer program product including computer instructions stored in a computer-readable storage medium; a processor reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions to implement the data writing method as described above.
[0023] In this embodiment, a priority identifier can be added to the write request. After the block layer recognizes the priority identifier, it directly submits the write request to the first hardware queue of the storage device layer. This simplifies the process of writing to the software queue first and then submitting to the second hardware queue, which helps to improve the processing efficiency of write requests and increase the writing speed of data that needs to be written first. For example, a priority identifier can be added to the write requests of foreground tasks to improve the data writing speed of foreground tasks and avoid the impact of background tasks competing for storage resources on the running quality of foreground tasks. Attached Figure Description
[0024] Figure 1 A flowchart illustrating a data writing method provided in an exemplary embodiment of this application is shown;
[0025] Figure 2 This is a schematic diagram illustrating an exemplary embodiment of the data writing process of this application;
[0026] Figure 3 This is a flowchart illustrating a write request processing procedure in a first hardware queue, as shown in an exemplary embodiment of this application;
[0027] Figure 4 This is a flowchart illustrating the write request processing procedure in a second hardware queue, as shown in an exemplary embodiment of this application;
[0028] Figure 5 This is a schematic diagram illustrating an implementation of the data writing process in another exemplary embodiment of this application;
[0029] Figure 6 This is a flowchart illustrating a data reading process in an exemplary embodiment of this application;
[0030] Figure 7 This is a system architecture diagram of a data storage system illustrated in an exemplary embodiment of this application;
[0031] Figure 8 A structural block diagram of a data writing apparatus provided in another exemplary embodiment of this application is shown;
[0032] Figure 9 A structural block diagram of a computer device provided in an exemplary embodiment of this application is shown. Detailed Implementation
[0033] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0034] In this article, "multiple" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.
[0035] In Zoned Universal Flash Storage (ZUFS), the address space is a collection of logical block addresses (LBAs) accessible to the host device software. It can be divided into multiple zones, and the logical block addresses within the same zone need to be written sequentially.
[0036] Since both foreground and background tasks need to write data, and these tasks may need to write data to the same zone, background tasks can compete for storage resources with foreground tasks, affecting the performance of foreground tasks.
[0037] In this embodiment, the storage device layer is provided with a first hardware queue and a second hardware queue, and priority identifiers can be added to write requests. Based on the priority identifiers carried in the write requests, the block layer can directly submit data that needs to be written first to the first hardware queue, and submit data that does not need to be written first to the software queue (which will be submitted to the second hardware queue later), thereby improving the write speed of data that needs to be written first.
[0038] The data writing method provided in this application can be applied to computer devices with flash memory storage devices that support zone partitioning. In some embodiments, the flash memory storage device may include ZNSSSD (Zoned Name Space SSD), ZUFS, SMR (Shingled Magnetic Recording), etc., and the computer device may include smartphones, tablets, personal computers, wearable devices, smart TVs, etc. This application does not limit the specific types of flash memory storage devices and computer devices.
[0039] Furthermore, the computer device in this application embodiment implements data writing through a file system, a block layer, and a storage device layer.
[0040] Please refer to Figure 1 This document illustrates a flowchart of a data writing method provided in an exemplary embodiment of this application. This embodiment uses the method applied to a computer device as an example for illustration, and the method may include the following steps:
[0041] Step 101: The file system sends the first write request to the block layer.
[0042] Optionally, the file system is F2FS (Flash Friendly File System).
[0043] In some embodiments, the first write request is a bio(blockio, block input / output) request.
[0044] In some embodiments, the upper layer can set a priority flag (REQ_VIP_IO) for high-priority IO requests and pass it to the storage device through the entire IO stack (requiring the extension of bio, request, and other structures to be passed sequentially to the block layer and storage device driver). For non-high-priority IO requests, there is no need to set a priority flag.
[0045] Correspondingly, the first write request sent by the file system to the block layer may or may not include a priority identifier.
[0046] In one possible implementation, the write request includes a priority bit, which uses different bit values to indicate whether it contains a priority identifier. For example, a priority bit value of 0 indicates that no priority identifier is included, while a priority bit value of 1 indicates that a priority identifier is included.
[0047] After receiving the first write request, the block layer checks whether the first write request contains a priority identifier. If it does, step 102 is executed; otherwise, step 103 is executed.
[0048] In one possible implementation, the block-level I / O scheduler detects the setting of REQ_VIP_IO via the blk_mq_sched_bypass_insert() function.
[0049] Step 102: If the first write request contains a priority identifier, the block layer submits the first write request to the first hardware queue of the storage device layer.
[0050] In some embodiments, the storage device layer sets up hardware queues for write requests that include a priority identifier and for write requests that do not include a priority identifier, namely a first hardware queue and a second hardware queue.
[0051] In some embodiments, each processor core of the processor corresponds to its own first hardware queue and second hardware queue, and both the first hardware queue and the second hardware queue are submission / completion queues.
[0052] When the block layer detects that the first write request contains a priority identifier, it bypasses software queue scheduling and directly submits the first write request to the first hardware queue of the storage device layer. In other words, the first write request containing a priority identifier will not be written to the software queue and then submitted from the software queue to the hardware queue, but will be submitted directly to the hardware queue. Since it does not need to go through software queue scheduling, write requests containing priority identifiers can be dispatched to the storage device layer for processing more quickly.
[0053] Step 103: If the first write request does not contain a priority identifier, the block layer writes the first write request to the software queue and submits the write requests in the software queue to the second hardware queue of the storage device layer.
[0054] When the block layer detects that the first write request does not contain a priority identifier, it first writes the first write request to the software queue according to the normal scheduling logic, and then submits it to the second hardware queue under the scheduling of the software queue.
[0055] Since the first hardware queue and the second hardware queue are two independent hardware queues, the processing latency of write requests in the first hardware queue can be further reduced.
[0056] In some embodiments, the software queue is an mq-deadline queue. Accordingly, the block layer schedules write requests in the queue to a second hardware queue via the mq-deadline scheduler.
[0057] Step 104: The storage device layer writes data to the write requests in the first hardware queue and the second hardware queue.
[0058] In some embodiments, the storage device layer reads write requests from a first hardware queue and a second hardware queue, and writes the write data indicated by the write request into the storage area. When reading write requests from the first and second hardware queues, the storage device layer reads the write requests from the first and second hardware queues according to the principle of avoiding blocking high-priority write requests in the first hardware queue from low-priority write requests in the second hardware queue.
[0059] Optionally, whether read / write requests are received from the first or second hardware queue is controlled by the storage device controller at the storage device layer. For example, for a ZUFS storage device, this storage device controller is a UFS controller.
[0060] Indicative, such as Figure 2 As shown, during the data writing process, the upper layer uses priority awareness to identify and add priority identifiers to high-priority write requests. After the file system 21 sends a bio request 221 to the block layer 22, the block layer 22 recognizes that the bio request 221 contains a priority identifier, and thus directly submits the bio request 221 to the first hardware queue 231. For low-priority write requests, since the bio request 221 does not contain a priority identifier, the block layer 22 writes the bio request 221 to the software queue 222, and under the scheduling of the software queue scheduler, submits the write requests in the software queue 222 to the second hardware queue 232. The storage device 23 then reads the write requests from the first hardware queue 231 and the second hardware queue 232 through the storage device controller, and writes the write data indicated by the write request into the flash page 233.
[0061] In summary, in this embodiment, priority identifiers can be added to write requests. After the block layer recognizes the priority identifier, it directly submits the write request to the first hardware queue of the storage device layer. This simplifies the process of writing to the software queue first and then submitting to the second hardware queue, which helps improve the processing efficiency of write requests and increases the writing speed of data that needs to be written first. For example, priority identifiers can be added to write requests of foreground tasks to improve the data writing speed of foreground tasks and avoid the impact of background tasks competing for storage resources on the running quality of foreground tasks.
[0062] In one possible application scenario, write requests from the foreground application include a priority identifier, while write requests from the background application do not. Therefore, write requests from the foreground application will be directly submitted to the first hardware queue, while write requests from the background application will be submitted to the second hardware queue via a software queue, thereby speeding up the processing of write requests from the foreground application.
[0063] Of course, in addition to setting priority identifiers according to front-end and back-end, priority identifiers can also be set according to other factors such as application type and application sensitivity to IO speed in other possible application scenarios. This application embodiment does not limit this.
[0064] Write requests in the first hardware queue
[0065] In one possible implementation, to prevent write requests in the second hardware queue from blocking write requests in the first hardware queue, the first hardware queue is set to a first priority, and the second hardware queue is set to a second priority, wherein the first priority is higher than the second priority.
[0066] Accordingly, when writing data, the storage device layer writes data to the write requests in the first hardware queue based on the first priority, and writes data to the write requests in the second hardware queue based on the second priority.
[0067] Since the first priority is higher than the second priority, the storage device layer prioritizes writing data to write requests in the first hardware queue, thereby avoiding high-priority write requests being blocked by low-priority write requests.
[0068] To avoid request starvation in the second hardware queue due to priority settings, a series of conditions can be set to trigger the cessation of processing write requests in the first hardware queue and the commencement of processing write requests in the second hardware queue.
[0069] Optionally, the above conditions include at least one of the request quantity condition and the unservice duration condition.
[0070] In one possible implementation, if the number of write requests in the second hardware queue does not reach the quantity threshold and the unservice duration of the second hardware queue does not reach the duration threshold, the storage device layer writes data to the write requests in the first hardware queue based on the first priority and writes data to the write requests in the second hardware queue based on the second priority.
[0071] If the number of write requests in the second hardware queue reaches a certain threshold, and / or the unservice duration of the second hardware queue reaches a certain duration threshold, the storage device layer stops writing data to the write requests in the first hardware queue and starts writing data to the write requests in the second hardware queue.
[0072] The unservice duration refers to the time interval between the last time a write request in the second hardware queue was processed and the current time.
[0073] The quantity threshold and duration threshold can be customized according to requirements. For example, the quantity threshold can be set to 8, and the duration threshold can be set to 200us.
[0074] In some embodiments, when the data writing of a write request in the second hardware queue is completed, or when the number of write requests in the second hardware queue is less than a number threshold after the data writing of a write request in the second hardware queue is completed, the storage device layer re-writes data based on the first priority and the second priority.
[0075] In this embodiment, by setting a higher priority for the first hardware queue than for the second hardware queue, data is written to high-priority write requests in the first hardware queue first, thus avoiding blocking of high-priority write requests by low-priority write requests and reducing the processing latency of high-priority write requests.
[0076] Furthermore, by setting request quantity conditions and / or downtime conditions, write requests in the second hardware queue can be triggered to avoid request starvation in the second hardware queue due to long-term priority processing of high-priority write requests.
[0077] IO optimization for low-priority write requests
[0078] When the address space at the storage device layer is divided into different zones, for low-priority write requests to the software queue, the software queue scheduler submits the write requests in the same zone to the second hardware queue in LBA order.
[0079] In related technologies, to ensure sequential processing of write requests, the software queue scheduler allocates a zone lock to each zone currently writing, guaranteeing that each zone can only serve one write request at a time. This approach limits the queue depth of each zone to 1, thereby limiting the IO performance of low-priority write requests.
[0080] However, when the storage device supports ordering requests in a single hardware queue (i.e., the storage device controller processes write requests submitted to the hardware queue in order without reordering), even if multiple write requests from the same zone are submitted to the hardware queue in LBA order, the sequential processing of multiple write requests in the same zone can still be guaranteed.
[0081] Therefore, in order to increase the queue depth of the zone and thus improve the IO performance of low-priority write requests, the block layer maintains a mapping relationship between the zone and the second hardware queue, and submits write requests in the software queue to the second hardware queue based on this mapping relationship.
[0082] In one possible implementation, during the process of the block layer submitting write requests from the software queue to the second hardware queue of the storage device layer, the block layer first determines the target second hardware queue mapped to the first target zone corresponding to the write request, wherein the first target zone is the zone to which the write data indicated by the write request is to be written. Further, the block layer submits the write request (from the software queue) to the target second hardware queue and updates the request count corresponding to the first target zone.
[0083] The request count represents the number of unprocessed write requests in the first target zone, and its initial value is 0. Accordingly, the block layer updates the request count for the first target zone based on the number of write requests submitted to the second target hardware queue.
[0084] In an illustrative example, when write request A in the software queue indicates that the data to be written is to zone1, the block layer, based on the mapping relationship between zones and the second hardware queue, determines that the target second hardware queue corresponding to zone1 is hardware queue 1 (indicating that there is a write request for zone1 in hardware queue 1), and thus submits write request A to hardware queue 1. When the request count for zone1 is 2, after submitting write request A to hardware queue 1, the request count for zone1 is updated to 3.
[0085] Based on the mapping relationship between zones and the second hardware queue, it can be ensured that multiple write requests in the same zone are submitted to the same second hardware queue. Since requests in the second hardware queue are ordered, multiple write requests in the same zone can be guaranteed to be processed sequentially.
[0086] Regarding the method of establishing the mapping relationship between the zone and the second hardware queue, in one possible implementation, if there is no target second hardware queue mapped to the first target zone, the block layer will trigger the second hardware queue corresponding to the processor of the write request, determine it as the target second hardware queue mapped to the first target zone, that is, establish the mapping relationship between the first target zone and the target second hardware queue, and initialize the request count corresponding to the first target zone.
[0087] Optionally, the processor refers to the processor core on a SoC (System on Chip).
[0088] In some embodiments, a processor may correspond one-to-one with a second hardware queue, or different processors may correspond to the same second hardware queue.
[0089] In an illustrative example, when write request B in the software queue indicates that the data to be written is to zone2, since there is no second hardware queue mapped to zone2 (indicating that there is no write request corresponding to zone2 in any of the second hardware queues), the block layer determines the hardware queue 2 corresponding to the processor that triggered write request B as the target second hardware queue mapped to zone2, and thus submits write request B to hardware queue 2. After submitting write request B to hardware queue 2, the request count corresponding to zone2 is updated to 1.
[0090] In addition to updating the request count corresponding to the first target zone after submitting the write request to the target second hardware queue, in some embodiments, the block layer updates the request count corresponding to the first target zone when the write request processing is completed.
[0091] Optionally, when a write request is completed, the block layer decrements the request count corresponding to the first target zone by one.
[0092] After the request count is updated, the block layer checks if the request count is 0. If the updated request count for the first target zone is 0, the block layer deletes the mapping between the first target zone and the target second hardware queue. Accordingly, before submitting write requests for the first target zone to the second hardware queue, the mapped target second hardware queue for the first target zone needs to be reconfigured.
[0093] If the request count corresponding to the updated first target zone is not 0, since there are still unprocessed write requests corresponding to the first target zone in the second target hardware queue, the block layer maintains the mapping relationship between the first target zone and the second target hardware queue, ensuring that subsequent write requests of the first target zone can still be submitted to the second target hardware queue, thereby ensuring that the write requests in the first target zone are processed in LBA order.
[0094] Since implementing the above scheme requires the storage device to support the ordering of requests in a single hardware queue, in one possible implementation, when the storage device corresponding to the storage device layer has a preset identifier, the block layer ignores the zone lock of the first target zone and submits multiple write requests of the first target zone to the target second hardware queue in logical address order. The preset identifier is used to characterize that the storage device supports the ordering of requests in a single hardware queue.
[0095] By ignoring zone locks, multiple write requests for the same zone can be written to the second hardware queue simultaneously.
[0096] In some embodiments, a new flag, QUEUE_FLAG_NO_ZONE_WRITE_LOCK, is added to the struct request_queue of the storage device to indicate that the storage device supports ordering requests within a single hardware queue. Correspondingly, the block-level I / O scheduler adds the mq-deadline-nozonelock algorithm to record the mapping between zones and second hardware queues for storage devices with QUEUE_FLAG_NO_ZONE_WRITE_LOCK and ignore zone locks, allowing multiple write requests within the same zone to be written to the same second hardware queue.
[0097] In this embodiment, by leveraging the storage device's ability to maintain the order of requests in a single hardware queue, the block layer ignores the zone lock of the zone and submits multiple write requests of the same zone to the same second hardware queue simultaneously based on the mapping relationship between the zone and the second hardware queue. This increases the queue depth of the zone and helps improve the IO performance of low-priority write requests.
[0098] When using the solution provided in the above embodiments to bypass high-priority write requests to reduce processing latency, there may be a problem where multiple write operations are submitted out of order to the same zone (for example, a high-priority write request with a later logical address is submitted before a low-priority write request with an earlier logical address). In this case, the offset of the write pointer in the physical zone does not match the starting address of the write request, resulting in write failure.
[0099] To address the write pointer mismatch issue, in one possible implementation, the write data indicated by a high-priority write request is not directly written to the physical zone. Instead, the write data indicated by the out-of-order high-priority write request is carried over using the write booster feature of the storage device.
[0100] WriteBooster was introduced into flash memory storage devices to mitigate the negative impact of high-density flash memory on write performance. It simulates low-density flash memory (pseudo-Single Level Cell, pSLC). Due to its better write performance, WriteBooster is used as a non-volatile write buffer for the host, and this part of the flash memory is not externally addressable, thereby improving the device's burst write capability.
[0101] In some embodiments, when the storage device layer writes data to write requests in the first hardware queue and the second hardware queue, it writes data to write requests in the first hardware queue in the first storage area and writes data to write requests in the second hardware queue in the second storage area.
[0102] Optionally, the first storage area is a WriteBooster area, while the second storage area is a physical zone area.
[0103] In some embodiments, the first storage area is an SLC area, and the second storage area is an MLC (Multi-Level Cell), TLC (Triple-Level Cell), or QLC (Quad-Level Cell) area. The flash memory block can be used as pSLC in one erase cycle and as MLC, TLC, or QLC in another erase cycle. In pSLC mode, the capacity is reduced to approximately one-third of that in TLC. Because the flash memory block can switch between pSLC and TLC (MLC or QLC) modes on demand, the storage device can dynamically adjust the size of the first and second storage areas according to actual needs.
[0104] In some embodiments, for storage devices that support zone partitioning, the size of the first storage region can be determined based on the number of zones being written to (i.e., the number of open zones). The size of the first storage region is positively correlated with the number of zones being written to.
[0105] Data writing process in the first storage area
[0106] In one possible implementation, when the address space of the storage device layer is divided into different zones, a first storage area is used to cache high-priority write data from different zones, while a second storage area is used for low-priority write data from different zones. To facilitate indexing of high-priority write data, the storage device layer maintains corresponding intra-zone mappings for each zone in the first storage area, so that data indexing can be implemented based on these intra-zone mappings.
[0107] like Figure 3 As shown, the storage device layer may perform the following steps to write data to a write request in the first hardware queue in the first storage area:
[0108] Step 301: The storage device layer determines the first target zone corresponding to the write request. The first target zone is the zone where the data to be written is indicated by the write request.
[0109] Since the address space of the first storage region is divided into different zones, the storage device layer first needs to determine the first target zone where the write data in the write request is to be written.
[0110] Step 302: The storage device layer writes the write data indicated by the write request to the position indicated by the first write pointer corresponding to the first target zone in the first storage area, and updates the first write pointer corresponding to the first target zone.
[0111] In one possible implementation, the zone mapping corresponding to each zone in the first storage area includes the zone identifier of the physical zone in the second storage area corresponding to the zone in the first storage area, the starting address of the zone in the first storage area, and the write pointer of the zone.
[0112] Accordingly, the storage device layer writes the write data indicated by the write request to the first target zone in the first storage area based on the first write pointer corresponding to the first target zone, and updates the first write pointer according to the amount of write data.
[0113] It should be noted that since the write data indicated by the write request in the first hardware queue is written to the first storage area, not the second storage area, the write pointer corresponding to the zone in the second storage area will not be updated.
[0114] Step 303: The storage device layer updates the first target mapping group corresponding to the first target zone. The first target mapping group is used to characterize the storage location of the data of the data block in the first target zone in the second storage area.
[0115] In one possible implementation, the zone mapping also includes a first target mapping group corresponding to the first target zone. Based on the first target mapping group, the actual storage location of the write data cached in the first target zone in the first storage area within the first target zone in the second storage area can be determined.
[0116] In one possible design, the first target mapping group is a one-dimensional array, where each member of the array represents the offset of a storage cell (e.g., a flash page or data block) in the second storage region within the first storage region. The offset is the address of the written data in the first target zone within the first storage region minus the starting address of the first target zone within the first storage region.
[0117] In an illustrative example, the number of array members in the first target mapping group equals the size of the first target zone divided by the storage unit size, which is the number of storage pages in the first target zone. For instance, if the physical zone size of the first target zone is 128MB and the flash page size is 16KB, the number of array members in the first target mapping group corresponding to the first target zone is 8192, and each array member occupies 13 bits.
[0118] Furthermore, the total space required to maintain the intra-zone mapping of a single zone is: zone identifier (4 bytes) + starting address (4 bytes) + write pointer (4 bytes) + (8192*13) / 8 = 13.01171875KB.
[0119] In some embodiments, zone mappings are stored in the storage device cache (such as SRAM). Since the number of zones that can be opened simultaneously is typically 6, and the storage device cache is typically several MB, the space occupied by zone mappings is acceptable for the storage device cache.
[0120] During the update of the first target mapping group, the storage device layer writes the write data to the storage location of the second storage area into the first target mapping group. This storage location can be represented by an identifier of a storage cell, such as a flash page ID.
[0121] Schematic, the first target mapping group currently contains 501 and 502, indicating that write data requiring flash pages 501 and 502 is cached in the first target zone. When the write data is stored in the second storage area as flash page 510, the storage device layer adds the flash page ID "510" to the first target mapping group, meaning the updated first target mapping group contains 501, 502, and 510.
[0122] In this embodiment, by setting a write pointer for a zone in the first storage area and caching high-priority write data in the zone based on the write pointer, the continuity of the write data cached in the zone is guaranteed. Furthermore, by maintaining the mapping group corresponding to the zone, the mapping group is used to store the actual storage location of the high-priority write data cached in the first storage area in the second storage area, which facilitates the accurate migration of the data cached in the first storage area to the second storage area in the future.
[0123] Data writing process in the second storage area
[0124] Because the write pointers for zones in the second storage area are not updated when data is written to the first storage area, a mismatch between the write address and the write pointer occurs when writing data to a zone in the second storage area, preventing the write operation from being completed. In this case, to ensure normal data writing, the storage device layer needs to migrate the write data from the first storage area to the second storage area, so that the write address and write pointer match.
[0125] like Figure 4 As shown, the storage device layer can perform data writing for write requests in the second hardware queue in the second storage area, which may include the following steps:
[0126] Step 401: The storage device layer determines the first target zone corresponding to the write request. The first target zone is the zone where the data to be written is to be written, as indicated by the write request.
[0127] Since the address space of the second storage area is divided into different zones, the storage device layer first needs to determine the first target zone where the write data in the write request is to be written.
[0128] Step 402: The storage device layer reads data contiguous with the write address from the first storage area based on the write address indicated by the write request.
[0129] In one possible implementation, the storage device layer detects whether the write address indicated by the write request matches the second write pointer corresponding to the first target zone. If they match, the write data indicated by the write request is written to the first target zone, and the second write pointer corresponding to the first target zone is updated.
[0130] If there is a mismatch, it indicates that some write data needs to be written back from the first target zone of the first storage area to the second target zone of the second storage area, so that data contiguous with the write address can be read from the first storage area based on the write address indicated by the write request.
[0131] In order to determine which write data cached in the first storage area has an address that is contiguous with the write address indicated by the current write request, in some embodiments, the storage device layer reads data that is contiguous with the write address from the first storage area based on the first target mapping group corresponding to the first target zone and the write address indicated by the write request.
[0132] Optionally, the storage device layer determines the address in the first target mapping group that is preceding and contiguous with the write address indicated by the write request, and retrieves the corresponding write data from the first target zone of the first storage area based on the determined address.
[0133] Schematic, the first target mapping group contains 501, 502, and 510 (i.e., the first three flash pages of the first target zone store the data of flash pages 501, 502, and 510 in the actual physical zone, respectively). When the write request indicates a write address of 503, since the second write pointer indicates a position of 501, the storage device layer needs to read the write data corresponding to flash pages 501 and 502 (located in the first and second flash pages of the first target zone) from the first target zone of the first storage area. The write data corresponding to flash page 510 (located in the third flash page of the first target zone) is still cached in the first storage area.
[0134] Step 403: The storage device layer merges the data read from the first storage area and the write data indicated by the write request, writes it to the position indicated by the second write pointer corresponding to the first target zone in the second storage area, and updates the second write pointer corresponding to the first target zone.
[0135] Furthermore, the storage device layer merges the data read from the first storage area with the write data indicated by the write request. Since the write address of the merged write data matches the second write pointer, the storage device layer can correctly write the merged write data into the first target zone of the second storage area (the location indicated by the second write pointer) and update the second write pointer based on the size of the merged write data.
[0136] To illustrate, in conjunction with the example in the steps above, after writing data to flash pages 501, 502, and 503, the storage device layer updates the second write pointer to 504.
[0137] In this embodiment, when the write address does not match the write pointer of the zone in the second storage area, the storage device layer reads the cached data that is continuous with the write address based on the mapping group corresponding to the zone in the first storage area. This allows the cached data to be merged with the write data that needs to be written back and then written into the zone in the second storage area, ensuring the feasibility and accuracy of writing data in the second storage area in the case of out-of-order write-back.
[0138] Furthermore, the overhead of writing cached data from the first storage area back to the second storage area is borne by the low-priority data write process, which can reduce the impact of data migration on the high-priority data write process.
[0139] In an illustrative example, where the first storage area is an SLC area and the second storage area is a TLC area, in Figure 2 On the basis of, such as Figure 5 As shown, with six open zones, both the SLC region 234 and TLC region 235 of storage device 23 are divided into six zones. When processing a write request in the first hardware queue 231, the write data corresponding to the write request is written to the zone in SLC region 234. When processing a write request in the second hardware queue 232, if the write address indicated by the write request matches the write pointer of the zone in TLC region 235, the write data corresponding to the write request is directly written to the zone in TLC region 235. If the write address indicated by the write request does not match the second write pointer of the zone in TLC region 235, the write data needs to be read from the zone in SLC region 234, and the read write data is merged with the write data corresponding to the write request before being written to the zone in TLC region 235.
[0140] In addition to the need to migrate high-priority write data when writing low-priority write data, in one possible implementation, when the write request is the last write request of the first target zone and the remaining storage space of the first storage area is less than the storage space threshold, the storage device layer writes the data of the first target zone in the first storage area to the first target zone in the second storage area.
[0141] Optionally, the storage space threshold can be the size of a zone, but this embodiment of the application does not limit this.
[0142] In some embodiments, if the remaining storage space in the first storage area is greater than the storage space threshold, the write request is completed after the data is written to the first storage area; if the remaining storage space in the first storage area is less than the storage space threshold, the storage device layer will only report that the write request is complete after writing the cached write data in the first storage area back to the second storage area.
[0143] Of course, in other possible implementations, since the computer device has a lot of idle time, the write data cached in the first storage area can be written back to the second storage area in the idle state.
[0144] Furthermore, the storage device layer can periodically swap some storage cells between the first and second storage regions to balance the lifespan of the storage cells. Regarding error correction, the storage cells in the first and second storage regions can still employ their respective error correction strategies to ensure data accuracy. For example, compared to the first storage region of low-density flash memory, the second storage region of high-density flash memory can use stronger error correction codes.
[0145] Data reading process
[0146] Since high-priority write data is first cached in the first storage zone, the storage device layer needs to determine whether to read from the first storage zone or the second storage zone during the data reading process.
[0147] like Figure 6 As shown, the data reading process may include the following steps:
[0148] Step 601: The storage device layer determines the second target zone corresponding to the read request. The second target zone is the zone where the read data indicated by the read request is located.
[0149] Since the address spaces of the first and second storage regions are divided into different zones, the storage device layer first needs to determine the second target zone where the read data in the read request is to be written.
[0150] In some embodiments, each zone in the second storage area corresponds to its own second write pointer, which is used to indicate the current write address of data in the zone. After determining the second target zone, the storage device layer further determines the second write pointer corresponding to the second target zone in the second storage area and checks whether the read address of the read request is less than the address indicated by the second write pointer. If the read address of the read request is less than the address indicated by the second write pointer, then step 602 is executed; if the read address of the read request is greater than the address indicated by the second write pointer, then step 603 is executed.
[0151] In some embodiments, since some data is cached in the first storage area and some data is stored in the second storage area only for zones that are currently being written to, and all data for zones that are not currently being written to is stored in the second storage area, the storage device layer determines the relationship between the read address and the size of the second write pointer of the second target zone in the second storage area when the second target zone is a zone that is currently being written to (i.e., an open zone); and when the second target zone is not a zone that is currently being written to, the storage device layer reads data from the second target zone in the second storage area based on the read address.
[0152] Step 602: If the read address of the read request is less than the second write pointer of the second target zone in the second storage area, the storage device layer reads data from the second target zone in the second storage area based on the read address.
[0153] If the read address of the read request is less than the second write pointer of the second target zone in the second storage area, it indicates that the data corresponding to the read address has been written into the second target zone of the second storage area. Therefore, the storage device layer reads the data directly from the second target zone of the second storage area based on the read address.
[0154] Schematic, when the second write pointer of the second target zone points to flash page 504 and the read address of the read request points to flash page 500, the storage device layer reads data from the 500th flash page of the second target zone in the second storage area.
[0155] Step 603: If the read address of the read request is greater than the second write pointer of the second target zone in the second storage area, the storage device layer reads data from the second target zone in the first storage area based on the read address.
[0156] If the read address of the read request is greater than the second write pointer of the second target zone in the second storage area, it indicates that the data corresponding to the read address has not yet been written to the second target zone of the second storage area, but is cached in the second target zone of the first storage area and has not yet been flushed to the second storage area. Therefore, the storage device layer needs to read the data from the second target zone of the first storage area.
[0157] Since the zone in the first storage area only caches high-priority write data in LBA order, the storage device layer cannot accurately find the data based on the read address alone. Instead, it needs to use the second target mapping group corresponding to the second target zone to determine the storage location of the read data in the second target zone.
[0158] In one possible implementation, the storage device layer reads data from the second target zone of the first storage area based on the second target mapping group corresponding to the second target zone and the read address. The second target mapping group is used to characterize the storage location of the data block in the second target zone in the second storage area.
[0159] Optionally, the storage device layer determines the array member in the second target mapping group that matches the read address, and determines the location of the read data in the second target zone in the first storage area based on the position of the matching array member in the second target mapping group.
[0160] Schematic, the second target mapping group contains 501, 502, and 510 (i.e., the first three flash pages of the first target zone store data for flash pages 501, 502, and 510 in the actual physical zone, respectively). When the read address of a read request points to flash page 502, the storage device layer needs to read data from the second target zone of the first storage region because the second write pointer of the second target zone points to flash page 500. Since the read address of the read request matches the second array member in the second target mapping group, the storage device layer reads data from the second flash page of the second target zone in the first storage region.
[0161] In this embodiment, when reading data, the storage device layer determines whether the data to be read has been written into the target zone of the second storage area by comparing the size relationship between the read address and the write pointer of the target zone in the second storage area. If the data has been written into the target zone of the second storage area, the data is read directly from the second storage area. If the data has not been written into the target zone of the second storage area, the data is read from the first storage area, thus ensuring the accuracy of data reading.
[0162] Please refer to Figure 7 The diagram illustrates a system architecture of a data storage system according to an exemplary embodiment of this application. The system includes a file system 701, a block layer 702, and a storage device layer 703.
[0163] The file system 701 is used to send a first write request to the block layer 702;
[0164] The block layer 702 is used to submit the first write request to the first hardware queue of the storage device layer 703 if the first write request contains a priority identifier.
[0165] The block layer 702 is used to write the first write request into a software queue when the first write request does not contain the priority identifier, and to submit the write request in the software queue to the second hardware queue of the storage device layer 703.
[0166] The storage device layer 703 is used to write data to the write requests in the first hardware queue and the second hardware queue.
[0167] Optionally, the storage device layer 703 is configured to write data to the write request in the first hardware queue based on a first priority, and to write data to the write request in the second hardware queue based on a second priority, wherein the first priority is higher than the second priority.
[0168] Optionally, the storage device layer 703 is configured to write data to the write requests in the first hardware queue based on the first priority and write data to the write requests in the second hardware queue based on the second priority when the number of write requests in the second hardware queue does not reach the number threshold and the unservice duration of the second hardware queue does not reach the duration threshold.
[0169] Optionally, the storage device layer 703 is configured to stop writing data to the write requests in the first hardware queue and write data to the write requests in the second hardware queue when the number of write requests in the second hardware queue reaches the number threshold, and / or when the unservice duration of the second hardware queue reaches the duration threshold.
[0170] Optionally, in the case where the address space of the storage device layer is divided into different zones;
[0171] The block layer 702 is used to determine the target second hardware queue mapped by the first target zone based on the first target zone corresponding to the write request, wherein the first target zone is the zone to be written for the write data indicated by the write request;
[0172] The write request is submitted to the target second hardware queue, and the request count corresponding to the first target zone is updated, with the initial value of the request count being 0.
[0173] Optionally, the block layer 702 is configured to, in the absence of the target second hardware queue, determine the second hardware queue corresponding to the processor that triggered the write request as the target second hardware queue mapped by the first target zone, and initialize the request count corresponding to the first target zone.
[0174] Optionally, the block layer 702 is used to update the request count corresponding to the first target zone when the write request processing is completed;
[0175] If the request count corresponding to the updated first target zone is 0, delete the mapping relationship between the first target zone and the target second hardware queue.
[0176] Optionally, the block layer 702 is configured to ignore the zone lock of the first target zone and submit multiple write requests of the first target zone to the target second hardware queue in logical address order when the storage device corresponding to the storage device layer 703 has a preset identifier. The preset identifier is used to characterize that the storage device supports keeping requests in a single hardware queue in order.
[0177] Optionally, the storage device layer 703 is configured to write data to the write request in the first hardware queue in a first storage area, and to write data to the write request in the second hardware queue in a second storage area.
[0178] Optionally, the first storage area is an SLC area, and the second storage area is an MLC area, a TLC area, or a QLC area.
[0179] Optionally, when the address space of the storage device layer is divided into different zones, the storage device layer 703 is used to write data to the write request in the first hardware queue in the first storage region, including:
[0180] Determine the first target zone corresponding to the write request, wherein the first target zone is the zone to which the write data indicated by the write request is to be written;
[0181] Write the write data indicated by the write request to the position indicated by the first write pointer corresponding to the first target zone in the first storage area, and update the first write pointer corresponding to the first target zone;
[0182] Update the first target mapping group corresponding to the first target zone. The first target mapping group is used to characterize the storage location of the data of the data block in the first target zone in the second storage area.
[0183] Optionally, the storage device layer 703 is configured to write the data of the first target zone in the first storage area into the first target zone in the second storage area when the write request is the last write request of the first target zone and the remaining storage space of the first storage area is less than the storage space threshold.
[0184] Optionally, when the address space of the storage device layer is divided into different zones, the storage device layer 703 is used to determine the first target zone corresponding to the write request, wherein the first target zone is the zone to which the write data indicated by the write request is to be written;
[0185] Based on the write address indicated by the write request, read data that is contiguous with the write address from the first storage area;
[0186] The data read from the first storage area and the write data indicated by the write request are merged and written to the position indicated by the second write pointer corresponding to the first target zone in the second storage area, and the second write pointer corresponding to the first target zone is updated.
[0187] Optionally, the storage device layer 703 is used to read data that is continuous with the write address from the first storage area based on the first target mapping group corresponding to the first target zone and the write address indicated by the write request. The first target mapping group is used to characterize the storage location of the data of the data block in the first target zone in the second storage area.
[0188] Optionally, when the address space of the storage device layer is divided into different zones, the storage device layer 703 is used to determine the second target zone corresponding to the read request, wherein the second target zone is the zone where the read data indicated by the read request is located;
[0189] If the read address of the read request is less than the second write pointer of the second target zone in the second storage area, data is read from the second target zone in the second storage area based on the read address;
[0190] If the read address of the read request is greater than the second write pointer of the second target zone in the second storage area, data is read from the second target zone in the first storage area based on the read address.
[0191] Optionally, the storage device layer 703 is used to read data from the second target zone of the first storage area based on the second target mapping group corresponding to the second target zone and the read address, wherein the second target mapping group is used to characterize the storage location of the data of the data block in the second target zone in the second storage area.
[0192] Optionally, the storage device layer 703 is used to determine the size relationship between the read address and the second write pointer of the second target zone in the second storage area when the second target zone is a zone being written to;
[0193] If the second target zone is not the zone being written to, data is read from the second target zone in the second storage area based on the read address.
[0194] Optionally, the write request of the foreground application includes the priority identifier, while the write request of the background application does not include the priority identifier.
[0195] The specific process of data writing and reading in the above data storage system can be referred to the method embodiment, which will not be repeated here.
[0196] Please refer to Figure 8 This illustration shows a structural block diagram of a data writing apparatus provided in an exemplary embodiment of this application. The apparatus includes:
[0197] Processing module 801 is used to send the first write request to the block layer through the file system;
[0198] The processing module 801 is configured to submit the first write request to the first hardware queue of the storage device layer through the block layer when the first write request contains a priority identifier.
[0199] The processing module 801 is configured to write the first write request into a software queue through the block layer when the first write request does not contain the priority identifier, and submit the write request in the software queue to the second hardware queue of the storage device layer.
[0200] Storage module 802 is used to write data to the write requests in the first hardware queue and the second hardware queue through the storage device layer.
[0201] Optional, storage module 802, used for:
[0202] The storage device layer writes data to the write request in the first hardware queue based on a first priority and writes data to the write request in the second hardware queue based on a second priority, wherein the first priority is higher than the second priority.
[0203] Optionally, the storage module 802 is configured to: write data to the write requests in the first hardware queue based on the first priority and write data to the write requests in the second hardware queue based on the second priority when the number of write requests in the second hardware queue does not reach the number threshold and the unservice duration of the second hardware queue does not reach the duration threshold.
[0204] Optional, storage module 802, used for:
[0205] If the number of write requests in the second hardware queue reaches the number threshold, and / or the unservice duration of the second hardware queue reaches the duration threshold, the storage device layer stops writing data to the write requests in the first hardware queue and starts writing data to the write requests in the second hardware queue.
[0206] Optionally, in the case where the address space of the storage device layer is divided into different zones;
[0207] Optionally, processing module 801 is used for:
[0208] The block layer determines the target second hardware queue mapped by the first target zone based on the first target zone corresponding to the write request, wherein the first target zone is the zone to be written to the write data indicated by the write request;
[0209] The write request is submitted to the target second hardware queue through the block layer, and the request count corresponding to the first target zone is updated. The initial value of the request count is 0.
[0210] Optionally, processing module 801 is used for:
[0211] In the absence of the target second hardware queue, the block layer determines the second hardware queue corresponding to the processor that triggered the write request as the target second hardware queue mapped to the first target zone, and initializes the request count corresponding to the first target zone.
[0212] Optionally, processing module 801 is used for:
[0213] Upon completion of the write request processing, the request count corresponding to the first target zone is updated through the block layer;
[0214] If the request count corresponding to the updated first target zone is 0, the mapping relationship between the first target zone and the target second hardware queue is deleted through the block layer.
[0215] Optionally, processing module 801 is used for:
[0216] When the storage device corresponding to the storage device layer has a preset identifier, the block layer ignores the zone lock of the first target zone and submits multiple write requests of the first target zone to the target second hardware queue in logical address order. The preset identifier is used to characterize that the storage device supports keeping requests in a single hardware queue in order.
[0217] Optional, storage module 802, used for:
[0218] The storage device layer writes data to the write request in the first hardware queue in the first storage area, and writes data to the write request in the second hardware queue in the second storage area.
[0219] Optionally, the first storage area is an SLC area, and the second storage area is an MLC area, a TLC area, or a QLC area.
[0220] Optionally, when the address space of the storage device layer is divided into different zones, the storage module 802 is used to:
[0221] The storage device layer determines the first target zone corresponding to the write request, where the first target zone is the zone where the write data indicated by the write request is to be written.
[0222] The write data indicated by the write request is written to the position indicated by the first write pointer corresponding to the first target zone in the first storage area through the storage device layer, and the first write pointer corresponding to the first target zone is updated.
[0223] The storage device layer updates the first target mapping group corresponding to the first target zone, and the first target mapping group is used to characterize the storage location of the data of the data block in the first target zone in the second storage area.
[0224] Optional, storage module 802, used for:
[0225] If the write request is the last write request for the first target zone and the remaining storage space in the first storage area is less than the storage space threshold, the data of the first target zone in the first storage area is written to the first target zone in the second storage area through the storage device layer.
[0226] Optionally, when the address space of the storage device layer is divided into different zones, the storage module 802 is used to:
[0227] The storage device layer determines the first target zone corresponding to the write request, where the first target zone is the zone where the write data indicated by the write request is to be written.
[0228] The storage device layer reads data contiguous to the write address from the first storage area based on the write address indicated by the write request;
[0229] The storage device layer merges the data read from the first storage area and the write data indicated by the write request, and writes it to the position indicated by the second write pointer corresponding to the first target zone in the second storage area, and updates the second write pointer corresponding to the first target zone.
[0230] Optional, storage module 802, used for:
[0231] The storage device layer reads data contiguous to the write address from the first storage area based on the first target mapping group corresponding to the first target zone and the write address indicated by the write request. The first target mapping group is used to characterize the storage location of the data block in the first target zone in the second storage area.
[0232] Optionally, when the address space of the storage device layer is divided into different zones, the storage module 802 is used to:
[0233] The storage device layer determines the second target zone corresponding to the read request, where the second target zone is the zone where the read data indicated by the read request is located;
[0234] If the read address of the read request is less than the second write pointer of the second target zone in the second storage area, data is read from the second target zone in the second storage area through the storage device layer based on the read address;
[0235] If the read address of the read request is greater than the second write pointer of the second target zone in the second storage area, data is read from the second target zone in the first storage area through the storage device layer based on the read address.
[0236] Optional, storage module 802, used for:
[0237] The storage device layer reads data from the second target zone of the first storage area based on the second target mapping group corresponding to the second target zone and the read address. The second target mapping group is used to characterize the storage location of the data block in the second target zone in the second storage area.
[0238] Optional, storage module 802, used for:
[0239] When the second target zone is a zone that is being written to, the relationship between the read address and the size of the second write pointer of the second target zone in the second storage area is determined by the storage device layer;
[0240] If the second target zone is not the zone being written to, data is read from the second target zone of the second storage area through the storage device layer based on the read address.
[0241] Optionally, the write request of the foreground application includes the priority identifier, while the write request of the background application does not include the priority identifier.
[0242] In summary, in this embodiment, priority identifiers can be added to write requests. After the block layer recognizes the priority identifier, it directly submits the write request to the first hardware queue of the storage device layer. This simplifies the process of writing to the software queue first and then submitting to the second hardware queue, which helps improve the processing efficiency of write requests and increases the writing speed of data that needs to be written first. For example, priority identifiers can be added to write requests of foreground tasks to improve the data writing speed of foreground tasks and avoid the impact of background tasks competing for storage resources on the running quality of foreground tasks.
[0243] It should be noted that the apparatus provided in the above embodiments is only an example of the division of the above functional modules. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the apparatus can be divided into different functional modules to complete all or part of the functions described above. In addition, the apparatus and method embodiments provided in the above embodiments belong to the same concept, and their implementation process can be found in the method embodiments, which will not be repeated here.
[0244] See Figure 9 , Figure 9 This is a structural block diagram of a computer device provided in an exemplary embodiment of this application. The computer device may include one or more components such as a processor 910 and a memory 920.
[0245] Optionally, the processor 910 connects various parts within the electronic device using various interfaces and lines, and performs various functions and processes data by running or executing instructions, programs, code sets, or instruction sets stored in the memory 920, and by calling data stored in the memory 920. Optionally, the processor 910 can be implemented in at least one hardware form selected from Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), and Programmable Logic Array (PLA).
[0246] The processor 910 can integrate one or more of the following: a central processing unit (CPU), a graphics processing unit (GPU), a neural network processing unit (NPU), and a baseband chip. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the content displayed on the touchscreen; the NPU implements artificial intelligence (AI) functions; and the baseband chip handles wireless communication. It is understood that the baseband chip can also be implemented as a separate chip without being integrated into the processor 910.
[0247] The memory 920 may include random access memory (RAM) or read-only memory (ROM). Optionally, the memory 920 may include a non-transitory computer-readable storage medium. The memory 920 may be used to store instructions, programs, code, code sets, or instruction sets. The memory 920 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function, instructions for implementing the various method embodiments described above, etc.; the data storage area may store data created according to the use of the electronic device, etc.
[0248] In addition, those skilled in the art will understand that the structure of the computer device shown in the above figures does not constitute a limitation on the computer device. The computer device may include more (e.g., display components, touch components, power supply components, sensor components) or fewer components than shown, or combine certain components, or have different component arrangements.
[0249] This application provides a computer-readable storage medium storing at least one computer instruction, which is executed by a processor to implement the data writing method as described in the above embodiments.
[0250] On the other hand, embodiments of this application provide a computer program product, the computer program product including computer instructions stored in a computer-readable storage medium; a processor reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions to implement the data writing method as described in the above embodiments.
[0251] Those skilled in the art will recognize that the functions described in the embodiments of this application in one or more of the above examples can be implemented using hardware, software, firmware, or any combination thereof. When implemented using software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or code on a computer-readable medium. Computer-readable media include computer storage media and communication media, wherein communication media include any medium that facilitates the transfer of a computer program from one place to another. Storage media can be any available medium that can be accessed by a general-purpose or special-purpose computer.
[0252] The above description is merely an optional embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A data writing method, characterized in that, The method includes: The file system sends the first write request to the block layer; If the first write request contains a priority identifier, the block layer submits the first write request to the first hardware queue of the storage device layer; If the first write request does not contain the priority identifier, the block layer writes the first write request to the software queue and submits the write requests in the software queue to the second hardware queue of the storage device layer. The storage device layer writes data to the write requests in the first hardware queue and the second hardware queue.
2. The method according to claim 1, characterized in that, The storage device layer writes data to the write requests in the first hardware queue and the second hardware queue, including: The storage device layer writes data to the write request in the first hardware queue based on a first priority, and writes data to the write request in the second hardware queue based on a second priority, wherein the first priority is higher than the second priority.
3. The method according to claim 2, characterized in that, The storage device layer writes data to the write requests in the first hardware queue based on a first priority, and writes data to the write requests in the second hardware queue based on a second priority, including: If the number of write requests in the second hardware queue does not reach the quantity threshold and the unservice duration of the second hardware queue does not reach the duration threshold, the storage device layer writes data to the write requests in the first hardware queue based on the first priority and writes data to the write requests in the second hardware queue based on the second priority.
4. The method according to claim 3, characterized in that, The storage device layer performs data writing on the write requests in the first hardware queue and the second hardware queue, and further includes: If the number of write requests in the second hardware queue reaches the number threshold, and / or the unservice duration of the second hardware queue reaches the duration threshold, the storage device layer stops writing data to the write requests in the first hardware queue and starts writing data to the write requests in the second hardware queue.
5. The method according to claim 1, characterized in that, When the address space of the storage device layer is divided into different zones; The block layer submits write requests from the software queue to the second hardware queue of the storage device layer, including: The block layer determines the target second hardware queue mapped by the first target zone based on the first target zone corresponding to the write request, wherein the first target zone is the zone to be written to the write data indicated by the write request; The block layer submits the write request to the target second hardware queue and updates the request count corresponding to the first target zone, with the initial value of the request count being 0.
6. The method according to claim 5, characterized in that, The block layer submits write requests from the software queue to the second hardware queue of the storage device layer, and further includes: In the absence of the target second hardware queue, the second hardware queue corresponding to the processor that triggered the write request is determined as the target second hardware queue mapped to the first target zone, and the request count corresponding to the first target zone is initialized.
7. The method according to claim 5, characterized in that, The method further includes: Upon completion of the write request processing, the block layer updates the request count corresponding to the first target zone; If the request count corresponding to the updated first target zone is 0, the block layer deletes the mapping relationship between the first target zone and the target second hardware queue.
8. The method according to claim 5, characterized in that, The block layer submits the write request to the target second hardware queue, including: When the storage device corresponding to the storage device layer has a preset identifier, the block layer ignores the zone lock of the first target zone and submits multiple write requests of the first target zone to the target second hardware queue in logical address order. The preset identifier is used to characterize that the storage device supports keeping requests in a single hardware queue in order.
9. The method according to claim 1, characterized in that, The storage device layer writes data to the write requests in the first hardware queue and the second hardware queue, including: The storage device layer writes data to the write request in the first hardware queue in the first storage area, and writes data to the write request in the second hardware queue in the second storage area.
10. The method according to claim 9, characterized in that, The first storage area is an SLC area, and the second storage area is an MLC area, a TLC area, or a QLC area.
11. The method according to claim 9, characterized in that, When the address space of the storage device layer is divided into different zones; The storage device layer writes data to the write request in the first hardware queue in the first storage area, including: The storage device layer determines a first target zone corresponding to the write request, whereby the first target zone is the zone to which the write data indicated by the write request is to be written. The storage device layer writes the write data indicated by the write request to the position indicated by the first write pointer corresponding to the first target zone in the first storage area, and updates the first write pointer corresponding to the first target zone. The storage device layer updates the first target mapping group corresponding to the first target zone, and the first target mapping group is used to characterize the storage location of the data of the data block in the first target zone in the second storage area.
12. The method according to claim 11, characterized in that, The method further includes: If the write request is the last write request for the first target zone and the remaining storage space in the first storage area is less than the storage space threshold, the storage device layer writes the data of the first target zone in the first storage area to the first target zone in the second storage area.
13. The method according to claim 9, characterized in that, When the address space at the storage device layer is divided into different zones; The storage device layer writes data to the write request in the second hardware queue in the second storage area, including: The storage device layer determines a first target zone corresponding to the write request, whereby the first target zone is the zone to which the write data indicated by the write request is to be written. The storage device layer reads data that is contiguous with the write address from the first storage area based on the write address indicated by the write request; The storage device layer merges the data read from the first storage area and the write data indicated by the write request, writes it to the position indicated by the second write pointer corresponding to the first target zone in the second storage area, and updates the second write pointer corresponding to the first target zone.
14. The method according to claim 13, characterized in that, The storage device layer reads data contiguous to the write address from the first storage area based on the write address indicated by the write request, including: The storage device layer reads data that is contiguous with the write address from the first storage area based on the first target mapping group corresponding to the first target zone and the write address indicated by the write request. The first target mapping group is used to characterize the storage location of the data block in the first target zone in the second storage area.
15. The method according to claim 9, characterized in that, When the address space of the storage device layer is divided into different zones; The method further includes: The storage device layer determines a second target zone corresponding to the read request, whereby the second target zone is the zone where the read data indicated by the read request is located. If the read address of the read request is less than the second write pointer of the second target zone in the second storage area, the storage device layer reads data from the second target zone in the second storage area based on the read address; If the read address of the read request is greater than the second write pointer of the second target zone in the second storage area, the storage device layer reads data from the second target zone in the first storage area based on the read address.
16. The method according to claim 15, characterized in that, The storage device layer reads data from the second target zone of the first storage region based on the read address, including: The storage device layer reads data from the second target zone of the first storage area based on the second target mapping group corresponding to the second target zone and the read address. The second target mapping group is used to characterize the storage location of the data block in the second target zone in the second storage area.
17. The method according to claim 15, characterized in that, The method further includes: If the second target zone is a zone that is being written to, determine the relationship between the read address and the size of the second write pointer of the second target zone in the second storage area; If the second target zone is not the zone being written to, the storage device layer reads data from the second target zone of the second storage area based on the read address.
18. The method according to claim 1, characterized in that, The write request of the foreground application includes the priority identifier, while the write request of the background application does not include the priority identifier.
19. A data writing device, characterized in that, The device includes: The processing module is used to send the first write request to the block layer through the file system; The processing module is configured to submit the first write request to the first hardware queue of the storage device layer through the block layer if the first write request contains a priority identifier. The processing module is configured to write the first write request into a software queue through the block layer when the first write request does not contain the priority identifier, and submit the write request in the software queue to the second hardware queue of the storage device layer. The storage module is used to write data to the write requests in the first hardware queue and the second hardware queue through the storage device layer.
20. A data storage system, characterized in that, The system includes: a file system, a block layer, and a storage device layer; The file system is used to send a first write request to the block layer; The block layer is configured to submit the first write request to the first hardware queue of the storage device layer if the first write request contains a priority identifier. The block layer is configured to write the first write request into a software queue if the first write request does not contain the priority identifier, and submit the write request in the software queue to the second hardware queue of the storage device layer. The storage device layer is used to write data to the write requests in the first hardware queue and the second hardware queue.
21. A computer device, characterized in that, The computer device includes a processor and a memory, the memory storing at least one computer instruction, the at least one computer instruction being loaded and executed by the processor to implement the data writing method as described in any one of claims 1 to 18.
22. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores at least one computer instruction, which is executed by a processor to implement the data writing method as described in any one of claims 1 to 18.
23. A computer program product, characterized in that, The computer program product includes computer instructions stored in a computer-readable storage medium; a processor reads the computer instructions from the computer-readable storage medium and executes the computer instructions to implement the data writing method as described in any one of claims 1 to 18.
