CN110389712B - Data writing method and device, solid state disk and computer readable storage medium - Google Patents

Data writing method and device, solid state disk and computer readable storage medium Download PDF

Info

Publication number
CN110389712B
CN110389712B CN201810362066.3A CN201810362066A CN110389712B CN 110389712 B CN110389712 B CN 110389712B CN 201810362066 A CN201810362066 A CN 201810362066A CN 110389712 B CN110389712 B CN 110389712B
Authority
CN
China
Prior art keywords
data
storage
data block
physical storage
storage area
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.)
Active
Application number
CN201810362066.3A
Other languages
Chinese (zh)
Other versions
CN110389712A (en
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.)
Hangzhou Haikang Storage Technology Co ltd
Original Assignee
Hangzhou Haikang Storage 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 Hangzhou Haikang Storage Technology Co ltd filed Critical Hangzhou Haikang Storage Technology Co ltd
Priority to CN201810362066.3A priority Critical patent/CN110389712B/en
Publication of CN110389712A publication Critical patent/CN110389712A/en
Application granted granted Critical
Publication of CN110389712B publication Critical patent/CN110389712B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • G06F12/0238Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory
    • G06F12/0246Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory in block erasable memory, e.g. flash memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • G06F12/0253Garbage collection, i.e. reclamation of unreferenced memory
    • 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 invention discloses a data writing method, a data writing device solid state disk and a computer readable storage medium, wherein the data writing method is applied to the solid state disk, the solid state disk comprises a plurality of physical storage areas, each physical storage area comprises a plurality of data blocks, the plurality of data blocks comprise storage data blocks and reserved data blocks, and the method comprises the following steps: when at least one reserved data block in the physical storage area is fully written with data, determining the quantity of valid data in each storage data block of the physical storage area; judging whether a storage data block with the quantity of the valid data being zero exists in the physical storage area or not; and if so, erasing all data in the storage data block with the quantity of the valid data in the physical storage area being zero. The method has high data writing speed and is particularly suitable for the field of video monitoring.

Description

