File reading and writing method and device, electronic equipment and storage medium

By mounting the server to the lower level of the file system and modifying files at the upper level, the high power consumption and resource consumption problems of mobile terminals when modifying remotely stored files are solved, and efficient file reading and writing are achieved.

CN118535075BActive Publication Date: 2025-11-07HUAWEI TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310188218.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-21
Publication Date
2025-11-07
Estimated Expiration
2043-02-21

AI Technical Summary

Technical Problem

When a mobile terminal's file system modifies remotely stored files, it causes a large amount of disk I/O and network access, which seriously affects power consumption and resources.

Method used

Mounting the server to the lower level of the file system, with lower priority than the upper level, reduces the transmission overhead between the terminal and the server by copying and modifying the parts of the file to be modified to the upper file system, and merges the modified content to reduce the need for multiple synchronizations.

Benefits of technology

It reduces the storage footprint and network access of mobile terminals, improves file read and write efficiency, and reduces power consumption and resource consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118535075B_ABST
    Figure CN118535075B_ABST
Patent Text Reader

Abstract

The application provides a file reading and writing method and device, electronic equipment and a storage medium. The method comprises the following steps: when a target file on a server is modified through a lower layer of a file system, copying a to-be-modified segment of the target file to an upper layer of the file system; and modifying the to-be-modified segment of the target file and saving the to-be-modified segment in the upper layer of the file system. The method provided by the application can improve the efficiency of file reading and writing.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of communication, and in particular to a file reading and writing method and device, an electronic device, and a storage medium. BACKGROUND

[0002] With more and more applications and larger and larger files, the storage space of mobile terminals such as mobile phones is facing great challenges. Currently, the common practice is to migrate files in mobile terminals such as mobile phones to servers.

[0003] Access to any file by an application on a mobile terminal based on a Linux operating system ultimately converges to operations at the file system level of the operating system. If the access mode to the server is encapsulated into a local file system, and then a fusion view file system is used to fuse the local file system and the encapsulated remote storage file system, the storage space of the mobile terminal can be expanded.

[0004] However, when an application modifies a file in remote storage, a large amount of disk input and output and network access are generated, which seriously affects the power consumption and resources of the mobile terminal. SUMMARY

[0005] The present application provides a file reading and writing method and device, an electronic device, and a storage medium, which helps to improve the efficiency of file reading and writing.

[0006] In a first aspect, the present application provides a file reading and writing method, applied to an electronic device, wherein the electronic device mounts a server to a lower layer of a file system, the access priority of the lower layer of the file system is lower than that of an upper layer of the file system, and the method comprises:

[0007] When a target file on the server is modified through the lower layer of the file system, copying a to-be-modified segment of the target file to the upper layer of the file system;

[0008] Modifying the to-be-modified segment of the target file and saving it in the upper layer of the file system.

[0009] In the present application, by mounting remote storage to the lower layer of the file system in advance, when a file in remote storage is modified, the lower layer file can be copied to the upper layer, thereby reducing the transmission overhead between the terminal and the server.

[0010] In one possible implementation, the target file on the server is an application file with a low user access frequency.

[0011] In the present application, by migrating application data to the server, the storage occupation of the terminal by the application data can be reduced. In addition, by migrating only the application data that is not frequently accessed by the user and storing the frequently used data locally, the efficiency problem caused by the access to the frequently used data can be avoided.

[0012] In one possible implementation, the method further includes:

[0013] determining whether the target file is stored in the upper layer of the file system;

[0014] if it is determined that the target file is stored in the upper layer of the file system, modifying the target file in the upper layer of the file system.

[0015] In one possible implementation, after the modification of the to-be-modified segment of the target file, the method further includes:

[0016] generating a modification log based on the modified content.

[0017] In one possible implementation, the method further includes:

[0018] synchronizing the modified content to the lower layer of the file system based on the modification log.

[0019] In one possible implementation, the modification log includes merged modification content, and the merged modification content is modification content obtained by merging modification content of different positions in the same target file.

[0020] The merged modification content is the last modification content in multiple modification contents of the same position in the same target file.

[0021] In the present application, by merging the modification content, the efficiency reduction caused by multiple modifications can be avoided.

[0022] In one possible implementation, the method further includes:

[0023] when the target file is deleted, discarding the unsynchronized modification log corresponding to the target file.

[0024] In the present application, after the target file is deleted, the corresponding modification log is discarded, so that the storage occupation of the terminal can be reduced.

[0025] In a second aspect, the present application provides a file reading and writing apparatus, which includes one or more functional modules, and the one or more functional modules are configured to implement the file reading and writing method according to the first aspect.

[0026] In a third aspect, the present application provides an electronic device, comprising: a processor and a memory, the memory being configured to store a computer program; and the processor being configured to run the computer program to implement the file reading and writing method according to the first aspect.

[0027] In a fourth aspect, the present application provides a computer readable storage medium, which stores a computer program, and when the computer program is run on a computer, the computer is caused to implement the file reading and writing method according to the first aspect.

[0028] In a fifth aspect, the present application provides a computer program, which, when run on a processor of an electronic device, causes the electronic device to perform the file reading and writing method according to the first aspect.

[0029] In a possible design, the program in the fifth aspect can be stored, in whole or in part, on a storage medium packaged together with the processor, or stored, in part or in whole, on a memory not packaged together with the processor. BRIEF DESCRIPTION OF DRAWINGS

[0030] Figure 1 a system architecture diagram provided by an embodiment of the present application;

[0031] Figure 2 an application scenario diagram provided by an embodiment of the present application;

[0032] Figure 3 a flowchart of an embodiment of the file reading and writing method provided by the present application;

[0033] Figure 4 a flowchart of another embodiment of the file reading and writing method provided by the present application;

[0034] Figure 5 a flowchart of another embodiment of the file reading and writing method provided by the present application;

[0035] Figure 6 a flowchart of another embodiment of the file reading and writing method provided by the present application;

[0036] Figure 7 a flowchart of another embodiment of the file reading and writing method provided by the present application;

[0037] Figure 8 a flowchart of another embodiment of the file reading and writing method provided by the present application;

[0038] Figure 9 a flowchart of another embodiment of the file reading and writing method provided by the present application;

[0039] Figure 10A structural schematic diagram of a file reading and writing device provided in an embodiment of the present application is shown in FIG. 1.

[0040] Figure 11 A structural schematic diagram of an electronic device provided in an embodiment of the present application is shown in FIG. 1. DETAILED DESCRIPTION

[0041] In the embodiments of the present application, unless otherwise specified, the character " / " represents a relationship of one or the other between the associated objects before and after. For example, A / B can represent A or B. The "and / or" describes the relationship between the associated objects, which means that there can be three relationships. For example, A and / or B can represent three cases: A exists alone, A and B exist together, and B exists alone.

[0042] It should be noted that the "first", "second", and the like in the embodiments of the present application are only used for distinguishing purposes of description, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features, nor can it be understood as indicating or implying the order.

[0043] In the embodiments of the present application, "at least one" means one or more, and "multiple" means two or more. In addition, "at least one of the following" or the like means any combination of these items, which can include any combination of single item or multiple items. For example, at least one of A, B or C can represent A, B, C, A and B, A and C, B and C, or A, B and C. Wherein, each of A, B and C can be an element or a set containing one or more elements.

[0044] In the embodiments of the present application, "example", "in some embodiments", "in another embodiment" and the like are used to represent as an example, illustration or description. Any embodiment or design scheme described as "example" in the present application should not be interpreted as more preferred or more advantageous than other embodiments or design schemes. Rather, the word "example" is intended to present the concept in a specific way.

[0045] In the embodiments of the present application, "of", "corresponding" and "corresponding" can be mixed sometimes, and it should be pointed out that the meanings to be expressed are consistent when the distinction is not emphasized. In the embodiments of the present application, communication and transmission can be mixed sometimes, and it should be pointed out that the meanings to be expressed are consistent when the distinction is not emphasized. For example, transmission can include sending and / or receiving, and can be a noun or a verb.

[0046] Equal to can be used with greater than in the embodiments of the present application, which is applicable to the technical solutions adopted when greater than. Equal to can also be used with less than, which is applicable to the technical solutions adopted when less than. It should be noted that when equal to is used with greater than, it cannot be used with less than; when equal to is used with less than, it cannot be used with greater than.

[0047] In the application of modifying the remotely stored file, if the lower layer of the file system contains the file to be modified, the mobile terminal will copy the file in the lower layer of the file system to the upper layer of the file system in full, then modify the copy in the upper layer of the file system as the target file, and finally synchronize the modified file to the lower layer of the file system, thereby causing the file to be copied back and forth between the lower layer and the upper layer of the file system, generating a large amount of disk input and output and network access, and seriously affecting the power consumption and resources of the mobile terminal.

[0048] Based on the above problems, the embodiments of the present application propose a file read-write method, which is applied to a mobile terminal, such as a mobile phone, a tablet, etc. The mobile terminal can also be referred to as a user equipment (UE), an access terminal, a user unit, a user station, a mobile station, a mobile station, a remote station, a remote terminal, a mobile device, a user terminal, a terminal, a wireless communication device, a user agent or a user device. The mobile terminal can be a station (STATION, ST) in WLAN, which can be a cellular phone, a cordless phone, a Session Initiation Protocol (SIP) phone, a Wireless Local Loop (WLL) station, a Personal Digital Assistant (PDA) device, a handheld device with wireless communication function, a computing device or other processing device connected to a wireless modem, a vehicle-mounted device, a vehicle networking terminal, a computer, a laptop, a handheld communication device, a handheld computing device, a satellite wireless device, a wireless modem card, a television set top box (STB), a customer premise equipment (CPE), and / or other devices for communicating on a wireless system, and a next-generation communication system, such as a mobile terminal in a 5G network or a mobile terminal in a future evolved Public Land Mobile Network (PLMN) network, etc. The mobile terminal can also be a wearable device. The wearable device can also be referred to as a wearable smart device, which is a general term for devices that apply wearable technology to the intelligent design and development of daily wear, such as glasses, gloves, watches, clothing and shoes, etc.

[0049] Now, the embodiments of the present application will be described in detail with reference to the accompanying drawings. Figures 1-9The file reading and writing method provided by the embodiment of the present application is described.

[0050] Figure 1 A system architecture diagram of a storage file system provided by the embodiment of the present application is shown in FIG. 1. Figure 1 As shown in the figure, the system architecture of the storage file system takes the Linux operating system as an example. It can be understood that the above example does not limit the application range of the embodiment of the present application. In some embodiments, the embodiment of the present application can also be applied to other types of operating systems. Referring to FIG. 2, Figure 1 The storage file system can include a Linux user state, a Linux kernel state, and hardware.

[0051] The Linux user state can include a LIBC library, which can be used to provide a basic file operation interface for user state applications.

[0052] The Linux kernel state can include a virtual file system (VFS), a fusion file system, and device management and driving. The virtual file system can be used to shield the differences between lower layer file systems and provide a unified file operation interface for upper layer file systems. The fusion file system is used to fuse multiple file systems (such as ext4 file system, f2fs file system, etc.) in the lower layer to provide a fusion directory view for applications, so that the application can be unaware of the change of the storage path of the file when reading and writing the file. Device management and driving are used to provide driving for accessing local storage and network storage.

[0053] The hardware can include local hardware and network storage. The local hardware can include a disk, a memory card, etc., and the network storage can include cloud storage, a network disk, etc.

[0054] Figure 2 An application architecture diagram provided by the embodiment of the present application is shown in FIG. 3. Figure 2The application architecture can include the mobile terminal 20 and the server 21. It can be understood that the server 21 can be a local server or a network server, and the type of the server 21 is not specially limited in the embodiments of the present application. The mobile terminal 20 can first migrate the data file of the application to the server 21, and then can specify the mounted directory of the remote storage as the lower layer of the file system, which can also be referred to as a lower layer file system. For example, the lower layer file system can be an NFS, and the mounted directory of the local storage is the upper layer of the file system, for example, the upper layer file system can be an f2fs. Thus, the application can be made to be unaware of the change of the storage path of the file when reading and writing the file. The access priority of the lower layer file system is lower than that of the upper layer file system. It can be understood that the migrated data can be the application data that is not frequently accessed by the user. The application data that is not frequently accessed by the user can be the application data with a low user access frequency. For example, the application data with a low user access frequency can be the application data with a user access frequency lower than a preset frequency threshold. Thus, the number of accesses to the server 21 can be reduced, and the data access efficiency can be improved.

[0055] As shown in FIG. 1, the application provides a file reading and writing method. Figure 3 FIG. 2 shows a flowchart of an embodiment of the file reading and writing method provided by the present application. In the embodiments of the present application, the application file that is not frequently accessed by the user can be migrated to the server, and the application file that is not frequently accessed by the user can be deleted in the mobile terminal after migration. Thus, the storage space of the mobile terminal can be saved. The method includes the following steps.

[0056] In step 301, the mobile terminal copies the application file to the server.

[0057] Specifically, the copied application file can be a part of the application that is not frequently accessed. That is, the frequently accessed application file in the mobile terminal is not migrated. Thus, the mobile terminal can directly obtain the frequently accessed application file from the local terminal, without obtaining the application file from the server. Thus, the access efficiency can be improved. The application file that is not frequently accessed can be migrated to the server. Thus, the storage space of the mobile terminal can be saved.

