File processing method, file system, electronic device and medium

By separating and processing file write operations in the file system, using hardware transaction memory and shadow page technology, combined with sequence number management, the problem of hardware transaction memory being difficult to perform large-scale write operations is solved, and data crash consistency and Concurrency consistency improves system stability and performance.

CN116661981BActive Publication Date: 2024-08-27HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210152798.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-18
Publication Date
2024-08-27
Estimated Expiration
2042-02-18

AI Technical Summary

Technical Problem

Due to hardware resource limitations, hardware transaction memory is difficult to perform file write operations that are large in number or occupy large amounts of memory, resulting in transaction failures and data consistency issues.

Method used

Obtain the update data of user write operations through the file system interface, which is divided into visible and invisible operations. The hardware transaction memory is used to perform visible write operations, and the shadow page technology of dynamic random access memory is used to perform invisible write operations. It combines sequence number management and Memory allocator to ensure crash consistency and concurrency consistency.

Benefits of technology

It effectively avoids transaction failures caused by excessive hardware memory execution operations, ensures data crash consistency and concurrency consistency, reduces the number of hardware transaction memory operations, and improves system stability and performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116661981B
    Figure CN116661981B
Patent Text Reader

Abstract

The present application relates to the technical field of file systems, and discloses a file processing method, a file system, an electronic device, and a medium. The method includes: obtaining update data generated by a user performing a write operation on file data; in response to a user's request to save the update data, obtaining various operations required to execute the request to save the update data; each operation includes a first type of operation and a second type of operation, the first type of operation includes an update operation that can be observed through a file system interface, and the second type of operation includes a read operation and / or an update operation that cannot be observed through a file system interface; executing the second type of operation through a first execution method; after the second type of operation is executed, executing the first type of operation by calling hardware transaction memory. Based on the above scheme, the file system can only use hardware transaction memory to execute the write operation that is visible in the first type of operation among various operations, which can effectively avoid the problem of transaction failure caused by too many hardware memory execution operations.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of file systems, and in particular to a file processing method, a file system, an electronic device and a medium. Background Art

[0002] The file system is a very important component of the operating system. The file system is generally used to store and manage file information. In order to better manage files, the file system needs to ensure data consistency. Among them, data consistency includes crash consistency and concurrency consistency.

[0003] Among them, crash consistency means ensuring that when the system crashes and restarts, all previous file system requests should satisfy the all-or-nothing semantics, that is, all modifications to the file system status should be saved in full or not saved at all. When crash consistency cannot be guaranteed, for example, the system crashes when the user is writing data, it can be understood that writing new data to a file requires first allocating storage space and then writing data. After the system is restored, the user may read the old data, that is, the new data is not written successfully, so the file does not use the newly allocated storage space, but the file system will think that these storage spaces have been used normally by the file, so there will be a situation where these storage spaces are lost. Concurrency consistency means that for any file system request, the modifications to the file system status observed by other concurrent tasks should be consistent. For example, when a user is modifying a file, there is a concurrent task to read the file, then the file status read is the saved modification, and the unsaved modification in the file cannot be read.

[0004] In the prior art, log technology is generally used to perform file write operations. However, before writing data into the system based on log technology, it is necessary to write it into a special log, so there is a problem of increasing writes, that is, increasing memory usage. There are also some solutions that perform file write operations based on hardware transaction memory, which can effectively ensure the consistency of transactions or data. However, since hardware transaction memory implements transaction execution based on hardware, it is difficult to execute a large number of operations or operations that occupy a large amount of memory due to hardware resource limitations. Summary of the invention

[0005] In order to solve the above-mentioned problem that due to the limitation of hardware resources, the hardware transaction memory is difficult to execute a large number of operations or operations that occupy a large amount of memory, the embodiments of the present application provide a file processing method, a file system, an electronic device and a medium.

[0006] In a first aspect, an embodiment of the present application provides a file processing method, comprising:

[0007] Obtain update data generated by the user's write operation on file data;

[0008] In response to a user's request for saving the updated data, obtaining various operations required to execute the request for saving the updated data; the various operations include a first type of operation and a second type of operation, the first type of operation includes an update operation that can be observed through a file system interface, and the second type of operation includes a read operation and / or an update operation that cannot be observed through a file system interface;

[0009] Execute the second type of operation by using a first execution mode;

[0010] After the second type of operation is executed, the first type of operation is executed through a second execution mode, and the second execution mode includes calling a hardware transaction memory.

[0011] It can be understood that in the embodiment of the present application, the file system can only use hardware transaction memory to execute the first type of operation, i.e., the visible write operation, among the operations required to execute the save request for updating data, which can effectively avoid the problem of transaction failure due to too many hardware memory execution operations.

[0012] Secondly, since the visible write operation is completed based on the hardware transactional memory, according to the characteristics of the hardware transactional memory execution operation, namely atomicity, consistency and isolation, when a system crash occurs, the crash consistency and concurrency consistency of the data can be effectively guaranteed.

[0013] It can be understood that in some embodiments, after detecting the user's request to save the updated data, that is, the user's save operation, the memory occupied by the updated data involved in the user's write operation can be determined. And when it is determined that the memory occupied by the updated data involved in the user's write operation is greater than the set value, only the first type of operation, that is, the visible write operation, is executed using the hardware transaction memory. The second type of operation is executed in other ways, for example, the invisible write operation can be executed based on the shadow page technology of the dynamic random access memory.

[0014] When it is determined that the memory occupied by the update data involved in the user's write operation is less than or equal to the set value, both the first type of operation and the second type of operation are executed using the hardware transaction memory.

[0015] In a possible implementation of the first aspect above, the file data has a corresponding sequence number;

[0016] The first type of operation includes: replacing the file data with update data and modifying the sequence number corresponding to the file data to the sequence number corresponding to the update data.

[0017] It can be understood that setting a sequence number for the file data and modifying the initial sequence number after the file write operation is submitted can facilitate the reading operation described later, and can infer that the file data has been modified based on the inconsistency between the current sequence number and the initial recorded sequence number, so as to ensure that the data finally read and the data written are consistent data, and ensure the concurrency consistency of the read and write operations and the write operations.

[0018] In a possible implementation of the first aspect above, when it is determined that the occupied memory required to execute the request to save the updated data is less than or equal to a set value, the first execution method includes calling a hardware transaction memory method.

[0019] It can be understood that when it is determined that the memory occupied by the updated data involved in the write operation is less than or equal to the set value, it can be inferred that the memory occupied by the data involved in the write operation may be less than or equal to the transaction memory that the hardware transaction can run. Therefore, the hardware transaction memory can directly execute all operations required to submit the write operation, that is, including the first type of operations and the second type of operations, but the second type of operations are still executed first, and then the first type of operations.

[0020] In a possible implementation of the first aspect above, when it is determined that the occupied memory required to execute the request to save the updated data is greater than a set value, the first execution mode does not adopt a mode of calling hardware transaction memory.

