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

By mounting the server to the lower layer of the file system and modifying the file fragments in the upper layer, combined with the method of merging modified contents and discarding unsynchronized logs, the problem of high power and resource consumption of mobile terminals when modifying remote storage files is solved, improving efficiency File reading and writing efficiency and storage space utilization.

CN118535075AActive Publication Date: 2024-08-23HUAWEI TECH CO LTD

Patent Information

Application Number
CN202310188218.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-02-21
Publication Date
2024-08-23
Estimated Expiration
2043-02-21

AI Technical Summary

Technical Problem

When the mobile terminal modifies remote storage files, it results in a large amount of disk input and output and network access, seriously affecting power consumption and resource utilization.

Method used

Mount the server to the lower layer of the file system, copy and modify the to-be-modified fragments of the file to the upper layer, thereby reducing the transmission overhead between the terminal and the server, and optimizing the file reading and writing process by merging modified content and discarding unsynchronized modification logs .

Benefits of technology

It effectively reduces the power and resource consumption of mobile terminals, improves file reading and writing efficiency, saves storage space, and avoids efficiency reduction caused by multiple modifications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118535075A
    Figure CN118535075A
Patent Text Reader

Abstract

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

Description

Technical Field

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

[0002] As more and more applications are used and files become larger and larger, the storage space of mobile terminals such as mobile phones has encountered a great challenge. Currently, the common practice is to migrate files in mobile terminals such as mobile phones to servers.

[0003] The access to any file by applications on a mobile terminal based on Linux operating system will eventually converge to the file system level operation of the operating system. If the access method to the server is encapsulated into a local file system, and then the local file system is merged with the above encapsulated remote storage file system using the fusion view file system, the storage space of the mobile terminal can be expanded.

[0004] However, when an application modifies a remotely stored file, a large amount of disk input and output and network access will be generated, which seriously affects the power consumption and resources of the mobile terminal. Summary of the invention

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

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

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

[0008] The segment to be modified of the target file is modified and saved in the upper layer of the file system.

[0009] In the present application, by pre-mounting the remote storage at the lower layer of the file system, when modifying the files in the remote storage, the lower layer files 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 that is less frequently accessed by users.

[0011] In this application, by migrating application data to the server, the storage occupied by application data on the terminal can be reduced. In addition, only application data that is not frequently accessed by users is migrated, and commonly used data is stored locally, which can avoid efficiency problems caused by access to commonly used data.

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

[0013] Determining whether the target file is stored in an 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, the target file is modified in the upper layer of the file system.

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

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

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

[0018] The modified content is synchronized to a lower layer of the file system based on the modification log.

[0019] In one possible implementation, the modification log includes merged modification content, where the merged modification content is the modification content obtained by merging modification content at different locations in the same target file; or

[0020] The merged modified content is the last modified content among multiple modified contents at the same position in the same target file.

[0021] In this application, by merging the modified contents, the reduction in efficiency caused by multiple modifications can be avoided.

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

[0023] When the target file is deleted, the unsynchronized modification log corresponding to the target file is discarded.

[0024] In this application, after the target file is deleted, the corresponding modification log is discarded, which can reduce the storage occupancy of the terminal.

[0025] In a second aspect, the present application provides a file reading and writing device, comprising one or more functional modules, wherein the one or more functional modules are used to implement the file reading and writing method as described in the first aspect.

[0026] In a third aspect, the present application provides an electronic device, comprising: a processor and a memory, wherein the memory is used to store a computer program; the processor is used to run the computer program to implement the file reading and writing method as described in the first aspect.

[0027] In a fourth aspect, the present application provides a computer-readable storage medium, which stores a computer program. When the computer-readable storage medium is executed on a computer, the computer implements the file reading and writing method as described in the first aspect.

[0028] In a fifth aspect, the present application provides a computer program, which, when executed on a processor of an electronic device, enables the electronic device to execute the file reading and writing method described in the first aspect.

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

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

[0031] Figure 2 A schematic diagram of an application scenario provided for an embodiment of the present application;

[0032] Figure 3 A flowchart of an embodiment of a 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] Fig. 9 A flowchart of another embodiment of the file reading and writing method provided by the present application;

