CN107180092B - File system control method and device and terminal - Google Patents

File system control method and device and terminal Download PDF

Info

Publication number
CN107180092B
CN107180092B CN201710337922.5A CN201710337922A CN107180092B CN 107180092 B CN107180092 B CN 107180092B CN 201710337922 A CN201710337922 A CN 201710337922A CN 107180092 B CN107180092 B CN 107180092B
Authority
CN
China
Prior art keywords
page
snapshot
node
inode
data
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
CN201710337922.5A
Other languages
Chinese (zh)
Other versions
CN107180092A (en
Inventor
陈小刚
李顺芬
韩文炳
李鸽子
李大刚
陈诗雁
宋志棠
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Institute of Microsystem and Information Technology of CAS
Original Assignee
Shanghai Institute of Microsystem and Information Technology of CAS
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 Shanghai Institute of Microsystem and Information Technology of CAS filed Critical Shanghai Institute of Microsystem and Information Technology of CAS
Priority to CN201710337922.5A priority Critical patent/CN107180092B/en
Publication of CN107180092A publication Critical patent/CN107180092A/en
Application granted granted Critical
Publication of CN107180092B publication Critical patent/CN107180092B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • 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
    • G06F16/128Details of file system snapshots on the file-level, e.g. snapshot creation, administration, deletion
    • 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/13File access structures, e.g. distributed indices

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a control method, a device and a terminal of a file system.A iNode area is set, and the iNode node comprises an N-ary tree level field, an N-ary tree root node field and a snapshot version pointer field; establishing an N-ary tree structure data area on the basis of the root node page; setting a linked list management area consisting of page index records; each page index record corresponds to a physical page of the data area in sequence; and forming page index linked lists, wherein each page index linked list corresponds to a set of the current version of one data page in the file and all historical versions generated by the snapshot. The invention establishes the file system based on the data chain table and the N-ary tree structure, realizes the random storage of data in the physical storage space, does not need to be stored in the physical address space according to the logical sequence of the file, manages the snapshot version of the logical data page in the file based on the chain table, can realize the data snapshot and rollback of the file system, and improves the operation efficiency of the file system.

Description

File system control method and device and terminal
Technical Field
The present invention relates to the field of file system technologies, and in particular, to a method, an apparatus, and a terminal for controlling a file system.
Background
With the development of new storage technologies such as NVDIMM and 3D Xpoint and the proposed Storage Class Memory (SCM) architecture by IBM, the non-volatile storage NVM based on hybrid Memory system architecture and management becomes a research hotspot. The novel storage technology SCM has the characteristics of nonvolatility, fast reading and writing, low power consumption and the like, but has a gap compared with a DRAM (dynamic random access memory), and the reliability of a system is reduced due to the limited writing and erasing cycle life. In the prior art, various memory organization modes and optimization methods are proposed based on a novel storage technology SCM.
With the development of technologies such as big data, cloud computing, internet of things and the like, data is growing and accumulating at an unprecedented speed. How to manage and organize this data is a challenge for conventional file systems. Although current file systems provide an easy-to-use data organization for applications, the data organization is designed based on the hardware features of the block device and cannot fully exploit the random access performance features of the SCM. Therefore, how to effectively organize data, so that an application program can be used and accessed in a manner closer to a memory, and advantages of reliable file system, easy maintenance and sharing and the like can be maintained, thereby maximally improving the overall operation efficiency of the system becomes a problem to be solved urgently.
Disclosure of Invention
In view of the above drawbacks of the prior art, an object of the present invention is to provide a method, an apparatus, and a terminal for controlling a file system, where an N-ary tree structure is used to manage data stored in a physical address space of the file system, so as to implement random storage of the file data in the physical storage space without sequentially storing the file data in the physical address space according to a logical order of the file, and manage snapshot versions of logical data pages in the file based on a linked list, so as to implement data snapshot and rollback of the file system, thereby maximally improving the overall operating efficiency of the file system.
To achieve the above and other related objects, according to a first aspect of the present invention, an embodiment of the present invention provides a control method for a file system, including the steps of:
setting an iNode area for storing iNode nodes, wherein the iNode nodes comprise an N-ary tree level field, an N-ary tree root node field and a snapshot version pointer field; the N-ary tree stage field is used for storing the stage of an N-ary tree structure adopted by a file, the N-ary tree root node field is used for storing the physical address of a file root node page, and the snapshot version pointer field is used for pointing to a snapshot iNode node corresponding to the latest snapshot of the iNode node;
establishing a data area of an N-ary tree structure based on the root node page; the N-ary tree comprises any multiple levels, and the nodes of the upper level store the physical addresses of the nodes of the lower level correspondingly; all nodes of the last layer are data pages, all other nodes except the nodes of the last layer are node pages, and the data pages and the node pages are arranged in a mixed manner in the data area;
setting a linked list management area consisting of page index records; each page index record corresponds to one physical page of the data area in sequence, and the page index record number is the same as the physical page number of the data area; and the page index record corresponding to each data page stores the creation time of the data page and the position information of the data page of the previous version, so that a page index linked list is formed, and each page index linked list corresponds to a set of the current version of one data page in the file and all historical versions generated by the snapshot and is used for realizing the snapshot rollback of the file.
Optionally, the iNode node further includes an iNode node information field for storing node information thereof, and the control method further includes a step of updating the iNode node information:
acquiring the creation time and system snapshot time of a target iNode node to be updated, wherein the system snapshot time is the latest snapshot time of the file system;
if the creation time of the target iNode node is later than the system snapshot time, updating an iNode node information field in the target iNode node; alternatively, the first and second electrodes may be,
if the creation time of the target iNode node is earlier than the system snapshot time, allocating an idle iNode node as a snapshot iNode node in the iNode area; initializing the snapshot iNode node according to the target iNode node; and storing the snapshot iNode node number in the target iNode node to point to the snapshot iNode node and updating the iNode node information field of the target iNode node.
Optionally, the control method further includes the step of updating the data page:
acquiring creation time and system snapshot time of a target data page to be updated, wherein the system snapshot time is the latest snapshot time of a file system;
if the creation time of the target data page is later than the system snapshot time, writing the updated data into the target data page; alternatively, the first and second electrodes may be,
if the creation time of the target data page is earlier than the system snapshot time, writing the updated data into an idle page of a data area to form a new data page; setting a page index record of the new data page in a linked list management area, and writing the position information and the current time of a target data page into the page index record of the new data page so that the page index record of the new data page is inserted into the head of a data page linked list; and updating the physical address of the new data page to the node page corresponding to the target data page, so that the node page points to the new data page.
Optionally, the file system includes a root folder and a snapshot folder below the root folder, where file contents of the root folder except for the snapshot folder are mapped to a portion below the snapshot folder, and the control method further includes:
when accessing the file through the path of the root folder, reading or writing the file of the current version; alternatively, the first and second electrodes may be,
when a file is accessed through a snapshot folder path, marking the iNode nodes of the file; if the operation on the file is writing, returning a rejection message according to the marked iNode node to reject to write the file; and if the operation on the file is reading, reading the file of the latest version before the designated snapshot time according to the marked iNode node and the designated snapshot time.
Optionally, when the target data page of the specified time is accessed, the control method further includes:
searching a page index linked list corresponding to the target data page from a linked list management area;
selecting a page index record which is earlier than and closest to the specified time from the searched page index linked list;
and extracting the position information in the page index record, and updating the physical address in the node page corresponding to the target data page according to the position information so as to enable the node page to point to the snapshot version data page corresponding to the specified time.
Optionally, when rolling back the file to the file version at the snapshot time, the control method further includes:
closing all opened files;
acquiring the creation time and the deletion time of all iNode nodes in the iNode area; when the creation time of the iNode node is later than the snapshot time, deleting and recovering the corresponding iNode node; when the deleting time of the iNode nodes is later than the snapshot time, restoring the corresponding iNode nodes and the link relation between the iNode nodes;
acquiring the creation time of data pages stored in all page index records in a linked list management area; when the creation time of the data page is later than the snapshot time, recovering the corresponding data page and deleting the page index record in the page index linked list corresponding to the data page; and updating the address in the page index record which is earlier than the snapshot time and closest to the snapshot time to the node page of the data page, and restoring the file to the file version of the snapshot time.
According to a second aspect of the present invention, an embodiment of the present invention provides a control apparatus for a file system, the control apparatus including:
the iNode area setting module is used for setting an iNode area for storing iNode nodes, wherein the iNode nodes comprise N-ary tree level fields, N-ary tree root node fields and snapshot version pointer fields; the N-ary tree stage field is used for storing the stage of an N-ary tree structure adopted by a file, the N-ary tree root node field is used for storing the physical address of a file root node page, and the snapshot version pointer field is used for pointing to a snapshot iNode node corresponding to the latest snapshot of the iNode node;
the data area setting module is used for establishing a data area of an N-ary tree structure on the basis of the root node page; the N-ary tree comprises any multiple levels, and the nodes of the upper level store the physical addresses of the nodes of the lower level correspondingly; all nodes of the last layer are data pages, all other nodes except the nodes of the last layer are node pages, and the data pages and the node pages are arranged in a mixed manner in the data area;
the linked list management area setting module is used for setting a linked list management area consisting of page index records; each page index record corresponds to one physical page of the data area in sequence, and the page index record number is the same as the physical page number of the data area; and the page index record corresponding to each data page stores the creation time of the data page and the position information of the data page of the previous version, so that a page index linked list is formed, and each page index linked list corresponds to a set of the current version of one data page in the file and all historical versions generated by the snapshot and is used for realizing the snapshot rollback of the file.
Optionally, the control apparatus further comprises an iNode node information updating module, the iNode node further comprises an iNode node information field storing node information thereof, the iNode node updating module is configured to,
acquiring the creation time and system snapshot time of a target iNode node to be updated, wherein the system snapshot time is the latest snapshot time of the file system;
if the creation time of the target iNode node is later than the system snapshot time, updating an iNode node information field in the target iNode node; alternatively, the first and second electrodes may be,
if the creation time of the target iNode node is earlier than the system snapshot time, distributing idle iNode nodes in the iNode area as snapshot iNode nodes, and updating the snapshot version pointer field; initializing the snapshot iNode node according to the target iNode node; and storing the snapshot iNode node number in the target iNode node to point to the snapshot iNode node and updating the iNode node information field of the target iNode node.
Optionally, the control device further comprises a data page update module for,
acquiring creation time and system snapshot time of a target data page to be updated, wherein the system snapshot time is the latest snapshot time of a file system;
if the creation time of the target data page is later than the system snapshot time, writing the updated data into the target data page; alternatively, the first and second electrodes may be,
if the creation time of the target data page is earlier than the system snapshot time, writing the updated data into an idle page of a data area to form a new data page; setting a page index record of the new data page in a linked list management area, and writing the position information and the current time of a target data page into the page index record of the new data page so that the page index record of the new data page is inserted into the head of a data page linked list; and updating the physical address of the new data page to the node page corresponding to the target data page, so that the node page points to the new data page.
Optionally, the control device further comprises an operation control module, wherein the file system comprises a root folder and a snapshot folder below the root folder, the contents of the files except for the snapshot folder in the root folder are mapped to the snapshot folder, the operation control module is configured to,
when accessing the file through the path of the root folder, reading or writing the file of the current version; alternatively, the first and second electrodes may be,
when a file is accessed through a snapshot folder path, marking the iNode nodes of the file; if the operation on the file is writing, returning a rejection message according to the marked iNode node to reject to write the file; and if the operation on the file is reading, reading the file of the latest version before the designated snapshot time according to the marked iNode node and the designated snapshot time.
Optionally, the control device further comprises an access control module for,
searching a page index linked list corresponding to the target data page from a linked list management area;
selecting a page index record which is earlier than and closest to the specified time from the searched page index linked list;
and extracting the position information in the page index record, and updating the physical address in the node page corresponding to the target data page according to the position information so as to enable the node page to point to the snapshot version data page corresponding to the specified time.
Optionally, the control device further comprises a rollback module for,
closing all opened files;
acquiring the creation time and the deletion time of all iNode nodes in the iNode area; when the creation time of the iNode node is later than the snapshot time, deleting and recovering the corresponding iNode node; when the deleting time of the iNode nodes is later than the snapshot time, restoring the corresponding iNode nodes and the link relation between the iNode nodes;
acquiring the creation time of data pages stored in all page index records in a linked list management area; when the creation time of the data page is later than the snapshot time, recovering the corresponding data page and deleting the page index record in the page index linked list corresponding to the data page; and updating the address in the page index record which is earlier than the snapshot time and closest to the snapshot time to the node page of the data page, and restoring the file to the file version of the snapshot time.
According to a third aspect of the present invention, there is also provided a terminal, including at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the one processor to cause the at least one processor to:
setting an iNode area for storing iNode nodes, wherein the iNode nodes comprise an N-ary tree level field, an N-ary tree root node field and a snapshot version pointer field; the N-ary tree stage field is used for storing the stage of an N-ary tree structure adopted by a file, the N-ary tree root node field is used for storing the physical address of a file root node page, and the snapshot version pointer field is used for pointing to a snapshot iNode node corresponding to the latest snapshot of the iNode node;
establishing a data area of an N-ary tree structure based on the root node page; the N-ary tree comprises any multiple hierarchies, and the nodes of the previous hierarchy store the corresponding physical addresses of the nodes of the next hierarchy; all nodes of the last layer are data pages, all other nodes except the nodes of the last layer are node pages, and the data pages and the node pages are arranged in a mixed manner in the data area;
setting a linked list management area consisting of page index records; each page index record corresponds to one physical page of the data area in sequence, and the page index record number is the same as the physical page number of the data area; and the page index record corresponding to each data page stores the creation time of the data page and the position information of the data page of the previous version, so that page index linked lists are formed, and each page index linked list corresponds to a set of the current version of one data page in the file and all historical versions generated by the snapshot.
As described above, the method, the device and the terminal for controlling the file system of the present invention have the following advantages: setting an iNode area for storing iNode nodes, wherein the iNode nodes comprise an N-ary tree level field, an N-ary tree root node field and a snapshot version pointer field; the N-ary tree stage field is used for storing the stage of an N-ary tree structure adopted by a file, the N-ary tree root node field is used for storing the physical address of a file root node page, and the snapshot version pointer field is used for pointing to a snapshot iNode node corresponding to the latest snapshot of the iNode node; establishing a data area of an N-ary tree structure based on the root node page; the N-ary tree comprises any multiple levels, and the nodes of the upper level store the physical addresses of the nodes of the lower level correspondingly; all nodes of the last layer are data pages, all other nodes except the nodes of the last layer are node pages, and the data pages and the node pages are arranged in a mixed manner in the data area; setting a linked list management area consisting of page index records; each page index record corresponds to one physical page of the data area in sequence, and the page index record number is the same as the physical page number of the data area; and the page index record corresponding to each data page stores the creation time of the data page and the position information of the data page of the previous version, so that page index linked lists are formed, and each page index linked list corresponds to a set of the current version of one data page in the file and all historical versions generated by the snapshot. The invention establishes a random access file system for realizing rapid rollback based on a data chain table and an N-ary tree structure, adopts the N-ary tree structure to manage the data stored in a physical address space of the file system, realizes the random storage of the file data in the physical storage space, does not need to store in the physical address space according to the logical sequence of the file, and manages the snapshot version of the logical data page in the file based on the chain table, and can efficiently realize the data snapshot and rollback of the file system, thereby improving the operating efficiency of the file system.
Drawings
Fig. 1 is a schematic structural diagram of a file system according to an embodiment of the present invention.
Fig. 2 is a flowchart illustrating a method for controlling a file system according to an embodiment of the present invention.
Fig. 3 is a schematic structural diagram of an iNode area according to an embodiment of the present invention.
Fig. 4 is a schematic structural diagram of an N-ary tree according to an embodiment of the present invention.
Fig. 5 is a flowchart illustrating an iNode node information updating method according to an embodiment of the present invention.
Fig. 6 is a flowchart illustrating a data page updating method according to an embodiment of the present invention.
Fig. 7 is a schematic diagram illustrating a data area structure according to an embodiment of the present invention.
Fig. 8 is a flowchart illustrating a file access control method according to an embodiment of the present invention.
Fig. 9 is a schematic diagram illustrating a principle of accessing a root file and a snapshot file according to an embodiment of the present invention.
Fig. 10 is a flowchart illustrating a snapshot file access method according to an embodiment of the present invention.
Fig. 11 is a flowchart illustrating a file rollback method according to an embodiment of the present invention.
Fig. 12 is a schematic structural diagram illustrating a control device of a file system according to an embodiment of the present invention.
Detailed Description
The embodiments of the present invention are described below with reference to specific embodiments, and other advantages and effects of the present invention will be easily understood by those skilled in the art from the disclosure of the present specification. The invention is capable of other and different embodiments and of being practiced or of being carried out in various ways, and its several details are capable of modification in various respects, all without departing from the spirit and scope of the present invention.
Please refer to fig. 1 to 12. It should be noted that the drawings provided in the present embodiment are only for illustrating the basic idea of the present invention, and the drawings only show the components related to the present invention rather than being drawn according to the number, shape and size of the components in actual implementation, and the type, quantity and proportion of each component in actual implementation may be changed arbitrarily, and the layout of the components may be more complicated.
The control method of the file system in the embodiment of the invention is a control method of the file system for realizing the random access of the fast rollback based on the data link table and the N-ary tree structure, adopts the N-ary tree structure to manage the data stored in the physical address space of the file system, and realizes the random storage of the file data in the physical storage space without sequentially storing the file data in the physical address space according to the logical sequence of the file. And managing the snapshot version of the logical data page in the file based on the linked list to realize data snapshot and rollback of the file system.
In order to clearly describe the control method of the file system in the embodiment of the present invention, first, the structure of the file system in the embodiment of the present invention is explained. Referring to fig. 1, which is a schematic structural diagram of a file system according to an embodiment of the present invention, as shown in fig. 1, in an exemplary embodiment, the file system includes an iNode area, a linked list area, and a data area, as well as a super block area and a bitmap area, which are arranged on a memory; the super block area is used for storing information such as the size, the empty and the full blocks of the file system, and the bitmap area is used for storing the use state of the blocks. The file system of the embodiment of the invention realizes the random storage of the file data and the data snapshot and rollback of the file system based on the structure; it should be noted that the control method of the file system in the embodiment of the present invention may be applied to a storage system with unified addressing of a dynamic random access memory and a nonvolatile random access memory. Also, the nonvolatile random access memory includes a phase change memory, a resistance change memory, a magnetic memory, a ferroelectric memory, and the like.
Referring to fig. 2, a flowchart of a method for controlling a file system according to an embodiment of the present invention is shown, and as shown in fig. 2, an embodiment of the present invention shows a process of a processor implementing the method for controlling the file system:
step S101: setting an iNode area for storing iNode nodes, wherein the iNode nodes comprise an N-ary tree level field, an N-ary tree root node field and a snapshot version pointer field; the N-ary tree stage field is used for storing the stage of an N-ary tree structure adopted by a file, the N-ary tree root node field is used for storing the physical address of a file root node page, and the snapshot version pointer field is used for pointing to a snapshot iNode node corresponding to the latest snapshot of the iNode node.
Referring to fig. 3, which is a schematic structural diagram of an iNode area according to an embodiment of the present invention, as shown in fig. 3, an iNode node stored in the iNode area includes an iNode node information field, an N-ary tree level field, an N-ary tree root node field, and a snapshot version pointer field; the iNode node information field is used for storing management information of files, such as creators, creation time, storage directories, permissions and the like; the N-ary tree progression field is used for storing the progression of an N-ary tree structure adopted by the file; the N-ary tree root node field is used for storing the initial physical address of the nth level node page of the file; the snapshot version pointer field is used for pointing to a snapshot iNode node corresponding to the latest snapshot of the iNode node.
Step S102: establishing a data area of an N-ary tree structure based on the root node page; the N-ary tree comprises any multiple levels, and the nodes of the upper level store the physical addresses of the nodes of the lower level correspondingly; and all the nodes of the last layer are data pages, all the nodes except the nodes of the last layer are node pages, and the data pages and the node pages are arranged in the data area in a mixed mode.
An N-ary tree, also known as an N-ary tree, is a tree-type data structure used to accomplish fast ordering, data compression, and fast retrieval of data. The data area in the embodiment of the invention comprises a data page and a node page, wherein the data page is used for storing file data, and the node page is used for storing a next-level node page in an N-ary tree or a physical address of the data page; and the data page and the node page are arranged in a data area in a mixed mode. Taking the page number of the N-th level node corresponding to the file as a root node, taking the page number of the (N-1) -th level node as a level 1 child node, and so on, taking the page number of the level 1 node as a level 1 child node, and forming an N-ary tree to store and manage all data of the file; wherein the level 1 node page is a data page; the traversal sequence of the N-ary tree is the logic sequence of the data pages; furthermore, in the embodiment of the present invention, the N-ary tree has one root node, and the number of child nodes of each node may not be completely the same.
Referring to fig. 4, a schematic structural diagram of an N-ary tree according to an embodiment of the present invention is shown in fig. 4, where a node page of the nth level corresponding to a file is a node page of the N-ary treeNThe page number is the root node, and the (N-1) level node page is the NodePageN-1The page number is the level 1 child node, and so on, the level 1 node page is used1The page number is the (N-1) level child node, an N-ary tree is formed to store and manage all data of the file, and the 1 level node page is a data page.
Specifically, the physical storage space where the file data is located is based on the NodePage of the nth level node page of the file corresponding to the fileNPage number, level (N-1) node page NodePageN-1Page number, … …, level 1 node page NodePage1Page number, in Nth level node page NodePageNThe page number is the root node, and the (N-1) level node page is the NodePageN-1The page number is the level 1 child node, and so on, the level 1 node page NodePage1The page number is the (N-1) level child node, and an N-ary tree is formed to perform storage management on file data. In the N-ary tree, each level of nodes manages the child nodes in a page table mode, and the number of the child nodes at each level is fixed to 512. As shown in FIG. 4, the level 1 node page NodePage1The pages are data pages. That is, the management node pages are organized from the root node to the N-2 th level child nodes, and the N-1 th level child nodes are groupedManage the data page. The root node stores the physical address of the node page corresponding to the level 1 child node; the 1 st level child node stores the physical address of the node page corresponding to the 2 nd level child node; and in analogy, the (N-2) level child node stores the physical address of the node page corresponding to the (N-1) level child node. The level 1 node page is a data page, and all data pages occupy the last level node of the N-ary tree. Therefore, the page physical address stored in the node page may be a next-level node page physical address, or may be a data page physical address.
In the present invention, all file data is managed in a page manner, and the page size coincides with the operating system memory page size. The traversal order of the N-ary tree is the logical order of the data pages.
And the sequence number of the data page during the N-ary tree traversal is the logical page number of the data page in the file. Therefore, the logical page number of the data page where the address is located and the path from the data page to the root node can be calculated according to the logical address in the file.
Step S103: setting a linked list management area consisting of page index records; each page index record corresponds to one physical page of the data area in sequence, and the page index record number is the same as the physical page number of the data area; and the page index record corresponding to each data page stores the creation time of the data page and the position information of the data page of the previous version, so that page index linked lists are formed, and each page index linked list corresponds to a set of the current version of one data page in the file and all historical versions generated by the snapshot.
The linked list management area is composed of a plurality of page index records, each page index record corresponds to one physical page of the data area in sequence, the number of the page index records is the same as that of the physical pages of the data area, the creation time of each data page and the position information of the previous version data page are stored in the page index record corresponding to each data page in the data area, so that a data page linked list is formed in the data area, and all data pages in each data page linked list correspond to the current version of a certain logic data page in a file and all historical versions generated by snapshots. The linked list management area implemented by the invention is used for managing the snapshot version of the logical data page in the file and realizing the data snapshot and rollback of the file system.
In an exemplary embodiment, the linked list management area is composed of N page index records, each page index record corresponds to one physical page of the data area, the capacity of the linked list management area is 1/512 of the total capacity of the data area, and the page index records are in 8 bytes as a unit to establish a mapping relationship between the page index records and the physical pages of the data area. The first 4 bytes of the page index record of the linked list management area store the physical address of the page, and the last 4 bytes store the modification time of the physical page. Each logical page of the file system has an association relation with 1 or more page index records, the modification time of the page index records refers to the current modification time of the logical page, and the page physical address of the page index records refers to the physical address of the corresponding data page after the logical page is modified last time. When a logical page in a file system is modified for multiple times, the same logical page has multiple versions of data pages, the multiple versions of data pages are all stored in a data area, and the data page of each version correspondingly occupies one physical page of a memory. And forming a page index linked list according to the time modification sequence of the logical pages by the page index records which have the association relation with the same logical page, wherein all data pages in each data page linked list correspond to the current version of a certain logical data page in the file and all historical versions generated by the snapshot.
As can be seen from the description of the foregoing embodiment, in the control method of a file system provided in the embodiment of the present invention, an iNode area for storing an iNode node is set, where the iNode node includes an N-ary tree level field, an N-ary tree root node field, and a snapshot version pointer field; the N-ary tree stage field is used for storing the stage of an N-ary tree structure adopted by a file, the N-ary tree root node field is used for storing the physical address of a file root node page, and the snapshot version pointer field is used for pointing to a snapshot iNode node corresponding to the latest snapshot of the iNode node; establishing a data area of an N-ary tree structure based on the root node page; the N-ary tree comprises any multiple levels, and the nodes of the upper level store the physical addresses of the nodes of the lower level correspondingly; all nodes of the last layer are data pages, all other nodes except the nodes of the last layer are node pages, and the data pages and the node pages are arranged in a mixed manner in the data area; setting a linked list management area consisting of page index records; each page index record corresponds to one physical page of the data area in sequence, and the page index record number is the same as the physical page number of the data area; and the page index record corresponding to each data page stores the creation time of the data page and the position information of the data page of the previous version, so that page index linked lists are formed, and each page index linked list corresponds to a set of the current version of one data page in the file and all historical versions generated by the snapshot. The invention establishes a random access file system for realizing rapid rollback based on a data chain table and an N-ary tree structure, adopts the N-ary tree structure to manage the data stored in a physical address space of the file system, realizes the random storage of the file data in the physical storage space, does not need to store in the physical address space according to the logical sequence of the file, and manages the snapshot version of the logical data page in the file based on the chain table, and can efficiently realize the data snapshot and rollback of the file system, thereby improving the operating efficiency of the file system.
In order to update the iNode node information in the file system in the embodiment of the present invention, an exemplary embodiment of the present invention also implements updating of the iNode node information. Referring to fig. 5, a flowchart of an iNode node information updating method provided in the embodiment of the present invention is shown, and as shown in fig. 5, the embodiment of the present invention shows a process of updating iNode node information:
step S201: and acquiring the creation time and the system snapshot time of the target iNode node to be updated, wherein the system snapshot time is the latest snapshot time of the file system.
In an embodiment of the present invention, when the system requests to update the file name of a file a, the node information in the target iNode node corresponding to the file a needs to be updated. First, the processor can obtain the creation time T of the target iNode node by reading the iNode node information fieldA(ii) a Meanwhile, when the file system creates a snapshot each time, the time of each snapshot is saved and recorded, and the processor can acquire the latest snapshot time of the file system, namely the system snapshot timeTsnapshot
Step S202: and if the creation time of the target iNode node is later than the system snapshot time, updating an iNode node information field in the target iNode node.
Further, the processor compares the creation time TAAnd system snapshot time Tsnapshot. If TALater than Tsnapshot,Then, the iNode of the file A is describedAThe node creating time is later than the latest snapshot creating time, and the next snapshot time does not arrive, the iNode node information field in the target iNode node can be directly modified for many times, thereby realizing the iNode corresponding to the file AAAnd updating the node information.
Step S203: if the creation time of the target iNode node is earlier than the system snapshot time, allocating an idle iNode node as a snapshot iNode node in the iNode area; initializing the snapshot iNode node according to the target iNode node; and storing the snapshot iNode node number in the target iNode node to point to the snapshot iNode node and updating the iNode node information field of the target iNode node.
If TAEarlier than Tsnapshot,Then, the iNode of the file A is describedAThe node creation time is earlier than the latest snapshot creation time, and the iNode is already saved during the latest snapshot creationAThe state information of the node is updated again to iNodeAWhen the node information is received, an idle iNode needs to be newly allocated in the iNode areaA1Node as node iNodeASnapshot iNode ofA1Based on iNodeANode information initialization snapshot iNodeA1Node information, and in iNodeASaving snapshots iNode on nodesA1Node number, then based on node iNodeAAnd the updating is completed by modifying the iNode node information field. Furthermore, in the implementation, iNode can be updatedASuch that the snapshot version pointer field points to the snapshot iNodeA1
The embodiment of the invention also provides an updating method of the data page of the file system, because the data page bears the Chinese file data information of the file system and is usually updated when the file system is operated. Referring to fig. 6, a flowchart of a data page updating method provided in the embodiment of the present invention is shown, and as shown in fig. 6, the embodiment of the present invention shows a process of updating a data page:
step S301: and acquiring the creation time and the system snapshot time of a target data page to be updated, wherein the system snapshot time is the latest snapshot time of the file system.
In an embodiment of the present invention, a file A is written. Referring to fig. 7, for a schematic diagram of a data area structure provided in an embodiment of the present invention, if a file a implements a write operation on a 1 st logical page, a 500 th logical page, a 600 th logical page, and a 1000 th logical page according to a write operation sequence, an N-ary tree structure of the file and a distribution of file data in the data area are shown in fig. 7. The file has 3 node pages and 4 data pages, wherein the node pages are NodePage3Storing node pages NodePage for root node 21 and NodePage 22 physical address, node Page 21 store data pages DataPage corresponding to the corresponding logical page numbers 21 and data Page DataPage 5001 physical address, node Page 22 store data pages DataPage corresponding to the corresponding logical page numbers 6001 and data Page DataPage 10001, physical address. Correspondingly, 4 index records in the linked list management area respectively correspond to the data pages DataPage 21、DataPage 5001、DataPage 6001. And data page DataPage 10001, the creation time of the corresponding data page is recorded.
The embodiment of the present invention will take the data update of the 500 th logical page as an example, and describe the update process of the data page in detail. When the 500 th logical page is updated for the first time, the NodePage 21 store data page DataPage 5001, then the target data page can be understood as a DataPage 5001, the processor first searches the linked list management area with the DataPage 5001 corresponding index record, therebyGet DataPage 5001 creation time; meanwhile, as described in the above example, the processor can also obtain the system snapshot time T of the file systemsnapshot,
Step S302: and if the creation time of the target data page is later than the system snapshot time, writing the updated data into the target data page.
Data page DataPage corresponding to 500 th logical page 5001 creation time TDataPage5001 and the latest snapshot time T of the file systemsnapshotBy comparison, if TDataPage 5001 later than TsnapshotIf the time of creating the data page DataPage5001 corresponding to the 500 th logical page is later than the time of creating the latest snapshot, and the time of the next snapshot is not yet reached, the update data can be directly written into the data page DataPage 5001 to update the relevant information of the node thereon a plurality of times.
Step S303: if the creation time of the target data page is earlier than the system snapshot time, writing the updated data into an idle page of a data area to form a new data page; setting a page index record of the new data page in a linked list management area, and writing the position information and the current time of a target data page into the page index record of the new data page so that the page index record of the new data page is inserted into the head of a data page linked list; and updating the physical address of the new data page to the node page corresponding to the target data page, so that the node page points to the new data page.
If TDataPage 5001 is earlier than Tsnapshot,Then, explain the data page DataPage 5001 the creation time is earlier than the creation time of the latest snapshot, and the dataPage is saved when the snapshot is created5001, when the process needs to update the 500 th logical page data again, a data page DataPage corresponding to the 500 th logical page is newly allocated based on the page fault interrupt mechanism 5002, creating a dataPage in the linked list area 5002 corresponding index record, and then data page DataPage 5002 physical address to node page NodePage 21, corresponding address field. In-chainTable management area, DataPage with data page 5002 Allocation time filling and physical data Page DataPage 5002 physical page, data page DataPage 5001 physical address update and physical data page DataPage 5002, corresponding to the index record.
And by analogy, after the 500 th logical page is updated for multiple times and is subjected to snapshot at corresponding specified time intervals for multiple times, the physical page DataPage is continuously allocated5003、DataPage5004、……,DataPage500N, the current version of the 500 th logical data page of File A and all the historical versions of the snapshot generation are shown in FIG. 7.
In an exemplary embodiment of the present invention, the file system may include a root folder, and a snapshot folder under the root folder, where file contents of the root folder except for the snapshot folder are mapped under the snapshot folder; specifically, the file system maintains a snapshot folder snapshot under a root folder/root, maps the content of the root file system under the snapshot folder by a mapping method, accesses the current version of the file data through a path of the root folder, and realizes the file snapshot version corresponding to the specified time through the path of the snapshot folder. The embodiment of the invention accesses the file data in a POSIX (English: Portable Operating System Interface of UNIX, Chinese: Portable Operating System Interface) mode, and distinguishes the snapshot file or the common file through an iNode number identification means so as to realize read access to the snapshot file and read-write access to the common file. Referring to fig. 8, a flowchart of a file access control method provided in the embodiment of the present invention is shown, and as shown in fig. 8, the embodiment of the present invention shows a process of controlling file access under a root folder and a snapshot folder:
step S401: when a file is accessed through the root folder path, the current version of the file is read or written.
Referring to fig. 9, a schematic diagram of a principle of accessing a root file and a snapshot file according to an embodiment of the present invention is provided, as shown in fig. 9, in an embodiment of the present invention, a file is providedThe root directory/root of the File system comprises a snapshot folder snapshot and three files File1, File2 and File 3. When a system needs to access data in a file system, the file system is firstly mounted in a memory, and a root node iNode is createdrootPopulating iNodes based on root node information in a file systemrootNode information when the system is going to access an iNodeFile1When the File is the corresponding File, the system reads the File data of the current version of the File1 from the File system into the memory, and then performs corresponding read-write operation.
Step S402: when a file is accessed through a snapshot folder path, marking the iNode nodes of the file; if the operation on the file is writing, returning a rejection message according to the marked iNode node to reject to write the file; and if the operation on the file is reading, reading the file of the latest version before the designated snapshot time according to the marked iNode node and the designated snapshot time.
When a system needs to access a file in a snapshot folder, the content of a root folder needs to be mapped to the snapshot folder, and an iNode is filled based on root node information in the file systemsnapshotNode information, when the system wants to access the iNode under the snapshot folderFile1When the corresponding file is used, firstly, the iNode is markedFile1E.g. setting a predetermined identity or in iNodeFile1Storing the corresponding iNode area; then the system will mark the iNodeFile1And corresponding appointed snapshot time is issued to the file system. The file system is based on the marked iNodeFile1Find iNodeFile1And copying the snapshot version corresponding to the specified time of the access request to a memory for system read access.
For convenience of a user to access a snapshot file of a historical version and to provide flexibility of a file system, referring to fig. 10, a flowchart of a snapshot file access method provided in an embodiment of the present invention is shown, where a file system can access a specified time T when the file system is accessed in a POSIX manner in response to a read operation, and the file system is accessed in a POSIX manner0As shown in fig. 10, an embodiment of the present invention illustrates accessing a snapshot version of a textThe process of the piece is as follows:
step S501: and searching a page index linked list corresponding to the target data page from the linked list management area.
In an exemplary embodiment, T is requested to access by a process0For example, since the logical page LPage may be subjected to multiple snapshots or updates, in the linked list management area, the page index linked list corresponding to the logical page LPage records all versions of the snapshots and the updates of the logical page LPage, and the target data page may be understood as a data page of a latest version corresponding to the current logical page LPage. The processor traverses all the page index linked lists in the linked list management area, so as to find out the page index linked lists corresponding to the logical pages LPage and the target data pages.
Step S502: and selecting a page index record which is earlier than and closest to the specified time from the searched page index linked list.
Step S503: and extracting the position information in the page index record, and updating the physical address in the node page corresponding to the target data page according to the position information so as to enable the node page to point to the snapshot version data page corresponding to the specified time.
By updating the physical address in the node page corresponding to the target data page, the node page can point to the designated time T0And the corresponding snapshot data page, thereby realizing the access to the file snapshot version.
For the convenience of recovering the file system, referring to fig. 11, a flowchart of a file rollback method provided in the embodiment of the present invention is shown, as shown in fig. 11, the embodiment of the present invention shows a process of rolling a file back to a file version at a snapshot time:
step S601: all open files are closed.
When a file rollback indication is received, the processor controls all open files to be closed.
Step S602: acquiring the creation time and the deletion time of all iNode nodes in the iNode area; when the creation time of the iNode node is later than the snapshot time, deleting and recovering the corresponding iNode node; and when the deletion time of the iNode nodes is later than the snapshot time, restoring the corresponding iNode nodes and the link relation between the iNode nodes.
The creation time and the deletion time of all the iNode nodes in the iNode area are obtained by traversing the iNode area of the file system, wherein the creation time can be understood as the time for creating the iNode node, for example, the time for creating a file to create an iNode node, and the deletion time can be understood as the time for deleting the iNode node, for example, the time for deleting a file to delete an iNode node.
And when the creation time of the iNode node is later than the snapshot time, the iNode node does not exist before the snapshot time, and the corresponding iNode node is deleted and recovered. When the deletion time of the iNode node is later than the snapshot time, the iNode node exists before the snapshot time, and the corresponding iNode node is recovered only if the iNode node is deleted after the snapshot time; meanwhile, the iNode nodes may include a plurality of snapshot iNode nodes, and the corresponding linked list relationship is established between the snapshot iNode nodes through a snapshot version pointer field, so in the embodiment of the invention, the link relationship of the iNode nodes can be recovered, and the deleted iNode nodes can be recovered into the linked list by modifying the pointing direction of the snapshot version pointer field; the other iNode nodes remain unchanged.
Step S603: acquiring the creation time of data pages stored in all page index records in a linked list management area; when the creation time of the data page is later than the snapshot time, recovering the corresponding data page and deleting the page index record in the page index linked list corresponding to the data page; and updating the address in the page index record which is earlier than the snapshot time and closest to the snapshot time to the node page of the data page, and restoring the file to the file version of the snapshot time.
Similarly, rolling back the data pages in the data area, and traversing the creation time of the data pages stored in all page index records of the linked list management area; when the creation time of the data page is later than the snapshot time, recovering by changing the corresponding bit of the bitmap area, and deleting the page index record in the page index linked list corresponding to the data page so as to correspondingly modify the link relation; further, updating the address in the page index record which is earlier than the snapshot time and closest to the snapshot time to the node page of the data page, and recovering the file to the file version of the snapshot time; and, the other data pages remain unchanged.
Corresponding to the embodiment of the control method of the file system, the embodiment of the invention also provides a control device of the file system.
Referring to fig. 12, a schematic structural diagram of a control device of a file system according to an embodiment of the present invention is shown in fig. 12, where the control device of the file system includes:
an iNode area setting module 11, configured to set an iNode area used for storing iNode nodes, where an iNode node includes an N-ary tree level field, an N-ary tree root node field, and a snapshot version pointer field; the N-ary tree stage field is used for storing the stage of an N-ary tree structure adopted by a file, the N-ary tree root node field is used for storing the physical address of a file root node page, and the snapshot version pointer field is used for pointing to a snapshot iNode node corresponding to the latest snapshot of the iNode node;
a data area setting module 12, configured to establish a data area of an N-ary tree structure based on the root node page; the N-ary tree comprises any multiple levels, and the nodes of the upper level store the physical addresses of the nodes of the lower level correspondingly; and all the nodes of the last layer are data pages, all the nodes except the nodes of the last layer are node pages, and the data pages and the node pages are arranged in the data area in a mixed mode.
A linked list management area setting module 13, configured to set a linked list management area formed by page index records; each page index record corresponds to one physical page of the data area in sequence, and the page index record number is the same as the physical page number of the data area; and the page index record corresponding to each data page stores the creation time of the data page and the position information of the data page of the previous version, so that page index linked lists are formed, and each page index linked list corresponds to a set of the current version of one data page in the file and all historical versions generated by the snapshot.
In the first implementation case, the control apparatus may further include an iNode node information updating module 14, the iNode node further including an iNode node information field storing node information thereof, the iNode node updating module configured to,
acquiring the creation time and system snapshot time of a target iNode node to be updated, wherein the system snapshot time is the latest snapshot time of the file system;
if the creation time of the target iNode node is later than the system snapshot time, updating an iNode node information field in the target iNode node; alternatively, the first and second electrodes may be,
if the creation time of the target iNode node is earlier than the system snapshot time, distributing idle iNode nodes in the iNode area as snapshot iNode nodes, and updating the snapshot version pointer field; initializing the snapshot iNode node according to the target iNode node; and storing the snapshot iNode node number in the target iNode node to point to the snapshot iNode node and updating the iNode node information field of the target iNode node.
In the second implementation case, the control device may further comprise a data page update module 15 for,
acquiring creation time and system snapshot time of a target data page to be updated, wherein the system snapshot time is the latest snapshot time of a file system;
if the creation time of the target data page is later than the system snapshot time, writing the updated data into the target data page; alternatively, the first and second electrodes may be,
if the creation time of the target data page is earlier than the system snapshot time, writing the updated data into an idle page of a data area to form a new data page; setting a page index record of the new data page in a linked list management area, and writing the position information and the current time of a target data page into the page index record of the new data page so that the page index record of the new data page is inserted into the head of a data page linked list; and updating the physical address of the new data page to the node page corresponding to the target data page, so that the node page points to the new data page.
In a third implementation case, the control device further includes an operation control module 16, where the file system includes a root folder, and a snapshot folder below the root folder, and file contents of the root folder except for the snapshot folder are mapped to a position below the snapshot folder, and the operation control module is configured to,
when accessing the file through the path of the root folder, reading or writing the file of the current version; alternatively, the first and second electrodes may be,
when a file is accessed through a snapshot folder path, marking the iNode nodes of the file; if the operation on the file is writing, returning a rejection message according to the marked iNode node to reject to write the file; and if the operation on the file is reading, reading the file of the latest version before the designated snapshot time according to the marked iNode node and the designated snapshot time.
In a fourth implementation case, the control device further comprises an access control module 17 for,
searching a page index linked list corresponding to the target data page from a linked list management area;
selecting a page index record which is earlier than and closest to the specified time from the searched page index linked list;
and extracting the position information in the page index record, and updating the physical address in the node page corresponding to the target data page according to the position information so as to enable the node page to point to the snapshot version data page corresponding to the specified time.
In a fifth implementation case, the control device may further include a rollback module 18 configured to,
closing all opened files;
acquiring the creation time and the deletion time of all iNode nodes in the iNode area; when the creation time of the iNode node is later than the snapshot time, deleting and recovering the corresponding iNode node; when the deleting time of the iNode nodes is later than the snapshot time, restoring the corresponding iNode nodes and the link relation between the iNode nodes;
acquiring the creation time of data pages stored in all page index records in a linked list management area; when the creation time of the data page is later than the snapshot time, recovering the corresponding data page and deleting the page index record in the page index linked list corresponding to the data page; and updating the address in the page index record which is earlier than the snapshot time and closest to the snapshot time to the node page of the data page, and restoring the file to the file version of the snapshot time.
The embodiment of the invention also provides a terminal, and particularly, the terminal can be understood as a personal computer, a portable terminal such as a PAD, a server and the like. In an embodiment of the present invention, the terminal includes at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the one processor to cause the at least one processor to:
setting an iNode area for storing iNode nodes, wherein the iNode nodes comprise an N-ary tree level field, an N-ary tree root node field and a snapshot version pointer field; the N-ary tree stage field is used for storing the stage of an N-ary tree structure adopted by a file, the N-ary tree root node field is used for storing the physical address of a file root node page, and the snapshot version pointer field is used for pointing to a snapshot iNode node corresponding to the latest snapshot of the iNode node;
establishing a data area of an N-ary tree structure based on the root node page; the N-ary tree comprises any multiple hierarchies, and the nodes of the previous hierarchy store the corresponding physical addresses of the nodes of the next hierarchy; all nodes of the last layer are data pages, all other nodes except the nodes of the last layer are node pages, and the data pages and the node pages are arranged in a mixed manner in the data area;
setting a linked list management area consisting of page index records; each page index record corresponds to one physical page of the data area in sequence, and the page index record number is the same as the physical page number of the data area; and the page index record corresponding to each data page stores the creation time of the data page and the position information of the data page of the previous version, so that page index linked lists are formed, and each page index linked list corresponds to a set of the current version of one data page in the file and all historical versions generated by the snapshot.
Furthermore, the processor in the terminal may be further configured to perform the method steps described in the above-mentioned control method embodiment of the file system.
In summary, the method, the device and the terminal for controlling the file system provided by the present invention adopt the N-ary tree structure to manage the data stored in the physical address space of the file system, implement the random storage of the file data in the physical storage space, manage the snapshot version of the logical data page in the file based on the linked list, and implement the data snapshot and rollback of the file system.
The foregoing embodiments are merely illustrative of the principles and utilities of the present invention and are not intended to limit the invention. Any person skilled in the art can modify or change the above-mentioned embodiments without departing from the spirit and scope of the present invention. Accordingly, it is intended that all equivalent modifications or changes which can be made by those skilled in the art without departing from the spirit and technical spirit of the present invention be covered by the claims of the present invention.

Claims (11)

1. A method for controlling a file system, the method comprising the steps of:
setting an iNode area for storing iNode nodes, wherein the iNode nodes comprise an N-ary tree level field, an N-ary tree root node field and a snapshot version pointer field; the N-ary tree stage field is used for storing the stage of an N-ary tree structure adopted by a file, the N-ary tree root node field is used for storing the physical address of a file root node page, and the snapshot version pointer field is used for pointing to a snapshot iNode node corresponding to the latest snapshot of the iNode node;
establishing a data area of an N-ary tree structure based on the root node page; the N-ary tree structure comprises any multiple levels, and the nodes of the upper level store the corresponding physical addresses of the nodes of the lower level; all nodes of the last level are data pages, all other nodes except the nodes of the last level are node pages, and the data pages and the node pages are arranged in a mixed manner in the data area;
setting a linked list management area consisting of page index records; each page index record corresponds to one physical page of the data area in sequence, and the page index record number is the same as the physical page number of the data area; the page index record corresponding to each data page stores the creation time of the data page and the position information of the data page of the previous version, so that a page index linked list is formed, each page index linked list corresponds to a set of the current version of one data page in a file and all historical versions generated by a snapshot and is used for realizing the snapshot rollback of the file;
the control method further includes the step of updating the data page:
acquiring creation time and system snapshot time of a target data page to be updated, wherein the system snapshot time is the latest snapshot time of a file system;
if the creation time of the target data page is later than the system snapshot time, writing the updated data into the target data page; alternatively, the first and second electrodes may be,
if the creation time of the target data page is earlier than the system snapshot time, writing the updated data into an idle page of a data area to form a new data page; setting a page index record of the new data page in a linked list management area, and writing the position information and the current time of a target data page into the page index record of the new data page so that the page index record of the new data page is inserted into the head of a data page linked list; and updating the physical address of the new data page to the node page corresponding to the target data page, so that the node page points to the new data page.
2. The method of claim 1, wherein the iNode node further includes an iNode node information field storing node information thereof, the method further comprising the step of updating the iNode node information:
acquiring the creation time and system snapshot time of a target iNode node to be updated, wherein the system snapshot time is the latest snapshot time of the file system;
if the creation time of the target iNode node is later than the system snapshot time, updating an iNode node information field in the target iNode node; alternatively, the first and second electrodes may be,
if the creation time of the target iNode node is earlier than the system snapshot time, allocating an idle iNode node as a snapshot iNode node in the iNode area; initializing the snapshot iNode node according to the target iNode node; and storing a snapshot iNode node number in the target iNode node to point to the snapshot iNode node and updating the iNode node information field of the target iNode node.
3. The method according to claim 1, wherein the file system includes a root folder, and a snapshot folder below the root folder, and contents of files other than the snapshot folder in the root folder are mapped below the snapshot folder, and the method further comprises:
when accessing the file through the path of the root folder, reading or writing the file of the current version; alternatively, the first and second electrodes may be,
when a file is accessed through a snapshot folder path, marking the iNode nodes of the file; if the operation on the file is writing, returning a rejection message according to the marked iNode node to reject to write the file; and if the operation on the file is reading, reading the file of the latest version before the designated snapshot time according to the marked iNode node and the designated snapshot time.
4. The file system control method according to claim 1, wherein when a target data page of a specified time is accessed, the control method further comprises:
searching a page index linked list corresponding to the target data page from a linked list management area;
selecting a page index record which is earlier than and closest to the specified time from the searched page index linked list;
and extracting the position information in the page index record, and updating the physical address in the node page corresponding to the target data page according to the position information so as to enable the node page to point to the snapshot version data page corresponding to the specified time.
5. The file system control method according to claim 1, wherein when rolling back a file to a file version at snapshot time, the control method further comprises:
closing all opened files;
acquiring the creation time and the deletion time of all iNode nodes in the iNode area; when the creation time of the iNode node is later than the snapshot time, recovering the corresponding iNode node; when the deleting time of the iNode nodes is later than the snapshot time, restoring the corresponding iNode nodes and the link relation between the iNode nodes;
acquiring the creation time of data pages stored in all page index records in a linked list management area; when the creation time of the data page is later than the snapshot time, recovering the corresponding data page and deleting the page index record in the page index linked list corresponding to the data page; and updating the address in the page index record which is earlier than the snapshot time and closest to the snapshot time to the node page of the data page, and restoring the file to the file version of the snapshot time.
6. A control apparatus of a file system, characterized in that the control apparatus comprises:
the iNode area setting module is used for setting an iNode area for storing iNode nodes, wherein the iNode nodes comprise N-ary tree level fields, N-ary tree root node fields and snapshot version pointer fields; the N-ary tree stage field is used for storing the stage of an N-ary tree structure adopted by a file, the N-ary tree root node field is used for storing the physical address of a file root node page, and the snapshot version pointer field is used for pointing to a snapshot iNode node corresponding to the latest snapshot of the iNode node;
the data area setting module is used for establishing a data area of an N-ary tree structure on the basis of the root node page; the N-ary tree structure comprises any multiple levels, and the nodes of the upper level store the corresponding physical addresses of the nodes of the lower level; all nodes of the last level are data pages, all other nodes except the nodes of the last level are node pages, and the data pages and the node pages are arranged in a mixed manner in the data area;
the linked list management area setting module is used for setting a linked list management area consisting of page index records; each page index record corresponds to one physical page of the data area in sequence, and the page index record number is the same as the physical page number of the data area; the page index record corresponding to each data page stores the creation time of the data page and the position information of the data page of the previous version, so that a page index linked list is formed, each page index linked list corresponds to a set of the current version of one data page in a file and all historical versions generated by a snapshot and is used for realizing the snapshot rollback of the file;
the system comprises a data page updating module, a data page updating module and a data page updating module, wherein the data page updating module is used for acquiring the creation time and the system snapshot time of a target data page to be updated, and the system snapshot time is the latest snapshot time of the file system; if the creation time of the target data page is later than the system snapshot time, writing the updated data into the target data page; or, if the creation time of the target data page is earlier than the system snapshot time, writing the updated data into an idle page of a data area to form a new data page; setting a page index record of the new data page in a linked list management area, and writing the position information and the current time of a target data page into the page index record of the new data page so that the page index record of the new data page is inserted into the head of a data page linked list; and updating the physical address of the new data page to the node page corresponding to the target data page, so that the node page points to the new data page.
7. The control apparatus of a file system according to claim 6, wherein said control apparatus further comprises an iNode node information updating module, said iNode node further comprising an iNode node information field storing node information thereof, said iNode node updating module for,
acquiring the creation time and system snapshot time of a target iNode node to be updated, wherein the system snapshot time is the latest snapshot time of the file system;
if the creation time of the target iNode node is later than the system snapshot time, updating an iNode node information field in the target iNode node; alternatively, the first and second electrodes may be,
if the creation time of the target iNode node is earlier than the system snapshot time, distributing idle iNode nodes in the iNode area as snapshot iNode nodes, and updating the snapshot version pointer field; initializing the snapshot iNode node according to the target iNode node; and storing a snapshot iNode node number in the target iNode node to point to the snapshot iNode node and updating the iNode node information field of the target iNode node.
8. The control device of a file system according to claim 6, further comprising an operation control module, wherein the file system comprises a root folder, and a snapshot folder under the root folder, under which the contents of files other than the snapshot folder are mapped, the operation control module is configured to,
when accessing the file through the path of the root folder, reading or writing the file of the current version; alternatively, the first and second electrodes may be,
when a file is accessed through a snapshot folder path, marking the iNode nodes of the file; if the operation on the file is writing, returning a rejection message according to the marked iNode node to reject to write the file; and if the operation on the file is reading, reading the file of the latest version before the designated snapshot time according to the marked iNode node and the designated snapshot time.
9. The control device of file system according to claim 6, wherein said control device further comprises an access control module for,
searching a page index linked list corresponding to the target data page from the linked list management area;
selecting a page index record which is earlier than and closest to the specified time from the searched page index linked list;
and extracting the position information in the page index record, and updating the physical address in the node page corresponding to the target data page according to the position information so as to enable the node page to point to the snapshot version data page corresponding to the specified time.
10. The control device of a file system according to claim 6, further comprising a rollback module for,
closing all opened files;
acquiring the creation time and the deletion time of all iNode nodes in the iNode area; when the creation time of the iNode node is later than the snapshot time, recovering the corresponding iNode node; when the deleting time of the iNode nodes is later than the snapshot time, restoring the corresponding iNode nodes and the link relation between the iNode nodes;
acquiring the creation time of data pages stored in all page index records in a linked list management area; when the creation time of the data page is later than the snapshot time, recovering the corresponding data page and deleting the page index record in the page index linked list corresponding to the data page; and updating the address in the page index record which is earlier than the snapshot time and closest to the snapshot time to the node page of the data page, and restoring the file to the file version of the snapshot time.
11. A terminal, characterized in that the terminal comprises at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions for execution by the at least one processor to enable the at least one processor to:
setting an iNode area for storing iNode nodes, wherein the iNode nodes comprise an N-ary tree level field, an N-ary tree root node field and a snapshot version pointer field; the N-ary tree stage field is used for storing the stage of an N-ary tree structure adopted by a file, the N-ary tree root node field is used for storing the physical address of a file root node page, and the snapshot version pointer field is used for pointing to a snapshot iNode node corresponding to the latest snapshot of the iNode node;
establishing a data area of an N-ary tree structure based on the root node page; the N-ary tree structure comprises any multiple hierarchies, and nodes of an upper hierarchy store corresponding physical addresses of nodes of a lower hierarchy; all nodes of the last level are data pages, all other nodes except the nodes of the last level are node pages, and the data pages and the node pages are arranged in a mixed manner in the data area;
setting a linked list management area consisting of page index records; each page index record corresponds to one physical page of the data area in sequence, and the page index record number is the same as the physical page number of the data area; the page index record corresponding to each data page stores the creation time of the data page and the position information of the data page of the previous version, so that a page index linked list is formed, each page index linked list corresponds to a set of the current version of one data page in a file and all historical versions generated by a snapshot and is used for realizing the snapshot rollback of the file;
the system comprises a data page updating module, a data page updating module and a data page updating module, wherein the data page updating module is used for acquiring the creation time and the system snapshot time of a target data page to be updated, and the system snapshot time is the latest snapshot time of the file system; if the creation time of the target data page is later than the system snapshot time, writing the updated data into the target data page; or, if the creation time of the target data page is earlier than the system snapshot time, writing the updated data into an idle page of a data area to form a new data page; setting a page index record of the new data page in a linked list management area, and writing the position information and the current time of a target data page into the page index record of the new data page so that the page index record of the new data page is inserted into the head of a data page linked list; and updating the physical address of the new data page to the node page corresponding to the target data page, so that the node page points to the new data page.
CN201710337922.5A 2017-05-15 2017-05-15 File system control method and device and terminal Active CN107180092B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710337922.5A CN107180092B (en) 2017-05-15 2017-05-15 File system control method and device and terminal

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710337922.5A CN107180092B (en) 2017-05-15 2017-05-15 File system control method and device and terminal

Publications (2)

Publication Number Publication Date
CN107180092A CN107180092A (en) 2017-09-19
CN107180092B true CN107180092B (en) 2020-10-23

Family

ID=59831495

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710337922.5A Active CN107180092B (en) 2017-05-15 2017-05-15 File system control method and device and terminal

Country Status (1)

Country Link
CN (1) CN107180092B (en)

Families Citing this family (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107704599A (en) * 2017-10-16 2018-02-16 杭州安恒信息技术有限公司 A kind of method and apparatus for realizing EDR data quick-searchings
CN110018989B (en) * 2017-11-13 2021-05-18 华为技术有限公司 Snapshot comparison method and device
CN108062233A (en) * 2017-12-29 2018-05-22 上海大汉三通无线通信有限公司 A kind of file backing method, system, device and computer readable storage medium
CN110019016A (en) * 2017-12-29 2019-07-16 北京忆恒创源科技有限公司 The KV for providing logic key stores device and method thereof
CN108563751A (en) * 2018-04-16 2018-09-21 中国刑事警察学院 Database fragment extracting method
CN109445989A (en) * 2018-10-22 2019-03-08 郑州云海信息技术有限公司 A kind of file system data backup method and device
CN109710542B (en) * 2018-12-28 2021-03-16 北京像素软件科技股份有限公司 Full N-way tree construction method and device
CN109933564A (en) * 2019-03-27 2019-06-25 中国科学院上海微系统与信息技术研究所 File system management method, device, terminal, the medium of quick rollback are realized based on chained list and N-ary tree construction
CN111090835B (en) * 2019-12-06 2022-04-19 支付宝(杭州)信息技术有限公司 Method and device for constructing file derivative graph
CN111400101B (en) * 2020-03-18 2021-06-01 北京北亚宸星科技有限公司 Data recovery method and system for deleting JFS2 file system data
CN111797058B (en) * 2020-07-02 2024-02-09 长沙景嘉微电子股份有限公司 Universal file system and file management method
CN113986824B (en) * 2021-10-27 2024-02-23 西安热工研究院有限公司 Method for efficiently storing and retrieving time sequence data
CN115185891B (en) * 2022-09-14 2023-01-17 联想凌拓科技有限公司 Data management method and device of file system, electronic equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101178677A (en) * 2007-11-09 2008-05-14 中国科学院计算技术研究所 Computer system for protecting software and method for protecting software
US8463820B2 (en) * 2009-05-26 2013-06-11 Intel Corporation System and method for memory bandwidth friendly sorting on multi-core architectures
CN103577329A (en) * 2013-10-18 2014-02-12 华为技术有限公司 Snapshot management method and device
US9244928B1 (en) * 2013-03-05 2016-01-26 Ca, Inc. Systems and methods for directory snapshot
CN106354890A (en) * 2016-11-22 2017-01-25 中国科学院上海微系统与信息技术研究所 Implementation method of random access file system based on N-ary tree structure

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101178677A (en) * 2007-11-09 2008-05-14 中国科学院计算技术研究所 Computer system for protecting software and method for protecting software
US8463820B2 (en) * 2009-05-26 2013-06-11 Intel Corporation System and method for memory bandwidth friendly sorting on multi-core architectures
US9244928B1 (en) * 2013-03-05 2016-01-26 Ca, Inc. Systems and methods for directory snapshot
CN103577329A (en) * 2013-10-18 2014-02-12 华为技术有限公司 Snapshot management method and device
CN106354890A (en) * 2016-11-22 2017-01-25 中国科学院上海微系统与信息技术研究所 Implementation method of random access file system based on N-ary tree structure

Also Published As

Publication number Publication date
CN107180092A (en) 2017-09-19

Similar Documents

Publication Publication Date Title
CN107180092B (en) File system control method and device and terminal
US8135907B2 (en) Method and system for managing wear-level aware file systems
US10289315B2 (en) Managing I/O operations of large data objects in a cache memory device by dividing into chunks
JP6205650B2 (en) Method and apparatus utilizing non-uniform hash function to place records in non-uniform access memory
US8315995B1 (en) Hybrid storage system
KR100484147B1 (en) Flash memory management method
US10565125B2 (en) Virtual block addresses
US8849880B2 (en) Providing a shadow directory and virtual files to store metadata
EP1265152B1 (en) Virtual file system for dynamically-generated web pages
US20150193434A1 (en) Storage media abstraction for uniform data storage
TW201935243A (en) SSD, distributed data storage system and method for leveraging key-value storage
US20090265519A1 (en) Method and system for power aware i/o scheduling
CN101488153A (en) Method for implementing high-capacity flash memory file system in embedded type Linux
CN106682110B (en) Image file storage and management system and method based on Hash grid index
KR20070024573A (en) Method for managing files for optimal performance
CN107463447A (en) B + tree management method based on remote direct nonvolatile memory access
Lee et al. An efficient index buffer management scheme for implementing a B-tree on NAND flash memory
CN110377599A (en) Key assignments storage device and its operating method
US11875055B2 (en) Storage device that receives inode address information to reduce external communication overhead
CN113568582B (en) Data management method, device and storage equipment
US11269771B2 (en) Storage device for improving journal replay, operating method thereof, and electronic device including the storage device
WO2022262381A1 (en) Data compression method and apparatus
US7424574B1 (en) Method and apparatus for dynamic striping
US20170286442A1 (en) File system support for file-level ghosting
CN115964350A (en) File system management model and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant