CN114625318A - Data writing method, device and equipment applied to solid state disk - Google Patents

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

Info

Publication number
CN114625318A
CN114625318A CN202210186790.1A CN202210186790A CN114625318A CN 114625318 A CN114625318 A CN 114625318A CN 202210186790 A CN202210186790 A CN 202210186790A CN 114625318 A CN114625318 A CN 114625318A
Authority
CN
China
Prior art keywords
written
data
storage space
data blocks
blocks
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210186790.1A
Other languages
Chinese (zh)
Inventor
郑宁
王晋强
蔡雪梅
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ruizhe Hangzhou Technology Co ltd
Original Assignee
Ruizhe Hangzhou Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ruizhe Hangzhou Technology Co ltd filed Critical Ruizhe Hangzhou Technology Co ltd
Priority to CN202210186790.1A priority Critical patent/CN114625318A/en
Publication of CN114625318A publication Critical patent/CN114625318A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0608Saving storage space on storage systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/061Improving I/O performance
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/064Management of blocks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/0671In-line storage system
    • G06F3/0673Single storage device
    • G06F3/0679Non-volatile semiconductor memory device, e.g. flash memory, one time programmable memory [OTP]

Abstract

The present disclosure provides a data writing method, apparatus and device applied to a solid state disk, which relates to a computer storage technology and includes: when the storage space occupied by the data block to be written cached in the solid state disk reaches a preset threshold value, distributing a physical storage space for the data block to be written; the physical storage space comprises at least one first storage space, and the data blocks which can be read quickly are positioned 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 distributed physical storage space; and writing the data blocks to be written into the physical storage space according to the sequence of the rearranged data blocks to be written. Through rearrangement, the data blocks to be written meeting the data volume condition of quick reading simultaneously meet the physical storage position condition of quick reading, so that the probability of meeting the data triggering the quick reading function is improved during data reading, and the data reading efficiency is improved.

Description

