A method of releasing data blocks and a storage device

By configuring the write allocation unit to align with the super data block, detecting write commands and releasing them in real time, the problem of insufficient storage space in storage devices during high-intensity writes is solved, achieving efficient data block release and stable write performance.

CN120371546BActive Publication Date: 2025-11-25BIWIN STORAGE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510873500.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-27
Publication Date
2025-11-25
Estimated Expiration
2045-06-27

AI Technical Summary

Technical Problem

When existing storage devices are subjected to high-intensity data writing, the garbage collection mechanism cannot meet the writing demand, resulting in a reduction in the number of available blocks in the memory card, triggering the write protection mechanism, and interrupting video recording.

Method used

By configuring the write allocation unit size to align with the super data block capacity, the system detects whether a write command is a rewrite command, performs targeted rewrite processing, and immediately releases invalid data blocks, thereby reducing the frequency of garbage collection mechanism activation.

Benefits of technology

Ensure that each super data block can be completely released through the write mechanism, reduce storage fragmentation, improve write performance and release efficiency, and avoid triggering the write protection mechanism.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120371546B_ABST
    Figure CN120371546B_ABST
Patent Text Reader

Abstract

The application discloses a method for releasing data blocks and a storage device. The method comprises the following steps: obtaining the capacity size of a super data block in the storage device, and configuring the size of a write allocation unit as the capacity size of the super data block; receiving a write command of a host, and detecting whether the write command belongs to a rewrite command; if yes, performing a rewrite process on the super data block according to current write data in the write command, to obtain an invalid data block, and performing a release process on the invalid data block. The application can release all super data blocks through a rewrite mechanism, so that the starting frequency of a garbage collection mechanism is reduced, and a write protection mechanism is avoided from being triggered.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of storage, and in particular to a method for releasing data blocks and a storage device. BACKGROUND

[0002] In the field of high-resolution video recording, storage devices need to have high sustained write speeds to meet the needs of high-quality video recording. The VPG 400 (Video Performance Guarantee) standard is used to specify the minimum sustained write speed that a memory card needs to achieve when recording high-resolution video. This standard requires that the storage device can guarantee a sustained write speed of at least 400 MB / s when recording video. This speed standard can meet the needs of high-quality video recording and ensure that there is no data write bottleneck during recording.

[0003] The storage space of a storage device is composed of multiple super blocks. In order to meet the write requirements of the above standard, the storage device needs to continuously provide available super blocks for data writing. However, the write performance of the existing storage card is limited by its storage space management mechanism. During data writing and deletion, the storage device will generate invalid data blocks, which need to be released through garbage collection (GC) or rewriting mechanism to provide available storage space for data writing. Although the release speed of the rewriting mechanism is better than that of the GC mechanism, not all super blocks can be released through the rewriting mechanism. For this part of the data block, only the GC mechanism can be used for release. However, when the host continuously writes data at high intensity, the efficiency of garbage collection may not meet the needs of data writing. If the speed of garbage collection cannot keep up with the speed of host writing, the number of available blocks inside the storage card will gradually decrease, eventually causing the storage card to be unable to continue receiving new write data, thereby triggering the write protection mechanism and interrupting the video recording process. SUMMARY

[0004] The technical problem to be solved by the present application is to provide a method for releasing data blocks and a storage device, which can release all super blocks through the rewriting mechanism to reduce the frequency of starting the garbage collection mechanism, thereby avoiding triggering the write protection mechanism.

[0005] To solve the above technical problems, one technical solution adopted by the present application is:

[0006] A method for releasing data blocks, comprising:

[0007] obtaining the capacity size of the super blocks in the storage device;

[0008] The size of the write allocation unit is configured as the capacity size of the super data block;

[0009] The write command of the host is received, and it is detected whether the write command belongs to a rewrite command;

[0010] If yes, the super data block is rewritten according to the current write data in the write command based on the write allocation unit to obtain an invalid data block, and the invalid data block is released.

[0011] To solve the above technical problems, another technical solution adopted by the present application is:

[0012] A storage device includes a control chip and a storage chip, the storage chip stores a computer program, and the computer program is executed by the control chip to realize each step of the above-mentioned data block release method.