[0058] In step 302, the server starts a sharing service to share the migrated application file.

[0059] Specifically, the server can start the sharing service by using an NFS server.

[0060] In step 303, the mobile terminal mounts a remote storage directory.

[0061] Specifically, the mobile terminal can mount the remote storage directory shared by the server by using an NFS client. Thus, the remote access can be realized.

[0062] Step 304, the mobile terminal fuses and mounts the directory stored locally and the directory stored remotely.

[0063] Step 305, the mobile terminal deletes the migrated application file.

[0064] The above describes the migration of the application file by way of example. Figure 3 The following describes the reading and writing of the application file by way of example. Figure 4 The following describes the reading and writing of the application file by way of example.

[0065] Figure 4 A flowchart of another embodiment of the file reading and writing method provided by the present application can include the following steps:

[0066] Step 401, an application in the mobile terminal reads a target file.

[0067] Step 402, the mobile terminal determines whether the storage location of the target file is in the upper layer of the file system.

[0068] Specifically, when the application in the mobile terminal wants to read the target file, the storage location of the target file can be determined first. Since the commonly used files are usually stored in the upper layer of the file system, it can be determined first whether the storage location of the target file is in the upper layer of the file system.

[0069] If the mobile terminal determines that the target file is stored in the upper layer of the file system, step 403 can be further performed.

[0070] If the mobile terminal determines that the target file is not stored in the upper layer of the file system, step 404 can be further performed.

[0071] Step 403, the mobile terminal reads the target file in the upper layer file system.

[0072] Specifically, after the mobile terminal determines that the target file is stored in the upper layer of the file system, the target file can be read in the upper layer file system. After the target file is read, step 407 can be further performed.

[0073] Step 404, the mobile terminal determines whether the storage location of the target file is in the lower layer of the file system.

[0074] Specifically, if the mobile terminal determines that the target file is stored in the lower layer of the file system, step 405 can be further performed.

[0075] If the mobile terminal determines that the target file is not stored in the lower layer of the file system, a file does not exist error can be returned, and the present access can be ended.

[0076] Step 405, the mobile terminal reads the target file in the lower layer file system.

[0077] Step 406, the lower layer file system remotely acquires the target file from the NFS server.

[0078] Step 407, the mobile terminal returns the read target file to the application.

[0079] The above is an exemplary description of the reading of the application file, and the following is an exemplary description of the modification of the application file. Figure 4 The above is an exemplary description of the reading of the application file, and the following is an exemplary description of the modification of the application file. Figure 5 The above is an exemplary description of the reading of the application file, and the following is an exemplary description of the modification of the application file.

[0080] Figure 5 The above is an exemplary description of the reading of the application file, and the following is an exemplary description of the modification of the application file.

[0081] Step 501, the application in the mobile terminal modifies the target file.

[0082] Step 502, the mobile terminal judges whether the storage position of the target file is in the upper layer of the file system.

[0083] Specifically, when the application in the mobile terminal wants to modify the target file, the storage position of the target file can be determined first. Since the commonly used files are usually stored in the upper layer of the file system, it can be first judged whether the storage position of the target file is in the upper layer of the file system.

[0084] If the mobile terminal judges that the target file is stored in the upper layer of the file system, step 503 can be further executed.

[0085] If the mobile terminal judges that the target file is not stored in the upper layer of the file system, step 504 can be further executed.

[0086] Step 503, the mobile terminal modifies the target file in the upper layer file system.

[0087] Specifically, after the mobile terminal determines that the target file is stored in the upper layer of the file system, the target file can be modified in the upper layer file system, and after the target file is modified, step 507 can be further executed.

[0088] Step 504, the mobile terminal judges whether the storage position of the target file is in the lower layer of the file system.

[0089] Specifically, if the mobile terminal judges that the target file is stored in the lower layer of the file system, step 505 can be further executed.

[0090] If the mobile terminal judges that the target file is not stored in the lower layer of the file system, a file does not exist error can be returned, and the modification can be ended.

[0091] At step 505, the mobile terminal saves the modified content to the upper layer of the file system.

[0092] Specifically, when the mobile terminal determines that the target file storage location is in the lower layer of the file system, the mobile terminal can copy the to-be-modified segment of the target file to the upper layer of the file system in the lower layer of the file system, for example, by remotely copying the to-be-modified segment of the target file to the upper layer of the file system in the server, so that the mobile terminal does not need to copy the entire target file, thereby saving the transmission overhead between the mobile terminal and the server.

[0093] After the mobile terminal copies the to-be-modified segment of the target file to the upper layer of the file system, the mobile terminal can modify the to-be-modified segment of the target file and save the modified content in the upper layer of the file system.

[0094] At step 506, the mobile terminal generates a modification log.

[0095] Specifically, after the mobile terminal modifies the target file, the mobile terminal can generate a corresponding modification log, where the modification log can include the modified content.

[0096] At step 507, the mobile terminal returns the modification result to the application.

[0097] In some optional embodiments, the mobile terminal can also synchronize the modified content in the upper layer of the file system to the lower layer of the file system, thereby avoiding the need for an additional service to remotely synchronize the modified content in the prior art. In the embodiments of the present application, the conditions for triggering synchronization can be configured as follows:

[0098] For example, if the total size of the modified content generated by the upper layer of the file system reaches a preset threshold, synchronization can be triggered; or

[0099] If the modified content in the upper layer of the file system is not synchronized within a preset time period, synchronization can be triggered; or

[0100] If the current access operation depends on the last modification, but the modification has not been synchronized, synchronization can be triggered; or

[0101] When the fusion file system is uninstalled, if there is modified content that has not been synchronized, synchronization can be triggered.

[0102] In some optional embodiments, in order to reduce the number of requests for the lower layer of the file system and improve efficiency, the content of the log can also be merged.

[0103] For example, when different positions of the same file are modified, the modified contents can be merged, and a modification log can be generated once, thereby avoiding multiple modification logs caused by multiple modifications, and further avoiding multiple synchronizations of the lower file of the file system caused by multiple modification logs; or

[0104] When a file is deleted, the unsynchronized modification log of the file can be discarded, and the unsynchronized modification log does not need to be synchronized again; or

[0105] When the same position of the same file is modified multiple times, the last modified content can be retained, and a modification log can be generated according to the last modified content.

[0106] Now, combined with Figures 6-9 , the synchronization of the modified content is exemplarily described through different application scenarios.

[0107] Figure 6 For another embodiment of the file reading and writing method provided in the present application, the flowchart can specifically include the following steps:

[0108] Step 601, an application in the mobile terminal reads and writes the lower file of the file system.

[0109] Step 602, the mobile terminal determines whether the content read and written this time has unsynchronized dependent content in the upper layer of the file system.

[0110] Specifically, if the mobile terminal determines that the content read and written this time has unsynchronized dependent content in the upper layer of the file system, step 603 can be further executed.

[0111] If the mobile terminal determines that the content read and written this time has no unsynchronized dependent content in the upper layer of the file system, the present flowchart can be ended.

[0112] Step 603, the mobile terminal merges the modified content in the upper layer of the file system.

[0113] Specifically, the manner in which the mobile terminal merges the modified content in the upper layer of the file system can refer to the related description in the above embodiments, which will not be described here again.

[0114] Step 604, the mobile terminal synchronizes the merged modified content to the lower layer of the file system.

[0115] Figure 7 For another embodiment of the file reading and writing method provided in the present application, the flowchart can specifically include the following steps:

[0116] Step 701, an application in the mobile terminal modifies the lower file of the file system.

[0117] At step 702, the mobile terminal saves the modified content in the upper layer of the file system and generates a modification log.

[0118] At step 703, the mobile terminal determines whether the total size of the modified content has reached a preset threshold.

[0119] Specifically, if the mobile terminal determines that the total size of the modified content has reached the preset threshold, step 704 can be further performed.

[0120] If the mobile terminal determines that the total size of the modified content has not reached the preset threshold, the current procedure can be ended.

[0121] At step 704, the mobile terminal merges the modified content in the upper layer of the file system.

[0122] Specifically, the manner in which the mobile terminal merges the modified content in the upper layer of the file system can refer to the related description in the above embodiments, and will not be described here again.

[0123] At step 705, the mobile terminal synchronizes the merged modified content to the lower layer of the file system.

[0124] Figure 8 A flowchart of another embodiment of the file reading and writing method provided in the present application can specifically include the following steps:

[0125] At step 801, a periodic timer is started.

[0126] At step 802, the mobile terminal determines whether there is modified content that has not been synchronized within the timer duration.

[0127] Specifically, if the mobile terminal determines that there is modified content that has not been synchronized within the timer duration, step 803 can be further performed.

