Data writing method of flash memory storage device and related device
By determining and writing subprogramming units of unwritten data in the flash storage medium, the problem of increasing write amplification caused by waste of write space is solved, and more efficient storage utilization is achieved.
Patent Information
- Application Number
- CN202411898989.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-23
- Publication Date
- 2025-04-18
AI Technical Summary
In the small IO random read and write scenario, the waste of write space of flash storage media leads to the problem of increasing write amplification.
By obtaining the data to be written and according to the specified subprogramming unit and the minimum programming unit of the last write operation, the target subprogramming unit is determined from the subprogramming unit where the data is not written, and the data is written to the target subprogramming unit to maximize the use of the storage space.
Reduces space waste caused by partially writing data into the smallest programming unit, and reduces the occurrence of write amplification.
Smart Images

Figure CN119847429A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of solid-state storage technology, and in particular to a method for writing data into a flash memory storage device and a related device. Background Art
[0002] With the advancement of solid-state storage manufacturing technology, the storage density of flash storage media is getting higher and higher, and the storage capacity is getting larger and larger. However, as people's needs continue to increase, they are limited by the limited width and length of flash storage media units. In small IO random read and write scenarios, the amount of data written to the flash storage medium each time is only 4KB, which cannot fill up a minimum programming unit of the flash storage medium (generally the minimum programming unit is 16KB). The next time data is written, a new minimum programming unit will be written directly, so that the minimum programming unit where data was written last time will have remaining space, which will lead to a waste of write space, thereby increasing write amplification. Summary of the invention
[0003] The object of the present invention is to provide a data writing method, device, electronic device and computer-readable storage medium to solve the problem of increased write amplification caused by waste of writing space.
[0004] In a first aspect, the present invention provides a method for writing data to a flash memory storage device, wherein the flash memory storage medium includes a plurality of minimum programming units, each of which is divided into a plurality of sub-programming units; the method comprises:
[0005] Get the data to be written;
[0006] Determine a target sub-programming unit from sub-programming units in which data is not written in the flash memory storage medium according to a designated sub-programming unit corresponding to a last data writing operation and a minimum programming unit to which the designated sub-programming unit belongs;
[0007] The to-be-written data is written into the target sub-programming unit.
[0008] In an optional embodiment, the determining the target sub-programming unit from the sub-programming units in which data is not written in the flash memory storage medium according to the designated sub-programming unit corresponding to the last data writing operation and the minimum programming unit to which the designated sub-programming unit belongs includes:
[0009] If the minimum programming unit to which the designated sub-programming unit belongs is not fully written with data, determining the next sub-programming unit adjacent to the designated sub-programming unit as the target sub-programming unit;
[0010] If the minimum programming unit to which the designated sub-programming unit belongs is fully written with data, the next minimum programming unit adjacent to the minimum programming unit to which the designated sub-programming unit belongs is determined, and the first sub-programming unit in the next minimum programming unit is determined as the target sub-programming unit.
[0011] In an optional implementation, the step of determining a target sub-programming unit from sub-programming units in which data is not written in the flash memory storage medium according to a designated sub-programming unit corresponding to a last data writing operation and a minimum programming unit to which the designated sub-programming unit belongs includes:
[0012] If the minimum programming unit to which the designated sub-programming unit belongs is not the last minimum programming unit in the flash memory storage medium, determining an offset position of the designated sub-programming unit in the minimum programming unit to which it belongs and a next minimum programming unit adjacent to the minimum programming unit to which the designated sub-programming unit belongs, and determining a target sub-programming unit from among a plurality of sub-programming units of the next minimum programming unit according to the offset position; the offset position of the target sub-programming unit in the next minimum programming unit is the same as the offset position of the designated sub-programming unit in the minimum programming unit to which it belongs;
[0013] If the minimum programming unit to which the designated sub-programming unit belongs is the last minimum programming unit in the flash memory storage medium and is not fully written with data, the offset position of the next sub-programming unit adjacent to the designated sub-programming unit in the minimum programming unit to which it belongs is determined, and a target sub-programming unit is determined among multiple sub-programming units of the first minimum programming unit in the flash memory storage medium based on the offset position; the offset position of the target sub-programming unit in the first minimum programming unit is the same as the offset position of the next sub-programming unit adjacent to the designated sub-programming unit in the minimum programming unit to which it belongs.
[0014] In an optional implementation manner, obtaining the data to be written includes:
[0015] Get initial data;
[0016] If the size of the initial data is larger than the maximum storage capacity of the sub-programming unit, the initial data is divided into a plurality of data to be written according to the maximum storage capacity; the size of each of the data to be written is smaller than or equal to the maximum storage capacity;
[0017] If the size of the initial data is less than or equal to the maximum storage capacity of the sub-programming unit, the initial data is determined as the data to be written.
[0018] In an optional implementation, writing the to-be-written data into the target sub-programming unit includes:
[0019] Generate a data write instruction according to the data to be written and the target sub-programming unit;
[0020] The data write instruction is sent to the flash memory storage medium so that the flash memory storage medium writes the data to be written into the target sub-programming unit according to the data write instruction.
[0021] In an optional implementation manner, recording the sub-programming unit in which data has been written to the flash memory storage medium and the minimum programming unit to which the sub-programming unit in which data has been written belongs; the method further comprises:
[0022] The target sub-programming unit into which data has been written and the minimum programming unit to which the target sub-programming unit belongs are recorded.
[0023] In an optional implementation, the data write instruction is a change write column (85h) command.
[0024] In a second aspect, the present invention provides a data writing device, wherein a flash memory storage medium includes a plurality of minimum programming units, each of which is divided into a plurality of sub-programming units; the device includes:
[0025] A module for acquiring data to be written, used for acquiring data to be written;
[0026] a target sub-programming unit determining module, configured to determine a target sub-programming unit from sub-programming units in which data is not written in the flash memory storage medium according to a designated sub-programming unit corresponding to a last data writing operation and a minimum programming unit to which the designated sub-programming unit belongs;
[0027] A data writing module is used to write the data to be written into the target sub-programming unit.
[0028] In a third aspect, the present invention provides a flash memory storage device, which includes a main controller and multiple flash memory chips, and the main controller executes instructions to implement the data writing method described in any of the aforementioned implementation methods.
[0029] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the data writing method as described in any one of the aforementioned embodiments.
[0030] The data writing method, device, electronic device and computer-readable storage medium provided by the embodiments of the present invention are applied to an electronic device, the electronic device is communicatively connected with a flash memory storage medium, the flash memory storage medium includes a plurality of minimum programming units, each minimum programming unit is divided into a plurality of sub-programming units, the method includes: obtaining the data to be written, determining the target sub-programming unit from the sub-programming units in the flash memory storage medium where the data has not been written according to the designated sub-programming unit corresponding to the last data writing operation and the minimum programming unit to which the designated sub-programming unit belongs, and writing the data to be written into the target sub-programming unit. By writing the data to be written into the sub-programming unit in the minimum programming unit where the data has not been written, the storage space of each minimum programming unit can be utilized to the maximum extent, reducing the space waste caused by writing data into part of the minimum programming unit and not writing data into the remaining part, thereby reducing write amplification. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0032] Figure 1 A schematic diagram showing a flow chart of a method for writing data into a flash memory storage device provided by an embodiment of the present invention;
[0033] Figure 2 Another schematic diagram of a flow chart of a method for writing data into a flash memory storage device provided by an embodiment of the present invention is shown;
[0034] Figure 3 A schematic diagram of writing data to be written provided by an embodiment of the present invention is shown;
[0035] Figure 4 Another schematic diagram of writing data to be written provided by an embodiment of the present invention is shown;
[0036] Figure 5 Another schematic diagram of a flow chart of a method for writing data into a flash memory storage device provided by an embodiment of the present invention is shown;
[0037] Figure 6 Another schematic diagram of writing data to be written provided by an embodiment of the present invention is shown;
[0038] Figure 7 Another schematic diagram of writing data to be written provided by an embodiment of the present invention is shown;
[0039] Figure 8A module block diagram of a data writing device provided by an embodiment of the present invention is shown.
[0040] Icons: 200 - data writing device; 210 - module for acquiring data to be written; 220 - module for determining target sub-programming unit; 230 - module for writing data. DETAILED DESCRIPTION
[0041] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0042] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. 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.
[0043] It should be noted that relational terms such as "first" and "second" are used only 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", "comprises" 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, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0044] See also Figure 1 , Figure 1 A schematic diagram of a method for writing data to a flash memory device provided by an embodiment of the present invention is shown. The flash memory storage medium includes multiple minimum programming units, each of which is divided into multiple sub-programming units. The specific process of this embodiment is described below using an electronic device as an example. Figure 1 The process shown in FIG. 1 is described in detail, and the data writing method of the flash memory storage device may specifically include the following steps:
[0045] Step 110: Obtain data to be written.
[0046] The data to be written is less than or equal to the maximum storage capacity of the sub-programming unit.
[0047] Step 120: Determine a target sub-programming unit from sub-programming units in which data is not written in the flash memory storage medium according to the designated sub-programming unit corresponding to the last data writing operation and the minimum programming unit to which the designated sub-programming unit belongs.
[0048] The minimum programming unit is an address range that can be operated when performing a data write operation. For different types of flash memories, the address range that can be operated by the minimum programming unit is different.
[0049] For example, the maximum storage capacity of the minimum programming unit is 16 KB, the minimum programming unit is divided into 4 sub-programming units, and the maximum storage capacity of each sub-programming unit is 4 KB.
[0050] In some embodiments, the flash memory storage medium stores the number of divisions of each minimum programming unit into multiple sub-programming units and the starting address of each minimum programming unit, and the starting address of each sub-programming unit can be obtained based on the number of divisions and the starting address of each minimum programming unit.
[0051] For example, if the number of divisions is 2, the maximum storage capacity of the minimum programming unit is 16KB, the maximum storage capacity of each sub-programming unit is 8KB (0x2000 (8*1024)), and the starting address of the minimum programming unit is 0x00000000, then the starting address of the first sub-programming unit of the minimum programming unit is 0x00000000, and the starting address of the second sub-programming unit of the minimum programming unit is 0x00002000 (0x00000000+0x2000). Among them, 0x00000000, 0x00002000 and 0x2000 are all hexadecimal numbers.
[0052] Step 130: Write the data to be written into the target sub-programming unit.
[0053] The data writing method provided by the embodiment of the present invention obtains the data to be written, determines the target sub-programming unit from the sub-programming units in the flash storage medium where the data has not been written, and writes the data to be written into the target sub-programming unit according to the designated sub-programming unit corresponding to the last data writing operation and the minimum programming unit to which the designated sub-programming unit belongs. By writing the data to be written into the sub-programming unit in the minimum programming unit where the data has not been written, the storage space of each minimum programming unit can be utilized to the maximum extent, and the space waste caused by writing data into part of the minimum programming unit and not writing data into the remaining part can be reduced, thereby reducing write amplification.
[0054] In practical applications, the type and characteristics of the flash storage medium can be used to determine the Figure 2The method shown, or use Figure 5 The method shown determines a target sub-programming unit.
[0055] In some embodiments, Figure 2 As shown, step 120 specifically further includes the following steps:
[0056] Step 121A: If the minimum programming unit to which the designated sub-programming unit belongs is not fully written with data, then the next sub-programming unit adjacent to the designated sub-programming unit is determined as the target sub-programming unit.
[0057] the following Figure 3 , Figure 4 , Figure 6 as well as Figure 7 In the example, it is taken that there are 4 minimum programming units Page in the flash memory storage medium, and each minimum programming unit is divided into 4 sub-programming units Subpage.
[0058] like Figure 3 As shown in (a), the designated sub-programming unit is the sub-programming unit Subpage2 in the minimum programming unit Page0. If the minimum programming unit Page0 is not fully written with data, the sub-programming unit Subpage3 in the minimum programming unit Page0 is determined as the target sub-programming unit. After the data to be written is written, Figure 3 (b) as shown.
[0059] Step 122A: If the minimum programming unit to which the designated sub-programming unit belongs is fully written with data, determine the next minimum programming unit adjacent to the minimum programming unit to which the designated sub-programming unit belongs, and determine the first sub-programming unit in the next minimum programming unit as the target sub-programming unit.
[0060] like Figure 4 As shown in (a), the sub-programming unit is designated as the sub-programming unit Subpage3 in the minimum programming unit Page0. The minimum programming unit Page0 has been fully written with data. The next minimum programming unit Page1 adjacent to the minimum programming unit Page0 is determined, and the first sub-programming unit Subpage0 in the minimum programming unit Page1 is determined as the target sub-programming unit. After writing the data to be written, as shown in FIG. Figure 4 (b) as shown.
[0061] In some embodiments, Figure 5 As shown, step 120 specifically further includes the following steps:
[0062] Step 121B: If the minimum programming unit to which the specified sub-programming unit belongs is not the last minimum programming unit in the flash memory storage medium, determine the offset position of the specified sub-programming unit in the minimum programming unit to which it belongs and the next minimum programming unit adjacent to the minimum programming unit to which the specified sub-programming unit belongs, and determine the target sub-programming unit among the multiple sub-programming units of the next minimum programming unit based on the offset position; the offset position of the target sub-programming unit in the next minimum programming unit is the same as the offset position of the specified sub-programming unit in the minimum programming unit to which it belongs.
[0063] The offset position is the offset of the starting address of the designated sub-programming unit relative to the starting address of the minimum programming unit to which the designated sub-programming unit belongs. For example, the maximum storage capacity of the minimum programming unit is 16KB, the maximum storage capacity of each sub-programming unit is 4KB (0x1000 (4*1024)), and the starting address of the minimum programming unit is 0x00004000. If the starting address of the designated sub-programming unit is 0x00005000, then the offset of the starting address of the designated sub-programming unit relative to the starting address of the minimum programming unit to which the designated sub-programming unit belongs is 0x1000, that is, the designated sub-programming unit is the second sub-programming unit in the minimum programming unit to which it belongs; if the starting address of the designated sub-programming unit is 0x00006000, then the offset of the starting address of the designated sub-programming unit relative to the starting address of the minimum programming unit to which the designated sub-programming unit belongs is 0x2000 (2 0x1000), that is, the designated sub-programming unit is the third sub-programming unit in the minimum programming unit to which it belongs.
[0064] like Figure 6 As shown in (a), the maximum storage capacity of the minimum programming unit is 16KB, the maximum storage capacity of each sub-programming unit is 4KB (0x1000 (4*1024)), the designated sub-programming unit is the sub-programming unit Subpage0 in the minimum programming unit Page0, the minimum programming unit Page0 to which the designated sub-programming unit (the sub-programming unit Subpage0 in the minimum programming unit Page0) belongs is not the last minimum programming unit in the flash storage medium, the offset position of the designated sub-programming unit (the sub-programming unit Subpage0 in the minimum programming unit Page0) in the minimum programming unit Page0 to which it belongs is determined to be 0x00000000, and the next minimum programming unit adjacent to the minimum programming unit Page0 to which the designated sub-programming unit (the sub-programming unit Subpage0 in the minimum programming unit Page0) belongs is Page1, and according to the offset position 0x00000000, the first sub-programming unit Subpage0 in the minimum programming unit Page1 is determined as the target sub-programming unit, and after writing the data to be written, as shown in FIG. Figure 6 (b) as shown.
[0065] Step 122B: If the minimum programming unit to which the designated sub-programming unit belongs is the last minimum programming unit in the flash memory storage medium and is not fully written with data, determine the offset position of the next sub-programming unit adjacent to the designated sub-programming unit in the minimum programming unit to which it belongs, and determine the target sub-programming unit among the multiple sub-programming units of the first minimum programming unit in the flash memory storage medium based on the offset position; the offset position of the target sub-programming unit in the first minimum programming unit is the same as the offset position of the next sub-programming unit adjacent to the designated sub-programming unit in the minimum programming unit to which it belongs.
[0066] like Figure 7 As shown in (a), the maximum storage capacity of the minimum programming unit is 16KB, the maximum storage capacity of each sub-programming unit is 4KB (0x1000 (4*1024)), the designated sub-programming unit is the sub-programming unit Subpage2 in the minimum programming unit Page3, the minimum programming unit Page3 to which the designated sub-programming unit (the sub-programming unit Subpage2 in the minimum programming unit Page3) belongs is the last minimum programming unit in the flash memory storage medium, the offset position of the designated sub-programming unit (the sub-programming unit Subpage2 in the minimum programming unit Page3) in the minimum programming unit Page3 to which it belongs is determined to be 0x00002000, the offset position of the next sub-programming unit adjacent to the designated sub-programming unit in the minimum programming unit to which it belongs is 0x00003000, the sub-programming unit Subpage3 with an offset position of 0x00003000 in the first minimum programming unit Page0 in the flash memory storage medium is determined as the target sub-programming unit, and after writing the data to be written, as shown in FIG. Figure 7 (b) as shown.
[0067] In some embodiments, step 110 specifically also includes the following steps: obtaining initial data; if the size of the initial data is larger than the maximum storage capacity of the sub-programming unit, dividing the initial data into multiple data to be written according to the maximum storage capacity, and the size of each data to be written is less than or equal to the maximum storage capacity; if the size of the initial data is less than or equal to the maximum storage capacity of the sub-programming unit, determining the initial data as the data to be written.
[0068] It is understandable that if the size of the initial data is larger than the maximum storage capacity of the sub-programming unit, the sub-programming unit cannot store the complete initial data, and the initial data needs to be divided into multiple data to be written, and a corresponding target sub-programming unit is determined for each data to be written.
[0069] In some embodiments, step 130 specifically also includes: generating a data write instruction based on the data to be written and the target sub-programming unit; sending the data write instruction to the flash memory storage medium so that the flash memory storage medium writes the data to be written into the target sub-programming unit according to the data write instruction.
[0070] In some implementations, the data write instruction may be a change write column (85h) command. It should be noted that the Change Write Column (85h) command may be used to modify the column address of the selected LUN (Logical Unit Number) in the address register (page register) during NAND programming, and the Change Write Column (85h) command may update the data in the NAND without erasing the original data.
[0071] In some embodiments, in order to facilitate the subsequent determination of the designated sub-programming unit corresponding to the last data write operation and the smallest programming unit to which the designated sub-programming unit belongs, the flash memory storage medium records the sub-programming unit to which data has been written and the smallest programming unit to which the sub-programming unit to which data has been written in the flash memory storage medium. The above-mentioned data writing method also includes: recording the target sub-programming unit to which data has been written and the smallest programming unit to which the target sub-programming unit belongs.
[0072] The sub-programming units in the flash storage medium to which data has been written and the minimum programming unit to which the sub-programming units to which data has been written belong, for example: - Page 0:
[0073] -Subpage 1: Data A has been written
[0074] -Subpage 2: Data B has been written
[0075] -Subpage 3: Data C has been written
[0076] -Subpage 4: Not used
[0077] -Page 2:
[0078] -Subpage 1: Not used
[0079] -Subpage 2: Not used
[0080] -Subpage 3: Not used
[0081] -Subpage 4: Not used.
[0082] In order to execute the corresponding steps in the above embodiments and various possible methods, a method for implementing a data writing device is given below. Figure 8 , is a functional module diagram of a data writing device provided by an embodiment of the present invention. It should be noted that the basic principle and technical effects of the data writing device provided by this embodiment are the same as those of the above embodiments. For the sake of brief description, for the parts not mentioned in this embodiment, reference can be made to the corresponding contents in the above embodiments. The data writing device 200 includes: a module for acquiring data to be written 210, a module for determining a target sub-programming unit 220, and a module for writing data 230, wherein:
[0083] The to-be-written data acquisition module 210 is used to acquire the to-be-written data.
[0084] The target sub-programming unit determining module 220 is used to determine the target sub-programming unit from the sub-programming units where no data is written in the flash memory storage medium according to the designated sub-programming unit corresponding to the last data writing operation and the minimum programming unit to which the designated sub-programming unit belongs.
[0085] The data writing module 230 is used to write the data to be written into the target sub-programming unit.
[0086] Furthermore, the target sub-programming unit determination module 220 is specifically used to determine the next sub-programming unit adjacent to the designated sub-programming unit as the target sub-programming unit if the smallest programming unit to which the designated sub-programming unit belongs is not fully written with data; if the smallest programming unit to which the designated sub-programming unit belongs is fully written with data, determine the next smallest programming unit adjacent to the smallest programming unit to which the designated sub-programming unit belongs, and determine the first sub-programming unit in the next smallest programming unit as the target sub-programming unit.
[0087] Further, the target sub-programming unit determination module 220 is also specifically used to determine the offset position of the specified sub-programming unit in the minimum programming unit to which it belongs and the next minimum programming unit adjacent to the minimum programming unit to which the specified sub-programming unit belongs, if the minimum programming unit to which the specified sub-programming unit belongs is not the last minimum programming unit in the flash memory storage medium, and determine the target sub-programming unit among multiple sub-programming units of the next minimum programming unit according to the offset position; the offset position of the target sub-programming unit in the next minimum programming unit is the same as the offset position of the specified sub-programming unit in the minimum programming unit to which it belongs; if the minimum programming unit to which the specified sub-programming unit belongs is the last minimum programming unit in the flash memory storage medium and is not fully written with data, determine the offset position of the next sub-programming unit adjacent to the specified sub-programming unit in the minimum programming unit to which it belongs, and determine the target sub-programming unit among multiple sub-programming units of the first minimum programming unit in the flash memory storage medium according to the offset position; the offset position of the target sub-programming unit in the first minimum programming unit is the same as the offset position of the next sub-programming unit adjacent to the specified sub-programming unit in the minimum programming unit to which it belongs.
[0088] Furthermore, the module for acquiring data to be written 210 is also specifically used to acquire initial data; if the size of the initial data is larger than the maximum storage capacity of the sub-programming unit, the initial data is divided into multiple data to be written according to the maximum storage capacity; the size of each data to be written is less than or equal to the maximum storage capacity; if the size of the initial data is less than or equal to the maximum storage capacity of the sub-programming unit, the initial data is determined as the data to be written.
[0089] Furthermore, the data writing module 230 is specifically used to generate a data writing instruction according to the data to be written and the target sub-programming unit; and send the data writing instruction to the flash memory storage medium so that the flash memory storage medium writes the data to be written into the target sub-programming unit according to the data writing instruction.
[0090] Furthermore, in order to record the sub-programming units in the flash memory storage medium to which data has been written and the minimum programming unit to which the sub-programming units to which data has been written belong, the data writing device 200 further includes: a recording module, wherein:
[0091] The recording module is used to record the target sub-programming unit into which data has been written and the minimum programming unit to which the target sub-programming unit belongs.
[0092] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and modules can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here.
[0093] In several embodiments provided by the present invention, the coupling between modules may be electrical, mechanical or other forms of coupling.
[0094] In addition, each functional module in each embodiment of the present invention may be integrated into one processing module, or each module may exist physically separately, or two or more modules may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of software functional modules.
[0095] An embodiment of the present invention further provides a flash memory storage device, which includes a main controller and a plurality of flash memory chips. The main controller executes instructions to implement the data writing method of the flash memory storage device.
[0096] An embodiment of the present invention further provides a computer-readable storage medium, in which a computer program is stored. When the computer program can be executed by a processor, the data writing method described in the above method embodiment is implemented.
[0097] The computer-readable storage medium may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk, or a ROM. Optionally, the computer-readable storage medium includes a non-transitory computer-readable storage medium. The computer-readable storage medium has storage space for program codes that execute any of the method steps in the above method. These program codes can be read from or written to one or more computer program products. The program code can be compressed, for example, in an appropriate form.
[0098] In several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and a module, a program segment or a part of the code contains one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0099] If the function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0100] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for writing data to a flash memory storage device, characterized in that: The flash memory storage medium includes a plurality of minimum programming units, each of which is divided into a plurality of sub-programming units; the method includes: Get the data to be written; Determine a target sub-programming unit from sub-programming units in which data is not written in the flash memory storage medium according to a designated sub-programming unit corresponding to a last data writing operation and a minimum programming unit to which the designated sub-programming unit belongs; The to-be-written data is written into the target sub-programming unit.
2. The method according to claim 1, characterized in that The step of determining a target sub-programming unit from sub-programming units in which data is not written in the flash memory storage medium according to a designated sub-programming unit corresponding to a data writing operation performed last time and a minimum programming unit to which the designated sub-programming unit belongs comprises: If the minimum programming unit to which the designated sub-programming unit belongs is not fully written with data, determining the next sub-programming unit adjacent to the designated sub-programming unit as the target sub-programming unit; If the minimum programming unit to which the designated sub-programming unit belongs is fully written with data, the next minimum programming unit adjacent to the minimum programming unit to which the designated sub-programming unit belongs is determined, and the first sub-programming unit in the next minimum programming unit is determined as the target sub-programming unit.
3. The method according to claim 1, characterized in that The step of determining a target sub-programming unit from sub-programming units in which data is not written in the flash memory storage medium according to a designated sub-programming unit corresponding to a data writing operation performed last time and a minimum programming unit to which the designated sub-programming unit belongs comprises: If the minimum programming unit to which the designated sub-programming unit belongs is not the last minimum programming unit in the flash memory storage medium, determining an offset position of the designated sub-programming unit in the minimum programming unit to which it belongs and a next minimum programming unit adjacent to the minimum programming unit to which the designated sub-programming unit belongs, and determining a target sub-programming unit from among a plurality of sub-programming units of the next minimum programming unit according to the offset position; the offset position of the target sub-programming unit in the next minimum programming unit is the same as the offset position of the designated sub-programming unit in the minimum programming unit to which it belongs; If the minimum programming unit to which the designated sub-programming unit belongs is the last minimum programming unit in the flash memory storage medium and is not fully written with data, the offset position of the next sub-programming unit adjacent to the designated sub-programming unit in the minimum programming unit to which it belongs is determined, and a target sub-programming unit is determined among multiple sub-programming units of the first minimum programming unit in the flash memory storage medium based on the offset position; the offset position of the target sub-programming unit in the first minimum programming unit is the same as the offset position of the next sub-programming unit adjacent to the designated sub-programming unit in the minimum programming unit to which it belongs.
4. The method according to claim 1, characterized in that: The step of obtaining the data to be written comprises: Get initial data; If the size of the initial data is larger than the maximum storage capacity of the sub-programming unit, the initial data is divided into a plurality of data to be written according to the maximum storage capacity; the size of each of the data to be written is smaller than or equal to the maximum storage capacity; If the size of the initial data is less than or equal to the maximum storage capacity of the sub-programming unit, the initial data is determined as the data to be written.
5. The method according to claim 1, characterized in that The step of writing the to-be-written data into the target sub-programming unit comprises: Generate a data write instruction according to the data to be written and the target sub-programming unit; The data write instruction is sent to the flash memory storage medium so that the flash memory storage medium writes the to-be-written data into the target sub-programming unit according to the data write instruction.
6. The method according to claim 5, characterized in that Recording the sub-programming unit in which the data has been written to the flash memory storage medium and the minimum programming unit to which the sub-programming unit in which the data has been written belongs; the method further comprises: The target sub-programming unit into which data has been written and the minimum programming unit to which the target sub-programming unit belongs are recorded.
7. The method according to claim 5 or 6, characterized in that: The data write instruction is a change writecolumn (85h) command.
8. A data writing device, characterized in that: The flash memory storage medium includes a plurality of minimum programming units, each of which is divided into a plurality of sub-programming units; the device includes: A module for acquiring data to be written, used for acquiring data to be written; a target sub-programming unit determining module, configured to determine a target sub-programming unit from sub-programming units in which data is not written in the flash memory storage medium according to a designated sub-programming unit corresponding to a last data writing operation and a minimum programming unit to which the designated sub-programming unit belongs; A data writing module is used to write the data to be written into the target sub-programming unit.
9. A flash memory storage device, characterized in that: The flash memory storage device includes a main controller and multiple flash memory chips, and the main controller executes instructions to implement the data writing method of the flash memory storage device according to any one of claims 1-7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for writing data to a flash memory storage device according to any one of claims 1 to 7 is implemented.