Data writing method and device, solid state disk and computer readable storage medium
Technical Field
The present invention relates to the field of data processing technologies, and in particular, to a data writing method, a data writing device, a solid state disk, and a computer-readable storage medium.
Background
A Solid State Drive (SSD) is a hard disk made of an array of Solid State electronic memory chips.
The Solid State Disk (SSD) generally comprises a plurality of logical storage units and physical storage units, wherein the physical storage units can adopt nonvolatile storage media, the physical storage units are generally divided into a plurality of data blocks for storing data, the client side can comprise a plurality of logical storage units, the logical addresses of the logical storage units and the physical addresses of the data blocks have a mapping relation, a write command from the upper layer client side carries the logical addresses and data to be written, corresponding physical addresses can be searched in the mapping relation according to the logical addresses, and the data to be written are written into the data blocks corresponding to the physical addresses, so that data writing is realized.
In order to increase the data writing speed, the physical memory unit is generally divided into a plurality of channels, each channel including a plurality of data blocks, and parallel writing may be performed for the plurality of channels, for example, data to be written may be divided into a plurality of portions and written in the data block of each channel.
For each channel, when the space in which data is written in each data block in the channel occupies a certain proportion of the storage space of the entire channel (i.e., the total storage space of all data blocks in the channel), a Garbage Collection operation (GC) needs to be performed, that is, valid data in a part of data blocks is read out, then the read valid data in one block is written into other blank data blocks, and then the data in the data block in which the valid data is located is erased, and the data block can be rewritten as a blank data block.
When data to be written are required to be written into data blocks of the channels respectively, some channels may need to perform garbage collection operation, and some channels do not need to perform garbage collection operation, so that data written into the channels are inconsistent, the overall writing speed of the data is affected, and the writing speed of the data is slow.
Disclosure of Invention
The invention provides a data writing method, a data writing device, a solid state disk and a computer readable storage medium, which aim to solve the defects in the related art.
According to a first aspect of the embodiments of the present invention, a data writing method is provided, which is applied to a solid state disk, where the solid state disk includes a plurality of physical storage areas, each physical storage area includes a plurality of data blocks, and the plurality of data blocks include storage data blocks and reserved data blocks; the method comprises the following steps:
when at least one reserved data block in the physical storage area is fully written with data, determining the quantity of valid data in each storage data block of the physical storage area;
judging whether a storage data block with the quantity of the valid data being zero exists in the physical storage area or not;
if yes, erasing all data in the storage data block with the quantity of the valid data in the physical storage area being zero.
Optionally, the method further includes:
if the physical storage area does not have the storage data block with the quantity of the valid data being zero, reading the valid data in part of the storage data blocks of the physical storage area;
correspondingly writing the read effective data into a reserved data block of a physical storage area where a storage data block for reading the part of effective data is located;
and erasing all data in each read partial storage data block.
Optionally, the reading valid data in the partial storage data block of each physical storage area includes:
respectively determining a storage data block with the minimum number of effective data in each storage data block of each physical storage area, and taking the storage data block as a source storage data block;
and respectively reading valid data in each source storage data block.
Optionally, before the correspondingly writing the read valid data into the reserved data block of the physical storage area where the storage data block that reads the part of valid data is located, the method further includes:
judging whether the total amount of the read valid data is larger than or equal to a writing amount threshold value or not;
if yes, correspondingly writing the read effective data into a reserved data block of a physical storage area where a storage data block for reading the part of effective data is located;
and if not, executing the step of reading the valid data in the partial storage data blocks of the physical storage areas.
Optionally, the respectively reading the valid data in each source storage data block includes:
sequentially and respectively reading each page of data in each source storage data block by taking a page as a unit;
judging whether the data of each read page is valid data or not;
if yes, executing the step of judging whether the total quantity of the read valid data is larger than or equal to a writing quantity threshold value;
if not, the step of respectively reading each page of data in each source storage data block by taking the page as the unit sequence is executed.
Optionally, the writing the read valid data into the reserved data block of the physical storage area where the storage data block that reads the part of valid data is located correspondingly includes:
and correspondingly writing the read effective data into a blank storage space of a reserved data block in a storage chip where the storage data block reading the part of effective data is located, and writing the rest part of effective data into reserved data blocks of other storage chips in a physical storage area where the storage data block reading the part of effective data is located after the blank storage space of the reserved data block is full.
According to a second aspect of the embodiments of the present invention, there is provided a data writing apparatus, applied to a solid state disk, where the solid state disk includes a plurality of physical storage areas, each physical storage area includes a plurality of data blocks, and the plurality of data blocks include a storage data block and a reserved data block; the device includes:
an effective data amount determining unit, configured to determine, when all of at least one reserved data block in the physical storage area is full of data, an amount of effective data in each storage data block of the physical storage area;
a valid data amount judgment unit configured to judge whether there is a storage data block in the physical storage area, where the number of valid data is zero;
and the first data erasing unit is used for erasing all data in the storage data block with the quantity of the valid data being zero in the physical storage area when the storage data block with the quantity of the valid data being zero in the physical storage area is judged to exist.
Optionally, the method further includes:
the valid data reading unit is used for reading the valid data in the partial storage data blocks of each physical storage area when judging that no storage data blocks with the number of the valid data being zero exist in the physical storage area;
the valid data writing determining unit is used for correspondingly writing the read valid data into a reserved data block of a physical storage area where a storage data block for reading the part of valid data is located;
and the second data erasing unit is used for erasing all data in each read partial storage data block.
Optionally, the valid data reading unit is specifically configured to:
respectively determining a storage data block with the minimum number of effective data in each storage data block of each physical storage area, and taking the storage data block as a source storage data block;
and respectively reading valid data in each source storage data block.
Optionally, the method further includes:
a valid data number judgment unit for judging whether the total number of the read valid data is greater than or equal to a write number threshold;
if yes, correspondingly writing the read effective data into a reserved data block of a physical storage area where a storage data block for reading the part of effective data is located;
if not, the step of reading the effective data in the partial storage data blocks of the physical storage areas is executed.
According to a third aspect of embodiments of the present invention, there is provided a solid state disk comprising a processor, a machine-readable storage medium and a physical storage medium, the physical storage medium comprising a plurality of physical storage areas, each physical storage area comprising a plurality of data blocks, the plurality of data blocks comprising a storage data block and a reserved data block, the machine-readable storage medium storing machine-executable instructions executable by the processor, the processor being caused by the machine-executable instructions to perform any of the methods described above.
According to a fourth aspect of embodiments of the present invention, there is provided a computer-readable storage medium, on which a computer program is stored, which when executed by a processor, implements any of the methods described above.
According to the technical scheme, when the solid state disk is in the full disk state or close to the full disk state, the data writing method clears the storage data block when the storage data block with the number of the effective data being zero exists, and the data can be rewritten and written as the blank data block, so that garbage collection operation is not needed, the data writing speed of each physical storage area is consistent, the overall data writing speed is not affected, and the data writing speed is high.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention, as claimed.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention.
Fig. 1 is a schematic structural diagram of a physical storage unit in a solid state disk provided in the related art;
FIG. 2 is a flowchart illustrating a data writing method according to an embodiment of the present invention;
FIG. 3 is a schematic block diagram of a storage system including a solid state disk according to an embodiment of the present invention;
FIG. 4 is a flowchart illustrating a data writing method according to another embodiment of the present invention;
FIG. 5 is a flowchart illustrating a data writing method according to another embodiment of the present invention;
FIG. 6 is a flowchart illustrating a data writing method according to another embodiment of the present invention;
FIG. 7 is a flowchart of a data writing method according to another embodiment of the present invention;
fig. 8 is a schematic structural diagram illustrating a garbage collection process performed by a solid state disk according to an embodiment of the present invention;
fig. 9 is a block diagram of a data writing apparatus provided according to still another embodiment of the present invention;
fig. 10 is a hardware structure diagram of a solid state disk according to an embodiment of the present invention.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the invention, as detailed in the appended claims.
<xnotran> 1 , 1 , , Channel1, Channel2, Channel3 Channel4, , Blocka Blocke, Blockb Block f, Block c Block g, Block d Block h, , , , , Host Date, , GC Date. </xnotran>
The physical storage unit can write a write command of user data from an upper layer or a write command of a garbage collection operation into a user data block or a garbage collection data block respectively through a Host Date or a GC Date carried in the write command.
The above data writing method has the following disadvantages:
firstly, whether the type of a write command is a write command of user data or a write command of garbage collection operation needs to be judged, and then corresponding operation is executed according to the type of the write command, and the judgment can increase the resource overhead of the solid state disk;
secondly, each channel has randomness when writing data, so that the number of effective data of each channel is different, the times of garbage collection of different channels are different, and some channels may always need garbage collection operation, while some channels always do not need garbage collection operation, thereby affecting the overall writing speed of the data;
thirdly, when garbage collection operation is performed, each channel has independence, and the garbage collection times of each channel are different, so that the write-in times and the erase times of data blocks in each channel are different, and the write-in times and the erase times of the data blocks can influence the service life of the solid state disk, so that the channels with high write-in times and erase times can influence the service life of the whole solid state disk;
fourthly, for the field of video monitoring, the solid state disk is required to have stable writing speed and higher copying times due to large data volume and continuity, and the above writing method is not suitable for writing video monitoring data because the speeds of writing data in each channel are inconsistent and influence the overall writing speed of data.
In view of the foregoing problems in the related art, an embodiment of the present invention provides a data writing method, where the data writing method provided in the following for one implementation is applied to a solid state disk, where the solid state disk includes a plurality of physical storage areas, each physical storage area includes a plurality of data blocks, and each data block includes a storage data block and a reserved data block; as shown in fig. 2, the method comprises the steps of:
step S10, when at least one reserved data block in the physical storage area is fully written with data, determining the quantity of effective data in each storage data block of the physical storage area;
step S20, judging whether the number of the valid data in the physical storage area is a storage data block with zero;
and step S30, if yes, erasing all data in the storage data block with the quantity of the valid data in the physical storage area being zero.
As shown in fig. 3, the solid state disk includes n physical storage areas, which are a physical storage area 1, a physical storage area 2, … …, a physical storage area n-1, and a physical storage area n; each physical storage area comprises n +1 data blocks, namely Block 0, block1, … … and Block n; the plurality of data blocks include a storage data Block and a reserved data Block, for example, the plurality of data blocks include n storage data blocks and 1 reserved data Block, block 1-Block n are storage data blocks, block 0 is a reserved data Block, and the storage data Block and the reserved data Block are not different in structure.
The solid state disk may include a plurality of nonvolatile storage media, for example, a plurality of FLASH chips or a plurality of DRAM chips, each nonvolatile storage medium may be divided into a plurality of physical storage spaces, the physical storage area may include one or more than two physical storage spaces, and each data block may include one or more than two physical storage spaces.
For a solid state disk with a NAND Flash chip as a non-volatile storage medium, a NAND Flash may include a plurality of Die, each Die has an independent operation register and a status register therein, each Die may be an independent unit, each Die may be divided into a plurality of physical storage blocks, and each data block may be one or more than two physical storage blocks on the Die.
The solid state disk can comprise a conversion layer, wherein the conversion layer is used for establishing a mapping relation between a client Host positioned at an upper layer and a physical storage area positioned at a lower layer, so that the client can access each physical storage area to realize writing or reading operation of data.
If the nonvolatile storage medium is a NAND Flash chip, the conversion layer may be an FTL (Flash translation layer, abbreviated as FTL).
As shown in fig. 3, the client Host may include n partitions, which are partition 1, partition 2, … …, partition n-1, partition n, and the translation layer may include n logical storage units, which are LBA 1, LBA2, … …, LBA n-1, and LBA n, where each partition has a mapping relationship with each logical storage unit, and each logical storage unit has a mapping relationship with each physical storage area, and thus, by establishing a corresponding relationship between each partition and each physical storage area, the client Host at an upper layer may perform a read/write operation on each physical storage area, for example, data in each partition of the client Host may be written into a corresponding physical storage area.
Each partition of the client Host can respectively correspond to each terminal device, data to be stored in each terminal device can be written into a corresponding physical storage area in the solid state disk, the terminal devices are cameras for example, a plurality of cameras correspond to each partition, and video stream data acquired by each camera can be written into each physical storage area respectively.
In the data writing process, a write command from the upper-layer client Host generally carries data to be written and a logical address, a physical address corresponding to the logical address can be found in a mapping relation between the logical address of the logical storage unit and physical addresses of data blocks in a physical storage area according to the logical address, and the data to be written is written into the data block corresponding to the physical address, so that data writing is realized.
The above physical storage areas are relatively independent, and can be operated in parallel, and the data to be written can be divided into a plurality of parts to be written in the physical storage areas in parallel.
With the continuous writing of data into the physical storage area, if the data is continuously written, the data to be written is sequentially written into each storage data block in the physical storage area, and with the continuous writing of the data, when each storage data block is fully written with the data, the solid state disk is in a full disk state at the moment; if the data is written randomly, the data to be written may be written randomly into each data block in the physical storage area, and with the continuous writing of the data, there may be a portion of the stored data blocks in which the data is already written full, and a portion of the stored data blocks in which a small amount of data is not written, and when the space in which the data is written in all the stored data blocks in the physical storage area occupies a certain proportion of the total storage space of the entire physical storage area, the proportion is usually a larger proportion, for example, 70% to 90%, and at this time, it may be considered that the solid state disk is in a near-full state.
When the solid state disk is in a full disk state or a state close to the full disk state, when a write command is received again, data to be written can be written into the reserved data block, at this time, data which is written into the storage data block earlier and has the same quantity and size as the data written into the reserved data block is taken as invalid data (also called overwriting data), and when the reserved data block is fully written, if a plurality of reserved data blocks are provided, data with the same quantity and size as the data of the reserved data block can be taken as invalid data when one reserved data block is fully written or when more than two reserved data blocks are fully written.
If the data is written continuously, the invalid data is usually distributed in one storage data block, and there may be a case that all data in one storage data block is invalid data; if the data is written randomly, the invalid data may be data distributed in one storage data block or may be distributed in different storage data blocks, and at this time, there may be no case where all data in the storage data blocks are invalid data.
Since the physical storage areas may be written in parallel, it may be that the reserved data block in one of the physical storage areas is full of data, or that the reserved data blocks in multiple physical storage areas are full of data.
In this embodiment, when at least one reserved data block in the physical storage area is fully written with data, the number of valid data in each storage data block of the physical storage area is determined, that is, the storage amount of valid data in the data stored in each storage data block is determined, when a storage data block in the physical storage area has a storage data block in which the data amount of valid data is zero, that is, none of the valid data in the storage data block is invalid data (that is, overwritten data), at this time, all data in the storage data block is erased, that is, the storage data block is cleared, the storage data block can be written again as a blank data block after being cleared, the blank data block can be used as a reserved data block, and the reserved data block and the storage data block are dynamically changed.
As can be seen from the above description, in the data writing method, when the solid state disk is in the full state or close to the full state, and when there is a storage data block with zero amount of valid data, the storage data block is cleared, and the storage data block is rewritable as a blank data block, so that garbage collection operation is not required, the data writing speed in each physical storage area is consistent, the overall data writing speed is not affected, and the data writing speed is fast.
For the field of video monitoring, video stream data is written continuously, data to be written is written into storage data blocks of each physical storage area in sequence, when a reserved data block is full, a storage data block with the number of valid data being zero exists certainly, namely, a situation that invalid data (namely, overwriting data) are all concentrated in one or more storage data blocks exists certainly, after the storage data block is emptied, data can be rewritten, when a solid state disk is in a full state again, the storage data block with the number of valid data being zero is emptied again, and therefore, circulation is repeated, garbage collection operation is not needed in each physical storage area, writing times and erasing times of the data blocks in each physical storage area are basically consistent, writing speed of each physical storage area is stable, and the situation that the service life of the whole solid state disk is affected due to the fact that the erasing times of one physical storage area are too high does not occur.
In addition, as garbage collection operation is not needed, the type of the write command does not need to be judged, the resource overhead of the solid state disk can be reduced, the read-write speed of the solid state disk can be improved, and therefore the data write-in method is particularly suitable for the field of video monitoring.
The data writing method can be applied to the field of video monitoring, video stream data can be continuously written into corresponding physical storage areas by taking a data block as a unit, video stream data in the cameras corresponding to all partitions of the client side are respectively stored into different physical storage areas, the correspondence between the logical partitions and the physical storage areas is realized, and the data management is convenient.
Furthermore, when any physical storage area is in a full disk state, data in the physical storage area can be released in a centralized manner by taking a data block as a unit, so that the problem of data writing delay caused by garbage recovery is avoided, data in each time can be effectively written into the data block, and the service life of the solid state disk is prolonged to the maximum extent; and the physical storage areas are independent from each other and do not interfere with each other, so that the solid application runs at a high speed and in a stable state, and the data writing speed is improved.
In an alternative embodiment, as shown in fig. 4, the method may further include the steps of:
step S41, if the storage data block with the quantity of the valid data being zero is judged not to exist in the physical storage area, reading the valid data in part of the storage data blocks of each physical storage area;
step S42, correspondingly writing the read effective data into a reserved data block of a physical storage area where a storage data block for reading the part of effective data is located;
and S43, erasing all data in the read storage data blocks of each part.
For the case that the data is randomly written, the invalid data may be data distributed in one storage data block, or may be distributed in different storage data blocks, so that there may be no case that all data in the storage data blocks are invalid data, that is, it is determined that there is no storage data block with zero number of valid data in the physical storage area, at this time, since at least one reserved data block is full of data, the solid state disk is in a state close to a full disk, and a garbage collection operation needs to be performed.
In this embodiment, when performing a garbage collection operation, first, valid data in a part of storage data blocks of each physical storage area is read, where the part of storage data blocks is usually a storage data block in which valid data and invalid data are stored, specifically, when the valid data is read from the storage data blocks of each physical storage area, valid data can be read from each storage data block in parallel, and valid data with the same quantity and size can be read from each storage data block, respectively, but since the number of valid data in each storage data block may not be the same, in each reading, it may be that, for some physical storage areas, a certain quantity of valid data can be read only after reading a plurality of storage data blocks or reading a larger storage space of one storage data block, and for some physical storage spaces, the same quantity of valid data can be read after reading a smaller storage data block or reading a smaller storage space of one storage data block.
After the valid data is read, the read valid data needs to be written into the reserved data block.
After the read valid data is written into the reserved data block, the valid data is stored, all data in each read storage data block can be erased, namely, each storage data block is emptied, the emptied storage data block can be used as a blank data block to write data again, and garbage collection operation is completed.
For example, in the data writing process, the solid state disk has four physical storage areas, which are a physical storage area 1, a physical storage area 2, a physical storage area 3, and a physical storage area 4, respectively, and reads 16K valid data from a part of storage data blocks in each physical storage area, and then correspondingly writes all the read valid data into reserved data blocks in the corresponding physical storage areas, respectively.
For the 4 pieces of 16K valid data that have been read, the 16K valid data read from the partial storage data block in the physical storage area 1 is written into the reserved data block of the physical storage area 1, and likewise, the 16K valid data read from the partial storage data block in the physical storage area 2 is written into the reserved data block of the physical storage area 2, the 16K valid data read from the partial storage data block in the physical storage area 3 is written into the reserved data block of the physical storage area 3, and the 16K valid data read from the partial storage data block in the physical storage area 4 is written into the reserved data block of the physical storage area 4.
In this embodiment, when writing in the valid data, the read valid data is written into the corresponding physical storage area, and the data writing in each physical storage area is relatively independent, so that the situation of writing across the physical storage areas does not occur, which not only can improve the data writing speed, but also is convenient for managing the data stored in the physical storage areas.
In some examples, as shown in fig. 5, the reading valid data in the partial memory data block of each physical memory area in step S41 includes:
step S411, respectively determining a storage data block with the minimum number of effective data in each storage data block of each physical storage area, and using the storage data block as a source storage data block;
and step S412, respectively reading the valid data in each source storage data block.
In this embodiment, when reading the valid data from the partial storage data blocks of each physical area, first determining that the number of the valid data in each storage data block is the minimum, and using the valid data as the source storage data block, and then reading the valid data from the source storage data block of each physical storage area, so that the data in the storage data block with the minimum number of the valid data can be erased first, the erasing speed is fast, and the garbage collection speed can be increased, thereby being beneficial to increasing the data writing speed.
In an alternative embodiment, as shown in fig. 6, before step S42, the method further includes:
step S413, determining whether the total amount of the valid data that has been read is greater than or equal to a writing amount threshold;
if so, the above step 42 is executed, otherwise, the valid data in the partial storage data block of each physical storage area is read in the above step S41.
In order to improve the data writing speed, usually, when the data is greater than a certain amount, the data is written, but not written after reading a certain amount of data, so that the data writing frequency can be reduced, and the writing efficiency is improved, accordingly, in this embodiment, before writing the read valid data into the reserved data block, it is further determined whether the total amount of the read valid data is greater than or equal to the writing number threshold, that is, it is determined whether the data writing condition is satisfied, and when the total amount of the valid data is greater than or equal to the writing number threshold, that is, it is determined that the writing condition is satisfied, the read valid data is written into the corresponding reserved data block; when the total number of valid data is smaller than the writing number threshold, that is, the writing condition is not satisfied, the step of reading the valid data is performed again, that is, the valid data is read again, and the valid data is written again when the total number of the valid data satisfies the writing condition.
In some examples, as shown in fig. 7, the separately reading the valid data in each source storage data block in step S412 includes:
step S4121, reading each page of data in each source storage data block in sequence by taking a page as a unit;
step S4122 of determining whether the read page data is valid data;
if yes, the step of determining whether the total amount of the read valid data is greater than or equal to the write number threshold in step S413 is executed;
if not, the step S4121 is executed, that is, the next page of data in each source storage data block is read.
For a solid state disk with a NAND Flash chip as a nonvolatile storage medium, each data block in each physical storage area may be one or more than two physical storage spaces on Die.
The NAND Flash chip is a nonvolatile Flash memory chip having characteristics that each bit can only be changed from 1 to 0 when data is written, each bit is changed from 0 to 1 when data is erased, and data is read and written in units of pages, and data is erased in units of physical memory blocks, and each physical memory block in the NAND Flash chip has the maximum number of times of erasing.
In this embodiment, the data in each source storage data block is read in a page unit, and whether each page of data read is valid data is further determined, for example, whether the data read is valid data is determined by a data check algorithm, if yes, the above step S42 is executed next, and if not, the next page of data in each source storage data block is read continuously.
Fig. 8 is a schematic structural diagram illustrating a garbage collection process performed by a solid state disk based on a NAND Flash chip, and as shown in fig. 8, the solid state disk includes n physical storage areas, namely a physical storage area 1, a physical storage area 2, … …, and a physical storage area n; each physical storage area comprises a plurality of memory chips Die, and the plurality of memory chips Die can form a NAND Flash chip.
The physical storage area 1 includes memory chips Die 11 to Die 1n; the physical storage area 2 includes memory chips Die21 to Die 2n; … …; the physical memory region n includes memory chips Die n1 to Die nn, and each memory chip may include a memory data block and several reserved data blocks.
In the following, referring to fig. 8, to further explain the work flow of the above embodiment, first, the storage data Block with the minimum number of valid data in each storage data Block of each physical storage area is determined and is taken as a source storage data Block, as shown in fig. 8, the storage data Block11 in the storage chip Die 11 in the physical storage area 1 is taken as a source storage data Block, the storage data Block21 in the storage chip Die21 in the physical storage area 2 is taken as a source storage data Block, … …, and the storage data Block n1 in the storage chip Die n1 in the physical storage area n is taken as a source storage data Block.
Reading data in each source storage data Block in each physical storage area respectively, reading data of one Page in each source storage data Block respectively in Page unit, reading Page 0 data Page 0 in the source storage data Block11, page 0 data Page 0, … … in the source storage data Block21, and Page 0 data Page 0 in the source storage data Block1 in parallel, judging whether each Page data read is valid data, for example, if all the Page 0 data in each source storage data Block is invalid data, continuing to read the next Page of data in each source storage data Block, for example, the Page 3 data Page 3 in the read source storage data Block11 is valid data, the Page 21 data Page 20 in the read source storage data Block21 is valid data, … …, and the Page n +1 data Page n in the read source storage data Block1 is valid data.
It is determined whether the total amount of valid data that has been read is greater than a threshold write amount, for example, 10 pages of valid data are read at this time, and the total amount of valid data of the 10 pages is 256K and greater than the threshold write amount, 200K.
Then, the read 10 pages of valid data are correspondingly written into the physical storage area, the page 3 of valid data read from the source storage data Block11 is written into the reserved data Block1n in the memory chip Die 11 of the physical storage area 1 where the source storage data Block11 is located, and if the reserved data Block1 is full after a plurality of pages of valid data are written, the remaining valid data can be written into other reserved data blocks of the physical storage area 1.
Similarly, the valid data of page 21 read from the source storage data Block21 of the physical storage area 2 is correspondingly written into a reserved data Block2n in the memory chip Die21 in the physical storage area 2; and by analogy, respectively writing the valid data read from the source storage data block of each physical storage area into the reserved data block of the corresponding physical storage area, where an arrow in fig. 8 indicates that the valid data is written into the corresponding reserved data block, and of course, only a part of the valid data is schematically marked in the figure and written into the corresponding reserved data block.
And after all the read valid data are written into the corresponding reserved data blocks, all the read data in each source storage data block are erased, and accordingly, the garbage collection operation is completed.
In some examples, the writing the read valid data into the reserved data block of the physical storage area where the storage data block that reads the part of valid data is located in the step S43 correspondingly includes:
and correspondingly writing the read effective data into a blank storage space of a reserved data block in a storage chip where the storage data block reading the part of the effective data is located, and writing the rest part of the effective data into reserved data blocks of other storage chips in a physical storage area where the storage data block reading the part of the effective data is located after the blank storage space of the reserved data block is full.
For a solid state disk, a physical storage area may include a plurality of storage chips, for example, a plurality of Die, in order to improve the read-write stability of data, a part of valid data to be written is preferentially written into a reserved data block in a storage chip where a storage data block that reads the part of valid data is located, that is, a part of valid data is preferentially written into a current storage chip that reads the part of valid data, when a blank storage space in the reserved data block of the current storage chip is full, the part of valid data is written into another storage chip, and of course, the storage chip where the storage data block that reads the part of valid data is located is also located in the physical storage area where the storage data block that reads the part of valid data is located.
For example, the solid state disk includes four physical storage areas, which are a physical storage area 1, a physical storage area 2, a physical storage area 3, and a physical storage area 4; the physical storage area 1 comprises a first storage chip and a second storage chip, the physical storage area 2 comprises a third storage chip and a fourth storage chip, the physical storage area 3 comprises a fifth storage chip and a sixth storage chip, the physical storage area 4 comprises a seventh storage chip and an eighth storage chip, and each storage chip is divided into 10 storage data blocks and 1 reserved data block.
Respectively reading 16K valid data from a partial storage data block of each physical storage area, and reading 4 pieces of 16K valid data, wherein the 16K valid data is read from a first storage data block in the physical storage area 1, the first storage data block is located on a first storage chip, and the first storage chip is also located in the physical storage area 1; reading 16K valid data from a second storage data block in the physical storage area 2, where the second storage data block is located on a fourth storage chip, and the fourth storage chip is also located in the physical storage area 2; reading 16K valid data from an eighth storage data block in the physical storage area 3, where the eighth storage data block is located on a sixth storage chip, and the eighth storage chip is also located in the physical storage area 3; the 16K valid data is read out from the fifth storage data block in the physical storage area 4, and the fifth storage data block is located on the seventh storage chip, that is, the seventh storage chip is located in the physical storage area 4.
Writing the 4 valid data of 16K into the empty storage space of the reserved data block of the corresponding memory chip, specifically, writing the empty storage space of the reserved data block in the fourth memory chip where the second memory data block, from which the valid data of 16K is read out, in the physical memory area 2, to full, for example, writing 2 valid data of 16K into the empty storage space, and then writing the remaining 1 valid data of 16K into the reserved data block of the third memory chip in the physical memory area 2; similarly, in the empty storage space of the reserved data block in the seventh storage chip where the fifth storage data block from which the 16K valid data is read out in the physical storage area 4 is located, for example, after 1 valid data of 16K is written in the empty storage space, the empty storage space is still not full of data, and since the valid data is already written, it is not necessary to write the valid data in the reserved data block of the eighth storage chip in the physical storage area 4 again.
The embodiment of the invention also provides a data writing device which is applied to the solid state disk, wherein the solid state disk comprises a plurality of physical storage areas, each physical storage area comprises a plurality of data blocks, and the plurality of data blocks comprise storage data blocks and reserved data blocks; as shown in fig. 9, the data writing device 09 includes:
a valid data amount determining unit 91, configured to determine, when all of at least one of the reserved data blocks in the physical storage area is full of data, the amount of valid data in each of the storage data blocks in the physical storage area;
a valid data amount judgment unit 92 for judging whether there is a storage data block in the physical storage area, the number of which is zero;
and a first data erasing unit 93, configured to erase all data in a storage data block with a zero amount of valid data in the physical storage area when it is determined that the storage data block with the zero amount of valid data exists in the physical storage area.
In an optional embodiment, the data writing apparatus further includes:
the valid data reading unit is used for reading the valid data in the partial storage data blocks of each physical storage area when judging that no storage data blocks with the number of the valid data being zero exist in the physical storage area;
the valid data writing determining unit is used for correspondingly writing the read valid data into a reserved data block of a physical storage area where a storage data block for reading the part of valid data is located;
and the second data erasing unit is used for erasing all data in each read partial storage data block.
In an optional implementation manner, the valid data reading unit is specifically configured to:
respectively determining a storage data block with the minimum number of effective data in each storage data block of each physical storage area, and taking the storage data block as a source storage data block;
and respectively reading the valid data in each source storage data block.
In an optional embodiment, the data writing apparatus further comprises:
a valid data number judgment unit for judging whether the total number of the read valid data is greater than or equal to a write number threshold;
if yes, correspondingly writing the read effective data into a reserved data block of a physical storage area where a storage data block for reading the part of effective data is located;
and if not, executing the step of reading the valid data in the partial storage data blocks of the physical storage areas.
Corresponding to the foregoing embodiment of the data writing method, the data writing device according to the present invention clears a storage data block when there is a storage data block with zero number of valid data when the solid state disk is in a full state or a state close to the full state, and rewrites data as a blank data block, so that garbage collection operation is not required, the data writing speed in each physical storage area is the same, the overall data writing speed is not affected, and the data writing speed is fast.
For the device embodiment, the implementation process of the functions and actions of each unit or sub-unit is specifically described in the implementation process of the corresponding steps in the above method, and is not described herein again.
The above-described embodiments of the apparatus are merely illustrative, wherein the units described as separate parts may or may not be physically separate, may be located in one place, or may be distributed over a plurality of network units; the units may be combined into one unit, or further divided into a plurality of sub-units.
Through the description of the above embodiments, the apparatus of the present embodiment may be implemented by software, or by software plus necessary general hardware, and may also be implemented by hardware. Based on such understanding, the technical solution of the present invention or the portions contributing to the prior art may be embodied in the form of software products, and taking the implementation of software as an example, as a logical means, the technical solution is formed by reading the corresponding computer program instructions in the nonvolatile memory into the memory for running through the processor of the device to which the apparatus is applied.
Referring to fig. 10, the present invention further provides a hardware architecture diagram of a solid state disk, where the solid state disk includes: a communication interface 101, a processor 102, a machine-readable storage medium 103, a bus 104, and a physical storage medium 105; wherein the communication interface 101, the processor 102, the machine-readable storage medium 103, and the physical storage medium 105 are in communication with each other via a bus 104. The processor 102 may perform the data writing method described above by reading and executing machine-executable instructions in the machine-readable storage medium 102 corresponding to control logic of the data writing method, the physical storage medium comprising a plurality of physical storage areas, each physical storage area comprising a plurality of data blocks, the plurality of data blocks comprising a storage data block and a reserved data block.
The machine-readable storage medium 103 referred to herein may be any electronic, magnetic, optical, or other physical storage device that can contain or store information such as executable instructions, data, and the like. For example, the machine-readable storage medium may be: a RAM (random access Memory), a volatile Memory, a non-volatile Memory, a flash Memory, a storage drive (e.g., a hard drive), any type of storage disk (e.g., an optical disk, a dvd, etc.), or similar storage medium, or a combination thereof.
The physical storage medium 104 may be one or more non-volatile storage media, such as a FLASH chip or a DRAM chip, for example.
The embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program is executed by a processor to implement the method of any one of the above embodiments.
Other embodiments of the invention will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. The invention is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the invention and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the invention being indicated by the following claims.

