WO2015131403A1 - 访问文件的方法和相关设备 - Google Patents

访问文件的方法和相关设备 Download PDF

Info

Publication number
WO2015131403A1
WO2015131403A1 PCT/CN2014/073070 CN2014073070W WO2015131403A1 WO 2015131403 A1 WO2015131403 A1 WO 2015131403A1 CN 2014073070 W CN2014073070 W CN 2014073070W WO 2015131403 A1 WO2015131403 A1 WO 2015131403A1
Authority
WO
WIPO (PCT)
Prior art keywords
file
address space
page table
memory area
memory
Prior art date
Application number
PCT/CN2014/073070
Other languages
English (en)
French (fr)
Inventor
沙行勉
诸葛晴凤
朱冠宇
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to PCT/CN2014/073070 priority Critical patent/WO2015131403A1/zh
Priority to CN201480000730.XA priority patent/CN105378687B/zh
Priority to EP14884527.4A priority patent/EP3115903B1/en
Priority to JP2016572867A priority patent/JP6385468B2/ja
Priority to KR1020167025615A priority patent/KR102061079B1/ko
Publication of WO2015131403A1 publication Critical patent/WO2015131403A1/zh
Priority to US15/257,928 priority patent/US10452562B2/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/10Address translation
    • G06F12/109Address translation for multiple virtual address spaces, e.g. segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/10Address translation
    • G06F12/1009Address translation using page tables, e.g. page table structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/11File system administration, e.g. details of archiving or snapshots
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/1727Details of free space management performed by the file system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/0643Management of files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/10Providing a specific technical effect
    • G06F2212/1008Correctness of operation, e.g. memory ordering
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/10Providing a specific technical effect
    • G06F2212/1016Performance improvement
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/65Details of virtual memory and virtual address translation
    • G06F2212/657Virtual address space management

Definitions

  • the present invention relates to the field of computer technologies, and in particular, to a method and apparatus for accessing files and a computing node. Background technique
  • SCM Storage Class Memory
  • the concept of Storage Class Memory (SCM) is now emerging, based on a new generation of non-volatile memory technology.
  • the access performance of the new generation of non-volatile memory is basically the same as that of the normal memory model.
  • it has the reliability of semiconductor products, such as shock and compression, and can be directly written without erasing old data. It can be used as a new generation storage device to alleviate the huge difference in access speed between processor and storage.
  • the SCM-side and some existing conventional random access memory (RAM) can be directly attached to the memory bus and directly face the central processing unit (CPU); In terms of its function, it also extends to existing external storage and can be used as a permanent data storage device.
  • NVM Non-Volatile Memory
  • DRAM dynamic random access memory
  • the embodiment of the invention provides a method for accessing a file and related devices, which are suitable for file access in a file system resident memory scenario.
  • a first aspect of the embodiments of the present invention provides a method for accessing a file, where the method for accessing a file is applied to a computing node, where the computing node includes a memory, and the memory includes: a file storage memory area and a process working memory area.
  • the working memory area of the process stores a memory page table, and an operating system runs in the working memory area of the process.
  • the method for accessing the file includes:
  • the operating system receives a file open request carrying a file identifier
  • the operating system obtains a first index node of the file represented by the file identifier, where the file is stored in the file storage memory area; and the file storage memory area is obtained based on the first index node a first physical address space in a memory area in which the file is stored;
  • the operating system allocates a first virtual address space to the file
  • the operating system records the first virtual address mapping relationship by using the memory page table
  • the first virtual real address mapping relationship includes a mapping relationship between the first virtual address space and the first physical address space, where the memory page table includes a kernel memory page table and/or a user process memory. Page table.
  • the obtaining, by the first index node, a first physical address space of a memory area in which the file is stored in the file storage memory area including: based on a first file page table recorded in the first index node or a pointer for pointing to the first file page table, obtaining a first physical address space of the memory area in the file storage memory area where the file is stored, wherein the first file page table is used to point to the file storage A memory area of the file is stored in the memory area, and the first physical address space is a single-level or multi-level file page table.
  • the using the memory page table to record the first virtual real address mapping relationship includes: adding the memory page table And an entry for recording the first virtual real address mapping relationship, the entry includes the first file page table or a pointer for pointing to the first file page table.
  • the total number of the memory page table is Y
  • the total number of the first file page table For X if it is The entry includes the first file page table, and the entry is an entry in the Y-X+1-level memory page table in the memory page table, if the entry includes a reference point a pointer of the first file page table, wherein the entry is an entry in a YX-level memory page table in the memory page table, the X is a positive integer, and the Y is greater than the positive of the X Integer.
  • the method further includes:
  • the operating system records, in the first index node, a first virtual address space and/or a starting address of the first virtual address space, and/or a file corresponding to the operating system in the file
  • the first virtual address space and/or the start address of the first virtual address space are recorded among the objects.
  • the first virtual address space is a continuous or non-contiguous virtual address space.
  • the first virtual address space is in a kernel virtual address space or a user process virtual address space.
  • the obtaining the first index node of the file represented by the file identifier includes: when it is determined that the file represented by the file identifier is stored in the file storage memory area, obtaining a file represented by the file identifier An index node.
  • the method further includes:
  • the operating system receives a file read request for requesting to read a file content of the file, wherein the file read request carries a first file in the file read into a memory address space and requested to be read The amount of data of the content, wherein the read-in memory address space is an address space of a first memory area in a working memory area of the user process;
  • the operating system obtains a reading from the file storage memory area based on the data amount of the first file content, the first virtual address space, and the first virtual real address mapping relationship recorded by the memory page table. Reading the physical address space of the first file content;
  • the operating system reads the first file content of the file from the file storage memory area based on the read physical address space;
  • the operating system writes the first file content into the first memory area.
  • the data amount based on the first file content, the first virtual address space, and the The first virtual real address mapping relationship recorded by the memory page table is obtained by reading the read physical address space of the first file content from the file storage memory area, including:
  • the area reads the read physical address space of the first file content, where the first file content offset is obtained from the file read request, or the first file content offset is from Obtained from among the file objects corresponding to the file.
  • the tenth possible implementation in the first aspect further includes:
  • the operating system receives a file write request requesting to write a file content to the file, wherein the file write request carries a read memory address space and a second file requested to be written into the file The amount of data of the content, wherein the read memory address space is an address space of a second memory area among the working memory areas of the process;
  • the operating system obtains a write to the file storage memory area based on the data amount of the second file content, the first virtual address space, and the first virtual real address mapping relationship recorded by the memory page table.
  • the operating system writes the second file content cached in the second memory area into the third memory area.
  • the data quantity based on the second file content, the first virtual address space, and The first virtual real address mapping relationship recorded by the memory page table is obtained by writing a write physical address space of the second file content to the file storage memory area, including:
  • the storage of the third memory area The capacity is greater than or equal to the amount of data of the second file content.
  • the method further includes: receiving a file close request for requesting to close the file; releasing a first virtual address space allocated for the file; releasing the first virtual address mapping relationship recorded in the memory page table.
  • the method further includes: the operating system determining that the file represented by the file identifier is not stored in the file storage memory area, and creating the file in the file storage memory area as the file Allocating a second index node, wherein the second index node records a second file page table or a pointer for pointing to the second file page table, wherein the second file page table is used to point to the file storage a memory area in which the file is stored in the memory area;
  • the operating system allocates a second virtual address space to the file
  • the operating system records the second virtual real address mapping relationship by using a memory page table
  • the second virtual address mapping relationship includes a mapping relationship between the second virtual address space and the second physical address space, where the second physical address space is in the file storage memory area.
  • a physical address space storing a memory area of the file, the memory page table including a kernel memory page table and/or a user process memory page table.
  • the number of the second file page table has a correspondence with the file type of the file relationship.
  • the file storage memory area includes a non-volatile memory area and/or a volatile memory area.
  • a second aspect of the present invention provides an apparatus for accessing a file, which may include:
  • a receiving unit configured to receive a file open request that carries a file identifier
  • An obtaining unit configured to obtain a first index node of the file represented by the file identifier, where the file is stored in a file storage memory area; and the storage unit in the file storage memory area is obtained based on the first index node The first physical address space of the memory area of the file;
  • An allocating unit configured to allocate a first virtual address space for the file
  • mapping unit configured to record a first virtual real address mapping relationship by using a memory page table
  • the first virtual real address mapping relationship includes a mapping relationship between the first virtual address space and the first physical address space, where the memory page table includes a kernel memory page table and/or a user process memory. Page table.
  • the obtaining unit is specifically configured to be based on the first index node, in the aspect that the first index node obtains the first physical address space of the memory area of the file in the file storage memory area a first file page table recorded in the file or a pointer for pointing to the first file page table, to obtain a first physical address space of the memory area in the file storage memory area where the file is stored, where
  • the first file page table is a single-level or multi-level file page table.
  • the mapping unit is specifically configured to: add, in the memory page table, the first virtual reality An entry of an address mapping relationship, the entry containing the first file page table or a pointer for pointing to the first file page table.
  • the total number of the memory page table is Y, the total number of the first file page table If the entry includes the first file page table, the entry is an entry in the Y-X+1-level memory page table in the memory page table, if the entry is Include a pointer for pointing to the first file page table, where the entry is an entry in a YX-level memory page table in the memory page table, the X is a positive integer, and the Y is greater than The positive integer of X.
  • the device for accessing the file further includes:
  • a recording unit configured to record, in the first index node, a starting address of the first virtual address space and/or the first virtual address space, and/or among file objects corresponding to the file Recording a first virtual address space and/or a starting address of the first virtual address space.
  • the first virtual address space is a continuous or non-contiguous virtual address space.
  • the first virtual address space is in a kernel virtual address space or a user process virtual address space.
  • the obtaining unit is specifically configured to: when the file storage memory area is determined to be stored in the file Identifying the file represented by the first index node of the file represented by the file identifier.
  • the receiving unit is further configured to receive a file read request for requesting to read a file content of the file, where the file read request carries a space read into a memory address space and requested to be read. a data volume of the first file content in the file, where the read memory address space is an address space of a first memory area in a working memory area of the user process;
  • the device for accessing a file further includes: a second mapping unit, configured to map, according to the data amount of the first file content, the first virtual address space, and the first virtual real address mapping relationship recorded by the memory page table Obtaining a read physical address space for reading the content of the first file from the file storage memory area;
  • a first read/write unit configured to read, according to the read physical address space, a first file content of the file from the file storage memory area; and write the first file content into the first file A memory area.
  • the data quantity based on the first file content, the first virtual address space, and the The first virtual real address mapping relationship recorded by the memory page table is obtained by reading a read physical address space of the first file content from the file storage memory area, where the second mapping unit is specifically used to The data amount of the first file content, the first file content offset, the first virtual address space, and the first virtual real address mapping relationship recorded by the memory page table are obtained from the file storage memory area. Taking the read physical address space of the first file content, where the first file content offset is obtained from the file read request, or the first file content offset is from the Obtained from the file object corresponding to the file.
  • the receiving unit is further configured to receive a file write request requesting to write a file content to the file, where the file write request carries a read memory address space and a request write station. a data amount of the second file content in the file, wherein the read memory address space is an address space of a second memory area in the working memory area of the process;
  • the device for accessing a file further includes: a third mapping unit, configured to map, according to the data amount of the second file content, the first virtual address space, and the first virtual real address mapping relationship recorded by the memory page table Obtaining a write physical address space for writing the content of the second file to the file storage memory area, where the write physical address space is a physical address of a third memory area in the file storage memory area Space
  • a second read/write unit configured to write the second file content cached in the second memory area into the third memory area.
  • the first virtual real address mapping relationship recorded by the memory page table is obtained by writing a write physical address space of the second file content to the file storage memory area, where the third mapping unit is specifically used. And storing, according to the data amount of the second file content, the second file content offset, the first virtual address space, and the first virtual real address mapping relationship recorded by the memory page table, to the file storage
  • the memory area is written into the write physical address space of the second file content, where the second file content offset is obtained from the file write request, or the second file content offset Obtained from the file object corresponding to the file.
  • the storage of the third memory area The capacity is greater than or equal to the amount of data of the second file content.
  • the receiving unit is further configured to: receive a file close request for requesting to close the file; the device for accessing the file further includes: a release unit, configured to release a first virtual address space allocated for the file; The first virtual real address mapping relationship recorded in the memory page table.
  • the device for accessing a file further includes: a file that is created, the file is created in the file storage memory area, and a second index node is allocated to the file, wherein the second index node records a second a file page table or a pointer for pointing to the second file page table, wherein the second file page table is used to point to a memory area in the file storage memory area where the file is stored;
  • the allocating unit is further configured to: allocate a second virtual address space for the file;
  • the mapping unit is further configured to: record, by using a memory page table, a second virtual real address mapping relationship; wherein the second virtual real address mapping relationship includes mapping between the second virtual address space and the second physical address space Relationship, wherein the second physical address space is a physical address space of a memory area in which the file is stored in the file storage memory area, and the memory page table includes a kernel memory page table and/or a user process memory page table .
  • the fifteenth possible aspect of the second aspect In conjunction with the fourteenth possible implementation of the second aspect, the fifteenth possible aspect of the second aspect In an embodiment, the number of levels of the second file page table and the file type of the file have a corresponding relationship.
  • the file storage memory area includes Volatile memory areas and/or volatile memory areas.
  • a third aspect of the embodiments of the present invention provides a computing node, which may include:
  • At least one bus at least one processor coupled to the bus, and at least one memory coupled to the bus;
  • the processor by using the bus, to call a code stored in the memory, to receive a file open request that carries a file identifier, and obtain a first index node of the file represented by the file identifier, where The file is stored in the file storage memory area; based on the first index; the first virtual address space is allocated to the file; the first virtual real address mapping relationship is recorded by using the memory page table; wherein the first virtual real address mapping The relationship includes a mapping relationship between the first virtual address space and the first physical address space, wherein the memory page table includes a kernel memory page table and/or a user process memory page table.
  • the code is specifically used to obtain, according to the first file page table recorded in the first index node or a pointer for pointing to the first file page table, to obtain a memory area in the file storage memory area where the file is stored.
  • a first physical address space wherein the first file page table is used to point to the file storage Storing a memory area of the file in the memory area, where the first physical address space is a physical address space of a memory area in the file storage memory area where the file is stored, where the first file page table is Single or multi-level file page table.
  • the processor is configured by using the memory page table to record a first virtual real address mapping relationship
  • the bus calls the code stored in the memory to specifically add an entry for recording the first virtual address mapping relationship in the memory page table, where the table entry includes the first file page table or A pointer to the first file page table.
  • the total number of the memory page table is Y, the total number of the first file page table If the entry includes the first file page table, the entry is an entry in the Y-X+1-level memory page table in the memory page table, if the entry is Include a pointer for pointing to the first file page table, where the entry is an entry in a YX-level memory page table in the memory page table, the X is a positive integer, and the Y is greater than The positive integer of X.
  • the processor calls the code stored in the memory through the bus to further record, in the first index node, the first virtual address space and/or the first virtual
  • the start address of the address space, and/or, the first virtual address space and/or the start address of the first virtual address space are recorded among file objects corresponding to the file.
  • the first virtual address space is a continuous or non-contiguous virtual address space.
  • the first virtual address space is in a kernel virtual address space or the user process is virtual.
  • the intended address space is in a kernel virtual address space or the user process is virtual.
  • the processor calls the code stored in the memory through the bus to further receive a file read request for requesting to read a file content of the file, where the file read request Carrying the data amount of the first file content in the file read into the memory address space and requesting to read, wherein the read memory address space is an address space of the first memory area in the working memory area of the user process Obtaining from the file according to the data amount of the first file content, the first virtual address space, and the first virtual real address mapping relationship recorded by the memory page table Reading a physical address space of the first file content; and reading, according to the read physical address space, the first file content of the file from the file storage memory area; The first file content is written into the first memory area.
  • the code stored in the memory is specifically used,
  • the storage memory area reads the read physical address space of the first file content, where the first file content offset is obtained from the file read request, or the first file content is offset
  • the amount is obtained from the file object corresponding to the file.
  • the processor by using the bus, to call the code stored in the memory to further receive the request a file write request for writing a file content to the file, wherein the file write request carries a read memory address space and a data amount of a second file content requested to be written into the file, wherein The read memory address space is an address space of a second memory area in the working memory area of the process;
  • the storage of the third memory area The capacity is greater than or equal to the amount of data of the second file content.
  • the processor by using the bus, to call the code stored in the memory to further receive a file close request for requesting to close the file; Freeing a first virtual address space allocated for the file; releasing the first virtual real address mapping relationship recorded in the memory page table.
  • the processor by using the bus, to call the code stored in the memory to further use the
  • the file is created in the file storage memory area, and the second index node is allocated to the file, wherein the second index node records a second file page table or a pointer for pointing to the second file page table.
  • the second file page table is used to point to a memory area in the file storage memory area where the file is stored
  • the second virtual address mapping relationship includes a mapping relationship between the second virtual address space and the second physical address space, where the second physical address space is in the file storage memory area.
  • a physical address space storing a memory area of the file, the memory page table including a kernel memory page table and/or a user process memory page table.
  • the step of the second file page table has a correspondence with the file type of the file relationship.
  • the file storage memory area includes Volatile memory areas and/or volatile memory areas.
  • a fourth aspect of the embodiments of the present invention provides a method for accessing a file, including:
  • the first virtual real address mapping relationship includes a mapping relationship between the first virtual address space and the first physical address space, where the memory page table includes a kernel memory page table and/or a user process memory. Page table.
  • the obtaining, by the first index node, a first physical address space of a memory area in which the file is stored in the file storage memory area including: based on a first file page table recorded in the first index node or a pointer for pointing to the first file page table, obtaining a first physical address space of the memory area in the file storage memory area where the file is stored, wherein the first file page table is used to point to the file storage A memory area of the file is stored in the memory area, and the first physical address space is a single-level or multi-level file page table.
  • the using the memory page table to record the first virtual real address mapping relationship includes: adding the memory page table And an entry for recording the first virtual real address mapping relationship, the entry includes the first file page table or a pointer for pointing to the first file page table.
  • the total number of the memory page table is Y, the total number of the first file page table If the entry includes the first file page table, the entry is an entry in the Y-X+1-level memory page table in the memory page table, if the entry is Include a pointer for pointing to the first file page table, where the entry is an entry in a YX-level memory page table in the memory page table, the X is a positive integer, and the Y is greater than The positive integer of X.
  • the method further includes:
  • the first virtual address space is a continuous or non-contiguous virtual address space.
  • the first virtual address space is in a kernel virtual address space or a user process virtual address space.
  • the obtaining the first index node of the file represented by the file identifier includes: when it is determined that the file represented by the file identifier is stored in the file storage memory area, obtaining a file represented by the file identifier An index node.
  • the method further includes:
  • the read-in memory address space is an address space of a first memory area in a working memory area of the user process
  • the ninth possible implementation of the fourth aspect In the manner, the first virtual address mapping relationship based on the data amount of the first file content, the first virtual address space, and the memory page table record is obtained from the file storage memory area.
  • the physical address space for reading the content of the first file includes:
  • the area reads the read physical address space of the first file content, where the first file content offset is obtained from the file read request, or the first file content offset is from Obtained from among the file objects corresponding to the file.
  • the file write request carries a read memory address space and a data amount of a second file content requested to be written into the file
  • the read memory address space is an address space of a second memory area in the working memory area of the process
  • the data quantity based on the second file content, the first virtual address space, and The first virtual real address mapping relationship recorded by the memory page table is obtained by writing a write physical address space of the second file content to the file storage memory area, including: Obtaining a storage memory to the file based on the data amount of the second file content, the second file content offset, the first virtual address space, and the first virtual real address mapping relationship recorded by the memory page table Writing a physical address space of the second file content, wherein the second file content offset is obtained from the file write request, or the second file content offset is from Obtained from among the file objects corresponding to the file.
  • the storage of the third memory area The capacity is greater than or equal to the amount of data of the second file content.
  • the method further includes: receiving a file close request for requesting to close the file; releasing a first virtual address space allocated for the file; releasing the first virtual address mapping relationship recorded in the memory page table.
  • the file that is created the file is created in the file storage memory area, Document allocation a second index node, wherein the second index page records a second file page table or a pointer for pointing to the second file page table, wherein the second file page table is used to point to the file storage memory area a memory area in which the file is stored;
  • the second virtual address mapping relationship includes a mapping relationship between the second virtual address space and the second physical address space, where the second physical address space is in the file storage memory area.
  • a physical address space storing a memory area of the file, the memory page table including a kernel memory page table and/or a user process memory page table.
  • the step of the second file page table has a correspondence with the file type of the file relationship.
  • the file storage memory area includes Volatile memory areas and/or volatile memory areas.
  • a fifth aspect of the present invention provides a computer storage medium, characterized in that
  • the computer storage medium stores a program that, when executed, includes the steps of any of the methods as provided by the above method embodiments.
  • the operating system after receiving the file open request carrying the file identifier, the operating system obtains the first index node of the file represented by the file identifier, and is based on the first physical address space;
  • the above file allocates the first virtual address space; a virtual real address mapping relationship; wherein the first virtual real address mapping relationship is a mapping relationship between the first virtual address space and the first physical address space, and the memory page table includes a kernel memory page to record the first virtual real address mapping
  • the relationship may be considered to be a certain degree to the first physical address space of the memory area in which the file is stored in the file storage memory area, and is packaged into a physical address space corresponding to a certain memory area in the working memory area of the process, which is beneficial to
  • the kernel or the user process accesses the file in the file storage memory area in a manner similar to the working memory area of the access process, which is convenient for the kernel or the user process to access the file system of the resident kernel file with the access performance of the ordinary memory data.
  • FIG. 1 is a schematic flowchart of a method for accessing a file according to an embodiment of the present invention
  • FIG. 2 is a schematic flowchart of another method for accessing a file according to an embodiment of the present invention
  • FIG. 2b is a schematic diagram of a memory of a computing node according to an embodiment of the present invention
  • FIG. 2 is a schematic diagram of another memory of a computing node according to an embodiment of the present disclosure
  • FIG. 2 is a schematic diagram of another file storage memory area according to an embodiment of the present invention.
  • FIG. 2 is a schematic diagram of a relationship between a file page table and a memory page according to an embodiment of the present invention
  • FIG. 3 is a schematic flowchart of another method for accessing a file according to an embodiment of the present invention
  • FIG. 5 is a schematic flowchart of another method for accessing a file according to an embodiment of the present invention
  • FIG. 6 is a schematic diagram of another method for accessing a file according to an embodiment of the present invention
  • FIG. 7 is a schematic flowchart diagram of another method for accessing a file according to an embodiment of the present invention
  • FIG. 8 is a schematic flowchart of another method for accessing a file according to an embodiment of the present invention
  • FIG. 9 is a schematic diagram of an apparatus for accessing a file according to an embodiment of the present invention
  • 9-b is a schematic diagram of another apparatus for accessing a file according to an embodiment of the present invention.
  • 9-c is a schematic diagram of another apparatus for accessing a file according to an embodiment of the present invention.
  • FIG. 9-d is a schematic diagram of another apparatus for accessing a file according to an embodiment of the present invention.
  • 9-e is a schematic diagram of another apparatus for accessing a file according to an embodiment of the present invention.
  • FIG. 10 is a schematic diagram of a computing node according to an embodiment of the present invention.
  • FIG. 11 is a schematic diagram of another computing node according to an embodiment of the present invention. detailed description
  • the embodiment of the invention provides a method for accessing a file and related devices, which are suitable for file access in a resident system of a file system.
  • An embodiment of the method for accessing a file wherein the method for accessing a file is applied to a computing node, wherein the computing node may include a memory, and the memory includes: a file storage memory area and a process working memory area, The working memory area of the process stores a kernel memory page table. The working memory area of the above process runs an operating system.
  • the method for accessing the file may include: the operating system receives a file open request carrying the file identifier; and the operating system obtains the file identifier.
  • Document a first index node, wherein the file is stored in a file storage memory area; the operating system is based on the upper physical address space; the operating system allocates a first virtual address space for the file; and the operating system records the first virtual address by using the memory page table
  • the first virtual address mapping relationship includes a mapping relationship between the first virtual address space and the first physical address space, where, for example, the process working memory area may include a kernel process working memory.
  • the area and user process working memory area wherein the kernel memory page table can be stored in the kernel process working memory area, and the user process memory page table can be stored in the working process memory area of the user process.
  • the above kernel process runs an operating system in the working memory area.
  • FIG. 1 is a schematic flowchart of a method for accessing a file according to an embodiment of the present invention.
  • a method for accessing a file provided by an embodiment of the present invention may include the following content:
  • the operating system receives a file open request that carries a file identifier.
  • the file open request for receiving the file identifier may include: receiving a file open request for carrying the file identifier from the user process.
  • the file open request may carry a file storage path (that is, a storage path of a file that is requested to be opened), where the file identifier may be included in the file storage path, and of course, in the file open request. It is also possible to carry a file identification and may not carry a file storage path.
  • the file opening request may further carry a file type flag bit, where the file type flag bit may indicate a file type of the file represented by the file identifier (the file type may be a directory file or a data file).
  • the operating system obtains a first index node of the file represented by the file identifier, and is based on the upper physical address space.
  • the above file is stored in the file storage memory area.
  • the file of the first cable that obtains the file indicated by the file identifier is obtained, and the first index node of the file represented by the file identifier is obtained.
  • the file represented by the file identifier is stored in the file storage memory area, and in this scenario, the step of determining whether the file indicated by the file identifier is stored in the file storage memory area may be omitted.
  • the memory may include: a process working memory area (where the process working memory area may include a user process working memory area and a kernel process working memory area) and a file storage memory area.
  • the process working memory area refers to a physical memory area for storing data structures and variables included in the working environment when the process is running.
  • the data structure and the variable may include at least one of the following information: a heap, a stack, a memory mapped area, a variable of the program corresponding to the process, a character, an array, and the like when the process runs.
  • the user process working memory area may refer to a physical memory area for storing contents such as data structures and variables included in the working environment when the user process runs.
  • the foregoing data structure and variables stored in the working memory area of the user process may include, for example, at least one of the following: a heap, a stack, a memory mapped area, a variable of a program corresponding to the user process, a character, an array, and the like when the user process runs. data.
  • the kernel process working memory area may refer to a physical memory area for storing data structures and variables included in the working environment of the kernel process runtime.
  • the foregoing data structure and variables stored in the working memory area of the kernel process may include, for example, at least one of the following: a heap, a stack, a memory mapped area, a variable of a program corresponding to the kernel process, characters, and an array of the kernel process. data.
  • the file storage memory area may be a physical memory area for storing a file system, and the file storage memory area may store various information of the file system itself, for example, an index node and a file in the file storage memory area where the file system may be stored. It can further store information such as superblocks (if any) of the file system.
  • the file storage memory area may include a non-volatile memory area and/or a volatile memory area (ie, the storage medium of the file storage memory area includes a non-volatile storage medium and/or Loss storage medium).
  • the process working memory area (such as the kernel process working memory area, the user process working memory area) may include a non-volatile memory area and/or a volatile memory area (ie, a storage medium of the working memory area of the process includes non-volatile Storage medium and/or volatile storage medium).
  • the process The memory area (such as the kernel process working memory area, the user process working memory area) and the file storage memory area do not overlap each other.
  • the index node of the file may include information that can obtain a physical address space of a memory area in the file storage memory area where the file is stored.
  • a first file page table FPT, File Page Table
  • a pointer for pointing to a first file page table may be recorded in the first index node of the above file, and the first file page table is a single-level or multi-level file page.
  • the first physical address space is a physical address space of a memory area in which the file is stored in the file storage memory area.
  • the first index node may also be a space or a starting address of the first physical address space, and the like.
  • the first index node of the file may further include information such as metadata of the file.
  • the operating system allocates a first virtual address space to the file.
  • the file may be allocated a first virtual address space of a preset size (for example, the size of the first virtual address space may be less than or equal to the maximum virtual address space of the system divided by the maximum number of files simultaneously supported by the system. Number).
  • the first virtual address space corresponding to the file type may be allocated to the file.
  • the virtual address space corresponding to the directory file and the virtual address space corresponding to the data file may not be equal.
  • the size of the virtual address space corresponding to the directory file may be smaller than the size of the virtual address space corresponding to the data file, for example, the virtual address corresponding to the directory file.
  • the size of the space is 1MB, 2MB, 10MB or 30MB.
  • the virtual address space corresponding to the data file is 100MB, 500MB, 1GB, 10GB, 100GB or 2TB.
  • the operating system records the first virtual real address mapping relationship by using a memory page table.
  • the first virtual real address mapping relationship includes a mapping relationship between the first virtual address space and the first physical address space, wherein the memory page table includes a kernel memory page table and/or a user process memory page table.
  • the operating system After receiving the file open request carrying the file identifier, the operating system obtains the first index node of the file represented by the file identifier, and obtains the file storage memory area to store the file according to the first index node.
  • the first virtual address space is recorded by the memory page table; wherein the first virtual address mapping relationship is the first virtual address space and the first physical address space, and the kernel memory page table is utilized.
  • the above file access scheme is suitable for high-performance file access in the file system resident memory scenario.
  • the virtual address space is allocated for the file when the file is requested to be opened, it is advantageous to reduce the invalid occupation and address conflict possibility of the system virtual address space, and is beneficial to improving the utilization efficiency of the system virtual address space.
  • a file open request for carrying a file identifier from a user process if a file open request for carrying a file identifier from a user process is received, a file object corresponding to the file and the user process may be created, and the first virtual reality may be recorded in the memory page table. After the address mapping relationship, the file description of the above file is fed back to the user process.
  • the recording the first virtual real address mapping relationship by using the memory page table may include: adding an entry for recording the first virtual real address mapping relationship in the memory page table (may be one or more An entry, wherein the entry includes the first file page table or a pointer for pointing to the first file page table.
  • the total number of levels of the memory page table is Y
  • the total number of levels of the first file page table is X.
  • the table entry may be in the memory page table.
  • the entry in the Y-X+1-level memory page table if the table entry includes a pointer for pointing to the first file page table, the table entry may be the YX-level memory page in the foregoing memory page table.
  • the entry (possibly one or more entries) added to the memory page table for recording the first virtual address mapping relationship may also be any level in the memory page table.
  • the recording the first virtual real address mapping relationship by using the memory page table may include: adding an entry for recording the first virtual real address mapping relationship in the memory page table (may be one or more (Table entry), where the entry includes the first physical address space or the entry may include a start address and/or an end address of the first physical address space, for example, the entry may be among the lowest level of the memory page table
  • the entry of the table may be an entry in any level of the memory page table.
  • the first virtual address space, the start address of the first virtual address space, and the end address of the first virtual address space may be further recorded in the first index node. At least one, and/or, at least one of the first virtual address space, the start address of the first virtual address space, and the end address of the first virtual address space may be recorded among the file objects corresponding to the file One.
  • the first virtual address space is a continuous or non-contiguous virtual address space. In some embodiments of the present invention, the first virtual address space is in a kernel virtual address space or the first virtual address space is in a user process virtual address space.
  • the file after the file is opened, the file can be read/written and the like.
  • the method of accessing a file may further include: an operating system receiving a file read request for requesting to read a file content of the file, wherein the file read request carries a read-in memory address space and requesting to read The data amount of the first file content in the above file (in addition, the file read request may further carry the file descriptor of the file), wherein the read-in memory address space is the first among the working process memory areas of the user process.
  • the first virtual address mapping relationship based on the data amount of the first file content, the first virtual address space, and the memory page table record is obtained from the file storage memory area.
  • the reading the physical address space of the content of the first file may include: a data amount based on the content of the first file, a first file content offset, the first virtual address space, and
  • the first virtual real address mapping relationship recorded by the memory page table is obtained by reading a read physical address space of the first file content from the file storage memory area, wherein the first file content offset is read from the file Obtained in the request, or the first file content offset is obtained from the file object corresponding to the file.
  • the default file content offset may be used as a first file content offset
  • a start address of the first virtual address space to obtain a starting read virtual address for reading the content of the first file; and using the initial read virtual address and the first virtual real address mapping Relationship, obtaining a starting physical address for reading the content of the first file from the file storage memory area; and reading the physical address of the first physical file and the content of the first file, and reading from the file storage memory area
  • the physical address space of the first file content is read.
  • the default file content offset may be As a first file content offset
  • a start read virtual address for reading the first file content is obtained; and based on the initial read virtual address and the first file content
  • the amount of data is obtained by reading the read virtual address space of the first file content; using the read virtual address space and the first virtual real address mapping relationship to obtain reading of the first file content from the file storage memory area Physical address space.
  • the method for accessing a file may further include: receiving a file write request requesting to write a file content to the file, wherein the file write request carries a read memory address space and requests to write the file
  • the data amount of the second file content (in addition, the file write request may further carry the file descriptor of the file), wherein the read memory address space is the second memory area in the process working memory area An address space; based on the data amount of the content of the second file, the first virtual address space, and the first virtual address mapping relationship recorded by the memory page table, obtaining the content of writing the second file to the file storage memory area Write the physical address space, wherein the write physical address space is a physical address space of a third memory area in the file storage memory area; and writing the second file content cached in the second memory area to Among the above third memory areas.
  • the foregoing is written into the file storage memory area.
  • the writing of the physical address space of the second file content may include: the first virtual address based on the data amount of the second file content, the second file content offset, the first virtual address space, and the memory page table record Mapping the relationship, obtaining a write physical address space for writing the content of the second file to the file storage memory area, wherein the second file content offset is obtained from the file write request, or the second file The content offset is obtained from the file object corresponding to the above file.
  • the default file content offset may be used as a second file content offset
  • a start address of the first virtual address space to obtain a start write virtual address for writing the content of the second file to the file; using the above-mentioned initial write virtual address and the first
  • the virtual real address mapping relationship obtains a starting physical address for writing the content of the second file to the file from the file storage memory area; and based on the data amount of the initial writing physical address and the second file content, Writing a physical address space of the content of the second file to the above file of the file storage memory area.
  • the default file content offset may be As the second file content offset
  • the virtual address is written to the beginning of the second file content in the file; the virtual address and the second file are written based on the start
  • the amount of data of the content is obtained by writing the write virtual address space to the content of the second file in the file of the file storage memory area; and using the write virtual address space and the first virtual physical write address space.
  • the storage capacity of the third memory area may be greater than or equal to the data volume of the second file content.
  • the memory area corresponding to the third memory area and the first physical address space has an intersection or no intersection. It can be understood that, in a normal case, if the memory area corresponding to the third memory area and the first physical address space have an intersection, it may indicate that the original file is replaced by the content of the second file.
  • Some or all of the contents of the file (if the intersection of the third memory area and the memory area corresponding to the first physical address space is smaller than the third memory area, indicating that a new memory area is allocated for the second file content, that is, storing the above file The memory area has changed, and the memory area for storing the above files has been expanded.) If the memory area corresponding to the third memory area and the first physical address space does not intersect, it may indicate that the second file content is added in the file, and the third memory area allocates a new memory area for the second file content, that is, The memory area in which the above file is stored has changed, and the memory area in which the above file is stored is expanded.
  • the new first file page table is such that the updated first file page table points to the memory area in the file storage memory area where the above file is currently stored.
  • the first virtual address mapping relationship recorded in the foregoing memory page table may be updated to a third virtual real address mapping relationship, where the third virtual real address mapping relationship includes the first virtual address space and the third physical address.
  • the mapping relationship between the spaces, the third physical address space is a physical address space of a memory area in the file storage memory area where the file is currently stored.
  • the memory page table records a pointer to the first file page table (for example, the starting physical address of the first file page table recorded in the memory page table)
  • the updated first file page table starts If the physical address has not changed, the pointer to the first file page table may not be modified in the memory page table.
  • the first file page table is updated without modifying the memory page table, and the virtual real address mapping relationship can be reconstructed, which greatly reduces the mapping operation.
  • the method for accessing a file may further include: the operating system receiving a file close request for requesting to close the file; releasing the first virtual address space allocated for the file; releasing the record in the memory page table The first virtual address mapping relationship described above. Further, if the file object corresponding to the file is created, the file object corresponding to the file may be further released.
  • the file after receiving the file open request carrying the file identifier, when it is determined that the file indicated by the file identifier is not stored in the file storage memory area, the file is created in the file storage memory area. , assign a second index node to the above file.
  • the second index page may record a second file page table or a pointer for pointing to the second file page table (the pointer for pointing to the second file page table may be the starting physical address of the second file page table) ;), the second article above Allocating a second virtual address space; using a memory page table to record a second virtual address mapping relationship; wherein, the second virtual real address mapping relationship may include a mapping relationship between the second virtual address space and the second physical address space, where The second physical address space is a physical address space of the memory area in which the file is stored in the file storage memory area, wherein the memory page table includes a kernel memory page table and/or a user process memory page table.
  • the number of the second file page table has a corresponding relationship with the file type of the file, where the file type of the file is determined by, for example, a file type flag of the file carried in the file open request.
  • the file type of the above file can also be determined by other means.
  • the file after receiving the file open request carrying the file identifier, when it is determined that the file indicated by the file identifier is not stored in the file storage memory area, the file is created in the file storage memory area. Assigning a third index node to the above file, at this time, the file page table of the file or the empty file page table of the file may not be created first (where, if the empty file page table of the file is created, the third index node may be The empty file page table or the pointer for pointing to the empty file page table is included.
  • the memory area for storing the file may be expanded (for example, from 10 MB to 1000 MB).
  • the file page table of the above file is updated so that the updated file page table points to the memory area in which the above file is stored after the expansion.
  • the file page table is similar or identical to the data structure of the memory page table.
  • the execution body of the foregoing operation may be an operating system (specifically, a kernel file system in an operating system).
  • the memory page table includes a kernel memory page table and/or a user process memory page table. Because the kernel memory page table and/or the user process memory page table are used to record the first virtual real address mapping relationship, it can be considered that the file storage memory area is stored to some extent.
  • the first physical address space of the memory area storing the file is packaged into a physical address space corresponding to a memory area in the working memory area of the process, which is convenient for the kernel or the user process to access the file in a manner similar to the working area of the access process.
  • Storing files in the memory area which is beneficial to the kernel or user process to access the file system of the resident kernel file by approximating the access performance of ordinary memory data, which is beneficial to greatly improve file access performance. It can be seen that the above file access scheme is more suitable for high-performance file access in the file system resident memory scenario.
  • the virtual address space is allocated for the file when the file is requested to be opened, this is advantageous for reducing the invalid occupation and address conflict possibility of the system virtual address space, and is beneficial to improving the utilization efficiency of the system virtual address space.
  • the memory management unit (MMU, Memory Management Unit) can transparently convert the virtual address and physical address of the file, which helps to speed up file access and even achieve zero overhead.
  • a file page table with a data structure similar to or the same as the memory page table is used to point to a memory page in which the file content is stored in the file storage memory area
  • the data structure of the file page table and the memory page table are similar or identical, it is advantageous to implement Zero conversion of the page table data structure, and when the memory page storing the file content changes, it may not be necessary to perform the operation of reconstructing the mapping relationship between the file physical address space and the virtual address space for the file page table, and by updating the file page table,
  • the pointer to the updated file page table is inserted into the table entry of the file page table, thereby completing the mapping of the physical address of the file and the virtual address, which is beneficial for reconstructing the physical address of the file within a constant time independent of the file size. Mapping to virtual addresses.
  • the file system in the file storage memory area is protected by the system virtual address and the MMU, which greatly reduces the possibility of being mistakenly written, and can not only be good. Protects the file and does not require an additional write protection mechanism to facilitate the system.
  • the size of the file is only affected by the system virtual address.
  • the size of the space, as well as the number of files that are supported by the operating system at the same time, are not limited by the file system itself, so the file size is not limited by the file system itself.
  • the file system adopts a method similar to the memory management, and the storage medium is accessed through the virtual address, and the MMU can be used to convert the virtual address and the physical address, and the kernel can be changed relatively less, which is convenient for the file system. Migrate to an existing operating system.
  • the following is an example of a specific application scenario.
  • FIG. 2-a is a schematic flowchart diagram of another method for accessing a file according to another embodiment of the present invention.
  • Another method for accessing a file provided by another embodiment of the present invention may include the following:
  • the operating system receives a file open request carrying a file identifier from a user process (hereinafter referred to as user process A).
  • the file open request may carry a file storage path (that is, a storage path of a file that is requested to be opened), where the file identifier may be included in the file storage path, and of course, in the file open request. It is also possible to carry a file identification and may not carry a file storage path.
  • the file opening request may further carry a file type flag bit, where the file type flag bit may indicate a file type of the file represented by the file identifier (the file type may be a directory file or a data file).
  • the operating system creates a file object corresponding to the file represented by the file identifier (hereinafter referred to as file F1), and allocates a file descriptor for the file F1. Among them, the file object of the file F1 can be found based on the file descriptor of the file F1.
  • the operating system determines whether a file F1 is stored in the file storage memory area.
  • step 204 is performed.
  • the operating system can feed back the file open failure instruction to user process A.
  • the operating system obtains the first index node of the file F1, wherein the file is stored in the file storage memory area, and the first index node of the file F1 is also stored in the file storage memory area.
  • Figure 2-b shows a memory diagram of a compute node, a compute node.
  • the memory may include a user process working memory area S1, a kernel process working memory area S2, and a file storage memory area S3.
  • the user process working memory area S1 may refer to a physical memory area for storing contents such as data structures and variables included in the working environment when the user process runs.
  • the foregoing data structure and variables stored in the working memory area of the user process may include, for example, at least one of the following: a heap, a stack, a memory mapped area, a variable of a program corresponding to the user process, a character, an array, and the like when the user process runs. data.
  • the kernel process working memory area S2 can be a physical memory area for storing data structures and variables included in the working environment of the kernel process.
  • the foregoing data structure and variables stored in the working memory area of the kernel process may include, for example, at least one of the following: a heap, a stack, a memory mapped area, a variable of a program corresponding to the kernel process, characters, and an array of the kernel process. data.
  • the file storage memory area S3 may include a non-volatile memory area and/or a volatile memory area (ie, the storage medium of the file storage memory area S3 includes a non-volatile storage medium and/or Volatile storage medium).
  • the process working memory area (such as the kernel process working memory area S2 and the user process working memory area S1) may include a non-volatile memory area and/or a volatile memory area (ie, a storage medium of the working memory area of the process includes non-volatile Storage medium and/or volatile storage medium).
  • the process working memory area (such as the kernel process working memory area S2, the user process working memory area S 1 ) and the file storage memory area do not overlap each other.
  • the user process work memory area S1 and the kernel process work memory area S2 may be located in the DRAM, and the file storage memory area S3 may be located in the NVM.
  • the file storage memory area S3 may refer to a physical memory area for storing a file system, and the file storage memory area may store various information of the file system itself, for example, an index node and a file in the file storage memory area where the file system can be stored. , can further store the super block (if any) of the file system and so on.
  • the file storage memory area S3 may include a super block, an inode area for storing a file index node, and a file data area for storing files.
  • a pointer for pointing to the first file page table may be recorded in the first index node of the file F1 (the pointer for pointing to the first file page table may include the start of the first file page table)
  • the first file page table is used to point to a memory area in the file storage memory area S3 where the file F1 is stored, and the first physical address space is a physics of the memory area in which the file is stored in the file storage memory area. Address space.
  • the first file page table described above is a single-level or multi-level file page table.
  • a memory page for storing a single file is organized by a file page table having a data structure similar or equivalent to a memory page table, and the file page table may be a one-level or multi-level file page table.
  • Each entry in each level file page table in the non-lowest level file page table records the starting physical address of a file page table at the next level.
  • Each entry of the lowest level file page table stores the starting physical address of a memory page of the file.
  • Figure 2-e shows that the first file page table is a three-level file page table, which is a PUD, PMD, and PTE level, wherein each entry in the PUD records a PMD.
  • the starting physical address, and each entry of each PMD records the starting physical address of a PTE, and each entry of the PTE records the starting physics of a memory page (where the memory page stores the file content of the file F1) address. Understandably, not every file needs to use a three-level file page table. Even if a three-level page table is used, it does not necessarily have a fixed format. For example, not every file needs to use 1024 PTEs.
  • the size of the file changes dynamically to adjust the file page table organization. For example, a pointer to a first level file page table PUD of a three-level file page table (e.g., a starting physical address of the PUD;) may be recorded in the first index node.
  • Each file corresponds to an inode.
  • the first index node includes a pointer (Pointer) for pointing to the file page table, and the pointer specifically stores the highest level file page table (PUD) of the file F1. The starting physical address of the physical memory page.
  • Pointer pointer
  • PID file page table
  • the first index node of the file F1 may further include the metadata of the file F1, and the metadata of the file F1 includes the attribute information of the file F1 (such as file size, file type, file modification time, file creation time, etc.)
  • the file page table of each file is stored in the file data area of the file storage memory area. Due to the byte-addressable nature of the file storage memory area and the linked list-based organization of the file page table, the file page table does not need to be placed in a fixed area. Just store it as a normal file in the file data area.
  • the operating system obtains, according to the first index node, a first physical address space of a memory area in which the file F1 is stored in the file storage memory area. Since the first index node includes a pointer for pointing to the first file page table of the file F1, a pointer for pointing to the first file page table of the file F1 can be obtained based on the first index node, and is obtained for pointing to the file.
  • the pointer of the first file page table of F1 can obtain the first file page table of the file F1, and further can obtain the first memory area of the file F1 stored in the file storage memory area based on the first file page table of the file F1. Physical address space.
  • the operating system allocates a first virtual address space to the file.
  • the file may be allocated a first virtual address space of a preset size (for example, the size of the first virtual address space may be less than or equal to the maximum virtual address space of the system divided by the maximum number of files simultaneously supported by the system. Number).
  • the first virtual address space corresponding to the file type may be allocated to the file.
  • the virtual address space corresponding to the directory file and the virtual address space corresponding to the data file may not be equal.
  • the size of the virtual address space corresponding to the directory file may be smaller than the size of the virtual address space corresponding to the data file, for example, the virtual address corresponding to the directory file.
  • the size of the space is 1MB, 2MB, 10MB or 30MB.
  • the virtual address space corresponding to the data file is 100MB, 500MB, 1GB, 10GB, 100GB or 2TB.
  • the operating system records the first virtual address mapping relationship by using a memory page table.
  • the first virtual real address mapping relationship is a mapping relationship between the first virtual address space and the first physical address space, wherein the memory page table includes a kernel memory page table and/or a user process memory page table.
  • the recording the first virtual real address mapping relationship by using the memory page table may include: adding an entry for recording the first virtual real address mapping relationship in the memory page table (may be one or a plurality of entries), wherein the table entry includes a pointer for pointing to the first file page table (the pointer for pointing to the first file page table may include a starting physical address of the first file page table). For example, the total number of stages of the memory page table is Y, and the total number of levels of the first file page table is X. If the table item includes the first file page table, the table entry may be the foregoing memory page table.
  • the entry in the Y-X+1-level memory page table in the table if the table entry includes a pointer for pointing to the first file page table, the table entry may be the YX level in the foregoing memory page table
  • an entry (possibly one or more entries) added to the memory page table for recording the first virtual address mapping relationship may also be any level of the memory page table in the memory page table. The entry in the table.
  • the first virtual address space, the start address of the first virtual address space, and the end address of the first virtual address space may be further recorded in the first index node. At least one, and/or, at least one of the first virtual address space, the start address of the first virtual address space, and the end address of the first virtual address space may be recorded among the file objects corresponding to the file One.
  • the first virtual address space is a continuous or non-contiguous virtual address space. In some embodiments of the present invention, the first virtual address space is in a kernel virtual address space or the first virtual address space is in a user process virtual address space.
  • the operating system feeds back to the user process A a file description symbol of the file F1.
  • User process A can initiate a read and write operation on file F1 based on the file description symbol of file F1. It can be seen that, in the foregoing technical solution of the embodiment, after receiving the file open request carrying the file identifier; determining whether the file represented by the file identifier is stored in the file storage memory area; if the file storage memory area is And storing the foregoing file, obtaining a first index node of the file, and obtaining, according to the first index node, a first physical address space of a memory area in which the file is stored in the file storage memory area; a virtual address space; the first virtual address mapping relationship is recorded by the memory page table; wherein the first virtual real address mapping relationship is a mapping relationship between the first virtual address space and the first physical address space, wherein the memory is
  • the page table includes a kernel memory page table and/or a user process memory page table.
  • the kernel virtual page table and/or the user process memory page table are used to record the first virtual real address mapping relationship, it can be considered that the first physical address space of the memory area storing the file in the file storage memory area is to some extent.
  • the physical address space corresponding to a certain memory area in the working memory area of the process which is beneficial for the kernel or the user process to implement the kernel or the user process to access the file system of the resident kernel file with the access performance of the ordinary memory data. , is conducive to greatly improve file access performance. It can be seen that the above file access scheme is more suitable for high-performance file access in the file system resident memory scenario. And because it is in the request When the file is opened, the virtual address space is allocated to the file, which is beneficial to reduce the invalid occupation and address conflict of the system virtual address space, and is beneficial to improving the utilization efficiency of the system virtual address space.
  • the MMU transparently completes the conversion between the virtual address and the physical address of the file, which facilitates faster file access and even zero overhead.
  • a file page table with a data structure similar to or the same as the memory page table is used to point to a memory page in which the file content is stored in the file storage memory area
  • the data structure of the file page table and the memory page table are similar or identical, it is advantageous to implement Zero conversion of the page table data structure, and when the memory page storing the file content changes, it may not be necessary to perform the operation of reconstructing the mapping relationship between the file physical address space and the virtual address space for the file page table, and by updating the file page table,
  • the pointer to the updated file page table is inserted into the table entry of the file page table, thereby completing the mapping of the physical address of the file and the virtual address, which is beneficial for reconstructing the physical address of the file within a constant time independent of the file size. Mapping to virtual addresses.
  • the file system in the file storage memory area is protected by the system virtual address and the MMU, which greatly reduces the possibility of being mistakenly written, and can not only be good. Protects the file and does not require an additional write protection mechanism to facilitate the system.
  • the size of the file is only affected by the size of the system virtual address space and the number of files simultaneously opened by the operating system, which are not limitations of the file system itself, and thus the file size. It is not subject to the design of the file system itself.
  • FIG. 3 is a schematic flowchart diagram of another method for accessing a file according to another embodiment of the present invention.
  • Another method for accessing a file provided by another embodiment of the present invention may include The following content:
  • the operating system receives a file open request carrying a file identifier from a user process (hereinafter referred to as user process A).
  • the file open request may carry a file storage path (that is, a storage path of a file that is requested to be opened), where the file identifier may be included in the file storage path, and of course, in the file open request. It is also possible to carry a file identification and may not carry a file storage path.
  • the file opening request may further carry a file type flag bit, where the file type flag bit may indicate a file type of the file represented by the file identifier (the file type may be a directory file or a data file).
  • the operating system creates a file represented by the file identifier (the file is hereinafter referred to as a file)
  • file descriptor is assigned to file F1.
  • the file object of the file F1 can be found based on the file descriptor of the file F1.
  • the operating system determines whether the file F1 is stored in the file storage memory area.
  • step 304 If yes, go to step 304.
  • the operating system obtains the first index node of the file F1, wherein the file is stored in the file storage memory area, and the first index node of the file F1 is also stored in the file storage memory area.
  • FIG. 2-b exemplifies a memory diagram of a computing node.
  • the memory of the computing node may include a user process working memory area S1, a kernel process working memory area S2, and a file storage memory area S3. Wait.
  • the user process working memory area S1 may refer to a physical memory area for storing contents such as data structures and variables included in the working environment when the user process runs.
  • the foregoing data structure and variables stored in the working memory area of the user process may include, for example, at least one of the following: a heap, a stack, a memory mapped area, a variable of a program corresponding to the user process, a character, an array, and the like when the user process runs. data.
  • the kernel process working memory area S2 may refer to a physical memory area for storing contents such as data structures and variables included in the working environment of the kernel process.
  • the above data structures and variables stored in the working memory area may include, for example, at least one of the following: a heap, a stack, a memory mapped area, a variable of a program corresponding to the kernel process, characters, and an array, etc. of the kernel process.
  • the file storage memory area S3 may include a non-volatile memory area and/or a volatile memory area (ie, the storage medium of the file storage memory area S3 includes a non-volatile storage medium and/or Volatile storage medium).
  • the process working memory area (such as the kernel process working memory area S2 and the user process working memory area S1) may include a non-volatile memory area and/or a volatile memory area (ie, a storage medium of the working memory area of the process includes non-volatile Storage medium and/or volatile storage medium).
  • the process working memory area (such as the kernel process working memory area S2, the user process working memory area S 1 ) and the file storage memory area do not overlap each other.
  • the user process work memory area S1 and the kernel process work memory area S2 may be located in the DRAM, and the file storage memory area S3 may be located in the NVM.
  • the file storage memory area S3 may refer to a physical memory area for storing a file system, and the file storage memory area may store various information of the file system itself, for example, an index node and a file in the file storage memory area where the file system can be stored. , can further store the super block (if any) of the file system and so on.
  • the file storage memory area S3 may include a super block, an inode area for storing a file index node, and a file data area for storing files.
  • the super block can store a pointer for pointing to the index node.
  • the super block can store a pointer for pointing to all index nodes, and can also store a pointer for an index node pointing to the root file.
  • a pointer for pointing to the first file page table may be recorded in the first index node of the file F1 (the pointer for pointing to the first file page table may include the start of the first file page table) a physical address), wherein the first file page table is used to point to a memory area in the file storage memory area S3 where the file F1 is stored, and the first physical address space is a physical area of the memory area in which the file is stored in the file storage memory area. Address space.
  • the first file page table described above is a single-level or multi-level file page table.
  • a memory page for storing a single file is organized by a file page table whose data structure is similar or equivalent to a memory page table, and the file page table may be a one-level or multi-level file page table.
  • Each entry of each level file page table in the non-lowest level file page table records the starting physical address of a file page table of the next level.
  • each entry of the lowest level file page table stores the start of a memory page of the file. Physical address.
  • Figure 2-e shows that the first file page table is a three-level file page table, which is a PUD, PMD, and PTE level, wherein each entry in the PUD records a PMD.
  • the starting physical address, and each entry of each PMD records the starting physical address of a PTE, and each entry of the PTE records the starting physics of a memory page (where the memory page stores the file content of the file F1) address. Understandably, not every file needs to use a three-level file page table. Even if a three-level page table is used, it does not necessarily have a fixed format. For example, not every file needs to use 1024 PTEs.
  • the size of the file changes dynamically to adjust the file page table organization. For example, a pointer to a first level file page table PUD of a three-level file page table (such as a starting physical address of a PUD;) may be recorded in the first index node.
  • Each file corresponds to an inode.
  • the first index node includes a pointer (Pointer) for pointing to the file page table, and the pointer specifically stores the highest level file page table (PUD) of the file F1. The starting physical address of the physical memory page.
  • Pointer pointer
  • PID file page table
  • the first index node of the file F1 may further include the metadata of the file F1, and the metadata of the file F1 includes the attribute information of the file F1 (such as file size, file type, file modification time, file creation time, etc.)
  • the file page table of each file is stored in the file data area of the file storage memory area. Due to the byte-addressable nature of the file storage memory area and the linked list-based organization of the file page table, the file page table does not need to be placed in a fixed area. Just store it as a normal file in the file data area.
  • the operating system obtains, according to the first index node, a first physical address space of a memory area in which the file F1 is stored in the file storage memory area.
  • the first index node includes a pointer for pointing to the first file page table of the file F1
  • a pointer for pointing to the first file page table of the file F1 can be obtained based on the first index node, and is obtained for pointing to the file.
  • the pointer of the first file page table of F1 can obtain the first file page table of the file F1, and further can obtain the first memory area of the file F1 stored in the file storage memory area based on the first file page table of the file F1. Physical address space.
  • the operating system allocates a first virtual address space to the file.
  • a first virtual address of a preset size may be allocated to the file.
  • Space for example, the size of the first virtual address space may be less than or equal to the maximum virtual address space of the system divided by the maximum number of files that the system supports simultaneously opening.
  • the first virtual address space corresponding to the file type may be allocated to the file.
  • the virtual address space corresponding to the directory file and the virtual address space corresponding to the data file may not be equal.
  • the size of the virtual address space corresponding to the directory file may be smaller than the size of the virtual address space corresponding to the data file, for example, the virtual address corresponding to the directory file.
  • the size of the space is 1MB, 2MB, 10MB or 30MB.
  • the virtual address space corresponding to the data file is 100MB, 500MB, 1GB, 10GB, 100GB or 2TB.
  • the operating system records the first virtual address mapping relationship by using the memory page table, and the process proceeds to step 311.
  • the first virtual real address mapping relationship is a mapping relationship between the first virtual address space and the first physical address space, wherein the memory page table includes a kernel memory page table and/or a user process memory page table.
  • the recording the first virtual real address mapping relationship by using the memory page table may include: adding an entry for recording the first virtual real address mapping relationship in the memory page table (may be one or a plurality of entries), wherein the table entry includes a pointer for pointing to the first file page table (the pointer for pointing to the first file page table may include a starting physical address of the first file page table). For example, the total number of stages of the memory page table is Y, and the total number of levels of the first file page table is X. If the table item includes the first file page table, the table entry may be the foregoing memory page table.
  • the entry in the Y-X+1-level memory page table in the table if the table entry includes a pointer for pointing to the first file page table, the table entry may be the YX level in the foregoing memory page table An entry in the memory page table, wherein the X is a positive integer, and the Y is a positive integer greater than the X.
  • the entry (possibly one or more entries) added to the memory page table for recording the first virtual address mapping relationship may also be any level in the memory page table.
  • the first virtual address space, the start address of the first virtual address space, and the end address of the first virtual address space may be further recorded in the first index node. At least one, and/or, the first virtual address space, the start address of the first virtual address space, and the first virtual may be recorded in a file object corresponding to the file At least one of the end addresses of the address space.
  • the first virtual address space is a continuous or non-contiguous virtual address space. In some embodiments of the present invention, the first virtual address space is in a kernel virtual address space or the first virtual address space is in a user process virtual address space.
  • the operating system creates a file F1 in the file storage memory area, and allocates a second index node to the created file F1, wherein the second index node of the file F1 is also stored in the file storage memory area.
  • a pointer for pointing to the second file page table may be recorded in the second index node of the file F1, wherein the second file page table is used to point to the file F1 stored in the file storage memory area.
  • the second physical address space of the memory area, the second file page table is a single-level or multi-level file page table.
  • a memory page for storing a single file is organized by a file page table having a data structure similar to or equivalent to a memory page table, and the second file page table may be a one-level or multi-level file page table.
  • Each entry in the non-minimum level file page table records the starting physical address of a file page table at the next level.
  • Each entry of the lowest level file page table stores the starting physical address of a memory page of the file.
  • Each file corresponds to an inode.
  • the second index node includes a pointer (Pointer) for pointing to the file page table, and the pointer specifically stores the physical memory page of the highest level file page table of the file F1. The starting physical address.
  • Pointer pointer
  • the second index node of the file F1 may further include the metadata of the file F1, and the metadata of the file F1 includes the attribute information of the file F1 (such as file size, file type, file modification time, file creation time, etc.)
  • the file page table of each file is stored in the file data area of the file storage memory area. Due to the byte-addressable nature of the file storage memory area and the linked list-based organization of the file page table, the second file page table does not need to be placed in a fixed area, as long as it is stored as a general file in the file data area. can.
  • the operating system allocates a second virtual address space for the file F1.
  • a second virtual address space of a preset size may be allocated to the file (for example, the size of the second virtual address space may be less than or equal to the maximum virtual address space of the system divided by The system supports the maximum number of files opened at the same time).
  • the second virtual address space corresponding to the file type may be allocated to the file.
  • the virtual address space corresponding to the directory file and the virtual address space corresponding to the data file may not be equal.
  • the size of the virtual address space corresponding to the directory file may be smaller than the size of the virtual address space corresponding to the data file, for example, the virtual address corresponding to the directory file.
  • the size of the space is 1MB, 2MB, 10MB or 30MB.
  • the virtual address space corresponding to the data file is 100MB, 500MB, 1GB, 10GB, 100GB or 2TB.
  • the operating system records the second virtual real address mapping relationship by using the memory page table, and the process proceeds to step 311.
  • the second virtual real address mapping relationship is a mapping relationship between the second virtual address space and the second physical address space, wherein the memory page table includes a kernel memory page table and/or a user process memory page table.
  • the recording the second virtual real address mapping relationship by using the memory page table may include: adding an entry for recording the second virtual real address mapping relationship in the memory page table (may be one or a plurality of entries), wherein the entry includes a pointer for pointing to the second file page table.
  • the total number of levels of the memory page table is Y
  • the total number of levels of the second file page table is X. If the table item includes the second file page table, the table entry may be the foregoing memory page table.
  • the entry in the Y-X+1-level memory page table in the table if the table entry includes a pointer for pointing to the second file page table, the entry may be the YX level in the memory page table An entry in the memory page table, wherein the X is a positive integer, and the Y is a positive integer greater than the X.
  • the entry (possibly one or more entries) added to the memory page table for recording the second virtual real address mapping relationship may also be any level in the memory page table.
  • the second virtual address space, the start address of the second virtual address space, and the end address of the second virtual address space may be further recorded in the second index node. At least one, and/or, at least one of the second virtual address space, the start address of the second virtual address space, and the end address of the second virtual address space may be recorded among the file objects corresponding to the file One.
  • the second virtual address space is continuous or non-contiguous Virtual address space. In some embodiments of the present invention, the second virtual address space is in a kernel virtual address space or the second virtual address space is in a user process virtual address space.
  • the operating system feeds back the file description symbol of the file F1 to the user process A.
  • User process A can initiate a read and write operation on file F1 based on the file description symbol of file F1. It can be seen that, in the foregoing technical solution of the embodiment, after receiving the file open request carrying the file identifier, determining whether the file represented by the file identifier is stored in the file storage memory area; if the file storage memory area is And storing the foregoing file, obtaining a first index node of the file, and obtaining, according to the first index node, a first physical address space of a memory area in which the file is stored in the file storage memory area; a virtual address space; the first virtual address mapping relationship is recorded by the memory page table; wherein the first virtual real address mapping relationship is a mapping relationship between the first virtual address space and the first physical address space, wherein the memory is
  • the page table includes a kernel memory page table and/or a user process memory page table.
  • the kernel virtual page table and/or the user process memory page table are used to record the first virtual real address mapping relationship, it can be considered that the first physical address space of the memory area storing the file in the file storage memory area is to some extent.
  • the physical address space corresponding to a certain memory area in the working memory area of the process, which is convenient for the kernel or the user process to access the file system of the resident kernel by the access performance of the normal kernel data or the user process to approximate the normal memory data.
  • Files which are beneficial to greatly improve file access performance. It can be seen that the above file access scheme is more suitable for high-performance file access in the file system resident memory scenario.
  • the virtual address space is allocated for the file when the file is requested to be opened, this is advantageous for reducing the inefficient occupation and address conflict of the system virtual address space, and is advantageous for improving the utilization efficiency of the system virtual address space.
  • the MMU transparently completes the conversion between the virtual address and the physical address of the file, which facilitates faster file access and even zero overhead.
  • the file page table is used to point to the file.
  • the memory page storing the contents of the file in the memory area because the data structure of the file page table and the memory page table are similar or identical, is beneficial to realize zero conversion of the page table data structure, and may also be changed when the memory page of the file content is changed.
  • the operation of rebuilding the physical address space of the file and the virtual address space is not performed on the file page table, and the pointer for pointing to the updated file page table is inserted into the table of the file page table by updating the file page table, thereby completing the reconstruction.
  • the mapping between the physical address of the file and the virtual address This method is useful for reconstructing the mapping between the physical address of the file and the virtual address within a constant time independent of the file size.
  • the file system in the file storage memory area is protected by the system virtual address and the MMU, which greatly reduces the possibility of being mistakenly written, and can not only be good. Protects the file and does not require an additional write protection mechanism to facilitate the system.
  • the size of the file is only affected by the size of the system virtual address space and the number of files simultaneously opened by the operating system, which are not limitations of the file system itself, and thus the file size. It is not subject to the design of the file system itself.
  • FIG. 4 is a schematic flowchart of another method for accessing a file according to another embodiment of the present invention.
  • the method for accessing the file shown in FIG. 4 can be implemented after the technical solution shown in FIG. 2-a or FIG. 3 is executed.
  • Another method for accessing a file provided by another embodiment of the present invention may include the following contents:
  • the operating system receives a file read request sent by the user process A for requesting to read the file content of the file F1.
  • the file read request carries a data amount of the first file content in the file F1 read into the memory address space and requested to be read.
  • the above file read request may also carry a file descriptor of the above file.
  • the read-in memory address space is an address space of a first memory area in a working memory area of the user process.
  • the operating system finds the first index node or file of the file F1 based on the file descriptor. Fl file object.
  • the start address of the first virtual address space is obtained based on the file object of the first index node or file F1.
  • the operating system obtains a starting read virtual address for reading the content of the first file according to the first file content offset and the starting address of the first virtual address space.
  • the operating system obtains a starting physical address for reading the content of the first file from the file storage memory area based on the foregoing initial read virtual address and the first virtual real address mapping relationship.
  • the operating system obtains a read physical address space for reading the content of the first file from the file storage memory area based on the initial read physical address and the data amount of the first file content.
  • the operating system reads the first file content of the file from the file storage memory area based on the read physical address space.
  • the first file content is written into the first memory area based on the read into the memory address space.
  • the file storage memory area is to some extent.
  • the first physical address space of the memory area in which the file is stored is packaged into a physical address space corresponding to a memory area in the working memory area of the process, which is beneficial for the kernel or user process when the file content is read.
  • FIG. 5 is a schematic flowchart of another method for accessing a file according to another embodiment of the present invention.
  • the method for accessing the file shown in FIG. 5 can be implemented after the technical solution shown in FIG. 2-a or FIG. 3 is executed.
  • Another method for accessing a file provided by another embodiment of the present invention may include the following contents:
  • the operating system receives a file read request sent by the user process A for requesting to read the first file content of the file F1.
  • the file read request carries the amount of data of the first file content in the file F1 read into the memory address space and requested to be read.
  • the above file read request may also carry a file descriptor of the above file.
  • the read-in memory address space is an address space of a first memory area in a working memory area of the user process.
  • the operating system searches for the first index node of the file F1 or the file object of the file F1 based on the file descriptor; and obtains a starting address of the first virtual address space based on the first index node or the file object of the file F1.
  • the operating system obtains a starting read virtual address for reading the content of the first file according to the first file content offset and the starting address of the first virtual address space.
  • the operating system obtains a read virtual address space for reading the content of the first file based on the data volume of the initial read virtual address and the first file content.
  • the operating system may obtain a read physical address space for reading the content of the first file from the file storage memory area based on the read virtual address space and the first virtual address mapping relationship.
  • the operating system reads the first file content of the file from the file storage memory area based on the read physical address space.
  • the first file content is written into the first memory area based on the read into the memory address space.
  • the file storage memory area is to some extent.
  • the first physical address space of the memory area in which the file is stored is packaged into a physical address space corresponding to a memory area in the working memory area of the process, which is beneficial for the kernel or user process when the file content is read.
  • FIG. 6 is a schematic flowchart diagram of another method for accessing a file according to another embodiment of the present invention.
  • the method for accessing the file shown in FIG. 6 can be implemented after the technical solution shown in FIG. 2-a or FIG. 3 is executed.
  • Another method for accessing a file provided by another embodiment of the present invention may include the following content: A file write request for the piece of content, wherein the file write request carries a read memory address space and a data amount of the second file content requested to be written into the file.
  • the above file write request may also carry a file descriptor of the above file.
  • the read memory address space is an address space of a second memory area in a working memory area of the user process.
  • the operating system may find the first index node of the file F1 or the file object of the file F1 based on the file descriptor.
  • the operating system obtains the starting address of the first virtual address space based on the file object of the first index node or file F1.
  • the operating system may obtain, according to the second file content offset and the start address of the first virtual address space, a starting write virtual address for writing the content of the second file to the file F1.
  • the operating system may obtain, according to the foregoing initial write virtual address and the first virtual real address mapping relationship, a starting write physical address for writing the content of the second file into the file F1 of the file storage memory area.
  • the operating system may obtain a write physical address space for writing the content of the second file into the file F1 of the file storage memory area based on the initial write physical address and the data amount of the second file content.
  • the operating system reads the second file content from the second memory area based on the read memory address space, and the operating system writes the read second file content based on the written physical address space. Go to the third memory area above.
  • the file storage memory area is to some extent.
  • the first physical address space of the memory area in which the file is stored is packaged into a physical address space corresponding to a memory area in the working memory area of the process, which is beneficial for the kernel or user process when the file content is written.
  • FIG. 7 is a schematic flowchart diagram of another method for accessing a file according to another embodiment of the present invention.
  • the method for accessing the file shown in FIG. 7 can be implemented after the technical solution shown in FIG. 2-a or FIG. 3 is executed.
  • Another method for accessing a file provided by another embodiment of the present invention may include the following: a file write request for a piece of content, wherein the file write request carries a read memory address space and requests to write to the file. The amount of data in the second file content.
  • the above file write request may also carry a file descriptor of the above file.
  • the read memory address space is an address space of a second memory area in a working memory area of the user process.
  • the operating system may find the first index node of the file F1 or the file object of the file F1 based on the file descriptor.
  • the start address of the first virtual address space is obtained based on the file object of the first index node or file F1.
  • the operating system may obtain, according to the second file content offset and the start address of the first virtual address space, a starting write virtual address for writing the content of the second file to the file F1.
  • the operating system may obtain a write virtual address space in which the content of the second file is written into the file F1 based on the data amount of the initial write virtual address and the content of the second file.
  • the operating system may obtain a write physical address space for writing the content of the second file into the file F1 of the file storage memory area based on the mapping relationship between the write virtual address space and the first virtual real address.
  • the operating system reads the second file content from the second memory area based on the read memory address space, and the operating system writes the read second file content based on the written physical address space. Go to the third memory area above.
  • the file storage memory area is to some extent.
  • the first physical address space of the memory area in which the file is stored is packaged into a physical address space corresponding to a memory area in the working memory area of the process, which is beneficial for the kernel or user process when the file content is written.
  • Access the file in a way similar to the working memory area of the access process The file in the memory area is stored, which is beneficial to the kernel or the user process to access the file system of the resident kernel file with the access performance of the ordinary memory data, which is beneficial to greatly improve the file access performance.
  • FIG. 8 is a schematic flowchart diagram of another method for accessing a file according to another embodiment of the present invention.
  • the method for accessing the file shown in FIG. 8 can be implemented after the technical solution shown in any one of FIG. 2-a or FIG. 3 to FIG. 7 is executed.
  • Another method for accessing a file provided by another embodiment of the present invention may include the following content:
  • the operating system receives a request sent by the user process A to close the file close request of the file F1, where the file close request may further carry the file descriptor of the file.
  • the operating system releases the first virtual address space or the second virtual address space allocated for the file.
  • the operating system releases the first virtual real address mapping relationship or the second virtual real address mapping relationship recorded in the foregoing memory page table.
  • the operating system releases the file object corresponding to the file F1 and the like.
  • the kernel memory page table and/or the user process memory page table are used to record the first virtual address mapping relationship, it can be considered that the first physical address space of the memory area in which the file is stored in the file storage memory area is to some extent. , is packaged into a physical address space corresponding to a memory area in the working memory area of the process, which is beneficial for the kernel or the user to access the file system of the resident kernel by implementing the access performance of the kernel or the user process to approximate normal memory data. Files, which are beneficial to greatly improve file access performance. It can be seen that the above file access scheme is more suitable for high-performance file access in the file system resident memory scenario.
  • the virtual address space is allocated for the file when the file is requested to be opened, and the virtual address space is allocated for the file when the file is closed, this is advantageous for reducing the possibility of invalid occupation and address conflict of the system virtual address space. It is beneficial to improve the utilization efficiency of the system virtual address space.
  • any method for accessing a file described in each of the foregoing embodiments may be applied to a computing node, where the computing node may include a memory, and the memory includes: a file storage memory area and a process worker As a memory area, wherein the working memory area of the above process stores a memory page table, and an operating system runs in the working memory area of the above process.
  • the working memory area of the process may include a kernel process working memory area and a user process working memory area, wherein the kernel memory page table may be stored in a kernel process working memory area, and the user process memory page table may be stored in the user process working.
  • the memory area such as the kernel process working memory area, runs an operating system.
  • an embodiment of the present invention provides an apparatus 900 for accessing a file, which may include:
  • the receiving unit 901 is configured to receive a file open request that carries a file identifier.
  • the file open request may carry a file storage path (that is, a storage path of a file that is requested to be opened), where the file identifier may be included in the file storage path, and of course, in the file open request. It is also possible to carry a file identification and may not carry a file storage path.
  • the file opening request may further carry a file type flag bit, where the file type flag bit may indicate a file type of the file represented by the file identifier (the file type may be a directory file or a data file).
  • the obtaining unit 902 is configured to obtain a first index node of the file represented by the file identifier, where the file is stored in a file storage memory area, and obtain the memory that stores the file in the file storage memory area based on the first index node.
  • the first physical address space of the zone is configured to obtain a first index node of the file represented by the file identifier, where the file is stored in a file storage memory area, and obtain the memory that stores the file in the file storage memory area based on the first index node.
  • the allocating unit 903 is configured to allocate a first virtual address space for the file.
  • the file may be allocated a first virtual address space of a preset size (for example, the size of the first virtual address space may be less than or equal to the maximum virtual address space of the system divided by the maximum number of files simultaneously supported by the system. Number).
  • the first virtual address space corresponding to the file type may be allocated to the file.
  • the virtual address space corresponding to the directory file and the virtual address space corresponding to the data file may not be equal.
  • the size of the virtual address space corresponding to the directory file may be smaller than the size of the virtual address space corresponding to the data file, for example, the virtual address corresponding to the directory file.
  • the size of the space is 1MB, 2MB, 10MB or 30MB.
  • the virtual address space corresponding to the data file is 100MB, 500MB, 1GB, 10GB, 100GB or 2TB. and many more.
  • the mapping unit 904 is configured to record the first virtual address mapping relationship by using the memory page table.
  • the first virtual real address mapping relationship includes a mapping relationship between the first virtual address space and the first physical address space, wherein the memory page table includes a kernel memory page table and/or a user process memory page table.
  • the index node of the file may include information that can obtain a physical address space of a memory area in the file storage memory area where the file is stored. For example, a first file page table or a pointer for pointing to the first file page table may be recorded in the first index node of the file, where the first file page table is used to point to the memory in the file storage memory area where the file is stored.
  • the first file page table is a single-level or multi-level file page table, wherein the first physical address space is a physical address space of a memory area in which the file is stored in the file storage memory area.
  • the first index node may directly store the first physical address space of the memory area in which the file is stored in the file storage memory area or the start address of the first physical address space.
  • the first index node of the file may further include information such as metadata of the file.
  • the acquiring unit 902 may be specifically configured to use, according to the foregoing, the foregoing first index node to obtain the first physical address space of the memory area in which the file is stored in the file storage memory area.
  • a first file page table recorded in the first index node or used to point to the first physical address space wherein the first file page table is used to point to a memory area in the file storage memory area where the file is stored
  • the foregoing A physical address space is a physical address space of a memory area in which the file is stored in the file storage memory area
  • the first file page table is a single-level or multi-level file page table.
  • the memory may include: a process working memory area (where the process working memory area may include a user process working memory area and a kernel process working memory area) and a file storage memory area.
  • the process working memory area refers to a physical memory area for storing data structures and variables included in the working environment when the process is running.
  • the data structure and the variable may include at least one of the following information: a heap, a stack, a memory mapped area, a variable of a program corresponding to the process, a character, an array, and the like when the process runs.
  • the user process working memory area may refer to a physical memory area for storing contents such as data structures and variables included in the working environment when the user process runs.
  • the foregoing data structure and variables stored in the working memory area of the user process may include, for example, at least one of the following: a heap, a stack, a memory mapped area, a variable of a program corresponding to the user process, a character, an array, and the like when the user process runs. data.
  • the kernel process working memory area may refer to a physical memory area for storing data structures and variables included in the working environment of the kernel process runtime.
  • the foregoing data structure and variables stored in the working memory area of the kernel process may include, for example, at least one of the following: a heap, a stack, a memory mapped area, a variable of a program corresponding to the kernel process, characters, and an array of the kernel process. data.
  • the file storage memory area may be a physical memory area for storing a file system, and the file storage memory area may store various information of the file system itself, for example, an index node and a file in the file storage memory area where the file system may be stored. It can further store information such as superblocks (if any) of the file system.
  • the file storage memory area may include a non-volatile memory area and/or a volatile memory area (ie, the storage medium of the file storage memory area includes a non-volatile storage medium and/or Loss storage medium).
  • the process working memory area (such as the kernel process working memory area, the user process working memory area) may include a non-volatile memory area and/or a volatile memory area (ie, a storage medium of the working memory area of the process includes non-volatile Storage medium and/or volatile storage medium).
  • the process working memory area (such as the kernel process working memory area, the user process working memory area) and the file storage memory area do not overlap each other.
  • the mapping unit 904 may be specifically configured to: add, in the memory page table, an entry for recording the first virtual address mapping relationship, where the foregoing table includes the first file page table or used in the foregoing Pointer to the first file page table above.
  • the total number of levels of the memory page table is Y
  • the total number of levels of the first file page table is X. If the entry includes the first file page table, the entry is The entry in the Y-X+1-level memory page table in the foregoing memory page table, if the entry includes a pointer for pointing to the first file page table, the entry is the first in the memory page table. The entry in the YX-level memory page table, The above X is a positive integer, and the above Y is a positive integer greater than the above X.
  • the apparatus 900 for accessing a file further includes: a recording unit 905, configured to record the first virtual address space and/or the first virtual medium in the first index node The start address of the address space, and/or, the first virtual address space and/or the start address of the first virtual address space are recorded in a file object corresponding to the file.
  • the first virtual address space is a continuous or non-contiguous virtual address space.
  • the first virtual address space is in a kernel virtual address space or a user process virtual address space.
  • the obtaining unit 902 may be specifically configured to: when it is determined that the file represented by the file identifier is stored in the file storage memory area, obtain a first index node of the file represented by the file identifier.
  • the receiving unit 901 is further configured to: receive a file read request for requesting to read a file content of the file, where the file read request carries a read-in memory address space and request to read And the amount of data of the first file content in the file is obtained, where the read-in memory address space is an address space of a first memory area in a working memory area of the user process;
  • the apparatus 900 for accessing the file further includes:
  • the second mapping unit 906 is configured to read the foregoing information from the file storage memory area based on the data amount of the first file content, the first virtual address space, and the first virtual real address mapping relationship recorded by the memory page table. Reading the physical address space of a file content;
  • the first read/write unit 907 is configured to read the first file content of the file from the file storage memory area based on the read physical address space; and write the first file content into the first memory area.
  • the first virtual real address mapping relationship based on the data amount of the first file content, the first virtual address space, and the memory page table record is obtained from the file storage memory area.
  • the second mapping unit 906 may be specifically configured to: based on the data amount of the first file content, the first file content offset, the first virtual address space, and The above first virtual real address mapping of the above memory page table record And obtaining a read physical address space for reading the content of the first file from the file storage memory area, wherein the first file content offset is obtained from the file read request, or the first file content The offset is obtained from the file object corresponding to the above file.
  • the default file content offset may be used as a first file content offset
  • a start address of the first virtual address space to obtain a starting read virtual address for reading the content of the first file; and using the initial read virtual address and the first virtual real address mapping Relationship, obtaining a starting physical address for reading the content of the first file from the file storage memory area; and reading the physical address of the first physical file and the content of the first file, and reading from the file storage memory area
  • the physical address space of the first file content is read.
  • the default file content offset may be As a first file content offset
  • a start read virtual address for reading the first file content is obtained; and based on the initial read virtual address and the first file content
  • the amount of data is obtained by reading the read virtual address space of the first file content; using the read virtual address space and the first virtual real address mapping relationship to obtain reading of the first file content from the file storage memory area Physical address space.
  • the receiving unit 901 is further configured to: receive a file write request for writing a file content to the file, where the file write request carries a read memory address space and request to write The data amount of the second file content in the file, wherein the read memory address space is an address space of the second memory area in the working memory area of the process;
  • the apparatus 900 for accessing the file further includes:
  • the third mapping unit 908 is configured to write the foregoing to the file storage memory area based on the data amount of the second file content, the first virtual address space, and the first virtual real address mapping relationship recorded by the memory page table. Writing a physical address space of the second file content, where the write physical address space is a physical address space of a third memory area in the file storage memory area;
  • the second read/write unit 909 is configured to write the second file content cached in the second memory area into the third memory area.
  • the first virtual address mapping relationship based on the data amount of the second file content, the first virtual address space, and the memory page table record is obtained by writing to the file storage memory area.
  • the third mapping unit 908 may be specifically configured to: based on the data amount of the second file content, the second file content offset, and the first virtual address space, in the aspect of writing the physical address space of the second file content.
  • the default file content offset may be used as a second file content offset
  • a start address of the first virtual address space to obtain a start write virtual address for writing the content of the second file to the file; using the above-mentioned initial write virtual address and the first
  • the virtual real address mapping relationship obtains a starting physical address for writing the content of the second file to the file from the file storage memory area; and based on the data amount of the initial writing physical address and the second file content, Writing a physical address space of the content of the second file to the above file of the file storage memory area.
  • the default file content offset may be As the second file content offset
  • the virtual address is written to the beginning of the second file content in the file; the virtual address and the second file are written based on the start
  • the amount of data of the content is obtained by writing the write virtual address space to the content of the second file in the file of the file storage memory area; and using the write virtual address space and the first virtual physical write address space.
  • the storage capacity of the third memory area may be greater than or equal to the data volume of the second file content.
  • the memory area corresponding to the third memory area and the first physical address space has an intersection or no intersection. It can be understood that, in a normal case, if the memory area corresponding to the third memory area and the first physical address space have an intersection, it may indicate that the original file is replaced by the content of the second file.
  • Some or all of the contents of the file (if the intersection of the third memory area and the memory area corresponding to the first physical address space is smaller than the third memory area, indicating that a new memory area is allocated for the second file content, that is, storing the above file The memory area has changed, and the memory area for storing the above files has been expanded.) If the memory area corresponding to the third memory area and the first physical address space does not intersect, it may indicate that the second file content is added in the file, and the third memory area allocates a new memory area for the second file content, that is, The memory area in which the above file is stored has changed, and the memory area in which the above file is stored is expanded.
  • the unit 904 may update the first file page table such that the updated first file page table points to a memory area in the file storage memory area where the file is currently stored.
  • the mapping unit 904 may update the first virtual real address mapping relationship recorded in the memory page table to a third virtual real address mapping relationship, where the third virtual real address mapping relationship includes the first virtual address space and the foregoing A mapping relationship between the three physical address spaces, where the third physical address space is a physical address space of a memory area in which the file is currently stored in the file storage memory area.
  • the memory page table records a pointer to the first file page table (for example, the starting physical address of the first file page table recorded in the memory page table)
  • the start of the first file page table after the update If the physical address has not changed, it is also possible to not modify the pointer in the memory page table that points to the first file page table.
  • the first file page table is updated without modifying the memory page table, and the virtual address mapping relationship can be reconstructed, which greatly reduces the mapping operation.
  • the receiving unit 901 is further configured to receive a file close request for requesting to close the file.
  • the apparatus 900 for accessing a file may further include: a releasing unit 910, configured to release a first virtual address space allocated for the file; and release the first virtual address mapping relationship recorded in the memory page table.
  • the apparatus 900 for accessing a file may further include: a file that is created, the file is created in the file storage memory area, and the second index node is allocated to the file, wherein the second index node Recording a second file page table or a pointer for pointing to the second file page table, wherein the second file page table is used to point to the file storage memory area The memory area where the above files are stored.
  • the allocating unit 903 is further configured to allocate a second virtual address space for the file.
  • the mapping unit 904 is further configured to record the second virtual real address mapping relationship by using the memory page table.
  • the second virtual address mapping relationship includes a mapping relationship between the second virtual address space and the second physical address space, where the second physical address space is a memory in which the file is stored in the file storage memory area.
  • the physical address space of the area, the above memory page table includes a kernel memory page table and/or a user process memory page table.
  • the number of levels of the second file page table has a correspondence with the file type of the file.
  • the file storage memory area includes a non-volatile memory area and/or a volatile memory area.
  • the device 900 for accessing the file may: after receiving the file open request carrying the file identifier; obtaining the first index node of the file represented by the file identifier, and based on the first The index node obtains a first physical address space of the memory area in which the file is stored in the file storage memory area; allocates a first virtual address space for the file; and records a first virtual address mapping relationship by using a memory page table; wherein, the first The virtual real address mapping relationship is a mapping relationship between the first virtual address space and the first physical address space, wherein the memory page table includes a kernel memory page table and/or a user process memory page table.
  • the kernel virtual page table and/or the user process memory page table are used to record the first virtual real address mapping relationship, it can be considered that the first physical address space of the memory area storing the file in the file storage memory area is to some extent. , the physical address space corresponding to a certain memory area in the working memory area of the process, which is beneficial for the kernel or the user process to implement the kernel or the user process to access the file system of the resident kernel file with the access performance of the ordinary memory data. This is beneficial for greatly improving file access performance. It can be seen that the above file access scheme is more suitable for high-performance file access in the file system resident memory scenario. And because it is in please When the file is opened, the virtual address space is allocated to the file, which is beneficial to reduce the invalid occupation and address conflict of the system virtual address space, and is beneficial to improving the utilization efficiency of the system virtual address space.
  • the MMU transparently completes the conversion between the virtual address and the physical address of the file, which facilitates faster file access and even zero overhead.
  • a file page table with a data structure similar to or the same as the memory page table is used to point to a memory page in which the file content is stored in the file storage memory area
  • the data structure of the file page table and the memory page table are similar or identical, it is advantageous to implement Zero conversion of the page table data structure, and when the memory page storing the file content changes, it may not be necessary to perform the operation of reconstructing the mapping relationship between the file physical address space and the virtual address space for the file page table, and by updating the file page table,
  • the pointer to the updated file page table is inserted into the table entry of the file page table, thereby completing the mapping of the physical address of the file and the virtual address, which is beneficial for reconstructing the physical address of the file within a constant time independent of the file size. Mapping to virtual addresses.
  • the file system in the file storage memory area is protected by the system virtual address and the MMU, which greatly reduces the possibility of being mistakenly written, and can not only be good. Protects the file and does not require an additional write protection mechanism to facilitate the system.
  • the size of the file is only affected by the size of the system virtual address space and the number of files simultaneously opened by the operating system, which are not limitations of the file system itself, and thus the file size. It is not subject to the design of the file system itself.
  • FIG. 10 is a schematic diagram of a computing node 1000 according to an embodiment of the present invention.
  • the computing node 1000 may include at least one bus 1001, at least one processor 1002 connected to the bus 1001, and At least one memory 1003 coupled to bus 1001.
  • the memory 1003 may include a memory, and may also include external storage.
  • the foregoing memory may include: a file storage memory area and a process working memory area, wherein the working memory area of the above process stores a memory page table, and an operating system runs in the working memory area of the process.
  • the working memory area of the process may include a kernel process working memory area and a user process working memory area, wherein the kernel memory page table may be stored in a kernel process working memory area, and the user process memory page table may be stored in the user process working memory area.
  • the processor 1002 calls, by using the bus 1001, the code stored in the memory 1003 to receive a file open request that carries the file identifier; and obtains a first index node of the file represented by the file identifier, where the file is stored in the file storage.
  • the first virtual address space is allocated by using the memory page table to record the first virtual address mapping relationship; wherein the first virtual real address mapping relationship includes the first virtual address space and The mapping relationship between the first physical address spaces, wherein the memory page table comprises a kernel memory page table and/or a user process memory page table.
  • the file open request may carry a file storage path (that is, a storage path of a file that is requested to be opened), where the file identifier may be included in the file storage path, and of course, in the file open request. It is also possible to carry a file identification and may not carry a file storage path.
  • the file opening request may further carry a file type flag bit, where the file type flag bit may indicate a file type of the file represented by the file identifier (the file type may be a directory file or a data file).
  • the processor 1002 calls the memory 1003 through the bus 1001 in terms of obtaining the first physical address space of the memory area of the file stored in the file storage memory area based on the first index node.
  • the stored code is specifically used to obtain a memory area in which the file is stored in the file storage memory area based on the first file page table recorded in the first index node or the pointer used to point to the first file page table. a first physical address space, wherein the first text is
  • the process working memory area refers to a physical memory area for storing data structures and variables included in the working environment when the process is running.
  • the data structure and the variable may include at least one of the following information: a heap, a stack, a memory mapped area, a variable of a program corresponding to the process, a character, an array, and the like when the process runs.
  • the user process working memory area may refer to a physical memory area for storing contents such as data structures and variables included in the working environment when the user process runs.
  • the foregoing data structure and variables stored in the working memory area of the user process may include, for example, at least one of the following: a heap, a stack, a memory mapped area, a variable of a program corresponding to the user process, a character, an array, and the like when the user process runs. data.
  • the kernel process working memory area may refer to a physical memory area for storing data structures and variables included in the working environment of the kernel process runtime.
  • the foregoing data structure and variables stored in the working memory area of the kernel process may include, for example, at least one of the following: a heap, a stack, a memory mapped area, a variable of a program corresponding to the kernel process, characters, and an array of the kernel process. data.
  • the file storage memory area may be a physical memory area for storing a file system, and the file storage memory area may store various information of the file system itself, for example, an index node and a file in the file storage memory area where the file system may be stored. It can further store information such as superblocks (if any) of the file system.
  • the file storage memory area may include a non-volatile memory area and/or a volatile memory area (ie, the storage medium of the file storage memory area includes a non-volatile storage medium and/or Loss storage medium).
  • the process working memory area (such as the kernel process working memory area, the user process working memory area) may include a non-volatile memory area and/or a volatile memory area (ie, a storage medium of the working memory area of the process includes non-volatile Storage medium and/or volatile storage medium).
  • the process working memory area (such as the kernel process working memory area, the user process working memory area) and the file storage memory area do not overlap each other.
  • the processor 1002 calls the code stored in the memory 1003 through the bus 1001 to specifically add to the memory page table.
  • An entry for recording the first virtual address mapping relationship, the foregoing entry The first file page table or the pointer for pointing to the first file page table described above is included.
  • the total number of levels of the memory page table is Y
  • the total number of levels of the first file page table is X. If the entry includes the first file page table, the entry is The entry in the Y-X+1-level memory page table in the foregoing memory page table, if the entry includes a pointer for pointing to the first file page table, the entry is the first in the memory page table In the entry in the YX-level memory page table, the above X is a positive integer, and the above Y is a positive integer greater than the above X.
  • the processor 1002 calls the code stored in the memory 1003 via the bus 1001 to further record the first virtual address space and/or the first virtual address in the first index node.
  • the start address of the space, and/or, the first virtual address space and/or the start address of the first virtual address space are recorded in a file object corresponding to the file.
  • the first virtual address space is a continuous or non-contiguous virtual address space.
  • the first virtual address space is in a kernel virtual address space or a user process virtual address space.
  • the processor 1002 calls the code stored in the memory 1003 via the bus 1001 to obtain the file identifier.
  • the first inode of the file in the aspect of obtaining the first index node of the file represented by the file identifier, the processor 1002 calls the code stored in the memory 1003 via the bus 1001 to obtain the file identifier.
  • the first inode of the file in the aspect of obtaining the first index node of the file represented by the file identifier, the processor 1002 calls the code stored in the memory 1003 via the bus 1001 to obtain the file identifier.
  • the first inode of the file in the aspect of obtaining the first index node of the file represented by the file identifier
  • the processor 1002 calls the code stored in the memory 1003 via the bus 1001 to further receive a file read request for requesting to read the file content of the file, wherein the file is read.
  • the request carries the data amount of the first file content in the file read into the memory address space and requested to be read, wherein the read memory address space is an address space of the first memory area in the working memory area of the user process.
  • the reading physicality of reading the content of the first file from the file storage memory area An address space; the first file content of the file is read from the file storage memory area based on the read physical address space; and the first file content is written into the first memory area.
  • the amount of data based on the content of the first file is obtained by reading the physical address space of the first file content from the file storage memory area, and the processor 1002 passes the bus 1001. Calling the code stored in the memory 1003 to specifically use,
  • the default file content offset may be used as a first file content offset
  • a start address of the first virtual address space to obtain a starting read virtual address for reading the content of the first file; and using the initial read virtual address and the first virtual real address mapping Relationship, obtaining a starting physical address for reading the content of the first file from the file storage memory area; and reading the physical address of the first physical file and the content of the first file, and reading from the file storage memory area
  • the physical address space of the first file content is read.
  • the default file content offset may be As a first file content offset
  • a start read virtual address for reading the first file content is obtained; and based on the initial read virtual address and the first file content
  • the amount of data is obtained by reading the read virtual address space of the first file content; using the read virtual address space and the first virtual real address mapping relationship to obtain reading of the first file content from the file storage memory area Physical address space.
  • the processor 1002 calls the code stored in the memory 1003 via the bus 1001 to further receive a file write request requesting to write the file content into the file, wherein the file is written.
  • the incoming request carries a read memory address space and a data amount of the second file content requested to be written into the file, wherein the read memory address space is an address space of the second memory area in the working memory area of the process. ;
  • the amount of data based on the content of the second file, the first virtual address space, and the memory page table Recording the first virtual real address mapping relationship, and obtaining a write physical address space for writing the content of the second file to the file storage memory area, where the write physical address space is the third among the file storage memory areas
  • the physical address space of the memory area
  • the first virtual address mapping relationship based on the data amount of the second file content, the first virtual address space, and the memory page table record is obtained by writing to the file storage memory area.
  • the processor 1002 calls the code stored in the memory 1003 through the bus 1001 to specifically use,
  • the default file content offset may be used as a second file content offset
  • a start address of the first virtual address space to obtain a start write virtual address for writing the content of the second file to the file; using the above-mentioned initial write virtual address and the first a virtual real address mapping relationship, obtaining a starting physical address for writing the content of the second file to the file from the file storage memory area; and writing a physical address based on the initial writing physical address and the second content space.
  • the default file content offset may be As the second file content offset
  • the virtual address is written to the beginning of the second file content in the file; the virtual address and the second file are written based on the start
  • the amount of data of the content is obtained by writing the write virtual address space of the content of the second file to the file in the file storage memory area; using the above-mentioned write virtual address space and the first virtual place Write to the physical address space.
  • the storage capacity of the third memory area may be greater than or equal to the data volume of the second file content.
  • the memory area corresponding to the third memory area and the first physical address space has an intersection or no intersection. It can be understood that, in a normal case, if the memory area corresponding to the third memory area and the first physical address space have an intersection, it may indicate that part or all of the original file contents in the file are replaced by the content of the second file ( If the intersection of the memory area corresponding to the third memory area and the first physical address space is smaller than the third memory area, indicating that a new memory area is allocated for the second file content, that is, the memory area storing the file changes, and the foregoing The memory area of the file has been expanded).
  • the memory area corresponding to the third memory area and the first physical address space may indicate that the second file content is added in the file, and the third memory area allocates a new memory area for the second file content, that is, The memory area in which the above file is stored has changed, and the memory area in which the above file is stored is expanded.
  • the device 1002 may update the first file page table such that the updated first file page table points to a memory area in the file storage memory area where the above file is currently stored.
  • the processor 1002 may update the first virtual real address mapping relationship recorded in the memory page table to a third virtual real address mapping relationship, where the third virtual real address mapping relationship includes the first virtual address space and the foregoing A mapping relationship between the three physical address spaces, where the third physical address space is a physical address space of a memory area in which the file is currently stored in the file storage memory area.
  • the memory page table records a pointer to the first file page table (for example, the starting physical address of the first file page table recorded in the memory page table;) if the updated first file page table starts The physical address does not change, and the pointer to the first file page table is not modified in the memory page table.
  • the first file page table is updated without modifying the memory page table, and the virtual real address mapping relationship can be reconstructed, which greatly reduces the mapping operation.
  • the processor 1002 calls the code stored in the memory 1003 via the bus 1001 to further receive a file close request for requesting to close the file; releasing the first virtual address allocated for the file. Space; releasing the first virtual address mapping relationship recorded in the foregoing memory page table.
  • the processor 1002 calls the memory 1003 to identify the file represented by the memory 1001, creates the file in the file storage memory area, and allocates a second index node to the file.
  • a second file page table or a pointer for pointing to the second file page table is recorded in the second index node, wherein the second file page table is used to point to a memory area in the file storage memory area where the file is stored;
  • the file is allocated a second virtual address space;
  • the second virtual real address mapping relationship is recorded by using the memory page table, wherein the second virtual real address mapping relationship includes a mapping relationship between the second virtual address space and the second physical address space, where , the second thing above
  • the file is created in the file storage memory area.
  • the processor 1002 may not first create a file page table of the file or create an empty file page table of the file (wherein, if the empty file page table of the file is created, the third index The node may include the above empty file page table or a pointer for pointing to the empty file page table.
  • the processor 1002 may expand the memory area where the file is stored (eg, from The 10MB is expanded to 1000 MB.
  • the processor 1002 updates the file page table of the above file so that the updated file page table points to the memory area in which the file is stored after the expansion.
  • the number of levels of the second file page table has a correspondence with the file type of the file.
  • the file storage memory area includes a non-volatile memory area and/or a volatile memory area.
  • the computing node 1000 can be a device with a memory such as a server, a personal computer, a network element, a mobile terminal, or the like. It can be seen that, in the foregoing technical solution of the embodiment, after receiving the file open request carrying the file identifier, the processor obtains the first index node of the file represented by the file identifier, and is based on a physical address space; The file is allocated a first virtual address space; the first virtual address mapping relationship is recorded by the memory page table; wherein the first virtual real address mapping relationship is a mapping relationship between the first virtual address space and the first physical address space, where
  • the above memory page table includes a kernel memory page table and/or a user process memory page table.
  • the kernel virtual page table and/or the user process memory page table are used to record the first virtual real address mapping relationship, it can be considered that the first physical address space of the memory area storing the file in the file storage memory area is to some extent.
  • the physical address space corresponding to a certain memory area in the working memory area of the process is packaged, which is convenient for the kernel or the user process to access the file system of the resident kernel file according to the access performance of the similar accessor process to approximate the normal memory data. It is beneficial to greatly improve file access performance. It can be seen that the above file access scheme is more suitable for high-performance file access in the file system resident memory scenario.
  • the virtual address space is allocated for the file when the file is requested to be opened, this is advantageous for reducing the invalid occupation and address conflict possibility of the system virtual address space, and is beneficial to improving the utilization efficiency of the system virtual address space.
  • the MMU transparently completes the conversion between the virtual address and the physical address of the file, which facilitates faster file access and even zero overhead.
  • a file page table with a data structure similar to or the same as the memory page table is used to point to a memory page in which the file content is stored in the file storage memory area
  • the data structure of the file page table and the memory page table are similar or identical, it is advantageous to implement Zero conversion of the page table data structure, and when the memory page storing the file content changes, it may not be necessary to perform the operation of reconstructing the mapping relationship between the file physical address space and the virtual address space for the file page table, and by updating the file page table, Inserting a pointer to the updated file page table into the table of the file page table, thereby completing the mapping of the physical address of the file and the virtual address.
  • the method is advantageous for reconstructing the mapping between the physical address of the file and the virtual address within a constant time independent of the file size.
  • the file system in the file storage memory area is protected by the system virtual address and the MMU, which greatly reduces the possibility of being mistakenly written, and can not only be good. Protects the file and does not require an additional write protection mechanism to facilitate the system.
  • the size of the file is only affected by the size of the system virtual address space and the number of files simultaneously opened by the operating system, which are not limitations of the file system itself, and thus the file size. It is not subject to the design of the file system itself.
  • the file system adopts a method similar to the memory management, and the storage medium is accessed through the virtual address, and the MMU can be used to convert the virtual address and the physical address, and the kernel can be changed relatively less, which is convenient for the file system. Migrate to an existing operating system.
  • FIG. 11 is a structural block diagram of a computing node 1100 according to another embodiment of the present invention.
  • the computing node 1100 can include: at least one processor 1101, at least one network interface 1104 or other user interface 1103, a memory 1105, and at least one communication bus 1102. Communication bus 1102 is used to implement connection communication between these components.
  • the computing node 1100 optionally includes a user interface 1103, including: a display (eg, a touch screen, an LCD, a CRT, a Holographic or a Projector, etc.), a pointing device (eg, a mouse, a trackball) ) a touch panel or touch screen, etc.), a camera and/or a sound pickup device, and the like.
  • the memory 1102 can include, for example, a read only memory and a random access memory, and
  • 1101 provides instructions and data.
  • a portion of the memory 1102 also includes non-volatile memory (NVRAM) and the like.
  • NVRAM non-volatile memory
  • the memory 1102 can include a memory, it can also include external memory.
  • the foregoing memory may include: a file storage memory area and a process working memory area, wherein the working memory area of the above process stores a memory page table, and an operating system runs in the working memory area of the foregoing process.
  • the working memory area of the process may include a kernel process working memory area and a user process working memory area, wherein the kernel memory page table may be stored in a kernel process working memory area, and the user process memory page table may be stored in the user process working memory area. . .
  • the memory 1105 stores the following elements, executable modules or data structures, or a subset thereof, or their extension set:
  • Operating system 11051 which contains various system programs for implementing various basic services and handling hardware-based tasks.
  • the application module 11052 includes various applications for implementing various application services.
  • the processor 1101 receives a file open request carrying a file identifier by calling a program or an instruction stored in the memory 1105, and obtains a first index node of the file indicated by the file identifier, where the file is stored in the file.
  • the first virtual address space is allocated by using the memory page table to record the first virtual address mapping relationship; wherein the first virtual real address mapping relationship includes the first virtual address space and The mapping relationship between the first physical address spaces, wherein the memory page table comprises a kernel memory page table and/or a user process memory page table.
  • the file open request may carry a file storage path (that is, a storage path of a file that is requested to be opened), where the file identifier may be included in the file storage path, and of course, in the file open request. It is also possible to carry a file identification and may not carry a file storage path.
  • the file opening request may further carry a file type flag bit, where the file type flag bit may indicate a file type of the file represented by the file identifier (the file type may be a directory file or a data file).
  • the processor 1101 by calling the first physical address space of the memory area storing the file in the file storage memory area based on the first index node, by calling a program or an instruction stored in the memory 1105,
  • the processor 1101 is specifically configured to obtain, according to the first file page table recorded in the first index node or the pointer for pointing to the first file page table, the memory area in the file storage memory area where the file is stored. a physical address space, wherein the first file page
  • the first file page table described above is a single-level or multi-level file page table.
  • the process working memory area refers to the number of working environments used to store the running time of the process.
  • the physical memory area according to the structure and variables.
  • the data structure and the variable may include at least one of the following information: a heap, a stack, a memory mapped area, a variable of a program corresponding to the process, a character, an array, and the like when the process runs.
  • the user process working memory area may refer to a physical memory area for storing contents such as data structures and variables included in the working environment when the user process runs.
  • the foregoing data structure and variables stored in the working memory area of the user process may include, for example, at least one of the following: a heap, a stack, a memory mapped area, a variable of a program corresponding to the user process, a character, an array, and the like when the user process runs. data.
  • the kernel process working memory area may refer to a physical memory area for storing data structures and variables included in the working environment of the kernel process runtime.
  • the foregoing data structure and variables stored in the working memory area of the kernel process may include, for example, at least one of the following: a heap, a stack, a memory mapped area, a variable of a program corresponding to the kernel process, characters, and an array of the kernel process. data.
  • the file storage memory area may be a physical memory area for storing a file system, and the file storage memory area may store various information of the file system itself, for example, an index node and a file in the file storage memory area where the file system may be stored. It can further store information such as superblocks (if any) of the file system.
  • the file storage memory area may include a non-volatile memory area and/or a volatile memory area (ie, the storage medium of the file storage memory area includes a non-volatile storage medium and/or Loss storage medium).
  • the process working memory area (such as the kernel process working memory area, the user process working memory area) may include a non-volatile memory area and/or a volatile memory area (ie, a storage medium of the working memory area of the process includes non-volatile Storage medium and/or volatile storage medium).
  • the process working memory area (such as the kernel process working memory area, the user process working memory area) and the file storage memory area do not overlap each other.
  • the processor 1101 in the above-described aspect of recording the first virtual real address mapping relationship by using the memory page table, by calling a program or instruction stored in the memory 1105, the processor 1101 is specifically used to add a table for the memory page. Recording an entry of the first virtual real address mapping relationship, where the entry includes the first file page table or a pointer for pointing to the first file page table.
  • the total number of levels of the memory page table is Y
  • the total number of levels of the first file page table is X.
  • the entry is The entry in the Y-X+1-level memory page table in the foregoing memory page table, if the entry includes a pointer for pointing to the first file page table, the entry is the first in the memory page table
  • the above X is a positive integer
  • the above Y is a positive integer greater than the above X.
  • the processor 1101 is further configured to record the first virtual address space and/or the first virtual address space in the first index node by using a program or an instruction stored in the memory 1105.
  • the start address, and/or, the first virtual address space and/or the start address of the first virtual address space are recorded in a file object corresponding to the file.
  • the first virtual address space is a continuous or non-contiguous virtual address space.
  • the first virtual address space is in a kernel virtual address space or a user process virtual address space.
  • the processor 1101 in the aspect of obtaining the first index node of the file represented by the file identifier, by calling a program or instruction stored in the memory 1105, the processor 1101 specifically identifies the file represented by the file identifier. The first index node.
  • the processor 1101 is further configured to receive a file read request for requesting to read a file content of the file by calling a program or an instruction stored in the memory 1105, where the file read request is Carrying the data amount of the first file content in the above file read into the memory address space and requesting to read, wherein the read memory address space is an address space of the first memory area in the working memory area of the user process; The data amount of the first file content, the first virtual address space, and the first virtual real address mapping relationship recorded by the memory page table, to obtain a read physical address space for reading the first file content from the file storage memory area. And reading the first file content of the file from the file storage memory area based on the reading the physical address space; and writing the first file content into the first memory area.
  • the first virtual real address mapping relationship based on the data amount of the first file content, the first virtual address space, and the memory page table record is obtained from the foregoing
  • the above-mentioned file storage memory area reads the aspect of reading the physical address space of the first file content, and the processor 1101 is specifically used to call the program or instruction stored in the memory 1105.
  • the default file content offset may be used as a first file content offset
  • a start address of the first virtual address space to obtain a starting read virtual address for reading the content of the first file; and using the initial read virtual address and the first virtual real address mapping Relationship, obtaining a starting physical address for reading the content of the first file from the file storage memory area; and reading the physical address of the first physical file and the content of the first file, and reading from the file storage memory area
  • the physical address space of the first file content is read.
  • the default file content offset may be As a first file content offset
  • a start read virtual address for reading the first file content is obtained; and based on the initial read virtual address and the first file content
  • the amount of data is obtained by reading the read virtual address space of the first file content; using the read virtual address space and the first virtual real address mapping relationship to obtain reading of the first file content from the file storage memory area Physical address space.
  • the processor 1101 is further configured to receive a file write request requesting to write a file content to the file by using a program or an instruction stored in the memory 1105, where the file write request is performed. Carrying a read memory address space and a data amount of the second file content requested to be written into the file, wherein the read memory address space is an address space of a second memory area in the process working memory area;
  • the first virtual address mapping relationship based on the data amount of the second file content, the first virtual address space, and the memory page table record is obtained by writing to the file storage memory area.
  • the processor 1101 is specifically configured to use, by calling a program or an instruction stored in the memory 1105, in the aspect of writing the physical address space of the content of the second file.
  • the default file content offset may be used as a second file content offset
  • a start address of the first virtual address space to obtain a start write virtual address for writing the content of the second file to the file; using the above-mentioned initial write virtual address and the first
  • the virtual real address mapping relationship obtains a starting physical address for writing the content of the second file to the file from the file storage memory area; and based on the data amount of the initial writing physical address and the second file content, Writing a physical address space of the content of the second file to the above file of the file storage memory area.
  • the default file content offset may be As the second file content offset
  • the virtual address is written to the beginning of the second file content in the file; the virtual address and the second file are written based on the start
  • the amount of data of the content is obtained by writing the write virtual address space of the content of the second file to the file in the file storage memory area; using the above-mentioned write virtual address space and the first virtual place Write to the physical address space.
  • the storage capacity of the third memory area may be greater than or equal to the data volume of the second file content.
  • the memory area corresponding to the third memory area and the first physical address space has an intersection or no intersection. It can be understood that, in a normal case, if the memory area corresponding to the third memory area and the first physical address space have an intersection, it may indicate that part or all of the original file contents in the file are replaced by the content of the second file ( If the intersection of the memory area corresponding to the third memory area and the first physical address space is smaller than the third memory area, indicating that a new memory area is allocated for the second file content, that is, the memory area storing the file changes, and the foregoing The memory area of the file has been expanded).
  • the memory area corresponding to the third memory area and the first physical address space may indicate that the second file content is added in the file, and the third memory area allocates a new memory area for the second file content, that is, The memory area in which the above file is stored has changed, and the memory area in which the above file is stored is expanded.
  • the device 1101 may update the first file page table such that the updated first file page table points to a memory area in the file storage memory area where the above file is currently stored.
  • the processor 1101 may update the first virtual address mapping relationship recorded in the memory page table to a third virtual address mapping relationship, where the third virtual address mapping relationship includes the first virtual address space and the foregoing A mapping relationship between the three physical address spaces, where the third physical address space is a physical address space of a memory area in which the file is currently stored in the file storage memory area.
  • the memory page table records a pointer to the first file page table (for example, the starting physical address of the first file page table recorded in the memory page table)
  • the updated first file page table starts The physical address has not changed, and the pointer to the first file page table may not be modified in the memory page table.
  • the first file page table is updated without modifying the memory page table, and the virtual real address mapping relationship can be reconstructed, which greatly reduces the mapping operation.
  • the processor 1101 is further configured to receive a file close request for requesting to close the file by calling a program or an instruction stored in the memory 1105; releasing a first virtual address space allocated for the file; The first virtual address mapping relationship recorded in the foregoing memory page table is released.
  • processing is performed by calling a program or instruction stored in the memory 1105.
  • a file the file is created in the file storage memory area, and the second index node is allocated to the file, wherein the second file node records a second file page table or a pointer to the second file page table.
  • the second file page table is used to point to the memory area of the file storage memory area for storing the file; the second virtual address space is allocated to the file; and the second virtual address mapping relationship is recorded by using the memory page table;
  • the second virtual address mapping relationship includes a mapping relationship between the second virtual address space and the second physical address space, where the second physical address is empty.
  • the file after receiving the file open request carrying the file identifier, when it is determined that the file indicated by the file identifier is not stored in the file storage memory area, the file is created in the file storage memory area.
  • the third index node is allocated to the above file, and the processor 1101 may not first create a file page table of the file or create an empty file page table of the file (wherein, if the empty file page table of the file is created, the third index)
  • the node may include the above empty file page table or a pointer for pointing to the empty file page table.
  • the processor 1101 may expand the memory area where the file is stored (eg, from The 10MB is expanded to 1100 MB.
  • the processor 1101 updates the file page table of the above file so that the updated file page table points to the memory area where the file is stored after the expansion.
  • the number of levels of the second file page table has a correspondence with the file type of the file.
  • the file storage memory area includes a non-volatile memory area and/or a volatile memory area.
  • the processor after receiving the file open request carrying the file identifier, the processor obtains the first index node of the file represented by the file identifier, and is based on a physical address space; a first virtual address space is allocated to the file; the first virtual address mapping relationship is recorded by the memory page table; wherein the first virtual address mapping relationship is the first virtual address space and the first physical address space
  • a mapping relationship between the foregoing memory page table includes a kernel memory page table and/or a user process memory page table. Because the kernel virtual page table and/or the user process memory page table are used to record the first virtual real address mapping relationship, it can be considered that the first physical address space of the memory area storing the file in the file storage memory area is to some extent.
  • the physical address space corresponding to a certain memory area in the working memory area of the process is packaged, which is convenient for the kernel or the user process to access the file system of the resident kernel file according to the access performance of the similar accessor process to approximate the normal memory data. It is beneficial to greatly improve file access performance. It can be seen that the above file access scheme is more suitable for high-performance file access in the file system resident memory scenario. Moreover, since the virtual address space is allocated for the file when the file is requested to be opened, this is advantageous for reducing the invalid occupation and address conflict possibility of the system virtual address space, and is beneficial to improving the utilization efficiency of the system virtual address space.
  • the MMU transparently completes the conversion between the virtual address and the physical address of the file, which facilitates faster file access and even zero overhead.
  • a file page table with a data structure similar to or the same as the memory page table is used to point to a memory page in which the file content is stored in the file storage memory area
  • the data structure of the file page table and the memory page table are similar or identical, it is advantageous to implement Zero conversion of the page table data structure, and when the memory page storing the file content changes, it may not be necessary to perform the operation of reconstructing the mapping relationship between the file physical address space and the virtual address space for the file page table, and by updating the file page table,
  • the pointer to the updated file page table is inserted into the table entry of the file page table, thereby completing the mapping of the physical address of the file and the virtual address, which is beneficial for reconstructing the physical address of the file within a constant time independent of the file size. Mapping to virtual addresses.
  • the file system is The file in the file storage memory area is protected by the system virtual address and the MMU, which greatly reduces the possibility of being mistakenly written, not only can protect the file well, and does not require an additional write protection mechanism, which is beneficial to the system.
  • the size of the file is only affected by the size of the system virtual address space and the number of files simultaneously opened by the operating system, which are not limitations of the file system itself, and thus the file size. It is not subject to the design of the file system itself.
  • the file system adopts a method similar to the memory management, and the storage medium is accessed through the virtual address, and the MMU can be used to convert the virtual address and the physical address, and the kernel can be changed relatively less, which is convenient for the file system. Migrate to an existing operating system.
  • the computing node of each embodiment of the present invention may be a device having a memory such as a server, a personal computer, a network element, a mobile terminal, or the like.
  • the embodiment of the present invention further provides a computer storage medium, wherein the computer storage medium may store a program, and the program includes some or all of the steps of the at least one method for accessing the file described in the foregoing method embodiments.
  • the disclosed apparatus may be implemented in other manners.
  • the device embodiments described above are merely illustrative.
  • the division of the unit is only a logical function division.
  • there may be another division manner for example, multiple units or components may be combined or may be Integration into another system, or some features can be ignored, or not executed.
  • the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be electrical or otherwise.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
  • each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
  • the above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
  • the integrated unit if implemented in the form of a software functional unit and sold or used as a standalone product, may be stored in a computer readable storage medium.
  • the instructions include a plurality of instructions for causing a computer device (which may be a personal computer, server or network device, etc., and in particular a processor in a computer device) to perform all or part of the steps of the methods of the various embodiments of the present invention.
  • the foregoing storage medium may include: a USB flash drive, a removable hard disk, a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM), and the like. The medium of the code.

Abstract

一种访问文件的方法和相关设备。一种访问文件的方法包括:操作系统接收携带文件标识的文件打开请求;获得文件标识所表示的文件的第一索引节点,其中,文件存储于文件存储内存区之中;基于第一索引节点得到文件存储内存区之中存储文件的内存区的第一物理地址空间;为文件分配第一虚拟地址空间;利用内存页表记录第一虚实地址映射关系;其中,第一虚实地址映射关系包括第一虚拟地址空间与第一物理地址空间之间的映射关系,其中,内存页表包括内核内存页表和/或用户进程内存页表。本发明实施例的技术方案可适用于在文件系统常驻内存场景下进行文件访问。

Description

访问文件的方法和相关设备 技术领域
本发明涉及计算机技术领域, 具体涉及访问文件的方法和装置及计算节 点。 背景技术
现在出现了存储级内存( SCM, Storage Class Memory )的概念, 此概念基于 新一代非易失性内存技术。新一代非易失性内存的存取效能表现与普通内存模 组基本一致。 同时具有半导体产品的可靠性, 例如防震抗压, 而且可以在无需 擦除旧有资料的情况下直接写入,可作为緩解处理器与存储之间巨大的访问速 度差异的新一代存储设备。其中, SCM—方面和现有的一些常规的随机存取存 储器(RAM, Random Access Memory )—样, 可直接挂在内存总线上, 直接 面对中央处理器(CPU, Center Processing Unit ); 另一方面, 它的功能也延伸 到现有外存上, 可以作为永久性数据存储设备。
业内预计, 新一代非易失性存储器( NVM , Non-Volatile Memory )可能成为 替代闪存、 磁盘甚至动态随机存取存储器(DRAM, Dynamic RAM ) 的未来 存储设备。 这些存储设备具有很多优秀的特性, 主要特性有访问速度快(可拥 有与 DRAM相近的访问速度)、 字节可寻址(可设计为与 DRAM具有相同访问 接口 )、数据掉电不丟失(可以与闪存或者磁盘一样可持久存储数据)。 这些特 性使得这一类新的存储器件,被公认为有可能在未来数年之内替代部分 DRAM 和磁盘等传统存储体而成为存储系统的主流,也因此将引发传统存储系统结构 的革命性变化。
这些变革之一就是文件系统有可能常驻内存,并期望实现以近似普通内存 数据的访问性能来访问文件系统的文件。在这种构想的架构之下, 采用传统的 文件访问方式将变得不合时宜。 发明内容
本发明实施例提供一种访问文件的方法和相关设备,以期适用于在文件系 统常驻内存场景下进行文件访问。 本发明实施例第一方面提供一种访问文件的方法,所述访问文件的方法应 用于计算节点中, 所述计算节点包括内存, 所述内存包括: 文件存储内存区和 进程工作内存区, 所述进程工作内存区存储有内存页表, 所述进程工作内存区 之中运行有操作系统,
其中, 所述访问文件的方法包括:
所述操作系统接收携带文件标识的文件打开请求;
所述操作系统获得所述文件标识所表示的文件的第一索引节点, 其中, 所 述文件存储于所述文件存储内存区之中;基于所述第一索引节点得到所述文件 存储内存区之中存储所述文件的内存区的第一物理地址空间;
所述操作系统为所述文件分配第一虚拟地址空间;
所述操作系统利用所述内存页表记录第一虚实地址映射关系;
其中,所述第一虚实地址映射关系包括所述第一虚拟地址空间与所述第一 物理地址空间之间的映射关系, 其中, 所述内存页表包括内核内存页表和 /或 用户进程内存页表。
结合第一方面, 在第一方面的第一种可能的实施方式中,
所述基于所述第一索引节点得到所述文件存储内存区之中存储所述文件 的内存区的第一物理地址空间, 包括: 基于所述第一索引节点中记录的第一文 件页表或用于指向第一文件页表的指针,得到所述文件存储内存区之中存储所 述文件的内存区的第一物理地址空间, 其中, 所述第一文件页表用于指向所述 文件存储内存区之中存储所述文件的内存区,所述的第一物理地址空间为所述 表为单级或多级文件页表。
结合第一方面的第一种可能的实施方式,在第一方面的第二种可能的实施 方式中, 所述利用内存页表记录第一虚实地址映射关系, 包括: 在内存页表中 增加用于记录所述第一虚实地址映射关系的表项,所述表项包含所述第一文件 页表或用于指向所述第一文件页表的指针。
结合第一方面的第二种可能的实施方式,在第一方面的第三种可能的实施 方式中, 所述内存页表的总级数为 Y, 所述第一文件页表的总级数为 X, 若所 述表项包含所述第一文件页表, 则所述表项为所述内存页表中的第 Y-X+1级内 存页表中的表项, 若所述表项包含用于指向所述第一文件页表的指针, 则所述 表项为所述内存页表中的第 Y-X级内存页表中的表项,所述 X为正整数,所述 Y 为大于所述 X的正整数。
结合第一方面或第一方面的第一种可能的实施方式或第一方面的第二种 可能的实施方式或第一方面的第三种可能的实施方式,在第一方面的第四种可 能的实施方式中, 所述方法还包括:
所述操作系统在所述第一索引节点中记录所述第一虚拟地址空间和 /或所 述第一虚拟地址空间的起始地址, 和 /或, 所述操作系统在所述文件对应的文 件对象之中记录所述第一虚拟地址空间和 /或所述第一虚拟地址空间的起始地 址。
结合第一方面或第一方面的第一种可能的实施方式或第一方面的第二种 可能的实施方式或第一方面的第三种可能的实施方式或第一方面的第四种可 能的实施方式,在第一方面的第五种可能的实施方式中, 所述第一虚拟地址空 间为连续的或者非连续的虚拟地址空间。
结合第一方面或第一方面的第一种可能的实施方式或第一方面的第二种 可能的实施方式或第一方面的第三种可能的实施方式或第一方面的第四种可 能的实施方式或第一方面的第五种可能的实施方式,在第一方面的第六种可能 的实施方式中,所述第一虚拟地址空间处于内核虚拟地址空间或者用户进程虚 拟地址空间。
结合第一方面或第一方面的第一种可能的实施方式或第一方面的第二种 可能的实施方式或第一方面的第三种可能的实施方式或第一方面的第四种可 能的实施方式或第一方面的第五种可能的实施方式或第一方面的第六种可能 的实施方式, 在第一方面的第七种可能的实施方式中,
所述获得所述文件标识所表示的文件的第一索引节点包括:当确定所述文 件存储内存区之中存储有所述文件标识所表示的文件,获得所述文件标识所表 示的文件的第一索引节点。
结合第一方面或第一方面的第一种可能的实施方式或第一方面的第二种 可能的实施方式或第一方面的第三种可能的实施方式或第一方面的第四种可 能的实施方式或第一方面的第五种可能的实施方式或第一方面的第六种可能 的实施方式或第一方面的第七种可能的实施方式,在第一方面的第八种可能的 实施方式中, 所述方法还包括:
所述操作系统接收用于请求读取所述文件的文件内容的文件读取请求,其 中,所述文件读取请求携带有读入内存地址空间和请求读取的所述文件中的第 一文件内容的数据量, 其中, 所述读入内存地址空间为用户进程工作内存区之 中的第一内存区的地址空间;
所述操作系统基于所述第一文件内容的数据量、所述第一虚拟地址空间和 所述内存页表记录的所述第一虚实地址映射关系,得到从所述文件存储内存区 读取所述第一文件内容的读取物理地址空间;
所述操作系统基于所述读取物理地址空间,从所述文件存储内存区之中读 取出所述文件的第一文件内容;
所述操作系统将所述第一文件内容写入所述第一内存区。
结合第一方面的第八种可能的实施方式,在第一方面的第九种可能的实施 方式中, 所述基于所述第一文件内容的数据量、所述第一虚拟地址空间和所述 内存页表记录的所述第一虚实地址映射关系,得到从所述文件存储内存区读取 所述第一文件内容的读取物理地址空间, 包括:
基于所述第一文件内容的数据量、第一文件内容偏移量、所述第一虚拟地 址空间和所述内存页表记录的所述第一虚实地址映射关系,得到从所述文件存 储内存区读取所述第一文件内容的读取物理地址空间, 其中, 所述第一文件内 容偏移量从所述文件读取请求之中得到, 或者, 所述第一文件内容偏移量从所 述文件对应的文件对象之中得到。
结合第一方面或第一方面的第一种可能的实施方式或第一方面的第二种 可能的实施方式或第一方面的第三种可能的实施方式或第一方面的第四种可 能的实施方式或第一方面的第五种可能的实施方式或第一方面的第六种可能 的实施方式或第一方面的第七种可能的实施方式或第一方面的第八种可能的 实施方式或第一方面的第九种可能的实施方式,在第一方面的第十种可能的实 施方式中, 所述方法还包括:
所述操作系统接收请求向所述文件之中写入文件内容的文件写入请求,其 中,所述文件写入请求携带有读出内存地址空间和请求写入所述文件之中的第 二文件内容的数据量, 其中, 所述读出内存地址空间为所述进程工作内存区之 中的第二内存区的地址空间;
所述操作系统基于所述第二文件内容的数据量、所述第一虚拟地址空间和 所述内存页表记录的所述第一虚实地址映射关系,得到向所述文件存储内存区 写入所述第二文件内容的写入物理地址空间, 其中, 所述写入物理地址空间为 所述文件存储内存区之中的第三内存区的物理地址空间;
所述操作系统将所述第二内存区之中緩存的所述第二文件内容写入到所 述第三内存区之中。
结合第一方面的第十种可能的实施方式中,在第一方面的第十一种可能的 实施方式中, 所述基于所述第二文件内容的数据量、所述第一虚拟地址空间和 所述内存页表记录的所述第一虚实地址映射关系,得到向所述文件存储内存区 写入所述第二文件内容的写入物理地址空间, 包括:
基于所述第二文件内容的数据量、第二文件内容偏移量、所述第一虚拟地 址空间和所述内存页表记录的所述第一虚实地址映射关系,得到向所述文件存 储内存区写入所述第二文件内容的写入物理地址空间, 其中, 所述第二文件内 容偏移量从所述文件写入请求之中得到, 或者, 所述第二文件内容偏移量从所 述文件对应的文件对象之中得到。
结合第一方面的第十种可能的实施方式或第一方面的第十一种可能的实 施方式中,在第一方面的第十二种可能的实施方式中, 所述第三内存区的存储 容量大于或者等于所述第二文件内容的数据量。
结合第一方面或第一方面的第一种可能的实施方式或第一方面的第二种 可能的实施方式或第一方面的第三种可能的实施方式或第一方面的第四种可 能的实施方式或第一方面的第五种可能的实施方式或第一方面的第六种可能 的实施方式或第一方面的第七种可能的实施方式或第一方面的第八种可能的 实施方式或第一方面的第九种可能的实施方式或第一方面的第十种可能的实 施方式或第一方面的第十一种可能的实施方式或第一方面的第十二种可能的 实施方式, 在第一方面的第十三种可能的实施方式中,
所述方法还包括: 接收用于请求关闭所述文件的文件关闭请求; 释放为所 述文件分配的第一虚拟地址空间;释放所述内存页表中记录的所述第一虚实地 址映射关系。
结合第一方面或第一方面的第一种可能的实施方式或第一方面的第二种 可能的实施方式或第一方面的第三种可能的实施方式或第一方面的第四种可 能的实施方式或第一方面的第五种可能的实施方式或第一方面的第六种可能 的实施方式或第一方面的第七种可能的实施方式或第一方面的第八种可能的 实施方式或第一方面的第九种可能的实施方式或第一方面的第十种可能的实 施方式或第一方面的第十一种可能的实施方式或第一方面的第十二种可能的 实施方式或第一方面的第十三种可能的实施方式,在第一方面的第十四种可能 的实施方式中,
所述方法还包括:所述操作系统当确定所述文件存储内存区之中未存储有 所述文件标识所表示的文件,在所述文件存储内存区之中创建所述文件, 为所 述文件分配第二索引节点, 其中, 所述第二索引节点中记录有第二文件页表或 者用于指向第二文件页表的指针, 其中, 所述第二文件页表用于指向所述文件 存储内存区之中存储所述文件的内存区;
所述操作系统为所述文件分配第二虚拟地址空间;
所述操作系统利用内存页表记录第二虚实地址映射关系;
其中,所述第二虚实地址映射关系包括所述第二虚拟地址空间与所述第二 物理地址空间之间的映射关系, 其中, 所述第二物理地址空间为所述文件存储 内存区之中存储所述文件的内存区的物理地址空间,所述内存页表包括内核内 存页表和 /或用户进程内存页表。
结合第一方面的第十四种可能的实施方式,在第一方面的第十五种可能的 实施方式中,所述第二文件页表的级数与所述文件的文件类型之间具有对应关 系。
结合第一方面或第一方面的第一种可能的实施方式或第一方面的第二种 可能的实施方式或第一方面的第三种可能的实施方式或第一方面的第四种可 能的实施方式或第一方面的第五种可能的实施方式或第一方面的第六种可能 的实施方式或第一方面的第七种可能的实施方式或第一方面的第八种可能的 实施方式或第一方面的第九种可能的实施方式或第一方面的第十种可能的实 施方式或第一方面的第十一种可能的实施方式或第一方面的第十三种可能的 实施方式或第一方面的第十四种可能的实施方式或第一方面的第十五种可能 的实施方式,在第一方面的第十六种可能的实施方式中, 所述文件存储内存区 包括非易失性内存区和 /或易失性内存区。
本发明第二方面提供一种访问文件的装置, 可包括:
接收单元, 用于接收携带文件标识的文件打开请求;
获取单元, 用于获得所述文件标识所表示的文件的第一索引节点, 所述文 件存储于文件存储内存区之中;基于所述第一索引节点得到所述文件存储内存 区之中存储所述文件的内存区的第一物理地址空间;
分配单元, 用于为所述文件分配第一虚拟地址空间;
映射单元, 用于利用内存页表记录第一虚实地址映射关系;
其中,所述第一虚实地址映射关系包括所述第一虚拟地址空间与所述第一 物理地址空间之间的映射关系, 其中, 所述内存页表包括内核内存页表和 /或 用户进程内存页表。
结合第二方面, 在第二方面的第一种可能的实施方式中,
在所述基于所述第一索引节点得到所述文件存储内存区之中存储所述文 件的内存区的第一物理地址空间的方面, 所述获取单元具体用于,基于所述第 一索引节点中记录的第一文件页表或用于指向第一文件页表的指针,得到所述 文件存储内存区之中存储所述文件的内存区的第一物理地址空间, 其中, 所述
理地址空间, 所述第一文件页表为单级或多级文件页表。
结合第二方面的第一种可能的实施方式,在第二方面的第二种可能的实施 方式中, 所述映射单元具体用于: 在内存页表中增加用于记录所述第一虚实地 址映射关系的表项,所述表项包含所述第一文件页表或用于指向所述第一文件 页表的指针。
结合第二方面的第二种可能的实施方式,在第二方面的第三种可能的实施 方式中, 所述内存页表的总级数为 Y, 所述第一文件页表的总级数为 X, 若所 述表项包含所述第一文件页表, 则所述表项为所述内存页表中的第 Y-X+1级内 存页表中的表项, 若所述表项包含用于指向所述第一文件页表的指针, 则所述 表项为所述内存页表中的第 Y-X级内存页表中的表项,所述 X为正整数,所述 Y 为大于所述 X的正整数。
结合第二方面或第二方面的第一种可能的实施方式或第二方面的第二种 可能的实施方式或第二方面的第三种可能的实施方式,在第二方面的第四种可 能的实施方式中, 所述访问文件的装置还包括:
记录单元, 用于在所述第一索引节点中记录所述第一虚拟地址空间和 /或 所述第一虚拟地址空间的起始地址, 和 /或, 在所述文件对应的文件对象之中 记录所述第一虚拟地址空间和 /或所述第一虚拟地址空间的起始地址。
结合第二方面或第二方面的第一种可能的实施方式或第二方面的第二种 可能的实施方式或第二方面的第三种可能的实施方式或第二方面的第四种可 能的实施方式,在第二方面的第五种可能的实施方式中, 所述第一虚拟地址空 间为连续的或者非连续的虚拟地址空间。
结合第二方面或第二方面的第一种可能的实施方式或第二方面的第二种 可能的实施方式或第二方面的第三种可能的实施方式或第二方面的第四种可 能的实施方式或第二方面的第五种可能的实施方式,在第二方面的第六种可能 的实施方式中,所述第一虚拟地址空间处于内核虚拟地址空间或者用户进程虚 拟地址空间。
结合第二方面或第二方面的第一种可能的实施方式或第二方面的第二种 可能的实施方式或第二方面的第三种可能的实施方式或第二方面的第四种可 能的实施方式或第二方面的第五种可能的实施方式或第二方面的第六种可能 的实施方式, 在第二方面的第七种可能的实施方式中,
所述获取单元具体用于:当确定所述文件存储内存区之中存储有所述文件 标识所表示的文件, 获得所述文件标识所表示的文件的第一索引节点。
结合第二方面或第二方面的第一种可能的实施方式或第二方面的第二种 可能的实施方式或第二方面的第三种可能的实施方式或第二方面的第四种可 能的实施方式或第二方面的第五种可能的实施方式或第二方面的第六种可能 的实施方式或第二方面的第七种可能的实施方式,在第二方面的第八种可能的 实施方式中, 所述接收单元还用于,接收用于请求读取所述文件的文件内容的 文件读取请求, 其中, 所述文件读取请求携带有读入内存地址空间和请求读取 的所述文件中的第一文件内容的数据量, 其中, 所述读入内存地址空间为用户 进程工作内存区之中的第一内存区的地址空间;
所述访问文件的装置还包括: 第二映射单元, 用于基于所述第一文件内容 的数据量、所述第一虚拟地址空间和所述内存页表记录的所述第一虚实地址映 射关系,得到从所述文件存储内存区读取所述第一文件内容的读取物理地址空 间;
第一读写单元, 用于基于所述读取物理地址空间,从所述文件存储内存区 之中读取出所述文件的第一文件内容;将所述第一文件内容写入所述第一内存 区。
结合第二方面的第八种可能的实施方式,在第二方面的第九种可能的实施 方式中,在所述基于所述第一文件内容的数据量、所述第一虚拟地址空间和所 述内存页表记录的所述第一虚实地址映射关系,得到从所述文件存储内存区读 取所述第一文件内容的读取物理地址空间的方面, 第二映射单元具体用于,基 于所述第一文件内容的数据量、第一文件内容偏移量、所述第一虚拟地址空间 和所述内存页表记录的所述第一虚实地址映射关系,得到从所述文件存储内存 区读取所述第一文件内容的读取物理地址空间, 其中, 所述第一文件内容偏移 量从所述文件读取请求之中得到, 或者, 所述第一文件内容偏移量从所述文件 对应的文件对象之中得到。
结合第二方面或第二方面的第一种可能的实施方式或第二方面的第二种 可能的实施方式或第二方面的第三种可能的实施方式或第二方面的第四种可 能的实施方式或第二方面的第五种可能的实施方式或第二方面的第六种可能 的实施方式或第二方面的第七种可能的实施方式或第二方面的第八种可能的 实施方式或第二方面的第九种可能的实施方式,在第二方面的第十种可能的实 施方式中, 所述接收单元还用于,接收请求向所述文件之中写入文件内容的文 件写入请求, 其中, 所述文件写入请求携带有读出内存地址空间和请求写入所 述文件之中的第二文件内容的数据量, 其中, 所述读出内存地址空间为所述进 程工作内存区之中的第二内存区的地址空间;
所述访问文件的装置还包括: 第三映射单元, 用于基于所述第二文件内容 的数据量、所述第一虚拟地址空间和所述内存页表记录的所述第一虚实地址映 射关系,得到向所述文件存储内存区写入所述第二文件内容的写入物理地址空 间, 其中, 所述写入物理地址空间为所述文件存储内存区之中的第三内存区的 物理地址空间;
第二读写单元,用于将所述第二内存区之中緩存的所述第二文件内容写入 到所述第三内存区之中。
结合第二方面的第十种可能的实施方式中,在第二方面的第十一种可能的 实施方式中,在所述基于所述第二文件内容的数据量、所述第一虚拟地址空间 和所述内存页表记录的所述第一虚实地址映射关系,得到向所述文件存储内存 区写入所述第二文件内容的写入物理地址空间的方面,所述第三映射单元具体 用于基于所述第二文件内容的数据量、 第二文件内容偏移量、所述第一虚拟地 址空间和所述内存页表记录的所述第一虚实地址映射关系,得到向所述文件存 储内存区写入所述第二文件内容的写入物理地址空间, 其中, 所述第二文件内 容偏移量从所述文件写入请求之中得到, 或者, 所述第二文件内容偏移量从所 述文件对应的文件对象之中得到。
结合第二方面的第十种可能的实施方式或第二方面的第十一种可能的实 施方式中,在第二方面的第十二种可能的实施方式中, 所述第三内存区的存储 容量大于或者等于所述第二文件内容的数据量。
结合第二方面或第二方面的第一种可能的实施方式或第二方面的第二种 可能的实施方式或第二方面的第三种可能的实施方式或第二方面的第四种可 能的实施方式或第二方面的第五种可能的实施方式或第二方面的第六种可能 的实施方式或第二方面的第七种可能的实施方式或第二方面的第八种可能的 实施方式或第二方面的第九种可能的实施方式或第二方面的第十种可能的实 施方式或第二方面的第十一种可能的实施方式或第二方面的第十二种可能的 实施方式, 在第二方面的第十三种可能的实施方式中,
所述接收单元还用于, 接收用于请求关闭所述文件的文件关闭请求; 所述访问文件的装置还包括: 释放单元, 用于释放为所述文件分配的第一 虚拟地址空间; 释放所述内存页表中记录的所述第一虚实地址映射关系。
结合第二方面或第二方面的第一种可能的实施方式或第二方面的第二种 可能的实施方式或第二方面的第三种可能的实施方式或第二方面的第四种可 能的实施方式或第二方面的第五种可能的实施方式或第二方面的第六种可能 的实施方式或第二方面的第七种可能的实施方式或第二方面的第八种可能的 实施方式或第二方面的第九种可能的实施方式或第二方面的第十种可能的实 施方式或第二方面的第十一种可能的实施方式或第二方面的第十二种可能的 实施方式或第二方面的第十三种可能的实施方式,在第二方面的第十四种可能 的实施方式中,
所述访问文件的装置还包括: 表示的文件,在所述文件存储内存区之中创建所述文件, 为所述文件分配第二 索引节点, 其中, 所述第二索引节点中记录有第二文件页表或者用于指向第二 文件页表的指针, 其中, 所述第二文件页表用于指向所述文件存储内存区之中 存储所述文件的内存区;
所述分配单元还用于, 为所述文件分配第二虚拟地址空间;
所述映射单元还用于, 利用内存页表记录第二虚实地址映射关系; 其中,所述第二虚实地址映射关系包括所述第二虚拟地址空间与所述第二 物理地址空间之间的映射关系, 其中, 所述第二物理地址空间为所述文件存储 内存区之中存储所述文件的内存区的物理地址空间,所述内存页表包括内核内 存页表和 /或用户进程内存页表。
结合第二方面的第十四种可能的实施方式,在第二方面的第十五种可能的 实施方式中,所述第二文件页表的级数与所述文件的文件类型之间具有对应关 系。
结合第二方面或第二方面的第一种可能的实施方式或第二方面的第二种 可能的实施方式或第二方面的第三种可能的实施方式或第二方面的第四种可 能的实施方式或第二方面的第五种可能的实施方式或第二方面的第六种可能 的实施方式或第二方面的第七种可能的实施方式或第二方面的第八种可能的 实施方式或第二方面的第九种可能的实施方式或第二方面的第十种可能的实 施方式或第二方面的第十一种可能的实施方式或第二方面的第十三种可能的 实施方式或第二方面的第十四种可能的实施方式或第二方面的第十五种可能 的实施方式,在第二方面的第十六种可能的实施方式中, 所述文件存储内存区 包括非易失性内存区和 /或易失性内存区。
本发明实施例第三方面提供一种计算节点, 可包括:
至少一个总线、与所述总线相连的至少一个处理器以及与所述总线相连的 至少一个存储器;
其中, 所述处理器通过所述总线调用所述存储器中存储的代码以用于, 接收携带文件标识的文件打开请求;获得所述文件标识所表示的文件的第 一索引节点, 其中, 所述文件存储于文件存储内存区之中; 基于所述第一索引 间; 为所述文件分配第一虚拟地址空间; 利用内存页表记录第一虚实地址映射 关系; 其中, 所述第一虚实地址映射关系包括所述第一虚拟地址空间与所述第 一物理地址空间之间的映射关系, 其中, 所述内存页表包括内核内存页表和 / 或用户进程内存页表。
结合第三方面, 在第三方面的第一种可能的实施方式中,
在所述基于所述第一索引节点得到所述文件存储内存区之中存储所述文 件的内存区的第一物理地址空间的方面,所述处理器通过所述总线调用所述存 储器中存储的代码以具体用于,基于所述第一索引节点中记录的第一文件页表 或用于指向第一文件页表的指针,得到所述文件存储内存区之中存储所述文件 的内存区的第一物理地址空间, 其中, 所述第一文件页表用于指向所述文件存 储内存区之中存储所述文件的内存区,所述的第一物理地址空间为所述文件存 储内存区之中存储所述文件的内存区的物理地址空间,所述第一文件页表为单 级或多级文件页表。
结合第三方面的第一种可能的实施方式,在第三方面的第二种可能的实施 方式中,在所述利用内存页表记录第一虚实地址映射关系的方面, 所述处理器 通过所述总线调用所述存储器中存储的代码以具体用于,在内存页表中增加用 于记录所述第一虚实地址映射关系的表项,所述表项包含所述第一文件页表或 用于指向所述第一文件页表的指针。
结合第三方面的第二种可能的实施方式,在第三方面的第三种可能的实施 方式中, 所述内存页表的总级数为 Y, 所述第一文件页表的总级数为 X, 若所 述表项包含所述第一文件页表, 则所述表项为所述内存页表中的第 Y-X+1级内 存页表中的表项, 若所述表项包含用于指向所述第一文件页表的指针, 则所述 表项为所述内存页表中的第 Y-X级内存页表中的表项,所述 X为正整数,所述 Y 为大于所述 X的正整数。
结合第三方面或第三方面的第一种可能的实施方式或第三方面的第二种 可能的实施方式或第三方面的第三种可能的实施方式,在第三方面的第四种可 能的实施方式中,所述处理器通过所述总线调用所述存储器中存储的代码以还 用于, 在所述第一索引节点中记录所述第一虚拟地址空间和 /或所述第一虚拟 地址空间的起始地址, 和 /或, 在所述文件对应的文件对象之中记录所述第一 虚拟地址空间和 /或所述第一虚拟地址空间的起始地址。
结合第三方面或第三方面的第一种可能的实施方式或第三方面的第二种 可能的实施方式或第三方面的第三种可能的实施方式或第三方面的第四种可 能的实施方式,在第三方面的第五种可能的实施方式中, 所述第一虚拟地址空 间为连续的或者非连续的虚拟地址空间。
结合第三方面或第三方面的第一种可能的实施方式或第三方面的第二种 可能的实施方式或第三方面的第三种可能的实施方式或第三方面的第四种可 能的实施方式或第三方面的第五种可能的实施方式,在第三方面的第六种可能 的实施方式中,所述第一虚拟地址空间处于内核虚拟地址空间或者用户进程虚 拟地址空间。
结合第三方面或第三方面的第一种可能的实施方式或第三方面的第二种 可能的实施方式或第三方面的第三种可能的实施方式或第三方面的第四种可 能的实施方式或第三方面的第五种可能的实施方式或第三方面的第六种可能 的实施方式,在第三方面的第七种可能的实施方式中,在所述获得所述文件标 识所表示的文件的第一索引节点的方面,所述处理器通过所述总线调用所述存 储器中存储的代码以具体用于,当确定所述文件存储内存区之中存储有所述文 件标识所表示的文件 , 获得所述文件标识所表示的文件的第一索引节点。
结合第三方面或第三方面的第一种可能的实施方式或第三方面的第二种 可能的实施方式或第三方面的第三种可能的实施方式或第三方面的第四种可 能的实施方式或第三方面的第五种可能的实施方式或第三方面的第六种可能 的实施方式或第三方面的第七种可能的实施方式,在第三方面的第八种可能的 实施方式中, 所述处理器通过所述总线调用所述存储器中存储的代码以还用 于, 接收用于请求读取所述文件的文件内容的文件读取请求, 其中, 所述文件 读取请求携带有读入内存地址空间和请求读取的所述文件中的第一文件内容 的数据量, 其中, 所述读入内存地址空间为用户进程工作内存区之中的第一内 存区的地址空间;基于所述第一文件内容的数据量、所述第一虚拟地址空间和 所述内存页表记录的所述第一虚实地址映射关系,得到从所述文件存储内存区 读取所述第一文件内容的读取物理地址空间;基于所述读取物理地址空间,从 所述文件存储内存区之中读取出所述文件的第一文件内容;将所述第一文件内 容写入所述第一内存区。
结合第三方面的第八种可能的实施方式,在第三方面的第九种可能的实施 方式中,在所述基于所述第一文件内容的数据量、所述第一虚拟地址空间和所 述内存页表记录的所述第一虚实地址映射关系,得到从所述文件存储内存区读 取所述第一文件内容的读取物理地址空间的方面,所述处理器通过所述总线调 用所述存储器中存储的代码以具体用于,
基于所述第一文件内容的数据量、第一文件内容偏移量、所述第一虚拟地 址空间和所述内存页表记录的所述第一虚实地址映射关系,得到从所述文件存 储内存区读取所述第一文件内容的读取物理地址空间, 其中, 所述第一文件内 容偏移量从所述文件读取请求之中得到, 或者, 所述第一文件内容偏移量从所 述文件对应的文件对象之中得到。
结合第三方面或第三方面的第一种可能的实施方式或第三方面的第二种 可能的实施方式或第三方面的第三种可能的实施方式或第三方面的第四种可 能的实施方式或第三方面的第五种可能的实施方式或第三方面的第六种可能 的实施方式或第三方面的第七种可能的实施方式或第三方面的第八种可能的 实施方式或第三方面的第九种可能的实施方式,在第三方面的第十种可能的实 施方式中, 所述处理器通过所述总线调用所述存储器中存储的代码以还用于, 接收请求向所述文件之中写入文件内容的文件写入请求, 其中, 所述文件写入 请求携带有读出内存地址空间和请求写入所述文件之中的第二文件内容的数 据量, 其中, 所述读出内存地址空间为所述进程工作内存区之中的第二内存区 的地址空间;
基于所述第二文件内容的数据量、所述第一虚拟地址空间和所述内存页表 记录的所述第一虚实地址映射关系,得到向所述文件存储内存区写入所述第二 文件内容的写入物理地址空间, 其中, 所述写入物理地址空间为所述文件存储 内存区之中的第三内存区的物理地址空间;
将所述第二内存区之中緩存的所述第二文件内容写入到所述第三内存区 之中。
结合第三方面的第十种可能的实施方式中,在第三方面的第十一种可能的 实施方式中,
在所述基于所述第二文件内容的数据量、所述第一虚拟地址空间和所述内 存页表记录的所述第一虚实地址映射关系,得到向所述文件存储内存区写入所 述第二文件内容的写入物理地址空间的方面,所述处理器通过所述总线调用所 述存储器中存储的代码以具体用于,
基于所述第二文件内容的数据量、第二文件内容偏移量、所述第一虚拟地 址空间和所述内存页表记录的所述第一虚实地址映射关系,得到向所述文件存 储内存区写入所述第二文件内容的写入物理地址空间, 其中, 所述第二文件内 容偏移量从所述文件写入请求之中得到, 或者, 所述第二文件内容偏移量从所 述文件对应的文件对象之中得到。
结合第三方面的第十种可能的实施方式或第三方面的第十一种可能的实 施方式中,在第三方面的第十二种可能的实施方式中, 所述第三内存区的存储 容量大于或者等于所述第二文件内容的数据量。
结合第三方面或第三方面的第一种可能的实施方式或第三方面的第二种 可能的实施方式或第三方面的第三种可能的实施方式或第三方面的第四种可 能的实施方式或第三方面的第五种可能的实施方式或第三方面的第六种可能 的实施方式或第三方面的第七种可能的实施方式或第三方面的第八种可能的 实施方式或第三方面的第九种可能的实施方式或第三方面的第十种可能的实 施方式或第三方面的第十一种可能的实施方式或第三方面的第十二种可能的 实施方式,在第三方面的第十三种可能的实施方式中, 所述处理器通过所述总 线调用所述存储器中存储的代码以还用于,接收用于请求关闭所述文件的文件 关闭请求; 释放为所述文件分配的第一虚拟地址空间; 释放所述内存页表中记 录的所述第一虚实地址映射关系。
结合第三方面或第三方面的第一种可能的实施方式或第三方面的第二种 可能的实施方式或第三方面的第三种可能的实施方式或第三方面的第四种可 能的实施方式或第三方面的第五种可能的实施方式或第三方面的第六种可能 的实施方式或第三方面的第七种可能的实施方式或第三方面的第八种可能的 实施方式或第三方面的第九种可能的实施方式或第三方面的第十种可能的实 施方式或第三方面的第十一种可能的实施方式或第三方面的第十二种可能的 实施方式或第三方面的第十三种可能的实施方式,在第三方面的第十四种可能 的实施方式中,所述处理器通过所述总线调用所述存储器中存储的代码以还用 所述文件存储内存区之中创建所述文件,为所述文件分配第二索引节点,其中, 所述第二索引节点中记录有第二文件页表或者用于指向第二文件页表的指针, 其中,所述第二文件页表用于指向所述文件存储内存区之中存储所述文件的内 存区; 为所述文件分配第二虚拟地址空间;
利用内存页表记录第二虚实地址映射关系;
其中,所述第二虚实地址映射关系包括所述第二虚拟地址空间与所述第二 物理地址空间之间的映射关系, 其中, 所述第二物理地址空间为所述文件存储 内存区之中存储所述文件的内存区的物理地址空间,所述内存页表包括内核内 存页表和 /或用户进程内存页表。
结合第三方面的第十四种可能的实施方式,在第三方面的第十五种可能的 实施方式中,所述第二文件页表的级数与所述文件的文件类型之间具有对应关 系。
结合第三方面或第三方面的第一种可能的实施方式或第三方面的第二种 可能的实施方式或第三方面的第三种可能的实施方式或第三方面的第四种可 能的实施方式或第三方面的第五种可能的实施方式或第三方面的第六种可能 的实施方式或第三方面的第七种可能的实施方式或第三方面的第八种可能的 实施方式或第三方面的第九种可能的实施方式或第三方面的第十种可能的实 施方式或第三方面的第十一种可能的实施方式或第三方面的第十三种可能的 实施方式或第三方面的第十四种可能的实施方式或第三方面的第十五种可能 的实施方式,在第三方面的第十六种可能的实施方式中, 所述文件存储内存区 包括非易失性内存区和 /或易失性内存区。
本发明实施例第四方面提供一种访问文件的方法, 包括:
接收携带文件标识的文件打开请求;
获得所述文件标识所表示的文件的第一索引节点, 其中, 所述文件存储于 所述文件存储内存区之中;基于所述第一索引节点得到所述文件存储内存区之 中存储所述文件的内存区的第一物理地址空间;
为所述文件分配第一虚拟地址空间;
利用所述内存页表记录第一虚实地址映射关系;
其中,所述第一虚实地址映射关系包括所述第一虚拟地址空间与所述第一 物理地址空间之间的映射关系, 其中, 所述内存页表包括内核内存页表和 /或 用户进程内存页表。 结合第四方面, 在第四方面的第一种可能的实施方式中,
所述基于所述第一索引节点得到所述文件存储内存区之中存储所述文件 的内存区的第一物理地址空间, 包括: 基于所述第一索引节点中记录的第一文 件页表或用于指向第一文件页表的指针,得到所述文件存储内存区之中存储所 述文件的内存区的第一物理地址空间, 其中, 所述第一文件页表用于指向所述 文件存储内存区之中存储所述文件的内存区,所述的第一物理地址空间为所述 表为单级或多级文件页表。
结合第四方面的第一种可能的实施方式,在第四方面的第二种可能的实施 方式中, 所述利用内存页表记录第一虚实地址映射关系, 包括: 在内存页表中 增加用于记录所述第一虚实地址映射关系的表项,所述表项包含所述第一文件 页表或用于指向所述第一文件页表的指针。
结合第四方面的第二种可能的实施方式,在第四方面的第三种可能的实施 方式中, 所述内存页表的总级数为 Y, 所述第一文件页表的总级数为 X, 若所 述表项包含所述第一文件页表, 则所述表项为所述内存页表中的第 Y-X+1级内 存页表中的表项, 若所述表项包含用于指向所述第一文件页表的指针, 则所述 表项为所述内存页表中的第 Y-X级内存页表中的表项,所述 X为正整数,所述 Y 为大于所述 X的正整数。
结合第四方面或第四方面的第一种可能的实施方式或第四方面的第二种 可能的实施方式或第四方面的第三种可能的实施方式,在第四方面的第四种可 能的实施方式中, 所述方法还包括:
在所述第一索引节点中记录所述第一虚拟地址空间和 /或所述第一虚拟地 址空间的起始地址, 和 /或, 在所述文件对应的文件对象之中记录所述第一虚 拟地址空间和 /或所述第一虚拟地址空间的起始地址。
结合第四方面或第四方面的第一种可能的实施方式或第四方面的第二种 可能的实施方式或第四方面的第三种可能的实施方式或第四方面的第四种可 能的实施方式,在第四方面的第五种可能的实施方式中, 所述第一虚拟地址空 间为连续的或者非连续的虚拟地址空间。 结合第四方面或第四方面的第一种可能的实施方式或第四方面的第二种 可能的实施方式或第四方面的第三种可能的实施方式或第四方面的第四种可 能的实施方式或第四方面的第五种可能的实施方式,在第四方面的第六种可能 的实施方式中,所述第一虚拟地址空间处于内核虚拟地址空间或者用户进程虚 拟地址空间。
结合第四方面或第四方面的第一种可能的实施方式或第四方面的第二种 可能的实施方式或第四方面的第三种可能的实施方式或第四方面的第四种可 能的实施方式或第四方面的第五种可能的实施方式或第四方面的第六种可能 的实施方式, 在第四方面的第七种可能的实施方式中,
所述获得所述文件标识所表示的文件的第一索引节点包括:当确定所述文 件存储内存区之中存储有所述文件标识所表示的文件,获得所述文件标识所表 示的文件的第一索引节点。
结合第四方面或第四方面的第一种可能的实施方式或第四方面的第二种 可能的实施方式或第四方面的第三种可能的实施方式或第四方面的第四种可 能的实施方式或第四方面的第五种可能的实施方式或第四方面的第六种可能 的实施方式或第四方面的第七种可能的实施方式,在第四方面的第八种可能的 实施方式中, 所述方法还包括:
接收用于请求读取所述文件的文件内容的文件读取请求, 其中, 所述文件 读取请求携带有读入内存地址空间和请求读取的所述文件中的第一文件内容 的数据量, 其中, 所述读入内存地址空间为用户进程工作内存区之中的第一内 存区的地址空间;
基于所述第一文件内容的数据量、所述第一虚拟地址空间和所述内存页表 记录的所述第一虚实地址映射关系,得到从所述文件存储内存区读取所述第一 文件内容的读取物理地址空间;
基于所述读取物理地址空间,从所述文件存储内存区之中读取出所述文件 的第一文件内容;
将所述第一文件内容写入所述第一内存区。
结合第四方面的第八种可能的实施方式,在第四方面的第九种可能的实施 方式中, 所述基于所述第一文件内容的数据量、所述第一虚拟地址空间和所述 内存页表记录的所述第一虚实地址映射关系,得到从所述文件存储内存区读取 所述第一文件内容的读取物理地址空间, 包括:
基于所述第一文件内容的数据量、第一文件内容偏移量、所述第一虚拟地 址空间和所述内存页表记录的所述第一虚实地址映射关系,得到从所述文件存 储内存区读取所述第一文件内容的读取物理地址空间, 其中, 所述第一文件内 容偏移量从所述文件读取请求之中得到, 或者, 所述第一文件内容偏移量从所 述文件对应的文件对象之中得到。
结合第四方面或第四方面的第一种可能的实施方式或第四方面的第二种 可能的实施方式或第四方面的第三种可能的实施方式或第四方面的第四种可 能的实施方式或第四方面的第五种可能的实施方式或第四方面的第六种可能 的实施方式或第四方面的第七种可能的实施方式或第四方面的第八种可能的 实施方式或第四方面的第九种可能的实施方式,在第四方面的第十种可能的实 施方式中, 所述方法还包括:
接收请求向所述文件之中写入文件内容的文件写入请求, 其中, 所述文件 写入请求携带有读出内存地址空间和请求写入所述文件之中的第二文件内容 的数据量, 其中, 所述读出内存地址空间为所述进程工作内存区之中的第二内 存区的地址空间;
基于所述第二文件内容的数据量、所述第一虚拟地址空间和所述内存页表 记录的所述第一虚实地址映射关系,得到向所述文件存储内存区写入所述第二 文件内容的写入物理地址空间, 其中, 所述写入物理地址空间为所述文件存储 内存区之中的第三内存区的物理地址空间;
将所述第二内存区之中緩存的所述第二文件内容写入到所述第三内存区 之中。
结合第四方面的第十种可能的实施方式中,在第四方面的第十一种可能的 实施方式中, 所述基于所述第二文件内容的数据量、所述第一虚拟地址空间和 所述内存页表记录的所述第一虚实地址映射关系,得到向所述文件存储内存区 写入所述第二文件内容的写入物理地址空间, 包括: 基于所述第二文件内容的数据量、第二文件内容偏移量、所述第一虚拟地 址空间和所述内存页表记录的所述第一虚实地址映射关系,得到向所述文件存 储内存区写入所述第二文件内容的写入物理地址空间, 其中, 所述第二文件内 容偏移量从所述文件写入请求之中得到, 或者, 所述第二文件内容偏移量从所 述文件对应的文件对象之中得到。
结合第四方面的第十种可能的实施方式或第四方面的第十一种可能的实 施方式中,在第四方面的第十二种可能的实施方式中, 所述第三内存区的存储 容量大于或者等于所述第二文件内容的数据量。
结合第四方面或第四方面的第一种可能的实施方式或第四方面的第二种 可能的实施方式或第四方面的第三种可能的实施方式或第四方面的第四种可 能的实施方式或第四方面的第五种可能的实施方式或第四方面的第六种可能 的实施方式或第四方面的第七种可能的实施方式或第四方面的第八种可能的 实施方式或第四方面的第九种可能的实施方式或第四方面的第十种可能的实 施方式或第四方面的第十一种可能的实施方式或第四方面的第十二种可能的 实施方式, 在第四方面的第十三种可能的实施方式中,
所述方法还包括: 接收用于请求关闭所述文件的文件关闭请求; 释放为所 述文件分配的第一虚拟地址空间;释放所述内存页表中记录的所述第一虚实地 址映射关系。
结合第四方面或第四方面的第一种可能的实施方式或第四方面的第二种 可能的实施方式或第四方面的第三种可能的实施方式或第四方面的第四种可 能的实施方式或第四方面的第五种可能的实施方式或第四方面的第六种可能 的实施方式或第四方面的第七种可能的实施方式或第四方面的第八种可能的 实施方式或第四方面的第九种可能的实施方式或第四方面的第十种可能的实 施方式或第四方面的第十一种可能的实施方式或第四方面的第十二种可能的 实施方式或第四方面的第十三种可能的实施方式,在第四方面的第十四种可能 的实施方式中, 所表示的文件,在所述文件存储内存区之中创建所述文件, 为所述文件分配第 二索引节点, 其中, 所述第二索引节点中记录有第二文件页表或者用于指向第 二文件页表的指针, 其中, 所述第二文件页表用于指向所述文件存储内存区之 中存储所述文件的内存区;
为所述文件分配第二虚拟地址空间;
利用内存页表记录第二虚实地址映射关系;
其中,所述第二虚实地址映射关系包括所述第二虚拟地址空间与所述第二 物理地址空间之间的映射关系, 其中, 所述第二物理地址空间为所述文件存储 内存区之中存储所述文件的内存区的物理地址空间,所述内存页表包括内核内 存页表和 /或用户进程内存页表。
结合第四方面的第十四种可能的实施方式,在第四方面的第十五种可能的 实施方式中,所述第二文件页表的级数与所述文件的文件类型之间具有对应关 系。
结合第四方面或第四方面的第一种可能的实施方式或第四方面的第二种 可能的实施方式或第四方面的第三种可能的实施方式或第四方面的第四种可 能的实施方式或第四方面的第五种可能的实施方式或第四方面的第六种可能 的实施方式或第四方面的第七种可能的实施方式或第四方面的第八种可能的 实施方式或第四方面的第九种可能的实施方式或第四方面的第十种可能的实 施方式或第四方面的第十一种可能的实施方式或第四方面的第十三种可能的 实施方式或第四方面的第十四种可能的实施方式或第四方面的第十五种可能 的实施方式,在第四方面的第十六种可能的实施方式中, 所述文件存储内存区 包括非易失性内存区和 /或易失性内存区。
本发明第五方面提供一种计算机存储介质, 其特征在于,
所述计算机存储介质存储有程序,所述程序执行时包括如上述方法实施例 提供的任一种方法的步骤。
可以看出, 本发明一些实施例的技术方案中,操作系统在接收携带文件标 识的文件打开请求后; 获得上述文件标识所表示的文件的第一索引节点, 并基 第一物理地址空间; 为上述文件分配第一虚拟地址空间; 利用内存页表记录第 一虚实地址映射关系; 其中, 上述第一虚实地址映射关系为上述第一虚拟地址 空间与上述第一物理地址空间之间的映射关系,上述内存页表包括内核内存页 来记录第一虚实地址映射关系,可认为是在一定程度上将文件存储内存区之中 存储上述文件的内存区的第一物理地址空间,包装成进程工作内存区之中的某 内存区对应的物理地址空间,这有利于使得内核或用户进程按照类似访问进程 工作内存区的方式来访文件存储内存区中文件,这样有利于实现内核或用户进 程以近似普通内存数据的访问性能来访问常驻内核的文件系统的文件,有利于 极大的提高文件访问性能。可见上述文件访问方案适用于在文件系统常驻内存 场景下进行文件高性能访问。且由于在请求打开文件时才为文件分配虚拟地址 空间, 这样有利于减少系统虚拟地址空间的无效占用和地址沖突可能性,有利 于提高系统虚拟地址空间的利用效率。 附图说明
为了更清楚地说明本发明实施例的技术方案,下面将对实施例描述所需要 使用的附图作筒单地介绍,显而易见地, 下面描述中的附图仅仅是本发明的一 些实施例, 对于本领域普通技术人员来讲, 在不付出创造性劳动的前提下, 还 可以根据这些附图获得其他的附图。
图 1是本发明实施例提供的一种访问文件的方法的流程示意图;
图 2-a是本发明实施例提供的另一种访问文件的方法的流程示意图; 图 2-b是本发明实施例提供的一种计算节点的内存的示意图;
图 2-c是本发明实施例提供的另一种计算节点的内存的示意图;
图 2-d是本发明实施例提供的另一种文件存储内存区的示意图;
图 2-e是本发明实施例提供的一种文件页表和内存页关系的示意图; 图 3是本发明实施例提供的另一种访问文件的方法的流程示意图; 图 4是本发明实施例提供的另一种访问文件的方法的流程示意图; 图 5是本发明实施例提供的另一种访问文件的方法的流程示意图; 图 6是本发明实施例提供的另一种访问文件的方法的流程示意图; 图 7是本发明实施例提供的另一种访问文件的方法的流程示意图; 图 8是本发明实施例提供的另一种访问文件的方法的流程示意图; 图 9-a是本发明实施例提供的一种访问文件的装置的示意图;
图 9-b是本发明实施例提供的另一种访问文件的装置的示意图;
图 9-c是本发明实施例提供的另一种访问文件的装置的示意图;
图 9-d是本发明实施例提供的另一种访问文件的装置的示意图;
图 9-e是本发明实施例提供的另一种访问文件的装置的示意图;
图 10是本发明实施例提供的一种计算节点的示意图;
图 11是本发明实施例提供的另一种计算节点的示意图。 具体实施方式
本发明实施例提供一种访问文件的方法和相关设备,以期适用于在文件系 统常驻内存场景下进行文件访问。
下面通过具体实施例, 分别进行详细的说明。
为使得本发明的发明目的、 特征、 优点能够更加的明显和易懂, 下面将结 合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、 完整地描 述, 显然, 下面所描述的实施例仅仅是本发明一部分实施例, 而非全部的实施 例。基于本发明中的实施例, 本领域普通技术人员在没有做出创造性劳动前提 下所获得的所有其它实施例, 都属于本发明保护的范围。
本发明的说明书和权利要求书及上述附图中的术语 "第一"、 "第二"、 "第 三" "第四" 等是用于区别不同的对象, 而不是用于描述特定顺序。 此外, 术 语 "包括" 和 "具有" 以及它们任何变形, 意图在于覆盖不排他的包含。 例如 包含了一系列步骤或单元的过程、 方法、 系统、 产品或设备没有限定于已列出 的步骤或单元, 而是可选地还包括没有列出的步骤或单元, 或可选地还包括对 于这些过程、 方法、 产品或设备固有的其它步骤或单元。
本发明一种访问文件的方法的一个实施例, 其中, 上述访问文件的方法应 用于计算节点中, 其中, 上述计算节点可包括内存, 上述内存包括: 文件存储 内存区和进程工作内存区, 上述进程工作内存区存储有内核内存页表, 上述进 程工作内存区之中运行有操作系统, 上述访问文件的方法可包括: 操作系统接 收携带文件标识的文件打开请求;操作系统获得上述文件标识所表示的文件的 第一索引节点, 其中, 上述文件存储于文件存储内存区之中; 操作系统基于上 物理地址空间; 操作系统为上述文件分配第一虚拟地址空间; 操作系统利用上 述内存页表记录第一虚实地址映射关系; 其中, 上述第一虚实地址映射关系包 括上述第一虚拟地址空间与上述第一物理地址空间之间的映射关系, 其中, 上 举例来说,上述进程工作内存区可包括内核进程工作内存区和用户进程工 作内存区, 其中, 内核内存页表可存储于内核进程工作内存区, 用户进程内存 页表可存储于上述用户进程工作内存区。例如上述内核进程工作内存区之中运 行有操作系统。
请参见图 1 ,图 1为本发明的一个实施例提供的一种访问文件的方法的流程 示意图。 如图 1所示, 本发明的一个实施例提供的一种访问文件的方法可包括 以下内容:
101、 操作系统接收携带文件标识的文件打开请求。
其中, 上述接收携带文件标识的文件打开请求可包括: 接收来自用户进程 的携带文件标识的文件打开请求。
在本发明一些实施例中, 上述文件打开请求可以携带文件存储路径 (即请 求打开的文件的存储路径), 其中, 上述文件标识可包含在上述文件存储路径 之中, 当然, 上述文件打开请求中也可能携带文件标识并且可不携带文件存储 路径。 进一步的, 上述文件打开请求中还可携带文件类型标志位, 该文件类型 标志位可指示出上述文件标识所表示的文件的文件类型(文件类型可能是目录 文件或数据文件)。
102、 操作系统获得上述文件标识所表示的文件的第一索引节点, 基于上 物理地址空间。 其中, 上述文件存储于文件存储内存区之中。
在本发明的一些实施例中,上述获得上述文件标识所表示的文件的第一索 的文件, 获得上述文件标识所表示的文件的第一索引节点。 当然, 也可以默认 上述文件存储内存区之中存储有上述文件标识所表示的文件,而在这种场景下 则可以省略执行确定上述文件存储内存区之中是否存储有上述文件标识所表 示的文件的步骤。
在本发明的一些实施例中, 内存可以包括: 进程工作内存区(其中, 进程 工作内存区可以包括用户进程工作内存区和内核进程工作内存区)和文件存储 内存区。 其中, 进程工作内存区是指, 用于存放进程运行时的工作环境所包含 的数据结构和变量等内容的物理内存区域。 其中, 上述数据结构和变量可包括 如下信息的至少一种: 进程运行时的堆、 栈、 内存映射区、 进程所对应的程序 的变量、 字符和数组等数据。
举例来说, 用户进程工作内存区可以是指, 用于存放用户进程运行时的工 作环境所包含的数据结构和变量等内容的物理内存区域。 其中, 用户进程工作 内存区存放的上述数据结构和变量例如可包括如下信息的至少一种:用户进程 运行时的堆、 栈、 内存映射区、 用户进程所对应的程序的变量、 字符和数组等 数据。
又举例来说, 内核进程工作内存区可以是指, 用于存放内核进程运行时的 工作环境所包含的数据结构和变量等内容的物理内存区域。其中, 内核进程工 作内存区存放的上述数据结构和变量例如可包括如下信息的至少一种:内核进 程运行时的堆、 栈、 内存映射区、 内核进程所对应的程序的变量、 字符和数组 等数据。
其中, 文件存储内存区可指用于存储文件系统的物理内存区域, 文件存储 内存区中可存放文件系统本身的各种信息, 例如, 文件存储内存区中可存放文 件系统的索引节点和文件, 还可进一步存放文件系统的超级块(若存在)等等 信息。
在本发明一些实施例中, 上述文件存储内存区可包括非易失性内存区和 / 或易失性内存区 (即, 文件存储内存区的存储介质包括非易失性存储介质和 / 或易失性存储介质)。 其中, 进程工作内存区 (如内核进程工作内存区、 用户 进程工作内存区)可包括非易失性内存区和 /或易失性内存区 (即进程工作内 存区的存储介质包括非易失性存储介质和 /或易失性存储介质)。 其中, 进程工 作内存区(如内核进程工作内存区、 用户进程工作内存区)和文件存储内存区 互不重叠。
其中,文件的索引节点中可包含能够得出文件存储内存区之中存储该文件 的内存区的物理地址空间的信息。例如, 上述文件的第一索引节点中可记录第 一文件页表(FPT, File Page Table )或用于指向第一文件页表的指针, 上述第 一文件页表为单级或多级文件页表, 其中, 第一物理地址空间为上述文件存储 内存区之中存储上述文件的内存区的物理地址空间。 当然, 第一索引节点也可 空间或第一物理地址空间的起始地址等。进一步的, 上述文件的第一索引节点 中还可包含该文件的元数据等信息。
103、 操作系统为上述文件分配第一虚拟地址空间。
在本发明的一些实施例中,可以为上述文件分配预设大小的第一虚拟地址 空间(例如第一虚拟地址空间的大小可小于或等于系统最大虚拟地址空间除以 系统支持同时打开的最多文件个数)。 或也可根据上述文件的文件类型, 为上 述文件分配与该文件类型对应大小的第一虚拟地址空间。 例如, 目录文件对应 的虚拟地址空间和数据文件对应的虚拟地址空间的大小可不相等,例如目录文 件对应的虚拟地址空间大小可小于数据文件对应的虚拟地址空间的大小,例如 目录文件对应的虚拟地址空间大小为 1MB、 2MB、 10MB或 30MB等, 数据文 件对应的虚拟地址空间大小为 100MB、 500MB、 1GB、 10GB, 100GB或者 2TB 等等。
104、 操作系统利用内存页表记录第一虚实地址映射关系。
其中,上述第一虚实地址映射关系包括上述第一虚拟地址空间与上述第一 物理地址空间之间的映射关系, 其中, 上述内存页表包括内核内存页表和 /或 用户进程内存页表。
由上可见,操作系统在接收携带文件标识的文件打开请求之后; 获得上述 文件标识所表示的文件的第一索引节点 ,并基于上述第一索引节点得到上述文 件存储内存区之中存储上述文件的内存区的第一物理地址空间;为上述文件分 配第一虚拟地址空间; 利用内存页表记录第一虚实地址映射关系; 其中, 上述 第一虚实地址映射关系为上述第一虚拟地址空间与上述第一物理地址空间之 于是利用内核内存页表和 /或用户进程内存页表来记录第一虚实地址映射关 一物理地址空间, 包装成进程工作内存区之中的某内存区对应的物理地址空 间,这有利于使得内核或用户进程按照类似访问进程工作内存区的方式来访文 件存储内存区中文件,这样有利于实现内核或用户进程以近似普通内存数据的 访问性能来访问常驻内核的文件系统的文件, 有利于极大的提高文件访问性 能。可见上述文件访问方案适用于在文件系统常驻内存场景下进行文件高性能 访问。 并且, 由于是在请求打开文件时才为文件分配虚拟地址空间, 这样有利 于减少系统虚拟地址空间的无效占用和地址沖突可能性,有利于提高系统虚拟 地址空间的利用效率。
在本发明的一些实施例中,若接收到来自用户进程的携带文件标识的文件 打开请求, 则可创建与该文件和该用户进程对应的文件对象, 并可在利用内存 页表记录第一虚实地址映射关系之后,向该用户进程反馈上述文件的文件描述 付寺。
在本发明的一些实施例中,上述利用内存页表记录第一虚实地址映射关系 可以包括: 在内存页表中增加用于记录上述第一虚实地址映射关系的表项(可 能为一个或多个表项), 其中, 上述表项包含上述第一文件页表或用于指向上 述第一文件页表的指针。 例如, 上述内存页表的总级数为 Y, 上述第一文件页 表的总级数为 X, 若上述表项包含上述第一文件页表, 则上述表项可为上述内 存页表中的第 Y-X+1级内存页表之中的表项, 若上述表项包含用于指向上述第 一文件页表的指针, 则上述表项可为上述内存页表中的第 Y-X级内存页表之中 的表项, 其中, 上述 X为正整数, 上述 Y为大于上述 X的正整数。 其中, 在一 些特殊应用场景下,在内存页表中增加的用于记录上述第一虚实地址映射关系 的表项(可能为一个或多个表项)也可以是内存页表中的任意一级内存页表之 中的表项。 在本发明另一些实施例中,上述利用内存页表记录第一虚实地址映射关系 可包括: 在内存页表中增加用于记录上述第一虚实地址映射关系的表项(可能 为一个或多个表项), 其中, 该表项包含第一物理地址空间或该表项可包含第 一物理地址空间的起始地址和 /或结束地址, 例如该表项可为最低一级内存页 表之中的表项或可为任意一级内存页表之中的表项。
在本发明的一些实施例中,还可进一步在上述第一索引节点中记录上述第 一虚拟地址空间、上述第一虚拟地址空间的起始地址和上述第一虚拟地址空间 的结束地址之中的至少一个, 和 /或, 还可在上述文件对应的文件对象之中记 录上述第一虚拟地址空间、上述第一虚拟地址空间的起始地址和上述第一虚拟 地址空间的结束地址之中的至少一个。
在本发明的一些实施例中,上述第一虚拟地址空间为连续的或者非连续的 虚拟地址空间。在本发明一些实施例中, 上述第一虚拟地址空间处于内核虚拟 地址空间或者上述第一虚拟地址空间处于用户进程虚拟地址空间。
其中, 当文件被打开之后, 可以对文件进行读 /写等操作。
举例来说,访问文件的方法还可进一步包括: 操作系统接收用于请求读取 上述文件的文件内容的文件读取请求, 其中, 上述文件读取请求携带有读入内 存地址空间和请求读取的上述文件中的第一文件内容的数据量(此外, 上述文 件读取请求还可以携带上述文件的文件描述符), 其中, 上述读入内存地址空 间为用户进程工作内存区之中的第一内存区的地址空间;基于上述第一文件内 容的数据量、上述第一虚拟地址空间和上述内存页表记录的上述第一虚实地址 映射关系,得到从上述文件存储内存区中读取上述第一文件内容的读取物理地 址空间;基于上述读取物理地址空间,从上述文件存储内存区之中读取出上述 文件的第一文件内容; 将上述第一文件内容写入上述第一内存区(基于上述读 入内存地址空间将上述第一文件内容写入上述第一内存区)。
在本发明的一些实施例中, 上述基于上述第一文件内容的数据量、上述第 一虚拟地址空间和上述内存页表记录的上述第一虚实地址映射关系,得到从上 述文件存储内存区读取上述第一文件内容的读取物理地址空间, 可包括: 基于 上述第一文件内容的数据量、第一文件内容偏移量、上述第一虚拟地址空间和 上述内存页表记录的上述第一虚实地址映射关系,得到从上述文件存储内存区 读取上述第一文件内容的读取物理地址空间, 其中, 上述第一文件内容偏移量 从上述文件读取请求之中得到, 或者, 上述第一文件内容偏移量从上述文件对 应的文件对象之中得到。
例如, 可基于第一文件内容偏移量(其中, 若未从上述文件读取请求从上 述文件对应的文件对象之中得到第一文件内容偏移量,则可将默认文件内容偏 移量作为第一文件内容偏移量 )和上述第一虚拟地址空间的起始地址,得到读 取上述第一文件内容的起始读取虚拟地址;利用上述起始读取虚拟地址和第一 虚实地址映射关系,得到从上述文件存储内存区读取上述第一文件内容的起始 读取物理地址;基于上述起始读取物理地址和第一文件内容的数据量,得到从 上述文件存储内存区读取上述第一文件内容的读取物理地址空间。
又例如, 可基于第一文件内容偏移量(其中, 若未从上述文件读取请求从 上述文件对应的文件对象之中得到第一文件内容偏移量,则可将默认文件内容 偏移量作为第一文件内容偏移量 )和上述第一虚拟地址空间的起始地址,得到 读取上述第一文件内容的起始读取虚拟地址;基于起始读取虚拟地址和第一文 件内容的数据量,得到读取上述第一文件内容的读取虚拟地址空间; 利用上述 读取虚拟地址空间和第一虚实地址映射关系,得到从上述文件存储内存区读取 上述第一文件内容的读取物理地址空间。
举例来说,访问文件的方法还可以进一步包括: 接收请求向上述文件之中 写入文件内容的文件写入请求, 其中, 上述文件写入请求携带有读出内存地址 空间和请求写入上述文件之中的第二文件内容的数据量(此外, 上述文件写入 请求还可以携带上述文件的文件描述符), 其中, 上述读出内存地址空间为上 述进程工作内存区之中的第二内存区的地址空间;基于上述第二文件内容的数 据量、上述第一虚拟地址空间和上述内存页表记录的上述第一虚实地址映射关 系, 得到向上述文件存储内存区写入上述第二文件内容的写入物理地址空间, 其中,上述写入物理地址空间为上述文件存储内存区之中的第三内存区的物理 地址空间;将上述第二内存区之中緩存的上述第二文件内容写入到上述第三内 存区之中。 在本发明的一些实施例中,基于上述第二文件内容的数据量、上述第一虚 拟地址空间和上述内存页表记录的上述第一虚实地址映射关系,得到向上述文 件存储内存区写入上述第二文件内容的写入物理地址空间, 可包括: 基于上述 第二文件内容的数据量、第二文件内容偏移量、上述第一虚拟地址空间和上述 内存页表记录的上述第一虚实地址映射关系,得到向上述文件存储内存区写入 上述第二文件内容的写入物理地址空间, 其中, 上述第二文件内容偏移量从上 述文件写入请求之中得到, 或者, 上述第二文件内容偏移量从上述文件对应的 文件对象之中得到。
例如, 可基于第二文件内容偏移量(其中, 若未从上述文件写入请求从上 述文件对应的文件对象之中得到第二文件内容偏移量,则可将默认文件内容偏 移量作为第二文件内容偏移量 )和上述第一虚拟地址空间的起始地址,得到向 上述文件写入上述第二文件内容的起始写入虚拟地址;利用上述起始写入虚拟 地址和第一虚实地址映射关系,得到向从上述文件存储内存区的上述文件中写 入上述第二文件内容的起始写入物理地址;基于上述起始写入物理地址和第二 文件内容的数据量,得到向上述文件存储内存区的上述文件中写入上述第二文 件内容的写入物理地址空间。
又例如, 可基于第二文件内容偏移量(其中, 若未从上述文件写入请求从 上述文件对应的文件对象之中得到第二文件内容偏移量,则可将默认文件内容 偏移量作为第二文件内容偏移量 )和上述第一虚拟地址空间的起始地址,得到 向上述文件中上述第二文件内容的起始写入虚拟地址;基于起始写入虚拟地址 和第二文件内容的数据量,得到向上述文件存储内存区的上述文件中写入上述 第二文件内容的写入虚拟地址空间;利用上述写入虚拟地址空间和第一虚实地 的写入物理地址空间。
其中,上述第三内存区的存储容量可以大于或者等于上述第二文件内容的 数据量。其中, 第三内存区和上述第一物理地址空间对应的内存区具有交集或 没有交集。 可以理解的是, 在通常情况下, 若第三内存区和上述第一物理地址 空间对应的内存区具有交集,则可以表示用第二文件内容替换了上述文件中原 有的部分或者全部文件内容(若第三内存区和上述第一物理地址空间对应的内 存区的交集小于第三内存区,表示为第二文件内容分配了新的内存区, 即存储 上述文件的内存区发生了变化, 存储上述文件的内存区被扩容了)。 若第三内 存区和上述第一物理地址空间对应的内存区没有交集,则可以表示上述文件中 新增了第二文件内容, 第三内存区是为第二文件内容分配了新内存区, 即存储 上述文件的内存区发生了变化, 存储上述文件的内存区被扩容了。 新第一文件页表,以使得更新后的第一文件页表指向文件存储内存区中当前存 储上述文件的内存区。
当然, 进一步的, 可将上述内存页表中记录的上述第一虚实地址映射关系 更新为第三虚实地址映射关系,上述第三虚实地址映射关系包括上述第一虚拟 地址空间与上述第三物理地址空间之间的映射关系,上述第三物理地址空间为 文件存储内存区中当前存储上述文件的内存区的物理地址空间。其中, 若内存 页表中记录的是指向第一文件页表的指针(例如内存页表中记录的第一文件页 表的起始物理地址), 若更新后的第一文件页表的起始物理地址未变化, 则也 可不修改内存页表中记录的是指向第一文件页表的指针。 而在这种情况下, 更 新第一文件页表而无需修改内存页表, 即可重建虚实地址映射关系,极大的筒 化了映射操作。
在本发明一些实施例中,访问文件的方法还可进一步包括: 操作系统接收 用于请求关闭上述文件的文件关闭请求;释放为上述文件分配的第一虚拟地址 空间; 释放上述内存页表中记录的上述第一虚实地址映射关系。 进一步的, 若 创建了上述文件对应的文件对象,则还可以进一步释放上述文件对应的文件对 象等。
在本发明的一些实施例中,接收携带文件标识的文件打开请求之后, 当确 定上述文件存储内存区之中未存储有上述文件标识所表示的文件,在上述文件 存储内存区之中创建上述文件, 为上述文件分配第二索引节点。 其中, 上述第 二索引节点中可记录有第二文件页表或者用于指向第二文件页表的指针(用于 指向第二文件页表的指针可以是第二文件页表的起始物理地址;), 上述第二文 分配第二虚拟地址空间; 利用内存页表记录第二虚实地址映射关系; 其中, 上 述第二虚实地址映射关系可包括上述第二虚拟地址空间与上述第二物理地址 空间之间的映射关系, 其中, 第二物理地址空间为上述文件存储内存区之中存 储上述文件的内存区的物理地址空间, 其中, 上述内存页表包括内核内存页表 和 /或用户进程内存页表。 可选的, 上述第二文件页表的级数与上述文件的文 件类型之间具有对应关系, 其中, 上述文件的文件类型例如可通过上述文件打 开请求中携带的上述文件的文件类型标志位确定,当然也可以通过其它方式来 确定上述文件的文件类型。
在本发明另一些实施例中,接收携带文件标识的文件打开请求之后, 当确 定上述文件存储内存区中未存储有上述文件标识所表示的文件,在上述文件存 储内存区之中创建上述文件, 为上述文件分配第三索引节点, 此时可先不创建 该文件的文件页表或创建该文件的空文件页表(其中, 若创建该文件的空文件 页表,则第三索引节点中可包含上述空文件页表或者用于指向上述空文件页表 的指针), 当需要向创建的上述文件中写入文件内容时, 可扩容存储上述文件 的内存区 (如从 10MB扩容至 1000MB ), 更新上述文件的文件页表以使得更新 后的文件页表指向扩容之后的存储上述文件的内存区。
在本发明一些实施例中, 文件页表与内存页表的数据结构类似或相同。 其中, 上述操作的执行主体可为操作系统(具体可为操作系统之中的内核 文件系统)等。
可以看出, 本实施例的上述技术方案之中,在接收携带文件标识的文件打 开请求之后; 获得上述文件标识所表示的文件的第一索引节点, 并基于上述第 地址空间; 为上述文件分配第一虚拟地址空间; 利用内存页表记录第一虚实地 址映射关系; 其中, 上述第一虚实地址映射关系为上述第一虚拟地址空间与上 述第一物理地址空间之间的映射关系, 其中, 上述内存页表包括内核内存页表 和 /或用户进程内存页表。 由于是利用内核内存页表和 /或用户进程内存页表来 记录第一虚实地址映射关系,可认为是在一定程度上将文件存储内存区之中存 储上述文件的内存区的第一物理地址空间,包装成进程工作内存区之中的某内 存区对应的物理地址空间,这有利于使得内核或用户进程按照类似访问进程工 作内存区的方式来访文件存储内存区中文件,这样有利于实现内核或用户进程 以近似普通内存数据的访问性能来访问常驻内核的文件系统的文件,有利于极 大的提高文件访问性能。可见, 上述文件访问方案比较适用于在文件系统常驻 内存场景下进行文件高性能访问。 并且, 由于是在请求打开文件时才为文件分 配虚拟地址空间,这样有利于减少系统虚拟地址空间的无效占用和地址沖突可 能性, 有利于提高系统虚拟地址空间的利用效率。
进一步的, 由于在打开文件过程中可为文件分配连续虚拟地址空间, 因此 有利于实现从读写文件的起始虚拟地址开始,一次性访问所需读写长度之内的 内存页, 而不需要在软件层面多次查找不同内存页的对应虚拟地址, 这样文件 顺序访问速度可以非常快。
借助存储器管理单元(MMU, Memory Management Unit )可透明地完成 文件的虚拟地址和物理地址之间的转换, 这有利于加快文件访问速度快、甚至 实现零开销。
进一步的,若采用数据结构与内存页表类似或相同的文件页表来指向文件 存储内存区中存储文件内容的内存页,由于文件页表与内存页表的数据结构类 似或相同,有利于实现页表数据结构的零转换, 并且当存储文件内容的内存页 发生变化时也可能无需对文件页表执行重建文件物理地址空间与虚拟地址空 间的映射关系的操作,通过更新文件页表,将用于指向更新的文件页表的指针 插入文件页表的表项中, 进而完成重建文件物理地址与虚拟地址的映射, 这种 方式有利于在与文件大小无关的常数时间之内,重建文件物理地址与虚拟地址 的映射。
进一步的, 由于可以为不同的文件分配独立的虚拟地址空间,使得文件系 统在文件存储内存区的文件受系统虚拟地址和 MMU的保护, 极大的减少被误 写的可能性, 不仅可以良好的保护文件, 且不需要额外的写保护机制, 有利于 筒化系统。
进一步的, 由于是通过虚拟地址访问文件, 文件的大小只受系统虚拟地址 空间的大小, 以及操作系统支持的同时打开的文件数量的影响, 这两者都不是 文件系统本身的限制, 因此文件大小可不受文件系统本身设计限制。
进一步的, 文件系统采用与内存管理相似的方式,都是通过虚拟地址访问 存储介质, 且都可利用 MMU进行虚拟地址和物理地址的转换, 对内核的改动 可以相对较少, 这样也便于文件系统移植到现有的操作系统中。 为便于更好的理解和实施本发明实施例的上述方案,下面通过一些具体是 应用场景进行举例介绍。
请参见图 2-a , 图 2-a为本发明另一个实施例提供的另一种访问文件的方法 的流程示意图。其中, 本发明另一个实施例提供的另一种访问文件的方法可包 括以下内容:
201、 操作系统接收来自用户进程(下面称之为用户进程 A ) 的携带文件 标识的文件打开请求。
在本发明一些实施例中, 上述文件打开请求可以携带文件存储路径 (即请 求打开的文件的存储路径), 其中, 上述文件标识可包含在上述文件存储路径 之中, 当然, 上述文件打开请求中也可能携带文件标识并且可不携带文件存储 路径。 进一步的, 上述文件打开请求中还可携带文件类型标志位, 该文件类型 标志位可指示出上述文件标识所表示的文件的文件类型(文件类型可能是目录 文件或数据文件)。
202、 操作系统创建上述文件标识所表示的文件 (该文件下面称之为文件 F1 )对应的文件对象, 为文件 F1分配文件描述符。 其中, 基于文件 F1的文件 描述符可找到文件 F1的文件对象。
203、 操作系统确定上述文件存储内存区之中是否存储有文件 F1。
若是, 则执行步骤 204。
若否, 则操作系统可向用户进程 A反馈文件打开失败指令。
204、 操作系统获得上述文件 F1的第一索引节点, 其中, 上述文件存储于 文件存储内存区之中,上述文件 F1的第一索引节点也存储于文件存储内存区之 中。
例如图 2-b所示, 图 2-b举例示出了一种计算节点的内存示意图, 计算节点 的内存可包括用户进程工作内存区 S 1、内核进程工作内存区 S2和文件存储内存 区 S3等。
举例来说,用户进程工作内存区 S1可以是指,用于存放用户进程运行时的 工作环境所包含的数据结构和变量等内容的物理内存区域。其中, 用户进程工 作内存区存放的上述数据结构和变量例如可包括如下信息的至少一种:用户进 程运行时的堆、 栈、 内存映射区、 用户进程所对应的程序的变量、 字符和数组 等数据。
又举例来说, 内核进程工作内存区 S2可以是指,用于存放内核进程运行时 的工作环境所包含的数据结构和变量等内容的物理内存区域。其中, 内核进程 工作内存区存放的上述数据结构和变量例如可包括如下信息的至少一种:内核 进程运行时的堆、 栈、 内存映射区、 内核进程所对应的程序的变量、 字符和数 组等数据。
在本发明一些实施例中,上述文件存储内存区 S3可包括非易失性内存区和 /或易失性内存区 (即文件存储内存区 S3的存储介质包括非易失性存储介质和 / 或易失性存储介质)。 进程工作内存区 (如内核进程工作内存区 S2、 用户进程 工作内存区 S1 )可包括非易失性内存区和 /或易失性内存区 (即进程工作内存 区的存储介质包括非易失性存储介质和 /或易失性存储介质)。 其中, 进程工作 内存区(如内核进程工作内存区 S2、用户进程工作内存区 S 1 )和文件存储内存 区互不重叠。 例如图 2-c举例所示, 在本发明一些实施例中, 用户进程工作内 存区 S1和内核进程工作内存区 S2可位于 DRAM中, 而文件存储内存区 S3可位 于 NVM中。
其中,文件存储内存区 S3可指用于存储文件系统的物理内存区域,文件存 储内存区中可存放文件系统本身的各种信息, 例如, 文件存储内存区中可存放 文件系统的索引节点和文件, 还可进一步存放文件系统的超级块(若存在)等 等信息。 例如图 2-d举例所示, 文件存储内存区 S3可包括超级块、 用于存储文 件索引节点的索引节点区和用于存储文件的文件数据区。
在本发明的一些实施例中,文件 F1的第一索引节点中可记录用于指向第一 文件页表的指针(用于指向第一文件页表的指针可包括第一文件页表的起始物 理地址), 其中, 上述第一文件页表用于指向文件存储内存区 S3之中存储文件 F1的内存区,第一物理地址空间为上述文件存储内存区之中存储上述文件的内 存区的物理地址空间。 上述第一文件页表为单级或多级文件页表。
其中,本发明实施例中用数据结构类似或等同于内存页表的文件页表来组 织用于存储单个文件的内存页, 文件页表可是一级或多级文件页表。 非最低一 级文件页表中的每一级文件页表的每个表项记录下一级的某文件页表的起始 物理地址。而最低一级文件页表的每个表项记录存储了文件的某内存页的起始 物理地址。 如图 2-e所示, 图 2-e举例第一文件页表为一个三级文件页表, 分别 是 PUD、 PMD和 PTE三级, 其中, PUD中的每一个表项都记录一个 PMD的起始 物理地址, 而各个 PMD的每个表项都记录一个 PTE的起始物理地址, PTE的每 一个表项都记录一个内存页(其中, 内存页存储文件 F1的文件内容)的起始物 理地址。 可以理解的是, 并不是每一个文件都需要使用三级文件页表, 即便是 使用三级页表,也不一定有固定的格式, 例如不一定每个文件都需要使用 1024 个 PTE, 可以根据文件的大小变化动态调整文件页表组织架构。 例如, 第一索 引节点中可记录指向三级文件页表的第一级文件页表 PUD的指针(如 PUD的起 始物理地址;)。
其中, 每个文件都对应一个索引节点(inode ), 例如第一索引节点中包含 用于指向文件页表的指针(Pointer ), 该指针具体存放文件 Fl的最高一级文件 页表( PUD )所属物理内存页的起始物理地址。
其中, 文件 F1的第一索引节点中还可包含文件 F1的元数据, 文件 F1的元 数据中包含文件 F1的属性信息(如文件大小、 文件类型、 文件修改时间、 文件 创建时间等)
可以理解的是,由于每个文件的文件页表都储存在文件存储内存区的文件 数据区。由于文件存储内存区字节可寻址的特性和文件页表的基于链表的组织 形式, 文件页表并不需要放置在固定区域。 只要当作一般的文件存放在文件数 据区域中即可。
205、 操作系统基于上述第一索引节点得到上述文件存储内存区之中存储 文件 F1的内存区的第一物理地址空间。 由于第一索引节点中包含用于指向文件 Fl的第一文件页表的指针,因此基 于上述第一索引节点可以得到用于指向文件 F1的第一文件页表的指针,而得到 用于指向文件 F1的第一文件页表的指针,可得到文件 F1的第一文件页表,进而 可以基于文件 F1的第一文件页表, 得到上述文件存储内存区之中存储文件 F1 的内存区的第一物理地址空间。
206、 操作系统为上述文件分配第一虚拟地址空间。
在本发明的一些实施例中,可以为上述文件分配预设大小的第一虚拟地址 空间(例如第一虚拟地址空间的大小可小于或等于系统最大虚拟地址空间除以 系统支持同时打开的最多文件个数)。 或也可根据上述文件的文件类型, 为上 述文件分配与该文件类型对应大小的第一虚拟地址空间。 例如, 目录文件对应 的虚拟地址空间和数据文件对应的虚拟地址空间的大小可不相等,例如目录文 件对应的虚拟地址空间大小可小于数据文件对应的虚拟地址空间的大小,例如 目录文件对应的虚拟地址空间大小为 1MB、 2MB、 10MB或 30MB等, 数据文 件对应的虚拟地址空间大小为 100MB、 500MB、 1GB、 10GB, 100GB或者 2TB 等等。
207、 操作系统利用内存页表记录第一虚实地址映射关系。
其中,上述第一虚实地址映射关系为上述第一虚拟地址空间与上述第一物 理地址空间之间的映射关系, 其中, 上述内存页表包括内核内存页表和 /或用 户进程内存页表。
其中,在本发明的一些实施例中, 上述利用内存页表记录第一虚实地址映 射关系可以包括:在内存页表中增加用于记录上述第一虚实地址映射关系的表 项 (可能为一个或多个表项), 其中, 上述表项包含用于指向上述第一文件页 表的指针(用于指向上述第一文件页表的指针可以包括上述第一文件页表的起 始物理地址)。 举例来说, 上述内存页表的总级数为 Y, 上述第一文件页表的 总级数为 X, 若上述表项包含上述第一文件页表, 则上述表项可为上述内存页 表中的第 Y-X+1级内存页表之中的表项, 若上述表项包含用于指向上述第一文 件页表的指针, 则上述表项可以为上述内存页表中的第 Y-X级内存页表之中的 表项, 其中, 上述 X为正整数, 上述 Y为大于上述 X的正整数。 其中, 在一些 特殊应用场景下,在内存页表中增加的用于记录上述第一虚实地址映射关系的 表项(可能为一个或多个表项)也可以是内存页表中的任意一级内存页表之中 的表项。
在本发明的一些实施例中,还可进一步在上述第一索引节点中记录上述第 一虚拟地址空间、上述第一虚拟地址空间的起始地址和上述第一虚拟地址空间 的结束地址之中的至少一个, 和 /或, 还可在上述文件对应的文件对象之中记 录上述第一虚拟地址空间、上述第一虚拟地址空间的起始地址和上述第一虚拟 地址空间的结束地址之中的至少一个。
在本发明的一些实施例中,上述第一虚拟地址空间为连续的或者非连续的 虚拟地址空间。在本发明一些实施例中, 上述第一虚拟地址空间处于内核虚拟 地址空间或者上述第一虚拟地址空间处于用户进程虚拟地址空间。
208、 操作系统向用户进程 A反馈文件 F1的文件描述符号。
用户进程 A可基于文件 F1的文件描述符号发起对文件 F1的读写操作。 可以看出, 本实施例的上述技术方案之中,在接收携带文件标识的文件打 开请求之后;可以判断文件存储内存区之中是否存储有上述文件标识所表示的 文件; 若上述文件存储内存区之中存储有上述文件, 则获得上述文件的第一索 引节点,并基于上述第一索引节点得到上述文件存储内存区之中存储上述文件 的内存区的第一物理地址空间; 为上述文件分配第一虚拟地址空间; 利用内存 页表记录第一虚实地址映射关系; 其中, 上述第一虚实地址映射关系为上述第 一虚拟地址空间与上述第一物理地址空间之间的映射关系, 其中, 上述内存页 表包括内核内存页表和 /或用户进程内存页表。 由于是利用内核内存页表和 /或 用户进程内存页表来记录第一虚实地址映射关系,可认为是在一定程度上将文 件存储内存区之中存储上述文件的内存区的第一物理地址空间,包装成进程工 作内存区之中的某内存区对应的物理地址空间,这有利于使得内核或用户进程 实现内核或用户进程以近似普通内存数据的访问性能来访问常驻内核的文件 系统的文件, 有利于极大的提高文件访问性能。 可见, 上述文件访问方案比较 适用于在文件系统常驻内存场景下进行文件高性能访问。 并且, 由于是在请求 打开文件时才为文件分配虚拟地址空间,这样有利于减少系统虚拟地址空间的 无效占用和地址沖突可能性, 有利于提高系统虚拟地址空间的利用效率。
进一步的, 由于在打开文件过程中可为文件分配连续虚拟地址空间, 因此 有利于实现从读写文件的起始虚拟地址开始,一次性访问所需读写长度之内的 内存页, 而不需要在软件层面多次查找不同内存页的对应虚拟地址, 这样文件 顺序访问速度可以非常快。
借助 MMU可透明地完成文件的虚拟地址和物理地址之间的转换, 这有利 于加快文件访问速度快、 甚至实现零开销。
进一步的,若采用数据结构与内存页表类似或相同的文件页表来指向文件 存储内存区中存储文件内容的内存页,由于文件页表与内存页表的数据结构类 似或相同,有利于实现页表数据结构的零转换, 并且当存储文件内容的内存页 发生变化时也可能无需对文件页表执行重建文件物理地址空间与虚拟地址空 间的映射关系的操作,通过更新文件页表,将用于指向更新的文件页表的指针 插入文件页表的表项中, 进而完成重建文件物理地址与虚拟地址的映射, 这种 方式有利于在与文件大小无关的常数时间之内,重建文件物理地址与虚拟地址 的映射。
进一步的, 由于可以为不同的文件分配独立的虚拟地址空间,使得文件系 统在文件存储内存区的文件受系统虚拟地址和 MMU的保护, 极大的减少被误 写的可能性, 不仅可以良好的保护文件, 且不需要额外的写保护机制, 有利于 筒化系统。
进一步的, 由于是通过虚拟地址访问文件, 文件的大小只受系统虚拟地址 空间的大小, 以及操作系统支持的同时打开的文件数量的影响, 这两者都不是 文件系统本身的限制, 因此文件大小可不受文件系统本身设计限制。
进一步的, 文件系统采用与内存管理相似的方式,都是通过虚拟地址访问 存储介质, 且都可利用 MMU进行虚拟地址和物理地址的转换, 对内核的改动 可以相对较少, 这样也便于文件系统移植到现有的操作系统中。 请参见图 3 ,图 3为本发明另一个实施例提供的另一种访问文件的方法的流 程示意图。其中, 本发明另一个实施例提供的另一种访问文件的方法可包括以 下内容:
301、 操作系统接收来自用户进程(下面称之为用户进程 A ) 的携带文件 标识的文件打开请求。
在本发明一些实施例中, 上述文件打开请求可以携带文件存储路径 (即请 求打开的文件的存储路径), 其中, 上述文件标识可包含在上述文件存储路径 之中, 当然, 上述文件打开请求中也可能携带文件标识并且可不携带文件存储 路径。 进一步的, 上述文件打开请求中还可携带文件类型标志位, 该文件类型 标志位可指示出上述文件标识所表示的文件的文件类型(文件类型可能是目录 文件或数据文件)。
302、 操作系统创建上述文件标识所表示的文件 (该文件下面称之为文件
F1 )对应的文件对象, 为文件 F1分配文件描述符。 其中, 基于文件 F1的文件 描述符可找到文件 F1的文件对象。
303、 操作系统确定上述文件存储内存区之中是否存储有文件 F1。
若是, 则执行步骤 304。
若否, 跳转至步骤 308。
304、 操作系统获得上述文件 F1的第一索引节点, 其中, 上述文件存储于 文件存储内存区之中,上述文件 F 1的第一索引节点也存储于文件存储内存区之 中。
例如图 2-b所示, 图 2-b举例示出了一种计算节点的内存示意图, 计算节点 的内存可包括用户进程工作内存区 S 1、内核进程工作内存区 S2和文件存储内存 区 S3等。
举例来说,用户进程工作内存区 S1可以是指,用于存放用户进程运行时的 工作环境所包含的数据结构和变量等内容的物理内存区域。其中, 用户进程工 作内存区存放的上述数据结构和变量例如可包括如下信息的至少一种:用户进 程运行时的堆、 栈、 内存映射区、 用户进程所对应的程序的变量、 字符和数组 等数据。
又举例来说, 内核进程工作内存区 S2可以是指,用于存放内核进程运行时 的工作环境所包含的数据结构和变量等内容的物理内存区域。其中, 内核进程 工作内存区存放的上述数据结构和变量例如可包括如下信息的至少一种:内核 进程运行时的堆、 栈、 内存映射区、 内核进程所对应的程序的变量、 字符和数 组等数据。
在本发明一些实施例中,上述文件存储内存区 S3可包括非易失性内存区和 /或易失性内存区 (即文件存储内存区 S3的存储介质包括非易失性存储介质和 / 或易失性存储介质)。 进程工作内存区 (如内核进程工作内存区 S2、 用户进程 工作内存区 S1 )可包括非易失性内存区和 /或易失性内存区 (即进程工作内存 区的存储介质包括非易失性存储介质和 /或易失性存储介质)。 其中, 进程工作 内存区(如内核进程工作内存区 S2、用户进程工作内存区 S 1 )和文件存储内存 区互不重叠。 例如图 2-c举例所示, 在本发明一些实施例中, 用户进程工作内 存区 S 1和内核进程工作内存区 S2可位于 DRAM中, 而文件存储内存区 S3可位 于 NVM中。
其中,文件存储内存区 S3可指用于存储文件系统的物理内存区域,文件存 储内存区中可存放文件系统本身的各种信息, 例如, 文件存储内存区中可存放 文件系统的索引节点和文件, 还可进一步存放文件系统的超级块(若存在)等 等信息。 例如图 2-d举例所示, 文件存储内存区 S3可包括超级块、 用于存储文 件索引节点的索引节点区和用于存储文件的文件数据区。 其中,超级块中可存 储用于指向索引节点的指针。 其中,超级块中可存储用于指向所有索引节点的 指针, 也可存储用于指向根目录文件的索引节点的指针。
在本发明的一些实施例中,文件 F1的第一索引节点中可记录用于指向第一 文件页表的指针(用于指向第一文件页表的指针可包括第一文件页表的起始物 理地址), 其中, 上述第一文件页表用于指向文件存储内存区 S3之中存储文件 F1的内存区,第一物理地址空间为上述文件存储内存区之中存储上述文件的内 存区的物理地址空间。 上述第一文件页表为单级或多级文件页表。
其中,本发明实施例中用数据结构类似或等同于内存页表的文件页表来组 织用于存储单个文件的内存页, 文件页表可是一级或多级文件页表。 非最低一 级文件页表中的每一级文件页表的每个表项记录下一级的某文件页表的起始 物理地址。而最低一级文件页表的每个表项记录存储了文件的某内存页的起始 物理地址。 如图 2-e所示, 图 2-e举例第一文件页表为一个三级文件页表, 分别 是 PUD、 PMD和 PTE三级, 其中, PUD中的每一个表项都记录一个 PMD的起始 物理地址, 而各个 PMD的每个表项都记录一个 PTE的起始物理地址, PTE的每 一个表项都记录一个内存页(其中, 内存页存储文件 F1的文件内容)的起始物 理地址。 可以理解的是, 并不是每一个文件都需要使用三级文件页表, 即便是 使用三级页表,也不一定有固定的格式, 例如不一定每个文件都需要使用 1024 个 PTE, 可以根据文件的大小变化动态调整文件页表组织架构。 例如, 第一索 引节点中可记录指向三级文件页表的第一级文件页表 PUD的指针(如 PUD的起 始物理地址;)。
其中, 每个文件都对应一个索引节点(inode ), 例如第一索引节点中包含 用于指向文件页表的指针(Pointer ), 该指针具体存放文件 Fl的最高一级文件 页表( PUD )所属物理内存页的起始物理地址。
其中, 文件 F1的第一索引节点中还可包含文件 F1的元数据, 文件 F1的元 数据中包含文件 F1的属性信息(如文件大小、 文件类型、 文件修改时间、 文件 创建时间等)
可以理解的是,由于每个文件的文件页表都储存在文件存储内存区的文件 数据区。由于文件存储内存区字节可寻址的特性和文件页表的基于链表的组织 形式, 文件页表并不需要放置在固定区域。 只要当作一般的文件存放在文件数 据区域中即可。
305、 操作系统基于上述第一索引节点得到上述文件存储内存区之中存储 文件 F1的内存区的第一物理地址空间。
由于第一索引节点中包含用于指向文件 F1的第一文件页表的指针,因此基 于上述第一索引节点可以得到用于指向文件 F1的第一文件页表的指针,而得到 用于指向文件 F1的第一文件页表的指针,可得到文件 F1的第一文件页表,进而 可以基于文件 F1的第一文件页表, 得到上述文件存储内存区之中存储文件 F1 的内存区的第一物理地址空间。
306、 操作系统为上述文件分配第一虚拟地址空间。
在本发明的一些实施例中,可以为上述文件分配预设大小的第一虚拟地址 空间(例如第一虚拟地址空间的大小可小于或等于系统最大虚拟地址空间除以 系统支持同时打开的最多文件个数)。 或也可根据上述文件的文件类型, 为上 述文件分配与该文件类型对应大小的第一虚拟地址空间。 例如, 目录文件对应 的虚拟地址空间和数据文件对应的虚拟地址空间的大小可不相等,例如目录文 件对应的虚拟地址空间大小可小于数据文件对应的虚拟地址空间的大小,例如 目录文件对应的虚拟地址空间大小为 1MB、 2MB、 10MB或 30MB等, 数据文 件对应的虚拟地址空间大小为 100MB、 500MB、 1GB、 10GB, 100GB或者 2TB 等等。
307、操作系统利用内存页表记录第一虚实地址映射关系,跳转至步骤 311。 其中,上述第一虚实地址映射关系为上述第一虚拟地址空间与上述第一物 理地址空间之间的映射关系, 其中, 上述内存页表包括内核内存页表和 /或用 户进程内存页表。
其中,在本发明的一些实施例中, 上述利用内存页表记录第一虚实地址映 射关系可以包括:在内存页表中增加用于记录上述第一虚实地址映射关系的表 项 (可能为一个或多个表项), 其中, 上述表项包含用于指向上述第一文件页 表的指针(用于指向上述第一文件页表的指针可以包括上述第一文件页表的起 始物理地址)。 举例来说, 上述内存页表的总级数为 Y, 上述第一文件页表的 总级数为 X, 若上述表项包含上述第一文件页表, 则上述表项可为上述内存页 表中的第 Y-X+1级内存页表之中的表项, 若上述表项包含用于指向上述第一文 件页表的指针, 则上述表项可以为上述内存页表中的第 Y-X级内存页表之中的 表项, 其中, 上述 X为正整数, 上述 Y为大于上述 X的正整数。 其中, 在一些 特殊应用场景下,在内存页表中增加的用于记录上述第一虚实地址映射关系的 表项(可能为一个或多个表项)也可以是内存页表中的任意一级内存页表之中 的表项。
在本发明的一些实施例中,还可进一步在上述第一索引节点中记录上述第 一虚拟地址空间、上述第一虚拟地址空间的起始地址和上述第一虚拟地址空间 的结束地址之中的至少一个, 和 /或, 还可在上述文件对应的文件对象之中记 录上述第一虚拟地址空间、上述第一虚拟地址空间的起始地址和上述第一虚拟 地址空间的结束地址之中的至少一个。
在本发明的一些实施例中,上述第一虚拟地址空间为连续的或者非连续的 虚拟地址空间。在本发明一些实施例中, 上述第一虚拟地址空间处于内核虚拟 地址空间或者上述第一虚拟地址空间处于用户进程虚拟地址空间。
308、 操作系统在文件存储内存区之中创建文件 F1 , 并为创建的文件 F1分 配第二索引节点,其中,文件 F1的第二索引节点也存储于文件存储内存区之中。
在本发明的一些实施例中,文件 F1的第二索引节点中可记录用于指向第二 文件页表的指针, 其中, 上述第二文件页表用于指向文件存储内存区之中存储 文件 F1的内存区的第二物理地址空间,上述第二文件页表为单级或多级文件页 表。
其中,本发明实施例中用数据结构类似或等同于内存页表的文件页表来组 织用于存储单个文件的内存页, 第二文件页表可是一级或多级文件页表。 非最 低一级文件页表中的每一级文件页表的每个表项记录下一级的某文件页表的 起始物理地址。而最低一级文件页表的每个表项记录存储了文件的某内存页的 起始物理地址。
其中, 每个文件都对应一个索引节点(inode ), 例如第二索引节点中包含 用于指向文件页表的指针(Pointer ), 该指针具体存放文件 F1的最高一级文件 页表所属物理内存页的起始物理地址。
其中, 文件 F1的第二索引节点中还可包含文件 F1的元数据, 文件 F1的元 数据中包含文件 F1的属性信息(如文件大小、 文件类型、 文件修改时间、 文件 创建时间等)
可以理解的是,由于每个文件的文件页表都储存在文件存储内存区的文件 数据区。由于文件存储内存区字节可寻址的特性和文件页表的基于链表的组织 形式, 因此第二文件页表并不需要放置在固定区域, 只要当作一般的文件存放 在文件数据区域中即可。
309、 操作系统为文件 F1分配第二虚拟地址空间。
在本发明的一些实施例中,可以为上述文件分配预设大小的第二虚拟地址 空间(例如第二虚拟地址空间的大小可小于或等于系统最大虚拟地址空间除以 系统支持同时打开的最多文件个数)。 或也可根据上述文件的文件类型, 为上 述文件分配与该文件类型对应大小的第二虚拟地址空间。 例如, 目录文件对应 的虚拟地址空间和数据文件对应的虚拟地址空间的大小可不相等,例如目录文 件对应的虚拟地址空间大小可小于数据文件对应的虚拟地址空间的大小,例如 目录文件对应的虚拟地址空间大小为 1MB、 2MB、 10MB或 30MB等, 数据文 件对应的虚拟地址空间大小为 100MB、 500MB、 1GB、 10GB, 100GB或者 2TB 等等。
310、操作系统利用内存页表记录第二虚实地址映射关系,跳转至步骤 311。 其中,上述第二虚实地址映射关系为上述第二虚拟地址空间与上述第二物 理地址空间之间的映射关系, 其中, 上述内存页表包括内核内存页表和 /或用 户进程内存页表。
其中,在本发明的一些实施例中, 上述利用内存页表记录第二虚实地址映 射关系可以包括:在内存页表中增加用于记录上述第二虚实地址映射关系的表 项 (可能为一个或多个表项), 其中, 上述表项包含用于指向上述第二文件页 表的指针。 举例来说, 上述内存页表的总级数为 Y, 上述第二文件页表的总级 数为 X, 若上述表项包含上述第二文件页表, 则上述表项可为上述内存页表中 的第 Y-X+1级内存页表之中的表项, 若上述表项包含用于指向上述第二文件页 表的指针, 则上述表项可以为上述内存页表中的第 Y-X级内存页表之中的表 项, 其中, 上述 X为正整数, 上述 Y为大于上述 X的正整数。 其中, 在一些特 殊应用场景下,在内存页表中增加的用于记录上述第二虚实地址映射关系的表 项(可能为一个或多个表项)也可以是内存页表中的任意一级内存页表之中的 表项。
在本发明的一些实施例中,还可进一步在上述第二索引节点中记录上述第 二虚拟地址空间、上述第二虚拟地址空间的起始地址和上述第二虚拟地址空间 的结束地址之中的至少一个, 和 /或, 还可在上述文件对应的文件对象之中记 录上述第二虚拟地址空间、上述第二虚拟地址空间的起始地址和上述第二虚拟 地址空间的结束地址之中的至少一个。
在本发明的一些实施例中,上述第二虚拟地址空间为连续的或者非连续的 虚拟地址空间。在本发明一些实施例中, 上述第二虚拟地址空间处于内核虚拟 地址空间或者上述第二虚拟地址空间处于用户进程虚拟地址空间。
311、 操作系统向用户进程 A反馈文件 F1的文件描述符号。
用户进程 A可基于文件 F1的文件描述符号发起对文件 F1的读写操作。 可以看出, 本实施例的上述技术方案之中,在接收携带文件标识的文件打 开请求之后,可判断文件存储内存区之中是否存储有上述文件标识所表示的文 件; 若上述文件存储内存区之中存储有上述文件, 则获得上述文件的第一索引 节点,并基于上述第一索引节点得到上述文件存储内存区之中存储上述文件的 内存区的第一物理地址空间; 为上述文件分配第一虚拟地址空间; 利用内存页 表记录第一虚实地址映射关系; 其中, 上述第一虚实地址映射关系为上述第一 虚拟地址空间与上述第一物理地址空间之间的映射关系, 其中, 上述内存页表 包括内核内存页表和 /或用户进程内存页表。 由于是利用内核内存页表和 /或用 户进程内存页表来记录第一虚实地址映射关系,可认为是在一定程度上将文件 存储内存区之中存储上述文件的内存区的第一物理地址空间,包装成进程工作 内存区之中的某内存区对应的物理地址空间,这有利于使得内核或用户进程按 现内核或用户进程以近似普通内存数据的访问性能来访问常驻内核的文件系 统的文件, 有利于极大的提高文件访问性能。 可见, 上述文件访问方案比较适 用于在文件系统常驻内存场景下进行文件高性能访问。 并且, 由于是在请求打 开文件时才为文件分配虚拟地址空间,这样有利于减少系统虚拟地址空间的无 效占用和地址沖突可能性, 有利于提高系统虚拟地址空间的利用效率。
进一步的, 由于在打开文件过程中可为文件分配连续虚拟地址空间, 因此 有利于实现从读写文件的起始虚拟地址开始,一次性访问所需读写长度之内的 内存页, 而不需要在软件层面多次查找不同内存页的对应虚拟地址, 这样文件 顺序访问速度可以非常快。
借助 MMU可透明地完成文件的虚拟地址和物理地址之间的转换, 这有利 于加快文件访问速度快、 甚至实现零开销。
进一步的,若采用数据结构与内存页表类似或相同的文件页表来指向文件 存储内存区中存储文件内容的内存页,由于文件页表与内存页表的数据结构类 似或相同,有利于实现页表数据结构的零转换, 并且当存储文件内容的内存页 发生变化时也可能无需对文件页表执行重建文件物理地址空间与虚拟地址空 间的映射关系的操作,通过更新文件页表,将用于指向更新的文件页表的指针 插入文件页表的表项中, 进而完成重建文件物理地址与虚拟地址的映射, 这种 方式有利于在与文件大小无关的常数时间之内,重建文件物理地址与虚拟地址 的映射。
进一步的, 由于可以为不同的文件分配独立的虚拟地址空间,使得文件系 统在文件存储内存区的文件受系统虚拟地址和 MMU的保护, 极大的减少被误 写的可能性, 不仅可以良好的保护文件, 且不需要额外的写保护机制, 有利于 筒化系统。
进一步的, 由于是通过虚拟地址访问文件, 文件的大小只受系统虚拟地址 空间的大小, 以及操作系统支持的同时打开的文件数量的影响, 这两者都不是 文件系统本身的限制, 因此文件大小可不受文件系统本身设计限制。
进一步的, 文件系统采用与内存管理相似的方式,都是通过虚拟地址访问 存储介质, 且都可利用 MMU进行虚拟地址和物理地址的转换, 对内核的改动 可以相对较少, 这样也便于文件系统移植到现有的操作系统中。 请参见图 4 ,图 4为本发明另一个实施例提供的另一种访问文件的方法的流 程示意图。 其中, 图 4所示的访问文件的方法可在图 2-a或图 3所示的技术方案 执行完之后实施。其中, 本发明另一个实施例提供的另一种访问文件的方法可 包括以下内容:
401、 操作系统接收用户进程 A发送的用于请求读取文件 F1的文件内容的 文件读取请求。其中, 上述文件读取请求携带有读入内存地址空间和请求读取 的上述文件 F1中的第一文件内容的数据量。
此外, 上述文件读取请求还可以携带上述文件的文件描述符。
其中,上述读入内存地址空间为用户进程工作内存区之中的第一内存区的 地址空间。
402、 操作系统基于上述文件描述符查找到文件 F1的第一索引节点或文件 Fl的文件对象。基于第一索引节点或文件 Fl的文件对象得到第一虚拟地址空间 的起始地址。
403、操作系统基于第一文件内容偏移量和第一虚拟地址空间的起始地址, 得到读取上述第一文件内容的起始读取虚拟地址。
404、 操作系统基于上述起始读取虚拟地址和第一虚实地址映射关系得到 从上述文件存储内存区读取上述第一文件内容的起始读取物理地址。
405、 操作系统基于起始读取物理地址和上述第一文件内容的数据量得到 从上述文件存储内存区读取上述第一文件内容的读取物理地址空间。
406、 操作系统基于上述读取物理地址空间, 从上述文件存储内存区之中 读取出上述文件的第一文件内容。基于上述读入内存地址空间,将上述第一文 件内容写入上述第一内存区。
可以看出, 本实施例的上述技术方案之中, 由于是利用内核内存页表和 / 或用户进程内存页表来记录第一虚实地址映射关系,可认为是在一定程度上将 文件存储内存区之中存储上述文件的内存区的第一物理地址空间,包装成进程 工作内存区之中的某内存区对应的物理地址空间,这有利于使得在进行文件内 容读取之时,内核或用户进程按照类似访问进程工作内存区的方式来访文件存 储内存区中文件,这样有利于实现内核或用户进程以近似普通内存数据的访问 性能来访问常驻内核的文件系统的文件,有利于极大的提高文件访问性能。 可 见上述文件访问方案比较适用于在文件系统常驻内存场景下进行文件高性能 访问。 请参见图 5 ,图 5为本发明另一个实施例提供的另一种访问文件的方法的流 程示意图。 其中, 图 5所示的访问文件的方法可在图 2-a或图 3所示的技术方案 执行完之后实施。其中, 本发明另一个实施例提供的另一种访问文件的方法可 包括以下内容:
501、 操作系统接收用户进程 A发送的用于请求读取文件 F1的第一文件内 容的文件读取请求。其中, 上述文件读取请求携带有读入内存地址空间和请求 读取的上述文件 F1中的第一文件内容的数据量。
此外, 上述文件读取请求还可以携带上述文件的文件描述符。 其中,上述读入内存地址空间为用户进程工作内存区之中的第一内存区的 地址空间。
502、 操作系统基于上述文件描述符查找到文件 F1的第一索引节点或文件 F1的文件对象;基于第一索引节点或文件 F1的文件对象得到第一虚拟地址空间 的起始地址。
503、操作系统基于第一文件内容偏移量和第一虚拟地址空间的起始地址, 得到读取上述第一文件内容的起始读取虚拟地址。
504、操作系统基于上述起始读取虚拟地址和上述第一文件内容的数据量, 得到读取上述第一文件内容的读取虚拟地址空间。
505、 操作系统可基于上述读取虚拟地址空间和上述第一虚实地址映射关 系, 得到从上述文件存储内存区读取上述第一文件内容的读取物理地址空间。
506、 操作系统基于上述读取物理地址空间, 从上述文件存储内存区之中 读取出上述文件的第一文件内容。基于上述读入内存地址空间,将上述第一文 件内容写入上述第一内存区。
可以看出, 本实施例的上述技术方案之中, 由于是利用内核内存页表和 / 或用户进程内存页表来记录第一虚实地址映射关系,可认为是在一定程度上将 文件存储内存区之中存储上述文件的内存区的第一物理地址空间,包装成进程 工作内存区之中的某内存区对应的物理地址空间,这有利于使得在进行文件内 容读取之时,内核或用户进程按照类似访问进程工作内存区的方式来访文件存 储内存区中文件,这样有利于实现内核或用户进程以近似普通内存数据的访问 性能来访问常驻内核的文件系统的文件,有利于极大的提高文件访问性能。 可 见上述文件访问方案比较适用于在文件系统常驻内存场景下进行文件高性能 访问。 请参见图 6 ,图 6为本发明另一个实施例提供的另一种访问文件的方法的流 程示意图。 其中, 图 6所示的访问文件的方法可在图 2-a或图 3所示的技术方案 执行完之后实施。其中, 本发明另一个实施例提供的另一种访问文件的方法可 包括以下内容: 件内容的文件写入请求, 其中, 上述文件写入请求携带有读出内存地址空间和 请求写入上述文件之中的第二文件内容的数据量。
此外, 上述文件写入请求还可以携带上述文件的文件描述符。
其中,上述读出内存地址空间为用户进程工作内存区之中的第二内存区的 地址空间。
602、 操作系统可以基于上述文件描述符查找到文件 F1的第一索引节点或 文件 F1的文件对象。操作系统基于第一索引节点或文件 F1的文件对象得到第一 虚拟地址空间的起始地址。
603、 操作系统可以基于第二文件内容偏移量和第一虚拟地址空间的起始 地址, 得到向文件 F1中写入上述第二文件内容的起始写入虚拟地址。
604、操作系统可以基于上述起始写入虚拟地址和第一虚实地址映射关系, 得到向上述文件存储内存区的文件 F1中写入第二文件内容的起始写入物理地 址。
605、操作系统可以基于起始写入物理地址和上述第二文件内容的数据量, 得到向上述文件存储内存区的文件 F1中写入第二文件内容的写入物理地址空 间。
606、 操作系统基于上述读出内存地址空间从上述第二内存区之中读取出 上述第二文件内容,操作系统基于上述写入物理地址空间,将读取出的上述第 二文件内容写入到上述第三内存区之中。
可以看出, 本实施例的上述技术方案之中, 由于是利用内核内存页表和 / 或用户进程内存页表来记录第一虚实地址映射关系,可认为是在一定程度上将 文件存储内存区之中存储上述文件的内存区的第一物理地址空间,包装成进程 工作内存区之中的某内存区对应的物理地址空间,这有利于使得在进行文件内 容写入之时,内核或用户进程按照类似访问进程工作内存区的方式来访文件存 储内存区中文件,这样有利于实现内核或用户进程以近似普通内存数据的访问 性能来访问常驻内核的文件系统的文件,有利于极大的提高文件访问性能。 可 见上述文件访问方案比较适用于在文件系统常驻内存场景下进行文件高性能 访问。 请参见图 7 ,图 7为本发明另一个实施例提供的另一种访问文件的方法的流 程示意图。 其中, 图 7所示的访问文件的方法可在图 2-a或图 3所示的技术方案 执行完之后实施。其中, 本发明另一个实施例提供的另一种访问文件的方法可 包括以下内容: 件内容的文件写入请求, 其中, 上述文件写入请求携带有读出内存地址空间和 请求写入上述文件之中的第二文件内容的数据量。
此外, 上述文件写入请求还可以携带上述文件的文件描述符。
其中,上述读出内存地址空间为用户进程工作内存区之中的第二内存区的 地址空间。
702、 操作系统可以基于上述文件描述符查找到文件 F1的第一索引节点或 文件 F1的文件对象。基于第一索引节点或文件 F1的文件对象得到第一虚拟地址 空间的起始地址。
703、 操作系统可以基于第二文件内容偏移量和第一虚拟地址空间的起始 地址, 得到向文件 F1中写入上述第二文件内容的起始写入虚拟地址。
704、 操作系统可以基于上述起始写入虚拟地址和上述第二文件内容的数 据量 , 得到向文件 F1中写入第二文件内容的写入虚拟地址空间。
705、操作系统可以基于上述写入虚拟地址空间和第一虚实地址映射关系, 得到向上述文件存储内存区的文件 F1中写入第二文件内容的写入物理地址空 间。
706、 操作系统基于上述读出内存地址空间从上述第二内存区之中读取出 上述第二文件内容,操作系统基于上述写入物理地址空间,将读取出的上述第 二文件内容写入到上述第三内存区之中。
可以看出, 本实施例的上述技术方案之中, 由于是利用内核内存页表和 / 或用户进程内存页表来记录第一虚实地址映射关系,可认为是在一定程度上将 文件存储内存区之中存储上述文件的内存区的第一物理地址空间,包装成进程 工作内存区之中的某内存区对应的物理地址空间,这有利于使得在进行文件内 容写入之时,内核或用户进程按照类似访问进程工作内存区的方式来访文件存 储内存区中文件,这样有利于实现内核或用户进程以近似普通内存数据的访问 性能来访问常驻内核的文件系统的文件,有利于极大的提高文件访问性能。 可 见上述文件访问方案比较适用于在文件系统常驻内存场景下进行文件高性能 访问。 请参见图 8,图 8为本发明另一个实施例提供的另一种访问文件的方法的流 程示意图。 其中, 图 8所示的访问文件的方法可在图 2-a或图 3~图7任意一图所 示的技术方案执行完之后实施。其中, 本发明另一个实施例提供的另一种访问 文件的方法可包括以下内容:
801、 操作系统接收用户进程 A发送的请求关闭上述文件 F1的文件关闭请 求, 其中, 上述文件关闭请求还可携带上述文件的文件描述符。
802、 操作系统释放为上述文件分配的第一虚拟地址空间或第二虚拟地址 空间。
803、 操作系统释放上述内存页表中记录的上述第一虚实地址映射关系或 第二虚实地址映射关系。
804、 操作系统释放上述文件 F1对应的文件对象等。
可以看出, 本实施例的上述技术方案之中。 由于是利用内核内存页表和 / 或用户进程内存页表来记录第一虚实地址映射关系,可认为是在一定程度上将 文件存储内存区之中存储上述文件的内存区的第一物理地址空间,包装成进程 工作内存区之中的某内存区对应的物理地址空间,这有利于使得内核或用户进 于实现内核或用户进程以近似普通内存数据的访问性能来访问常驻内核的文 件系统的文件, 有利于极大的提高文件访问性能。 可见, 上述文件访问方案比 较适用于在文件系统常驻内存场景下进行文件高性能访问。 并且, 由于是在请 求打开文件时才为文件分配虚拟地址空间,而在关闭文件时就释放为文件分配 虚拟地址空间,这样有利于减少对系统虚拟地址空间的无效占用和地址沖突可 能性, 有利于提高系统虚拟地址空间的利用效率。
可以理解的是,上述各实施例描述的任意一种访问文件的方法均可应用于 计算节点中, 该计算节点可包括内存, 该内存包括: 文件存储内存区和进程工 作内存区, 其中, 上述进程工作内存区存储有内存页表, 上述进程工作内存区 之中运行有操作系统。举例来说, 上述进程工作内存区可包括内核进程工作内 存区和用户进程工作内存区, 其中, 内核内存页表可存储于内核进程工作内存 区, 用户进程内存页表可存储于上述用户进程工作内存区, 例如内核进程工作 内存区之中运行有操作系统。 为便于更好的实施本发明实施例的上述方案,下面提供用于实施上述方案 的相关装置。
参见图 9-a, 本发明实施例提供访问文件的装置 900, 可包括:
接收单元 901、 获取单元 902、 分配单元 903和映射单元 904。
其中, 接收单元 901 , 用于接收携带文件标识的文件打开请求。
在本发明一些实施例中, 上述文件打开请求可以携带文件存储路径 (即请 求打开的文件的存储路径), 其中, 上述文件标识可包含在上述文件存储路径 之中, 当然, 上述文件打开请求中也可能携带文件标识并且可不携带文件存储 路径。 进一步的, 上述文件打开请求中还可携带文件类型标志位, 该文件类型 标志位可指示出上述文件标识所表示的文件的文件类型(文件类型可能是目录 文件或数据文件)。
获取单元 902, 用于获得上述文件标识所表示的文件的第一索引节点, 上 述文件存储于文件存储内存区之中;基于上述第一索引节点得到上述文件存储 内存区之中存储上述文件的内存区的第一物理地址空间。
分配单元 903, 用于为上述文件分配第一虚拟地址空间。
在本发明的一些实施例中,可以为上述文件分配预设大小的第一虚拟地址 空间(例如第一虚拟地址空间的大小可小于或等于系统最大虚拟地址空间除以 系统支持同时打开的最多文件个数)。 或也可根据上述文件的文件类型, 为上 述文件分配与该文件类型对应大小的第一虚拟地址空间。 例如, 目录文件对应 的虚拟地址空间和数据文件对应的虚拟地址空间的大小可不相等,例如目录文 件对应的虚拟地址空间大小可小于数据文件对应的虚拟地址空间的大小,例如 目录文件对应的虚拟地址空间大小为 1MB、 2MB、 10MB或 30MB等, 数据文 件对应的虚拟地址空间大小为 100MB、 500MB、 1GB、 10GB, 100GB或者 2TB 等等。
映射单元 904, 用于利用内存页表记录第一虚实地址映射关系。
其中,上述第一虚实地址映射关系包括上述第一虚拟地址空间与上述第一 物理地址空间之间的映射关系, 其中, 上述内存页表包括内核内存页表和 /或 用户进程内存页表。
其中,文件的索引节点中可包含能够得出文件存储内存区之中存储该文件 的内存区的物理地址空间的信息。例如, 上述文件的第一索引节点中可记录第 一文件页表或用于指向第一文件页表的指针,上述第一文件页表用于指向上述 文件存储内存区之中存储上述文件的内存区,上述第一文件页表为单级或多级 文件页表, 其中, 第一物理地址空间为上述文件存储内存区之中存储上述文件 的内存区的物理地址空间。 当然, 第一索引节点也可能直接存储上述文件存储 内存区之中存储上述文件的内存区的第一物理地址空间或第一物理地址空间 的起始地址等。进一步的, 上述文件的第一索引节点中还可包含该文件的元数 据等信息。
在本发明的一些实施例中,在上述基于上述第一索引节点得到上述文件存 储内存区之中存储上述文件的内存区的第一物理地址空间的方面, 获取单元 902可具体用于, 基于上述第一索引节点中记录的第一文件页表或用于指向第 一物理地址空间, 其中, 上述第一文件页表用于指向上述文件存储内存区之中 存储上述文件的内存区,上述的第一物理地址空间为上述文件存储内存区之中 存储上述文件的内存区的物理地址空间,上述第一文件页表为单级或多级文件 页表。
在本发明的一些实施例中, 内存可以包括: 进程工作内存区(其中, 进程 工作内存区可以包括用户进程工作内存区和内核进程工作内存区)和文件存储 内存区。 其中, 进程工作内存区是指, 用于存放进程运行时的工作环境所包含 的数据结构和变量等内容的物理内存区域。其中, 上述数据结构和变量可包括 如下信息的至少一种: 进程运行时的堆、 栈、 内存映射区、 进程所对应的程序 的变量、 字符和数组等数据。 举例来说, 用户进程工作内存区可以是指, 用于存放用户进程运行时的工 作环境所包含的数据结构和变量等内容的物理内存区域。 其中, 用户进程工作 内存区存放的上述数据结构和变量例如可包括如下信息的至少一种:用户进程 运行时的堆、 栈、 内存映射区、 用户进程所对应的程序的变量、 字符和数组等 数据。
又举例来说, 内核进程工作内存区可以是指, 用于存放内核进程运行时的 工作环境所包含的数据结构和变量等内容的物理内存区域。其中, 内核进程工 作内存区存放的上述数据结构和变量例如可包括如下信息的至少一种:内核进 程运行时的堆、 栈、 内存映射区、 内核进程所对应的程序的变量、 字符和数组 等数据。
其中, 文件存储内存区可指用于存储文件系统的物理内存区域, 文件存储 内存区中可存放文件系统本身的各种信息, 例如, 文件存储内存区中可存放文 件系统的索引节点和文件, 还可进一步存放文件系统的超级块(若存在)等等 信息。
在本发明一些实施例中, 上述文件存储内存区可包括非易失性内存区和 / 或易失性内存区 (即, 文件存储内存区的存储介质包括非易失性存储介质和 / 或易失性存储介质)。 其中, 进程工作内存区 (如内核进程工作内存区、 用户 进程工作内存区)可包括非易失性内存区和 /或易失性内存区 (即进程工作内 存区的存储介质包括非易失性存储介质和 /或易失性存储介质)。 其中, 进程工 作内存区(如内核进程工作内存区、 用户进程工作内存区)和文件存储内存区 互不重叠。
在本发明的一些实施例中, 映射单元 904可具体用于, 在内存页表中增加 用于记录上述第一虚实地址映射关系的表项,上述表项包含上述第一文件页表 或用于指向上述第一文件页表的指针。
在本发明的一些实施例中, 上述内存页表的总级数为 Y, 上述第一文件页 表的总级数为 X, 若上述表项包含上述第一文件页表, 则上述表项为上述内存 页表中的第 Y-X+1级内存页表中的表项, 若上述表项包含用于指向上述第一文 件页表的指针, 则上述表项为上述内存页表中的第 Y-X级内存页表中的表项, 上述 X为正整数, 上述 Y为大于上述 X的正整数。
参见图 9-b, 在本发明的一些实施例中, 访问文件的装置 900还包括: 记录单元 905 , 用于在上述第一索引节点中记录上述第一虚拟地址空间和 / 或上述第一虚拟地址空间的起始地址, 和 /或, 在上述文件对应的文件对象之 中记录上述第一虚拟地址空间和 /或上述第一虚拟地址空间的起始地址。
在本发明的一些实施例中,上述第一虚拟地址空间为连续的或者非连续的 虚拟地址空间。
在本发明的一些实施例中,上述第一虚拟地址空间处于内核虚拟地址空间 或者用户进程虚拟地址空间。
在本发明的一些实施例中, 获取单元 902可具体用于: 当确定上述文件存 储内存区之中存储有上述文件标识所表示的文件,获得上述文件标识所表示的 文件的第一索引节点。
在本发明的一些实施例中, 接收单元 901还可用于, 接收用于请求读取上 述文件的文件内容的文件读取请求, 其中, 上述文件读取请求携带有读入内存 地址空间和请求读取的上述文件中的第一文件内容的数据量, 其中, 上述读入 内存地址空间为用户进程工作内存区之中的第一内存区的地址空间;
参见图 9-c , 上述访问文件的装置 900还包括:
第二映射单元 906, 用于基于上述第一文件内容的数据量、 上述第一虚拟 地址空间和上述内存页表记录的上述第一虚实地址映射关系,得到从上述文件 存储内存区读取上述第一文件内容的读取物理地址空间;
第一读写单元 907, 用于基于上述读取物理地址空间, 从上述文件存储内 存区之中读取出上述文件的第一文件内容;将上述第一文件内容写入上述第一 内存区。
在本发明的一些实施例中,在上述基于上述第一文件内容的数据量、上述 第一虚拟地址空间和上述内存页表记录的上述第一虚实地址映射关系,得到从 上述文件存储内存区读取上述第一文件内容的读取物理地址空间的方面,第二 映射单元 906可具体用于, 基于上述第一文件内容的数据量、 第一文件内容偏 移量、上述第一虚拟地址空间和上述内存页表记录的上述第一虚实地址映射关 系, 得到从上述文件存储内存区读取上述第一文件内容的读取物理地址空间, 其中, 上述第一文件内容偏移量从上述文件读取请求之中得到, 或者, 上述第 一文件内容偏移量从上述文件对应的文件对象之中得到。
例如, 可基于第一文件内容偏移量(其中, 若未从上述文件读取请求从上 述文件对应的文件对象之中得到第一文件内容偏移量,则可将默认文件内容偏 移量作为第一文件内容偏移量 )和上述第一虚拟地址空间的起始地址,得到读 取上述第一文件内容的起始读取虚拟地址;利用上述起始读取虚拟地址和第一 虚实地址映射关系,得到从上述文件存储内存区读取上述第一文件内容的起始 读取物理地址;基于上述起始读取物理地址和第一文件内容的数据量,得到从 上述文件存储内存区读取上述第一文件内容的读取物理地址空间。
又例如, 可基于第一文件内容偏移量(其中, 若未从上述文件读取请求从 上述文件对应的文件对象之中得到第一文件内容偏移量,则可将默认文件内容 偏移量作为第一文件内容偏移量 )和上述第一虚拟地址空间的起始地址,得到 读取上述第一文件内容的起始读取虚拟地址;基于起始读取虚拟地址和第一文 件内容的数据量,得到读取上述第一文件内容的读取虚拟地址空间; 利用上述 读取虚拟地址空间和第一虚实地址映射关系,得到从上述文件存储内存区读取 上述第一文件内容的读取物理地址空间。
在本发明的一些实施例中, 接收单元 901还可用于, 接收请求向上述文件 之中写入文件内容的文件写入请求, 其中, 上述文件写入请求携带有读出内存 地址空间和请求写入上述文件之中的第二文件内容的数据量, 其中,上述读出 内存地址空间为上述进程工作内存区之中的第二内存区的地址空间;
参见图 9-d, 上述访问文件的装置 900还包括:
第三映射单元 908, 用于基于上述第二文件内容的数据量、 上述第一虚拟 地址空间和上述内存页表记录的上述第一虚实地址映射关系,得到向上述文件 存储内存区写入上述第二文件内容的写入物理地址空间, 其中, 上述写入物理 地址空间为上述文件存储内存区之中的第三内存区的物理地址空间;
第二读写单元 909, 用于将上述第二内存区之中緩存的上述第二文件内容 写入到上述第三内存区之中。 在本发明的一些实施例中,在上述基于上述第二文件内容的数据量、上述 第一虚拟地址空间和上述内存页表记录的上述第一虚实地址映射关系,得到向 上述文件存储内存区写入上述第二文件内容的写入物理地址空间的方面,上述 第三映射单元 908可具体用于, 基于上述第二文件内容的数据量、 第二文件内 容偏移量、上述第一虚拟地址空间和上述内存页表记录的上述第一虚实地址映 射关系,得到向上述文件存储内存区写入上述第二文件内容的写入物理地址空 间, 其中, 上述第二文件内容偏移量从上述文件写入请求之中得到, 或者, 上 述第二文件内容偏移量从上述文件对应的文件对象之中得到。
例如, 可基于第二文件内容偏移量(其中, 若未从上述文件写入请求从上 述文件对应的文件对象之中得到第二文件内容偏移量,则可将默认文件内容偏 移量作为第二文件内容偏移量 )和上述第一虚拟地址空间的起始地址,得到向 上述文件写入上述第二文件内容的起始写入虚拟地址;利用上述起始写入虚拟 地址和第一虚实地址映射关系,得到向从上述文件存储内存区的上述文件中写 入上述第二文件内容的起始写入物理地址;基于上述起始写入物理地址和第二 文件内容的数据量,得到向上述文件存储内存区的上述文件中写入上述第二文 件内容的写入物理地址空间。
又例如, 可基于第二文件内容偏移量(其中, 若未从上述文件写入请求从 上述文件对应的文件对象之中得到第二文件内容偏移量,则可将默认文件内容 偏移量作为第二文件内容偏移量 )和上述第一虚拟地址空间的起始地址,得到 向上述文件中上述第二文件内容的起始写入虚拟地址;基于起始写入虚拟地址 和第二文件内容的数据量,得到向上述文件存储内存区的上述文件中写入上述 第二文件内容的写入虚拟地址空间;利用上述写入虚拟地址空间和第一虚实地 的写入物理地址空间。
其中,上述第三内存区的存储容量可以大于或者等于上述第二文件内容的 数据量。其中, 第三内存区和上述第一物理地址空间对应的内存区具有交集或 没有交集。 可以理解的是, 在通常情况下, 若第三内存区和上述第一物理地址 空间对应的内存区具有交集,则可以表示用第二文件内容替换了上述文件中原 有的部分或者全部文件内容(若第三内存区和上述第一物理地址空间对应的内 存区的交集小于第三内存区,表示为第二文件内容分配了新的内存区, 即存储 上述文件的内存区发生了变化, 存储上述文件的内存区被扩容了)。 若第三内 存区和上述第一物理地址空间对应的内存区没有交集,则可以表示上述文件中 新增了第二文件内容, 第三内存区是为第二文件内容分配了新内存区, 即存储 上述文件的内存区发生了变化, 存储上述文件的内存区被扩容了。 单元 904可更新第一文件页表, 以使得更新后的第一文件页表指向文件存储内 存区中当前存储上述文件的内存区。
当然, 进一步的, 映射单元 904可将上述内存页表中记录的上述第一虚实 地址映射关系更新为第三虚实地址映射关系,上述第三虚实地址映射关系包括 上述第一虚拟地址空间与上述第三物理地址空间之间的映射关系, 其中, 上述 第三物理地址空间为文件存储内存区中当前存储上述文件的内存区的物理地 址空间。 其中, 若内存页表中记录的是指向第一文件页表的指针(例如内存页 表中记录的第一文件页表的起始物理地址), 若更新之后的第一文件页表的起 始物理地址未变化,则也可以不修改内存页表中记录的是指向第一文件页表的 指针。 而在这种情况下, 更新第一文件页表而无需修改内存页表, 即可重建虚 实地址映射关系, 极大的筒化了映射操作。
在本发明的一些实施例中, 接收单元 901还可用于, 接收用于请求关闭上 述文件的文件关闭请求。
参见图 9-e , 访问文件的装置 900还可包括: 释放单元 910, 用于释放为上 述文件分配的第一虚拟地址空间;释放上述内存页表中记录的上述第一虚实地 址映射关系。
在本发明的一些实施例中, 访问文件的装置 900还可包括: 表示的文件,在上述文件存储内存区之中创建上述文件, 为上述文件分配第二 索引节点, 其中, 上述第二索引节点中记录有第二文件页表或者用于指向第二 文件页表的指针, 其中, 上述第二文件页表用于指向上述文件存储内存区之中 存储上述文件的内存区。
分配单元 903还可用于, 为上述文件分配第二虚拟地址空间。
映射单元 904还可用于, 利用内存页表记录第二虚实地址映射关系。
其中,上述第二虚实地址映射关系包括上述第二虚拟地址空间与上述第二 物理地址空间之间的映射关系, 其中, 上述第二物理地址空间为上述文件存储 内存区之中存储上述文件的内存区的物理地址空间,上述内存页表包括内核内 存页表和 /或用户进程内存页表。
在本发明的一些实施例中,上述第二文件页表的级数与上述文件的文件类 型之间具有对应关系。
在本发明的一些实施例中, 上述文件存储内存区包括非易失性内存区和 / 或易失性内存区。
可以理解的是, 本实施例的访问文件的装置 900的各功能模块的功能可根 据上述方法实施例中的方法具体实现,其具体实现过程可以参照上述方法实施 例的相关描述, 此处不再赘述。
可以看出, 本实施例的上述技术方案之中, 访问文件的装置 900可在接收 携带文件标识的文件打开请求之后;获得上述文件标识所表示的文件的第一索 引节点,并基于上述第一索引节点得到上述文件存储内存区之中存储上述文件 的内存区的第一物理地址空间; 为上述文件分配第一虚拟地址空间; 利用内存 页表记录第一虚实地址映射关系; 其中, 上述第一虚实地址映射关系为上述第 一虚拟地址空间与上述第一物理地址空间之间的映射关系, 其中, 上述内存页 表包括内核内存页表和 /或用户进程内存页表。 由于是利用内核内存页表和 /或 用户进程内存页表来记录第一虚实地址映射关系,可认为是在一定程度上将文 件存储内存区之中存储上述文件的内存区的第一物理地址空间,包装成进程工 作内存区之中的某内存区对应的物理地址空间,这有利于使得内核或用户进程 实现内核或用户进程以近似普通内存数据的访问性能来访问常驻内核的文件 系统的文件, 这有利于极大的提高文件访问性能。 可见, 上述文件访问方案比 较适用于在文件系统常驻内存场景下进行文件高性能访问。 并且, 由于是在请 求打开文件时才为文件分配虚拟地址空间,这样有利于减少系统虚拟地址空间 的无效占用和地址沖突可能性, 有利于提高系统虚拟地址空间的利用效率。
进一步的, 由于在打开文件过程中可为文件分配连续虚拟地址空间, 因此 有利于实现从读写文件的起始虚拟地址开始,一次性访问所需读写长度之内的 内存页, 而不需要在软件层面多次查找不同内存页的对应虚拟地址, 这样文件 顺序访问速度可以非常快。
借助 MMU可透明地完成文件的虚拟地址和物理地址之间的转换, 这有利 于加快文件访问速度快、 甚至实现零开销。
进一步的,若采用数据结构与内存页表类似或相同的文件页表来指向文件 存储内存区中存储文件内容的内存页,由于文件页表与内存页表的数据结构类 似或相同,有利于实现页表数据结构的零转换, 并且当存储文件内容的内存页 发生变化时也可能无需对文件页表执行重建文件物理地址空间与虚拟地址空 间的映射关系的操作,通过更新文件页表,将用于指向更新的文件页表的指针 插入文件页表的表项中, 进而完成重建文件物理地址与虚拟地址的映射, 这种 方式有利于在与文件大小无关的常数时间之内,重建文件物理地址与虚拟地址 的映射。
进一步的, 由于可以为不同的文件分配独立的虚拟地址空间,使得文件系 统在文件存储内存区的文件受系统虚拟地址和 MMU的保护, 极大的减少被误 写的可能性, 不仅可以良好的保护文件, 且不需要额外的写保护机制, 有利于 筒化系统。
进一步的, 由于是通过虚拟地址访问文件, 文件的大小只受系统虚拟地址 空间的大小, 以及操作系统支持的同时打开的文件数量的影响, 这两者都不是 文件系统本身的限制, 因此文件大小可不受文件系统本身设计限制。
进一步的, 文件系统采用与内存管理相似的方式,都是通过虚拟地址访问 存储介质, 且都可利用 MMU进行虚拟地址和物理地址的转换, 对内核的改动 可以相对较少, 这样也便于文件系统移植到现有的操作系统中。 参见图 10, 图 10为本发明实施例提供的计算节点 1000的示意图, 计算节 点 1000可包括至少一个总线 1001、与总线 1001相连的至少一个处理器 1002以及 与总线 1001相连的至少一个存储器 1003。
其中, 存储器 1003可包括内存, 还可包括外存。 上述内存可包括: 文件存 储内存区和进程工作内存区, 其中, 上述进程工作内存区存储有内存页表, 上 述进程工作内存区之中运行有操作系统。例如, 上述进程工作内存区可包括内 核进程工作内存区和用户进程工作内存区, 其中, 内核内存页表可存储于内核 进程工作内存区, 用户进程内存页表可存储于上述用户进程工作内存区。
其中, 处理器 1002通过总线 1001 ,调用存储器 1003中存储的代码以用于接 收携带文件标识的文件打开请求;获得上述文件标识所表示的文件的第一索引 节点, 其中, 上述文件存储于文件存储内存区之中; 基于上述第一索引节点得 述文件分配第一虚拟地址空间; 利用内存页表记录第一虚实地址映射关系; 其 中,上述第一虚实地址映射关系包括上述第一虚拟地址空间与上述第一物理地 址空间之间的映射关系, 其中, 上述内存页表包括内核内存页表和 /或用户进 程内存页表。
在本发明一些实施例中, 上述文件打开请求可以携带文件存储路径 (即请 求打开的文件的存储路径), 其中, 上述文件标识可包含在上述文件存储路径 之中, 当然, 上述文件打开请求中也可能携带文件标识并且可不携带文件存储 路径。 进一步的, 上述文件打开请求中还可携带文件类型标志位, 该文件类型 标志位可指示出上述文件标识所表示的文件的文件类型(文件类型可能是目录 文件或数据文件)。
在本发明的一些实施例中,在上述基于上述第一索引节点得到上述文件存 储内存区之中存储上述文件的内存区的第一物理地址空间的方面,处理器 1002 通过总线 1001 ,调用存储器 1003中存储的代码以具体用于,基于上述第一索引 节点中记录的第一文件页表或用于指向第一文件页表的指针,得到上述文件存 储内存区之中存储上述文件的内存区的第一物理地址空间, 其中, 上述第一文
空间, 上述第一文件页表为单级或多级文件页表。 其中, 进程工作内存区是指, 用于存放进程运行时的工作环境所包含的数 据结构和变量等内容的物理内存区域。其中, 上述数据结构和变量可包括如下 信息的至少一种: 进程运行时的堆、 栈、 内存映射区、 进程所对应的程序的变 量、 字符和数组等数据。
举例来说, 用户进程工作内存区可以是指, 用于存放用户进程运行时的工 作环境所包含的数据结构和变量等内容的物理内存区域。 其中, 用户进程工作 内存区存放的上述数据结构和变量例如可包括如下信息的至少一种:用户进程 运行时的堆、 栈、 内存映射区、 用户进程所对应的程序的变量、 字符和数组等 数据。
又举例来说, 内核进程工作内存区可以是指, 用于存放内核进程运行时的 工作环境所包含的数据结构和变量等内容的物理内存区域。其中, 内核进程工 作内存区存放的上述数据结构和变量例如可包括如下信息的至少一种:内核进 程运行时的堆、 栈、 内存映射区、 内核进程所对应的程序的变量、 字符和数组 等数据。
其中, 文件存储内存区可指用于存储文件系统的物理内存区域, 文件存储 内存区中可存放文件系统本身的各种信息, 例如, 文件存储内存区中可存放文 件系统的索引节点和文件, 还可进一步存放文件系统的超级块(若存在)等等 信息。
在本发明一些实施例中, 上述文件存储内存区可包括非易失性内存区和 / 或易失性内存区 (即, 文件存储内存区的存储介质包括非易失性存储介质和 / 或易失性存储介质)。 其中, 进程工作内存区 (如内核进程工作内存区、 用户 进程工作内存区)可包括非易失性内存区和 /或易失性内存区 (即进程工作内 存区的存储介质包括非易失性存储介质和 /或易失性存储介质)。 其中, 进程工 作内存区(如内核进程工作内存区、 用户进程工作内存区)和文件存储内存区 互不重叠。
在本发明的一些实施例中,在上述利用内存页表记录第一虚实地址映射关 系的方面, 处理器 1002通过总线 1001 ,调用存储器 1003中存储的代码以具体用 于,在内存页表中增加用于记录上述第一虚实地址映射关系的表项, 上述表项 包含上述第一文件页表或用于指向上述第一文件页表的指针。
在本发明的一些实施例中, 上述内存页表的总级数为 Y, 上述第一文件页 表的总级数为 X, 若上述表项包含上述第一文件页表, 则上述表项为上述内存 页表中的第 Y-X+1级内存页表中的表项, 若上述表项包含用于指向上述第一文 件页表的指针, 则上述表项为上述内存页表中的第 Y-X级内存页表中的表项, 上述 X为正整数, 上述 Y为大于上述 X的正整数。
在本发明的一些实施例中, 处理器 1002通过总线 1001 , 调用存储器 1003 中存储的代码以还用于,在上述第一索引节点中记录上述第一虚拟地址空间和 /或上述第一虚拟地址空间的起始地址, 和 /或, 在上述文件对应的文件对象之 中记录上述第一虚拟地址空间和 /或上述第一虚拟地址空间的起始地址。
在本发明的一些实施例中,上述第一虚拟地址空间为连续的或者非连续的 虚拟地址空间。
在本发明的一些实施例中,上述第一虚拟地址空间处于内核虚拟地址空间 或者用户进程虚拟地址空间。
在本发明的一些实施例中,在上述获得上述文件标识所表示的文件的第一 索引节点的方面, 处理器 1002通过总线 1001 ,调用存储器 1003中存储的代码以 件, 获得上述文件标识所表示的文件的第一索引节点。
在本发明的一些实施例中, 处理器 1002通过总线 1001 , 调用存储器 1003 中存储的代码以还用于,接收用于请求读取上述文件的文件内容的文件读取请 求, 其中, 上述文件读取请求携带有读入内存地址空间和请求读取的上述文件 中的第一文件内容的数据量, 其中, 上述读入内存地址空间为用户进程工作内 存区之中的第一内存区的地址空间;基于上述第一文件内容的数据量、上述第 一虚拟地址空间和上述内存页表记录的上述第一虚实地址映射关系,得到从上 述文件存储内存区读取上述第一文件内容的读取物理地址空间;基于上述读取 物理地址空间, 从上述文件存储内存区之中读取出上述文件的第一文件内容; 将上述第一文件内容写入上述第一内存区。
在本发明的一些实施例中,在上述基于上述第一文件内容的数据量、上述 第一虚拟地址空间和上述内存页表记录的上述第一虚实地址映射关系,得到从 上述文件存储内存区读取上述第一文件内容的读取物理地址空间的方面,处理 器 1002通过总线 1001 , 调用存储器 1003中存储的代码以具体用于,
基于上述第一文件内容的数据量、第一文件内容偏移量、上述第一虚拟地 址空间和上述内存页表记录的上述第一虚实地址映射关系,得到从上述文件存 储内存区读取上述第一文件内容的读取物理地址空间, 其中, 上述第一文件内 容偏移量从上述文件读取请求之中得到, 或者, 上述第一文件内容偏移量从上 述文件对应的文件对象之中得到。
例如, 可基于第一文件内容偏移量(其中, 若未从上述文件读取请求从上 述文件对应的文件对象之中得到第一文件内容偏移量,则可将默认文件内容偏 移量作为第一文件内容偏移量 )和上述第一虚拟地址空间的起始地址,得到读 取上述第一文件内容的起始读取虚拟地址;利用上述起始读取虚拟地址和第一 虚实地址映射关系,得到从上述文件存储内存区读取上述第一文件内容的起始 读取物理地址;基于上述起始读取物理地址和第一文件内容的数据量,得到从 上述文件存储内存区读取上述第一文件内容的读取物理地址空间。
又例如, 可基于第一文件内容偏移量(其中, 若未从上述文件读取请求从 上述文件对应的文件对象之中得到第一文件内容偏移量,则可将默认文件内容 偏移量作为第一文件内容偏移量 )和上述第一虚拟地址空间的起始地址,得到 读取上述第一文件内容的起始读取虚拟地址;基于起始读取虚拟地址和第一文 件内容的数据量,得到读取上述第一文件内容的读取虚拟地址空间; 利用上述 读取虚拟地址空间和第一虚实地址映射关系,得到从上述文件存储内存区读取 上述第一文件内容的读取物理地址空间。
在本发明的一些实施例中, 处理器 1002通过总线 1001 , 调用存储器 1003 中存储的代码以还用于,接收请求向上述文件之中写入文件内容的文件写入请 求, 其中, 上述文件写入请求携带有读出内存地址空间和请求写入上述文件之 中的第二文件内容的数据量, 其中, 上述读出内存地址空间为上述进程工作内 存区之中的第二内存区的地址空间;
基于上述第二文件内容的数据量、上述第一虚拟地址空间和上述内存页表 记录的上述第一虚实地址映射关系,得到向上述文件存储内存区写入上述第二 文件内容的写入物理地址空间, 其中, 上述写入物理地址空间为上述文件存储 内存区之中的第三内存区的物理地址空间;
将上述第二内存区之中緩存的上述第二文件内容写入到上述第三内存区 之中。
在本发明的一些实施例中,在上述基于上述第二文件内容的数据量、上述 第一虚拟地址空间和上述内存页表记录的上述第一虚实地址映射关系,得到向 上述文件存储内存区写入上述第二文件内容的写入物理地址空间的方面,处理 器 1002通过总线 1001 , 调用存储器 1003中存储的代码以具体用于,
基于上述第二文件内容的数据量、第二文件内容偏移量、上述第一虚拟地 址空间和上述内存页表记录的上述第一虚实地址映射关系,得到向上述文件存 储内存区写入上述第二文件内容的写入物理地址空间, 其中, 上述第二文件内 容偏移量从上述文件写入请求之中得到, 或者, 上述第二文件内容偏移量从上 述文件对应的文件对象之中得到。
例如, 可基于第二文件内容偏移量(其中, 若未从上述文件写入请求从上 述文件对应的文件对象之中得到第二文件内容偏移量,则可将默认文件内容偏 移量作为第二文件内容偏移量 )和上述第一虚拟地址空间的起始地址,得到向 上述文件写入上述第二文件内容的起始写入虚拟地址;利用上述起始写入虚拟 地址和第一虚实地址映射关系,得到向从上述文件存储内存区的上述文件中写 入上述第二文件内容的起始写入物理地址;基于上述起始写入物理地址和第二 件内容的写入物理地址空间。
又例如, 可基于第二文件内容偏移量(其中, 若未从上述文件写入请求从 上述文件对应的文件对象之中得到第二文件内容偏移量,则可将默认文件内容 偏移量作为第二文件内容偏移量 )和上述第一虚拟地址空间的起始地址,得到 向上述文件中上述第二文件内容的起始写入虚拟地址;基于起始写入虚拟地址 和第二文件内容的数据量,得到向上述文件存储内存区的上述文件中写入上述 第二文件内容的写入虚拟地址空间;利用上述写入虚拟地址空间和第一虚实地 的写入物理地址空间。
其中,上述第三内存区的存储容量可以大于或者等于上述第二文件内容的 数据量。其中, 第三内存区和上述第一物理地址空间对应的内存区具有交集或 没有交集。 可以理解的是, 在通常情况下, 若第三内存区和上述第一物理地址 空间对应的内存区具有交集,则可以表示用第二文件内容替换了上述文件中原 有的部分或者全部文件内容(若第三内存区和上述第一物理地址空间对应的内 存区的交集小于第三内存区,表示为第二文件内容分配了新的内存区, 即存储 上述文件的内存区发生了变化, 存储上述文件的内存区被扩容了)。 若第三内 存区和上述第一物理地址空间对应的内存区没有交集,则可以表示上述文件中 新增了第二文件内容, 第三内存区是为第二文件内容分配了新内存区, 即存储 上述文件的内存区发生了变化, 存储上述文件的内存区被扩容了。 器 1002可更新第一文件页表,以使得更新后的第一文件页表指向文件存储内存 区中当前存储上述文件的内存区。
当然, 进一步的, 处理器 1002可将上述内存页表中记录的上述第一虚实地 址映射关系更新为第三虚实地址映射关系,上述第三虚实地址映射关系包括上 述第一虚拟地址空间与上述第三物理地址空间之间的映射关系, 其中, 上述第 三物理地址空间为文件存储内存区中当前存储上述文件的内存区的物理地址 空间。 其中, 若内存页表中记录的是指向第一文件页表的指针(例如内存页表 中记录的第一文件页表的起始物理地址;), 若更新后的第一文件页表的起始物 理地址未变化, 可不修改内存页表中记录的是指向第一文件页表的指针。 而在 这种情况下, 更新第一文件页表而无需修改内存页表, 即可重建虚实地址映射 关系, 极大的筒化了映射操作。
在本发明的一些实施例中, 处理器 1002通过总线 1001 , 调用存储器 1003 中存储的代码以还用于,接收用于请求关闭上述文件的文件关闭请求; 释放为 上述文件分配的第一虚拟地址空间;释放上述内存页表中记录的上述第一虚实 地址映射关系。 在本发明的一些实施例中, 处理器 1002通过总线 1001 , 调用存储器 1003 识所表示的文件,在上述文件存储内存区之中创建上述文件, 为上述文件分配 第二索引节点, 其中, 上述第二索引节点中记录有第二文件页表或者用于指向 第二文件页表的指针, 其中, 上述第二文件页表用于指向上述文件存储内存区 之中存储上述文件的内存区; 为上述文件分配第二虚拟地址空间; 利用内存页 表记录第二虚实地址映射关系; 其中, 上述第二虚实地址映射关系包括上述第 二虚拟地址空间与上述第二物理地址空间之间的映射关系, 其中, 上述第二物
在本发明另一些实施例中,接收携带文件标识的文件打开请求之后, 当确 定上述文件存储内存区中未存储有上述文件标识所表示的文件,在上述文件存 储内存区之中创建上述文件, 为上述文件分配第三索引节点, 此时处理器 1002 可先不创建该文件的文件页表或创建该文件的空文件页表(其中, 若创建该文 件的空文件页表,则第三索引节点中可包含上述空文件页表或者用于指向上述 空文件页表的指针),当需要向创建的上述文件中写入文件内容时,处理器 1002 可扩容存储上述文件的内存区 (如从 10MB扩容至 1000MB ), 处理器 1002更新 上述文件的文件页表以使得更新后的文件页表指向扩容之后的存储上述文件 的内存区。
在本发明的一些实施例中,上述第二文件页表的级数与上述文件的文件类 型之间具有对应关系。
在本发明的一些实施例中, 上述文件存储内存区包括非易失性内存区和 / 或易失性内存区。
可以理解的是,本实施例的计算节点 1000的各功能模块的功能可根据上述 方法实施例中的方法具体实现,其具体实现过程可以参照上述方法实施例的相 关描述, 此处不再赘述。
其中, 计算节点 1000可为服务器、 个人计算机、 网元、 移动终端等等具有 内存的设备。 可以看出, 本实施例的上述技术方案之中, 处理器在接收携带文件标识的 文件打开请求之后; 获得上述文件标识所表示的文件的第一索引节点, 并基于 一物理地址空间; 为上述文件分配第一虚拟地址空间; 利用内存页表记录第一 虚实地址映射关系; 其中, 上述第一虚实地址映射关系为上述第一虚拟地址空 间与上述第一物理地址空间之间的映射关系, 其中, 上述内存页表包括内核内 存页表和 /或用户进程内存页表。 由于是利用内核内存页表和 /或用户进程内存 页表来记录第一虚实地址映射关系,可认为是在一定程度上将文件存储内存区 之中存储上述文件的内存区的第一物理地址空间,包装成进程工作内存区之中 的某内存区对应的物理地址空间,这有利于使得内核或用户进程按照类似访问 户进程以近似普通内存数据的访问性能来访问常驻内核的文件系统的文件,有 利于极大的提高文件访问性能。可见, 上述文件访问方案比较适用于在文件系 统常驻内存场景下进行文件高性能访问。 并且, 由于是在请求打开文件时才为 文件分配虚拟地址空间,这样有利于减少系统虚拟地址空间的无效占用和地址 沖突可能性, 有利于提高系统虚拟地址空间的利用效率。
进一步的, 由于在打开文件过程中可为文件分配连续虚拟地址空间, 因此 有利于实现从读写文件的起始虚拟地址开始,一次性访问所需读写长度之内的 内存页, 而不需要在软件层面多次查找不同内存页的对应虚拟地址, 这样文件 顺序访问速度可以非常快。
借助 MMU可透明地完成文件的虚拟地址和物理地址之间的转换, 这有利 于加快文件访问速度快、 甚至实现零开销。
进一步的,若采用数据结构与内存页表类似或相同的文件页表来指向文件 存储内存区中存储文件内容的内存页,由于文件页表与内存页表的数据结构类 似或相同,有利于实现页表数据结构的零转换, 并且当存储文件内容的内存页 发生变化时也可能无需对文件页表执行重建文件物理地址空间与虚拟地址空 间的映射关系的操作,通过更新文件页表,将用于指向更新的文件页表的指针 插入文件页表的表项中, 进而完成重建文件物理地址与虚拟地址的映射, 这种 方式有利于在与文件大小无关的常数时间之内,重建文件物理地址与虚拟地址 的映射。
进一步的, 由于可以为不同的文件分配独立的虚拟地址空间,使得文件系 统在文件存储内存区的文件受系统虚拟地址和 MMU的保护, 极大的减少被误 写的可能性, 不仅可以良好的保护文件, 且不需要额外的写保护机制, 有利于 筒化系统。
进一步的, 由于是通过虚拟地址访问文件, 文件的大小只受系统虚拟地址 空间的大小, 以及操作系统支持的同时打开的文件数量的影响, 这两者都不是 文件系统本身的限制, 因此文件大小可不受文件系统本身设计限制。
进一步的, 文件系统采用与内存管理相似的方式,都是通过虚拟地址访问 存储介质, 且都可利用 MMU进行虚拟地址和物理地址的转换, 对内核的改动 可以相对较少, 这样也便于文件系统移植到现有的操作系统中。
参见图 11 , 图 11是本发明另一实施例提供的计算节点 1100的结构框图。 其中, 计算节点 1100可以包括: 至少一个处理器 1101 , 至少一个网络接口 1104或者其他用户接口 1103, 存储器 1105, 至少一个通信总线 1102。 通信总线 1102用于实现这些组件之间的连接通信。 其中, 该计算节点 1100可选的包含用 户接口 1103 ,包括:显示器(例如,触摸屏、 LCD, CRT,全息成像( Holographic ) 或者投影 (Projector )等)、 点击设备(例如, 鼠标, 轨迹球(trackball )触感 板或触摸屏等)、 摄像头和 /或拾音装置等。
其中, 存储器 1102例如可包括只读存储器和随机存取存储器, 并向处理器
1101提供指令和数据。
存储器 1102中的一部分还包括非易失性内存(NVRAM )等。
举例来说, 其中, 存储器 1102可包括内存, 还可包括外存。 上述内存可以 包括: 文件存储内存区和进程工作内存区, 其中, 上述进程工作内存区存储有 内存页表, 上述进程工作内存区之中运行有操作系统。 例如, 上述进程工作内 存区可包括内核进程工作内存区和用户进程工作内存区, 其中, 内核内存页表 可存储于内核进程工作内存区,用户进程内存页表可存储于上述用户进程工作 内存区。。 在一些实施方式中,存储器 1105存储了如下的元素, 可执行模块或者数据 结构, 或者他们的子集, 或者他们的扩展集:
操作系统 11051 , 包含各种系统程序, 用于实现各种基础业务以及处理基 于硬件的任务。
应用程序模块 11052, 包含各种应用程序, 用于实现各种应用业务。
在本发明实施例中, 通过调用存储器 1105存储的程序或指令, 处理器 1101 接收携带文件标识的文件打开请求;获得上述文件标识所表示的文件的第一索 引节点, 其中, 上述文件存储于文件存储内存区之中; 基于上述第一索引节点 上述文件分配第一虚拟地址空间; 利用内存页表记录第一虚实地址映射关系; 其中,上述第一虚实地址映射关系包括上述第一虚拟地址空间与上述第一物理 地址空间之间的映射关系, 其中, 上述内存页表包括内核内存页表和 /或用户 进程内存页表。
在本发明一些实施例中, 上述文件打开请求可以携带文件存储路径 (即请 求打开的文件的存储路径), 其中, 上述文件标识可包含在上述文件存储路径 之中, 当然, 上述文件打开请求中也可能携带文件标识并且可不携带文件存储 路径。 进一步的, 上述文件打开请求中还可携带文件类型标志位, 该文件类型 标志位可指示出上述文件标识所表示的文件的文件类型(文件类型可能是目录 文件或数据文件)。
在本发明的一些实施例中,在上述基于上述第一索引节点得到上述文件存 储内存区之中存储上述文件的内存区的第一物理地址空间的方面,通过调用存 储器 1105存储的程序或指令, 处理器 1101以具体用于,基于上述第一索引节点 中记录的第一文件页表或用于指向第一文件页表的指针,得到上述文件存储内 存区之中存储上述文件的内存区的第一物理地址空间, 其中, 上述第一文件页
上述第一文件页表为单级或多级文件页表。
其中, 进程工作内存区是指, 用于存放进程运行时的工作环境所包含的数 据结构和变量等内容的物理内存区域。其中, 上述数据结构和变量可包括如下 信息的至少一种: 进程运行时的堆、 栈、 内存映射区、 进程所对应的程序的变 量、 字符和数组等数据。
举例来说, 用户进程工作内存区可以是指, 用于存放用户进程运行时的工 作环境所包含的数据结构和变量等内容的物理内存区域。 其中, 用户进程工作 内存区存放的上述数据结构和变量例如可包括如下信息的至少一种:用户进程 运行时的堆、 栈、 内存映射区、 用户进程所对应的程序的变量、 字符和数组等 数据。
又举例来说, 内核进程工作内存区可以是指, 用于存放内核进程运行时的 工作环境所包含的数据结构和变量等内容的物理内存区域。其中, 内核进程工 作内存区存放的上述数据结构和变量例如可包括如下信息的至少一种:内核进 程运行时的堆、 栈、 内存映射区、 内核进程所对应的程序的变量、 字符和数组 等数据。
其中, 文件存储内存区可指用于存储文件系统的物理内存区域, 文件存储 内存区中可存放文件系统本身的各种信息, 例如, 文件存储内存区中可存放文 件系统的索引节点和文件, 还可进一步存放文件系统的超级块(若存在)等等 信息。
在本发明一些实施例中, 上述文件存储内存区可包括非易失性内存区和 / 或易失性内存区 (即, 文件存储内存区的存储介质包括非易失性存储介质和 / 或易失性存储介质)。 其中, 进程工作内存区 (如内核进程工作内存区、 用户 进程工作内存区)可包括非易失性内存区和 /或易失性内存区 (即进程工作内 存区的存储介质包括非易失性存储介质和 /或易失性存储介质)。 其中, 进程工 作内存区(如内核进程工作内存区、 用户进程工作内存区)和文件存储内存区 互不重叠。
在本发明的一些实施例中,在上述利用内存页表记录第一虚实地址映射关 系的方面, 通过调用存储器 1105存储的程序或指令, 处理器 1101以具体用于在 内存页表中增加用于记录上述第一虚实地址映射关系的表项,上述表项包含上 述第一文件页表或用于指向上述第一文件页表的指针。 在本发明的一些实施例中, 上述内存页表的总级数为 Y, 上述第一文件页 表的总级数为 X, 若上述表项包含上述第一文件页表, 则上述表项为上述内存 页表中的第 Y-X+1级内存页表中的表项, 若上述表项包含用于指向上述第一文 件页表的指针, 则上述表项为上述内存页表中的第 Y-X级内存页表中的表项, 上述 X为正整数, 上述 Y为大于上述 X的正整数。
在本发明的一些实施例中, 通过调用存储器 1105存储的程序或指令, 处理 器 1101还用于, 在上述第一索引节点中记录上述第一虚拟地址空间和 /或上述 第一虚拟地址空间的起始地址, 和 /或, 在上述文件对应的文件对象之中记录 上述第一虚拟地址空间和 /或上述第一虚拟地址空间的起始地址。
在本发明的一些实施例中,上述第一虚拟地址空间为连续的或者非连续的 虚拟地址空间。
在本发明的一些实施例中,上述第一虚拟地址空间处于内核虚拟地址空间 或者用户进程虚拟地址空间。
在本发明的一些实施例中,在上述获得上述文件标识所表示的文件的第一 索引节点的方面, 通过调用存储器 1105存储的程序或指令, 处理器 1101具体用 述文件标识所表示的文件的第一索引节点。
在本发明的一些实施例中, 通过调用存储器 1105存储的程序或指令, 处理 器 1101还用于,接收用于请求读取上述文件的文件内容的文件读取请求,其中, 上述文件读取请求携带有读入内存地址空间和请求读取的上述文件中的第一 文件内容的数据量, 其中, 上述读入内存地址空间为用户进程工作内存区之中 的第一内存区的地址空间;基于上述第一文件内容的数据量、上述第一虚拟地 址空间和上述内存页表记录的上述第一虚实地址映射关系,得到从上述文件存 储内存区读取上述第一文件内容的读取物理地址空间;基于上述读取物理地址 空间,从上述文件存储内存区之中读取出上述文件的第一文件内容; 将上述第 一文件内容写入上述第一内存区。
在本发明的一些实施例中,在上述基于上述第一文件内容的数据量、上述 第一虚拟地址空间和上述内存页表记录的上述第一虚实地址映射关系,得到从 上述文件存储内存区读取上述第一文件内容的读取物理地址空间的方面,通过 调用存储器 1105存储的程序或指令, 处理器 1101具体用于,
基于上述第一文件内容的数据量、第一文件内容偏移量、上述第一虚拟地 址空间和上述内存页表记录的上述第一虚实地址映射关系,得到从上述文件存 储内存区读取上述第一文件内容的读取物理地址空间, 其中, 上述第一文件内 容偏移量从上述文件读取请求之中得到, 或者, 上述第一文件内容偏移量从上 述文件对应的文件对象之中得到。
例如, 可基于第一文件内容偏移量(其中, 若未从上述文件读取请求从上 述文件对应的文件对象之中得到第一文件内容偏移量,则可将默认文件内容偏 移量作为第一文件内容偏移量 )和上述第一虚拟地址空间的起始地址,得到读 取上述第一文件内容的起始读取虚拟地址;利用上述起始读取虚拟地址和第一 虚实地址映射关系,得到从上述文件存储内存区读取上述第一文件内容的起始 读取物理地址;基于上述起始读取物理地址和第一文件内容的数据量,得到从 上述文件存储内存区读取上述第一文件内容的读取物理地址空间。
又例如, 可基于第一文件内容偏移量(其中, 若未从上述文件读取请求从 上述文件对应的文件对象之中得到第一文件内容偏移量,则可将默认文件内容 偏移量作为第一文件内容偏移量 )和上述第一虚拟地址空间的起始地址,得到 读取上述第一文件内容的起始读取虚拟地址;基于起始读取虚拟地址和第一文 件内容的数据量,得到读取上述第一文件内容的读取虚拟地址空间; 利用上述 读取虚拟地址空间和第一虚实地址映射关系,得到从上述文件存储内存区读取 上述第一文件内容的读取物理地址空间。
在本发明的一些实施例中, 通过调用存储器 1105存储的程序或指令, 处理 器 1101还用于,接收请求向上述文件之中写入文件内容的文件写入请求,其中, 上述文件写入请求携带有读出内存地址空间和请求写入上述文件之中的第二 文件内容的数据量, 其中, 上述读出内存地址空间为上述进程工作内存区之中 的第二内存区的地址空间;
基于上述第二文件内容的数据量、上述第一虚拟地址空间和上述内存页表 记录的上述第一虚实地址映射关系,得到向上述文件存储内存区写入上述第二 文件内容的写入物理地址空间, 其中, 上述写入物理地址空间为上述文件存储 内存区之中的第三内存区的物理地址空间;
将上述第二内存区之中緩存的上述第二文件内容写入到上述第三内存区 之中。
在本发明的一些实施例中,在上述基于上述第二文件内容的数据量、上述 第一虚拟地址空间和上述内存页表记录的上述第一虚实地址映射关系,得到向 上述文件存储内存区写入上述第二文件内容的写入物理地址空间的方面,通过 调用存储器 1105存储的程序或指令, 处理器 1101具体用于,
基于上述第二文件内容的数据量、第二文件内容偏移量、上述第一虚拟地 址空间和上述内存页表记录的上述第一虚实地址映射关系,得到向上述文件存 储内存区写入上述第二文件内容的写入物理地址空间, 其中, 上述第二文件内 容偏移量从上述文件写入请求之中得到, 或者, 上述第二文件内容偏移量从上 述文件对应的文件对象之中得到。
例如, 可基于第二文件内容偏移量(其中, 若未从上述文件写入请求从上 述文件对应的文件对象之中得到第二文件内容偏移量,则可将默认文件内容偏 移量作为第二文件内容偏移量 )和上述第一虚拟地址空间的起始地址,得到向 上述文件写入上述第二文件内容的起始写入虚拟地址;利用上述起始写入虚拟 地址和第一虚实地址映射关系,得到向从上述文件存储内存区的上述文件中写 入上述第二文件内容的起始写入物理地址;基于上述起始写入物理地址和第二 文件内容的数据量,得到向上述文件存储内存区的上述文件中写入上述第二文 件内容的写入物理地址空间。
又例如, 可基于第二文件内容偏移量(其中, 若未从上述文件写入请求从 上述文件对应的文件对象之中得到第二文件内容偏移量,则可将默认文件内容 偏移量作为第二文件内容偏移量 )和上述第一虚拟地址空间的起始地址,得到 向上述文件中上述第二文件内容的起始写入虚拟地址;基于起始写入虚拟地址 和第二文件内容的数据量,得到向上述文件存储内存区的上述文件中写入上述 第二文件内容的写入虚拟地址空间;利用上述写入虚拟地址空间和第一虚实地 的写入物理地址空间。
其中,上述第三内存区的存储容量可以大于或者等于上述第二文件内容的 数据量。其中, 第三内存区和上述第一物理地址空间对应的内存区具有交集或 没有交集。 可以理解的是, 在通常情况下, 若第三内存区和上述第一物理地址 空间对应的内存区具有交集,则可以表示用第二文件内容替换了上述文件中原 有的部分或者全部文件内容(若第三内存区和上述第一物理地址空间对应的内 存区的交集小于第三内存区,表示为第二文件内容分配了新的内存区, 即存储 上述文件的内存区发生了变化, 存储上述文件的内存区被扩容了)。 若第三内 存区和上述第一物理地址空间对应的内存区没有交集,则可以表示上述文件中 新增了第二文件内容, 第三内存区是为第二文件内容分配了新内存区, 即存储 上述文件的内存区发生了变化, 存储上述文件的内存区被扩容了。 器 1101可更新第一文件页表,以使得更新后的第一文件页表指向文件存储内存 区中当前存储上述文件的内存区。
当然, 进一步的, 处理器 1101可将上述内存页表中记录的上述第一虚实地 址映射关系更新为第三虚实地址映射关系,上述第三虚实地址映射关系包括上 述第一虚拟地址空间与上述第三物理地址空间之间的映射关系, 其中, 上述第 三物理地址空间为文件存储内存区中当前存储上述文件的内存区的物理地址 空间。 其中, 若内存页表中记录的是指向第一文件页表的指针(例如内存页表 中记录的第一文件页表的起始物理地址), 若更新后的第一文件页表的起始物 理地址未变化, 可不修改内存页表中记录的是指向第一文件页表的指针。 而在 这种情况下, 更新第一文件页表而无需修改内存页表, 即可重建虚实地址映射 关系, 极大的筒化了映射操作。
在本发明的一些实施例中, 通过调用存储器 1105存储的程序或指令, 处理 器 1101还用于,接收用于请求关闭上述文件的文件关闭请求; 释放为上述文件 分配的第一虚拟地址空间;释放上述内存页表中记录的上述第一虚实地址映射 关系。
在本发明的一些实施例中, 通过调用存储器 1105存储的程序或指令, 处理 的文件,在上述文件存储内存区之中创建上述文件, 为上述文件分配第二索引 节点, 其中, 上述第二索引节点中记录有第二文件页表或者用于指向第二文件 页表的指针, 其中, 上述第二文件页表用于指向上述文件存储内存区之中存储 上述文件的内存区; 为上述文件分配第二虚拟地址空间; 利用内存页表记录第 二虚实地址映射关系; 其中, 上述第二虚实地址映射关系包括上述第二虚拟地 址空间与上述第二物理地址空间之间的映射关系, 其中, 上述第二物理地址空
在本发明另一些实施例中,接收携带文件标识的文件打开请求之后, 当确 定上述文件存储内存区中未存储有上述文件标识所表示的文件,在上述文件存 储内存区之中创建上述文件, 为上述文件分配第三索引节点, 此时处理器 1101 可先不创建该文件的文件页表或创建该文件的空文件页表(其中, 若创建该文 件的空文件页表,则第三索引节点中可包含上述空文件页表或者用于指向上述 空文件页表的指针),当需要向创建的上述文件中写入文件内容时,处理器 1101 可扩容存储上述文件的内存区 (如从 10MB扩容至 1100MB ), 处理器 1101更新 上述文件的文件页表以使得更新后的文件页表指向扩容之后的存储上述文件 的内存区。
在本发明的一些实施例中,上述第二文件页表的级数与上述文件的文件类 型之间具有对应关系。
在本发明的一些实施例中, 上述文件存储内存区包括非易失性内存区和 / 或易失性内存区。
可以理解的是,本实施例的计算节点 1100的各功能模块的功能可根据上述 方法实施例中的方法具体实现,其具体实现过程可以参照上述方法实施例的相 关描述, 此处不再赘述。
可以看出, 本实施例的上述技术方案之中, 处理器在接收携带文件标识的 文件打开请求之后; 获得上述文件标识所表示的文件的第一索引节点, 并基于 一物理地址空间; 为上述文件分配第一虚拟地址空间; 利用内存页表记录第一 虚实地址映射关系; 其中, 上述第一虚实地址映射关系为上述第一虚拟地址空 间与上述第一物理地址空间之间的映射关系, 其中, 上述内存页表包括内核内 存页表和 /或用户进程内存页表。 由于是利用内核内存页表和 /或用户进程内存 页表来记录第一虚实地址映射关系,可认为是在一定程度上将文件存储内存区 之中存储上述文件的内存区的第一物理地址空间,包装成进程工作内存区之中 的某内存区对应的物理地址空间,这有利于使得内核或用户进程按照类似访问 户进程以近似普通内存数据的访问性能来访问常驻内核的文件系统的文件,有 利于极大的提高文件访问性能。可见, 上述文件访问方案比较适用于在文件系 统常驻内存场景下进行文件高性能访问。 并且, 由于是在请求打开文件时才为 文件分配虚拟地址空间,这样有利于减少系统虚拟地址空间的无效占用和地址 沖突可能性, 有利于提高系统虚拟地址空间的利用效率。
进一步的, 由于在打开文件过程中可为文件分配连续虚拟地址空间, 因此 有利于实现从读写文件的起始虚拟地址开始,一次性访问所需读写长度之内的 内存页, 而不需要在软件层面多次查找不同内存页的对应虚拟地址, 这样文件 顺序访问速度可以非常快。
借助 MMU可透明地完成文件的虚拟地址和物理地址之间的转换, 这有利 于加快文件访问速度快、 甚至实现零开销。
进一步的,若采用数据结构与内存页表类似或相同的文件页表来指向文件 存储内存区中存储文件内容的内存页,由于文件页表与内存页表的数据结构类 似或相同,有利于实现页表数据结构的零转换, 并且当存储文件内容的内存页 发生变化时也可能无需对文件页表执行重建文件物理地址空间与虚拟地址空 间的映射关系的操作,通过更新文件页表,将用于指向更新的文件页表的指针 插入文件页表的表项中, 进而完成重建文件物理地址与虚拟地址的映射, 这种 方式有利于在与文件大小无关的常数时间之内,重建文件物理地址与虚拟地址 的映射。
进一步的, 由于可以为不同的文件分配独立的虚拟地址空间,使得文件系 统在文件存储内存区的文件受系统虚拟地址和 MMU的保护, 极大的减少被误 写的可能性, 不仅可以良好的保护文件, 且不需要额外的写保护机制, 有利于 筒化系统。
进一步的, 由于是通过虚拟地址访问文件, 文件的大小只受系统虚拟地址 空间的大小, 以及操作系统支持的同时打开的文件数量的影响, 这两者都不是 文件系统本身的限制, 因此文件大小可不受文件系统本身设计限制。
进一步的, 文件系统采用与内存管理相似的方式,都是通过虚拟地址访问 存储介质, 且都可利用 MMU进行虚拟地址和物理地址的转换, 对内核的改动 可以相对较少, 这样也便于文件系统移植到现有的操作系统中。
本发明各实施例的计算节点可为服务器、 个人计算机、 网元、 移动终端等 等具有内存的设备。
本发明实施例还提供一种计算机存储介质, 其中, 该计算机存储介质可存 储有程序,该程序执行时包括上述方法实施例中记载的至少一种访问文件的方 法的部分或全部步骤。
在上述实施例中,对各个实施例的描述都各有侧重, 某个实施例中没有详 述的部分, 可以参见其他实施例的相关描述。
需要说明的是, 对于前述的各方法实施例, 为了筒单描述, 故将其都表述 为一系列的动作组合,但是本领域技术人员应该知悉, 本发明并不受所描述的 动作顺序的限制,因为依据本发明,某些步骤可以采用其他顺序或者同时进行。 其次, 本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施 例, 所涉及的动作和模块并不一定是本发明所必须的。
在本申请所提供的几个实施例中, 应该理解到, 所揭露的装置, 可通过其 它的方式实现。 例如, 以上所描述的装置实施例仅仅是示意性的, 例如所述单 元的划分, 仅仅为一种逻辑功能划分, 实际实现时可以有另外的划分方式, 例 如多个单元或组件可以结合或者可以集成到另一个系统, 或一些特征可以忽 略, 或不执行。 另一点, 所显示或讨论的相互之间的耦合或直接耦合或通信连 接可以是通过一些接口, 装置或单元的间接耦合或通信连接, 可以是电性或其 它的形式。 所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为 单元显示的部件可以是或者也可以不是物理单元, 即可以位于一个地方, 或者 也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部 单元来实现本实施例方案的目的。
另外,在本发明各实施例中的各功能单元可以集成在一个处理单元中,也 可以是各个单元单独物理存在, 也可以两个或两个以上单元集成在一个单元 中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的 形式实现。
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售 或使用时, 可以存储在一个计算机可读取存储介质中。基于这样的理解, 本发 明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全 部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储 介质中, 包括若干指令用以使得一台计算机设备(可以为个人计算机、 服务器 或者网络设备等, 具体可以是计算机设备中的处理器)执行本发明各个实施例 所述方法的全部或部分步骤。 其中, 而前述的存储介质可包括: U盘、 移动硬 盘、 磁碟、 光盘、 只读存储器(ROM, Read-Only Memory )或者随机存取存 储器(RAM, Random Access Memory )等各种可以存储程序代码的介质。
以上所述, 以上实施例仅用以说明本发明的技术方案, 而非对其限制; 尽 管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理 解: 其依然可以对前述各实施例所记载的技术方案进行修改, 或者对其中部分 技术特征进行等同替换; 而这些修改或者替换, 并不使相应技术方案的本质脱 离本发明各实施例技术方案的精神和范围。

Claims

权 利 要 求
1、 一种访问文件的方法, 其特征在于, 所述访问文件的方法应用于计算 节点中, 所述计算节点包括内存, 所述内存包括: 文件存储内存区和进程工作 内存区, 所述进程工作内存区存储有内存页表, 所述进程工作内存区之中运行 有操作系统,
其中, 所述访问文件的方法包括:
所述操作系统接收携带文件标识的文件打开请求;
所述操作系统获得所述文件标识所表示的文件的第一索引节点, 其中, 所 述文件存储于所述文件存储内存区之中;基于所述第一索引节点得到所述文件 存储内存区之中存储所述文件的内存区的第一物理地址空间;
所述操作系统为所述文件分配第一虚拟地址空间;
所述操作系统利用所述内存页表记录第一虚实地址映射关系;
其中,所述第一虚实地址映射关系包括所述第一虚拟地址空间与所述第一 物理地址空间之间的映射关系, 其中, 所述内存页表包括内核内存页表和 /或 用户进程内存页表。
2、 根据权利要求 1所述的方法, 其特征在于,
所述基于所述第一索引节点得到所述文件存储内存区之中存储所述文件 的内存区的第一物理地址空间, 包括: 基于所述第一索引节点中记录的第一文 件页表或用于指向第一文件页表的指针,得到所述文件存储内存区之中存储所 述文件的内存区的第一物理地址空间, 其中, 所述第一文件页表用于指向所述 文件存储内存区之中存储所述文件的内存区,所述的第一物理地址空间为所述 表为单级或多级文件页表。
3、 根据权利要求 2所述的方法, 其特征在于,
所述利用内存页表记录第一虚实地址映射关系, 包括: 在内存页表中增加 用于记录所述第一虚实地址映射关系的表项,所述表项包含所述第一文件页表 或用于指向所述第一文件页表的指针。
4、 根据权利要求 3所述的方法, 其特征在于, 所述内存页表的总级数为 Y, 所述第一文件页表的总级数为 X, 若所述表 项包含所述第一文件页表, 则所述表项为所述内存页表中的第 Υ-Χ+ 1级内存页 表中的表项, 若所述表项包含用于指向所述第一文件页表的指针, 则所述表项 为所述内存页表中的第 Υ-Χ级内存页表中的表项,所述 X为正整数,所述 Υ为大 于所述 X的正整数。
5、 根据权利要求 1至 4任一项所述的方法, 其特征在于,
所述方法还包括:
所述操作系统在所述第一索引节点中记录所述第一虚拟地址空间和 /或所 述第一虚拟地址空间的起始地址, 和 /或, 所述操作系统在所述文件对应的文 件对象之中记录所述第一虚拟地址空间和 /或所述第一虚拟地址空间的起始地 址。
6、 根据权利要求 1至 5任一项所述的方法, 其特征在于, 所述第一虚拟地 址空间为连续的或者非连续的虚拟地址空间。
7、 根据权利要求 1至 6任一项所述的方法, 其特征在于, 所述第一虚拟地 址空间处于内核虚拟地址空间或者用户进程虚拟地址空间。
8、 根据权利要求 1至 7任一项所述的方法, 其特征在于,
所述获得所述文件标识所表示的文件的第一索引节点包括:当确定所述文 件存储内存区之中存储有所述文件标识所表示的文件,获得所述文件标识所表 示的文件的第一索引节点。
9、 根据权利要求 1至 8任一项所述的方法, 其特征在于,
所述方法还包括:
所述操作系统接收用于请求读取所述文件的文件内容的文件读取请求,其 中,所述文件读取请求携带有读入内存地址空间和请求读取的所述文件中的第 一文件内容的数据量, 其中, 所述读入内存地址空间为用户进程工作内存区之 中的第一内存区的地址空间;
所述操作系统基于所述第一文件内容的数据量、所述第一虚拟地址空间和 所述内存页表记录的所述第一虚实地址映射关系,得到从所述文件存储内存区 读取所述第一文件内容的读取物理地址空间; 所述操作系统基于所述读取物理地址空间,从所述文件存储内存区之中读 取出所述文件的第一文件内容;
所述操作系统将所述第一文件内容写入所述第一内存区。
10、 根据权利要求 9所述的方法, 其特征在于,
所述基于所述第一文件内容的数据量、所述第一虚拟地址空间和所述内存 页表记录的所述第一虚实地址映射关系,得到从所述文件存储内存区读取所述 第一文件内容的读取物理地址空间, 包括:
基于所述第一文件内容的数据量、第一文件内容偏移量、所述第一虚拟地 址空间和所述内存页表记录的所述第一虚实地址映射关系,得到从所述文件存 储内存区读取所述第一文件内容的读取物理地址空间, 其中, 所述第一文件内 容偏移量从所述文件读取请求之中得到, 或者, 所述第一文件内容偏移量从所 述文件对应的文件对象之中得到。
11、 根据权利要求 1至 10任一项所述的方法, 其特征在于,
所述方法还包括:
所述操作系统接收请求向所述文件之中写入文件内容的文件写入请求,其 中,所述文件写入请求携带有读出内存地址空间和请求写入所述文件之中的第 二文件内容的数据量, 其中, 所述读出内存地址空间为所述进程工作内存区之 中的第二内存区的地址空间;
所述操作系统基于所述第二文件内容的数据量、所述第一虚拟地址空间和 所述内存页表记录的所述第一虚实地址映射关系,得到向所述文件存储内存区 写入所述第二文件内容的写入物理地址空间, 其中, 所述写入物理地址空间为 所述文件存储内存区之中的第三内存区的物理地址空间;
所述操作系统将所述第二内存区之中緩存的所述第二文件内容写入到所 述第三内存区之中。
12、 根据权利要求 11所述的方法, 其特征在于,
所述基于所述第二文件内容的数据量、所述第一虚拟地址空间和所述内存 页表记录的所述第一虚实地址映射关系,得到向所述文件存储内存区写入所述 第二文件内容的写入物理地址空间, 包括: 基于所述第二文件内容的数据量、第二文件内容偏移量、所述第一虚拟地 址空间和所述内存页表记录的所述第一虚实地址映射关系,得到向所述文件存 储内存区写入所述第二文件内容的写入物理地址空间, 其中, 所述第二文件内 容偏移量从所述文件写入请求之中得到, 或者, 所述第二文件内容偏移量从所 述文件对应的文件对象之中得到。
13、 根据权利要求 11或 12所述的方法, 其特征在于, 所述第三内存区的存 储容量大于或者等于所述第二文件内容的数据量。
14、 根据权利要求 1至 13任一项所述的方法, 其特征在于,
所述方法还包括: 接收用于请求关闭所述文件的文件关闭请求; 释放为所 述文件分配的第一虚拟地址空间;释放所述内存页表中记录的所述第一虚实地 址映射关系。
15、 根据权利要求 7所述的方法, 其特征在于,
所述方法还包括:所述操作系统当确定所述文件存储内存区之中未存储有 所述文件标识所表示的文件,在所述文件存储内存区之中创建所述文件, 为所 述文件分配第二索引节点, 其中, 所述第二索引节点中记录有第二文件页表或 者用于指向第二文件页表的指针, 其中, 所述第二文件页表用于指向所述文件 存储内存区之中存储所述文件的内存区;
所述操作系统为所述文件分配第二虚拟地址空间;
所述操作系统利用内存页表记录第二虚实地址映射关系;
其中,所述第二虚实地址映射关系包括所述第二虚拟地址空间与所述第二 物理地址空间之间的映射关系, 其中, 所述第二物理地址空间为所述文件存储 内存区之中存储所述文件的内存区的物理地址空间,所述内存页表包括内核内 存页表和 /或用户进程内存页表。
16、 根据权利要求 15所述的方法, 其特征在于, 所述第二文件页表的级数 与所述文件的文件类型之间具有对应关系。
17、 根据权利要求 1至 16任一项所述的方法, 其特征在于, 所述文件存储 内存区包括非易失性内存区和 /或易失性内存区。
18、 一种访问文件的装置, 其特征在于, 包括: 接收单元, 用于接收携带文件标识的文件打开请求;
获取单元, 用于获得所述文件标识所表示的文件的第一索引节点, 所述文 件存储于文件存储内存区之中;基于所述第一索引节点得到所述文件存储内存 区之中存储所述文件的内存区的第一物理地址空间;
分配单元, 用于为所述文件分配第一虚拟地址空间;
映射单元, 用于利用内存页表记录第一虚实地址映射关系;
其中,所述第一虚实地址映射关系包括所述第一虚拟地址空间与所述第一 物理地址空间之间的映射关系, 其中, 所述内存页表包括内核内存页表和 /或 用户进程内存页表。
19、 根据权利要求 18所述的装置, 其特征在于,
在所述基于所述第一索引节点得到所述文件存储内存区之中存储所述文 件的内存区的第一物理地址空间的方面, 所述获取单元具体用于,基于所述第 一索引节点中记录的第一文件页表或用于指向第一文件页表的指针,得到所述 文件存储内存区之中存储所述文件的内存区的第一物理地址空间, 其中, 所述
理地址空间, 所述第一文件页表为单级或多级文件页表。
20、 根据权利要求 19所述的装置, 其特征在于,
所述映射单元具体用于:在内存页表中增加用于记录所述第一虚实地址映 射关系的表项,所述表项包含所述第一文件页表或用于指向所述第一文件页表 的指针。
21、 根据权利要求 20所述的装置, 其特征在于,
所述内存页表的总级数为 Y, 所述第一文件页表的总级数为 X, 若所述表 项包含所述第一文件页表, 则所述表项为所述内存页表中的第 Y-X+ 1级内存页 表中的表项, 若所述表项包含用于指向所述第一文件页表的指针, 则所述表项 为所述内存页表中的第 Y-X级内存页表中的表项,所述 X为正整数,所述 Y为大 于所述 X的正整数。
22、 根据权利要求 18至 21任一项所述的装置, 其特征在于, 所述访问文件的装置还包括:
记录单元, 用于在所述第一索引节点中记录所述第一虚拟地址空间和 /或 所述第一虚拟地址空间的起始地址, 和 /或, 在所述文件对应的文件对象之中 记录所述第一虚拟地址空间和 /或所述第一虚拟地址空间的起始地址。
23、 根据权利要求 18至 22任一项所述的装置, 其特征在于, 所述第一虚拟 地址空间为连续的或者非连续的虚拟地址空间。
24、 根据权利要求 18至 23任一项所述的装置, 其特征在于, 所述第一虚拟 地址空间处于内核虚拟地址空间或者用户进程虚拟地址空间。
25、 根据权利要求 18至 24任一项所述的装置, 其特征在于,
所述获取单元具体用于:当确定所述文件存储内存区之中存储有所述文件 标识所表示的文件, 获得所述文件标识所表示的文件的第一索引节点。
26、 根据权利要求 18至 25任一项所述的装置, 其特征在于,
所述接收单元还用于,接收用于请求读取所述文件的文件内容的文件读取 请求, 其中, 所述文件读取请求携带有读入内存地址空间和请求读取的所述文 件中的第一文件内容的数据量, 其中, 所述读入内存地址空间为用户进程工作 内存区之中的第一内存区的地址空间;
所述访问文件的装置还包括: 第二映射单元, 用于基于所述第一文件内容 的数据量、所述第一虚拟地址空间和所述内存页表记录的所述第一虚实地址映 射关系,得到从所述文件存储内存区读取所述第一文件内容的读取物理地址空 间;
第一读写单元, 用于基于所述读取物理地址空间,从所述文件存储内存区 之中读取出所述文件的第一文件内容;将所述第一文件内容写入所述第一内存 区。
27、 根据权利要求 26所述的装置, 其特征在于,
在所述基于所述第一文件内容的数据量、所述第一虚拟地址空间和所述内 存页表记录的所述第一虚实地址映射关系,得到从所述文件存储内存区读取所 述第一文件内容的读取物理地址空间的方面, 第二映射单元具体用于,基于所 述第一文件内容的数据量、第一文件内容偏移量、所述第一虚拟地址空间和所 述内存页表记录的所述第一虚实地址映射关系,得到从所述文件存储内存区读 取所述第一文件内容的读取物理地址空间, 其中, 所述第一文件内容偏移量从 所述文件读取请求之中得到, 或者, 所述第一文件内容偏移量从所述文件对应 的文件对象之中得到。
28、 根据权利要求 18至 27任一项所述的装置, 其特征在于, 请求, 其中, 所述文件写入请求携带有读出内存地址空间和请求写入所述文件 之中的第二文件内容的数据量, 其中, 所述读出内存地址空间为所述进程工作 内存区之中的第二内存区的地址空间;
所述访问文件的装置还包括: 第三映射单元, 用于基于所述第二文件内容 的数据量、所述第一虚拟地址空间和所述内存页表记录的所述第一虚实地址映 射关系,得到向所述文件存储内存区写入所述第二文件内容的写入物理地址空 间, 其中, 所述写入物理地址空间为所述文件存储内存区之中的第三内存区的 物理地址空间;
第二读写单元,用于将所述第二内存区之中緩存的所述第二文件内容写入 到所述第三内存区之中。
29、 根据权利要求 28所述的装置, 其特征在于,
在所述基于所述第二文件内容的数据量、所述第一虚拟地址空间和所述内 存页表记录的所述第一虚实地址映射关系,得到向所述文件存储内存区写入所 述第二文件内容的写入物理地址空间的方面,所述第三映射单元具体用于基于 所述第二文件内容的数据量、第二文件内容偏移量、所述第一虚拟地址空间和 所述内存页表记录的所述第一虚实地址映射关系,得到向所述文件存储内存区 写入所述第二文件内容的写入物理地址空间, 其中, 所述第二文件内容偏移量 从所述文件写入请求之中得到, 或者, 所述第二文件内容偏移量从所述文件对 应的文件对象之中得到。
30、 根据权利要求 18至 29任一项所述的装置, 其特征在于,
所述接收单元还用于, 接收用于请求关闭所述文件的文件关闭请求; 所述访问文件的装置还包括: 释放单元, 用于释放为所述文件分配的第一 虚拟地址空间; 释放所述内存页表中记录的所述第一虚实地址映射关系。
31、 根据权利要求 18至 30任一项所述的装置, 其特征在于,
所述访问文件的装置还包括: 表示的文件,在所述文件存储内存区之中创建所述文件, 为所述文件分配第二 索引节点, 其中, 所述第二索引节点中记录有第二文件页表或者用于指向第二 文件页表的指针, 其中, 所述第二文件页表用于指向所述文件存储内存区之中 存储所述文件的内存区;
所述分配单元还用于, 为所述文件分配第二虚拟地址空间;
所述映射单元还用于, 利用内存页表记录第二虚实地址映射关系; 其中,所述第二虚实地址映射关系包括所述第二虚拟地址空间与所述第二 物理地址空间之间的映射关系, 其中, 所述第二物理地址空间为所述文件存储 内存区之中存储所述文件的内存区的物理地址空间,所述内存页表包括内核内 存页表和 /或用户进程内存页表。
32、 根据权利要求 31所述的装置, 其特征在于, 所述第二文件页表的级数 与所述文件的文件类型之间具有对应关系。
33、 根据权利要求 18至 32任一项所述的装置, 其特征在于, 所述文件存储 内存区包括非易失性内存区和 /或易失性内存区。
34、 一种计算节点, 其特征在于, 包括:
至少一个总线、与所述总线相连的至少一个处理器以及与所述总线相连的 至少一个存储器;
其中, 所述处理器通过所述总线调用所述存储器中存储的代码以用于, 接收携带文件标识的文件打开请求;获得所述文件标识所表示的文件的第 一索引节点, 其中, 所述文件存储于文件存储内存区之中; 基于所述第一索引 间; 为所述文件分配第一虚拟地址空间; 利用内存页表记录第一虚实地址映射 关系; 其中, 所述第一虚实地址映射关系包括所述第一虚拟地址空间与所述第 一物理地址空间之间的映射关系, 其中, 所述内存页表包括内核内存页表和 / 或用户进程内存页表。
35、 根据权利要求 34所述的计算节点, 其特征在于,
在所述基于所述第一索引节点得到所述文件存储内存区之中存储所述文 件的内存区的第一物理地址空间的方面,所述处理器通过所述总线调用所述存 储器中存储的代码以具体用于,基于所述第一索引节点中记录的第一文件页表 或用于指向第一文件页表的指针,得到所述文件存储内存区之中存储所述文件 的内存区的第一物理地址空间, 其中, 所述第一文件页表用于指向所述文件存 储内存区之中存储所述文件的内存区,所述的第一物理地址空间为所述文件存 储内存区之中存储所述文件的内存区的物理地址空间,所述第一文件页表为单 级或多级文件页表。
36、 根据权利要求 35所述的计算节点, 其特征在于,
在所述利用内存页表记录第一虚实地址映射关系的方面,所述处理器通过 所述总线调用所述存储器中存储的代码以具体用于,在内存页表中增加用于记 录所述第一虚实地址映射关系的表项,所述表项包含所述第一文件页表或用于 指向所述第一文件页表的指针。
37、 根据权利要求 36所述的计算节点, 其特征在于,
所述内存页表的总级数为 Y, 所述第一文件页表的总级数为 X, 若所述表 项包含所述第一文件页表, 则所述表项为所述内存页表中的第 Y-X+1级内存页 表中的表项, 若所述表项包含用于指向所述第一文件页表的指针, 则所述表项 为所述内存页表中的第 Y-X级内存页表中的表项,所述 X为正整数,所述 Y为大 于所述 X的正整数。
38、 根据权利要求 34至 37任一项所述的计算节点, 其特征在于, 所述处理器通过所述总线调用所述存储器中存储的代码以还用于,在所述 第一索引节点中记录所述第一虚拟地址空间和 /或所述第一虚拟地址空间的起 始地址, 和 /或, 在所述文件对应的文件对象之中记录所述第一虚拟地址空间 和 /或所述第一虚拟地址空间的起始地址。
39、 根据权利要求 34至 38任一项所述的计算节点, 其特征在于, 所述第一 虚拟地址空间为连续的或者非连续的虚拟地址空间。
40、 根据权利要求 34至 39任一项所述的计算节点, 其特征在于, 所述第一 虚拟地址空间处于内核虚拟地址空间或者用户进程虚拟地址空间。
41、 根据权利要求 34至 40任一项所述的计算节点, 其特征在于, 在所述获得所述文件标识所表示的文件的第一索引节点的方面,所述处理 器通过所述总线调用所述存储器中存储的代码以具体用于,当确定所述文件存 储内存区之中存储有所述文件标识所表示的文件,获得所述文件标识所表示的 文件的第一索引节点。
42、 根据权利要求 34至 41任一项所述的计算节点, 其特征在于, 所述处理器通过所述总线调用所述存储器中存储的代码以还用于,接收用 于请求读取所述文件的文件内容的文件读取请求, 其中, 所述文件读取请求携 带有读入内存地址空间和请求读取的所述文件中的第一文件内容的数据量,其 中,所述读入内存地址空间为用户进程工作内存区之中的第一内存区的地址空 间;基于所述第一文件内容的数据量、所述第一虚拟地址空间和所述内存页表 记录的所述第一虚实地址映射关系,得到从所述文件存储内存区读取所述第一 文件内容的读取物理地址空间;基于所述读取物理地址空间,从所述文件存储 内存区之中读取出所述文件的第一文件内容;将所述第一文件内容写入所述第 一内存区。
43、 根据权利要求 42所述的计算节点, 其特征在于,
在所述基于所述第一文件内容的数据量、所述第一虚拟地址空间和所述内 存页表记录的所述第一虚实地址映射关系,得到从所述文件存储内存区读取所 述第一文件内容的读取物理地址空间的方面,所述处理器通过所述总线调用所 述存储器中存储的代码以具体用于,
基于所述第一文件内容的数据量、第一文件内容偏移量、所述第一虚拟地 址空间和所述内存页表记录的所述第一虚实地址映射关系,得到从所述文件存 储内存区读取所述第一文件内容的读取物理地址空间, 其中, 所述第一文件内 容偏移量从所述文件读取请求之中得到, 或者, 所述第一文件内容偏移量从所 述文件对应的文件对象之中得到。
44、 根据权利要求 34至 43任一项所述的计算节点, 其特征在于, 所述处理器通过所述总线调用所述存储器中存储的代码以还用于,接收请 求向所述文件之中写入文件内容的文件写入请求,其中, 所述文件写入请求携 带有读出内存地址空间和请求写入所述文件之中的第二文件内容的数据量,其 中,所述读出内存地址空间为所述进程工作内存区之中的第二内存区的地址空 间;
基于所述第二文件内容的数据量、所述第一虚拟地址空间和所述内存页表 记录的所述第一虚实地址映射关系,得到向所述文件存储内存区写入所述第二 文件内容的写入物理地址空间, 其中, 所述写入物理地址空间为所述文件存储 内存区之中的第三内存区的物理地址空间;
将所述第二内存区之中緩存的所述第二文件内容写入到所述第三内存区 之中。
45、 根据权利要求 44所述的计算节点, 其特征在于,
在所述基于所述第二文件内容的数据量、所述第一虚拟地址空间和所述内 存页表记录的所述第一虚实地址映射关系,得到向所述文件存储内存区写入所 述第二文件内容的写入物理地址空间的方面,所述处理器通过所述总线调用所 述存储器中存储的代码以具体用于,
基于所述第二文件内容的数据量、第二文件内容偏移量、所述第一虚拟地 址空间和所述内存页表记录的所述第一虚实地址映射关系,得到向所述文件存 储内存区写入所述第二文件内容的写入物理地址空间, 其中, 所述第二文件内 容偏移量从所述文件写入请求之中得到, 或者, 所述第二文件内容偏移量从所 述文件对应的文件对象之中得到。
46、 根据权利要求 34至 45任一项所述的计算节点, 其特征在于, 所述处理 器通过所述总线调用所述存储器中存储的代码以还用于,接收用于请求关闭所 述文件的文件关闭请求; 释放为所述文件分配的第一虚拟地址空间; 释放所述 内存页表中记录的所述第一虚实地址映射关系。
47、 根据权利要求 34至 46任一项所述的计算节点, 其特征在于, 所述处理 器通过所述总线调用所述存储器中存储的代码以还用于,当确定所述文件存储 内存区之中未存储有所述文件标识所表示的文件,在所述文件存储内存区之中 创建所述文件, 为所述文件分配第二索引节点, 其中, 所述第二索引节点中记 录有第二文件页表或者用于指向第二文件页表的指针, 其中, 所述第二文件页 为所述文件分配第二虚拟地址空间;
利用内存页表记录第二虚实地址映射关系;
其中,所述第二虚实地址映射关系包括所述第二虚拟地址空间与所述第二 物理地址空间之间的映射关系, 其中, 所述第二物理地址空间为所述文件存储 内存区之中存储所述文件的内存区的物理地址空间,所述内存页表包括内核内 存页表和 /或用户进程内存页表。
48、 根据权利要求 47所述的计算节点, 其特征在于, 所述第二文件页表的 级数与所述文件的文件类型之间具有对应关系。
49、 根据权利要求 34至 48任一项所述的计算节点, 其特征在于, 所述文件 存储内存区包括非易失性内存区和 /或易失性内存区。
50、 一种计算机存储介质, 其特征在于,
所述计算机存储介质存储有程序, 所述程序执行时包括如权利要求 1至 17 任一项所述的步骤。
PCT/CN2014/073070 2014-03-07 2014-03-07 访问文件的方法和相关设备 WO2015131403A1 (zh)

Priority Applications (6)

Application Number Priority Date Filing Date Title
PCT/CN2014/073070 WO2015131403A1 (zh) 2014-03-07 2014-03-07 访问文件的方法和相关设备
CN201480000730.XA CN105378687B (zh) 2014-03-07 2014-03-07 访问文件的方法和相关设备
EP14884527.4A EP3115903B1 (en) 2014-03-07 2014-03-07 File accessing method and related device
JP2016572867A JP6385468B2 (ja) 2014-03-07 2014-03-07 ファイルアクセス方法及び関係するデバイス
KR1020167025615A KR102061079B1 (ko) 2014-03-07 2014-03-07 파일 액세스 방법 및 관련 기기
US15/257,928 US10452562B2 (en) 2014-03-07 2016-09-07 File access method and related device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2014/073070 WO2015131403A1 (zh) 2014-03-07 2014-03-07 访问文件的方法和相关设备

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US15/257,928 Continuation US10452562B2 (en) 2014-03-07 2016-09-07 File access method and related device

Publications (1)

Publication Number Publication Date
WO2015131403A1 true WO2015131403A1 (zh) 2015-09-11

Family

ID=54054406

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/073070 WO2015131403A1 (zh) 2014-03-07 2014-03-07 访问文件的方法和相关设备

Country Status (6)

Country Link
US (1) US10452562B2 (zh)
EP (1) EP3115903B1 (zh)
JP (1) JP6385468B2 (zh)
KR (1) KR102061079B1 (zh)
CN (1) CN105378687B (zh)
WO (1) WO2015131403A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110018998A (zh) * 2019-04-12 2019-07-16 深信服科技股份有限公司 一种文件管理方法、系统及电子设备和存储介质
WO2020057394A1 (zh) * 2018-09-19 2020-03-26 华为技术有限公司 监控样本进程的内存访问行为的方法和装置

Families Citing this family (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP3173931B1 (en) * 2014-09-01 2018-08-29 Huawei Technologies Co., Ltd. File access method, device and storage system
US10339065B2 (en) * 2016-12-01 2019-07-02 Ampere Computing Llc Optimizing memory mapping(s) associated with network nodes
CN107493329A (zh) * 2017-08-15 2017-12-19 诸葛晴凤 一种分布式内存文件系统的远程文件访问方法
US11119939B2 (en) * 2017-08-21 2021-09-14 Alibaba Group Holding Limited Methods and systems for memory management of kernel and user spaces
US11042394B2 (en) 2017-10-13 2021-06-22 Electronics And Telecommunications Research Institute Method for processing input and output on multi kernel system and apparatus for the same
CN113835898B (zh) * 2017-11-29 2024-03-01 北京忆芯科技有限公司 存储器分配器
WO2019127135A1 (zh) * 2017-12-27 2019-07-04 华为技术有限公司 文件页表管理技术
CN114089916B (zh) * 2018-01-12 2022-12-20 珠海极海半导体有限公司 数据采集系统和温湿度传感器系统
US20190227957A1 (en) * 2018-01-24 2019-07-25 Vmware, Inc. Method for using deallocated memory for caching in an i/o filtering framework
US10261693B1 (en) * 2018-01-31 2019-04-16 EMC IP Holding Company LLC Storage system with decoupling and reordering of logical and physical capacity removal
CN111143072B (zh) * 2019-12-29 2023-09-08 浪潮(北京)电子信息产业有限公司 用户态程序内存分配方法、系统及相关组件
CN112148229B (zh) * 2020-10-12 2024-01-30 北京计算机技术及应用研究所 一种飞腾服务器平台下的加速非易失性内存读写效率的方法
CN114996024A (zh) * 2022-07-29 2022-09-02 阿里巴巴(中国)有限公司 内存带宽监测方法、服务器和计算机可读存储介质
CN117708000A (zh) * 2024-02-05 2024-03-15 成都佰维存储科技有限公司 数据的随机写入方法、装置、电子设备及存储介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101876918A (zh) * 2009-11-27 2010-11-03 北京航空航天大学 虚拟机客户操作系统同步任务感知方法
CN102207896A (zh) * 2010-03-31 2011-10-05 微软公司 虚拟机崩溃文件生成技术
US20130097354A1 (en) * 2011-10-13 2013-04-18 International Business Machines Corporation Protecting memory of a virtual guest
CN103218312A (zh) * 2013-03-28 2013-07-24 中国科学院上海微系统与信息技术研究所 文件访问方法及系统

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US4742447A (en) * 1986-01-16 1988-05-03 International Business Machines Corporation Method to control I/O accesses in a multi-tasking virtual memory virtual machine type data processing system
US7506095B2 (en) * 2006-04-04 2009-03-17 International Business Machines Corporation System and method for providing execute-in-place functionality
US7797508B2 (en) * 2007-07-31 2010-09-14 International Business Machines Corporation Fair memory resource control for mapped memory
US20090113111A1 (en) * 2007-10-30 2009-04-30 Vmware, Inc. Secure identification of execution contexts
US8630987B2 (en) * 2008-07-16 2014-01-14 Cleversafe, Inc. System and method for accessing a data object stored in a distributed storage network
US8819011B2 (en) * 2008-07-16 2014-08-26 Cleversafe, Inc. Command line interpreter for accessing a data object stored in a distributed storage network
KR101038167B1 (ko) * 2008-09-09 2011-05-31 가부시끼가이샤 도시바 프로세서로부터 메모리로의 액세스를 관리하는 메모리 관리 장치를 포함하는 정보 처리 장치 및 메모리 관리 방법
JP2012173870A (ja) * 2011-02-18 2012-09-10 Toshiba Corp 半導体装置及びメモリ保護方法
CN102184145B (zh) 2011-05-13 2013-04-17 杭州华三通信技术有限公司 重启数据不丢失方法及装置
JP2013109404A (ja) * 2011-11-17 2013-06-06 Toshiba Corp 情報処理装置
US9612973B2 (en) * 2013-11-09 2017-04-04 Microsoft Technology Licensing, Llc Using shared virtual memory resources for performing memory-mapping

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101876918A (zh) * 2009-11-27 2010-11-03 北京航空航天大学 虚拟机客户操作系统同步任务感知方法
CN102207896A (zh) * 2010-03-31 2011-10-05 微软公司 虚拟机崩溃文件生成技术
US20130097354A1 (en) * 2011-10-13 2013-04-18 International Business Machines Corporation Protecting memory of a virtual guest
CN103218312A (zh) * 2013-03-28 2013-07-24 中国科学院上海微系统与信息技术研究所 文件访问方法及系统

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2020057394A1 (zh) * 2018-09-19 2020-03-26 华为技术有限公司 监控样本进程的内存访问行为的方法和装置
CN110928737A (zh) * 2018-09-19 2020-03-27 华为技术有限公司 监控样本进程的内存访问行为的方法和装置
CN110928737B (zh) * 2018-09-19 2021-05-18 华为技术有限公司 监控样本进程的内存访问行为的方法和装置
US11467977B2 (en) 2018-09-19 2022-10-11 Huawei Technologies Co., Ltd. Method and apparatus for monitoring memory access behavior of sample process
CN110018998A (zh) * 2019-04-12 2019-07-16 深信服科技股份有限公司 一种文件管理方法、系统及电子设备和存储介质
CN110018998B (zh) * 2019-04-12 2023-05-12 深信服科技股份有限公司 一种文件管理方法、系统及电子设备和存储介质

Also Published As

Publication number Publication date
EP3115903A1 (en) 2017-01-11
EP3115903B1 (en) 2020-04-15
JP2017507448A (ja) 2017-03-16
CN105378687B (zh) 2018-12-25
CN105378687A (zh) 2016-03-02
KR102061079B1 (ko) 2019-12-31
EP3115903A4 (en) 2017-03-08
KR20160123370A (ko) 2016-10-25
US10452562B2 (en) 2019-10-22
JP6385468B2 (ja) 2018-09-05
US20160378680A1 (en) 2016-12-29

Similar Documents

Publication Publication Date Title
WO2015131403A1 (zh) 访问文件的方法和相关设备
US10067684B2 (en) File access method and apparatus, and storage device
US11640353B2 (en) Memory system, data storage device, user device and data management method thereof
US11042487B2 (en) Memory system and method for controlling nonvolatile memory
US10157143B2 (en) File access method and apparatus, and storage system
US10061711B2 (en) File access method and apparatus, and storage system
WO2016082191A1 (zh) 访问文件的方法和装置
US20150324281A1 (en) System and method of implementing an object storage device on a computer main memory system
CN108595349B (zh) 大容量存储设备的地址转换方法与装置
WO2019127135A1 (zh) 文件页表管理技术
US20090100213A1 (en) Systems and Methods for Managing Memory Core Surface
US10120812B2 (en) Manipulation of virtual memory page table entries to form virtually-contiguous memory corresponding to non-contiguous real memory allocations
CN107179929B (zh) 一种write_same函数的优化实现方法及装置
CN107155306B (zh) 文件页面管理单元、处理设备和文件页面管理方法
WO2020024151A1 (zh) 信息处理方法及装置、设备、系统
Oikawa Adapting byte addressable memory storage to user-level file system services
KR20210043001A (ko) 하이브리드 메모리 시스템 인터페이스
KR101825013B1 (ko) 비휘발성 메모리에 영구 보존 데이터를 저장할 수 있는 시스템에서의 데이터 관리 방법
CN117130955A (zh) 用于管理相关联的存储器的方法和系统
Zhang et al. Research on persistent memory file system optimization
KR20140085643A (ko) 데이터 저장 장치 및 그것의 동작 방법

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 14884527

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2016572867

Country of ref document: JP

Kind code of ref document: A

NENP Non-entry into the national phase

Ref country code: DE

ENP Entry into the national phase

Ref document number: 20167025615

Country of ref document: KR

Kind code of ref document: A

REEP Request for entry into the european phase

Ref document number: 2014884527

Country of ref document: EP

WWE Wipo information: entry into national phase

Ref document number: 2014884527

Country of ref document: EP