[0013] The beneficial effects of the present application are that: since the rewrite mechanism invalidates data according to the write allocation unit (a continuous area composed of the minimum unit of multiple write commands), and a super data block may store data of multiple write allocation units, if only the data of one write allocation unit is invalidated, the entire super data block cannot be completely released. Therefore, the size of the write allocation unit is configured as the capacity size of the super data block, the write allocation unit and the super data block are spatially aligned, so that the data of one write allocation unit can completely occupy the entire data block space. When receiving the write command of the host, it is detected whether the write command belongs to a rewrite command, and the invalid data block obtained after the rewrite is released immediately. The present application aligns the write allocation unit and the super data block in space, so that the data of one write allocation unit can completely occupy the entire data block space, avoiding the fragmentation problem caused by cross-block storage, thereby ensuring that the rewrite mechanism can completely release a super data block when releasing a data block, and further ensuring that each data block can be released through rewriting, reducing the frequency of starting the garbage collection mechanism, and avoiding triggering the write protection mechanism. BRIEF DESCRIPTION OF DRAWINGS

[0014] Figure 1 A distribution diagram of a write allocation unit in a super data block is provided for the prior art;

[0015] Figure 2 Another distribution diagram of a write allocation unit in a super data block is provided for the prior art;

[0016] Figure 3 A flowchart of a data block release method provided by the present application is provided;

[0017] Figure 4A schematic diagram of a storage structure provided by the present invention;

[0018] Figure 5 A schematic diagram of the distribution of write allocation units in a super data block provided by the present invention;

[0019] Figure 6 A schematic diagram of the distribution of copy data provided by the present invention;

[0020] Figure 7 This invention provides another schematic diagram of the distribution of copy data;

[0021] Figure 8 A schematic diagram of the distribution of write allocation units in a super data block provided by the present invention;

[0022] Figure 9 A schematic diagram illustrating the distribution of another write allocation unit in a super data block, provided by the present invention.

[0023] Figure 10 This is a schematic diagram of the structure of a storage device provided by the present invention. Detailed Implementation

[0024] To explain in detail the technical content, objectives, and effects of the present invention, the following description is provided in conjunction with the embodiments and accompanying drawings.

[0025] Embodiments of the present invention provide a method for releasing a data block, comprising:

[0026] Get the size of the super block in the storage device;

[0027] Configure the size of the write allocation unit to the capacity size of the super data block;

[0028] Receive a write command from the host and detect whether the write command is a rewrite command;

[0029] If so, the super data block is overwritten according to the current write data issued by the write allocation unit in the write command to obtain an invalid data block, and the invalid data block is released.

[0030] As described above, the beneficial effects of this invention are as follows: Since the overwrite mechanism invalidates data according to the write allocation unit, and a super data block may store data from multiple write allocation units, invalidating only the data of one write allocation unit will not completely release the entire super data block. Therefore, configuring the size of the write allocation unit to the capacity of the super data block achieves spatial alignment between the write allocation unit and the super data block, allowing the data of one write allocation unit to completely occupy the entire data block space. When a write command is received from the host, by detecting whether the write command is an overwrite command, an immediate release mechanism is applied to the invalidated data blocks obtained after the overwrite process. This invention, by aligning the space of the write allocation unit and the super data block, ensures that the data of one write allocation unit can completely occupy the entire data block space, avoiding the fragmentation problem caused by cross-block storage. This ensures that the overwrite mechanism can completely release a super data block when releasing a data block, thereby ensuring that each data block can be released through overwrite, reducing the frequency of garbage collection and avoiding triggering the write protection mechanism.

[0031] Furthermore, obtaining the capacity of the super data block in the storage device includes:

[0032] Obtain the device model of the storage device;

[0033] The storage structure of the storage device is determined based on the device model.

[0034] The capacity of the super data block used to store user data is determined based on the storage structure.

[0035] As described above, the method involves obtaining the device model of the storage device, determining its storage structure, and then accurately determining the capacity of the super block used to store user data based on this storage structure. This provides accurate basic data for subsequent spatial alignment of the write allocation unit with the super block, ensuring that the write allocation unit can fully occupy the entire super block space.

[0036] Furthermore, configuring the size of the write allocation unit to the capacity size of the super data block includes:

[0037] Get multiple configurable parameters for the size of the write allocation unit;

[0038] Determine a target configuration parameter among the plurality of configurable parameters that is smaller than the capacity size and whose difference from the capacity size is less than a preset value;

[0039] Configure the size of the write allocation unit as the target configuration parameter.

[0040] As described above, by obtaining the configurable parameters of the write allocation unit, a configuration baseline for different storage device types is determined. In practice, the size of the write allocation unit can only be configured with predefined parameters, thus limiting the choice of write allocation unit size and making it impossible to completely match the size of the superblock. Therefore, when configuring the size of the write allocation unit, a configurable parameter smaller than and closest to the block size is selected as the target configuration parameter, making the size of the write allocation unit as close as possible to the size of a superblock. This ensures that write performance meets industry standards while minimizing storage space fragmentation caused by the mismatch between the write allocation unit and the block size.