Claims (12)

1. A data writing method is applied to a solid state disk and is characterized in that the solid state disk comprises a plurality of physical storage areas, each physical storage area comprises a plurality of data blocks, and the plurality of data blocks comprise storage data blocks and reserved data blocks; the method comprises the following steps:
when at least one reserved data block in the physical storage area is fully written with data, determining the quantity of valid data in each storage data block of the physical storage area;
judging whether a storage data block with the quantity of the valid data being zero exists in the physical storage area;
if yes, erasing all data in the storage data block with the quantity of the valid data in the physical storage area being zero.
2. The method of claim 1, further comprising:
if the physical storage area does not have the storage data block with the quantity of the valid data being zero, reading the valid data in part of the storage data blocks of the physical storage area;
correspondingly writing the read effective data into a reserved data block of a physical storage area where a storage data block for reading the part of effective data is located;
and erasing all data in each read partial storage data block.
3. The method according to claim 2, wherein said reading valid data in the partial storage data block of each of the physical storage areas comprises:
respectively determining a storage data block with the minimum number of effective data in each storage data block of each physical storage area, and taking the storage data block as a source storage data block;
and respectively reading valid data in each source storage data block.
4. The method according to claim 3, before correspondingly writing the read valid data into a reserved data block of a physical storage area where the storage data block from which the part of valid data is read belongs to, further comprising:
judging whether the total amount of the read valid data is larger than or equal to a writing amount threshold value or not;
if yes, correspondingly writing the read effective data into a reserved data block of a physical storage area where a storage data block for reading the part of effective data is located;
and if not, executing the step of reading the valid data in the partial storage data blocks of the physical storage areas.
5. The method of claim 4, wherein said separately reading valid data in each of said source storage data blocks comprises:
sequentially and respectively reading each page of data in each source storage data block by taking a page as a unit;
judging whether the data of each read page is valid data or not;
if yes, executing the step of judging whether the total quantity of the read valid data is larger than or equal to a writing quantity threshold value;
if not, the step of respectively reading each page of data in each source storage data block by taking the page as the unit sequence is executed.
6. The method according to claim 4, wherein correspondingly writing the read valid data into a reserved data block of a physical storage area where a storage data block for reading the part of valid data is located comprises:
and correspondingly writing the read effective data into a blank storage space of a reserved data block in a storage chip where the storage data block for reading the part of effective data is located, and writing the rest part of effective data into reserved data blocks of other storage chips in a physical storage area where the storage data block for reading the part of effective data is located after the blank storage space of the reserved data block is full.
7. A data writing device is applied to a solid state disk and is characterized in that the solid state disk comprises a plurality of physical storage areas, each physical storage area comprises a plurality of data blocks, and the plurality of data blocks comprise storage data blocks and reserved data blocks; the device includes:
an effective data amount determining unit, configured to determine, when all of at least one reserved data block in the physical storage area is full of data, an amount of effective data in each storage data block of the physical storage area;
an effective data amount judgment unit for judging whether there is a storage data block with zero amount of effective data in the physical storage area;
and the first data erasing unit is used for erasing all data in the storage data block with the quantity of the valid data being zero in the physical storage area when the storage data block with the quantity of the valid data being zero in the physical storage area is judged to exist.
8. The apparatus of claim 7, further comprising:
the valid data reading unit is used for reading the valid data in the partial storage data blocks of each physical storage area when judging that no storage data blocks with the number of the valid data being zero exist in the physical storage area;
the valid data writing determining unit is used for correspondingly writing the read valid data into a reserved data block of a physical storage area where a storage data block for reading the part of valid data is located;
and the second data erasing unit is used for erasing all the data in each read partial storage data block.
9. The apparatus of claim 8, wherein the valid data reading unit is specifically configured to:
respectively determining a storage data block with the minimum number of effective data in each storage data block of each physical storage area, and taking the storage data block as a source storage data block;
and respectively reading valid data in each source storage data block.
10. The apparatus of claim 9, further comprising:
a valid data number judgment unit for judging whether the total number of the read valid data is greater than or equal to a write number threshold;
if yes, correspondingly writing the read effective data into a reserved data block of a physical storage area where a storage data block for reading the part of effective data is located;
and if not, executing the step of reading the valid data in the partial storage data blocks of the physical storage areas.
11. A solid state disk comprising a processor, a machine-readable storage medium, and a physical storage medium, the physical storage medium comprising a plurality of physical storage areas, each physical storage area comprising a plurality of data blocks, the plurality of data blocks comprising a stored data block and a reserved data block, the machine-readable storage medium storing machine-executable instructions executable by the processor, the processor being caused by the machine-executable instructions to perform the method of any of claims 1 to 6.
12. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the method of any one of claims 1 to 6.
CN201810362066.3A 2018-04-20 2018-04-20 Data writing method and device, solid state disk and computer readable storage medium Active CN110389712B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810362066.3A CN110389712B (en) 2018-04-20 2018-04-20 Data writing method and device, solid state disk and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810362066.3A CN110389712B (en) 2018-04-20 2018-04-20 Data writing method and device, solid state disk and computer readable storage medium

Publications (2)

Publication Number Publication Date
CN110389712A CN110389712A (en) 2019-10-29
CN110389712B true CN110389712B (en) 2022-12-23

Family

ID=68284163

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810362066.3A Active CN110389712B (en) 2018-04-20 2018-04-20 Data writing method and device, solid state disk and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN110389712B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111078137B (en) * 2019-11-07 2021-07-06 深圳市金泰克半导体有限公司 Method for cleaning storage space
CN112162935B (en) * 2020-09-30 2021-06-08 深圳市时创意电子有限公司 Data processing method and device of storage chip, computer equipment and storage medium
CN113867642B (en) * 2021-09-29 2023-08-04 杭州海康存储科技有限公司 Data processing method, device and storage equipment
CN113891072B (en) * 2021-12-08 2022-02-11 北京拙河科技有限公司 Video monitoring and anomaly analysis system and method based on hundred million-level pixel data

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101819509A (en) * 2010-04-19 2010-09-01 清华大学深圳研究生院 Solid state disk read-write method
US9330727B1 (en) * 2013-12-30 2016-05-03 Emc Corporation Binding a data object to a rotational hard drive
CN105808156B (en) * 2014-12-31 2020-04-28 华为技术有限公司 Method for writing data into solid state disk and solid state disk

Also Published As

