Storage management method and storage management device

By dividing the logical block into sub-logical blocks and storing data in units, the problem of low space utilization in the prior art is solved, and efficient storage space allocation and operation efficiency are achieved.

CN119200998APending Publication Date: 2024-12-27SIGMASTAR TECH LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411364282.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-27
Publication Date
2024-12-27

AI Technical Summary

Technical Problem

In the prior art, the file system stores data in blocks, resulting in low space utilization, especially when the amount of file data is small, the entire block is occupied and the resource waste is caused.

Method used

By further dividing the logical block into multiple sub-logical blocks and storing data in units of sub-logical blocks, if there are free sub-logical blocks in the same logical block, it is allocated to the rest of the data to achieve efficient storage space allocation.

Benefits of technology

It effectively improves the utilization rate of storage space, avoids resource waste, and records the status of logical blocks and sub-logical blocks in detail through logical identification codes, optimizing the efficiency of storage operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119200998A_ABST
    Figure CN119200998A_ABST
Patent Text Reader

Abstract

The invention discloses a storage management method and a storage management device, and relates to the technical field of storage. According to the storage management method, a storage device is accessed through a file system. The storage device comprises a plurality of blocks, the file system comprises a plurality of logic blocks mapped to the blocks, and each logic block has a logic block number. The storage management method comprises the following steps: receiving a first storage request to store first data of a first type; dividing a first logic block in the plurality of logic blocks into a plurality of sub-logic blocks in response to the first storage request; allocating a first sub-logic block of the plurality of sub-logic blocks to the first data; generating a first logic identification code mapped to the first sub-logic block so as to record a state mark which corresponds to the first type and is a first value, a sub-logic block number of the first sub-logic block and a logic block number of the first logic block in the first logic identification code;
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of storage technology, and in particular to a storage management method and a storage management device. Background Art

[0002] Embedded electronic products use Serial Peripheral Interface NAND Flash Memory (SPI NAND flash) as an external large-capacity storage device, including multiple erasable blocks to store image system files and file system data. Among them, the file system stores data in blocks. Under the above allocation method, even if the file has a small amount of data, the file will still occupy the entire block. Therefore, the above allocation method will lead to low space utilization. Summary of the invention

[0003] One of the purposes of the present application is to provide a storage management method and a storage management device to improve the deficiencies of the prior art.

[0004] In some embodiments, a storage management method accesses a storage device through a file system, wherein the storage device includes multiple blocks, and the file system includes multiple logical blocks mapped to the multiple blocks, each of the multiple logical blocks has a logical block number; the storage management method includes: receiving a first storage request to store a first data of a first type; in response to the first storage request, dividing a first logical block among the multiple logical blocks into multiple sub-logical blocks; allocating a first sub-logical block of the multiple sub-logical blocks to the first data; generating a first logical identification code mapped to the first sub-logical block to record a status mark with a first value corresponding to the first type, a sub-logical block number of the first sub-logical block, and a logical block number of the first logical block in the first logical identification code; receiving a second storage request to store a second data of a second type; in response to the second storage request, allocating a second logical block among the multiple logical blocks to the second data; and generating a second logical identification code mapped to the second logical block to record a status mark with a second value corresponding to the second type, a preset sub-logical block number, and a logical block number of the second logical block in the second logical identification code.

[0005] In some embodiments, a storage management device accesses a storage device through a file system, wherein the storage device includes a plurality of blocks, and the file system includes a plurality of logical blocks mapped to the plurality of blocks, each of the plurality of logical blocks having a logical block number; the storage management device includes a processor, and the processor performs the following steps according to at least one instruction in a memory: receiving a first storage request to store a first data of a first type; dividing a first logical block among the plurality of logical blocks into a plurality of sub-logical blocks in response to the first storage request; allocating a first sub-logical block among the plurality of sub-logical blocks to the first data; generating a first logical identification code mapped to the first sub-logical block to record a status mark corresponding to the first type with a first value, a sub-logical block number of the first sub-logical block, and a logical block number of the first logical block in the first logical identification code; receiving a second storage request to store a second data of a second type; allocating a second logical block among the plurality of logical blocks to the second data in response to the second storage request; and generating a second logical identification code mapped to the second logical block to record a status mark corresponding to the second type with a second value, a preset sub-logical block number, and a logical block number of the second logical block in the second logical identification code.

[0006] The storage management method and storage management device of the present application further divide the logical block into multiple sub-logical blocks, and then use the multiple sub-logical blocks in the logical block to respectively store multiple data with smaller data volumes. Therefore, if there are still free sub-logical blocks in the same logical block, the above-mentioned free sub-logical blocks will be allocated to the remaining data for use. Therefore, the storage management method and storage management device of the present application can efficiently allocate storage space, thereby avoiding wasting storage space.