[0041] Further, obtain the historical logical block address of the historical write command received before the write command;

[0042] Detect whether the current logical block address of the write command is the same as the historical logical block address;

[0043] If so, then the write command is determined to be a rewrite command;

[0044] Otherwise, it is determined that the write command is not a rewrite command.

[0045] As described above, a logical block address refers to the logical address used by the operating system and applications when accessing storage devices. Each time the host issues a write command, it carries the logical block address. If the current write command and a previous write command complete the data write operation using the same logical block address, it indicates that the current write command is a rewrite command; that is, the purpose of the current write command is to rewrite and release the data block from the previous write command. This mechanism can quickly determine whether the current write command is for writing or releasing a data block.

[0046] Furthermore, the invalid data block obtained by overwriting the super data block based on the current write data issued by the write allocation unit in the write command includes:

[0047] The current write data issued by the write allocation unit in the write command is written into the free data block in the super data block to obtain a valid data block;

[0048] The mapping entry of the current logical block address is updated to the valid data block, so that the original data block mapped by the mapping entry before the update is invalidated to obtain an invalid data block.

[0049] As described above, to release a data block written in the past, the data in that block must first be overwritten to other data blocks. After overwriting, the mapping entry of the logical block address will inevitably be updated to the data block written later, making the previously written data block invalid, thus realizing the release of the data block.

[0050] Furthermore, writing the current write data issued by the write allocation unit into the free data block in the super data block to obtain a valid data block includes:

[0051] The target write data is obtained by writing the current write data issued by the write allocation unit in the write command to a preset cache. The preset cache only allows the current write data of the size of one write allocation unit to be written.

[0052] After the target write data in the preset cache is completely written into the free data block, it is detected whether there are any free data pages in the free data block;

[0053] If so, then the write completion marker is filled into the end of the target write data to obtain a valid data block.

[0054] As described above, firstly, by limiting the amount of data that the preset cache can accept to a single write allocation unit, the data size of each cache operation strictly corresponds to the smallest management unit of the storage device, thus avoiding the data fragmentation problem caused by cross-unit writing at the physical level; secondly, after completing the overall migration of cached data to free data blocks, by detecting the physical storage status of free data pages, a write completion marker is appended to the end of the data. This marker is used to determine that the current data block has finished writing, thus serving as a physical identifier of the valid data block boundary, effectively preventing cross-block storage caused by subsequent accidental data overlay writing.

[0055] Furthermore, filling the end of the target written data with a write completion marker to obtain a valid data block includes:

[0056] Detect whether the current data page in the free data block where the target data is being written is completely filled;

[0057] If so, the write completion marker is filled into the next free data page following the current data page to obtain a valid data block;

[0058] Otherwise, the write completion marker is filled into the blank address of the current data page where the target write data has not been written and the next free data page after the current data page to obtain a valid data block.

[0059] As described above, the process first checks whether the data page containing the target data is completely filled. If it is, a marker is added to the subsequent free data page. This process uses the write completion marker to form a clear block termination identifier. When a data page is not full, markers are added to both the current page's blank address and the next page. Adding a marker to the current page's blank address isolates the free data page from the data page containing the target data but not yet filled. Adding a marker to the next page forms a clear block termination identifier, preventing subsequent data from being written to the free data pages of this data block. This ensures that a super data block can only be written to one write allocation unit, effectively solving the problem in traditional overwrite methods where the entire super data block cannot be completely released due to data containing multiple write allocation units.

[0060] Furthermore, it also includes:

[0061] If the valid data block is marked as the target block for garbage collection, then the data page in the valid data block that has the write completion mark is marked as a stop data page.

[0062] If the stopped data page is read during data transfer of the target block to be recycled, the garbage collection operation is terminated.

[0063] As described above, when a valid data block is selected as the target block for garbage collection, the presence of a write-complete marker indicates that the content following that data page is a blank page, meaning it requires no further processing. Therefore, marking the stop data page directly identifies the boundary of data validity. During the data movement process of garbage collection, once a stop data page is read, it means that subsequent pages do not need further processing, thus immediately ending the garbage collection operation. This mechanism reduces unnecessary data movement, improves the release efficiency of the garbage collection mechanism, and ensures that under high-intensity continuous write scenarios, the garbage collection mechanism can quickly release space to maintain the continuous write capability of the storage device.

[0064] Furthermore, it also includes:

[0065] If a write interruption request is received when writing the current write data issued by the write allocation unit in the write command to the preset cache, then when the next write command from the host is received, it is detected whether the next write data issued by the write allocation unit in the next write command and the current write data already written to the preset cache are consecutive writes.

[0066] If so, the next write data is written to the preset cache to obtain the target write data, and the step of detecting whether there is a free data page in the free data block after the target write data in the preset cache is completely written to the free data block is executed;

[0067] Otherwise, the currently written data already written to the preset cache is used as the target written data, and the step of detecting whether there are any free data pages in the free data block after the target written data in the preset cache is completely written to the free data block is executed.

[0068] As described above, when a write interruption occurs, the preset cache has not yet fully written a write allocation unit of data. Therefore, by detecting the write correlation between the next write data and the cached data, two processing paths are distinguished: if the next write data and the cached data are written consecutively, the next write data is appended to the cache to form a complete data unit, avoiding data fragmentation caused by the interruption; if the next write data and the cached data are not written consecutively, it means that the next write data is new data, so the current cached data is directly committed to the data block and a marker is filled, so that the current cached data and the next write data can be written to different data blocks, thereby isolating the current cached data and the next write data. This processing mechanism not only ensures that each super data block stores only one write allocation unit of data, but also effectively solves the data continuity management problem in interrupt recovery scenarios.

[0069] Furthermore, it also includes:

[0070] If the write command is not a rewrite command, the current write data is written to a free data block in the super data block to obtain a valid data block, and the current logical block address is mapped to the valid data block to obtain a mapping table entry.

[0071] As described above, if the write command is not a rewrite command, it indicates that the current write command is for writing a data block. Therefore, after writing the data to the free data block and recording the mapping relationship of the logical block address, there is no need to invalidate the data block, thus ensuring the normal writing function of the data block. Simultaneously, since the current write data is issued based on the write allocation unit, the data written to a free data block only includes the data of one write allocation unit. This minimizes storage space fragmentation caused by the mismatch between the write allocation unit and the data block size, facilitating the subsequent release of the data block.

[0072] Another embodiment of the present invention provides a storage device including a control chip and a storage chip, the storage chip storing a computer program, which, when executed by the control chip, implements the steps of the above-described method for releasing a data block.

[0073] The method and storage device for releasing data blocks described above are applicable to storage devices requiring high-performance writing. When a host (which can be a video recording device) performs a high-speed write (i.e., enters VPG mode), it distributes data in units of pre-configured Write Allocation Units (AUs). Therefore, the write operation in the super block of the storage device is completed in units of AUs. Based on this, in existing storage devices, if the super block is released through a rewrite mechanism, the following two rewrite release scenarios will occur based on the distribution of AUs in the super block: The first scenario, such as... Figure 1 As shown, multiple AUs simultaneously occupy a single super block. In this case, simply overwriting the data of one AU is insufficient to completely release the super block. For example, if AU 0 is overwritten, its data becomes invalid, but since AU1 and AU2 remain valid, super block A cannot be released. The second scenario... Figure 2 As shown, an AU occupies multiple super blocks. In this case, some super blocks may not be completely released. For example, when AU 0 is overwritten, super block A, which is completely occupied by AU 0 data, will be completely released, while AU 1 data in super block B remains valid, so super block B cannot be released. When AU 1 or AU 3 is overwritten, both super block B and super block C cannot be released because there is valid data in other AUs. Therefore, existing overwrite mechanisms cannot release super data blocks containing data from multiple write allocation units in a single overwrite. Such super data blocks can only be released through data migration via garbage collection, but garbage collection requires data migration, and its data block release speed cannot keep up with the data block usage speed in high-speed write mode, resulting in no free data blocks available in the storage device, thus triggering write protection and affecting host usage. Therefore, this invention provides a method and storage device for releasing data blocks, which can release all super data blocks through an overwrite mechanism, thereby reducing the frequency of garbage collection and avoiding triggering write protection. The following describes specific implementation methods:

[0074] Please refer to Figures 3 to 7 Embodiment 1 of the present invention is as follows:

[0075] like Figure 3 As shown, a method for releasing a data block specifically includes the following S1-S4:

[0076] S1. Obtain the size of the super data block in the storage device. Specifically, step S1 only obtains the size of one super data block.