[0021] It can be understood that when it is determined that the memory occupied by the updated data involved in the write operation is greater than the set value, it can be determined that the memory occupied by the data involved in the write operation may be greater than the transaction memory that can be run by the hardware transaction memory, and the hardware transaction memory is difficult to execute all operations required to commit the write operation. In this case, only the hardware transaction memory can be used to execute the first type of operation to reduce the number of operations executed by the hardware transaction memory.

[0022] In a possible implementation of the first aspect, the file data includes data in a data page of the file, and the data page has a corresponding first sequence number;

[0023] The performing the second type of operation by using the first execution mode includes:

[0024] Writing the update data into the shadow page by using the shadow page technology;

[0025] The performing of the first type of operation by using a second execution mode includes:

[0026] The hardware transaction memory is called to replace the data page with the shadow page, and the first sequence number corresponding to the data page is changed to a second sequence number.

[0027] In a possible implementation of the first aspect, performing the first type of operation in the second execution mode further includes:

[0028] Modify file access time and commit memory allocation information to the file system.

[0029] In a possible implementation of the first aspect above, the file data includes metadata of the file.

[0030] In a possible implementation of the first aspect,

[0031] The writing operation on the file data comprises: writing operation on the storage location information of the file;

[0032] The performing the second type of operation by using the first execution mode includes:

[0033] Read the original storage location information and the target storage location information of the file;

[0034] The performing of the first type of operation by using a second execution mode includes:

[0035] The hardware transaction memory is called to replace the file data with the update data, and the slot sequence number and directory entry sequence number corresponding to the file are modified.

[0036] It can be understood that by adopting the above method, executing the read operation before the visible write operation can effectively avoid the problem of transaction failure caused by executing the visible write operation before the read operation is completed in some file processing methods in the prior art.

[0037] In a possible implementation of the first aspect, the present invention further includes:

[0038] When a concurrent process accesses the file data during the execution of the second type of operation, the execution of the second type of operation is controlled to fail.

[0039] In a possible implementation of the first aspect above, when the number of failed executions of the second type of operation reaches a set number, the file corresponding to the file data is locked.

[0040] In the embodiment of the present application, when the hardware transaction repeatedly fails and reaches the upper limit of failure, an inode-level lock is used, that is, the file is completely locked to ensure the concurrent consistency of the read and write operations of the file data. And it can effectively avoid the problem of performance degradation caused by multiple failures of hardware transaction memory in high concurrency scenarios.

[0041] In a possible implementation of the first aspect, the present invention further includes:

[0042] Record the initial sequence number of the data to be read;

[0043] Reading the data to be read;

[0044] Calling the hardware transaction memory to obtain the current sequence number of the data to be read;

[0045] When the current sequence number of the data to be read is consistent with the initial sequence number, the access time of the file is modified, and the hardware transaction memory is closed.

[0046] In a possible implementation of the first aspect above, when the current sequence number of the data to be read is inconsistent with the initial sequence number, the current sequence number of the data to be read is recorded, and the data to be read is read.

[0047] It can be understood that in the embodiments of the present application, the serial number corresponding to the data will be recorded before the data is read. In the final submission stage, the hardware transaction memory will be called to obtain the current serial number corresponding to the data. When it is determined that the serial number of the current data is inconsistent with the serial number of the initially recorded data, the serial number and data of the data are re-read to ensure that the data finally read and the data written are consistent data, thereby ensuring the concurrent consistency of the read operation and the write operation.

[0048] In a second aspect, an embodiment of the present application provides a file system, including a processor, wherein the processor is used to execute the file processing method.

[0049] In a possible implementation of the second aspect above, the file system further includes a kernel file system and a user-mode file system library;

[0050] The user-mode file system library includes at least one atomic memory allocator, and the kernel file system includes a kernel memory allocator;

[0051] The atomic memory allocator is used to allocate the free pages required for the write operation on the file;

[0052] The atomic memory allocator is also used to send a memory allocation request to the kernel memory allocator;

[0053] The kernel memory allocator is used to allocate corresponding memory to the atomic allocator according to the memory allocation request.

[0054] In a possible implementation of the second aspect, the atomic allocator includes a free page linked list and a to-be-allocated linked list, the free page linked list includes an unallocated pointer area and an allocated pointer area, the unallocated pointer area includes at least one unallocated pointer, and the allocated pointer area includes at least one allocated pointer;

[0055] When the user performs a write operation on the file data, the atomic memory allocator selects a preset pointer required for the write operation on the file data from the unallocated pointer area;

[0056] The atomic memory allocator adds the preset pointer to a linked list to be allocated;

[0057] When the second type of operation is completed, the atomic memory allocator allocates the preset pointer to the file corresponding to the file data.

[0058] In a possible implementation of the second aspect above, when the second type of operation fails to be executed, the atomic memory allocator allocates the preset pointer to an unallocated area of ​​the free page linked list.

[0059] It can be understood that in the embodiment of the present application, when a transaction fails or the system crashes and restarts, the to-be-allocated linked list will be directly added to the head of the free linked list, that is, the memory pages allocated to execute the transaction will be reclassified as unallocated memory pages, which can effectively avoid the occurrence of memory leaks caused by transaction failure, the transaction is not successfully executed, but the memory is occupied.

[0060] In a possible implementation of the second aspect, a file item is further included, where the file item includes a plurality of data pages, and each of the data pages has a corresponding sequence number.

[0061] In a possible implementation of the second aspect, the method further includes a directory, wherein the directory includes at least one slot, each slot having a corresponding pointer and a corresponding slot sequence number;

[0062] Each slot of the at least one slot includes at least one directory entry, and each directory entry of the at least one directory entry has a corresponding directory entry sequence number.

[0063] In a third aspect, an embodiment of the present application provides an electronic device, comprising the file system.

[0064] In a fourth aspect, an embodiment of the present application provides an electronic device, including:

[0065] a memory for storing instructions to be executed by one or more processors of the leather case keyboard;

[0066] The processor is one of the one or more processors of the electronic device, and is used to execute the above-mentioned file processing method.

[0067] In a fifth aspect, an embodiment of the present application provides a readable medium, on which instructions are stored, and when the instructions are executed on an electronic device, the machine executes the file processing method claimed above.

[0068] In a sixth aspect, an embodiment of the present application provides a computer program product, comprising instructions for executing the above-mentioned file processing method. BRIEF DESCRIPTION OF THE DRAWINGS

[0069] Figure 1 According to some embodiments of the present application, a scenario schematic diagram of a file processing method is shown.

[0070] Figure 2 According to some embodiments of the present application, a schematic diagram of the structure of a file system is shown.

[0071] Figure 3a According to some embodiments of the present application, a schematic diagram of the structure of an atomic memory allocator is shown.

[0072] Figure 3b According to some embodiments of the present application, a schematic diagram of the structure of an atomic memory allocator is shown.

[0073] Figure 3c According to some embodiments of the present application, a schematic diagram of the structure of an atomic memory allocator is shown.

[0074] Figure 4 According to some embodiments of the present application, a schematic diagram of the structure of a file item is shown.

[0075] Figure 5 According to some embodiments of the present application, a schematic diagram of the structure of a directory is shown.

[0076] Figure 6 According to some embodiments of the present application, a flowchart of a file processing method is shown.

[0077] Figure 7 According to some embodiments of the present application, a flowchart of a file processing method is shown.

[0078] Figure 8 According to some embodiments of the present application, a flowchart of a file processing method is shown.

[0079] Fig. 9 According to some embodiments of the present application, a flowchart of a file processing method is shown. DETAILED DESCRIPTION

[0080] The illustrative embodiments of the present application include, but are not limited to, a file processing method and a file system, and an electronic device.

[0081] In order to better understand the solutions in the embodiments of the present application, the nouns involved in the embodiments of the application are first explained accordingly.

[0082] Transaction: refers to a series of operations performed as a single logical unit of work, which is either completely executed or not executed at all. The following uses a bank transfer as an example to explain the concept of transactions:

[0083] For example, user A needs to transfer a certain amount of money to user B's account. The required transaction operations include deducting the amount from user A's account and adding the amount to user B's account. If the program is interrupted after deducting the amount from user A's account but before adding the amount to user B's account, the transaction will ensure that the deduction from user A's account is canceled, causing all operations in the transaction to fail.

[0084] Hardware transactional memory: A memory based on a multi-processor structure with shared storage. The execution of transactions is implemented by hardware circuits, which can ensure the atomicity, consistency and isolation of transactions.

[0085] Atomicity: refers to the state in which all actions in a transaction are executed or none of them are executed. For example, during the data update process, if other users access the file, the file status displayed to other users can only be the state in which the data is updated or the state in which the data is not updated at all, but not the state in which the data is half updated.

[0086] Consistency: means that the state of the system before and after the execution of any transaction that accesses shared data should be consistent.

[0087] Isolation: It means that before a transaction is committed normally, its internal operations are invisible to the outside world, that is, uncommitted transaction operations will not affect the state of the system.

[0088] In order to solve the aforementioned technical problem that the hardware transaction memory is difficult to execute a large number of operations or operations that occupy a large amount of memory due to the limitation of hardware resources, the present application provides a file processing method that can be executed by a file system. It includes: obtaining the user's write operation on file data, wherein the file data has a corresponding sequence number; when the user's save operation is detected, determining the memory occupied by the updated data involved in the user's write operation. When it is determined that the memory occupied by the updated data involved in the user's write operation is greater than the set value, the various operations required to submit the write operation are obtained. And first execute other operations other than the visible write operations in each operation, and after the other operations are executed, call the hardware transaction memory to execute the visible write operation. When it is determined that the memory occupied by the updated data involved in the write operation is less than or equal to the set value, directly call the hardware transaction memory, and execute all operations required to submit the user's write operation within the hardware transaction.

[0089] Among them, visible write operations include replacing old data with new data, modifying the sequence number corresponding to the file data, modifying the access time of the file corresponding to the file data, and submitting the corresponding memory allocation information to the file system, etc., which are update operations that can be observed through the file system interface.

[0090] Other operations besides visible write operations include read operations and invisible write operations, where invisible write operations are update operations that cannot be observed through the file system interface, such as memory allocation operations, operations to obtain updated data, etc. In the embodiment of the present application, other operations besides visible write operations can be performed by any other storage device. For example, invisible write operations can be performed based on the shadow page technology of dynamic random access memory.

[0091] It is understood that the above file data may include data in a data page in a file or metadata of the file, wherein the metadata of the file includes system data describing the characteristics of a file, such as directory entries, attributes, storage location information and other data.

[0092] In the above-mentioned file processing method provided by the embodiment of the present application, when it is determined that the updated data involved in the user's write operation occupies a large amount of memory, the file system obtains the operations required to submit the write operation, and only uses the visible write operations in the operations to execute using the hardware transaction memory. This can effectively reduce the number of operations in the hardware transaction memory and avoid the problem of transaction failure due to too many operations executed by the hardware memory.

[0093] Secondly, since the visible write operation is completed based on the hardware transactional memory, according to the characteristics of the hardware transactional memory execution operation, namely atomicity, consistency and isolation, when a system crash occurs, the crash consistency and concurrency consistency of the data can be effectively guaranteed.

[0094] The following takes the file data as the data in the data page of the file and the writing operation of the data page in the file as an example to illustrate the file processing method provided in the embodiment of the present application. The following takes the writing operation of the data page in the word document by the user as an example to illustrate the scheme in the embodiment of the present application.

[0095] For example, Figure 1 As shown, the user writes data to the first data page 101 and the second data page 102 in the word document, and the file system obtains the user's write operation on the first data page 101 and the second data page 102 in the document, wherein the first data page 101 and the second data page 102 have corresponding serial numbers.

[0096] When it is detected that the user clicks the "Save" control or other forms of save operations, the data involved in the above-mentioned write operation of the user, that is, the memory occupied by the write data, is determined. When it is determined that the memory occupied by the above-mentioned write data of the user is greater than the set value, for example, greater than 4096b, all operations required to submit the write operation are obtained, which may specifically include the operation of obtaining new data and the operation of replacing old data with new data, wherein the replacement of old data with new data is a visible write operation. At this time, the invisible write operation of obtaining new data is executed first, and then the visible write operation of replacing old data with new data is executed. The operation of acquiring new data is performed through the shadow page technology, specifically, the first data page 101 and the second data page 102 are assigned corresponding first shadow pages 103 and second shadow pages 104, and the write data is written into the first shadow pages 103 and second shadow pages 104. After all the write data is written into the first shadow pages 103 and second shadow pages 104, the hardware transaction memory is called, and the first shadow pages 103 and second shadow pages 104 are used to replace the first data page 101 and the second data page 102. In the embodiment of the present application, the visible write operation performed by the hardware transaction memory may also include modifying the sequence number corresponding to the first data page 101 and the second data page 102, modifying the access time of the file, and submitting the corresponding memory allocation information. The memory allocation information may be that two shadow pages are allocated.

[0097] The following uses file data as metadata and the writing operation of the file metadata as an example to illustrate the file processing method provided in the embodiment of the present application.

[0098] For example, if a user moves a file from the C drive to the F drive, the storage location information of the file will change, that is, the metadata of the file will be modified, that is, a write operation is performed on the file metadata. When the file system obtains the write operation and detects the user's save operation, it determines the memory occupied by the data corresponding to the user's write operation, that is, the write data. When it is determined that the memory occupied by the user's write data is greater than the set value, it obtains all operations required to submit the write operation, such as the read operation of the C drive and the read operation of the F drive, as well as the file deletion operation of the C drive and the file addition operation of the F drive. Among them, the file deletion operation of the C drive and the file addition operation of the F drive are visible write operations, and the read operation of the C drive and the read operation of the F drive are read operations. At this time, the file system will first execute the read operation of the C drive and the read operation of the F drive, and then call the hardware transaction memory to execute the file deletion operation of the C drive and the file addition operation of the F drive, and at the same time modify the directory entry sequence number and slot sequence number corresponding to the file.

[0099] The above method can effectively avoid the problem of transaction failure caused by executing visible write operations before completing the read operation in some file processing methods in the prior art. For example, when the read operation of the F drive is not completed, the file deletion operation of the C drive and the file addition operation of the F drive are executed, but it is found that the F drive does not exist, thus causing the transaction execution to fail.

[0100] In order to better understand the solution provided in the embodiments of the present application, the structure of the file system involved in the present application is first described below. Figure 2 As shown, Figure 2 A schematic diagram of a file system is shown.

[0101] It can be understood that the file system provided in the embodiment of the present application may include a kernel file system and a user-mode file system library.

[0102] The user-state file system library includes multiple data areas, such as data area A, data area B and data area C, and multiple user-state atomic memory allocators, such as atomic memory allocator A, atomic memory allocator B and atomic memory allocator C. The user-state file system can use multiple user-state atomic memory allocators to manage the data and metadata in multiple data areas respectively. For example, atomic memory allocator A manages the data and metadata in data area A, atomic memory allocator B manages the data and metadata in data area B, and atomic memory allocator C manages the data and metadata in data area C.

[0103] The user-state file system can also allocate separate free pages in each data area through the user-state atomic memory allocator. When the free pages in a data area are insufficient, the user-state atomic memory allocator corresponding to the data area can send a memory allocation request to the kernel memory allocator of the kernel file system so that the kernel memory allocator can allocate additional free pages to the data area. For example, when the free pages in data area A are insufficient, the user-state atomic memory allocator A corresponding to the data area A can send a memory allocation request to the kernel memory allocator of the kernel file system so that the kernel memory allocator can allocate additional free pages to data area A.

[0104] Among them, the basic structure of the atomic memory allocator is as follows Figure 3a As shown in FIG. 2 , a free linked list 200 is shown, in which each pointer before the current position represents an unused free page, and each pointer after the current position represents a memory page that has been used. Figure 3a As shown in the figure, pointer 4 and all pointers to the right of pointer 4 represent allocated memory pages, and pointer 1, pointer 2, and pointer 3 represent unallocated memory pages. When the file system needs to allocate a page of memory, such as Figure 3bAs shown, the atomic memory allocator will move the current position forward by one position, and the pointer of the allocated memory page, for example, pointer 3, will be added to a pending allocation list with the same structure as the free list 200. When the transaction is committed, the pending allocation list will be directly released, thereby completing the permanent allocation of memory. When the transaction fails or the system crashes and restarts, the pending allocation list will be directly added to the head of the free list 200. For example, if there is only pointer 3 in the pending allocation list, then Figure 3c As shown, pointer 3 will be added to the head of the free list 200. The memory page allocated to the transaction will be reclassified as an unallocated memory page, which can effectively avoid the occurrence of memory leaks caused by the transaction failure, the transaction is not successfully executed, but the memory is occupied.

[0105] It can be understood that each of the above data areas has a separate atomic memory allocator, which enables the memory allocator to manage the corresponding data area separately, avoiding competition for memory allocation among multiple data areas, and thus safely classifying modifications to the memory allocator as an invisible write operation type.

[0106] Since memory allocation operations can also be classified as invisible write operations, memory allocation operations must be completed before write operations. The atomic memory allocator using the above structure can achieve efficient commit and rollback, and can effectively prevent the atomic memory allocator from crashing before the transaction is committed.

[0107] The user-mode file system library can also include file items and directories. A file item can include multiple files. The structure of each file can be as follows: Figure 4 As shown, it includes multiple data pages such as page 0, page 1...page n, each data page has a corresponding pointer, for example, the pointer corresponding to page 0 is pointer 0, the pointer corresponding to page 1 is pointer 1, and the pointer corresponding to page n is pointer n; wherein each pointer has a corresponding sequence number, for example, pointer 0 corresponds to sequence number 0, pointer 1 corresponds to sequence number 1, and pointer 2 corresponds to sequence number 2; that is, each data page has a corresponding sequence number, for example, page 0 corresponds to sequence number 0, page 1 corresponds to sequence number 1, and page 2 corresponds to sequence number 2; each time data is modified, the sequence number of the data page corresponding to the data will also be modified synchronously.

[0108] The directory structure is as follows Figure 5As shown, it is a hash table. Specifically, it includes multiple slots, each slot stores multiple directory entries, for example, slot 0 has directory entry 0, directory entry 1 and directory entry 2; each slot has a corresponding slot sequence number and pointer, for example, slot 0 has a corresponding sequence number 0 and pointer 0, and each directory entry has a corresponding directory entry sequence number, directory entry number and directory entry name. For example, directory entry 0 has a corresponding directory entry sequence number 0, directory entry number 0 and directory entry name 0. When the file system performs an access operation on a directory entry, it first performs a hash calculation on the access directory name and maps it to the corresponding slot, traverses all directory entries in the slot, and finds the directory entry corresponding to the above directory name. When a directory entry is modified, the slot sequence number and the directory entry sequence number will be modified synchronously.

[0109] The kernel file system includes a kernel memory allocator, which is responsible for the initialization of the file system and metadata management of all data areas. When receiving a memory allocation request sent by a user-mode atomic memory allocator, the kernel memory allocator can allocate additional free pages to the data area managed by the user-mode atomic memory allocator.

[0110] The following is an introduction to the file processing method provided in the embodiment of the present application in conjunction with the above-mentioned file system. Figure 6 A flowchart of a file processing method according to an embodiment of the present application is shown. Figure 6 The file processing method shown in can be executed by the file system. Figure 6 As shown, the file processing method may include:

[0111] 601: Obtain a user's write operation on file data, wherein the file data has a corresponding sequence number.

[0112] It is understood that in the embodiment of the present application, the above-mentioned file data may include data in a data page in a file or metadata of the file. The metadata of the file includes system data describing the characteristics of a file, such as data describing data attributes, storage location, etc. such as directory entries.

[0113] The write operation to the data page in the file may include various operations such as deleting data and adding data.

[0114] The writing operation of the metadata of a file may include the operation of moving the location of the file, the operation of modifying the attributes of the file, etc.

[0115] 602: When a save operation of the user is detected, the memory occupied by the update data involved in the write operation of the user is determined.

[0116] It can be understood that the user's saving operation can be a saving method such as the user clicking a save button, or an automatic save set by the user or the system.

[0117] The memory occupied by the updated data involved in the write operation includes the sum of the memory occupied by the deleted data and the memory occupied by the added data.

[0118] 603: Determine whether the memory occupied by the data involved in the user's write operation is greater than a set value.

[0119] If the result of the judgment is yes, it is determined that the memory occupied by the data involved in the write operation may be larger than the transaction memory that can be run by the hardware transaction memory, and the hardware transaction memory is difficult to execute all the operations required to submit the write operation, then the process goes to 604 to obtain the operations required to submit the write operation. If the result of the judgment is no, it is determined that the memory occupied by the data involved in the write operation may be less than or equal to the transaction memory that can be run by the hardware transaction memory, then the process goes to 605 to call the hardware transaction memory to execute the operations required to submit the write operation.

[0120] It can be understood that the above-mentioned setting value may be a transaction memory value that can be run by the hardware transaction memory. In some embodiments, the above-mentioned setting value may also be set according to actual needs.

