A hard disk operation method, computer program product, electronic device and medium
By determining the target available space in the solid-state drive and setting the host write and garbage collection target times based on nonlinear conversion information, the problem of insufficient garbage collection of solid-state drives is solved, and the detailed balance of the available space of the solid-state drive, host write operations and garbage collection operations is achieved, and the service life of the solid-state drive is extended.
Patent Information
- Application Number
- CN202411948433.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-27
- Publication Date
- 2025-03-11
- Estimated Expiration
- 2044-12-27
AI Technical Summary
Inadequate garbage collection of solid-state drives leads to insufficient free space, affecting the host's write performance, and excessive garbage collection increases the write amplification coefficient and shortens the service life.
By determining the target available space of the solid state drive and determining the host write target number and garbage collection write target number based on nonlinear and positively correlated conversion information, the solid state drive is controlled to perform host write and garbage collection operations.
It realizes a meticulous balance between host write and garbage collection operations, reduces write amplification of solid-state drives, and extends service life.
Smart Images

Figure CN119376648B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of storage technology, and more specifically, to a hard disk operation method, a computer program product, an electronic device and a medium. Background Art
[0002] During the use of Solid State Drives (SSDs), host writes will reduce available space, and garbage collection (GC) will release available space. If the SSD has too little garbage collection, there will be a problem of insufficient available space. When the host writes data, it needs to first garbage collect available space, resulting in low host write performance. Conversely, if the SSD has too many garbage collection operations, a large amount of internal data will be moved, increasing the write amplification factor of the SSD, increasing the number of wear operations, and shortening the service life of the SSD.
[0003] In summary, how to improve the service life of a solid state drive is an urgent problem to be solved by those skilled in the art. Summary of the invention
[0004] The purpose of the present invention is to provide a hard disk operation method, which can solve the technical problem of how to improve the service life of a solid state hard disk to a certain extent. The present invention also provides a computer program product, an electronic device and a computer readable storage medium.
[0005] In order to achieve the above object, the present invention provides the following technical solutions:
[0006] In a first aspect, a hard disk operation method is provided, comprising:
[0007] Determine the target free space of the SSD;
[0008] Determine target conversion information of the host write count value and the available space of the solid state drive, wherein the target conversion information includes nonlinear and positively correlated conversion information;
[0009] Determine, according to the target conversion information, a host write target number value corresponding to the target available space;
[0010] Control the solid state drive to perform a host write operation according to the host write target number of times.
[0011] On the other hand, after determining the host write target number value corresponding to the target available space according to the target conversion information, the method further includes:
[0012] Determining a garbage collection write target number value of the solid state drive according to the host write target number value;
[0013] Controlling the solid state drive to perform a host write operation according to the host write target number of times, including:
[0014] The solid state drive is controlled to perform a host write operation according to the host write target number of times, and the solid state drive is controlled to perform a garbage collection write operation according to the garbage collection write target number of times.
[0015] On the other hand, determining target conversion information of the host write count value and the available space of the solid state drive includes:
[0016] Obtaining a set total number of times, the total number of times including a total number of write operations determined according to a size of cached data;
[0017] Determining a minimum setting value and a maximum setting value of the available space of the solid state drive;
[0018] According to the total number of times, the minimum setting value and the maximum setting value, target conversion information of the host write count value and the available space of the solid state drive is generated.
[0019] On the other hand, generating target conversion information of the host write count value and the available space of the solid state drive according to the total count value, the minimum setting value and the maximum setting value, including:
[0020] Using the available space of the solid state drive as the horizontal axis value;
[0021] The host write count value is used as the vertical axis value;
[0022] Using the host write count value corresponding to the minimum setting value as zero and the host write count value corresponding to the maximum setting value as the total count value as constraint conditions, generating an elliptic curve of the host write count value and the available space of the solid state drive;
[0023] In the elliptic curve, a curve segment in which the host write count value is positively correlated with the available space of the solid state drive and has a non-negative value is used as target conversion information.
[0024] On the other hand, determining the host target write count value corresponding to the target available space according to the target conversion information includes:
[0025] Determine whether the target available space is greater than or equal to the maximum setting value;
[0026] In response to the target available space being greater than or equal to the maximum setting value, determining the host write target number value corresponding to the target available space to be the total number value;
[0027] In response to the target available space being less than the maximum setting value, determining whether the target available space is greater than the minimum setting value;
[0028] In response to the target available space being greater than the minimum set value, the target available space is operated according to the target conversion information to obtain an operation count value, and the operation count value is rounded down to obtain a host write target count value corresponding to the target available space;
[0029] In response to the target available space being less than or equal to the minimum setting value, determining that the host write target number value corresponding to the target available space is zero;
[0030] Determining a garbage collection write target number value of the solid state drive according to the host write target number value includes:
[0031] Generate a first difference between the total number of times and the host write target number of times;
[0032] The first difference is used as a target number of garbage collection write times of the solid state drive.
[0033] On the other hand, controlling the solid state drive to perform a host write operation according to the host write target number of times, and controlling the solid state drive to perform a garbage collection write operation according to the garbage collection write target number of times, includes:
[0034] Get the set number of operation batches;
[0035] Dividing the host write target number value according to the number of operation batches to obtain host write number sub-values of each batch;
[0036] Dividing the garbage collection write target number value according to the number of operation batches to obtain garbage collection write number sub-values of each batch;
[0037] From the beginning of the first batch to the end of the last batch, the host write count sub-value of the current batch is used as the host write bucket size value, and the garbage collection write count sub-value of the current batch is used as the garbage collection write bucket size value; if a host write operation is performed, the host write bucket size value is reduced by one, and if a garbage collection write operation is performed, the garbage collection write bucket size value is reduced by one, until the host write bucket size value and the garbage collection write bucket size value are both zero and then enter the next batch.
[0038] On the other hand, determine the target free space of the SSD, including:
[0039] Get the latest recorded value of the available space of the solid state drive and the recording time corresponding to the latest recorded value;
[0040] Counting space change information between the recording time and the current time, wherein the space change information includes space write amount and / or garbage collection read amount and / or newly added bad block amount;
[0041] Adjust the latest recorded value according to the space change information to obtain the target available space of the solid state drive;
[0042] The target available space is taken as the latest recorded value.
[0043] On the other hand, before obtaining the latest recorded value of the available space of the solid state drive, it also includes:
[0044] In response to the solid state drive being powered on, identifying a free super block and a write-status super block in the solid state drive, the super block including a set number of blocks;
[0045] Determine a first number of blocks in the superblock to be written in parallel;
[0046] Determine the number of bad blocks of each free super block and write-state super block, the number of pages in each block, and the unit data volume in each page, wherein the unit data volume is determined according to the ratio of available space to a set data volume;
[0047] Determine the number of pages in the write-status superblock that have data written to it;
[0048] Determine the available space of the free super block according to the first number, the number of bad blocks in the free super block, the number of pages in each block, and the unit data amount in each page;
[0049] Determine the available space of the super block in the write state according to the first number, the bad block number value of the super block in the write state, the number of pages in each block, the unit data amount in each page and the number of pages;
[0050] Generate initial available space of the solid state drive according to available space of the free super block and available space of the write-state super block;
[0051] The initial available space is taken as the latest recorded value.
[0052] On the other hand, the space change information between the recording time and the current time is counted, and the space change information includes the space writing amount, including:
[0053] determining a second number of pages included in each write row of the flash memory;
[0054] Determine the write volume statistics interval;
[0055] Between the recording time and the current time, count the number of first layers of the valid layers in each write operation;
[0056] Generate a space write amount between a recording time and a current time according to the second amount, the first layer number, the write amount statistical interval and the unit data amount in each page;
[0057] The latest recorded value is adjusted according to the space change information to obtain the target available space of the solid state drive, including:
[0058] Generate a second difference between the latest recorded value and the space writing amount;
[0059] The second difference is used as the target available space of the solid state drive.
[0060] On the other hand, the space change information between the recording time and the current time is counted, and the space change information includes the garbage collection reading amount, including:
[0061] Determine the reading volume statistics interval;
[0062] Between the recording time and the current time, count the number of second layers of the valid layer at each garbage collection read;
[0063] Generate a garbage collection read amount between a recording time and a current time according to the second layer number, the read amount statistical interval and the unit data amount in each page;
[0064] The latest recorded value is adjusted according to the space change information to obtain the target available space of the solid state drive, including:
[0065] Generate a sum of the latest record value and the garbage collection reading amount;
[0066] The sum is used as the target available space of the solid state drive.
[0067] On the other hand, the spatial change information between the recording time and the current time is counted, and the spatial change information includes the amount of newly added bad blocks, including:
[0068] Between the recording time and the current time, counting a third number of bad blocks newly added in the super block of the solid state drive;
[0069] Generate the amount of newly added bad blocks between the recording time and the current time according to the third amount, the number of pages in each block and the unit data amount in each page;
[0070] The latest recorded value is adjusted according to the space change information to obtain the target available space of the solid state drive, including:
[0071] generating a third difference between the latest recorded value and the amount of newly added bad blocks;
[0072] The third difference is used as the target available space of the solid state drive.
[0073] On the other hand, before determining the target conversion information of the host write count value and the available space of the solid state drive, it also includes:
[0074] Detect whether the set active triggering conditions for garbage collection operations are met;
[0075] In response to the active triggering condition being met, only the garbage collection operation is performed on the solid state drive, and after the garbage collection of a super block is completed, it is detected whether the set active end condition of the garbage collection operation is met;
[0076] In response to not meeting the active termination condition, returning to the step of performing the garbage collection operation only on the solid state drive;
[0077] In response to the active termination condition being met, the step of determining target conversion information of the host write count value and the available space of the solid state drive is performed;
[0078] In response to the active trigger condition not being met, the step of determining target conversion information of the host write count value and the available space of the solid state drive is performed.
[0079] On the other hand, it detects whether the active end conditions of the set garbage collection operation are met, including:
[0080] The target number of super blocks that have undergone garbage collection operations last are used as blocks to be detected;
[0081] Count the amount of valid unit data in each block to be detected;
[0082] Count the maximum unit data volume that can be written in each block to be detected;
[0083] Generate a valid data ratio of the solid state drive according to the ratio of the valid unit data volume to the maximum unit data volume;
[0084] Detecting whether the effective data ratio is greater than or equal to a set data ratio;
[0085] In response to the valid data proportion being greater than or equal to the set data proportion, it is determined that the set active termination condition of the garbage collection operation is met.
[0086] In a second aspect, a computer program product is provided, comprising a computer program / instruction, which, when executed by a processor, implements the steps of any of the hard disk operation methods described above.
[0087] According to a third aspect, an electronic device is provided, including:
[0088] Memory for storing computer programs;
[0089] A processor is used to implement the steps of any of the hard disk operation methods described above when executing the computer program.
[0090] In a fourth aspect, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the steps of any of the hard disk operation methods described above are implemented.
[0091] The present invention provides a hard disk operation method, which determines the target available space of a solid state hard disk; determines the target conversion information of the host write count value and the available space of the solid state hard disk, wherein the target conversion information includes nonlinear and positively correlated conversion information; determines the host write target count value corresponding to the target available space according to the target conversion information; and controls the solid state hard disk to perform a host write operation according to the host write target count value. The beneficial effect of the present invention is that the host write count value and the target conversion information of the available space of the solid state hard disk are nonlinear and positively correlated conversion information, so that as the target available space of the solid state hard disk increases, the corresponding host write target count value will increase in a nonlinear form, and similarly, as the target available space of the solid state hard disk decreases, the corresponding host write target count value will decrease in a nonlinear form, and compared with the existing linear conversion information, the host write count value changes with the available space more meticulously, thereby making the process of the host write operation reducing the available space of the solid state hard disk more meticulously, making the garbage collection operation of the solid state hard disk more meticulously, achieving a more meticulous balance between the available space, the host write operation and the garbage collection operation, and improving the service life of the solid state hard disk. The present invention provides a computer program product, an electronic device and a computer-readable storage medium which also solve the corresponding technical problems. BRIEF DESCRIPTION OF THE DRAWINGS
[0092] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0093] Figure 1 A flowchart of a hard disk operation method provided by an embodiment of the present invention;
[0094] Figure 2 A schematic diagram of the elliptic curve relationship between the host write count value and the available space of the solid state drive;
[0095] Figure 3 This is a flowchart of operating the hard disk in actual applications;
[0096] Figure 4 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention;
[0097] Figure 5Another structural schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0098] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0099] See also Figure 1 , Figure 1 The present invention provides a flowchart of a hard disk operation method according to an embodiment of the present invention.
[0100] A hard disk operation method provided by an embodiment of the present invention may include the following steps:
[0101] Step S101: Determine the target available space of the solid state drive.
[0102] In practical applications, considering that the available space of the SSD affects the host write operation and garbage collection operation, the target available space of the SSD can be determined first. The target available space is also the current available space of the SSD. The size of the target available space can be adjusted as needed. For example, the target available space can be the ratio of the available space to the set data volume (DataFrame), and the set data volume can be the minimum data writing amount for the write operation.
[0103] In actual applications, in the process of determining the target available space of the solid-state hard disk, taking into account that the available space of the solid-state hard disk changes in real time, it can be recorded in real time, and the current available space can be determined based on the recorded value, that is, the latest recorded value of the available space of the solid-state hard disk and the recording time corresponding to the latest recorded value can be obtained; the space change information between the recording time and the current time can be counted, and the space change information includes the space write amount and / or the garbage collection read amount and / or the new bad block amount; the latest recorded value is adjusted according to the space change information to obtain the target available space of the solid-state hard disk; the target available space is used as the latest recorded value, so that the available space at the next moment can be determined based on the latest recorded value.
[0104] In specific application scenarios, the method for determining the available space of the SSD can be determined according to the structure of the SSD. For example, the SSD writes and erases data in units of SuperBlock. Each SuperBlock can contain n*MultiPlane (multiple blocks written in parallel) + 1*MultiPlane physical Blocks, where n*MultiPlane Blocks store user data and 1*MultiPlane stores the check data of the first n*MultiPlane Blocks. Assuming n is 31, the structure of the SSD is shown in Table 1.
[0105] Table 1 Schematic diagram of a single super block in a solid state drive
[0106]
[0107] At this time, the available space of the solid-state drive can be determined based on the initial available space when the solid-state drive is powered on and the subsequent space change information, that is, before obtaining the latest record value of the available space of the solid-state drive, in response to the solid-state drive being powered on, the free super blocks and the write status super blocks in the solid-state drive are identified, and the super blocks include a set number of blocks. The free super block refers to a super block without any valid data, and the write status super block refers to a super block that is being written but not yet full of data. Valid data refers to data that meets user needs; determine the first number of multiple blocks written in parallel in the super block; determine the number of bad blocks in the free super block and the write status super block, the number of pages (Plane) in each block, and the unit data amount in each page, and the unit data amount is determined according to the ratio of the available space to the set data amount; determine the number of pages with data written in the write status super block; determine the free super block based on the first number, the number of bad blocks in the free super block, the number of pages in each block, and the unit data amount in each page. The available space of the block, the generation formula of the available space of the free super block can be (n*b-c1)*d*e1, wherein b represents the first quantity, c1 represents the number of bad blocks of the free super block, d represents the number of pages in each block, and e1 represents the unit data amount in each page of the free super block; according to the first quantity, the number of bad blocks of the write-state super block, the number of pages in each block, the unit data amount in each page, and the number of pages, the available space of the write-state super block is determined, and the generation formula of the available space of the write-state super block can be (n*b-c2)*(dg)*e2, wherein b represents the first quantity, c2 represents the number of bad blocks of the write-state super block, d represents the number of pages in each block, g represents the number of pages with written data in the write-state super block, and e2 represents the unit data amount in each page of the write-state super block; according to the available space of the free super block and the available space of the write-state super block, the initial available space of the solid-state drive is generated, and the generation formula of the initial available space can be expressed as , Indicates the available space of the SSD, N1 indicates the number of free super blocks, and N2 indicates the number of super blocks in write state. Represents the available space of the i-th free superblock, Indicates the available space of the j-th write-state superblock; the initial available space is taken as the latest recorded value.
[0108] From the implementation process, it can be seen that when the solid-state hard disk is powered on, the present invention determines the initial available space of the solid-state hard disk based on the available space of the free super blocks and the write status super blocks in the solid-state hard disk, so as to subsequently determine the target available space of the solid-state hard disk in real time based on the space change information, thereby realizing real-time tracing of the available space of the solid-state hard disk and ensuring the efficiency of determining the target available space. In the process of determining the initial available space, the first number of multiple blocks written in parallel in the super block is determined, the bad block number value, the number of pages in each block, and the unit data amount in each page of the free super block and the write status super block are determined, the unit data amount is determined according to the ratio of the available space to the set data amount, and the number of pages with written data in the write status super block is determined; the available space of the free super block is determined according to the first number, the bad block number value of the free super block, the number of pages in each block, and the unit data amount in each page; the available space of the write status super block is determined according to the first number, the bad block number value of the write status super block, the number of pages in each block, the unit data amount in each page, and the number of pages; the initial available space of the solid state drive is generated according to the available space of the free super block and the available space of the write status super block, so as to realize the accurate statistics of the available space of the super block according to the first number of multiple blocks written in parallel in the super block, the bad block number value, the number of pages in each block, the unit data amount in each page, and the number of pages with written data, thereby ensuring the accuracy of the determination of the initial available space.
[0109] It should be noted that in addition to the free and open states, the super block status can also include the used, reclaimed and bad states. The open state means that the data is being written but not yet full; the used state means that the data is full and there are valid and invalid data. The valid data refers to the data that meets the user's needs, and the invalid data refers to the data that does not meet the user's needs; the reclaiming state refers to the super block in the GC, and the valid data is being read and written to other open blocks; the bad state refers to the damaged super block, which is a super block with many bad blocks and is no longer used. And the SuperBlock structure can be used to record the information of each SuperBlock, as shown below:
[0110] typedef struct super_block_s {
[0111] uint8_t blockState; / / super block status
[0112] uint8_t pageNum; / / page number currently written by super block
[0113] uint8_t badBlockBitmap
[32] ; / / super block bad block table
[0114] uint8_t badBlockCount; / / Number of bad blocks in super block
[0115] uint8_t newBadBlockCount; / / Number of new bad blocks in super block
[0116] uint8_t newBadBlockBitmap
[32] ; / / super block adds a new bad block table
[0117] uint32_t vdfc; / / The number of valid dataframes in super block, i.e. the amount of valid data
[0118] uint32_t totalVdfc; / / The maximum number of dataframes that can be written to the super block
[0119] }super_block_t.
[0120] In practical applications, in the process of counting the space change information between the recording time and the current time, the space change information includes the space write amount, the second number of pages contained in each write line (WordLine) of the flash memory can be determined; the write amount statistical interval is determined; between the recording time and the current time, the first layer number of the effective layer in each write operation is counted, and the effective layer refers to the layer storing valid data; according to the second number, the first layer number, the write amount statistical interval and the unit data amount in each page, the space write amount between the recording time and the current time is generated; accordingly, in the process of adjusting the latest recorded value according to the space change information to obtain the target available space of the solid-state hard disk, the second difference between the latest recorded value and the space write amount can be generated; the second difference is used as the target available space of the solid-state hard disk, and the update process of the available space of the solid-state hard disk can be expressed as: , Indicates the write volume statistics interval. represents the first layer number of the effective layer during the mth write operation, f represents the second number, and e3 represents the unit data volume in each page of the super block written, that is, each occurrence For each write operation, the available space of the SSD is reduced once.
[0121] In a specific application scenario, in the process of counting the space change information between the recording time and the current time, the space change information includes the garbage collection read amount, the reading amount statistical interval can be determined; between the recording time and the current time, the second layer number of the effective layer at each garbage collection read is counted; according to the second layer number, the reading amount statistical interval and the unit data volume in each page, the garbage collection read amount between the recording time and the current time is generated; accordingly, in the process of adjusting the latest recorded value according to the space change information to obtain the target available space of the solid-state hard disk, the sum value between the latest recorded value and the garbage collection read amount can be generated; the sum value is used as the target available space of the solid-state hard disk, and the update process of the available space of the solid-state hard disk can be expressed as: , Indicates the reading statistics interval. Indicates the second level number of the effective level when the pth garbage collection is read, and e4 indicates the unit data volume of each page of the super block read by garbage collection, that is, each time The available space increases once for each garbage collection read operation.
[0122] In a specific application scenario, in the process of counting the space change information between the recording time and the current time, the space change information includes the amount of newly added bad blocks, the third number of newly added bad blocks in the super block of the solid-state hard disk can be counted between the recording time and the current time; the amount of newly added bad blocks between the recording time and the current time is generated according to the third number, the number of pages in each block, and the unit data volume in each page; accordingly, in the process of adjusting the latest recorded value according to the space change information to obtain the target available space of the solid-state hard disk, a third difference between the latest recorded value and the amount of newly added bad blocks can be generated; the third difference is used as the target available space of the solid-state hard disk, and the update process of the available space of the solid-state hard disk can be expressed as: T Cnt =T Cnt -(k*d*e5), k represents the third quantity, d represents the number of pages in each block, and e5 represents the unit data amount in each page of the super block of the newly added bad block.
[0123] Step S102: determining target conversion information of the host write count value and the available space of the solid state drive, wherein the target conversion information includes nonlinear and positively correlated conversion information.
[0124] Step S103: Determine the host target write count value corresponding to the target available space according to the target conversion information.
[0125] Step S104: Control the solid state drive to perform a host write operation according to the host write target number of times.
[0126] In actual applications, the present invention is provided with target conversion information of the host write count value and the available space of the solid-state hard disk, and the target conversion information includes nonlinear and positively correlated conversion information, so that when the available space of the solid-state hard disk increases, the host write count value will increase in a nonlinear manner, and when the available space of the solid-state hard disk decreases, the host write count value will decrease in a nonlinear manner. Therefore, after determining the target available space, it is necessary to determine the host write target count value corresponding to the target available space according to the target conversion information, that is, it is necessary to determine the host write target count value adapted to the target available space, so as to control the solid-state hard disk to perform the host write operation according to the host write target count value.
[0127] In actual applications, after determining the host write target number value corresponding to the target available space according to the target conversion information, the garbage collection write target number value of the solid-state drive can also be determined based on the host write target number value; accordingly, in the process of controlling the solid-state drive to perform host write operations according to the host write target number value, the solid-state drive can be controlled to perform host write operations according to the host write target number value, and the solid-state drive can be controlled to perform garbage collection write operations according to the garbage collection write target number value.
[0128] It can be seen from the implementation process that, compared with the existing linear conversion information, the present invention makes the process of the host write count value changing with the available space more detailed, thereby making the process of the host write operation reducing the available space of the solid-state hard disk more detailed, and because the garbage collection write target count value is compatible with the host write target count value, the garbage collection operation of the solid-state hard disk is also more detailed, achieving a more detailed balance between the available space, the host write operation and the garbage collection operation, and then controlling the solid-state hard disk to perform the host write operation according to the host write target count value and controlling the solid-state hard disk to perform the garbage collection write operation according to the garbage collection write target count value, so that the host write operation of the host write target count value times and the garbage collection write operation of the garbage collection write target count value times are performed in the same process, reducing the write amplification factor of the solid-state hard disk and improving the service life of the solid-state hard disk. Among them, the write amplification factor refers to the ratio of the write sum value to the host write, and the write sum value refers to the sum of the host write and the garbage collection write.
[0129] In a specific application scenario, in the process of determining the target conversion information of the host write count value and the available space of the solid-state hard disk, the set total count value can be obtained, and the total count value includes the total count value of write operations determined according to the size of the cached data; the minimum set value and the maximum set value of the available space of the solid-state hard disk are determined, the minimum set value can be determined according to the minimum available space that the solid-state hard disk must perform garbage collection operations, and the maximum set value can be determined according to the minimum available space that allows the host write operation to be fully performed; according to the total count value, the minimum set value and the maximum set value, the target conversion information of the host write count value and the available space of the solid-state hard disk is generated. Further, in the process of generating the target conversion information of the host write count value and the available space of the solid-state hard disk according to the total count value, the minimum set value and the maximum set value, the available space of the solid-state hard disk can be used as the horizontal coordinate value; the host write count value can be used as the vertical coordinate value; with the host write count value corresponding to the minimum set value T1 being zero and the host write count value corresponding to the maximum set value T0 being the total count value S0 as constraints, an elliptic curve of the host write count value and the available space of the solid-state hard disk is generated, such as Figure 2 As shown, S0=H R +G R , , H R Indicates the number of host write times, G R Indicates the garbage collection write count value; in the elliptic curve, the curve segment in which the host write count value is positively correlated with the available space of the solid-state drive and the value is non-negative is used as the target conversion information, so as to generate the target conversion information with the help of the elliptic curve.
[0130] In a specific application scenario, in the process of determining the host write target number value corresponding to the target available space according to the target conversion information, it can be determined whether the target available space is greater than or equal to the maximum setting value; in response to the target available space being greater than or equal to the maximum setting value, the host write target number value corresponding to the target available space is determined to be the total number value, at which time the available space of the solid-state hard disk is sufficient, and only host write operations can be performed; in response to the target available space being less than the maximum setting value, it is determined whether the target available space is greater than the minimum setting value; in response to the target available space being greater than the minimum setting value, the target available space is operated according to the target conversion information to obtain the operation number value, and the operation number value is rounded down to obtain the host write target number value corresponding to the target available space, at which time host write operations and garbage collection operations can be performed simultaneously; in response to the target available space being less than or equal to the minimum setting value, it is determined that the host write target number value corresponding to the target available space is zero, at which time only garbage collection operations can be performed; accordingly, in the process of determining the garbage collection write target number value of the solid-state hard disk according to the host write target number value, a first difference between the total number value and the host write target number value can be generated; the first difference is used as the garbage collection write target number value of the solid-state hard disk.
[0131] In a specific application scenario, in the process of controlling the solid-state hard disk to perform a host write operation according to the host write target number value, and controlling the solid-state hard disk to perform a garbage collection write operation according to the garbage collection write target number value, the set number of operation batches can be obtained, and this number of operation batches is used to determine the time when the host write target number value and the garbage collection write target number value are consumed; the host write target number value is divided according to the number of operation batches to obtain the host write number sub-values of each batch, and the garbage collection write target number value is divided according to the number of operation batches to obtain the garbage collection write number sub-values of each batch, and the division method can be a balanced division or other division methods; from the first batch to the end of the last batch, the host write number sub-value of the current batch is used as the host write bucket size value, and the garbage collection write number sub-value of the current batch is used as the garbage collection write bucket size value; if a host write operation is performed, the host write bucket size value is reduced by one, and if a garbage collection write operation is performed, the garbage collection write bucket size value is reduced by one, until the host write bucket size value and the garbage collection write bucket size value are both zero and then enter the next batch. In this way, in each batch, host write operations sub-valued by the host write count and garbage collection write operations sub-valued by the garbage collection write count are performed, thereby controlling the write traffic of host writes and garbage collection writes through token buckets, making the write of host writes and garbage collection writes smoother, further avoiding write amplification of the SSD and increasing the life of the SSD.
[0132] The present invention provides a hard disk operation method, which determines the target available space of a solid state hard disk; determines the target conversion information of the host write count value and the available space of the solid state hard disk, wherein the target conversion information includes nonlinear and positively correlated conversion information; determines the host write target count value corresponding to the target available space according to the target conversion information; and controls the solid state hard disk to perform a host write operation according to the host write target count value. The beneficial effect of the present invention is that the host write count value and the target conversion information of the available space of the solid state hard disk are nonlinear and positively correlated conversion information, so that as the target available space of the solid state hard disk increases, the corresponding host write target count value will increase in a nonlinear form, and similarly, as the target available space of the solid state hard disk decreases, the corresponding host write target count value will decrease in a nonlinear form, and compared with the existing linear conversion information, the host write count value changes with the available space more meticulously, thereby making the process of the host write operation reducing the available space of the solid state hard disk more meticulous, making the garbage collection operation of the solid state hard disk more meticulous, achieving a more meticulous balance between the available space, the host write operation and the garbage collection operation, and improving the service life of the solid state hard disk.
[0133] On the basis of the above embodiment, if the process of controlling the solid-state hard disk to perform the host write operation according to the host write target number value, and controlling the solid-state hard disk to perform the garbage collection write operation according to the garbage collection write target number value is made into a passive GC, the user can also actively control the garbage collection operation of the solid-state hard disk, that is, active GC can be performed, and the active GC and passive GC processes can be switched with each other. For example, before determining the target conversion information of the host write number value and the available space of the solid-state hard disk, it can also be detected whether the set active triggering condition of the garbage collection operation is met; in response to satisfying the active triggering condition, only the garbage collection operation is performed on the solid-state hard disk, that is, only the active GC is performed, and after completing the garbage collection of a super block, it is detected whether the set active end condition of the garbage collection operation is met; in response to not satisfying the active end condition, returning to the step of performing only the garbage collection operation on the solid-state hard disk; in response to satisfying the active end condition, the step of determining the target conversion information of the host write number value and the available space of the solid-state hard disk is executed, that is, switching to passive GC; in response to not satisfying the active triggering condition, the step of determining the target conversion information of the host write number value and the available space of the solid-state hard disk is executed, that is, switching to passive GC.
[0134] In specific application scenarios, the active termination conditions can be flexibly adjusted as needed. For example, in the process of detecting whether the active termination conditions of the set garbage collection operation are met, the target number u super blocks that will be subjected to the garbage collection operation at the end can be used as the blocks to be detected; the effective unit data volume q in each block to be detected is counted, and the effective unit data volume refers to the unit data volume of the stored effective data; the maximum unit data volume r that can be written in each block to be detected is counted, and the maximum unit data volume refers to the unit data volume of the writable space; according to the ratio of the effective unit data volume to the maximum unit data volume, the effective data ratio value V of the solid-state drive is generated, and the generation formula of the effective data ratio value can be ,q s represents the effective unit data volume of the sth block to be detected, r s It indicates the maximum unit data amount that can be written in the sth block to be detected, and s increases from 1 to u; it detects whether the effective data ratio is greater than or equal to the set data ratio, and the set data ratio can be flexibly determined, such as 90, 92, etc.; in response to the effective data ratio being greater than or equal to the set data ratio, it indicates that the effective data ratio in the super block is too high. At this time, the efficiency of active GC is low, and the write amplification caused is too large. Therefore, it can be determined that the active end condition of the set garbage collection operation is met to avoid the write amplification of the solid-state hard disk caused by active GC, thereby further improving the service life of the solid-state hard disk.
[0135] In specific application scenarios, the active triggering conditions can be flexibly adjusted as needed. For example, in the process of detecting whether the active triggering conditions of the set garbage collection operation are met, the real-time duration of the garbage collection operation on the solid-state hard disk can be accumulated; detect whether the real-time duration is greater than the set duration, and this set duration is used to constrain the execution interval of the active GC; in response to the real-time duration being greater than the set duration, detect whether the target available space is less than the set threshold, and the set threshold can be the minimum available space, etc.; in response to the target available space being less than the set threshold, it is determined that the active triggering conditions of the set garbage collection operation are met; accordingly, in the process of detecting whether the active termination conditions of the set garbage collection operation are met, the target available space of the solid-state hard disk can be updated; detect whether the updated target available space is greater than or equal to the set threshold; in response to the updated target available space being greater than or equal to the set threshold, it is determined that the active termination conditions of the set garbage collection operation are met. In addition, during the process of performing garbage collection operation only on the solid-state hard disk, it is also possible to detect whether a host write operation occurs; in response to a host write operation occurring, the garbage collection operation only on the solid-state hard disk is suspended, and the step of determining the target conversion information of the host write count value and the available space of the solid-state hard disk is executed; after waiting for the target time, the step of returning to the step of detecting whether the set active triggering condition of the garbage collection operation is met is executed. This process can be as follows Figure 3 shown.
[0136] From this implementation process, it can be seen that the present invention will trigger an active GC operation when the stop time of the active GC exceeds the set time, and / or the target available space is less than the set threshold, so that the user can control the process of the active GC by setting the set time and the set threshold accordingly, thereby improving the user experience; and when the active GC is not in progress or there is a host write during the active GC process, it will switch to the passive GC, realizing the combination of active GC and passive GC, which can more flexibly and accurately control the host write and garbage collection write operations of the solid-state hard disk, avoid the increase of the write amplification factor of the solid-state hard disk, and ensure the service life of the solid-state hard disk.
[0137] It should be noted that users can control the active GC process through the NVMe (Non Volatile Memory Host Controller Interface Specification) protocol. For example, the active GC custom commands include three categories: query, setting, and control. Each category contains several sub-commands. The contents are shown in Table 2. The query return results of active GC are shown in Table 3. The active GC setting input parameters are shown in Table 4.
[0138] Table 2 NVMe protocol content table
[0139]
[0140] Table 3 Active GC query results
[0141]
[0142] Table 4 Active GC setting input parameters
[0143]
[0144] The present invention also provides an electronic device and a computer-readable storage medium, both of which have the corresponding effects of the hard disk operation method provided in the embodiment of the present invention. Figure 4 , Figure 4 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention.
[0145] An electronic device provided by an embodiment of the present invention includes a memory 201 and a processor 202. The memory 201 stores a computer program. When the processor 202 executes the computer program, the steps of the hard disk operation method described in any of the above embodiments are implemented.
[0146] See also Figure 5 Another electronic device provided in an embodiment of the present invention may also include: an input port 203 connected to the processor 202, used to transmit commands input from the outside to the processor 202; a display unit 204 connected to the processor 202, used to display the processing results of the processor 202 to the outside; a communication module 205 connected to the processor 202, used to realize the communication between the electronic device and the outside. The display unit 204 can be a display panel, a laser scanning display, etc.; the communication mode adopted by the communication module 205 includes but is not limited to mobile high-definition link technology (Mobile High-Definition Link, MHL), Universal Serial Bus (Universal Serial Bus, USB), High-Definition Multimedia Interface (High-Definition Multimedia Interface, HDMI), wireless connection: wireless fidelity technology (WIreless Fidelity, WiFi), Bluetooth communication technology, low-power Bluetooth communication technology, and communication technology based on IEEE802.11s.
[0147] An embodiment of the present invention provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of the hard disk operation method described in any of the above embodiments are implemented.
[0148] The computer-readable storage medium involved in the present invention includes random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, register, hard disk, removable disk, CD-ROM (Compact Disc Read-Only Memory), or any other form of storage medium known in the technical field.
[0149] A computer program product provided by an embodiment of the present invention includes a computer program / instruction, and when the computer program / instruction is executed by a processor, the steps of the hard disk operation method described in any of the above embodiments are implemented.
[0150] For the description of the relevant parts of a computer program product, an electronic device, and a computer-readable storage medium provided by the embodiment of the present invention, please refer to the detailed description of the corresponding parts in a hard disk operation method provided by the embodiment of the present invention, which will not be repeated here. In addition, the parts of the above technical solutions provided by the embodiment of the present invention that are consistent with the implementation principles of the corresponding technical solutions in the prior art are not described in detail to avoid excessive elaboration.
[0151] It should also be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0152] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A hard disk operation method, characterized in that: include: Determine the target free space of the SSD; Determine target conversion information of the host write count value and the available space of the solid state drive, wherein the target conversion information includes nonlinear and positively correlated conversion information; Determine, according to the target conversion information, a host write target number value corresponding to the target available space; Controlling the solid state drive to perform a host write operation according to the host write target number of times; Wherein, determining the target conversion information of the host write count value and the available space of the solid state drive includes: Obtaining a set total number of times, the total number of times including a total number of write operations determined according to a size of cached data; Determining a minimum setting value and a maximum setting value of the available space of the solid state drive; According to the total number of times, the minimum setting value and the maximum setting value, target conversion information of the host write count value and the available space of the solid state drive is generated.
2. The hard disk operation method according to claim 1, characterized in that: After determining the host write target number value corresponding to the target available space according to the target conversion information, the method further includes: Determining a garbage collection write target number value of the solid state drive according to the host write target number value; Controlling the solid state drive to perform a host write operation according to the host write target number of times, including: The solid state drive is controlled to perform a host write operation according to the host write target number of times, and the solid state drive is controlled to perform a garbage collection write operation according to the garbage collection write target number of times.
3. The hard disk operation method according to claim 1, characterized in that: Generating target conversion information of the host write count value and the available space of the solid state drive according to the total count value, the minimum set value and the maximum set value, including: Using the available space of the solid state drive as the horizontal axis value; The host write count value is used as the vertical axis value; Using the host write count value corresponding to the minimum setting value as zero and the host write count value corresponding to the maximum setting value as the total count value as constraint conditions, generating an elliptic curve of the host write count value and the available space of the solid state drive; In the elliptic curve, a curve segment in which the host write count value is positively correlated with the available space of the solid state drive and has a non-negative value is used as target conversion information.
4. The hard disk operation method according to claim 3, characterized in that: Determining, according to the target conversion information, a host target write count value corresponding to the target available space, including: Determine whether the target available space is greater than or equal to the maximum setting value; In response to the target available space being greater than or equal to the maximum setting value, determining the host write target number value corresponding to the target available space to be the total number value; In response to the target available space being less than the maximum setting value, determining whether the target available space is greater than the minimum setting value; In response to the target available space being greater than the minimum set value, the target available space is operated according to the target conversion information to obtain an operation count value, and the operation count value is rounded down to obtain a host write target count value corresponding to the target available space; In response to the target available space being less than or equal to the minimum setting value, determining that the host write target number value corresponding to the target available space is zero; Determining a garbage collection write target number value of the solid state drive according to the host write target number value includes: Generate a first difference between the total number of times and the host write target number of times; The first difference is used as a target number of garbage collection write times of the solid state drive.
5. The hard disk operation method according to claim 2, characterized in that: Controlling the solid state drive to perform a host write operation according to the host write target number of times, and controlling the solid state drive to perform a garbage collection write operation according to the garbage collection write target number of times, including: Get the set number of operation batches; Dividing the host write target number value according to the number of operation batches to obtain host write number sub-values of each batch; Dividing the garbage collection write target number value according to the number of operation batches to obtain garbage collection write number sub-values of each batch; From the beginning of the first batch to the end of the last batch, the host write count sub-value of the current batch is used as the host write bucket size value, and the garbage collection write count sub-value of the current batch is used as the garbage collection write bucket size value; if a host write operation is performed, the host write bucket size value is reduced by one, and if a garbage collection write operation is performed, the garbage collection write bucket size value is reduced by one, until the host write bucket size value and the garbage collection write bucket size value are both zero and then enter the next batch.
6. The hard disk operation method according to claim 1, characterized in that: Determine the target free space for the SSD, including: Get the latest recorded value of the available space of the solid state drive and the recording time corresponding to the latest recorded value; Counting space change information between the recording time and the current time, wherein the space change information includes space write amount and / or garbage collection read amount and / or newly added bad block amount; Adjust the latest recorded value according to the space change information to obtain the target available space of the solid state drive; The target available space is taken as the latest recorded value.
7. The hard disk operation method according to claim 6, characterized in that: Before obtaining the latest recorded value of the available space of the solid-state drive, it also includes: In response to the solid state drive being powered on, identifying a free super block and a write-status super block in the solid state drive, the super block including a set number of blocks; Determine a first number of blocks in the superblock to be written in parallel; Determine the number of bad blocks of each free super block and write-state super block, the number of pages in each block, and the unit data volume in each page, wherein the unit data volume is determined according to the ratio of available space to a set data volume; Determine the number of pages in the write-status superblock that have data written to it; Determine the available space of the free super block according to the first number, the number of bad blocks in the free super block, the number of pages in each block, and the unit data amount in each page; Determine the available space of the super block in the write state according to the first number, the bad block number value of the super block in the write state, the number of pages in each block, the unit data amount in each page and the number of pages; Generate initial available space of the solid state drive according to available space of the free super block and available space of the write-state super block; The initial available space is taken as the latest recorded value.
8. The hard disk operation method according to claim 7, characterized in that: The space change information between the statistical recording time and the current time, wherein the space change information includes the space writing amount, includes: determining a second number of pages included in each write row of the flash memory; Determine the interval for writing statistics; Between the recording time and the current time, count the number of first layers of the valid layers in each write operation; Generate a space write amount between a recording time and a current time according to the second amount, the first layer number, the write amount statistical interval and the unit data amount in each page; The latest recorded value is adjusted according to the space change information to obtain the target available space of the solid state drive, including: Generate a second difference between the latest recorded value and the space writing amount; The second difference is used as the target available space of the solid state drive.
9. The hard disk operation method according to claim 7, characterized in that: Count the space change information between the recording time and the current time, the space change information includes the garbage collection read amount, including: Determine the reading volume statistics interval; Between the recording time and the current time, count the number of second layers of the valid layer at each garbage collection read; Generate a garbage collection read amount between a recording time and a current time according to the second layer number, the read amount statistical interval and the unit data amount in each page; The latest recorded value is adjusted according to the space change information to obtain the target available space of the solid state drive, including: Generate a sum of the latest record value and the garbage collection reading amount; The sum is used as the target available space of the solid state drive.
10. The hard disk operation method according to claim 7, characterized in that: The space change information between the statistical recording time and the current time, wherein the space change information includes the amount of newly added bad blocks, includes: Between the recording time and the current time, counting a third number of bad blocks newly added in the super block of the solid state drive; Generate the amount of newly added bad blocks between the recording time and the current time according to the third amount, the number of pages in each block, and the unit data amount in each page; The latest recorded value is adjusted according to the space change information to obtain the target available space of the solid state drive, including: generating a third difference between the latest recorded value and the amount of newly added bad blocks; The third difference is used as the target available space of the solid state drive.
11. The hard disk operation method according to any one of claims 1 to 10, characterized in that: Before determining the target conversion information of the host write count value and the available space of the solid state drive, the method further includes: Detect whether the set active triggering conditions for garbage collection operations are met; In response to the active triggering condition being met, only the garbage collection operation is performed on the solid state drive, and after the garbage collection of a super block is completed, it is detected whether the set active end condition of the garbage collection operation is met; In response to not meeting the active termination condition, returning to the step of performing the garbage collection operation only on the solid state drive; In response to the active termination condition being met, the step of determining target conversion information of the host write count value and the available space of the solid state drive is performed; In response to the active trigger condition not being met, the step of determining target conversion information of the host write count value and the available space of the solid state drive is performed.
12. The hard disk operation method according to claim 11, characterized in that: Check whether the active end conditions of the garbage collection operation are met, including: The target number of super blocks that have undergone garbage collection operations last are used as blocks to be detected; Count the amount of valid unit data in each block to be detected; Count the maximum unit data volume that can be written in each block to be detected; Generate a valid data ratio of the solid state drive according to the ratio of the valid unit data volume to the maximum unit data volume; Detecting whether the effective data ratio is greater than or equal to a set data ratio; In response to the valid data proportion being greater than or equal to the set data proportion, it is determined that the set active termination condition of the garbage collection operation is met.
13. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instruction is executed by a processor, the steps of the hard disk operation method described in any one of claims 1 to 12 are implemented.
14. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the hard disk operation method according to any one of claims 1 to 12 when executing the computer program.
15. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the hard disk operating method according to any one of claims 1 to 12 are implemented.
Citation Information
Patent Citations
Non-volatile memory with scheduled reclaim operations
CN101278267A