Data writing method, device and equipment applied to solid state hard disk

By rearranging the data blocks to be written in the solid-state hard disk, ensuring that they meet the fast read conditions, the problem of low reading efficiency in the existing SSD writing methods is solved, and the effect of improving data reading efficiency is achieved.

CN114625318BActive Publication Date: 2025-05-16RUIZHE (HANGZHOU) TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210186790.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-28
Publication Date
2025-05-16
Estimated Expiration
2042-02-28

AI Technical Summary

Technical Problem

In the existing SSD writing method, the probability that the data corresponding to the read request meets the conditions required for the fast read function is low, resulting in low data reading efficiency.

Method used

In a solid-state hard disk, when the storage space occupied by the cached data block to be written reaches a preset threshold, physical storage space is allocated for the data block to be written, and the data block to be written is rearranged according to the storage space occupied by each data block to be written and the allocated physical storage space to ensure that the data blocks that meet the fast read conditions can be quickly read.

Benefits of technology

By rearranging the data blocks to be written, they satisfy the data amount and physical storage location conditions that are quickly read, the probability of data that meets the fast reading function is improved, thereby improving the data reading efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114625318B_ABST
    Figure CN114625318B_ABST
Patent Text Reader

Abstract

The present disclosure provides a data writing method, device, and apparatus for a solid-state hard disk, which relates to computer storage technology, including: when the storage space occupied by the data blocks to be written cached in the solid-state hard disk reaches a preset threshold, physical storage space is allocated for the data blocks to be written; the physical storage space includes at least one first storage space, and the data blocks that can be quickly read are located in the same first storage space; according to the storage space occupied by each data block to be written and the allocated physical storage space, each data block to be written is rearranged; according to the order of each data block to be written after the rearrangement, each data block to be written is written into the physical storage space. The rearrangement can make the data blocks to be written that meet the data volume condition of the fast read meet the physical storage location condition of the fast read at the same time, so that when the data is read, the probability of satisfying the data that triggers the fast read function can be increased, thereby improving the data reading efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to computer storage technology, and in particular to a method, device, and equipment for writing data to a solid state drive. Background Art

[0002] A solid state drive (SSD), also known as a solid-state drive, is a hard disk made of a solid-state electronic storage chip array. NAND flash memory is the main storage medium for current SSDs.

[0003] In the prior art, NAND flash memory in SSD generally provides a quick read function. The main function of quick read is that when the data corresponding to the read request meets certain conditions in terms of data volume and physical storage location, it can be quickly read through a dedicated read channel, thereby providing better performance than a general read channel. Among them, the data written to the SSD has multiple sources, such as database applications, file system metadata, etc., so the write operation of the SSD often has multiple different characteristics, such as data blocks can be large or small, logical addresses can be sequential or random, etc.

[0004] However, under the existing SSD writing method, the probability that the data corresponding to the read request meets the conditions required by the fast reading function is low, resulting in low data reading efficiency. Summary of the invention

[0005] The present disclosure provides a data writing method, device and apparatus for a solid state drive to solve the problem that the probability of data corresponding to a read request satisfying a fast reading function is low under the existing writing method, resulting in low data reading efficiency.

[0006] According to a first aspect of the present application, a data writing method applied to a solid state drive is provided, comprising:

[0007] When the storage space occupied by the data blocks to be written cached in the solid state drive reaches a preset threshold, a physical storage space is allocated for the data blocks to be written; the physical storage space includes at least one first storage space, and the data blocks that can be quickly read are located in the same first storage space;

[0008] Rearranging the data blocks to be written according to the storage space occupied by the data blocks to be written and the allocated physical storage space;

[0009] According to the order of the data blocks to be written after the rearrangement, each of the data blocks to be written is written into the physical storage space.

[0010] According to a second aspect of the present application, a data writing device applied to a solid state drive is provided, comprising:

[0011] an allocation unit, configured to allocate physical storage space to the data blocks to be written when the storage space occupied by the data blocks to be written cached in the solid state drive reaches a preset threshold; the physical storage space includes at least one first storage space, and the data blocks that can be quickly read are located in the same first storage space;

[0012] A rearrangement unit, configured to rearrange the data blocks to be written according to the storage space occupied by the data blocks to be written and the allocated physical storage space;

[0013] The writing unit is used to write each of the to-be-written data blocks into the physical storage space according to the order of the to-be-written data blocks after rearrangement.

[0014] According to a third aspect of the present application, an electronic device is provided, including a memory and a processor; wherein:

[0015] The memory is used to store computer programs;

[0016] The processor is used to read the computer program stored in the memory and execute the data writing method applied to the solid state drive as described in the first aspect according to the computer program in the memory.