[0121] 604: Obtain various operations required to submit the write operation, wherein the various operations include first-category operations and second-category operations, wherein the first-category operations are visible write operations, and the second-category operations are read operations and / or invisible write operations.

[0122] It can be understood that the file system can arrange the order of operations in advance by obtaining the operations required to submit the write operation, and execute the read operation and / or invisible write operation before the visible write operation. The visible write operation is executed using hardware transaction memory.

[0123] For example, for the above-mentioned write operation to the data in the data page of the file, all operations required to submit the write operation may include an operation of obtaining new data and an operation of replacing old data with new data, wherein the operation of replacing old data with new data is an update that can be observed through the file system interface, and is therefore a visible write operation, and the operation of obtaining new data is an update that cannot be observed by the file system interface, and is therefore an invisible write operation.

[0124] At this time, the invisible write operation of acquiring new data is first performed, and then the visible write operation of replacing old data with new data is performed. The acquisition operation of new data is performed through the shadow page technology, specifically, the corresponding shadow page is allocated to the data page, and the new data is written into the shadow page. When all the data is written into the shadow page, the hardware transaction memory is called, and the shadow page is replaced by the data page through the hardware transaction memory. In the embodiment of the present application, the visible write operation performed by the hardware transaction memory can also include modifying the sequence number corresponding to the data page, modifying the access time of the file, and submitting the corresponding memory allocation information.

[0125] For another example, for the above-mentioned write operation of the metadata of the file, such as moving the file location, that is, the renaming operation of the file storage location information. All operations required to submit the renaming operation include a read operation of reading the original storage location of the file, a read operation of reading the target storage location of the file, and a visible write operation of deleting the file from the original storage location and adding the file to the target storage location. At this time, the read operation of reading the original storage location of the file and the read operation of reading the target storage location of the file can be performed first, and then the hardware transaction memory is called to perform a visible write operation of deleting the file from the original storage location and adding the file to the target storage location.

[0126] 605: Execute the second type of operation.

[0127] It can be understood that in the implementation of this application, the first execution method can be used to execute the second type of operation.

[0128] As mentioned above, the second category of operations includes read operations, invisible write operations, and other operations that are not visible write operations, among which invisible write operations can be performed by technologies such as shadow pages, that is, the first execution method mentioned in the embodiment of the present application can be the shadow page technology method.

[0129] For example, for a write operation that modifies a data page within a file, the invisible write operation among all operations required to submit the write operation can be an operation for the file system to obtain updated data. This operation can be performed by shadow page technology, that is, allocating a corresponding shadow page to the corresponding data page, and writing the updated data involved in the write operation into the shadow page.

[0130] For the above-mentioned writing operation of the metadata of the file, such as moving the file location, that is, the renaming operation of the file location information. All operations required to submit the renaming operation include a read operation of reading the original location of the file and a read operation of reading the target location of the file. The read operation can be performed by any memory.

[0131] 606: Call the hardware transaction memory to perform the first type of operation.

[0132] It can be understood that in the implementation of the present application, the second execution mode can be used to execute the first type of operation, wherein the second execution mode can be a mode of calling hardware transaction memory.

[0133] It can be understood that in the embodiment of the present application, for the first type of operations, that is, visible write operations, only the hardware transaction memory is used for execution, and other operations are executed in other ways, which can effectively reduce the number of operations in the hardware transaction memory and avoid the problem of transaction failure due to too many operations executed by the hardware memory.

[0134] Secondly, since the visible write operation is completed based on the hardware transactional memory, according to the characteristics of the hardware transactional memory execution operation, namely atomicity, consistency, isolation and persistence, when a system crash occurs, the crash consistency and concurrency consistency of the data can be effectively maintained.

[0135] Visible write operations include replacing old data, modifying the sequence number corresponding to the file data, modifying the access time of the file corresponding to the file data, and submitting the corresponding memory allocation information to the file system.

[0136] For example, for the above-mentioned write operation of modifying the data page in the file, the visible write operation includes replacing the old data, modifying the sequence number corresponding to the file data, modifying the access time of the file corresponding to the file data, and submitting the corresponding memory allocation information to the file system.

[0137] When the operation of obtaining updated data is completed based on the shadow page, the visible write operation performed by the hardware transaction memory is: the shadow page is replaced with the initial data page through the hardware transaction memory, and the sequence number corresponding to the data page is modified, the access time of the file is modified, and the corresponding memory allocation information is submitted to the file system.

[0138] As another example, for the above-mentioned write operation on the metadata of a file, such as moving the file location, that is, renaming the file location information, the visible write operation includes deleting the file from the original storage location and adding the file to the target storage location. Therefore, the operation performed by the hardware transaction memory is deleting the file from the original storage location and adding the file to the target storage location, and modifying the sequence number of the directory entry and slot corresponding to the file, modifying the access time of the file, and submitting the corresponding memory allocation information to the file system.

[0139] 607: Directly call the hardware transaction memory to perform the operations required to commit the write operation.

[0140] It can be understood that when it is determined that the memory occupied by the updated data involved in the write operation is less than or equal to the set value, it can be inferred that the memory occupied by the data involved in the write operation may be less than or equal to the transaction memory that the hardware transaction can run, so the hardware transaction memory can directly execute all operations required to submit the write operation.

[0141] For example, for the above-mentioned write operation on the data in the data page of the file, all operations required to submit the write operation can be directly executed through the hardware transaction memory, such as the operation of obtaining new data and replacing old data with new data, and can also include modifying the serial number corresponding to the data page, modifying the access time of the file, and submitting the corresponding memory allocation information to the file system.

[0142] It can be understood that metadata access operations in conventional file systems are fixed. Therefore, compared with data read and write operations, metadata access operations usually involve a smaller amount of data. The memory access of most metadata access operations will not exceed the capacity limit of the hardware transaction memory. Therefore, hardware transactions can be directly called to ensure the consistency of these metadata accesses.

[0143] For some metadata write operations involving a large amount of memory access (such as the above-mentioned operation of moving the file location, that is, the renaming operation), the segmentation method in the embodiment of the present application can also be adopted, that is, first obtain all operations required to perform the operation, put the visible write operation at the end, and execute it by hardware transaction memory to ensure crash consistency, complete most of the other operations in advance, and after executing the visible write operation, modify the corresponding slot sequence number and directory entry sequence number to ensure its concurrent consistency.

[0144] In the above-mentioned file processing method provided by the embodiment of the present application, when it is determined that the updated data involved in the user's write operation occupies a large amount of memory, the file system obtains the operations required to submit the write operation, and only uses the visible write operations in the operations to execute using the hardware transaction memory. This can effectively reduce the number of operations in the hardware transaction memory and avoid the problem of transaction failure due to too many operations executed by the hardware memory.

[0145] Secondly, since the visible write operation is completed based on the hardware transactional memory, according to the characteristics of the hardware transactional memory execution operation, namely atomicity, consistency and isolation, the crash consistency and concurrency consistency of the data can be guaranteed when a system crash occurs.