[0039] Fig.10A schematic diagram of the structure of a file reading and writing device provided in an embodiment of the present application;

[0040] Fig.11 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0041] In the embodiments of the present application, unless otherwise specified, the character " / " indicates that the objects before and after the association are in an or relationship. For example, A / B can represent A or B. "And / or" describes the association relationship of the associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone.

[0042] It should be pointed out that the words "first", "second", etc. involved in the embodiments of the present application are only used to distinguish the description purpose, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated, nor can they be understood as indicating or implying order.

[0043] In the embodiments of the present application, "at least one" refers to one or more, and "plurality" refers to two or more. In addition, "at least one of the following" or similar expressions refers to any combination of these items, which may include any combination of single items or plural items. For example, at least one of A, B, or C may represent: A, B, C, A and B, A and C, B and C, or A, B and C. Among them, each of A, B, and C may be an element itself, or a set containing one or more elements.

[0044] In the embodiments of the present application, "exemplary", "in some embodiments", "in another embodiment", etc. are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" in the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of the word "exemplary" is intended to present concepts in a concrete way.

[0045] In the embodiments of the present application, "of", "corresponding", and "corresponding" can sometimes be used interchangeably. It should be noted that when the distinction between them is not emphasized, the meanings to be expressed are consistent. In the embodiments of the present application, communication and transmission can sometimes be used interchangeably. It should be noted that when the distinction between them is not emphasized, the meanings to be expressed are consistent. For example, transmission can include sending and / or receiving, which can be a noun or a verb.

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

[0047] When an application modifies a remotely stored file, if the lower layer of the file system contains the file to be modified, the mobile terminal will copy all the files in the lower layer of the file system to the upper layer of the file system, and then use the copy of the upper layer of the file system as the target file for modification. Finally, the modified file will be synchronized to the lower layer of the file system, thereby causing the entire file to be copied back and forth between the lower and upper layers of the file system, generating a large amount of disk input and output and network access, which has a serious impact on the power consumption and resources of the mobile terminal.

[0048] Based on the above problems, the embodiment of the present application proposes a file reading and writing method, which is applied to a mobile terminal, such as a mobile phone, a tablet, etc. A mobile terminal may 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 may be a station (STAION, ST) in a WLAN, 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 computer, a handheld communication device, a handheld computing device, a satellite wireless device, a wireless modem card, a TV 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, for example, 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 may also be a wearable device. Wearable devices can also be called wearable smart devices. They are a general term for the intelligent design and development of wearable devices for daily wear using wearable technology, such as glasses, gloves, watches, clothing and shoes.

[0049] Now combined Figure 1-Figure 9The file reading and writing method provided in the embodiment of the present application is described.

[0050] Figure 1 This is a system architecture diagram of the storage file system provided in the embodiment of the present application. Figure 1 As shown, 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 scope 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. Figure 1 , the storage file system may include Linux user state, Linux kernel state and hardware.

[0051] The Linux user state may include a LIBC library, which may 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 fused file system, and device management and drivers. The virtual file system can be used to shield the differences between the lower-level file systems and provide a unified file operation interface for the upper-level file system. The fused file system is used to fuse multiple file systems (for example, ext4 file system, f2fs file system, etc.) at the lower level and provide a fused directory view to the application, so that the application is unaware of the changes in the file storage path when reading and writing files. Device management and drivers are used to provide drivers for accessing local storage and network storage.

[0053] Hardware can include local hardware and network storage. Local hardware can include disks and memory cards, and network storage can include cloud storage, network disks, etc.

[0054] Figure 2 For the application architecture diagram provided in the embodiment of this application, refer to Figure 2, the application architecture may include a mobile terminal 20 and a server 21. It is understandable that the server 21 may be a local server or a network server, and the embodiment of the present application does not specifically limit the type of the server 21. The mobile terminal 20 may first migrate the data files of the application to the server 21, and then the remotely stored mount directory may be designated as the lower layer of the file system, the lower layer of the file system may also be referred to as the lower file system, for example, the lower file system may be NFS, and merged with the locally stored mount directory as the upper file system, for example, the upper file system may be f2fs, thereby enabling the application to be unaware of the change in the storage path of the file when reading and writing the file. Among them, the access priority of the lower file system is lower than that of the upper file system. It is understandable that the above-mentioned migrated data may be application data that is not frequently accessed by the user, and the above-mentioned application data that is not frequently accessed by the user may be application data that is less frequently accessed by the user, and illustratively, the application data that is less frequently accessed by the user may be application data whose access frequency domain is lower than the preset frequency threshold, thereby reducing the number of accesses to the server 21 and improving data access efficiency.

[0055] like Figure 3 The figure shows a flow chart of an embodiment of the file reading and writing method provided by the present application. In the embodiment of the present application, the application files that are not frequently accessed by the user can be migrated to the server, and the application files that are not frequently accessed by the user can be deleted in the mobile terminal after migration, thereby saving the storage space of the mobile terminal. Specifically, the following steps are included:

[0056] Step 301: The mobile terminal copies the application file to the server.

[0057] Specifically, the application files that are copied may be some files in the application that are not frequently accessed. That is to say, the frequently accessed application files in the mobile terminal are not migrated, so that when the mobile terminal accesses the frequently used application files, it can obtain them directly from the local without obtaining them from the server, thereby improving the access efficiency. For the application files that are not frequently accessed, they can be migrated to the server, thereby saving the storage space of the mobile terminal.

[0058] Step 302: The server starts a sharing service to share the migrated application files.

[0059] Specifically, the server can start the above sharing service as an NFS server.

[0060] Step 303: The mobile terminal mounts the remote storage directory.

[0061] Specifically, the mobile terminal can mount the remote storage directory shared by the server with an NFS client, thereby achieving remote access.

[0062] Step 304: The mobile terminal integrates the directory stored locally and the directory stored remotely for the application and mounts it.

[0063] Step 305: The mobile terminal deletes the migrated application files.

[0064] The above Figure 3 The migration of application files is described in an exemplary manner. Figure 4 The reading and writing of application files are exemplified.

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

[0066] Step 401: an application in a 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 an application in a mobile terminal wants to read a target file, it can first determine the storage location of the target file. Since common files are usually stored in the upper layer of the file system, it can first determine 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 an upper layer of the file system, step 403 may be further executed.

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

[0071] Step 403: The mobile terminal reads the target file in the upper 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 may be read in the upper layer file system, and after the target file is read, step 407 may be further executed.

