Method for reducing UBI subsystem management overhead, UBI subsystem and medium
By setting logical blocks in Nand storage devices to simulate Nand that supports Sub-Page, and optimizing the UBI management structure, the problem of management overhead occupying a large amount of user space is solved, and the ultimate compression of management overhead is achieved without modifying the management strategy. Free up more user space.
Patent Information
- Application Number
- CN202011290463.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-18
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2040-11-18
AI Technical Summary
When using Nand storage devices, management overhead occupies a large amount of user space, especially in a small capacity Nand solution. How to reduce management overhead to free up more user space without modifying the original management policy is a Emergency demand.
By setting the first logical block, the logical block maps to the first physical block and the second physical block in the flash memory, the two physical blocks are physically addressed adjacent and merged at the logical level into larger logical blocks to simulate support for Sub- Page's Nand optimizes UBI management structure and reduces management overhead.
It realizes that the management overhead is ultimately compressed and frees up more user space without affecting the UBI management logic and performance. In the specific example, the management overhead of the 128M Nand is reduced from 7072K to 4580K, freeing up about 2.43M of space.
Smart Images

Figure CN112394884B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of storage management, and in particular to a method for reducing management overhead of a UBI subsystem, a UBI subsystem and a medium. Background Art
[0002] Due to the physical characteristics of Nand, the driver must implement algorithms such as wear leveling and bad block management, so there will always be various management overheads when using Nand. Taking a 128M Nand as an example, the available space presented to the user space may be 108M, and 20M of space is used for Nand management overhead. More management overhead means less user available space. In the small-capacity Nand solution, every inch of land is valuable. How to reasonably reduce management overhead to free up more user space while ensuring stability is particularly critical.
[0003] The UBI subsystem is widely used in Linux to implement Nand feature management. According to its management strategy, the management overhead has a fixed calculation formula:
[0004] (bad block reserve + 4) * physical block size + 2 * page size * (total number of blocks including bad blocks - bad block reserve - 4)
[0005] Taking the 128M completely bad block-free Jiangbolong FS35ND01G-S1F1 SPINand as an example, its management overhead is 7072K. How to achieve more extreme compression of management overhead to free up more user space without modifying the original management strategy has become an urgent need. Summary of the invention
[0006] The present invention aims to solve at least one of the technical problems existing in the prior art. To this end, the present invention proposes a method for reducing the management overhead of the UBI subsystem, which can achieve more extreme compression of the management overhead to free up more user space without modifying the original management strategy.
[0007] The present invention also proposes a UBI subsystem using the above method.
[0008] The present invention also provides a computer-readable storage medium for implementing the above method.
[0009] According to an embodiment of a first aspect of the present invention, a method for reducing UBI subsystem management overhead includes: setting a first logical block, the first logical block is mapped to a first physical block and a second physical block in a flash memory, the first physical block is adjacent to the second physical block in physical address; the first physical block includes a first physical page, the second physical block includes a second physical page, the first physical page and the second physical page are configured as a first logical page, the first physical page and the second physical page have the same size, and the relative position of the first physical page and the first physical block header is the same as the relative position of the second physical page and the second physical block header; setting the first physical block header to store an EC header and the second physical block header to store a VID header; if a read, write or erase operation is initiated, the first logical page is used as a read and write unit, and the first logical block is used as an erase unit.
[0010] According to some embodiments of the present invention, the setting of the first logical block, the first logical block is mapped to the first physical block and the second physical block in the flash memory, and the first physical block is adjacent to the second physical block in physical address, including: determining whether there are bad blocks between the first physical block and the second physical block; if the first physical block and the second physical block have at least one bad block, skipping the bad block and returning to the step of determining whether there are bad blocks between the first physical block and the second physical block.
[0011] According to some embodiments of the present invention, setting the header of the first physical block to store an EC header and the header of the second physical block to store a VID header includes: setting the EC header to record the number of erase times of the first logical block, and the VID header to record a volume mapping relationship.
[0012] According to some embodiments of the present invention, the further embodiment includes: except for the first logical page storing the EC header and the VID header, the remaining first logical page is configured as user available space.
[0013] According to some embodiments of the present invention, the method further comprises: if power is lost during erasing of the first logic block, performing erase failure processing after restarting.
[0014] According to some embodiments of the present invention, if power fails during erasing the first logical block, the method for handling erasure failure after restarting includes: erasing the first physical block and the second physical block corresponding to the first logical block in sequence, erasing the EC header first; if power fails during the erasing process, checking the EC header after restarting; if it is determined that the EC header is invalid, placing the first logical block in an erasure queue.
[0015] According to some embodiments of the present invention, the method also includes: initiating a read and write operation with the first logical page as the read and write unit, and reading and writing the first physical page and the second physical page in sequence; if power failure occurs during the reading and writing process, the data of the first logical page is read after restart, and the integrity of the data is detected based on the UBIFS verification mechanism.
[0016] According to some embodiments of the present invention, the method further includes: when erasing the first physical page and the second physical page, erasing the first physical block where the EC header is located first.
[0017] According to a second aspect of an embodiment of the present invention, a UBI subsystem includes: a management overhead reduction module, which is used to perform the following steps: setting a first logical block, the first logical block is mapped to a first physical block and a second physical block in a flash memory, the first physical block is adjacent to the second physical block in physical address; the first physical block includes a first physical page, the second physical block includes a second physical page, the first physical page and the second physical page are configured as a first logical page, the first physical page and the second physical page are the same size, and the relative position of the first physical page and the first physical block header is the same as the relative position of the second physical page and the second physical block header; setting the first physical block header to store an EC header and the second physical block header to store a VID header; if a read, write or erase operation is initiated, the first logical page is used as a read and write unit, and the first logical block is used as an erase unit.
[0018] According to a third aspect of an embodiment of the present invention, a computer-readable storage medium stores a computer program, which, when executed by a processor, implements any one of the methods in the first method embodiment of the present invention.
[0019] The embodiments of the present invention have at least the following beneficial effects:
[0020] The embodiment of the present invention optimizes the UBI management structure, compresses the management overhead, and frees up more user space. In addition, the embodiment of the present invention only changes the metadata management and storage results of the UBI, and has no impact on its management logic and physical operations, so it has no impact on performance.
[0021] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The above and / or additional aspects and advantages of the present invention will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:
[0023] Figure 1 A flowchart of a method for reducing UBI subsystem management overhead according to an embodiment of the present invention.
[0024] Figure 2 This is a flow chart of a method for handling a first logic block erase failure according to an embodiment of the present invention.
[0025] Figure 3 This is a flow chart of a method for performing read and write operations on a first logic block according to an embodiment of the present invention.
[0026] Figure 4 This is a schematic diagram of the original management structure of UBI in the prior art.
[0027] Figure 5 Schematic diagram of the UBI management structure that supports sub-page.
[0028] Figure 6 Schematic diagram of the UBI management structure after optimization based on the method of the embodiment of the present invention.
[0029] Figure 7 It is a schematic diagram of a logical UBI structure of a method based on an embodiment of the present invention.
[0030] Figure 8 It is a schematic block diagram of modules of a UBI subsystem according to an embodiment of the present invention. DETAILED DESCRIPTION
[0031] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and cannot be understood as limiting the present invention.
[0032] In the description of the present invention, "several" means one or more, "more" means two or more, "greater than", "less than", "exceed" etc. are understood as not including the number itself, and "above", "below", "within" etc. are understood as including the number itself. If there is a description of "first" or "second", it is only used for the purpose of distinguishing the technical features, and cannot be understood as indicating or implying the relative importance or implicitly indicating the number of the indicated technical features or implicitly indicating the order of the indicated technical features.
[0033] Reference Figure 4 , the original management strategy of the UBI subsystem is as follows Figure 4 The first two physical pages of each physical block store the EC header and the VID header respectively, where the EC header records the number of times the block has been erased, and the VID header records the volume mapping relationship, while the remaining pages are user available space.
[0034] Reference Figure 5Since the reading and writing of Nand are all in physical pages, for example, if the physical page is 2K, then each reading and writing must be 2K of data. There are some special Nands that support sub-pages. Such Nands allow for smaller reading and writing particles. For example, if the page is 4K and supports 2K sub-pages, then 2K can be read and written each time instead of 4K. In this case, the UBI subsystem adopts Figure 5 The management structure shown in the figure. Undoubtedly, in the UBI subsystem, the Nand supporting Sub-Page has higher space utilization.
[0035] However, most of the current Nands do not support Sub-Page, and the purpose of the present invention is to simulate Sub-Page in Nands that do not support Sub-Page. The embodiment of the present invention simulates a Nand that supports Sub-Page by logically merging adjacent physical blocks into larger logical blocks, thereby realizing a higher space management structure in the UBI subsystem and achieving higher space utilization.
[0036] Reference Figure 1 , Figure 6 and Figure 7 The method for reducing the UBI subsystem management overhead of an embodiment of the present invention comprises the following steps: setting a first logical block, mapping the first logical block to a first physical block and a second physical block in a flash memory, the first physical block being adjacent to the second physical block in physical address; the first physical block includes a first physical page, the second physical block includes a second physical page, the first physical page and the second physical page are configured as a first logical page, the first physical page and the second physical page have the same size, and the relative position of the first physical page and the first physical block header is the same as the relative position of the second physical page and the second physical block header; setting the header of the first physical block to store the EC header, and the header of the second physical block to store the VID header; if a read, write or erase operation is initiated, the first logical page is used as the read and write unit, and the first logical block is used as the erase unit.
[0037] Reference Figure 6 , the UBI subsystem uses the first logical page as the read and write unit, and the first logical block as the erase unit; in the lower-level implementation, the physical page is still the read and write unit, and the physical block is the erase unit. When the UBI subsystem initiates the read and write of the first logical page, the bottom layer actually operates the two physical pages of the adjacent block. At this time, for the UBI subsystem, the registered Nand supports the Sub-Page operation, and the sub-page at this time is actually a physical page. In this case, the UBI management structure becomes as follows Figure 6 Management structure shown.
[0038] In some embodiments, the method also includes: when setting the first logical block, determining whether there are bad blocks between the first physical block and the second physical block; if there is at least one bad block between the first physical block and the second physical block, skipping the bad block and returning to the step of determining whether there are bad blocks between the first physical block and the second physical block.
[0039] In some embodiments, the setting of the EC header and the VID header further includes: setting the EC header to record the number of erasures of the first logical block, and setting the VID header to record the volume mapping relationship.
[0040] In some embodiments, except for the first logical page storing the EC header and the VID header, the remaining first logical page is configured as user available space.
[0041] In some embodiments, if power is lost during erasing the first logical block, an erase failure process is performed after restart. In the underlying operation, the atomicity of the UBI operation of the first logical page / block must be guaranteed. For example, the UBI subsystem initiates erasing the first logical block, and the underlying layer loses power during the sequential erasing of two adjacent physical blocks. As a result, the erasure is incomplete, and one physical block remains. After restart, the UBI subsystem must be able to present an erase failure, and the data of one remaining physical block cannot be mistakenly judged as valid data.
[0042] Reference Figure 2 In some embodiments, when erasing the first logical block fails, the erasure failure processing includes the following steps: erasing the first physical block and the second physical block corresponding to the first logical block in sequence, erasing the EC header first; if power failure occurs during the erasing process, checking the EC header after restarting; if the EC header is determined to be invalid, putting the first logical block into the erasure queue. For erasing the first logical block, if power failure occurs at any time when erasing the two physical blocks in sequence, it is necessary to avoid the UBI subsystem from misjudging it as a valid block. According to the implementation of the UBI subsystem, it will first check the EC header. If the EC header is invalid, the block will be directly put into the erasure queue. Therefore, if the bottom layer gives priority to erasing the EC header when erasing the two physical blocks in sequence, even if the VID header still exists, the UBI subsystem will still determine it as an invalid block and erase it again.
[0043] Further references Figure 3In some embodiments, the read and write operations on the first logical page include the following steps: initiating a read and write operation with the first logical page as the read and write unit, and reading and writing the first physical page and the second physical page in sequence; if power failure occurs during the read and write process, the data of the first logical page is read after restart, and the integrity of the data is detected based on the verification mechanism of UBIFS. For reading and writing the first logical page, if power failure occurs at any time when reading and writing two physical pages in sequence, the phenomenon is consistent with UBI directly operating the physical page, and the data read after restart is incomplete. The verification mechanism of UBIFS can solve this problem, so the power failure of merging into the first logical page will not affect the reading and writing of the UBI subsystem.
[0044] In some embodiments, when erasing the first physical page and the second physical page, the first physical block where the EC header is located is erased first.
[0045] Reference Figure 8 In addition to modules for implementing functions such as wear leveling and bad block management, the UBI subsystem of the embodiment of the present invention also includes a management overhead reduction module, which is used to perform the following steps: The management overhead reduction module is used to perform the following steps: a first logical block is set, the first logical block is mapped to a first physical block and a second physical block in the flash memory, and the first physical block is adjacent to the second physical block in physical address; the first physical block includes a first physical page, the second physical block includes a second physical page, the first physical page and the second physical page are configured as a first logical page, the first physical page and the second physical page have the same size, and the relative position of the first physical page and the first physical block header is the same as the relative position of the second physical page and the second physical block header; the first physical block header is set to store the EC header, and the second physical block header is set to store the VID header; if a read, write or erase operation is initiated, the first logical page is used as the read and write unit, and the first logical block is used as the erase unit.
[0046] After optimizing UBI using the method of the embodiment of the present invention, each physical block has one less physical page management overhead. Take the 128M completely bad block-free Jiangbolong FS35ND01G-S1F1 SPINand as an example. Its specifications are 2K page size, 128K block size, a total of 1024 blocks, and the default UBI bad block reservation mechanism (20 bad blocks are reserved for every 1024 blocks)
[0047] Therefore, the UBI management overhead before optimization is:
[0048] (20+4)*128K+2*2K*(1024-20-4)=7072K≈6.9M
[0049] The optimized UBI management overhead is:
[0050] (10+4)*256K+2K*(512-10-4)=4580K≈4.47M
[0051] Using this method, the management overhead of UBI can be compressed to the extreme without affecting its functionality or modifying its management logic, freeing up nearly 2492K (≈2.43M) of space.
[0052] According to the method of the present invention, the more Nand blocks there are, the larger the compressed space is. Taking Samsung's K9F4G08UXF as an example, its specifications are: 512M total capacity, 2K page size, 128K block size, 4096 blocks, theoretically reducing management overhead by 11.26M.
[0053] Although specific embodiments are described herein, those of ordinary skill in the art will recognize that many other modifications or alternative embodiments are also within the scope of the present disclosure. For example, any of the functions and / or processing capabilities described in conjunction with a particular device or component may be performed by any other device or component. In addition, although various exemplary implementations and architectures have been described according to embodiments of the present disclosure, those of ordinary skill in the art will recognize that many other modifications to the exemplary implementations and architectures described herein are also within the scope of the present disclosure.
[0054] Some aspects of the present disclosure are described above with reference to the block diagram and flow chart of the system, method, system and / or computer program product according to the exemplary embodiments.It should be understood that the combination of one or more blocks in the block diagram and the flow chart and the blocks in the block diagram and the flow chart can be realized by executing computer executable program instructions respectively.Equally, according to some embodiments, some blocks in the block diagram and the flow chart may not need to be executed in the order shown, or may not need to be executed in full.In addition, additional components and / or operations beyond those components and / or operations shown in the blocks in the block diagram and the flow chart may be present in certain embodiments.
[0055] Therefore, the blocks in the block diagrams and flow charts support the combination of devices for performing the specified functions, the combination of elements or steps for performing the specified functions, and the program instruction devices for performing the specified functions. It should also be understood that each block in the block diagrams and flow charts and the combination of blocks in the block diagrams and flow charts can be implemented by a special-purpose hardware computer system or a combination of special-purpose hardware and computer instructions that performs a specific function, element or step.
[0056] The program modules, applications, etc. described herein may include one or more software components, including, for example, software objects, methods, data structures, etc. Each such software component may include computer-executable instructions that, in response to execution, cause at least a portion of the functionality described herein (e.g., one or more operations of the illustrative methods described herein) to be performed.
[0057] Software components can be encoded with any of various programming languages. An exemplary programming language can be a low-level programming language, such as an assembly language associated with a specific hardware architecture and / or an operating system platform. Software components comprising assembly language instructions may need to be converted to executable machine code by an assembler before being executed by hardware architecture and / or platform. Another exemplary programming language can be a higher-level programming language, which can be transplanted across multiple architectures. Software components comprising a higher-level programming language may need to be converted to an intermediate representation by an interpreter or a compiler before execution. Other examples of programming languages include but are not limited to macro languages, shells or command languages, job control languages, scripting languages, database queries or search languages or report writing languages. In one or more exemplary embodiments, a software component comprising the instructions of one of the above-mentioned programming language examples can be directly executed by an operating system or other software components, without first being converted into another form.
[0058] Software components may be stored as files or other data storage structures. Software components of similar type or related functions may be stored together, such as in a specific directory, folder, or library. Software components may be static (e.g., preset or fixed) or dynamic (e.g., created or modified at execution time).
[0059] The embodiments of the present invention are described in detail above in conjunction with the accompanying drawings, but the present invention is not limited to the above embodiments, and various changes can be made within the knowledge scope of ordinary technicians in the relevant technical field without departing from the purpose of the present invention.
Claims
1. A method for reducing UBI subsystem management overhead, characterized in that: include: Setting a first logical block, wherein the first logical block is mapped to a first physical block and a second physical block in the flash memory, and the first physical block is adjacent to the second physical block in terms of physical address; The first physical block includes a first physical page, the second physical block includes a second physical page, the first physical page and the second physical page are configured as a first logical page, the first physical page and the second physical page have the same size, and a relative position between the first physical page and the header of the first physical block is the same as a relative position between the second physical page and the header of the second physical block; Set the header of the first physical block to store the EC header, and the header of the second physical block to store the VID header; If a read, write or erase operation is initiated, the first logical page is used as a read or write unit, and the first logical block is used as an erase unit; The step of setting a first logical block, wherein the first logical block is mapped to a first physical block and a second physical block in the flash memory, and the first physical block is adjacent to the second physical block in terms of physical address, comprises: Determine whether there are bad blocks in the first physical block and the second physical block; If at least one of the first physical block and the second physical block is a bad block, skip the bad block and return to the step of determining whether there is a bad block between the first physical block and the second physical block. The method further includes: Initiate a read / write operation with the first logical page as a read / write unit, and read / write the first physical page and the second physical page in sequence; If power failure occurs during the reading and writing process, the data of the first logical page is read after restart, and the integrity of the data is detected based on the UBIFS verification mechanism.
2. The method for reducing UBI subsystem management overhead according to claim 1, characterized in that: The step of setting the header of the first physical block to store the EC header and the header of the second physical block to store the VID header comprises: The EC header is configured to record the number of times the first logic block is erased, and the VID header is configured to record a volume mapping relationship.
3. The method for reducing UBI subsystem management overhead according to claim 1, characterized in that: Also includes: Except for the first logical page storing the EC header and the VID header, the remaining first logical page is configured as user available space.
4. The method for reducing UBI subsystem management overhead according to claim 1, characterized in that: The method further includes: If power is lost during erasing of the first logic block, erasure failure processing is performed after restart.
5. The method for reducing UBI subsystem management overhead according to claim 4, characterized in that: The method for performing erasure failure processing after restarting if power is lost during erasing the first logic block includes: Erasing the first physical block and the second physical block corresponding to the first logical block in sequence, erasing the EC header first; If power failure occurs during the erase process, check the EC header after restart; If it is determined that the EC header is invalid, the first logic block is placed in an erase queue.
6. The method for reducing UBI subsystem management overhead according to claim 1, characterized in that: The method further includes: When erasing the first physical page and the second physical page, the first physical block where the EC header is located is erased first.
7. A UBI subsystem, using the method of any one of claims 1 to 6, characterized in that: include: Reduced Management Overhead module that performs the following steps: Setting a first logical block, wherein the first logical block is mapped to a first physical block and a second physical block in the flash memory, and the first physical block is adjacent to the second physical block in terms of physical address; The first physical block includes a first physical page, the second physical block includes a second physical page, the first physical page and the second physical page are configured as a first logical page, the first physical page and the second physical page have the same size, and a relative position between the first physical page and the header of the first physical block is the same as a relative position between the second physical page and the header of the second physical block; Set the header of the first physical block to store the EC header, and the header of the second physical block to store the VID header; If a read, write or erase operation is initiated, the first logical page is used as a read or write unit, and the first logical block is used as an erase unit; The step of setting a first logical block, wherein the first logical block is mapped to a first physical block and a second physical block in the flash memory, and the first physical block is adjacent to the second physical block in terms of physical address, comprises: Determine whether there are bad blocks in the first physical block and the second physical block; If at least one of the first physical block and the second physical block is a bad block, skip the bad block and return to the step of determining whether there is a bad block between the first physical block and the second physical block. The method also includes: Initiate a read / write operation with the first logical page as a read / write unit, and read / write the first physical page and the second physical page in sequence; If power failure occurs during the reading and writing process, the data of the first logical page is read after restart, and the integrity of the data is detected based on the UBIFS verification mechanism.
8. A computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the method according to any one of claims 1 to 6 when executed by a processor.
Citation Information
Patent Citations
Method and apparatus for splitting a logical block
CN1705936A