[0077] Specifically, S1 involves: obtaining the device model of the storage device, determining the storage structure based on the device model, and determining the capacity of the super block used to store user data based on the storage structure. For example, taking the YMTC X3 9070 512GB (a model number of a 3D NAND flash memory product) as an example... Figure 4 As shown, the storage structure of this product is as follows: a super block contains 1392 SLC super pages, each super page contains 4 dies, each die contains 6 planes, each plane stores 16KB of data, and one plane out of the 6 super pages stores RAID data. Figure 4 In the diagram, "P" represents "plane," and the shaded area represents the RAID (Redundant Array of Independent Disks) data stored therein. Therefore, the capacity of one superblock is 1392 × 4 × 6 × 16 KB = 534528 KB. Of this, the RAID space occupies 1392 / 6 × 16 KB = 2712 KB. Thus, the actual usable capacity for storing user data is 531816 KB, equivalent to 519.351 MB. This means that one superblock in this product can store 519.351 MB of user data.

[0078] S2. Configure the size of the write allocation unit to the capacity of the super data block.

[0079] It should be noted that the size of the write allocation unit is configured through the firmware. After the size of the write allocation unit is configured in the firmware, the firmware is uploaded to the host, thus completing S2. Once the firmware configuration is complete, the size of the write allocation unit cannot be changed or modified again.

[0080] Ideally, if the size of the write allocation unit is configured to be the size of the super data block, the storage situation of the data block is as follows: Figure 5As shown, one AU occupies one super block. In this case, simply overwriting the data of one AU can completely free up a super block. For example, if AU 0 is overwritten, the data in AU 0 is invalidated, and since super block A does not store any other valid data, super block A can be freed. However, in practice, there are limitations on the size of the write allocation unit, which cannot be exactly the same as the capacity of the super block. Therefore, the write allocation unit needs to be approximately the size of a super block.

[0081] Specifically, S2 includes the following S21-S23:

[0082] S21. Obtain multiple configurable parameters for the size of the write allocation unit.

[0083] In some embodiments, configurable parameters of the write allocation unit are described in the storage device write performance standard.

[0084] S22. Determine the target configuration parameter among the plurality of configurable parameters that is smaller than the capacity size and whose difference from the capacity size is less than a preset value.

[0085] S23. Configure the size of the write allocation unit as the target configuration parameter.

[0086] In some embodiments, the preset value is 10% of the super block size. For example, if the super block size is 519.351 MB, the preset value is 51.9351 MB.

[0087] Applying step S2 to a specific scenario, the storage device write performance standard is specifically the VPG standard. The VPG standard specifies configurable parameters for write allocation units as 128MB, 256MB, and 512MB. Based on this, if the size of a superblock obtained in S1 is 519.351MB, then the target configuration parameter among the configurable parameters that is less than 519.351MB and whose difference from 519.351MB is less than 51.9351 is 512MB. Therefore, the write allocation unit size is configured to 512MB.

[0088] S3. Receive the write command from the host and detect whether the write command is a rewrite command.

[0089] It should be noted that the smallest unit of a single write command from the host is a RU, while an AU is a contiguous region composed of multiple smallest units (RUs). In VPG mode, the host issues write commands in units of pre-configured AUs.

[0090] Specifically, detecting whether the write command is a rewrite command in S3 includes:

[0091] S31. Obtain the address of the historical logical block of the historical write command received before the write command.

[0092] S32. Detect whether the current logical block address of the write command is the same as the historical logical block address. If so, determine that the write command is a rewrite command; otherwise, determine that the write command is not a rewrite command.

[0093] It's important to note that each write command issued by the host carries an LBA (Logical Block Address). If two consecutive write commands issued by the host have the same LBA, it indicates that the data corresponding to that LBA will be overwritten. After each data block is written, the FTL (Flash Translation Layer) creates an entry based on the LBA and the physical location to be written. For example... Figure 6 As shown, assuming data from LBA 0-100 is written to super Block A, the entry in the table points to super Block A. If data from LBA 0-100 is subsequently written to super Block B, then the entry for super Block A will point to super Block B. Therefore, when detecting whether a write command is a rewrite command, it is only necessary to check whether the LBA entry maps to a specific data block to determine if the LBA is consistent with the previous write command.

[0094] S4. If so, the super data block is overwritten according to the current write data issued by the write allocation unit in the write command to obtain an invalid data block, and the invalid data block is released.

[0095] Specifically, S4 includes the following S41-S42:

[0096] S41. Write the current write data issued by the write allocation unit in the write command into the free data block in the super data block to obtain a valid data block.

[0097] S42. Update the mapping entry of the current logical block address to the valid data block, so that the original data block mapped by the mapping entry before the update is invalidated to obtain an invalid data block.

[0098] The method also includes:

[0099] S5. If the write command is not a rewrite command, the current write data is written to the free data block in the super data block to obtain a valid data block, and the current logical block address is mapped to the valid data block to obtain a mapping table entry.

[0100] Applying steps S4 and S5 to a specific scenario, such as... Figure 7 As shown, the host first issues a write command. The logical block address range of the first write command is LBA0-100. Data in the LBA0-100 range is written to the free super block A, and the entries in the LBA0-100 table point to super block A. The host then issues a second write command. The logical block address range of the second write command is LBA100-200. Data in the LBA100-200 range is written to the free super block B, and the entries in the LBA100-200 table point to super block B. Similarly, when writing to the free super block N, the host issues the Nth write command. The logical block address range of the Nth write command is LBA0-100. At this time, the logical block address of the Nth write command is the same as that of the first write command. However, when the Nth write command is executed, since super block A has already been written and is no longer a free data block, and subsequent writes must be to data blocks that have already been erased, the data in the LBA0-100 range is written to the free super block N. The entries in LBA0-100 change from super block A to super block N, and the data in super block A is invalidated, meaning super block A is an invalid data block. Invalid data blocks can be released and reused. In this scenario, the Nth write command is a write-overload command, while the first and second write commands are not write-overload commands.

[0101] To more intuitively understand the difference in effectiveness between the data block release method of the present invention and the existing data block release method in practical applications, four rounds of experiments were conducted to obtain statistical data on the number of data blocks released under garbage collection and overwrite mechanisms, as shown in Table 1.

[0102] Table 1 Statistics on the number of data blocks released

[0103]

[0104] As shown in Table 1, when the total number of data blocks released is roughly the same, existing data block release methods result in a significantly higher proportion of data blocks released under garbage collection because some data blocks cannot be released through the overwrite mechanism. In contrast, the data block release method of this invention releases a significantly higher proportion of data blocks released under the overwrite mechanism than existing methods. This means that the release of certain data blocks can be achieved without relying on garbage collection, reducing the frequency of garbage collection activation and greatly simplifying the data block release process, thus effectively improving the efficiency of data block release.

[0105] Please refer to Figure 8 Embodiment two of the present invention is as follows:

[0106] A method for releasing data blocks differs from Embodiment 1 in that it specifies the specific implementation of step S41. Since in real-world scenarios, the size of a super data block is larger than the size of a write allocation unit, after the data in a write allocation unit is completely written, some space will remain in the super data block. To ensure that a super data block is only written to the data of one write allocation unit, special padding is required for the remaining space after the data in one write allocation unit is written, thereby preventing other data from being written to the remaining space.

[0107] Specifically, S41 includes S411-S413:

[0108] S411. Write the current write data issued by the write allocation unit in the write command to a preset cache to obtain the target write data. The preset cache only allows the current write data of the size of one write allocation unit to be written.

[0109] In some embodiments, data sent by the host is first stored in a preset cache. In a specific application scenario, if the preset cache currently contains data of AU 0, when a new write command of AU 1 is received from the host, the write command of AU 1 will be temporarily suspended. The data of AU 1 can only be stored after the data of AU 0 in the preset cache has been flushed. This ensures that the preset cache only writes the current write data of the size of a write allocation unit.

[0110] S412. After the target write data in the preset cache is completely written into the free data block, detect whether there is a free data page in the free data block.

[0111] S413. If so, then fill the write completion mark to the end of the target write data to obtain a valid data block.

[0112] Specifically, step S413 includes the following S4131-S4133:

[0113] S4131. Detect whether the current data page in the free data block where the target data is written is completely filled.

[0114] S4132. If so, the write completion marker is filled into the next free data page after the current data page to obtain a valid data block;

[0115] S4133. Otherwise, the write completion marker is filled into the blank address of the current data page where the target write data has not been written and the next free data page after the current data page to obtain a valid data block.

[0116] Applying steps S412 and S413 to a specific scenario, such as... Figure 8 As shown, 1. Write the target write data of AU 0 from the preset cache to super Block A. The write range of the target write data in super Block A includes super page 0-N, and the data pages super page 0-N in the write range are completely filled. Therefore, fill the data page super page N+1 after the current data page super page N with write completion markers, where write completion markers are dummy data of CLOSE LAA (fill data for closing logical addresses). 2. Write the target write data of AU 1 from the preset cache to super Block B. The write range of the target write data in super Block B includes super page 0-N, but the data page super page N in the write range of super page 0-N is not completely filled. Therefore, fill the blank address of the current data page super page N with dummy data of CLOSE LAA, and fill the data page super page N+1 after the current data page super page N with dummy data of CLOSE LAA. The data filling process of AU 3 is the same as that of AU 2. After a data block is filled with the dummy data of the CLOSE LAA, no other data will be written. Therefore, the data for a new write command will be written to the next data block. In the current scenario, super Block A, super Block B, and super Block C are the same size, while AU 0, AU 1, and AU3 are different sizes. The specific size relationship of the write allocation units is: AU 0 > AU 1 > AU3.