[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 a lower layer of the file system, step 405 may be further executed.

[0075] If the mobile terminal determines that the target file is not stored in the lower layer of the file system, it may return a file-non-existent error and terminate the access.

[0076] Step 405: The mobile terminal reads the target file in the lower file system.

[0077] Step 406: The lower file system remotely obtains the target file from the NFS server.

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

[0079] The above Figure 4 The reading of the application file is explained exemplarily. Figure 5 The modification of the application file is described exemplarily.

[0080] Figure 5 A flowchart of another embodiment of the file reading and writing method provided by the present application may specifically include the following steps:

[0081] Step 501: An application in a mobile terminal modifies a target file.

[0082] Step 502: The mobile terminal determines whether the storage location of the target file is in the upper layer of the file system.

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

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

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

[0086] Step 503: The mobile terminal modifies the target file in the upper 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 may be modified in the upper layer file system, and after the target file is modified, step 507 may be further executed.

[0088] Step 504: the mobile terminal determines whether the storage location of the target file is in the lower layer of the file system.

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

[0090] If the mobile terminal determines that the target file is not stored in the lower layer of the file system, it can return a file does not exist error and end the modification.

[0091] 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 to-be-modified segment of the target file can be copied in the lower file system to the upper file system. For example, the to-be-modified segment of the target file can be remotely copied in the server to the upper file system, thereby eliminating the need to copy the entire target file, thereby saving 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 to-be-modified segment of the target file can be modified, and the modified content can be saved in the upper layer of the file system.

[0094] Step 506: The mobile terminal generates a modification log.

[0095] Specifically, after modifying the target file, the mobile terminal may generate a corresponding modification log, wherein the modification log may include the modified content.

[0096] Step 507: The mobile terminal returns the modified result to the application.

[0097] In some optional embodiments, the mobile terminal can also synchronize the modified content in the upper file system to the lower file system, thereby avoiding the need for additional services in the prior art to perform remote synchronization of the modified content. In the embodiment of the present application, the above-mentioned conditions for triggering synchronization can be configured as follows:

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

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

[0100] If the currently accessed operation depends on the last modification, but that modification has not yet been synchronized, synchronization can be triggered; or

[0101] When the fused file system is unmounted, if there are unsynchronized modified contents, synchronization can be triggered.

[0102] In some optional embodiments, in order to reduce the number of requests for lower-level files of the file system and improve efficiency, the contents of the logs may also be merged.

[0103] Exemplarily, when different locations of the same file are modified, the modified contents may be merged and a modification log may be generated, thereby avoiding multiple modification logs generated by multiple modifications, and further avoiding multiple synchronizations of lower-level files 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 there is no need to synchronize the unsynchronized modification log; or

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

[0106] Now combined Figure 6-Figure 9 , the synchronization of modified content is exemplified through different application scenarios.

[0107] Figure 6 A flowchart of another embodiment of the file reading and writing method provided by the present application may specifically include the following steps:

[0108] Step 601: An application in a mobile terminal reads and writes lower-level files in a file system.

[0109] Step 602: The mobile terminal determines whether the content to be read or written this time has any 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 may 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, this process can be ended.

[0112] Step 603: The mobile terminal merges the modified contents in the upper layer of the file system.

[0113] Specifically, the manner in which the mobile terminal merges the modified contents in the upper layer of the file system may be specifically referred to the relevant description in the above embodiment, which will not be described in detail here.

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

[0115] Figure 7 A flowchart of another embodiment of the file reading and writing method provided by the present application may specifically include the following steps:

[0116] Step 701: An application in a mobile terminal modifies a lower-layer file in a file system.

[0117] Step 702: The mobile terminal saves the modified content in the upper layer of the file system and generates a modification log.

[0118] 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 a preset threshold, step 704 may be further executed.

[0120] If the mobile terminal determines that the total size of the modified content does not reach the preset threshold, the current process can be terminated.

[0121] Step 704: The mobile terminal merges the modified contents in the upper layer of the file system.

[0122] Specifically, the manner in which the mobile terminal merges the modified contents in the upper layer of the file system may be specifically referred to the relevant description in the above embodiment, which will not be described in detail here.

[0123] 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 by the present application may specifically include the following steps:

[0125] Step 801, start the periodic timer.

[0126] Step 802: The mobile terminal determines whether there is any 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 may be further executed.

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

[0129] Step 803: The mobile terminal merges the modified contents in the upper layer of the file system.

[0130] Specifically, the manner in which the mobile terminal merges the modified contents in the upper layer of the file system may be specifically referred to the relevant description in the above embodiment, which will not be described in detail here.

[0131] Step 804: The mobile terminal synchronizes the merged modified content to the lower layer of the file system.

[0132] Fig. 9 A flowchart of another embodiment of the file reading and writing method provided by the present application may specifically include the following steps:

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

[0134] Step 902: The mobile terminal determines whether there is any unsynchronized modified content.

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

[0136] If the mobile terminal determines whether there is any modification content to be synchronized, the current process can be ended.

[0137] Step 903: The mobile terminal merges the modified contents in the upper layer of the file system.

[0138] Specifically, the manner in which the mobile terminal merges the modified contents in the upper layer of the file system may be specifically referred to the relevant description in the above embodiment, which will not be described in detail here.

[0139] Step 904: The mobile terminal synchronizes the merged modified content to the lower layer of the file system.

[0140] Fig.10 This is a schematic diagram of the structure of an embodiment of the file reading and writing device of this application, such as Fig.10 As shown, the file reading and writing device 1000 is applied to an electronic device, and the electronic device mounts the server to the lower layer of the file system, and the access priority of the lower layer of the file system is lower than the access priority of the upper layer of the file system. The file reading and writing device 1000 may include: a copy module 1010 and a modification module 1020; wherein,

[0141] A copy module 1010, configured to copy a segment of the target file to be modified to an upper layer of the file system when modifying the target file on the server through the lower layer of the file system;

[0142] The modification module 1020 is used 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 manner, the target file on the server is an application file that is less frequently used by users.

[0144] In one possible implementation, the modification module 1020 is further used to determine whether the target file is stored in an 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] A generation module is used to generate a modification log based on the modified content.

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