[0128] If the mobile terminal determines that there is no modified content that has not been synchronized within the timer duration, the current procedure can be ended.

[0129] At step 803, the mobile terminal merges the modified content in the upper layer of the file system.

[0130] Specifically, the manner in which the mobile terminal merges the modified content in the upper layer of the file system can refer to the related description in the above embodiments, and will not be described here again.

[0131] At step 804, the mobile terminal synchronizes the merged modified content to the lower layer of the file system.

[0132] Figure 9 A flowchart of another embodiment of the file reading and writing method provided in the present application can specifically include the following steps:

[0133] Step 901, offload the fusion file system.

[0134] Step 902, the mobile terminal determines whether there is unsynchronized modification content.

[0135] Specifically, if the mobile terminal determines that there is unsynchronized modification content, step 903 can be further executed.

[0136] If the mobile terminal determines that there is no unsynchronized modification content, the current process can be ended.

[0137] Step 903, the mobile terminal merges the modification content in the upper layer of the file system.

[0138] Specifically, the mobile terminal merges the modification content in the upper layer of the file system in the manner described in the above embodiments, which will not be repeated here.

[0139] Step 904, the mobile terminal synchronizes the merged modification content to the lower layer of the file system.

[0140] Figure 10 An embodiment of the structure of the file reading and writing device of the present application is shown in the figure Figure 10 The file reading and writing device 1000 described above is applied to an electronic device, the electronic device mounts a server to the lower layer of a file system, the access priority of the lower layer of the file system is lower than that of the upper layer of the file system, and the file reading and writing device 1000 can include a copying module 1010 and a modification module 1020; wherein

[0141] The copying module 1010 is configured to copy a segment to be modified of a target file on the server to the upper layer of the file system when the target file is modified through the lower layer of the file system.

[0142] The modification module 1020 is configured to modify the segment to be modified of the target file and save it in the upper layer of the file system.

[0143] In one possible implementation, the target file on the server is an application file with low user usage frequency.

[0144] In one possible implementation, the modification module 1020 is further configured to determine whether the target file is stored in the upper layer of the file system.

[0145] If it is determined that the target file is stored in the upper layer of the file system, the target file is modified in the upper layer of the file system.

[0146] In one possible implementation, the file reading and writing device 1000 further includes:

[0147] generating a modification log based on the modified content.

[0148] In one possible implementation, the file reading and writing apparatus 1000 further includes:

[0149] a synchronizing module configured to synchronize the modified content to a lower layer of the file system based on the modification log.

[0150] In one possible implementation, the modification log includes merged modified content, the merged modified content being modified content after merging of modified content of different positions in a same target file; or

[0151] the merged modified content being the last modified content in multiple modified contents of a same position in a same target file.

[0152] In one possible implementation, the file reading and writing apparatus 1000 further includes:

[0153] a discarding module configured to discard the unsynchronized modification log corresponding to the target file when the target file is deleted.

[0154] Figure 10 The file reading and writing apparatus 1000 provided by the embodiments can be used to execute the technical solutions of the method embodiments, and the implementation principles and technical effects can be further referred to the related descriptions in the method embodiments.

[0155] It should be understood that the above Figure 10 The division of each module of the file reading and writing apparatus 1000 is only a logical functional division, and all or part of the modules can be integrated into one physical entity, or can be physically separated. The modules can all be implemented in the form of software through a processing element, or all be implemented in the form of hardware, or part of the modules be implemented in the form of software through a processing element and part of the modules be implemented in the form of hardware. For example, the detecting module can be a separately established processing element, or can be implemented in a certain chip of the electronic device. The implementation of other modules is similar. In addition, all or part of the modules can be integrated together, or can be independently implemented. In the implementation process, each step of the above method or each module can be completed by integrated logic circuits of hardware in the processing element or instructions in the form of software.

[0156] For example, the above modules can be one or more integrated circuits configured to implement the above methods, such as one or more Application Specific Integrated Circuits (ASICs), or one or more Digital Signal Processors (DSPs), or one or more Field Programmable Gate Arrays (FPGAs), etc. For another example, the modules can be integrated together in the form of a System-On-a-Chip (SOC).

[0157] The above Figure 11 Further, the electronic device provided in the embodiments of the present application is introduced. Figure 11 A structural diagram of the electronic device 1100 is shown.

[0158] The electronic device 1100 described above can include at least one processor and at least one memory connected in communication with the processor, wherein the memory stores program instructions executable by the processor, and the processor calling the program instructions can execute the method of the present application Figures 1-9 The method provided in the embodiments shown.