[0017] According to a fourth aspect of the present application, a computer-readable storage medium is provided, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, the data writing method applied to a solid-state hard disk as described in the first aspect is implemented.

[0018] According to a fifth aspect of the present application, a computer program product is provided, including a computer program, which, when executed by a processor, implements the data writing method applied to a solid state drive as described in the first aspect.

[0019] The data writing method, device, and equipment provided by the present disclosure for solid-state hard disks include: when the storage space occupied by the data blocks to be written cached in the solid-state hard disk reaches a preset threshold, physical storage space is allocated for the data blocks to be written; the physical storage space includes at least one first storage space, and the data blocks that can be quickly read are located in the same first storage space; according to the storage space occupied by each data block to be written and the allocated physical storage space, each data block to be written is rearranged; according to the order of each data block to be written after the rearrangement, each data block to be written is written into the physical storage space. In the data writing method, device, and equipment for solid-state hard disks provided by the present scheme, each data block to be written can be rearranged first, and then each rearranged data block to be written is written into the physical storage space. The data blocks to be written that meet the data volume condition of fast reading can be rearranged so that the physical storage location condition of fast reading is met at the same time, so that when reading data, the probability of data that meets the triggering fast reading function can be increased, thereby improving the data reading efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 A schematic flow chart of a method for writing data to a solid state drive according to an exemplary embodiment of the present application;

[0021] Figure 2 A schematic diagram of a method for rearranging data blocks to be written according to an exemplary embodiment of the present application;

[0022] Figure 3 A schematic flow chart of a method for writing data to a solid state drive according to another exemplary embodiment of the present application;

[0023] Figure 4 A schematic diagram of a method for determining multiple data sub-blocks in valid data shown in an exemplary embodiment of the present application;

[0024] Figure 5 This is a schematic diagram of filling invalid data according to an exemplary embodiment of the present application;

[0025] Figure 6 This is a structural diagram of a data writing device applied to a solid state drive, shown as an exemplary embodiment of the present application;

[0026] Figure 7 The figure is a structural diagram of an electronic device according to an exemplary embodiment of the present application. DETAILED DESCRIPTION

[0027] Solid state drive (SSD), also known as solid state drive, is a hard disk made of solid-state electronic storage chip array. NAND flash memory is the main storage medium of current SSD. Specifically, a NAND flash memory has several Die (or LUN) connection channels, each Die has several Planes (commonly 1, 2, 4), each Plane has several Blocks, each Block has several Pages, each Page corresponds to a Wordline, and each Wordline consists of thousands of storage cells. In the prior art, NAND flash memory in SSD generally provides a fast read (snap read) function. Among them, the data written to SSD has multiple sources, such as database applications, file system metadata, etc., so the write operation of SSD often has a variety of different characteristics, such as data blocks can be large or small, logical addresses can be sequential or random, etc.

[0028] The main function of fast read is that when the data corresponding to the read request meets certain conditions in terms of data volume and physical storage location, it can be quickly read through a dedicated read channel, thereby providing better performance than a general read channel.

[0029] However, under the existing writing method, the probability that the data corresponding to the read request meets the conditions required by the fast reading function is low, resulting in low data reading efficiency.

[0030] In order to solve the above technical problems, the solution provided by the present disclosure can first rearrange the data blocks to be written, and then write the rearranged data blocks to be written into the physical storage space. The data blocks to be written that meet the data volume conditions for fast reading can be rearranged so that they can also meet the physical storage location conditions for fast reading. Therefore, when reading data, the probability of data that meets the conditions for triggering the fast reading function can be increased, thereby improving the data reading efficiency.

[0031] Figure 1 The present invention is a flowchart of a method for writing data to a solid state drive according to an exemplary embodiment of the present invention.

[0032] like Figure 1 As shown, the data writing method applied to the solid state drive provided in this embodiment includes:

[0033] Step 101, when the storage space occupied by the data blocks to be written cached in the solid state drive reaches a preset threshold, physical storage space is allocated for the data blocks to be written; the physical storage space includes at least one first storage space, and the data blocks that can be quickly read are located in the same first storage space.

[0034] The solution provided by the present disclosure can be executed by a solid-state hard disk. When the storage space occupied by the data blocks to be written cached in the solid-state hard disk reaches a preset threshold, the solid-state hard disk can allocate physical storage space for the data blocks to be written, wherein the allocated physical storage space includes at least one first storage space.

[0035] Among them, a solid state drive (SSD), also known as a solid-state drive, is a hard disk made of a solid-state electronic storage chip array.

[0036] When writing data to a solid state drive, the solid state drive usually caches the data blocks to be written, and when the cached data blocks to be written reach a certain number, writes them together into the physical space of the solid state drive.