Data writing method, device and equipment applied to solid state disk
Technical Field
The present disclosure relates to computer storage technologies, and in particular, to a data writing method, apparatus, and device applied to a solid state disk.
Background
A Solid State Drive (SSD), also called a solid state drive, is a hard disk made of an array of solid state electronic memory chips. NAND flash is currently the primary storage medium for SSDs.
In the prior art, a NAND flash memory in an SSD generally provides a fast read (snap read) function. The main function of fast reading is to perform fast reading through a dedicated read channel when data corresponding to a read request satisfies a certain condition on data size and physical storage location, thereby providing better performance than a general read channel. The data written by the SSD may be from various sources, such as database applications, file system metadata, etc., and thus, for the write operation of the SSD, there are various different characteristics, such as the size of the data block, the logical address order, etc.
However, in the conventional SSD writing method, the probability that the data corresponding to the read request satisfies the conditions required by the fast read function is low, which results in low data read efficiency.
Disclosure of Invention
The disclosure provides a data writing method, a data writing device and data writing equipment applied to a solid state disk, and aims to solve the problem that the probability that data corresponding to a read request meets a quick read function is low in the existing writing method, so that the data reading efficiency is low.
According to a first aspect of the present application, a data writing method applied to a solid state disk is provided, including:
when the storage space occupied by the data block to be written cached in the solid state disk reaches a preset threshold value, distributing a physical storage space for the data block to be written; the physical storage space comprises at least one first storage space, and the data blocks which can be read quickly 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 distributed physical storage space;
and writing the data blocks to be written into the physical storage space according to the sequence of the rearranged data blocks to be written.
According to a second aspect of the present application, there is provided a data writing device applied to a solid state disk, including:
the allocation unit is used for allocating a physical storage space for the data block to be written when the storage space occupied by the data block to be written cached in the solid state disk reaches a preset threshold value; the physical storage space comprises at least one first storage space, and the data blocks which can be read quickly are located in the same first storage space;
the rearrangement unit is used for rearranging the data blocks to be written according to the storage space occupied by the data blocks to be written and the distributed physical storage space;
and the writing unit is used for writing the data blocks to be written into the physical storage space according to the sequence of the rearranged data blocks to be written.
According to a third aspect of the present application, there is provided an electronic device comprising a memory and a processor; wherein the content of the first and second substances,
the memory for storing a computer program;
the processor is configured to read the computer program stored in the memory, and execute the data writing method applied to the solid state disk according to the computer program in the memory.
According to a fourth aspect of the present application, there is provided a computer-readable storage medium, in which computer-executable instructions are stored, and when a processor executes the computer-executable instructions, the data writing method applied to a solid state disk according to the first aspect is implemented.
According to a fifth aspect of the present application, there is provided a computer program product comprising a computer program which, when executed by a processor, implements the data writing method applied to a solid state disk as described in the first aspect.
The data writing method, device and equipment applied to the solid state disk comprise the following steps: when the storage space occupied by the data block to be written cached in the solid state disk reaches a preset threshold value, distributing a physical storage space for the data block to be written; the physical storage space comprises at least one first storage space, and the data blocks which can be read quickly are positioned 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 distributed physical storage space; and writing the data blocks to be written into the physical storage space according to the sequence of the rearranged data blocks to be written. According to the data writing method, the data writing device and the data writing equipment applied to the solid state disk, the data blocks to be written can be rearranged first, and then the rearranged data blocks to be written can be written into the physical storage space. The data blocks to be written meeting the data volume condition of quick reading can be enabled to be written into through rearrangement, the physical storage position condition of quick reading is met, the probability of meeting the data triggering the quick reading function is improved when the data are read, and the data reading efficiency is improved.
Drawings
Fig. 1 is a schematic flowchart illustrating a data writing method applied to a solid state disk according to an exemplary embodiment of the present application;
fig. 2 is a schematic diagram illustrating a data block rearrangement method to be written according to an exemplary embodiment of the present application;
fig. 3 is a schematic flowchart illustrating a data writing method applied to a solid state disk according to another exemplary embodiment of the present application;
fig. 4 is a schematic diagram illustrating a method for determining a plurality of sub-blocks of data in valid data according to an exemplary embodiment of the present application;
FIG. 5 is a diagram illustrating padding invalid data according to an exemplary embodiment of the present application;
fig. 6 is a block diagram illustrating a data writing device applied to a solid state disk according to an exemplary embodiment of the present application;
fig. 7 is a block diagram of an electronic device according to an exemplary embodiment of the present application.
Detailed Description
A Solid State Drive (SSD), also called a solid state drive, is a hard disk made of an array of solid state electronic memory chips. NAND flash is currently the primary storage medium for SSDs. Specifically, a NAND flash memory has a plurality of Die (or LUN) connection channels, each Die has a plurality of planes (1, 2, 4 common), each Plane has a plurality of blocks, each Block has a plurality of pages, each Page corresponds to a word, and each word is composed of thousands of storage units. In the prior art, a NAND flash memory in an SSD generally provides a fast read (snap read) function. The data written by the SSD may be from various sources, such as database applications, file system metadata, etc., and thus, for the write operation of the SSD, there are various different characteristics, such as the size of the data block, the logical address order, etc.
The main function of fast reading is to perform fast reading through a dedicated read channel when data corresponding to a read request satisfies a certain condition on data size and physical storage location, thereby providing better performance than a general read channel.
However, in the conventional writing method, the probability that the data corresponding to the read request satisfies the conditions required by the fast read function is low, which results in low data read efficiency.
In order to solve the above technical problem, according to the scheme provided by the present disclosure, the data blocks to be written may be rearranged first, and then the rearranged data blocks to be written may be written into the physical storage space. The data blocks to be written satisfying the fast read data amount condition can be made to satisfy the fast read physical storage location condition by rearrangement. Therefore, when data are read, the probability of triggering the data with the quick reading function is improved, and the data reading efficiency is improved.
Fig. 1 is a schematic flowchart of a data writing method applied to a solid state disk according to an exemplary embodiment of the present application.
As shown in fig. 1, the data writing method applied to the solid state disk provided in this embodiment includes:
step 101, when a storage space occupied by a data block to be written cached in a solid state disk reaches a preset threshold, allocating a physical storage space for the data block to be written; the physical storage space comprises at least one first storage space, and the data blocks capable of being read quickly are located in the same first storage space.
The scheme provided by the disclosure can be executed by a solid state disk. When the storage space occupied by the data block to be written cached in the solid state disk reaches a preset threshold value, the solid state disk may allocate a physical storage space for the data block to be written, where the allocated physical storage space includes at least one first storage space.
Among them, a Solid State Drive (SSD), also called a solid state drive, is a hard disk manufactured by using a solid state electronic memory chip array.
When data is written into the solid state disk, the solid state disk generally caches data blocks of the data to be written, and the cached data blocks to be written are written into a physical space of the solid state disk together after reaching a certain number.
The data block to be written in the cache may be written into a physical space of the hard disk when the cached data block to be written reaches a preset threshold, where the preset threshold is a storage space threshold preset according to an actual situation, and may be, for example, 32 KB.
When the data blocks to be written are written into the solid state disk, physical storage space can be allocated for the data blocks to be written. Specifically, during allocation, allocation may be performed according to the management granularity of the storage space of the solid state disk, for example, a plurality of first storage spaces may be allocated, where the first storage space refers to the management granularity of the solid state disk and may be, for example, a page.
The solid state disk has a quick reading function, and the NAND flash memory in the solid state disk can provide the function.
The fast reading function is that when data corresponding to a read request meets certain conditions on data volume and physical storage position, the data can be read fast through a special reading channel, so that better performance is provided than that of a general reading channel. The data size of the data satisfying the fast reading function may be 4KB, 8KB, or the like; and the data blocks can be read quickly when being located in the same first storage space.
For example, if there is a data block with a size of 8KB in the same first storage space, the data block can be read quickly; if there is another data block of size 8KB which spans the two first memory spaces, the data block cannot be read quickly.
The physical storage space allocated by the solid state disk for the data block to be written may be 32KB or 64 KB.
And 102, rearranging the data blocks to be written according to the storage space occupied by the data blocks to be written and the distributed physical storage space.
Specifically, before storing each data block to be written in the physical storage space, the data blocks to be written in may be rearranged, so that as many data blocks to be written as possible that satisfy the data volume condition of the fast read function also satisfy the fast read function at the physical storage location when writing in the solid state disk. Therefore, when the data block is read, the quick reading function can be utilized, and the reading efficiency is further improved.
Further, by rearranging as many data blocks to be written as possible are located in one first storage space, rather than across multiple first storage spaces, the data blocks to be written can satisfy the fast reading condition.
The storage space occupied by each data block to be written may be, for example, 4KB or 8 KB.
The allocated physical memory space may be 32KB or 64 KB.
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 comprise at least one first storage space, and the size of each first storage space is fixed, so that a plurality of data blocks to be written, the sum of the occupied storage spaces of which is the same as the size of the first storage space, can be rearranged according to the storage space occupied by each data block to be written, and then the remaining data blocks to be written, the sum of the storage spaces of which 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 the data blocks can be read in a fast reading mode when the data blocks need to be read subsequently.
Specifically, if the size of the data block to be written that can be quickly read has a certain requirement, in order to prevent more data blocks to be written that satisfy the size condition from spanning multiple first storage spaces when being stored, the storage space occupied by each data block to be written may also be obtained, and the data block in which the storage space satisfies the data amount condition in the quick reading condition may be determined.
In the rearrangement, it is possible to prioritize the arrangement of the data blocks at the position corresponding to one first storage space, and for the data blocks whose storage spaces do not satisfy the data amount condition in the fast reading condition, the data blocks can be used to fill the vacant positions.
For example, a first storage space is 16KB in size, and 2 first storage spaces are allocated for storing the cached data block to be written. The size of the data block to be written is 8KB, 5KB, 4KB, 3KB, 8KB, respectively. If the data size of the data satisfying the fast read function is 4KB and 8KB, all the data blocks to be written are likely to be fast read. The data blocks may be first located in a separate first storage space. For example, 8KB or 8KB data blocks may be arranged in a position corresponding to the first memory space, and 4KB or 4KB data blocks may be arranged in a position corresponding to the other first memory space. Since one memory space is 16KB in size, the corresponding location of the first memory space is full, and the other memory space has the remaining locations, the 5KB or 3KB data block is arranged in the corresponding location of the other memory space, and specifically, the data block can be arranged behind the 4KB or 4KB data block.
As shown in fig. 2, the data blocks to be written cached in the cache unit of the solid state disk are sequentially 4KB, 8KB, and 4KB, and totally 32KB, if the physical space allocated by the solid state disk for the 32KB data is two complete 16KB spaces, before the rearrangement, the distribution of the 32KB data in the physical address space is as shown in the upper part of fig. 2, and at this time, the middle 8KB data cannot be read quickly; after rearrangement, the 32KB data can be distributed in the physical space as shown in the lower part of fig. 2, and all the data blocks to be written can be read in a fast reading mode.
And 103, writing the data blocks to be written into the physical storage space according to the sequence of the rearranged data blocks to be written.
Specifically, the solid state disk may write the data blocks to be written into the physical storage space in the solid state disk according to the sequence of the data blocks to be written after rearrangement.
For example, as shown in fig. 2, after the rearrangement, the order of the data blocks to be written is as shown in the lower part of fig. 2, and according to the order, the data blocks to be written are written into the physical storage space in the solid state disk. By this implementation, when reading each data block in the 32KB, each data block in the 32KB satisfies the condition of fast reading, and can be fast read.
If the data blocks to be written are not rearranged during data writing, such as the 8KB data block spanning two 16KB data blocks shown in the upper part of fig. 2, the 8KB data block cannot be read quickly because it does not satisfy the condition of quick reading.
Therefore, the method provided by the scheme can improve the probability of meeting the requirement of triggering the data with the quick reading function, and further improve the data reading efficiency.
The data writing method applied to the solid state disk comprises the following steps: when the storage space occupied by the data block to be written cached in the solid state disk reaches a preset threshold value, distributing a physical storage space for the data block to be written; the physical storage space comprises at least one first storage space, and the data blocks which can be read quickly are positioned 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 distributed physical storage space; and writing the data blocks to be written into the physical storage space according to the sequence of the rearranged data blocks to be written. According to the scheme provided by the disclosure, the data blocks to be written can be rearranged first, and then the rearranged data blocks to be written are written into the physical storage space. The data blocks to be written meeting the data volume condition of quick reading can be enabled to be rearranged, meanwhile, the physical storage position condition of quick reading is met, and therefore the probability of meeting the data triggering the quick reading function is improved when data are read, and the data reading efficiency is improved.
Fig. 3 is a flowchart illustrating a data writing method applied to a solid state disk according to another exemplary embodiment of the present application.
As shown in fig. 3, the data writing method applied to the solid state disk provided in this embodiment includes:
step 301, a write request for performing a write operation on a data block to be written is obtained.
Specifically, the solid state disk may obtain a write request for performing a write operation on a data block to be written.
The write request can be generated in two ways, one of which can be generated by a host end; the other type can be generated by the solid state disk when the data is migrated.
Optionally, the solid state disk 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 side and the solid state disk, and operate the host side to write data into the solid state disk. For example, a file stored in the host side may be imported into the solid state disk, and a write request may be sent thereto.
In another case, when data migration is performed inside the solid state disk, a write request for performing a write operation is also generated, for example, when operations such as garbage collection and wear leveling are performed inside the solid state disk, a system provided in the solid state disk generates the write request.
In this implementation manner, the solid state disk may further obtain a write request for performing a write operation on the data block to be written, which is generated when the data is migrated.
Step 302, caching the data block to be written according to the write request.
Specifically, the solid state disk may cache the data block to be written according to the write request.
Optionally, if the obtained write request is sent by the host side and the solid state disk has a transparent compression function, transparently compressing the data block to be written according to the write request;
wherein transparent compression means compression is transparent to the user.
And caching the compressed data block to be written.
For example, if the data to be written occupying the 8KB storage space is 5KB after transparent compression, the data block cached by the cache unit of the solid state disk is the compressed data block to be written of 5 KB.
Specifically, if the write request acquired by the solid state disk is sent by the host side and the solid state disk has a transparent compression function, the solid state disk firstly performs transparent compression on a data block to be written according to the write request; and then caching the compressed data block to be written.
Optionally, if the obtained write request is generated when the solid state disk migrates data, obtaining a physical address of a physical storage space before data migration according to the write request;
specifically, the solid state disk records the use conditions of each physical space in the solid state disk, and can generate a write request for performing migration in the solid state disk on data according to the use conditions of each physical space. The write request may include a physical address of the physical storage space before data migration; the solid state disk can acquire the physical address according to the write request.
Determining effective data to be migrated and a logical address corresponding to the effective data according to a physical storage space before data migration and an address mapping table; the address mapping table records the corresponding relation between the logical address and the physical address of the effective data;
the valid data may refer to data that is not deleted or changed and is stored in the physical storage space before migration.
Specifically, the solid state disk may query the address mapping table according to the obtained physical address of the physical storage space before migration, to obtain a current logical address corresponding to the physical address of the physical storage space before migration; and the current logical address corresponds to the data stored in the physical storage space before the current migration. The logical address of the last write of the data can be obtained according to the physical storage space before migration. Then comparing whether the logic address written last time is consistent with the current logic address; and if the comparison result is consistent, determining that the data stored in the physical storage space before migration is valid data needing migration. And determining the current logical address as the logical address corresponding to the valid data.
Determining a plurality of first data sub-blocks in the effective data according to the logic address and the bit map of the effective data, and caching the first data sub-blocks; the bit map records the corresponding relation between the logical address of the effective data and the label; wherein the label comprises a first label and a second label.
The storage space of one data sub-block may be 4 KB. A first sub-block of data may include one or more sub-blocks of data.
Wherein, the first label can be represented as 1; the second label may be denoted as 0.
In particular, the bitmap may be used to indicate the continuity of the data blocks to be written at the physical addresses. When the solid state disk internally migrates data (such as garbage collection, wear leveling and other operations), the solid state disk can be migrated in combination with the bitmap to maximize the fast reading probability of the data.
Specifically, the logical address of each data sub-block corresponds to one tag, for the logical address of the first data sub-block newly written at one time, the tag corresponding to the logical address of the first data sub-block may be a first tag and may be represented as 1, and the tag corresponding to the logical address of the data sub-block included in the subsequent write request may be a second tag and may be represented as 0. For example, for a 16KB write request, the tag sequence in the bitmap corresponding to the write request may be 1000 after the write is completed; if the data sub-block in a certain original data block is updated, the updated data sub-block part changes the bitmap according to the above criteria, and if valid data still exists in the original data block after the updated data sub-block part, the tag corresponding to the logical address of the first data sub-block after the updated data sub-block part is also set to 1.
Optionally, determining each tag corresponding to the logical address according to the logical address of the valid data and the bit map; the labels comprise a first label and a second label;
if the first label is followed by at least one second label continuously, determining the data corresponding to the logical address of the first label corresponding to the continuous at least one second label as a first data sub-block;
and if the first label is followed by another first label continuously, determining that the data corresponding to the logical address corresponding to the first label is a first data sub-block.
For example, as shown in fig. 4, the original tag sequence is 1000 for a 16KB data block (LBA0-LBA3), and when LBA1 is updated, the updated tag sequence is 1110. The data block includes two first sub-blocks of data, where the data in LBA0 is one first sub-block of data; the data in LBA2-LBA3 is a first sub-block of data.
Specifically, the solid state disk may use each first data subblock as a data block to be written in, and cache a plurality of first data subblocks.
Specifically, in this way, the data in the LBAs 2-3 can be cached as one data block to be written, and the data in the LBAs 2 and the LBAs 3 do not need to be divided into two data blocks to be written for caching, so that fast reading can be performed conveniently.
Step 303, when a storage space occupied by a to-be-written data block cached in the solid state disk reaches a preset threshold, allocating a physical storage space for the to-be-written data block; the physical storage space comprises at least one first storage space, and the data blocks capable of being read quickly are located in the same first storage space.
Specifically, the principle and implementation manner of step 303 are similar to those of step 101, and are not described again.
Step 304, if the storage space occupied by the data block to be written meets the fast reading condition; and determining a plurality of continuous data blocks to be written according to the storage space occupied by each data block to be written, wherein the sum of the storage spaces of the plurality of continuous data blocks to be written is less than or equal to the space of one first storage space, and the difference between the sum of the storage spaces of the plurality of continuous data blocks to be written and the space of one first storage space is less than the storage space occupied by any other data block to be written except the plurality of continuous data blocks to be written.
Specifically, before storing each data block to be written in the physical storage space, the data blocks to be written in may be rearranged, so that as many data blocks to be written as possible that satisfy the data volume condition of the fast read function also satisfy the fast read function at the physical storage location when writing in the solid state disk. Therefore, when the data block is read, the quick reading function can be utilized, and the reading efficiency is further improved.
Further, by rearranging, as many data blocks to be written as possible are located in one first storage space, rather than across multiple first storage spaces, so that the data blocks to be written can satisfy the fast reading condition.
Step 305, continuously determining a plurality of continuous data blocks to be written in the remaining other data blocks to be written, and arranging the plurality of continuous data blocks to be written which are determined later after the plurality of continuous data blocks to be written which are determined last time until the data blocks to be written are rearranged.
Optionally, the solid state disk has a transparent compression function; if the sum of the storage spaces occupied by the multiple continuous data blocks to be written determined at the previous time is smaller than the space of one first storage space, and the space difference between the sum of the storage spaces occupied and the space of one first storage space is smaller than a preset threshold, filling invalid data after the multiple continuous data blocks to be written, wherein the sum of the space occupied by the multiple continuous data blocks to be written and the space occupied by the invalid data is equal to the space of one first storage space;
the preset threshold is a threshold preset according to actual conditions. For example, the preset threshold may be 500B.
The filled invalid data may be, for example, all 0 s.
Specifically, for a solid state disk with a transparent compression function, when the remaining space of a certain first storage space is small and is not enough to fill a data block to be written, which satisfies the fast reading size condition, invalid data may be filled in the corresponding remaining space, and a new first storage space is used to store the data block, which satisfies the fast reading size condition. As shown in fig. 5, the previous 16KB physical space is nearly full (300B space remained), and if the preset threshold is 500B, a data block of 3KB after compression is filled into the next 16KB, and the remaining space of 16KB is filled with invalid data (e.g. all 0 data) of 300B; if a certain data block to be written is 280B after compression, the remaining space of 300B can still be filled.
And arranging the plurality of continuous data blocks to be written which are determined later behind the invalid data of the plurality of continuous data blocks to be written which are determined last time.
And step 306, writing the data blocks to be written into the physical storage space according to the rearranged sequence of the data blocks to be written.
Specifically, after step 306 is executed, step 307 and step 308 are executed.
Specifically, step 306 is similar to step 103 in principle and implementation, and is not described again.
Step 307, updating an address mapping table according to the physical storage space written by each data block to be written and the logical address of the data block to be written; the address mapping table records the corresponding relationship between the logical address of each data block to be written and the physical address of the physical storage space.
Further, if the data stored in the physical storage space is deleted or updated, the address mapping table is updated accordingly.
Step 308, updating the bitmap according to the logic address of each data block to be written; wherein, the bit map records the corresponding relation between the logical address of each data block to be written and the label; wherein the label comprises a first label and a second label; the data block to be written comprises a plurality of data sub-blocks, wherein the first data sub-block corresponds to the first label, and the rest data sub-blocks correspond to the second label.
The storage space of one data sub-block may be 4 KB.
Wherein, the first label can be represented as 1; the second label may be represented as 0.
In particular, the bitmap may be used to indicate the continuity of the data blocks to be written at the physical addresses. When the solid state disk internally migrates data (such as garbage collection, wear leveling and other operations), the purpose of rapid migration can be achieved by combining the bitmap.
Fig. 6 is a structural diagram of a data writing device applied to a solid state disk according to an exemplary embodiment of the present application.
As shown in fig. 6, the data writing device 600 applied to the solid state disk provided in the present application includes:
the allocation unit 610 is configured to allocate a physical storage space to the data block to be written when a storage space occupied by the data block to be written cached in the solid state disk reaches a preset threshold; the physical storage space comprises at least one first storage space, and the data blocks which can be read quickly are positioned in the same first storage space;
a rearranging 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;
and a writing unit 630, configured to write the data blocks to be written into the physical storage space according to the rearranged sequence of the data blocks to be written.
If the storage space occupied by the data block to be written meets the quick reading condition; a rearranging unit 620, configured to determine a plurality of consecutive data blocks to be written according to a storage space occupied by each data block to be written, where a sum of storage spaces of the plurality of consecutive data blocks to be written is smaller than or equal to a space of one first storage space, and a difference between the sum of storage spaces of the plurality of consecutive data blocks to be written and the space of one first storage space is smaller than a storage space occupied by any other data block to be written other than the plurality of consecutive data blocks to be written; and continuously determining a plurality of continuous data blocks to be written in the rest other data blocks to be written, arranging the plurality of continuous data blocks to be written which are determined later after the plurality of continuous data blocks to be written which are determined at the previous time, and arranging the plurality of continuous data blocks to be written till the data blocks to be written are rearranged completely.
The solid state disk has a transparent compression function; if the sum of the storage spaces occupied by the plurality of continuous data blocks to be written determined at the previous time is smaller than the space of one first storage space, and the size of the space difference between the sum of the storage spaces occupied and the space of one first storage space is smaller than the preset threshold, the rearrangement unit 620 is specifically configured to fill invalid data after the plurality of continuous data blocks to be written, where the sum of the spaces occupied by the plurality of continuous data blocks to be written and the space occupied by the invalid data is equal to the space of one first storage space; and arranging the plurality of continuous data blocks to be written which are determined later behind the invalid data of the plurality of continuous data blocks to be written which are determined last time.
The application provides a be applied to data write device 600 of solid state hard drives, still includes:
an address mapping table updating unit 640, configured to update the address mapping table according to the physical storage space written by each data block to be written and the logical address of the data block to be written; wherein, the address mapping table records the corresponding relationship between the logical address of each data block to be written and the physical address of the physical storage space;
a bitmap updating unit 650 for updating the bitmap according to the logical address of each data block to be written; wherein, the bit map records the corresponding relation between the logic address of each data block to be written and the label; wherein the label comprises a first label and a second label; the data block to be written comprises a plurality of data sub-blocks, wherein the first data sub-block corresponds to the first label, and the rest data sub-blocks correspond to the second label;
an obtaining unit 660, configured to obtain a write request for performing a write operation on a data block to be written;
and the cache unit 670 is configured to cache the data block to be written according to the write request.
An obtaining unit 660, specifically configured to obtain a write request sent by a host for performing a write operation on a data block to be written;
and/or acquiring a write request which is generated by the solid state disk during data migration and is used for performing write operation on the data block to be written.
If the obtained write request is sent by the host side and the solid state disk has a transparent compression function, the cache unit 670 is specifically configured to transparently compress the data block to be written according to the write request;
and caching the compressed data block to be written.
If the obtained write request is generated when the solid state disk migrates data, the cache unit 670 is specifically configured to obtain a physical address of a physical storage space before data migration according to the write request;
determining effective data to be migrated and a logical address corresponding to the effective data according to a physical storage space before data migration and an address mapping table; the address mapping table records the corresponding relation between the logical address and the physical address of the effective data;
determining a plurality of first data sub-blocks in the effective data according to the logic address and the bitmap of the effective data, and caching the first data sub-blocks; the bit map records the corresponding relation between the logical address of the effective data and the label; wherein the label comprises a first label and a second label.
A buffer unit 670, configured to determine, according to the logical address and the bitmap of the valid data, each tag corresponding to the logical address; the labels comprise a first label and a second label;
if the first label is followed by at least one second label, determining data corresponding to the logical addresses corresponding to the first label and the at least one second label as a first data sub-block;
and if the first label is followed by another first label continuously, determining that the data corresponding to the logical address corresponding to the first label is a first data sub-block.
Fig. 7 is a block diagram of an electronic device according to an exemplary embodiment of the present application.
As shown in fig. 7, the electronic device provided in this embodiment includes:
a memory 701;
a processor 702; and
a computer program;
wherein the computer program is stored in the memory 701 and configured to be executed by the processor 702 to implement the data writing method applied to the solid state disk as any of the above.
The present embodiment also provides a computer-readable storage medium having a computer program stored thereon, the computer program being executed by a processor to implement any of the above data writing methods applied to a solid state disk.
The embodiment also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the computer program implements any one of the above data writing methods applied to the solid state disk.
Those of ordinary skill in the art will understand that: all or a portion of the steps of implementing the above-described method embodiments may be performed by hardware associated with program instructions. The program may be stored in a computer-readable storage medium. When executed, the program performs steps comprising the method embodiments described above; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.