Publication number Publication date
CN110389712A (en) 2019-10-29

Similar Documents

Publication Publication Date Title
CN106708424B (en) Apparatus and method for performing selective underlying exposure mapping on user data
CN110389712B (en) Data writing method and device, solid state disk and computer readable storage medium
US8886990B2 (en) Block management schemes in hybrid SLC/MLC memory
US20130151892A1 (en) Data storing method for solid state drive to preserve data integrity after power failure
CN104484283B (en) A kind of method for reducing solid state disk write amplification
EP3168736A1 (en) Storage device including multi-partitions for multimode operations, and operation method thereof
JP2019020788A (en) Memory system and control method
US10073771B2 (en) Data storage method and system thereof
US20200183831A1 (en) Storage system and system garbage collection method
US20140328127A1 (en) Method of Managing Non-Volatile Memory and Non-Volatile Storage Device Using the Same
JP6139711B2 (en) Information processing device
EP3752905A1 (en) Append only streams for storing data on a solid state device
US20100318726A1 (en) Memory system and memory system managing method
CN106598504B (en) data storage method and device
KR20160106240A (en) Semiconductor device and operating method thereof
US20230153236A1 (en) Data writing method and apparatus
KR20160139864A (en) Non-volatile memory system
CN113986773A (en) Write amplification optimization method and device based on solid state disk and computer equipment
US20130138910A1 (en) Information Processing Apparatus and Write Control Method
CN116795735B (en) Solid state disk space allocation method, device, medium and system
US9304906B2 (en) Memory system, controller and control method of memory
JP6100927B2 (en) Information processing device
WO2014185038A1 (en) Semiconductor storage device and control method thereof
US10990520B2 (en) Method for gabage collecting for non-volatile memory
TWI724550B (en) Data storage device and non-volatile memory control method

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
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20200317

Address after: 310051 room 307, floor B, building 2, No. 399, Danfeng Road, Binjiang District, Hangzhou City, Zhejiang Province

Applicant after: Hangzhou Haikang Storage Technology Co.,Ltd.

Address before: 430074 East Lake Development Zone, Wuhan City, Hubei Province, No. 1 Software Park, Guanshan Road, Phase 5, Building F4, Room 21, Room 01

Applicant before: WUHAN HIKSTORAGE TECHNOLOGY Co.,Ltd.

GR01 Patent grant
GR01 Patent grant