[0037] When the cached data blocks to be written reach a preset threshold, each cached data block to be written can be written into the physical space of the hard disk. The preset threshold is a storage space threshold pre-set according to actual conditions, for example, 32KB.

[0038] When writing data blocks to be written into the solid state drive, physical storage space can be allocated for these data blocks to be written. Specifically, when allocating, the allocation can be performed according to the storage space management granularity of the solid state drive. For example, a number of first storage spaces can be allocated, and the first storage space refers to the management granularity of the solid state drive, such as a page.

[0039] Among them, the solid-state drive has a fast reading function, and the NAND flash memory in the solid-state drive can provide this function.

[0040] The fast read function means that when the data corresponding to the read request meets certain conditions in terms of data volume and physical storage location, it can be quickly read through a dedicated read channel, thereby providing better performance than general read channels. The data volume that meets the fast read function can be 4KB, 8KB, etc., and the data blocks can only be quickly read when they are located in the same first storage space.

[0041] For example, if there is a data block of 8 KB in size located in the same first storage space, the data block can be read quickly; if there is another data block of 8 KB in size spanning two first storage spaces, the data block cannot be read quickly.

[0042] The physical storage space allocated by the solid state drive for the data block to be written may be 32 KB or 64 KB.

[0043] Step 102: rearrange the data blocks to be written according to the storage space occupied by the data blocks to be written and the allocated physical storage space.

[0044] Specifically, before storing each data block to be written into the physical storage space, it can be rearranged so that as many data blocks to be written as possible that meet the data volume conditions of the fast reading function can also meet the fast reading function at the physical storage location when written into the solid state disk. In this way, when reading the data block, the fast reading function can be used to improve the reading efficiency.

[0045] Furthermore, by rearrangement, as many data blocks to be written as possible can be located in one first storage space rather than spanning multiple first storage spaces, so that these data blocks to be written can meet the fast reading condition.

[0046] The storage space occupied by each data block to be written may be, for example, 4 KB or 8 KB.

[0047] The allocated physical storage space may be 32KB or 64KB.

[0048] The storage space occupied by each data block to be written and the allocated physical storage space can be obtained. The allocated physical storage space can include at least one first storage space, and the size of each first storage space is fixed. Therefore, according to the storage space occupied by each data block to be written, a number of data blocks to be written whose total occupied storage space is the same as the size of the first storage space can be rearranged, and then the remaining data blocks to be written whose total storage space is the same as the size of the first storage space can be rearranged, and so on. The rearranged data blocks to be written can be stored in the same first storage space, and when these data blocks need to be read later, they can be read in a fast reading manner.

[0049] Specifically, if there are certain requirements for the size of the data blocks to be written that can be read quickly, in order to ensure that more data blocks to be written that meet the size conditions are stored without spanning multiple first storage spaces, the storage space occupied by each data block to be written can also be obtained, and the data blocks whose storage space meets the data volume conditions in the fast reading conditions can be determined.

[0050] During rearrangement, priority may be given to arranging the data blocks at positions corresponding to a first storage space, and data blocks whose storage spaces do not satisfy the data volume condition in the fast reading condition may be used to fill the remaining positions.

[0051] For example, a first storage space is 16KB in size, and two first storage spaces are allocated to store cached data blocks to be written. The sizes of the data blocks to be written are 8KB, 5KB, 4KB, 4KB, 3KB, and 8KB respectively. If the data volume of the data that meets the fast reading function is 4KB and 8KB, all the data blocks to be written may be read quickly. The positions of these data blocks can be determined first so that they are located in an independent first storage space. For example, the 8KB and 8KB data blocks can be arranged in the position corresponding to the first storage space, and the 4KB and 4KB data blocks can be arranged in the position corresponding to the other first storage space. Since the size of one storage space is 16KB, the position corresponding to the first storage space is filled, while the other storage space has remaining positions. Therefore, the 5KB and 3KB data blocks are arranged in the position corresponding to the other storage space, specifically after the 4KB and 4KB data blocks.

[0052] like Figure 2 As shown, the data blocks to be written cached in the cache unit of the solid-state drive are 4KB, 8KB, 8KB, 8KB, 4KB, in order, for a total of 32KB. If the physical space allocated by the solid-state drive for the 32KB data is two complete 16KB spaces, then before rearrangement, the distribution of the 32KB data in the physical address space is as follows: Figure 2 As shown in the upper part, the 8KB data in the middle cannot be read quickly. After rearrangement, the distribution of 32KB data in the physical space can be as follows: Figure 2 As shown in the lower part, at this time, all the data blocks to be written can be read in a fast read mode.