Claims (14)

1. A data writing method applied to a solid state disk is characterized by comprising the following steps:
when the storage space occupied by the data block to be written cached in the solid state disk reaches a preset threshold value, distributing a physical storage space for the data block to be written; the physical storage space comprises at least one first storage space, and the data blocks which can be read quickly are positioned 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 distributed physical storage space;
and writing the data blocks to be written into the physical storage space according to the sequence of the rearranged data blocks to be written.
2. The method according to claim 1, wherein if the storage space occupied by the data block to be written satisfies a fast reading condition;
the rearranging of the data blocks to be written according to the storage space occupied by the data blocks to be written and the distributed physical storage space comprises:
determining a plurality of continuous data blocks to be written according to the storage space occupied by each data block to be written, wherein the sum of the storage spaces of the plurality of continuous data blocks to be written is less than or equal to the space of one first storage space, and the difference between the sum of the storage spaces of the plurality of continuous data blocks to be written and the space of one first storage space is less than the storage space occupied by any other data block to be written except the plurality of continuous data blocks to be written;
and continuously determining a plurality of continuous data blocks to be written in the rest other data blocks to be written, arranging the plurality of continuous data blocks to be written which are determined later after the plurality of continuous data blocks to be written which are determined at the previous time, and arranging the plurality of continuous data blocks to be written till the data blocks to be written are rearranged completely.
3. The method of claim 2, wherein the solid state disk is provided with a transparent compression function; if the sum of the storage spaces occupied by the plurality of continuous data blocks to be written determined at the previous time is smaller than the space of one first storage space, and the size of the space difference between the sum of the occupied storage spaces and the space of one first storage space is smaller than a preset threshold, arranging the plurality of continuous data blocks to be written determined at the next time behind the plurality of continuous data blocks to be written determined at the previous time, including:
filling invalid data after a plurality of continuous data blocks to be written, wherein the sum of the space occupied by the continuous data blocks to be written and the space occupied by the invalid data is equal to the space of a first storage space;
and arranging the plurality of continuous data blocks to be written which are determined later behind the invalid data of the plurality of continuous data blocks to be written which are determined last time.
4. The method of claim 1, wherein after writing each of the data blocks to be written into the physical storage space, further comprising:
updating an address mapping table according to the physical storage space written by each data block to be written and the logic address of the data block to be written; wherein, the address mapping table records the corresponding relationship between the logical address of each data block to be written and the physical address of the physical storage space.
5. The method of claim 1, wherein after writing each of the data blocks to be written into the physical storage space, further comprising:
updating a bit map according to the logic address of each data block to be written; wherein, the bit map records the corresponding relationship between the logical address and the label of each data block to be written; wherein the tag comprises a first tag and a second tag; the data block to be written comprises a plurality of data sub-blocks, wherein a first data sub-block corresponds to the first label, and the rest data sub-blocks correspond to the second label.
6. The method of claim 1, further comprising:
acquiring a write request for performing write operation on the data block to be written;
and caching the data block to be written according to the write request.
7. The method of claim 6, wherein obtaining the write request for writing the data block to be written comprises:
acquiring a write-in request which is sent by a host and used for performing write-in operation on the data block to be written;
and/or acquiring a write-in request which is generated when the solid state disk transfers data and is used for performing write-in operation on the data block to be written.
8. The method according to any one of claims 6 or 7, wherein if the obtained write request is sent by a host and the solid state disk has a transparent compression function, the caching the data block to be written according to the write request includes:
performing transparent compression on the data block to be written according to the writing request;
and caching the compressed data block to be written.
9. The method according to any one of claims 6 or 7, wherein if the obtained write request is generated by the solid state disk during data migration, the caching the data block to be written according to the write request includes:
acquiring a physical address of a physical storage space before data migration according to the write-in request;
determining effective data to be migrated and a logical address corresponding to the effective data according to the physical storage space before data migration and an address mapping table; the address mapping table records the corresponding relation between the logical address and the physical address of the effective data;
determining a plurality of first data sub-blocks in the effective data according to the logic address and the bitmap of the effective data, and caching the first data sub-blocks; the bit map records the corresponding relation between the logic address of the effective data and the label; wherein the tag comprises a first tag and a second tag.
10. The method of claim 9, wherein the determining the plurality of first data sub-blocks in the valid data according to the logical address of the valid data and the bitmap comprises:
determining each label corresponding to the logic address according to the logic address and the bit map of the effective data; the labels comprise a first label and a second label;
if the first label is followed by at least one second label, determining the data corresponding to the logical address corresponding to the first label and the continuous at least one second label as a first data sub-block;
and if the first label is followed by another first label continuously, determining that the data corresponding to the logical address corresponding to the first label is a first data sub-block.
11. A data writing device applied to a solid state disk is characterized by comprising:
the allocation unit is used for allocating a physical storage space for the data block to be written when the storage space occupied by the data block to be written cached in the solid state disk reaches a preset threshold value; the physical storage space comprises at least one first storage space, and the data blocks which can be read quickly are located in the same first storage space;
the rearrangement unit is used for rearranging the data blocks to be written according to the storage space occupied by the data blocks to be written and the distributed physical storage space;
and the writing unit is used for writing the data blocks to be written into the physical storage space according to the rearranged sequence of the data blocks to be written.
12. An electronic device comprising a memory and a processor; wherein the content of the first and second substances,
the memory for storing a computer program;
the processor is configured to read the computer program stored in the memory and execute the method of any one of claims 1 to 10 according to the computer program in the memory.
13. A computer-readable storage medium having computer-executable instructions stored thereon which, when executed by a processor, implement the method of any one of claims 1-10.
14. A computer program product comprising a computer program, characterized in that the computer program, when being executed by a processor, carries out the method of any one of the preceding claims 1-10.
CN202210186790.1A 2022-02-28 2022-02-28 Data writing method, device and equipment applied to solid state disk Pending CN114625318A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210186790.1A CN114625318A (en) 2022-02-28 2022-02-28 Data writing method, device and equipment applied to solid state disk

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210186790.1A CN114625318A (en) 2022-02-28 2022-02-28 Data writing method, device and equipment applied to solid state disk