[0146] It can be understood that in the embodiment of the present application, in terms of concurrent consistency, for example, when a concurrent process accesses shared data during data update, the hardware transaction memory will control the hardware transaction to fail, that is, the operation being executed fails, for example, the modification to the data is not saved. And the above transaction is re-executed. Therefore, if the transaction is successfully executed, it can be confirmed that there is no impact on other concurrent processes.

[0147] In the embodiment of the present application, when the hardware transaction repeatedly fails and reaches the upper limit of failure, an inode-level lock is used, that is, the file is completely locked to ensure the concurrent consistency of the read and write operations of the file data. And it can effectively avoid the problem of performance degradation caused by multiple failures of hardware transaction memory in high concurrency scenarios.

[0148] In the embodiment of the present application, when a transaction is committed, the to-be-allocated linked list in the atomic memory allocator will be directly released, thereby completing the permanent allocation of memory. When a transaction fails or the system crashes and restarts, the to-be-allocated linked list will be directly added to the head of the free linked list, that is, the memory page allocated to execute the transaction will be reclassified as an unallocated memory page, which can effectively avoid the occurrence of memory leaks caused by the failure of a transaction, the transaction was not successfully executed, but the memory was occupied.

[0149] The following takes the file data as the data in the data page of the file and the write operation of the data page in the file as an example to illustrate the file processing method provided in the embodiment of the present application. Figure 7 As shown, Figure 7 A schematic diagram of a file processing method in an embodiment of the present application is shown.

[0150] 701: Obtain the write operation of the user on the data page in the file, wherein each data page is assigned a corresponding sequence number.

[0151] It can be understood that the write operation of data on a data page in a file may include various operations such as deleting data and adding data.

[0152] 702: When a save operation of the user is detected, the memory occupied by the updated data involved in the write operation of the user is determined.

[0153] It can be understood that the user's saving operation can be a saving method such as the user clicking a save button, or an automatic save set by the user or the system.

[0154] The memory occupied by the updated data involved in the write operation includes the sum of the memory occupied by the deleted data and the memory occupied by the added data.

[0155] 703: Determine whether the memory occupied by the data involved in the user's write operation is greater than a set value.

[0156] If the result of the judgment is yes, it is determined that the memory occupied by the data involved in the write operation may be larger than the transaction memory that can be run by the hardware transaction memory, and the hardware transaction memory is difficult to execute all the operations required to submit the write operation, then the process goes to 704 to obtain the operations required to submit the write operation. If the result of the judgment is no, it is determined that the memory occupied by the data involved in the write operation may be less than or equal to the transaction memory that can be run by the hardware transaction memory, then the process goes to 705 to call the hardware transaction memory to execute the operations required to submit the write operation.

[0157] 704: Obtain the first type of operations and the second type of operations required to submit the write operation. The first type of operations include operations of replacing old data with new data and modifying the sequence number corresponding to the data page, and the second type of operations include operations of obtaining new data.

[0158] As mentioned above, the first type of operations are visible write operations, and the second type of operations are read operations and / or invisible write operations.

[0159] The operation of writing data to a data page in a file may also include the operation of modifying the access time of the file and submitting the corresponding memory allocation information to the file system.

[0160] 805: Execute the second type of operation.

[0161] It can be understood that the second type of operation, that is, the acquisition operation of new data, is performed in the embodiment of the present application by allocating a corresponding shadow page to the corresponding data page and writing the updated data involved in the write operation into the shadow page. In some embodiments, other methods can also be used to perform the operation.

[0162] 706: Call the hardware transaction memory to perform the first type of operation.

[0163] It can be understood that the specific method of performing the first type of operation is to call the hardware transaction memory, replace the initial data page with the shadow page, and modify the sequence number corresponding to the data page.

[0164] In some embodiments, calling the hardware transaction memory may also perform the above-mentioned other visible write operations, such as modifying the access time of the file and submitting the corresponding memory allocation information to the file system.

[0165] 707: Call the hardware transaction memory to perform the first type of operation and the second type of operation required to commit the write operation.

[0166] The following uses file data as file metadata and takes moving the file location, that is, writing the storage location information of the file, as an example to illustrate the file processing method provided in the embodiment of the present application. Figure 8 As shown, Figure 8 A schematic diagram of a file processing method in an embodiment of the present application is shown.

[0167] 801: Obtaining a user's operation of changing the location of a file, wherein a directory entry and a slot corresponding to each file have a corresponding sequence number;

[0168] It can be understood that the user's operation of changing the location of a file can be an operation of the user moving the file from an original storage location to a target storage location. When the location of a file is changed, the storage location information of the file will be changed.

[0169] 802: When a save operation of a user is detected, the memory occupied by the update data involved in the write operation of the user is determined.

[0170] It can be understood that when performing a write operation on the metadata of a file, the corresponding save operation may be performed by clicking a save control, or may be a custom save operation set by the system.

[0171] 803: Determine whether the memory occupied by the data involved in the file position change operation is greater than a set value.

[0172] If the judgment result is yes, it is determined that the memory occupied by the data involved in the file position change operation may be larger than the transaction memory that the hardware transaction memory can run, and the hardware transaction memory is difficult to execute all operations required to submit the file position change operation, then go to 804 to obtain the operations required to submit the file position change operation.

[0173] If the result of the judgment is no, it is determined that the memory occupied by the data involved in the file position change operation may be less than or equal to the transaction memory that can be run by the hardware transaction memory, then go to 805, call the hardware transaction memory, and execute various operations required to submit the file position change operation.

[0174] 804: Obtain the first type of operation and the second type of operation required to submit the file location change operation. The first type of operation includes the operation of deleting the file from the original storage location of the file, the operation of adding the file to the target storage location of the file, and the operation of modifying the directory entry and slot corresponding to the file to have the corresponding sequence number. The second type of operation includes the operation of reading the original storage location of the file and the operation of reading the target storage location of the file.

[0175] It can be understood that, as mentioned above, the first type of operations are visible write operations, and the second type of operations are read operations and / or invisible write operations and other operations that do not belong to visible write operations.

[0176] 805: Execute the second type of operation.

[0177] It can be understood that the second type of operation is the operation of reading the original storage location of the file and reading the target storage location of the file.

[0178] 806: Call the hardware transaction memory to perform the first type of operation.

[0179] It can be understood that the first type of operation is to delete the file at the original storage location of the file, add the file to the target storage location of the file, and modify the directory entry corresponding to the file and the corresponding sequence number of the slot.

[0180] It can be understood that the first type of operation may also include other visible write operations.

[0181] 807: Call the hardware transactional memory to perform the first and second type operations required to commit the file position change operation.

[0182] It can be understood that the above-mentioned file processing method is to manage the write operation in the file system, and the file system also includes the read operation. The read operation can be performed in parallel with the write operation. The following takes the read and write operations as an example to illustrate another file processing method in the embodiment of the present application. Fig. 9 As shown, the file processing method in the embodiment of the present application may include:

[0183] 901: Record the sequence number corresponding to the data to be read.

[0184] 902: Read the corresponding data to be read.