[0053] Step 103, writing each data block to be written into the physical storage space according to the order of each data block to be written after the rearrangement.

[0054] Specifically, the solid state drive may write each data block to be written into the physical storage space in the solid state drive according to the order of the data blocks to be written after the rearrangement.

[0055] For example, Figure 2 As shown in Figure 2, after rearrangement, the order of the data blocks to be written is as follows: Figure 2 As shown in the lower part, each data block to be written is written into the physical storage space in the solid state drive in this order. Through this implementation, when reading each data block in the 32KB, each data block in the 32KB meets the fast reading condition and can be read quickly.

[0056] If the data blocks to be written are not rearranged when the data is written, such as Figure 2The 8KB data block spanning two 16KB blocks shown in the upper part cannot be read quickly because it does not meet the conditions for fast reading.

[0057] Therefore, the method provided by this solution can increase the probability of data satisfying the triggering of the fast reading function, thereby improving the data reading efficiency.

[0058] The data writing method applied to a solid-state hard disk provided by the present disclosure includes: when the storage space occupied by the data blocks to be written cached in the solid-state hard disk reaches a preset threshold, a physical storage space is allocated for the data blocks to be written; the physical storage space includes at least one first storage space, and the data blocks that can be quickly read are located in the same first storage space; according to the storage space occupied by each data block to be written and the allocated physical storage space, each data block to be written is rearranged; according to the order of each data block to be written after the rearrangement, each data block to be written is written into the physical storage space. The scheme provided by the present disclosure can first rearrange each data block to be written, and then write each rearranged data block to be written into the physical storage space. The data blocks to be written that meet the data volume condition of the fast read can be rearranged so that the physical storage position condition of the fast read is met at the same time, so that when the data is read, the probability of satisfying the data that triggers the fast read function can be increased, thereby improving the data reading efficiency.

[0059] Figure 3 The present invention is a flowchart of a method for writing data to a solid state drive according to another exemplary embodiment of the present invention.

[0060] like Figure 3 As shown, the data writing method applied to the solid state drive provided in this embodiment includes:

[0061] Step 301: Obtain a write request for performing a write operation on a data block to be written.

[0062] Specifically, the solid state drive may obtain a write request for performing a write operation on a data block to be written.

[0063] There are two ways to generate a write request: one is generated by a host; the other is generated by a solid state drive when migrating data.

[0064] Optionally, the SSD may obtain a write request sent by the host for performing a write operation on a data block to be written. For example, a user may connect the host to the SSD and operate the host to write data to the SSD. For example, a file stored in the host may be imported into the SSD and a write request may be sent to the SSD.

[0065] In another case, when data migration is performed inside the SSD, a write request for a write operation is also generated. For example, when operations such as garbage collection and wear leveling are performed inside the SSD, a system set up in the SSD generates a write request.

[0066] In this implementation, the solid state drive may also obtain a write request for performing a write operation on a data block to be written, which is generated when data is migrated.

[0067] Step 302: Cache the data block to be written according to the write request.

[0068] Specifically, the solid state drive may cache the data blocks to be written according to the write request.

[0069] Optionally, if the acquired write request is sent by the host, and the solid-state drive has a transparent compression function, transparent compression is performed on the data block to be written according to the write request;

[0070] Among them, transparent compression means that the compression is transparent to the user.

[0071] Cache compressed data blocks to be written.

[0072] For example, a to-be-written data occupying 8KB of storage space becomes 5KB after transparent compression, and the data block cached by the cache unit of the solid-state drive is the compressed 5KB to-be-written data block.

[0073] Specifically, if the write request obtained by the SSD is sent by the host, and the SSD has a transparent compression function, the SSD will first transparently compress the data block to be written according to the write request; and then cache the compressed data block to be written.

[0074] Optionally, if the acquired write request is generated by the solid state drive when migrating data, then according to the write request, a physical address of the physical storage space before the data migration is acquired;

[0075] Specifically, the SSD will record the usage of each physical space in the SSD, and can generate a write request for migrating data within the SSD according to the usage of each physical space. The write request may include the physical address of the physical storage space before data migration; the SSD can obtain the physical address according to the write request.

[0076] Determine the valid data to be migrated and the logical address corresponding to the valid data according to the physical storage space before data migration and the address mapping table; the address mapping table records the correspondence between the logical address and the physical address of the valid data;

[0077] The valid data may refer to data stored in the physical storage space before migration and not deleted or changed.

[0078] Specifically, the solid-state drive can query the address mapping table based on the physical address of the physical storage space before migration, and obtain the current logical address corresponding to the physical address of the physical storage space before migration; wherein the current logical address corresponds to the data stored in the physical storage space before migration. The logical address of the last time the data was written can be obtained based on the physical storage space before migration. Then, the logical address of the last write is compared with the current logical address to see if they are consistent; if the comparison result is consistent, it is determined that the data stored in the physical storage space before migration is valid data that needs to be migrated. And the current logical address is determined to be the logical address corresponding to the valid data.

[0079] According to the logical address and bit map of the valid data, multiple first data sub-blocks in the valid data are determined and cached; the bit map records the correspondence between the logical address of the valid data and the label; wherein the label includes a first label and a second label.

[0080] The storage space of a data sub-block may be 4 KB. A first data sub-block may include one or more data sub-blocks.

[0081] The first label can be represented as 1, and the second label can be represented as 0.

[0082] Specifically, the bitmap can be used to indicate the continuity of the data block to be written in terms of the physical address. When the SSD is performing internal data migration (such as garbage collection, wear leveling, etc.), the bitmap can be used for migration to maximize the probability of fast data reading.

[0083] Specifically, the logical address of each data sub-block corresponds to a label. For the logical address of the first data sub-block of a new write, the label corresponding to the logical address of the first data sub-block may be a first label, which may be represented as 1, and the label corresponding to the logical address of the data sub-block included in the subsequent write request may be a second label, which may be represented as 0. For example, for a 16KB write request, the label sequence corresponding to it in the bitmap after the write is completed may be 1000; if a data sub-block in an original data block is updated, the updated data sub-block part changes the bitmap according to the above-mentioned criteria, and if there is still valid data in the original data block after the updated data sub-block part, the label corresponding to the logical address of the first data sub-block after the updated data sub-block part is also set to 1.

[0084] Optionally, each label corresponding to the logical address is determined according to the logical address and the bit map of the valid data; the label includes a first label and a second label;

[0085] If the first label is followed by at least one second label, then determining that the data corresponding to the logical address corresponding to the first label and the at least one second label is a first data sub-block;

[0086] If the first label is followed by another first label, it is determined that the data corresponding to the logical address corresponding to the first label is a first data sub-block.

[0087] For example, Figure 4 As shown, for a 16KB data block (LBA0-LBA3), its original label sequence is 1000. If LBA1 is updated, the updated label sequence is 1110. The data block includes two first data sub-blocks, wherein the data in LBA0 is a first data sub-block; and the data in LBA2-LBA3 is a first data sub-block.

[0088] Specifically, the solid state drive may treat each first data sub-block as a data block to be written, and cache multiple first data sub-blocks.

[0089] Specifically, in this manner, the data in LBA2-LBA3 can be cached as a data block to be written, and the data in LBA2 and LBA3 does not need to be divided into two data blocks to be written for caching, which can facilitate quick reading later.

[0090] Step 303, when the storage space occupied by the data blocks to be written cached in the solid state drive reaches a preset threshold, physical storage space is allocated for the data blocks to be written; the physical storage space includes at least one first storage space, and the data blocks that can be quickly read are located in the same first storage space.

[0091] Specifically, the principle and implementation of step 303 are similar to those of step 101 and will not be described in detail.

[0092] Step 304, if the storage space occupied by the data block to be written meets the fast reading condition; determine multiple consecutive data blocks to be written based on the storage space occupied by each data block to be written, the sum of the storage space of the multiple consecutive data blocks to be written is less than or equal to the space of a first storage space, and the difference between the sum of the storage space of the multiple consecutive data blocks to be written and the space of the first storage space is less than the storage space occupied by any other data block to be written except the multiple consecutive data blocks to be written.

[0093] Specifically, before storing each data block to be written into the physical storage space, it can be rearranged so that as many data blocks to be written as possible that meet the data volume conditions of the fast reading function can also meet the fast reading function at the physical storage location when written into the solid state disk. In this way, when reading the data block, the fast reading function can be used to improve the reading efficiency.

[0094] Furthermore, by rearrangement, as many data blocks to be written as possible can be located in one first storage space rather than spanning multiple first storage spaces, so that these data blocks to be written can meet the fast reading condition.

[0095] Step 305 , continue to determine multiple continuous data blocks to be written from the remaining other data blocks to be written, and arrange the multiple continuous data blocks to be written determined later after the multiple continuous data blocks to be written determined previously, until all the data blocks to be written are rearranged.

[0096] Optionally, the solid-state hard disk has a transparent compression function; if the total storage space occupied by the multiple consecutive data blocks to be written determined last time is less than the space of a first storage space, and the difference between the total storage space occupied and the space of the first storage space is less than a preset threshold, then invalid data is filled after the multiple consecutive data blocks to be written, and the total space occupied by the multiple consecutive data blocks to be written and the space occupied by the invalid data is equal to the space of the first storage space;