[0149] A synchronization module is used 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 modification content, where the merged modification content is the modification content obtained by merging modification content at different locations in the same target file; or

[0151] The merged modified content is the last modified content among multiple modified contents at the same position in the same target file.

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

[0153] The discarding module is used to discard the unsynchronized modification log corresponding to the target file after the target file is deleted.

[0154] Fig.10 The file reading and writing device 1000 provided in the illustrated embodiment can be used to execute the technical solution of the method embodiment illustrated in the present application, and its implementation principle and technical effects can be further referred to the relevant description in the method embodiment.

[0155] It should be understood that the above Fig.10 The division of the various modules of the file reading and writing device 1000 shown is only a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or they can be physically separated. And these modules can all be implemented in the form of software calling through processing elements; they can also be all implemented in the form of hardware; some modules can also be implemented in the form of software calling through processing elements, and some modules can be implemented in the form of hardware. For example, the detection module can be a separately established processing element, or it can be integrated in a chip of an electronic device. The implementation of other modules is similar. In addition, all or part of these modules can be integrated together, or they can be implemented independently. In the implementation process, each step of the above method or the above modules can be completed by the hardware integrated logic circuit in the processor element or the instructions in the form of software.

[0156] For example, the above modules may be one or more integrated circuits configured to implement the above methods, such as one or more application specific integrated circuits (ASIC), or one or more microprocessors (DSP), or one or more field programmable gate arrays (FPGA). For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).

[0157] Combine the following Fig.11 The exemplary electronic device provided in the embodiments of the present application is further introduced. Fig.11 A schematic structural diagram of an electronic device 1100 is shown.

[0158] The electronic device 1100 may include: at least one processor; and at least one memory in communication with the processor, wherein: the memory stores program instructions executable by the processor, and the processor calls the program instructions to execute the present application. Figure 1-Figure 9 The method provided by the illustrated embodiment.

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

[0160] like Fig.11 As shown, the electronic device 1100 is in the form of a general computing device. The components of the electronic device 1100 may 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] The 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 port, a processor or a local bus using any of a variety of bus structures. For example, these architectures include but are not limited to Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus and Peripheral Component Interconnection (PCI) bus.

[0162] The electronic device 1100 typically includes a variety of computer system readable media, which can be any available media that can be accessed by the electronic device, including volatile and nonvolatile media, removable and non-removable media.

[0163] The memory 1120 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) and / or cache memory. The electronic device may further include other removable / non-removable, volatile / non-volatile computer system storage media. Fig.11 Not shown, a disk drive for reading and writing a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing a removable non-volatile optical disk (e.g., a compact disc read only memory (CD-ROM), a digital versatile disc read only memory (DVD-ROM), or other optical media) may be provided. In these cases, each drive may be connected to the communication bus 1140 via one or more data medium interfaces. The memory 1120 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present application.

[0164] A program / utility having a set (at least one) of program modules may be stored in memory 1120, such program modules including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. The program modules typically perform the functions and / or methods of the embodiments described herein.