[0185] It can be understood that in the embodiment of the present application, when reading data in a data page in a file, a page-by-page reading method can be adopted. For example, if the data to be read exists on two data pages, the sequence number of the first page is recorded first, and then the data of the first page is read. Then the sequence number of the second page is recorded, and then the data of the second page is read.

[0186] 903: Call the hardware transaction memory to obtain the current sequence number corresponding to the data to be read.

[0187] 904: Determine whether the current sequence number is consistent with the initial sequence number.

[0188] If they are inconsistent, go to 901 to re-record the sequence number corresponding to the data to be read, and re-read the corresponding data to be read. If they are consistent, go to 905 to modify the file access time and close the hardware transaction memory.

[0189] It can be understood that if the current sequence number is inconsistent with the sequence number of the initial record, it can be inferred that the file data has been modified. Then the sequence number and data of the data are re-read to ensure that the data finally read and the data written are consistent data, ensuring the concurrency consistency of the read and write operations and the write operations.

[0190] It can be understood that in the embodiment of the present application, whether the current sequence number is consistent with the initial sequence number can be determined by sequentially determining the sequence numbers one by one. For example, when reading the data in the two data pages in the above-mentioned file, it can be first determined whether the record number of the first data page is consistent with the sequence number of the first data page of the initial record. If not, the sequence number corresponding to the first data page is re-recorded, and the data in the first data page is re-read. If consistent, it is determined whether the record number of the second data page is consistent with the sequence number of the second data page of the initial record. If the record number of the second data page is inconsistent with the sequence number of the second data page of the initial record, the sequence number corresponding to the second data page is re-recorded, and the data in the second data page is re-read. If the record number of the second data page is consistent with the sequence number of the second data page of the initial record, the file access time is modified and the hardware transaction memory is closed.

[0191] 905: Modify file access time and disable hardware transactional memory.

[0192] It can be understood that in the embodiments of the present application, the serial number corresponding to the data will be recorded before the data is read. In the final submission stage, the hardware transaction memory will be called to obtain the current serial number corresponding to the data. When it is determined that the serial number of the current data is inconsistent with the serial number of the initially recorded data, the serial number and data of the data are re-read to ensure that the data finally read and the data written are consistent data, thereby ensuring the concurrent consistency of the read operation and the write operation.

[0193] The following is the user in the above Figure 1 Taking the reading operation in the word document in the example, the file processing method in the embodiment of the present application is explained. It includes: the file system first records the sequence number of the first data page, reads the data of the first data page, and then records the sequence number of the second data page, and reads the data of the second data page. After the data is read, the hardware transaction memory is called to determine whether the record number of the first data page is consistent with the sequence number of the first data page initially recorded. If not, the sequence number corresponding to the first data page is re-recorded, and the data in the first data page is re-read. If consistent, it is determined whether the record number of the second data page is consistent with the sequence number of the second data page initially recorded. If the record number of the second data page is inconsistent with the sequence number of the second data page initially recorded, the sequence number corresponding to the second data page is re-recorded, and the data in the second data page is re-read. If the record number of the second data page is consistent with the sequence number of the second data page initially recorded, the file access time is modified and the hardware transaction memory is closed.

[0194] In the above-mentioned file processing method provided by the embodiment of the present application, when it is determined that the updated data involved in the user's write operation occupies a large amount of memory, the file system obtains the operations required to submit the write operation, and only uses the visible write operations in the operations to execute using the hardware transaction memory. This can effectively reduce the number of operations in the hardware transaction memory and avoid the problem of transaction failure due to too many operations executed by the hardware memory.

[0195] Secondly, since the visible write operation is completed based on the hardware transactional memory, according to the characteristics of the hardware transactional memory execution operation, namely atomicity, consistency and isolation, the crash consistency and concurrency consistency of the data can be guaranteed when a system crash occurs.

[0196] It can be understood that in the embodiment of the present application, in terms of concurrent consistency, for example, when a concurrent process accesses shared data during data update, the hardware transaction memory will control the hardware transaction to fail, that is, the operation being executed fails, for example, the modification to the data is not saved. And the above transaction is re-executed. Therefore, if the transaction is successfully executed, it can be confirmed that there is no impact on other concurrent processes.

[0197] In the embodiment of the present application, when the hardware transaction repeatedly fails and reaches the upper limit of failure, an inode-level lock is used, that is, the file is completely locked to ensure the concurrent consistency of the read and write operations of the file data. And it can effectively avoid the problem of performance degradation caused by multiple failures of hardware transaction memory in high concurrency scenarios.

[0198] In the embodiment of the present application, when a transaction is committed, the to-be-allocated linked list in the atomic memory allocator will be directly released, thereby completing the permanent allocation of memory. When a transaction fails or the system crashes and restarts, the to-be-allocated linked list will be directly added to the head of the free linked list, that is, the memory page allocated to execute the transaction will be reclassified as an unallocated memory page, which can effectively avoid the occurrence of memory leaks caused by transaction failure, transaction failure, but memory is occupied

[0199] In an embodiment of the present application, the serial number corresponding to the data will be recorded before reading the data. In the final submission stage, the hardware transaction memory will be called to obtain the current serial number corresponding to the data. When it is determined that the serial number of the current data is inconsistent with the serial number of the initially recorded data, the serial number and data of the data are re-read, thereby effectively ensuring that the data finally read and the data written are consistent data, and ensuring the concurrent consistency of the read and write operations and the write operations.

[0200] In the embodiment of the present application, the file system may include a processor, and the processor is used to execute the above-mentioned file processing method.

[0201] An embodiment of the present application provides an electronic device, including the above-mentioned file system.

[0202] The embodiment of the present application also provides an electronic device, which includes: a memory for storing instructions executed by one or more processors of a leather case keyboard; a processor, which is one of the one or more processors of the electronic device, and is used to execute the above-mentioned file processing method.

[0203] The various embodiments disclosed in the present application may be implemented in hardware, software, firmware, or a combination of these implementation methods. The embodiments of the present application may be implemented as a computer program or program code executed on a programmable system, the programmable system including at least one processor, a storage system (including volatile and non-volatile memory and / or storage elements), at least one input device, and at least one output device.

[0204] Program code can be applied to input instructions to perform the functions described in this application and generate output information. The output information can be applied to one or more output devices in a known manner. For the purposes of this application, a processing system includes any system having a processor such as, for example, a digital signal processor (DSP), a microcontroller, an application specific integrated circuit (ASIC), or a microprocessor.

[0205] Program code can be implemented with high-level programming language or object-oriented programming language to communicate with the processing system. When necessary, program code can also be implemented with assembly language or machine language. In fact, the mechanism described in this application is not limited to the scope of any specific programming language. In either case, the language can be a compiled language or an interpreted language.