[0097] The preset threshold is a threshold preset according to actual conditions. For example, the preset threshold may be 500B.

[0098] Among them, the invalid data filled in, for example, can be filled with all 0s.

[0099] Specifically, for a solid-state drive with a transparent compression function, when the remaining space of a first storage space is small and insufficient to fill a data block to be written that meets the fast read size condition, invalid data can be filled in the corresponding remaining space, and a new first storage space can be used to store the data block that meets the fast read size condition. Figure 5 As shown in the figure, the previous 16KB physical space is almost full (300B of space remaining). At this time, if the preset threshold is 500B, a data block of 3KB after compression will fill the next 16KB, and the remaining space of the previous 16KB will be filled with 300B of invalid data (for example, all-0 data); if a data block to be written is compressed to 280B, the remaining space of 300B can still be filled.

[0100] The multiple consecutive data blocks to be written that are determined later are arranged after the invalid data of the multiple consecutive data blocks to be written that are determined previously.

[0101] Step 306, writing each data block to be written into the physical storage space according to the order of each data block to be written after the rearrangement.

[0102] Specifically, after step 306 is executed, step 307 and step 308 are executed.

[0103] Specifically, the principle and implementation of step 306 are similar to those of step 103 and will not be described in detail.

[0104] Step 307, update the address mapping table according to the physical storage space where each data block to be written is written and the logical address of the data block to be written; wherein the address mapping table records the correspondence between the logical address of each data block to be written and the physical address of the physical storage space.

[0105] Furthermore, if the data stored in the physical storage space is deleted or updated, the address mapping table will be updated accordingly.

[0106] Step 308, updating the bitmap according to the logical address of each data block to be written; wherein the bitmap records the correspondence between the logical address of each data block to be written and the label; wherein the label includes a first label and a second label; the data block to be written includes multiple data sub-blocks, wherein the first data sub-block corresponds to the first label, and the remaining data sub-blocks correspond to the second label.

[0107] The storage space of a data sub-block may be 4 KB.

[0108] The first label can be represented as 1, and the second label can be represented as 0.

[0109] Specifically, the bitmap can be used to indicate the continuity of the data block to be written in terms of the physical address. When the SSD is performing internal data migration (such as garbage collection, wear leveling, etc.), the bitmap can be combined to achieve the purpose of fast migration.

[0110] Figure 6 The structure diagram of a data writing device applied to a solid state drive is shown as an exemplary embodiment of the present application.

[0111] like Figure 6 As shown, the data writing device 600 applied to a solid state drive provided by the present application includes:

[0112] The allocation unit 610 is used to allocate physical storage space for the data blocks to be written when the storage space occupied by the data blocks to be written cached in the solid state drive reaches a preset threshold; the physical storage space includes at least one first storage space, and the data blocks that can be quickly read are located in the same first storage space;

[0113] A rearrangement unit 620, configured to rearrange the data blocks to be written according to the storage space occupied by the data blocks to be written and the allocated physical storage space;

[0114] The writing unit 630 is used to write each data block to be written into the physical storage space according to the order of the data blocks to be written after the rearrangement.

[0115] If the storage space occupied by the data blocks to be written meets the fast reading condition; the rearrangement unit 620 is specifically used to determine multiple consecutive data blocks to be written according to the storage space occupied by each data block to be written, the total storage space of the multiple consecutive data blocks to be written is less than or equal to the space of a first storage space, and the difference between the total storage space of the multiple consecutive data blocks to be written and the space of the first storage space is less than the storage space occupied by any other data blocks to be written except the multiple consecutive data blocks to be written; continue to determine multiple consecutive data blocks to be written from the remaining other data blocks to be written, and arrange the multiple consecutive data blocks to be written determined later after the multiple consecutive data blocks to be written determined last time, until all the data blocks to be written are rearranged.

[0116] The solid-state hard disk has a transparent compression function; if the total storage space occupied by the multiple consecutive data blocks to be written determined last time is less than the space of a first storage space, and the difference between the total storage space occupied and the space of a first storage space is less than a preset threshold, then the rearrangement unit 620 is specifically used to fill invalid data after the multiple consecutive data blocks to be written, and the total space occupied by the multiple consecutive data blocks to be written and the space occupied by the invalid data is equal to the space of a first storage space; the multiple consecutive data blocks to be written determined later are arranged after the invalid data of the multiple consecutive data blocks to be written determined last time.

[0117] The data writing device 600 for a solid state drive provided in the present application further includes:

[0118] The address mapping table updating unit 640 is used to update the address mapping table according to the physical storage space where each data block to be written is written and the logical address of the data block to be written; wherein the address mapping table records the correspondence between the logical address of each data block to be written and the physical address of the physical storage space;