[0117] In this embodiment, the method further includes the following steps S601-S602:

[0118] S601. If the valid data block is marked as the target block for garbage collection, then the data page in the valid data block that has the write completion mark is marked as a stop data page.

[0119] S602. When the target block is being relocated, if the stopped data page is read, the garbage collection operation is terminated.

[0120] If a data block has been written to the Allocation Unit (AU) and filled with dummy data, but has not been released through overwrite, the garbage collection mechanism may select this data block's super block as the source super block. When moving this source super block, if this CLOSE LAA dummy data is read, the garbage collection mechanism will set this page (data page) filled with CLOSE LAA dummy data as the set stop page, thus eliminating the need to read or write data further, and the task of moving this source super block can end early.

[0121] Please refer to Figure 9 Embodiment 3 of the present invention is as follows:

[0122] A method for releasing a data block, which differs from Embodiment 1 or Embodiment 2 in that a write interrupt request is received during the execution of step S411.

[0123] Specifically, the method includes:

[0124] S701. If a write interruption request is received when writing the current write data issued by the write allocation unit in the write command to the preset cache, then when the next write command from the host is received, it is detected whether the next write data issued by the write allocation unit in the next write command and the current write data already written to the preset cache are consecutive writes. If so, S702 is executed; otherwise, S703 is executed.

[0125] In some embodiments, detecting whether the next write data issued based on the write allocation unit in the next write command and the current write data already written to the preset cache belong to continuous writes specifically involves: obtaining the current LBA of the current write command and the next LBA of the next write command, detecting whether the next LBA belongs to the range of the current LBA, if so, then the next write data and the current write data belong to continuous writes; otherwise, the next write data and the current write data do not belong to continuous writes.

[0126] S702, then write the next write data into the preset cache to obtain the target write data, and execute S412-S413.

[0127] S703, Take the currently written data that has been written to the preset cache as the target written data, and execute S412-S413.

[0128] Applying steps S701 and S703 to a specific scenario, such as... Figure 9 As shown, suppose data AU0 is currently being written to the preset cache, but a write interruption request is received halfway through the writing process. When a new write command is received, it is detected that the LBA of the new write command does not belong to the range of the old write command AU0. In this case, the remaining data of AU0 in the preset cache is first flushed to super Block A, and dummy data is used to fill the unfilled data pages super page M and super page M+1 to close super Block A. After the preset cache is emptied, the data of AU1 in the new write command is flushed to super Block B through the preset cache. Furthermore, if the LBA of the new write command is detected to belong to the range of the old write command AU0, the data in the new write command is written to the preset cache, and the data from both the old and new commands is flushed to super Block A through the preset cache.

[0129] Please refer to Figure 10 Embodiment four of the present invention is as follows:

[0130] A storage device includes a control chip and a storage chip, the storage chip storing a computer program, which, when executed by the control chip, implements the steps of a method for releasing a data block according to embodiments one to three above.

[0131] In summary, this invention provides a method and storage device for releasing data blocks. By spatially aligning the size of the write allocation unit with the capacity of the super data block, it effectively solves the storage space fragmentation problem caused by the mismatch between the write allocation unit and the data block size in traditional overwrite methods. By configuring the write allocation unit size to a configurable parameter that is smaller than and closest to the super data block size, write performance standards are met while minimizing fragmentation. During the write process, by detecting whether the write command is an overwrite command, invalid data blocks after overwriting are released immediately, avoiding cross-block storage and ensuring that each data block can be released completely, reducing the frequency of garbage collection and avoiding triggering write protection mechanisms. Furthermore, by using a preset cache and write completion marking mechanism, the data write process is further optimized, avoiding data fragmentation and cross-block storage problems. Simultaneously, during garbage collection operations, by marking stopped data pages, unnecessary data movement is reduced, improving garbage collection release efficiency. In write interruption scenarios, by detecting the continuity of written data and properly handling cached data, data integrity and continuity are guaranteed. The solution of this invention not only improves the write performance and space utilization of storage devices, but also enhances the release efficiency of data blocks and the stability of write performance.

[0132] In the embodiments provided in this application, it should be understood that the disclosed methods, apparatuses, computer-readable storage media, and electronic devices can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple components or modules may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices, components, or modules may be electrical, mechanical, or other forms.

[0133] The components described as separate parts may or may not be physically separate. The components shown as components 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 components can be selected to achieve the purpose of this embodiment according to actual needs.