[0159] Figure 11 A block diagram of an exemplary electronic device 1100 suitable for implementing the embodiments of the present application is shown. Figure 11 The electronic device 1100 shown is only an example, and should not bring any limitation to the functions and use range of the embodiments of the present application.

[0160] As Figure 11 The electronic device 1100 is shown in the form of a general computing device. The components of the electronic device 1100 can include, but are not limited to, one or more processors 1110, a memory 1120, a communication bus 1140 connecting different system components including the memory 1120 and the processor 1110, and a communication interface 1130.

[0161] Communication bus 1140 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration bus, a processor or local bus using any of a variety of bus architectures. By way of example, these architectures include Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MCA) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.

[0162] Electronic device 1100 typically includes a variety of computer system readable media. Such media can be any available media that is accessible by electronic device, and includes both volatile and non-volatile media, removable and non-removable media.

[0163] Memory 1120 can include computer system readable media in the form of volatile memory, such as random access memory (RAM) and / or cache memory. Electronic device can further include other removable / non-removable, volatile / non-volatile computer system storage media. Although Figure 11 Although not shown in FIG. 11, computer system can also include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, FIG. 12 illustrates a disk drive 1251 that can read from and write to a non-removable, non-volatile media such as a read only compact disc (CD-ROM) 1252, read / write CD- ROM, DVD-ROM, or other optical media 1253, or a removable mass storage medium such as flash memory or other removable media 1254. It should be noted that the disk drive 1251 and its associated computer-readable media can provide a storage mechanism for the electronic device. Disk drive 1251 and its associated computer-readable media provide a storage mechanism for the electronic device. These examples provide some of possible

[0164] The program / utility, having a set of program modules, can be stored in memory 1120, for execution by the operating system, the one or more application programs, other program modules, and program data, each or any combination thereof, can include implementation of the network environment. The program modules typically carry out the functions and / or methodologies of embodiments of the present application.

[0165] The electronic device 1100 can also communicate with one or more external devices such as a keyboard or pointing device, a display 1112, etc. through a communication interface 1130. Additionally, the electronic device 1100 can communicate with one or more devices such as a printer, a scanner, a Figure 11 The electronic device 1100 can also communicate with one or more networks, such as a local area network (LAN), a wide area network (WAN), and / or the Internet through a network adapter (not shown in FIG. 11). It should be appreciated that the network adapter can also be used to enable connection to other types of networks and / or remote servers (not shown in FIG. 11) through a communication interface 1130. Moreover, the electronic device 1100 can also be connected to one or more devices remotely (e.g., through the Internet) through a communication interface 1130. Figure 11 It should be appreciated that the electronic device 1100 can also employ other hardware and / or software modules that can or can not be illustrated in FIG. 11, including but not limited to microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data archival storage systems, etc.

[0166] The processor 1110 performs various function applications and data processing by running programs stored in the memory 1120, such as implementing the method provided by the embodiments of the present application.

[0167] It should be appreciated that the interface connection relationship between the modules illustrated in the embodiments of the present application is only illustrative, and does not constitute a structural limitation of the electronic device 1100. In other embodiments of the present application, the electronic device 1100 can also use different interface connection manners in the above embodiments, or a combination of multiple interface connection manners.

[0168] In the above embodiments, the processor can include a CPU, a DSP, a microcontroller, or a digital signal processor, and can further include a GPU, an embedded neural network processing unit (NPU), and an image signal processor (ISP). The processor can further include necessary hardware accelerators or logic processing hardware circuits, such as an ASIC, or one or more integrated circuits for controlling the execution of the program of the technical solution of the present application. In addition, the processor can have the function of operating one or more software programs, and the software programs can be stored in a storage medium.

[0169] The embodiment of the present application further provides a computer readable storage medium, which stores a computer program, and when the computer program is run on a computer, the computer is enabled to execute the method provided by the embodiment of the present application.

[0170] The embodiment of the present application further provides a computer program product, which includes a computer program, and when the computer program is run on a computer, the computer is enabled to execute the method provided by the embodiment of the present application.

[0171] In the embodiment of the present application, "at least one" means one or more, and "multiple" means two or more. The "and / or" describes the association relationship of the associated objects, which means that there can be three relationships, for example, A and / or B, which means that A exists alone, A and B exist together, and B exists alone. Wherein A and B can be singular or plural. The character " / " generally represents that the associated objects before and after it are in an "or" relationship. "At least one of the following" and the like means any combination of these items, including any combination of single or multiple items. For example, at least one of a, b and c can mean: a, b, c, a and b, a and c, b and c, or a and b and c, wherein a, b, and c can be single or multiple.