[0007] The features, implementation and effects of the present application are described in detail below with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0008] Figure 1 A schematic diagram of a storage management device and a memory is drawn according to some embodiments of the present application;

[0009] Figure 2 A flowchart of a storage management method is drawn according to some embodiments of the present application;

[0010] Figure 3 A schematic diagram of the relationship between a logic block and a sub-logic block is drawn according to some embodiments of the present application;

[0011] Figure 4 A schematic diagram of the allocation relationship between sub-logic blocks and data is drawn according to some embodiments of the present application;

[0012] Figure 5A schematic diagram of a logic block, a sub-logic block and a logic identification code is drawn according to some embodiments of the present application;

[0013] Figure 6 A schematic diagram of an allocation process of a logic block and a sub-logic block is drawn according to some embodiments of the present application;

[0014] Figure 7 A schematic diagram of a reading process of a logic block and a sub-logic block is drawn according to some embodiments of the present application;

[0015] Figure 8 A schematic diagram of a writing process of a logic block and a sub-logic block is drawn according to some embodiments of the present application;

[0016] Fig. 9 A schematic diagram of a process of erasing a logic block and a sub-logic block is drawn according to some embodiments of the present application; and

[0017] Fig.10 A schematic diagram of a logic block and a sub-logic block is drawn according to some embodiments of the present application.

[0018] 100: storage management device;

[0019] 115: Processor;

[0020] 200: Methods;

[0021] 210~240: Steps;

[0022] 400: storage device;

[0023] 500: memory;

[0024] 600: Methods;

[0025] 610~633: Steps;

[0026] 700: Methods;

[0027] 710~722: steps;

[0028] 800: Methods;

[0029] 810~822: steps;

[0030] 900: Methods;

[0031] 910~930: Steps;

[0032] Rx: segment of the logical identification code;

[0033] Ry: segment of the logical identification code;

[0034] Rz: logical identification code segment. DETAILED DESCRIPTION

[0035] The technical terms used in the following descriptions refer to the customary terms in the technical field. If some of the terms are explained or defined in this specification, the interpretation of the terms shall be based on the explanation or definition in this specification.

[0036] Figure 1 A schematic diagram of a storage management device 100, a storage device 400 and a memory 500 is drawn according to some embodiments of the present application. The storage management device 100 is connected to the storage device 400 and the memory 500, and the storage management device 100 includes a processor 115. The storage device 400 can be a NAND flash memory, and the memory 500 can be a dynamic random access memory (DRAM). The memory 500 stores a plurality of program instructions and / or program codes, and the storage management device 100 implements its functions by executing these program instructions and / or program codes. In some embodiments, the storage management device 100 can be a control chip.

[0037] Combine the following Figure 2 The operation of the storage management device 100 is described in detail. Figure 2 A flowchart of a storage management method 200 is drawn according to some embodiments of the present application. The storage management method 200 accesses a storage device 400 through a file system. The storage device 400 includes multiple blocks. Each of the multiple blocks includes multiple storage units (pages). The storage unit (page) is the basic operation unit when reading or writing to the storage device 400. The block (block) is the basic operation unit for erasing the storage device 400. Please refer to Figure 3 The file system includes multiple logical blocks i and i+1 mapped to multiple blocks, and each of the multiple logical blocks i and i+1 has a logical block number (block number, BN).

[0038] Step 210: receiving a storage request to store first data of a first type, dividing a first logical block among a plurality of logical blocks into a plurality of sub-logical blocks, and recording a plurality of sub-logical block numbers (SN) for marking the plurality of sub-logical blocks. Figure 3, the processor 115 can divide an idle logic block i among multiple logic blocks i, i+1 into multiple sub-logic blocks 0 to N-1 according to a preset sub-logic block size (subblock size), and each sub-logic block corresponds to a preset number of storage units (for example, one). When a logic block is divided into multiple sub-logic blocks, the processor 115 also records multiple usage marks for marking the usage of each sub-logic block, for example, the first usage mark indicates that the sub-logic block is currently in an idle state, and the second usage mark indicates that the sub-logic block is currently in an occupied state. It can be understood that each logic block also records a corresponding usage mark. In this way, the usage mark of the logic block or sub-logic block is updated according to the current usage of the logic block or sub-logic block; the current usage of the logic block or sub-logic block can be known by querying the usage mark.

[0039] Step 220: Allocate a first logical sub-block among the plurality of logical sub-blocks to the first data. Figure 4 , the processor 115 allocates the sub-logical block 0 and the sub-logical block 1 of the logical block i to the first data A according to the size of the data A (which will be combined with Figure 6 Detailed description). In this way, the first data A can be stored in the storage units corresponding to the sub-logical block 0 and the sub-logical block 1. In some embodiments, the first data A can be a file, such as a file in the littlefs file system. Further, when the first sub-logical block is allocated to the first data, the processor 115 updates the usage mark of the first sub-logical block according to the allocation, for example, updates the first usage mark to the second usage mark.

[0040] Step 230, generate a first logic identification code mapped to the first sub-logic block to record the state mark of the first type corresponding to the first value, the sub-logic block number of the first sub-logic block, and the logic block number of the first logic block in the first logic identification code. In this embodiment, the logic identification code occupies a preset number of bits, wherein the first number of bits is used to record the state mark of the corresponding logic block or sub-logic block, the second number of bits is used to record the sub-logic block number, and the third number of bits is used to record the logic block number, and the sum of the first number of bits, the second number of bits, and the third number of bits is equal to the preset number of bits. Please refer to Figure 5 In one embodiment, as shown in the upper left corner of the figure, the preset number of bits is 32 bits, that is, a logic identification code is recorded by 32 bits, the Rx segment of the logic identification code is used to record the state mark of the logic block / sub-logic block, the Ry segment of the logic identification code is used to record the sub-logic block number, and the Rz segment of the logic identification code is used to record the logic block number. The present application can use the above-mentioned logic identification code to record the state of the logic block / sub-logic block, the relationship between the sub-logic block and the logic block in detail, and then efficiently allocate storage space and perform subsequent write, read, erase and other operations.

[0041] In one embodiment, for other sub-logical blocks in the logical block where no data is stored, the processor 115 may also generate multiple logical identification codes corresponding thereto, and the Rx segment record status marks of the multiple logical identification codes are preset marks such as FREE. The processor 115 also records all logical identification codes of the file system in a table for management.

[0042] Step 240, storing the first data in the sub-logical block corresponding to the first logical identification code. In addition, after the first data is stored in the sub-logical block, the use mark of the sub-logical block is also updated accordingly. It can be understood that in the present application, storing data in a logical block or a sub-logical block means storing the data in a block corresponding to the logical block or a storage unit corresponding to the sub-logical block.

[0043] This file system will configure a corresponding logical identification code for each logical block or sub-logical block, and can obtain relevant information of the logical block or sub-logical block according to the logical identification code. The following Table 1 is an example to illustrate the corresponding relationship between the state of the logical block or sub-logical block of this application and the state mark in the logical identification code, so that the state of the logical block or sub-logical block can be known through the state mark in the logical identification code.

[0044] Table 1 is a table showing the symbols of data types in the logical identification code and their meanings.

[0045]

[0046] In some embodiments, in order to make the file system of this application have a certain degree of inheritance with the littlefs file system so as to directly use some functions provided by littlefs, this application can set the preset number of bits to 32 bits. In this way, this application can apply the storage structure of the littlefs file system, and only needs to adjust the meaning of the uint32_t type field used by the littlefs storage structure to record the logical identification code. Figure 5 Taking the content shown as an example, the number of bits occupied by the Rx segment, Ry segment and Rz segment are Bx, By and Bz respectively. Bx, By and Bz can achieve the above adjustment as long as they meet the following conditions:

[0047] 0≤Bx≤4, condition 1;

[0048] 0≤By≤8, condition 2;

[0049] 20≤Bz≤32, condition 3;

[0050] Bx+By+Bz=32, condition 4;

[0051] Assuming that Bx is 0, By is 0 and Bz is 32, the storage structure of the present application is equivalent to the storage structure of littlefs. In other words, all 32 bits of the littlefs storage structure are used to represent the value of the logical identification code (block id), and its addressing space is 2 32 .

[0052] Please refer to condition 4. Once the number of bits occupied by the Rx segment and the Ry segment is determined, the number of bits occupied by the Rz segment is also determined. The present application is not limited to the above embodiment, which is only used to illustrate one of the implementation methods of the present application. In the remaining embodiments, the present application may also use other appropriate bit configuration methods of the logic identification code according to actual needs.

[0053] See also Figure 5 In the logical identification code 1, assuming that the data type in the sub-logical block N-2 of the logical block i is a file (because the file system of the present application uses the CTZ skip-list data structure to record the file information, it is referred to as the file data of CTZ type), the processor 115 can generate a logical identification code 1 according to the logical block i, the sub-logical block N-2 and the data type in the sub-logical block N-2 and record the status mark 0xB (characterizing the file data of CTZ type), the sub-logical block number N-2 of the sub-logical block N-2 and the logical block number i of the logical block i in the logical identification code 1.

[0054] The sub-logical block number represents a relative position of a sub-logical block in its corresponding logical block, which corresponds to one or more storage units in the block mapped by the logical block. In other words, the storage unit corresponding to the sub-logical block number can be addressed according to the address mapping relationship between the sub-logical block and its corresponding logical block and the block.

[0055] See also Figure 4If sub-logical blocks 0 and 1 of logical block i are allocated to data A (CTZ type file), processor 115 can generate a first logical identification code corresponding to sub-logical block 0 and a second logical identification code corresponding to sub-logical block 1 to record the status mark 0xB, sub-logical block number 0 of sub-logical block 0 and logical block number i of logical block i in the first logical identification code, and record the status mark 0xB, sub-logical block number 1 of sub-logical block 1 and logical block number i of logical block i in the second logical identification code. If sub-logical block 2 of logical block i is allocated to data B (CTZ type file), processor 115 can generate a third logical identification code corresponding to sub-logical block 2 to record the status mark 0xB, sub-logical block number 2 of sub-logical block 2 and logical block number i of logical block i in the third logical identification code. After data A and data B are stored in sub-logical blocks 0, 1, and 2, processor 115 updates the use marks of sub-logical blocks 0, 1, and 2.

[0056] See also Figure 5 Logical identification code 2 in. Assuming that the type of data to be stored is a directory, the present application can allocate the entire logical block i+2 among multiple logical blocks i~i+2 to the above data according to the data type being a directory, and generate a logical identification code (such as logical identification code 2) accordingly to record the status mark 0xC (corresponding to metadata, because the present file system will use metadata to record directory data), the sub-logical block number with a preset value, and the logical block number i+2 of the logical block i+2 in the logical identification code 2. It should be noted that for directory data, the present file system uses one or more metadata to record the relevant information of the directory (such as information such as documents and sub-directories under the directory). The present application will allocate an entire logical block to a metadata to store the directory data in the block corresponding to the logical block. Therefore, the sub-logical block number in the logical identification code 2 only needs to record the preset value (such as FULL).

[0057] In some embodiments, when data fails, for example, data in a sub-logical block fails, the processor 115 updates the logic identification code corresponding to the logic block or sub-logical block storing the data accordingly to record the information that the data has failed in the updated logic identification code. For example, the processor 115 may update the status mark of the Rx segment of the logic identification code to a preset status mark such as 0xD or 0xE (corresponding to ABANDAN or GC). In this way, when the preset status mark is identified in the Rx segment of the logic identification code, if the logic identification code corresponds to a sub-logical block, the sub-logical block cannot be read or written; if the logic identification code corresponds to a logic block, only the erase operation can be performed on the logic block.

[0058] As described above, the present application can record the storage status of data, the relationship between sub-logical blocks and logical blocks in detail through logical identification codes. The new logical identification codes of the present application are very helpful for data reading, writing, erasing and other related operations.

[0059] Figure 6 A schematic diagram 600 of a logic block and a sub-logic block allocation process is drawn according to some embodiments of the present application. It should be noted that: Figure 6 This is a detailed flow chart of step 220 in an embodiment. Specifically, step 610 includes: when a storage request is received to write data to a storage device, an allocation command is generated according to the storage request to allocate a logical block or a sub-logical block to the data. The storage request is generated in response to a user operation, and the allocation command is generated according to the storage request. In addition, one or more allocation commands that can be generated according to a storage request depend on the size of the data to be written to the storage device by the storage request. Figure 4 , data A needs to occupy two sub-logical blocks 0 and 1. Two allocation commands are generated according to the storage request for storing data A. In response to each allocation command, one sub-logical block is allocated to data A. That is, each allocation command only allocates one sub-logical block or one logical block (depending on the data type) to the data.

[0060] Step 611, identify the type of data. Specifically, the storage request includes information about the data to be stored, such as type, size, etc., and the type of the data can be identified based on the information of the data. If the type of the data is a directory, proceed to step 612; if the type of the data is a file, proceed to step 620. Step 612, search for available free logical blocks, such as erased logical blocks. Specifically, the processor 115 can search for free logical blocks based on the state mark of the logical identification code being a preset state mark (e.g., 0xA) or the use mark of the logical block being the first use mark. If found, proceed to step 613; if not found, proceed to step 615. Step 613, obtain the logical identification code of the free logical block, such as BLOCK_ID (0xA, 0, X). Step 614, update the logic identification code according to the type of the data to generate an updated logic identification code and return the updated logic identification code such as BLOCK_ID (0xC, Full, X), so as to allocate the entire free logic block X to the data, and the updated logic identification code records a status mark (0xC) corresponding to the data type (metadata), a sub-logical block number with a preset value such as Full, and a logical block number such as X. Step 615, return a preset signal such as a no response error signal ERR_NOS PC, indicating that the logical block cannot be allocated to the data.

[0061] Step 620, search for a free sub-logical block. For details of step 620, see step 612. If found, proceed to step 621; if not found, proceed to step 630. Step 621, generate a logical identification code corresponding to the sub-logical block and return the logical identification code. In one embodiment, the state mark in the existing logical identification code of the sub-logical block can be updated according to the type of the data to generate a new logical identification code and return it. For example, the logical identification code of the sub-logical block is BLOCK_ID (FRE E, Y2, Y1), and according to the type of the data being a file, the logical identification code is updated to BLOCK_ID (CTZ, Y2, Y1) and returned, so as to allocate the sub-logical block Y2 of the logical block Y1 to the data. In another embodiment, the logical identification code BLOCK_ID (CTZ, Y2, Y1) of the sub-logical block can be newly generated according to the type of the data, the block number Y2 of the sub-logical block and the block number Y1 of the corresponding logical block. Afterwards, the original logic identification code BLOCK_ID (FREE, Y2, Y1) of the sub-logic block is replaced by the logic identification code BLOCK_ID (CTZ, Y2, Y1).

[0062] Step 630, search for available free logical blocks, such as erased free logical blocks. For details of step 630, refer to the details of step 612. If found, proceed to step 631; if not found, proceed to step 633. Step 631, obtain the logical block number Z1 of the free logical block, divide the logical block into multiple sub-logical blocks, and allocate a sub-logical block of the multiple sub-logical blocks to the data, and obtain the sub-logical block number Z2 of the sub-logical block. Step 632, generate a logical identification code such as BLOCK_ID (CTZ, Z2, Z1) according to the type of the data, the logical block number Z1 and the sub-logical block number Z2, and return the logical identification code to allocate the sub-logical block Z2 of the logical block Z1 to the data. Step 633, return a preset signal such as the no response error signal ERR_NOSPC, indicating that the logical block cannot be allocated to the data.

[0063] In addition, when a logic block or a sub-logic block is allocated to data in steps 614 , 621 , and 632 , the processor 115 will correspondingly record or update the usage mark of the logic block or the sub-logic block.

[0064] Figure 7A schematic diagram of a read process 700 of a logic block and a sub-logic block is drawn according to some embodiments of the present application, including: step 710, receiving a read request to read data, the read request including a logic identification code. In another embodiment, the read request also includes parameters such as an address offset (offset) and the amount of data to be read (size). Step 711, identifying the status mark in the logic identification code, and determining whether the data to be read is a directory or a file according to the status mark to perform a corresponding read operation. Specifically, if the data to be read is a file (such as identifying the status mark corresponding to CTZ in the logic identification code), step 720 is executed; if the data to be read is a directory (such as identifying the status mark corresponding to metadata in the logic identification code), step 721 is executed; otherwise (that is, the data type to be read is neither a file nor a directory, such as identifying the status mark corresponding to GC in the logic identification code), step 722 is executed. Step 720, determining the address of the data to be read according to the logic block number and the sub-logic block number in the logic identification code to read the data. Specifically, the processor 115 determines a starting address according to the logical block number, the sub-logical block number, and the address offset in the read request. Furthermore, the processor 115 also determines an ending address according to the amount of data in the read request. In practice, the processor 115 reads data by calling a read function: read(block number, subblock number×subblock size+offset, size) according to the identified logical block number (block number), sub-logical block number (subblock number), the size of each sub-logical block (subblocksize), the address offset (offset), and the amount of data (size).

[0065] Step 721, determine the address of the data to be read according to the logical block number in the logical identification code to read the data. When the read request contains an address offset and a data amount, the start address of the read data can also be determined according to the address offset, and an end address can be determined according to the data amount. In specific implementation, the data is read by calling the read function: read(block number, offset, size) according to the identified logical block number (block number), the address offset (offset) and the data amount (size). Step 722, return a preset read error signal such as the no valid data signal ERR_INVAL, indicating that the data cannot be read according to the read request.

[0066] Figure 8 A schematic diagram of a write process 800 for a logic block and a sub-logic block is drawn according to some embodiments of the present application. It should be noted that: Figure 8FIG. 2 is a detailed flow chart of step 240 in one embodiment.

[0067] Step 810, a write command is obtained to write data, and the write command includes a logical identification code. Specifically, the processor 115 generates a corresponding write command upon receiving the logical identification code returned by one of steps 614, 621, and 631. It is understandable that the write command can be obtained once it is generated. Optionally, the write command also includes parameters such as address offset (offset) and amount of data to be written (size). Step 811, identify the status mark in the logical identification code in the write command, and determine whether the write data is a directory or a file based on this and perform the corresponding write operation. Specifically, if the write data is a file, step 820 is executed; if the write data is a directory, step 821 is executed; otherwise, that is, the write data is neither a file nor a directory, step 822 is executed. Step 820, determine the write address according to the logical block number and sub-logical block number in the logical identification code. Optionally, the write start address is also determined according to the address offset in the write command, and the write end address is determined according to the amount of data in the write command. During implementation, data can be written into the corresponding sub-logical block by calling the write function: prog(block number, subblock number×subblock size+offset, size) according to the identified logical block number (block number), sub-logical block number (subblock number), size of each sub-logical block (subblock siz), address offset (offset) and data amount (size).

[0068] Step 821, determine the write address to write data according to the logical block number in the logical identification code. When there is an address offset in the write command, the write start address can also be determined according to the address offset, and the write end address can be determined according to the amount of data in the write command. In practice, the data can be written to the corresponding logical block by calling the write function: prog (block number, offset, size) according to the identified logical block number (block number), address offset (offset) and data amount (size). Step 822, return a preset write error signal, indicating that the data cannot be written to the corresponding logical block or its sub-logical block according to the write command.

[0069] After completing data writing, the processor 115 updates the corresponding logic identification code, for example, updates the status mark in the logic identification code and updates the usage mark of the corresponding logic block or sub-logic block.

[0070] Fig. 9A schematic diagram of a logical block erasing process 900 is drawn according to some embodiments of the present application. As shown in the figure, in step 910, an erase request is received to erase a data. The erase request includes a logical identification code. Step 911, identify the status mark in the logical identification code, and determine whether the data requested to be erased is a directory or a file based on this to perform the corresponding erase operation. Specifically, if the data is a file, execute step 912; if the data is a directory, execute step 920; otherwise, that is, the data is neither a file nor a directory (such as identifying the status mark corresponding to FREE in the logical identification code), execute step 930. Step 912, determine whether there is valid data in the logical block corresponding to the logical identification code. Specifically, determine the logical block number in the logical identification code, find all logical identification codes including the logical block number, and determine whether there is valid data in the logical block based on the corresponding status marks of all the logical identification codes. If the status mark of one of the logical identification codes is a preset value such as CTZ, it is determined that there is valid data in the logical block. If yes, then go to step 913 and return an erase error signal to inform that the erase operation will not be performed. That is, if there are other sub-logical blocks storing valid data in the logical block where the logical identification code is located, then the logical block cannot be erased.

[0071] Step 920, perform an erase operation on the logical block corresponding to the logical identification code. Specifically, the logical block number can be obtained from the logical identification code included in the erase request and the erase interface: erase (block number) can be called to erase the entire logical block, that is, to perform an erase operation on the block corresponding to the logical block. Step 930, return an erase error signal to indicate that the erase operation cannot be performed. It can be understood that the erase error signals returned by steps 913 and 930 may be the same or different.

[0072] Fig.10 A schematic diagram of a logic block and a sub-logic block is drawn according to some embodiments of the present application. As shown in the figure, the present application can configure the size (i.e., subblock size) of a sub-logic block (such as a virtual block (subblock)), and the size of the sub-logic block (subblock size) can be an integer multiple of the write page size (program page size) and the read page size (read page size), and can divide the logic block size (such as the erase logic block size (erase blocksize)). The size of the sub-logic block (subblock size) will be recorded in the configuration document of the file system of the present application.

[0073] It should be noted that this application does not Figures 1 to 10The embodiments shown are limited to one of the implementation methods of the present application, which is used to illustrate one of the implementation methods of the present application, so that the technology of the present application is easy to understand, and the patent scope of the present application shall be based on the scope of the invention application. Those skilled in the art shall make modifications and modifications to the embodiments of the present application without departing from the spirit of the present application, and still fall within the scope of the invention application of the present application.

[0074] In summary, the storage management method and storage management device of the present application further divide the logical block into multiple sub-logical blocks, and then use the multiple sub-logical blocks in the logical block to respectively store multiple data with smaller data volumes. Therefore, if there are still free sub-logical blocks in the same logical block, the above-mentioned free sub-logical blocks will be allocated to the remaining data for use. Therefore, the storage management method and storage management device of the present application can efficiently allocate storage space, thereby avoiding wasting storage space.

[0075] In addition, the storage management method and storage management device of the present application are further configured with a logical identification code. The present application can use the above-mentioned logical identification code to record in detail the status of the logical block or sub-logical block, the relationship between the sub-logical block and the logical block, and then efficiently allocate storage space and perform subsequent writing, reading, erasing and other operations.

[0076] Although the embodiments of the present application are described above, these embodiments are not intended to limit the present application. Technicians in this technical field may change the technical features of the present application based on the explicit or implicit contents of the present application. All these changes may fall within the scope of patent protection sought by the present application. The scope of patent protection of the present application shall be based on the scope of the patent application of this specification.

Claims

1. A storage management method, characterized in that: Accessing a storage device through a file system, the storage device comprising a plurality of blocks, the file system comprising a plurality of logical blocks mapped to the plurality of blocks, each of the plurality of logical blocks having a logical block number; The storage management method comprises: Receiving a first storage request to store a first data of a first type; In response to the first storage request, dividing a first logic block among the plurality of logic blocks into a plurality of sub-logic blocks; Allocating a first sub-logical block of the plurality of sub-logical blocks to the first data; Generate a first logic identification code mapped to the first sub-logic block to record a state flag with a first value corresponding to the first type, a sub-logic block number of the first sub-logic block, and a logic block number of the first logic block in the first logic identification code; receiving a second storage request to store a second data of a second type; allocating a second logical block among the plurality of logical blocks to the second data in response to the second storage request; and A second logic identification code mapped to the second logic block is generated to record a state flag of a second value corresponding to the second type, a preset sub-logic block number and the logic block number of the second logic block in the second logic identification code.

2. The storage management method according to claim 1, characterized in that: The dividing the first logic block among the plurality of logic blocks into the plurality of sub-logical blocks includes: generating and recording a plurality of sub-logical block numbers for marking the plurality of sub-logical blocks.

3. The storage management method according to claim 1, characterized in that: The dividing the first logic block among the plurality of logic blocks into the plurality of sub-logic blocks comprises: setting a use mark for each of the plurality of sub-logic blocks, and When the first sub-logical block is allocated to the first data, a usage flag of the first sub-logical block is updated.

4. The storage management method according to claim 3, characterized in that: Also includes: In response to an allocation command generated according to the first storage request, searching for a free sub-logical block according to the usage marks of the plurality of sub-logical blocks; If the free sub-logical block is found, generating a logical identification code according to the first type, the sub-logical block number of the free sub-logical block, and the logical block number of the logical block corresponding to the free sub-logical block; and If a free sub-logical block is not found, a free third logical block is searched from the plurality of logical blocks.

5. The storage management method according to claim 1, characterized in that: The dividing the first logic block among the plurality of logic blocks into the plurality of sub-logic blocks comprises: Generate a plurality of logic identification codes mapped to the plurality of sub-logic blocks, each of the plurality of logic identification codes having a state flag of an initial value; In response to an allocation command generated according to the first storage request, searching for a free sub-logical block among the plurality of sub-logical blocks according to the status flags recorded in the logic identification codes of the plurality of sub-logical blocks; If the free sub-logical block is found, updating the initial value of the status flag of the free sub-logical block to the first value of the status flag; and If a free sub-logical block is not found, a free third logical block is searched from the plurality of logical blocks.

6. The storage management method according to claim 1, characterized in that: The logical identification code occupies a preset number of bits, the first number of bits in the logical identification code is used to record the status mark, the second number of bits is used to record the sub-logical block number, and the third number of bits is used to record the logical block number, and the sum of the first number of bits, the second number of bits and the third number of bits is equal to or less than the preset number of bits.

7. The storage management method according to claim 1, characterized in that: Also includes: receiving a read request to read a data, wherein the read request includes a logical identification code; Identify a status flag of the logical identifier record in the read request; If the status flag is the first value, determining a read address according to the logical block number and the sub-logical block number of the logical identification code in the read request to read data accordingly; as well as If the status flag is the second value, a read address is determined according to the logical block number of the logical identification code in the read request to read data accordingly.

8. The storage management method according to claim 1, characterized in that: Also includes: A write command is obtained, wherein the write command includes a logic identification code; Identify a status mark of the logic identification code record in the write command; If the state mark is the first value, determining the write address according to the logical block number and the sub-logical block number of the logical identification code in the write command; as well as If the status flag is the second value, the write address is determined according to the logical block number of the logical identification code in the write command.

9. The storage management method according to claim 1, characterized in that: Also includes: Obtaining an erase request, wherein the erase request includes a logical identification code; a status flag identifying the logical identification code record in the erase request; If the status mark is a third value, obtain all status marks mapped to the logical block number in the erase request, and when all the obtained status marks are the third value, erase the data in the logical block corresponding to the logical identification code in the erase request; or If the status mark is the second value, data in the logic block corresponding to the logic identification code in the erase request is erased.