[0165] The electronic device 1100 may also communicate with one or more external devices (e.g., keyboard, pointing device, display, etc.), one or more devices that enable a user to interact with the electronic device, and / or any device that enables the electronic device to communicate with one or more other computing devices (e.g., network card, modem, etc.). Such communication may be performed via the communication interface 1130. Furthermore, the electronic device 1100 may also communicate with the network adapter ( Fig.11 The network adapter can communicate with one or more networks (such as a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through the communication bus 1140. It should be understood that although Fig.11 Not shown, other hardware and / or software modules may be used in conjunction with the electronic device 1100, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, disk arrays (Redundant Arrays of Independent Drives; hereinafter referred to as: RAID) systems, tape drives, and data backup storage systems.

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

[0167] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device 1100. In other embodiments of the present application, the electronic device 1100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.

[0168] In the above embodiments, the processor involved may include, for example, a CPU, a DSP, a microcontroller or a digital signal processor, and may also include a GPU, an embedded neural network processor (Neural-network Process Units; hereinafter referred to as: NPU) and an image signal processor (Image Signal Processing; hereinafter referred to as: ISP). The processor may also include necessary hardware accelerators or logic processing hardware circuits, such as 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 may have the function of operating one or more software programs, and the software programs may be stored in a storage medium.

[0169] An embodiment of the present application also provides a computer-readable storage medium, in which a computer program is stored. When the computer-readable storage medium is run on a computer, the computer executes the method provided by the embodiment shown in the present application.

[0170] An embodiment of the present application also provides a computer program product, which includes a computer program. When the computer program is run on a computer, it enables the computer to execute the method provided by the embodiment shown in the present application.

[0171] In the embodiments of the present application, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent the existence of A alone, the existence of A and B at the same time, and the existence of B alone. Among them, A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following" and similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b and c can be represented by: a, b, c, a and b, a and c, b and c, or a and b and c, where a, b, c can be single or multiple.

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

[0173] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0174] In several embodiments provided in the present application, if any function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory; hereinafter referred to as: ROM), random access memory (Random Access Memory; hereinafter referred to as: RAM), disk or optical disk, and other media that can store program codes.

[0175] The above is only a specific implementation of the present application. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. The protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A file reading and writing method, characterized in that: Applied to an electronic device, 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 the access priority of the upper layer of the file system, and the method includes: When modifying the target file on the server through the lower layer of the file system, copying the segment of the target file to be modified to the upper layer of the file system; The segment to be modified of the target file is modified and saved in the upper layer of the file system.

2. The method according to claim 1, characterized in that The target file on the server is an application file that is less frequently accessed by users.

3. The method according to claim 1, characterized in that The method further comprises: Determining whether the target file is stored in an upper layer of the file system; 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.

4. The method according to claim 1, characterized in that: After modifying the to-be-modified segment of the target file, the method further comprises: Generate a modification log based on the modified content.

5. The method according to claim 4, characterized in that The method further comprises: The modified content is synchronized to a 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 includes merged modification content, where the merged modification content is the modification content after modification content at different positions in the same target file is merged; or The merged modified content is the last modified content among multiple modified contents at the same position in the same target file.

7. The method according to claim 4 or 5, characterized in that: The method further comprises: When the target file is deleted, the unsynchronized modification log corresponding to the target file is discarded.

8. A file reading and writing device, characterized in that: Applied to an electronic device, 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 the access priority of the upper layer of the file system, and the device comprises: A copy module, used for copying the to-be-modified segment of the target file to the upper layer of the file system when modifying the target file on the server through the lower layer of the file system; The modification module is used to modify the to-be-modified segment of the target file and save it in the upper layer of the file system.

9. The device according to claim 8, characterized in that The target file on the server is an application file that is less frequently accessed by users.

10. The device according to claim 8, characterized in that The modification module is also used to determine whether the target file is stored in the upper layer of the file system; 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.

11. The device according to claim 8, characterized in that The device also includes: A generation module is used to generate a modification log based on the modified content.

12. The device according to claim 11, characterized in that The device also includes: A synchronization module is used to synchronize the modified content to a lower layer of the file system based on the modification log.

13. The device according to claim 11 or 12, characterized in that The modification log includes merged modification content, where the merged modification content is the modification content after modification content at different positions in the same target file is merged; or The merged modified content is the last modified content among multiple modified contents at the same position in the same target file.

14. The device according to claim 11 or 12, characterized in that The device also includes: The discarding module is used to discard the unsynchronized modification log corresponding to the target file after the target file is deleted.

15. An electronic device, characterized in that: include: A processor and a memory, wherein the memory is used to store a computer program; and the processor is used to run the computer program to implement the file reading and writing method according to any one of claims 1 to 7.

16. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is run on a computer, the file reading and writing method according to any one of claims 1 to 7 is implemented.

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

  • Method for updating file system, network device and computer readable storage medium

    CN110018994A

  • System repair method, server and storage medium

    CN110162429A

  • File snapshot method and device, electronic equipment and storage medium

    CN111625500A

Cited By

  • File management method based on RAID card, storage medium and computer equipment

    CN120085803A