Publications (1)

Publication Number Publication Date
CN114625318A true CN114625318A (en) 2022-06-14

Family

ID=81900478

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210186790.1A Pending CN114625318A (en) 2022-02-28 2022-02-28 Data writing method, device and equipment applied to solid state disk

Country Status (1)

Country Link
CN (1) CN114625318A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116737064A (en) * 2023-03-29 2023-09-12 深圳市领德创科技有限公司 Data management method and system for solid state disk

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116737064A (en) * 2023-03-29 2023-09-12 深圳市领德创科技有限公司 Data management method and system for solid state disk
CN116737064B (en) * 2023-03-29 2024-04-05 深圳市领德创科技有限公司 Data management method and system for solid state disk

Similar Documents

Publication Publication Date Title
US9229876B2 (en) Method and system for dynamic compression of address tables in a memory
KR102042643B1 (en) Managing multiple namespaces in a non-volatile memory (nvm)
CN109690681B (en) Data processing method, storage device, solid state disk and storage system
JP6553566B2 (en) Memory system and control method
US11928053B2 (en) System garbage collection method and method for garbage collection in solid state disk
KR102603070B1 (en) Memory system, a method of writing data to the memory system, and a method of reading data from the memory system
JP2019020788A (en) Memory system and control method
US11321229B2 (en) System controller and system garbage collection method
KR20070060070A (en) Fat analysis for optimized sequential cluster management
KR20100139149A (en) Method and system for storage address re-mapping for a multi-bank memory device
CN106970765B (en) Data storage method and device
US11397669B2 (en) Data storage device and non-volatile memory control method
JP6139711B2 (en) Information processing device
KR101017067B1 (en) Locality-Aware Garbage Collection Technique for NAND Flash Memory-Based Storage Systems
JPWO2017068904A1 (en) Storage system
KR102347841B1 (en) Memory management apparatus and control method thereof
US20190243758A1 (en) Storage control device and storage control method
US11307979B2 (en) Data storage device and non-volatile memory control method
EP3798852B1 (en) System controller and system garbage recovery method
CN114625318A (en) Data writing method, device and equipment applied to solid state disk
KR100745163B1 (en) Method for managing flash memory using dynamic mapping table
US11748023B2 (en) Data storage device and non-volatile memory control method
CN112162703B (en) Cache implementation method and cache management module
KR20100056685A (en) Method and device for managing solid state drive
KR20210089055A (en) Flash memory storage with improved erase performance and method thereof

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination