Dynamic storage method, system and device for page index bitmap in file system and storage medium
By dynamically storing page index bitmaps in the file system and pre-applying cache pages, the problem of inefficient storage and update of page index bitmaps is solved, and the system performance and response speed is improved, and duplicate rewrittening is avoided.
Patent Information
- Application Number
- CN202411368315.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-29
- Publication Date
- 2025-01-17
AI Technical Summary
In file systems, the inefficient storage and update of page index bitmaps, especially in high concurrency environments, can lead to large storage overhead and slow response, and existing solutions fail to fundamentally solve these problems.
By storing the page index bitmap count in the super block and pre-applying continuous idle pages as pre-apply pages, and after updating, putting them into these pages in turn, using the cache mechanism to reduce the number of memory erases, avoid repeated erases, and dynamically update the super Count in blocks.
Improves system performance and response speed, reduces the number of memory erases, avoids repeated erases, and ensures the stability of the data writing process.
Smart Images

Figure CN119322764A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of file systems, and in particular to a method, system and device for dynamically storing a page index bitmap in a file system. Background Art
[0002] In a database system or file system, data is usually divided into fixed-size blocks or pages. Each page has a unique identifier called PageID (i.e., page index). It is very important to manage the validity, allocation status, and access rights of these pages. The PageID bitmap is used to track which pages are free and which pages are allocated, thereby optimizing data access and management operations. The size of the bitmap depends on the total number of pages. In a high-concurrency environment, updates to the bitmap need to be handled carefully to ensure consistency and prevent competition conditions. Locks or other synchronization mechanisms are usually required to handle concurrent modifications to the bitmap; in some cases, the bitmap can become very large. To save storage space, compression techniques such as run-length encoding (RLE) can be used to reduce the storage requirements of the bitmap.
[0003] In the field of file systems and storage, pageid bitmap technology mainly faces the following problems: high storage overhead, especially when processing large-scale data, the storage and management of bitmaps may become complicated; in addition, the performance problem of bitmap updates may also become a bottleneck, especially when frequently modified and queried. These problems may affect the overall efficiency and response speed of the system.
[0004] In response to the above problems, the current solutions are only to use compression technology to compress bitmap blocks that remain zero for a long time to significantly reduce the occupied space, or to reduce the reference or erase time of bitmap pages through memory optimization, parallel processing cache, system improvement, etc., and optimize the query mechanism to improve the response speed. However, these solutions do not solve the above problems in principle. Summary of the invention
[0005] In order to solve the above technical problems, the present invention provides a method, system, device and storage medium for dynamically storing a page index bitmap in a file system.
[0006] The present invention is achieved through the following technical solutions.
[0007] The present invention provides a method for dynamically storing a page index bitmap in a file system, which is characterized by comprising the following methods: Store the page index bitmap count in the superblock; Apply for several consecutive free pages as pre-application pages for storing page index bitmaps, which can also be used for application when the file system writes data; After the page index bitmap is updated, it is placed into the pre-requested free pages in sequence; After all the pre-applied free pages are used, apply for a number of free pages as pre-applied pages; Updates the page index bitmap count in the superblock.
[0008] Further, storing the count of the page index bitmap in the super block includes the following methods: Allocate the first page and the first page index for the super block in memory, and place the page index bitmap count in the super block; The second page is allocated to store the current page index bitmap, and the first page is adjacent to the second page.
[0009] Further, applying for a number of consecutive free pages as pre-application pages for storing page index bitmaps; After the page index bitmap is updated, different pre-requested free pages are placed in sequence, including the following methods: If one side of the intervening application page is adjacent to the second page, the page index of the pre-application page is stored in the cache; The page index bitmap is updated and stored in the page adjacent to the second page.
[0010] Further, after all the pre-applied free pages are used, applying for a plurality of free pages as pre-applied pages includes the following method: When a pre-allocated page is used, the page index stored in the cache is taken and the corresponding cache page is set to a blank page; Repeat the above pre-application steps, and store the index of the free page applied again in the cache.
[0011] Further, updating the page index bitmap count in the super block includes the following methods: After the updated page index bitmap is stored in the second page, the page index bitmap count is updated according to the number of pages storing the page index bitmap in the memory.
[0012] The present invention also provides a page index bitmap dynamic storage system in a file system, including a memory and a cache. The memory includes a plurality of pages, and each page corresponds to a page index. A page is provided in the memory as a super block for storing the page index bitmap, and the page index of the free page is stored in the cache. The present invention also provides a page index bitmap dynamic storage device in a file system, which is used to implement the above method and system. A CPU, a memory, and a register are provided in the device, and the above devices are connected through the same bus. A cache is provided in the CPU.
[0013] The beneficial effects of the present invention are: by changing the storage of the page index bitmap to dynamic storage and adding a pre-application cache mechanism, the number of memory erases and writes is reduced, and the problem of repeatedly erasing the same memory block is avoided. Since the frequency of erasing is reduced, the system performance and response speed can be improved; Through the pre-application mechanism, the page index where the upper file system is to write data is determined in advance, ensuring that even if a power outage occurs during the writing process, the data will not be written to the used storage area. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] Figure 1 It is a schematic diagram of the method steps of the present invention; Figure 2 This is the initial state of Embodiment 1 of the present invention; Figure 3 This is state 1 of embodiment 1 of the present invention; Figure 4 This is state 2 of embodiment 1 of the present invention; Figure 5 This is state three of embodiment 1 of the present invention; Figure 6 This is the initial state of Embodiment 2 of the present invention; Figure 7 This is state 1 of embodiment 2 of the present invention; Figure 8 This is state 2 of embodiment 2 of the present invention; Fig. 9 This is state 3 of embodiment 2 of the present invention; Fig.10 It is a connection relationship diagram of the internal modules of the device of the present invention. DETAILED DESCRIPTION
[0015] The technical solution of the present invention is further described below, but the scope of protection claimed is not limited to the description.
[0016] In order to make the purpose, technical solutions and advantages of the present invention more clear, the present invention is described in detail below with reference to the accompanying drawings and specific embodiments.
[0017] Embodiment 1: The development board model used in this embodiment is STM32F407, and the matching Flash storage chip model is W25Q64. W25Q64 has a total of 8M storage space. The size of the logical page is set to 4K. A section of memory is selected in the memory as the implementation scenario of this embodiment, and its page index numbers are 0~7 in sequence. The page index bitmap count is stored in the super block. The super block is one end of the memory and the page index is 0. The current page index bitmap is stored in the page with a page index of 1. In this embodiment, free pages with consecutive page indexes 2~4 are applied as pre-application pages, and the values of page indexes 2~4 are stored in the cache. At this time, the page index bitmap is 0b1100 0000. Since there is only one page in the current memory to store the page index bitmap, the count in the super block is 1 at this time.
[0018] When the page index bitmap is updated to 0b1111 1000, this page index bitmap is stored in the page of pre-application page index 2, and the value 2 in the cache is cleared. Since there are 2 pages in the current memory to store the page index bitmap, the count in the super block is set to 2 at this time, and the page indexes 2~4 in the cache are all taken out and set to null pointers. Similarly, when the page index bitmap changes, the new page index bitmap will be stored in the pre-application page in turn, and the count in the super block will be updated. The data storage process of this embodiment is dynamic storage. During the access process, the page index bitmap is stored in a different pre-application page after each update, which avoids repeated erasing and writing of the same page. In addition, because the super block will be updated only after all the pre-application pages are used, the update frequency of the super block is reduced, which can also protect the super block.
[0019] Example 2 The development board model used in this embodiment is STM32F407, and the matching Flash storage chip model is W25Q64. W25Q64 has a total of 8M storage space. The size of the logical page is set to 4K. A section of memory is selected in the memory as the implementation scenario of this embodiment, and its page index numbers are 0~7 in sequence. The page index bitmap count is stored in the super block. The super block is one end of the memory and the page index is 0. The current page index bitmap is stored in the page with a page index of 1. In this embodiment, free pages with consecutive page indexes 2~5 are applied as pre-application pages, and the values of page indexes 2~5 are stored in the cache. At this time, the page index bitmap is 0b1100 0000. Since there is only one page in the current memory to store the page index bitmap, the count in the super block is 1 at this time.
[0020] When the page index bitmap is updated to 0b1111 1100, this page index bitmap is stored in the page of pre-application page index 2, and the value 2 in the cache is cleared. Since there are 2 pages in the current memory to store the page index bitmap, the count in the super block is set to 2 at this time, and the page indexes 2~5 in the cache are all taken out and set to null pointers. Similarly, when the page index bitmap changes, the new page index bitmap will be stored in the pre-application page in turn, and the count in the super block will be updated. The data storage process of this embodiment is dynamic storage. During the access process, the page index bitmap is stored in a different pre-application page after each update, which avoids repeated erasing and writing of the same page. In addition, because the super block will be updated only after all the pre-application pages are used, the update frequency of the super block is reduced, which can also protect the super block.
[0021] The above embodiments are preferred solutions for implementing the present invention. It should be noted that any obvious replacements and minor changes are within the protection scope of the present invention without departing from the concept of the present invention.
Claims
1. A method for dynamically storing a page index bitmap in a file system, characterized in that The following methods are included: S101, storing the page index bitmap count in the super block; S102, applying for a number of consecutive free pages as pre-application pages for storing page index bitmaps; S103, after the page index bitmap is updated, the pre-applied free pages are put into it in sequence; S104, after all the pre-applied free pages are used, apply for a number of free pages as pre-applied pages; S105. Update the page index bitmap count in the super block.
2. The method for dynamically storing page index bitmaps in a file system according to claim 1, characterized in that The following methods are used to store the page index bitmap count in the superblock: Allocate the first page and the first page index for the super block in memory, and place the page index bitmap count in the super block; The second page is allocated to store the current page index bitmap, and the first page is adjacent to the second page.
3. The method for dynamically storing page index bitmap in a file system according to claim 1, characterized in that: Apply for several consecutive free pages as pre-application pages for storing page index bitmaps; After the page index bitmap is updated, different pre-requested free pages are placed in sequence, including the following methods: If one side of the intervening application page is adjacent to the second page, the page index of the pre-application page is stored in the cache; The page index bitmap is updated and stored in the page adjacent to the second page.
4. The method for dynamically storing page index bitmap in a file system according to claim 1, characterized in that: After all the pre-applied idle pages are used, applying for a plurality of idle pages as pre-applied pages comprises the following method: When a pre-allocated page is used, the page index stored in the cache is taken and the corresponding cache page is set to a blank page; Repeat the above pre-application steps S102 and S103, and store the index of the free page applied again in the cache.
5. The method for dynamically storing page index bitmap in a file system according to claim 1, characterized in that: The following methods are used to update the page index bitmap count in the superblock: After the updated page index bitmap is stored in the second page, the page index bitmap count is updated according to the number of pages storing the page index bitmap in the memory.
6. A page index bitmap dynamic storage system in a file system, comprising a memory and a cache, wherein the memory comprises a plurality of pages, characterized in that Each page corresponds to a page index. A page is set in the memory as a super block to store the page index bitmap, and the page index of the free page is stored in the cache.
7. A device for dynamically storing a page index bitmap in a file system, comprising a module for executing the method according to any one of claims 1 to 5, characterized in that: It includes a processor and an interface circuit, wherein the interface circuit is used to receive signals from other devices other than the device for executing kernel mode commands and transmit them to the processor or send signals from the processor to other devices other than the device for executing kernel mode commands, and the processor is used to implement the method as described in any one of claims 1 to 5 through logic circuits or execution code instructions.
8. 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 according to any one of claims 1 to 5 is implemented.