[0172] Those of ordinary skill in the art can realize that the units and algorithm steps described in the embodiments disclosed herein can be realized by electronic hardware, computer software and a combination of electronic hardware and computer software. Whether the functions are realized in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.

[0173] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described system, device and unit can refer to the corresponding process in the foregoing method embodiments, which will not be described here.

[0174] In several embodiments provided in the present application, any function, if realized in the form of a software function unit and sold or used as an independent product, can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application, essentially or in part, or parts of the technical solutions that make contributions to the prior art, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including a number of instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (Read-Only Memory; hereinafter referred to as: ROM), a random access memory (Random Access Memory; hereinafter referred to as: RAM), a magnetic disk or an optical disk, and various media that can store program codes.

[0175] The above description is merely a specific implementation of the present application. Any person skilled in the art can easily think of changes or replacements within the technical scope disclosed in the present application, which should be covered within the protection scope of the present application. The protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A file read-write method, characterized by, The method is applied to an electronic device, the electronic device mounts a server to a lower layer of a file system, an access priority of the lower layer of the file system is lower than an access priority of an upper layer of the file system, and the method comprises the following steps: copying a segment to be modified of a target file on the server to the upper layer of the file system when the target file is modified through the lower layer of the file system; modifying the segment to be modified of the target file and saving in the upper layer of the file system.

2. The method of claim 1, wherein, The target file on the server is an application file with a low user access frequency.

3. The method of claim 1, wherein, The method further comprises the following steps: judging whether the target file is stored in the upper layer of the file system; if it is judged that the target file is stored in the upper layer of the file system, modifying the target file in the upper layer of the file system.

4. The method of claim 1, wherein, After the segment to be modified of the target file is modified, the method further comprises the following steps: generating a modification log based on the modified content.

5. The method of claim 4, wherein, The method further comprises the following steps: synchronizing the modified content to the lower layer of the file system based on the modification log.

6. The method according to claim 4 or 5, characterized in that, The modification log comprises merged modification content, the merged modification content is modification content after merging modification content of different positions in a same target file; or the merged modification content is last modification content in multiple modification contents of a same position in a same target file.

7. The method according to claim 4 or 5, characterized in that, The method further comprises the following steps: when the target file is deleted, discarding unsynchronized modification logs corresponding to the target file.

8. A file read-write device, characterized by comprising: The device is applied to an electronic device, the electronic device mounts a server to a lower layer of a file system, an access priority of the lower layer of the file system is lower than an access priority of an upper layer of the file system, and the device comprises the following steps: a copying module, used for copying a segment to be modified of a target file on the server to the upper layer of the file system when the target file is modified through the lower layer of the file system; a modifying module, used for modifying the segment to be modified of the target file and saving in the upper layer of the file system.

9. The apparatus of claim 8, wherein, The target file on the server is an application file with a low user access frequency.

10. The apparatus of claim 8, wherein, The modifying module is further used for judging whether the target file is stored in the upper layer of the file system; if it is judged that the target file is stored in the upper layer of the file system, modifying the target file in the upper layer of the file system.

11. The apparatus of claim 8, wherein, The device further comprises the following steps: a generating module, used for generating a modification log based on the modified content.

12. The apparatus of claim 11, wherein, The device further comprises the following steps: a synchronizing module, used for synchronizing the modified content to the lower layer of the file system based on the modification log.

13. The apparatus of claim 11 or 12, wherein, The modification log comprises merged modification content, the merged modification content is modification content after merging modification content of different positions in a same target file; or the merged modification content is last modification content in multiple modification contents of a same position in a same target file.

14. The apparatus of claim 11 or 12, wherein, The device further comprises the following steps: a discarding module, used for discarding unsynchronized modification logs corresponding to the target file when the target file is deleted.

15. An electronic device, comprising: The device comprises the following steps: A processor and a memory, the memory is used to store a computer program; the processor is used to run the computer program, and realizes the file reading and writing method as claimed in any one of claims 1-7.

16. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and when the computer program runs on a computer, realizes the file reading and writing method as claimed in any one of claims 1-7.

Citation Information

Patent Citations

  • Method and device for modifying mirror image document

    CN107015995A

  • A method and a device for realizing data consistency in a distributed file system

    CN109582658A