File page table management technology
A file page table management method. The file page table management method is applied to a storage system in which a file system is created in a memory. According to the file page table management method, a mapping manner of a file page table can be dynamically adjusted based on an access type of an access request for accessing the memory, thereby improving memory access efficiency and saving memory space.
1. A file page table management method applied to a storage system with a processor, a memory, and a file system created based on the memory, the method comprising:
collecting, by the processor, statistics about types of access to a first file in the file system within a first time period;
performing a first determination, by the processor, that a quantity of first access types is greater than a quantity of second access types during the access to the first file within the first time period, wherein the first access type includes sequential access and large-granularity random access, and the second access type includes small-granularity random access;
performing a second determination, by the processor, that a mapping manner of a first file page table is a first mapping manner, wherein the first file page table is used to record a mapping relationship between a virtual address of an operating system and a memory page that stores data of the first file in the memory, wherein the first mapping manner establishes a mapping relationship between the virtual address of the operating system and a first-type page in the memory, wherein the first-type page stores the data of the first file; and
in response to the first determination and the second determination, adjusting, by the processor, the first file page table from the first mapping manner to a second mapping manner, wherein the second mapping manner establishes a mapping relationship between the virtual address of the operating system and a second-type page in the memory, and a size of the second-type page is greater than a size of the first-type page.
2. The method of claim 1 , wherein the adjusting the first file page table from the first mapping manner to a second mapping manner comprises:
allocating, by the processor, a second page in the memory to the first file, wherein the second page belongs to the second-type page;
copying, by the processor to the second page, data of a plurality of consecutive first-type pages to which the page table points; and
updating, by the processor, a pointer from pointing to the plurality of consecutive first-type pages in the page table to pointing to the second page.
3. The method according to claim 2 , further comprising:
releasing, by the processor, the plurality of consecutive first-type pages.
4. The method according to claim 1 , further comprising:
processing, by the processor based on an adjusted first file page table, a subsequent access request for accessing the first file.
5. The method according to claim 1 , wherein the memory is a non-volatile memory.
6. A file page table management method applied to a storage system with a processor, a memory, and a file system created based on the memory, the method comprising:
collecting, by the processor, statistics about types of access to a second file in the file system within a first time period;
performing a first determination, by the processor, that a quantity of first access types is not greater than a quantity of second access types during the access to the second file within the first time period, wherein the first access type includes sequential access and large-granularity random access, and the second access type includes small-granularity random access;
performing a second determination, by the processor, that a mapping manner of a second file page table is a second mapping manner, wherein the second file page table is used to record a mapping relationship between a virtual address of an operating system and a memory page that stores data of the second file in the memory, wherein the second mapping manner establishes a mapping relationship between the virtual address of the operating system and a second-type page in the memory, wherein the second-type page stores data of the second file; and
in response to the first determination and the second determination, adjusting, by the processor, the second file page table from the second mapping manner to a first mapping manner, wherein the first mapping manner establishes a mapping relationship between the virtual address of the operating system and a first-type page in the memory, and a size of the first-type page is less than a size of the second-type page.
7. The method according to claim 6 , wherein the adjusting, by the processor, the second file page table from the second mapping manner to a first mapping manner comprises:
allocating, by the processor, a next-level page table to a last-level page directory in the second file page table, wherein the next-level page table includes a plurality of page table entries, and a page directory entry in the last-level page directory points to the second-type page in the memory;
splitting, by the processor, the second-type page to which the second file page table points into a plurality of first-type pages based on addresses;
updating, by the processor, start addresses of the plurality of first-type pages to the plurality of page table entries in the next-level page table; and
updating, by the processor, a pointer from pointing to the second-type page in the second file page table to pointing to the next-level page table.
8. The method according to claim 6 , further comprising:
processing, by the processor based on an adjusted second file page table, a subsequent access request for accessing the second file.
9. The method according to claim 6 , wherein the memory is a non-volatile memory.
10. A storage system, comprising:
a memory and a file system;
a processor connected to the memory, the processor configured to:
collect statistics about types of access to a first file in the file system within a first time period;
perform a first determination that a quantity of first access types is greater than a quantity of second access types during the access to the first file within the first time period, wherein the first access type includes sequential access and large-granularity random access, and the second access type includes small-granularity random access;
perform a second determination that a mapping manner of a first file page table is a first mapping manner, wherein the first file page table is used to record a mapping relationship between a virtual address of an operating system and a memory page that stores data of the first file in a memory, wherein the first mapping manner establishes a mapping relationship between the virtual address of the operating system and a first-type page in the memory, wherein the first-type page stores the data of the first file; and
in response to the first determination and the second determination, adjust the first file page table from the first mapping manner to a second mapping manner, wherein the second mapping manner establishes a mapping relationship between the virtual address of the operating system and a second-type page in the memory, and a size of the second-type page is greater than a size of the first-type page.
11. The storage system of claim 10 , wherein in the step of the adjusting, the processor is configured to:
allocate a second page in the memory to the first file, wherein the second page belongs to the second-type page;
copy, to the second page, data of a plurality of consecutive first-type pages to which the page table points; and
update a pointer from pointing to the plurality of consecutive first-type pages in the page table to pointing to the second page.
12. The storage system according to the claim 11 , wherein the processor is further configured to:
release the plurality of consecutive first-type pages.
13. The storage system according to the claim 10 , wherein the processor is further configured to:
process, based on an adjusted first file page table, a subsequent access request for accessing the first file.
14. The storage system according to the claim 10 , wherein the memory is a non-volatile memory.
15. A storage system, comprising:
a memory and a file system;
a processor connected to the memory, the processor configured to:
collect statistics about types of access to a second file in the file system within a first time period;
perform a first determination that a quantity of first access types is not greater than a quantity of second access types during the access to the second file within the first time period, wherein the first access type includes sequential access and large-granularity random access, and the second access type includes small-granularity random access;
perform a second determination that a mapping manner of a second file page table is a second mapping manner, wherein the second file page table is used to record a mapping relationship between a virtual address of an operating system and a memory page that stores data of the second file in a memory, wherein the second mapping manner establishes a mapping relationship between the virtual address of the operating system and a second-type page in the memory, wherein the second-type page stores data of the second file; and
in response to the first determination and the second determination, adjust the second file page table from the second mapping manner to a first mapping manner, wherein the first mapping manner establishes a mapping relationship between the virtual address of the operating system and a first-type page in the memory, and a size of the first-type page is less than a size of the second-type page.
16. The storage system according to claim 15 , wherein in the step of the adjusting, the processor is configured to:
allocate a next-level page table to a last-level page directory in the second file page table, wherein the next-level page table includes a plurality of page table entries, and a page directory entry in the last-level page directory points to the second-type page in the memory;
split the second-type page to which the second file page table points into a plurality of first-type pages based on addresses;
update start addresses of the plurality of first-type pages to the plurality of page table entries in the next-level page table; and
update a pointer from pointing to the second-type page in the second file page table to pointing to the next-level page table.
17. The storage system according to the claim 15 , wherein the processor is further configured to:
process, based on an adjusted second file page table, a subsequent access request for accessing the second file.
18. The storage system according to the claim 15 , wherein the memory is a non-volatile memory.