[0134] Furthermore, the functional modules in the various embodiments of the present invention can be integrated into one processing module, or each component can exist physically separately, or two or more modules can be integrated into one module. The integrated modules described above can be implemented in hardware or as software functional modules.

[0135] If the integrated module is implemented as a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0136] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that the present invention is not limited to the described order of actions, because according to the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to the present invention.

[0137] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.

[0138] The above description is merely an embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent modifications made based on the content of the present invention specification and drawings, or direct or indirect applications in related technical fields, are similarly included within the patent protection scope of the present invention.

Claims

1. A method for releasing a data block, characterized in that, include: Get the size of the super block in the storage device; The size of the write allocation unit is configured to the capacity of the super data block; the size of the write allocation unit is configured via firmware. Receive a write command from the host and detect whether the write command is a rewrite command; If so, the super data block is overwritten according to the current write data issued by the write allocation unit in the write command to obtain an invalid data block, and the invalid data block is released. Detecting whether the write command is a rewrite command includes: Obtain the address of the historical logical block of the historical write command received before the write command; Detect whether the current logical block address of the write command is the same as the historical logical block address; If so, then the write command is determined to be a rewrite command; Otherwise, it is determined that the write command is not a rewrite command; Invalid data blocks obtained by rewriting the super data block based on the current write data issued by the write allocation unit in the write command include: The current write data issued by the write allocation unit in the write command is written into the free data block in the super data block to obtain a valid data block; Update the mapping entry of the current logical block address to the valid data block, so that the original data block mapped by the mapping entry before the update is invalidated to obtain an invalid data block; The process of writing the current write data issued by the write allocation unit in the write command to a free data block in the super data block to obtain a valid data block includes: The target write data is obtained by writing the current write data issued by the write allocation unit in the write command to a preset cache. The preset cache only allows the current write data of the size of one write allocation unit to be written. After the target write data in the preset cache is completely written into the free data block, it is detected whether there are any free data pages in the free data block; If so, then the write completion marker is filled into the end of the target write data to obtain a valid data block.

2. The method for releasing a data block according to claim 1, characterized in that, Obtaining the size of the superblock in the storage device includes: Obtain the device model of the storage device; The storage structure of the storage device is determined based on the device model. The capacity of the super data block used to store user data is determined based on the storage structure.

3. The method for releasing a data block according to claim 2, characterized in that, Configuring the size of the write allocation unit to the capacity size of the super data block includes: Get multiple configurable parameters for the size of the write allocation unit; Determine a target configuration parameter among the plurality of configurable parameters that is smaller than the capacity size and whose difference from the capacity size is less than a preset value; Configure the size of the write allocation unit as the target configuration parameter.

4. The method for releasing a data block according to claim 1, characterized in that, Filling the end of the target written data with a write completion marker to obtain a valid data block includes: Detect whether the current data page in the free data block where the target data is being written is completely filled; If so, the write completion marker is filled into the next free data page following the current data page to obtain a valid data block; Otherwise, the write completion marker is filled into the blank address of the current data page where the target write data has not been written and the next free data page after the current data page to obtain a valid data block.

5. The method for releasing a data block according to claim 1, characterized in that, Also includes: If the valid data block is marked as the target block for garbage collection, then the data page in the valid data block that has the write completion mark is marked as a stop data page. If the stopped data page is read during data transfer of the target block to be recycled, the garbage collection operation is terminated.

6. The method for releasing a data block according to claim 1, characterized in that, Also includes: If a write interruption request is received when writing the current write data issued by the write allocation unit in the write command to the preset cache, then when receiving the next write command from the host, it is detected whether the next write data issued by the write allocation unit in the next write command and the current write data already written to the preset cache are consecutive writes. If so, the next write data is written to the preset cache to obtain the target write data, and the step of detecting whether there is a free data page in the free data block after the target write data in the preset cache is completely written to the free data block is executed; Otherwise, the currently written data already written to the preset cache is used as the target written data, and the step of detecting whether there are any free data pages in the free data block after the target written data in the preset cache is completely written to the free data block is executed.

7. The method for releasing a data block according to claim 1, characterized in that, Also includes: If the write command is not a rewrite command, the current write data is written to a free data block in the super data block to obtain a valid data block, and the current logical block address is mapped to the valid data block to obtain a mapping table entry.

8. A storage device comprising a control chip and a storage chip, wherein the storage chip stores a computer program, characterized in that, When the computer program is executed by the control chip, it implements the steps of a method for releasing a data block as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Data storage method and device based on address redirection

    CN115390751A

  • Super block-based write management in non-volatile memory devices

    CN116737060A