10. A storage management device, characterized in that: Accessing a storage device through a file system, the storage device comprising a plurality of blocks, the file system comprising a plurality of logical blocks mapped to the plurality of blocks, each of the plurality of logical blocks having a logical block number; The storage management device comprises: A processor executes the following steps according to at least one instruction in a memory: Receiving a first storage request to store a first data of a first type; In response to the first storage request, dividing a first logic block among the plurality of logic blocks into a plurality of sub-logic blocks; Allocating a first sub-logical block of the plurality of sub-logical blocks to the first data; Generate a first logic identification code mapped to the first sub-logic block to record a state flag with a first value corresponding to the first type, a sub-logic block number of the first sub-logic block, and a logic block number of the first logic block in the first logic identification code; receiving a second storage request to store a second data of a second type; allocating a second logical block among the plurality of logical blocks to the second data in response to the second storage request; and A second logic identification code mapped to the second logic block is generated to record a state flag of a second value corresponding to the second type, a preset sub-logic block number and the logic block number of the second logic block in the second logic identification code.

11. The storage management device according to claim 10, characterized in that: The dividing of the first logic block among the plurality of logic blocks into the plurality of sub-logic blocks performed by the processor includes: generating and recording a plurality of sub-logic block numbers for marking the plurality of sub-logic blocks.

12. The storage management device according to claim 10, characterized in that: The dividing of the first logic block among the plurality of logic blocks into the plurality of sub-logic blocks performed by the processor includes: setting a use mark for each of the plurality of sub-logic blocks, and When the first sub-logical block is allocated to the first data, a usage flag of the first sub-logical block is updated.

13. The storage management device according to claim 12, characterized in that: The processor also performs the following steps according to the at least one instruction in the memory: In response to an allocation command generated according to the first storage request, searching for a free sub-logical block according to the usage marks of the plurality of sub-logical blocks; If the free sub-logical block is found, generating a logical identification code according to the first type, the sub-logical block number of the free sub-logical block, and the logical block number of the logical block corresponding to the free sub-logical block; and If a free sub-logical block is not found, a free third logical block is searched from the plurality of logical blocks.

14. The storage management device according to claim 10, characterized in that: The dividing of the first logic block among the plurality of logic blocks into the plurality of sub-logic blocks performed by the processor includes: Generate a plurality of logic identification codes mapped to the plurality of sub-logic blocks, each of the plurality of logic identification codes having a state flag of an initial value; In response to an allocation command generated according to the first storage request, searching for a free sub-logical block among the plurality of sub-logical blocks according to the status flags recorded in the logic identification codes of the plurality of sub-logical blocks; If the free sub-logical block is found, updating the initial value of the status flag of the free sub-logical block to the first value of the status flag; and If a free sub-logical block is not found, a free third logical block is searched from the plurality of logical blocks.

15. The storage management device according to claim 10, characterized in that: The logical identification code occupies a preset number of bits, the first number of bits in the logical identification code is used to record the status mark, the second number of bits is used to record the sub-logical block number, and the third number of bits is used to record the logical block number, and the sum of the first number of bits, the second number of bits and the third number of bits is equal to or less than the preset number of bits.

16. The storage management device according to claim 10, characterized in that: The processor also performs the following steps according to the at least one instruction in the memory: receiving a read request to read a data, wherein the read request includes a logical identification code; Identify a status flag of the logical identifier record in the read request; If the status flag is the first value, determining a read address according to the logical block number and the sub-logical block number of the logical identification code in the read request to read data accordingly; as well as If the status flag is the second value, a read address is determined according to the logical block number of the logical identification code in the read request to read data accordingly.

17. The storage management device according to claim 10, characterized in that: The processor also performs the following steps according to the at least one instruction in the memory: A write command is obtained, wherein the write command includes a logic identification code; Identify a status mark of the logic identification code record in the write command; If the state mark is the first value, determining the write address according to the logical block number and the sub-logical block number of the logical identification code in the write command; as well as If the status flag is the second value, the write address is determined according to the logical block number of the logical identification code in the write command.

18. The storage management device according to claim 10, characterized in that: The processor also performs the following steps according to the at least one instruction in the memory: Obtaining an erase request, wherein the erase request includes a logical identification code; a status flag identifying the logical identification code record in the erase request; If the status mark is a third value, obtain all status marks mapped to the logical block number in the erase request, and when all the obtained status marks are the third value, erase the data in the logical block corresponding to the logical identification code in the erase request; or If the status mark is the second value, data in the logic block corresponding to the logic identification code in the erase request is erased.