[0119] The bitmap updating unit 650 is used to update the bitmap according to the logical address of each data block to be written; wherein the bitmap records the correspondence between the logical address of each data block to be written and the label; wherein the label includes a first label and a second label; the data block to be written includes a plurality of data sub-blocks, wherein the first data sub-block corresponds to the first label, and the remaining data sub-blocks correspond to the second label;

[0120] An acquisition unit 660 is used to acquire a write request for performing a write operation on a data block to be written;

[0121] The cache unit 670 is used to cache the data blocks to be written according to the write request.

[0122] The acquisition unit 660 is specifically used to acquire a write request sent by the host end for performing a write operation on the data block to be written;

[0123] And / or, obtaining a write request for performing a write operation on a data block to be written, which is generated by the solid state drive when migrating data.

[0124] If the acquired write request is sent by the host, and the solid-state hard disk has a transparent compression function, the cache unit 670 is specifically used to transparently compress the data block to be written according to the write request;

[0125] Cache compressed data blocks to be written.

[0126] If the acquired write request is generated by the solid state drive when migrating data, the cache unit 670 is specifically used to acquire the physical address of the physical storage space before the data migration according to the write request;

[0127] Determine the valid data to be migrated and the logical address corresponding to the valid data according to the physical storage space before data migration and the address mapping table; the address mapping table records the correspondence between the logical address and the physical address of the valid data;

[0128] According to the logical address and bit map of the valid data, multiple first data sub-blocks in the valid data are determined and cached; the bit map records the correspondence between the logical address of the valid data and the label; wherein the label includes a first label and a second label.

[0129] The cache unit 670 is specifically used to determine each label corresponding to the logical address according to the logical address and the bit map of the valid data; the label includes a first label and a second label;

[0130] If the first label is followed by at least one second label, then determining that the data corresponding to the logical address corresponding to the first label and the at least one second label is a first data sub-block;

[0131] If the first label is followed by another first label, it is determined that the data corresponding to the logical address corresponding to the first label is a first data sub-block.

[0132] Figure 7 The figure is a structural diagram of an electronic device according to an exemplary embodiment of the present application.

[0133] like Figure 7 As shown, the electronic device provided in this embodiment includes:

[0134] Memory 701;

[0135] Processor 702; and

[0136] Computer programs;

[0137] The computer program is stored in the memory 701 and is configured to be executed by the processor 702 to implement any of the above data writing methods applied to a solid state drive.

[0138] This embodiment also provides a computer-readable storage medium on which a computer program is stored. The computer program is executed by a processor to implement any of the above data writing methods applied to a solid state drive.

[0139] This embodiment also provides a computer program product, including a computer program, which, when executed by a processor, implements any of the above-mentioned data writing methods applied to a solid state drive.

[0140] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.

[0141] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A data writing method applied to a solid state hard disk, characterized in that: The method comprises: When the storage space occupied by the data blocks to be written cached in the solid state drive reaches a preset threshold, a physical storage space is allocated for the data blocks to be written; the physical storage space includes at least one first storage space, and the data blocks that can be quickly read are located in the same first storage space; Rearranging the data blocks to be written according to the storage space occupied by the data blocks to be written and the allocated physical storage space; Wherein, if the storage space occupied by the data block to be written meets the fast reading condition; According to the storage space occupied by each of the data blocks to be written and the allocated physical storage space, the data blocks to be written are rearranged, including: Determine a plurality of consecutive data blocks to be written according to the storage space occupied by each of the data blocks to be written, the sum of the storage spaces of the plurality of consecutive data blocks to be written is less than or equal to the space of a first storage space, and the difference between the sum of the storage spaces of the plurality of consecutive data blocks to be written and the space of the first storage space is less than the storage space occupied by any other data blocks to be written except the plurality of consecutive data blocks to be written; Continue to determine multiple continuous data blocks to be written from the remaining other data blocks to be written, and arrange the multiple continuous data blocks to be written determined later after the multiple continuous data blocks to be written determined previously, until all the data blocks to be written are rearranged; According to the order of the data blocks to be written after the rearrangement, each of the data blocks to be written is written into the physical storage space.

2. The method according to claim 1, characterized in that The solid state drive has a transparent compression function; if the total storage space occupied by the plurality of consecutive data blocks to be written determined last time is less than the space of a first storage space, and the difference between the total storage space occupied and the space of the first storage space is less than a preset threshold, then arranging the plurality of consecutive data blocks to be written determined later after the plurality of consecutive data blocks to be written determined last time includes: Fill invalid data after the plurality of consecutive data blocks to be written, wherein the sum of the space occupied by the plurality of consecutive data blocks to be written and the space occupied by the invalid data is equal to the space of a first storage space; The multiple consecutive data blocks to be written that are determined later are arranged after the invalid data of the multiple consecutive data blocks to be written that are determined previously.

3. The method according to claim 1, characterized in that After writing each of the to-be-written data blocks into the physical storage space, the method further includes: The address mapping table is updated according to the physical storage space where each data block to be written is written and the logical address of the data block to be written; wherein the address mapping table records the correspondence between the logical address of each data block to be written and the physical address of the physical storage space.

4. The method according to claim 1, characterized in that: After writing each of the to-be-written data blocks into the physical storage space, the method further includes: Update the bitmap according to the logical address of each data block to be written; wherein the bitmap records the correspondence between the logical address of each data block to be written and the label; wherein the label includes a first label and a second label; the data block to be written includes multiple data sub-blocks, wherein the first data sub-block corresponds to the first label, and the remaining data sub-blocks correspond to the second label.

5. The method according to claim 1, characterized in that Also includes: Obtaining a write request for performing a write operation on the data block to be written; The to-be-written data block is cached according to the write request.

6. The method according to claim 5, characterized in that The obtaining of a write request for performing a write operation on the data block to be written includes: Obtaining a write request sent by the host end for performing a write operation on the data block to be written; And / or, obtaining a write request for performing a write operation on the to-be-written data block, which is generated by the solid state drive when migrating data.

7. The method according to any one of claims 5 or 6, characterized in that: If the acquired write request is sent by the host, and the solid state drive has a transparent compression function, then caching the to-be-written data block according to the write request includes: According to the write request, transparently compressing the data block to be written; Cache compressed data blocks to be written.

8. The method according to any one of claims 5 or 6, characterized in that: If the acquired write request is generated by the solid state drive when migrating data, caching the to-be-written data block according to the write request includes: According to the write request, obtaining a physical address of the physical storage space before data migration; Determine the valid data to be migrated and the logical address corresponding to the valid data according to the physical storage space before the data migration and the address mapping table; the address mapping table records the correspondence between the logical address and the physical address of the valid data; According to the logical address and bit map of the valid data, multiple first data sub-blocks in the valid data are determined, and the multiple first data sub-blocks are cached; the bit map records the correspondence between the logical address of the valid data and the label; wherein the label includes a first label and a second label.

9. The method according to claim 8, characterized in that The determining, according to the logical address and the bit map of the valid data, a plurality of first data sub-blocks in the valid data comprises: According to the logical address and the bit map of the valid data, determining each label corresponding to the logical address; the label includes a first label and a second label; If the first label is followed by at least one second label, then determining that the data corresponding to the logical address corresponding to the first label and the at least one second label is a first data sub-block; If the first label is followed by another first label, it is determined that the data corresponding to the logical address corresponding to the first label is a first data sub-block.

10. A data writing device for a solid state hard disk, characterized in that: The device comprises: an allocation unit, configured to allocate physical storage space to the data blocks to be written when the storage space occupied by the data blocks to be written cached in the solid state drive reaches a preset threshold; the physical storage space includes at least one first storage space, and the data blocks that can be quickly read are located in the same first storage space; A rearrangement unit, configured to rearrange the data blocks to be written according to the storage space occupied by the data blocks to be written and the allocated physical storage space; If the storage space occupied by the data block to be written meets the fast reading condition; the rearrangement unit is further used to: The step of rearranging the data blocks to be written according to the storage space occupied by the data blocks to be written and the allocated physical storage space comprises: Determine a plurality of consecutive data blocks to be written according to the storage space occupied by each of the data blocks to be written, the sum of the storage spaces of the plurality of consecutive data blocks to be written is less than or equal to the space of a first storage space, and the difference between the sum of the storage spaces of the plurality of consecutive data blocks to be written and the space of the first storage space is less than the storage space occupied by any other data blocks to be written except the plurality of consecutive data blocks to be written; Continue to determine multiple continuous data blocks to be written from the remaining other data blocks to be written, and arrange the multiple continuous data blocks to be written determined later after the multiple continuous data blocks to be written determined previously, until all the data blocks to be written are rearranged; The writing unit is used to write each of the to-be-written data blocks into the physical storage space according to the order of the to-be-written data blocks after rearrangement.

11. An electronic device, characterized in that: comprising a memory and a processor; wherein, The memory is used to store computer programs; The processor is used to read the computer program stored in the memory and execute the method according to any one of claims 1 to 9 according to the computer program in the memory.

12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the processor executes the computer-executable instructions, the method described in any one of claims 1 to 9 is implemented.

13. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method described in any one of claims 1 to 9 is implemented.

Citation Information

Patent Citations

  • Solid state disk based database optimization method and system

    CN102867046A