[0206] In some cases, the disclosed embodiments may be implemented in hardware, firmware, software, or any combination thereof. The disclosed embodiments may also be implemented as instructions carried or stored on one or more temporary or non-temporary machine-readable (e.g., computer-readable) storage media, which may be read and executed by one or more processors. For example, instructions may be distributed over a network or through other computer-readable media. Therefore, machine-readable media may include any mechanism for storing or transmitting information in a machine (e.g., computer) readable form, including, but not limited to, floppy disks, optical disks, optical disks, read-only memories (CD-ROMs), magneto-optical disks, read-only memories (ROMs), random access memories (RAMs), erasable programmable read-only memories (EPROMs), electrically erasable programmable read-only memories (EEPROMs), magnetic or optical cards, flash memory, or a tangible machine-readable memory for transmitting information (e.g., carrier waves, infrared signals, digital signals, etc.) using the Internet in electrical, optical, acoustic, or other forms of propagation signals. Therefore, machine-readable media include any type of machine-readable media suitable for storing or transmitting electronic instructions or information in a machine (e.g., computer) readable form.

[0207] In the accompanying drawings, some structural or method features may be shown in a specific arrangement and / or order. However, it should be understood that such a specific arrangement and / or order may not be required. Instead, in some embodiments, these features may be arranged in a manner and / or order different from that shown in the illustrative drawings. In addition, the inclusion of structural or method features in a particular figure does not mean that such features are required in all embodiments, and in some embodiments, these features may not be included or may be combined with other features.

[0208] It should be noted that the units / modules mentioned in the various device embodiments of the present application are all logical units / modules. Physically, a logical unit / module can be a physical unit / module, or a part of a physical unit / module, or can be implemented as a combination of multiple physical units / modules. The physical implementation method of these logical units / modules themselves is not the most important. The combination of functions implemented by these logical units / modules is the key to solving the technical problems proposed by the present application. In addition, in order to highlight the innovative part of the present application, the above-mentioned device embodiments of the present application do not introduce units / modules that are not closely related to solving the technical problems proposed by the present application, which does not mean that there are no other units / modules in the above-mentioned device embodiments.

[0209] It should be noted that in the examples and description of this patent, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "including one" do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0210] Although the present application has been illustrated and described with reference to certain preferred embodiments thereof, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the scope of the present application.

Claims

1. A file processing method, applied to a file system, characterized in that: include: Obtain update data generated by the user's write operation on file data; The file data includes data page data and metadata; In response to a user's request for saving the updated data, obtaining various operations required to execute the request for saving the updated data; the various operations include a first type of operation and a second type of operation, the first type of operation includes an update operation that can be observed through a file system interface, and the second type of operation includes a read operation and / or an update operation that cannot be observed through a file system interface; When the file data is data page data, the second type of operation is performed by a first execution mode, wherein when it is determined that the occupied memory required to execute the save request of the updated data is less than or equal to a set value, the first execution mode is a mode of calling hardware transaction memory; when it is determined that the occupied memory required to execute the save request of the updated data is greater than a set value, the second type of operation is performed by the first execution mode, including: writing the updated data into a shadow page by a shadow page technology; And after the second type of operation is executed, the first type of operation is executed through a second execution method, wherein the execution of the first type of operation through the second execution method includes: calling hardware transaction memory, replacing the data page with the shadow page, and changing the first sequence number corresponding to the data page to the second sequence number.

2. The file processing method according to claim 1, characterized in that: The performing of the first type of operation by the second execution mode further includes: Modify file access time and commit memory allocation information to the file system.

3. The file processing method according to claim 1, characterized in that: When the file data is metadata, the writing operation on the file data includes: writing operation on the storage location information of the file; When the file data is metadata, the second type of operation is performed by a third execution mode, Wherein, when it is determined that the occupied memory required to execute the request to save the updated data is less than or equal to the set value, the third execution mode is to call the hardware transaction memory mode; when it is determined that the occupied memory required to execute the request to save the updated data is greater than the set value, executing the second type of operation through the third execution mode includes: reading the original storage location information and the target storage location information of the file; After the second type of operation is executed, the first type of operation is executed by a fourth execution mode, wherein the first type of operation is executed by the fourth execution mode, including: The hardware transaction memory is called to replace the file data with the update data, and the slot sequence number and directory entry sequence number corresponding to the file are modified.

4. The file processing method according to any one of claims 1 to 3, characterized in that: Also includes: When a concurrent process accesses the file data during the execution of the second type of operation, the execution of the second type of operation is controlled to fail.

5. The file processing method according to claim 4, characterized in that: When the number of failed executions of the second type of operation reaches a set number, the file corresponding to the file data is locked.

6. The file processing method according to claim 1, characterized in that: Also includes: Record the initial sequence number of the data to be read; Reading the data to be read; Calling the hardware transaction memory to obtain the current sequence number of the data to be read; When the current sequence number of the data to be read is consistent with the initial sequence number, the access time of the file is modified, and the hardware transaction memory is closed.

7. The file processing method according to claim 6, characterized in that: When the current sequence number of the data to be read is inconsistent with the initial sequence number, the current sequence number of the data to be read is recorded, and the data to be read is read.

8. A file system, characterized in that: The invention comprises a processor, wherein the processor is used to execute the file processing method according to any one of claims 1 to 7.

9. The file system according to claim 8, characterized in that: It also includes kernel file system and user-mode file system libraries; The user-mode file system library includes at least one atomic memory allocator, and the kernel file system includes a kernel memory allocator; The atomic memory allocator is used to allocate free pages required for writing operations to files; The atomic memory allocator is also used to send a memory allocation request to the kernel memory allocator; The kernel memory allocator is used to allocate corresponding memory to the atomic memory allocator according to the memory allocation request.

10. The file system according to claim 9, characterized in that: The atomic memory allocator includes a free page linked list and a to-be-allocated linked list, the free page linked list includes an unallocated pointer area and an allocated pointer area, the unallocated pointer area includes at least one unallocated pointer, and the allocated pointer area includes at least one allocated pointer; When the user performs a write operation on the file data, the atomic memory allocator selects a preset pointer required for the write operation on the file data from the unallocated pointer area; The atomic memory allocator adds the preset pointer to a linked list to be allocated; When the second type of operation is completed, the atomic memory allocator allocates the preset pointer to the file corresponding to the file data.

11. The file system according to claim 10, characterized in that: When the second type of operation fails to be executed, the atomic memory allocator allocates the preset pointer to an unallocated area of ​​the free page linked list.

12. The file system according to any one of claims 8 to 11, characterized in that: It also includes a file entry, wherein the file entry includes a plurality of data pages, and each of the data pages has a corresponding sequence number.

13. The file system according to any one of claims 8 to 11, characterized in that: Also included is a directory, the directory including at least one slot, each slot having a corresponding pointer and a corresponding slot sequence number; Each slot of the at least one slot includes at least one directory entry, and each directory entry of the at least one directory entry has a corresponding directory entry sequence number.

14. An electronic device, characterized in that: A file system comprising any one of claims 8 to 13.

15. An electronic device, characterized in that: include: a memory for storing instructions to be executed by one or more processors of the leather case keyboard; The processor is one of the one or more processors of the electronic device, and is used to execute the file processing method described in any one of claims 1 to 7.

16. A readable medium, characterized in that The readable medium stores instructions, which, when executed on an electronic device, enable the machine to execute the file processing method according to any one of claims 1 to 7.

17. A computer program product, characterized in that The method comprises instructions for executing the file processing method according to any one of claims 1 to 7.