File operation method and device

By receiving and processing file operation requests in the embedded heterogeneous multi -nuclear equipment, and sending the request to the server through nuclear intercourse communication, the existing remote file system cannot meet the requirements of high -real time and lightweight requirements, and achieve efficient efficiency. Remote file operation of embedded nuclear intercate.

CN115733904BActive Publication Date: 2025-01-24JINGWEI HIRAIN (TIANJIN) RES&DEV CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211550432.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-05
Publication Date
2025-01-24
Estimated Expiration
2042-12-05

AI Technical Summary

Technical Problem

Existing remote file systems cannot meet the requirements of high real-time and lightweight in embedded heterogeneous multi-core devices, especially some CPU cores cannot directly operate storage media for file management.

Method used

By receiving the file operation request initiated by the target application, calling the file operation interface matching the request, based on program control of lock and priority, the request is sent to the protocol parsing controller, the message is generated and sent to the server through the inter-core communication cache , realizing high real-time and lightweight embedded inter-core remote file operations.

Benefits of technology

Effectively realized the high -real time and lightweight embedded nuclear inter -file operation of embedded heterogeneous multi -core equipment, which solved the problem of some CPU cores that could not directly operate the storage medium for file management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115733904B_ABST
    Figure CN115733904B_ABST
Patent Text Reader

Abstract

The present application discloses a file operation method and device, which relate to the field of communication technology. The file operation method is applied to a multi-core device, and the file operation method includes: receiving a first file operation request, wherein the first file operation request is initiated by a target application; calling a file operation interface that matches the first file operation request, and sending the first file operation request to a protocol parsing controller through program control based on locks and priorities, so that the protocol parsing controller encapsulates the first file operation request according to a preset protocol, generates a first message, and sends the first message to a server through an inter-core communication cache. According to an embodiment of the present application, highly real-time and lightweight embedded inter-core remote file operations can be implemented based on multi-core devices, solving the problem that some CPU cores cannot directly operate storage media for file management.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technology, and in particular to a file operation method and device. Background Art

[0002] For embedded heterogeneous multi-core devices, during the normal operation of each core in the device, it is often necessary to operate and manage files stored in the underlying disk, such as reading, writing, and deleting files.

[0003] However, some central processing unit (CPU) cores cannot directly operate storage media, and a remote file system is needed to save and read files. Most existing remote file systems are based on the network and rely on a large number of complex communication protocol stacks, which does not meet the requirements of lightweight and high real-time performance in embedded heterogeneous multi-core devices. Summary of the invention

[0004] The embodiments of the present application provide a file operation method and device, which can realize highly real-time and lightweight embedded inter-core remote file operation of multi-core devices, and solve the problem that some CPU cores cannot directly operate storage media for file management.

[0005] In a first aspect, an embodiment of the present application provides a file operation method, which is applied to a multi-core device. The file operation method includes:

[0006] receiving a first file operation request, wherein the first file operation request is initiated by a target application;

[0007] Call the file operation interface that matches the first file operation request, and send the first file operation request to the protocol parsing controller through program control based on locks and priorities, so that the protocol parsing controller encapsulates the first file operation request according to the preset protocol, generates a first message, and sends the first message to the server through the inter-core communication cache.

[0008] In some possible implementations, sending the first message to the server through the inter-core communication cache includes:

[0009] The first message is sent to the server through the inter-core shared memory.

[0010] In some possible implementations, calling a file operation interface that matches the first file operation request, and sending the first file operation request to a protocol parsing controller through program control based on locks and priorities, includes:

[0011] In the case of receiving multiple file operation requests initiated by N applications at the same time, calling a file operation interface matching a first file operation request, and allocating lock resources to the first file operation request based on preset priorities of the N applications;

[0012] Sending the first file operation request after the lock resource is allocated to the protocol parsing controller;

[0013] The N applications include a target application, the multiple file operation requests include a first file operation request, and the preset priority of the target application is the highest among the N applications.

[0014] In some possible implementations, after sending the first message to the server through the inter-core communication cache, the file operation method further includes:

[0015] receiving a target file descriptor associated with a target file sent by a server; the target file is a file requested to be operated by the first file operation request;

[0016] Sending the second file operation request to the protocol parsing controller, so that the protocol parsing controller encapsulates the second file operation request according to the preset protocol, generates a second message, and sends the second message to the server through the inter-core communication cache; wherein the second operation request includes a target file descriptor; the second operation request is used to request to perform a second operation on the target file;

[0017] After receiving the second message, the server determines the target file based on the target file descriptor and performs the second operation on the target file.

[0018] In some possible implementations, the first file operation request is used to request to perform a first operation on a target file; the server establishes communication with an underlying file system of the multi-core device in advance; after sending the first message to the server through the inter-core communication cache, the file operation method further includes:

[0019] The server performs a first operation on the target file by controlling the underlying file system according to the first message.

[0020] In some possible implementations, the first file operation request includes identification information of a client where a target application is located; and the server performs a first operation on the target file by controlling an underlying file system according to the first message, including:

[0021] The server verifies the file operation authority of the client according to the identification information of the client, and if the file operation authority of the client passes the verification, the server performs the first operation on the target file by controlling the underlying file system.

[0022] In some possible implementations, after sending the first message to the server through the inter-core communication cache, the file operation method further includes:

[0023] If the protocol analysis controller receives a response message sent by the server within a preset time period, the response message is detected, and if it is detected that the response message does not match the first message, the response message is discarded; and,

[0024] If no response message sent by the server is received within a preset time period, a processing failure result of the first file operation request is returned to the target application.

[0025] In some possible implementations, before sending the first file operation request to the protocol parsing controller, the file operation method further includes:

[0026] When it is detected that the server is in a non-idle state, the first file operation request is cached; and when it is detected that the server has resumed an idle state, the cached first file operation request is processed according to the preset priority of the target application and the initiation time of the first file operation request, so that the first file operation request is sent to the protocol parsing controller.

[0027] In some possible implementations, the message protocol format of the first message adopts a field combination form of a type field, a length field, and a value field;

[0028] The type field is filled with the message type, the length field is filled with the content length, and the value field is filled with the payload transmitted by the first message.

[0029] In a second aspect, an embodiment of the present application provides a file operation device, which is applied to a multi-core device. The file operation device includes:

[0030] A first receiving module, configured to receive a first file operation request, wherein the first file operation request is initiated by a target application;

[0031] The first processing module is used to call the first file operation interface that matches the first file operation request, and send the first file operation request to the protocol parsing controller through program control based on locks and priorities, so that the protocol parsing controller encapsulates the first file operation request according to a preset protocol, generates a first message, and sends the first message to the server through the inter-core communication cache.

[0032] In a third aspect, an embodiment of the present application provides a file operation device, the file operation device comprising:

[0033] a processor and a memory storing computer program instructions;

[0034] When the processor executes the computer program instructions, it implements the file operation method provided in any one of the above-mentioned embodiments of the present application.

[0035] In a fourth aspect, an embodiment of the present application provides a computer storage medium, on which computer readable storage medium is stored computer program instructions, and when the computer program instructions are executed by a processor, a file operation method provided in any one of the above-mentioned embodiments of the present application is implemented.

[0036] In a fifth aspect, an embodiment of the present application provides a computer program product. When the instructions in the computer program product are executed by a processor of an electronic device, the electronic device executes a file operation method provided in any one of the above-mentioned embodiments of the present application.

[0037] The file operation method and device of the embodiment of the present application receive a first file operation request initiated by a target application, then call a file operation interface matching the first file operation request, and send the first file operation request to a protocol parsing controller through program control based on locks and priorities, so that the protocol parsing controller encapsulates the first file operation request according to a preset protocol, generates a first message, and sends the first message to a server through an inter-core communication cache. Compared with the existing remote file system based on a network and communication protocol stack, a file operation method and device provided by the embodiment of the present application can effectively realize high real-time and lightweight embedded inter-core remote file operations of embedded heterogeneous multi-core devices by setting the above series of file request processing steps, thereby solving the problem that some CPU cores cannot directly operate storage media for file management. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] In order to more clearly illustrate the technical solution of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0039] Figure 1 It is a flowchart of a file operation method provided by an embodiment of the present application;

[0040] Figure 2 A flowchart of an overall embodiment of the file operation method provided in the embodiment of the present application;

[0041] Figure 3 is a structural schematic diagram of a file operation device provided by an embodiment of the present application;

[0042] Figure 4 It is a structural diagram of a file operation device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0043] The features and exemplary embodiments of various aspects of the present application will be described in detail below. In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain the present application, rather than to limit the present application. For those skilled in the art, the present application can be implemented without the need for some of these specific details. The following description of the embodiments is only to provide a better understanding of the present application by illustrating the examples of the present application.

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

[0045] In the present application, an embedded heterogeneous multi-core device may be composed of a server and one or more clients. The server and the client may specifically be the respective cores in the embedded heterogeneous multi-core device, and one server may provide services to multiple clients.

[0046] As described in the background technology section, currently some CPU cores cannot directly operate storage media and need to use remote file systems to save and read files. However, existing remote file system implementations are mostly network-based and rely on a large number of complex communication protocol stacks, which do not meet the requirements of lightweight and high real-time performance in embedded heterogeneous multi-core devices.

[0047] Based on this, in order to solve the problems of the prior art, the embodiments of the present application provide a file operation method and device. It should be noted that the embodiments provided in the present application are not intended to limit the scope of the present application.

[0048] The following first introduces the file operation method provided in the embodiment of the present application.

[0049] Figure 1The flowchart of the file operation method provided by an embodiment of the present application is shown. The file operation method is applied to a multi-core device, which can be an embedded heterogeneous multi-core device, and the multi-core device can include a server and a client. Figure 1 As shown, the file operation method applied to the client includes the following steps:

[0050] S110, receiving a first file operation request, wherein the first file operation request is initiated by a target application;

[0051] S120, calling the file operation interface that matches the first file operation request, and sending the first file operation request to the protocol parsing controller through program control based on locks and priorities, so that the protocol parsing controller encapsulates the first file operation request according to a preset protocol, generates a first message, and sends the first message to the server through the inter-core communication cache.

[0052] The file operation method of the embodiment of the present application receives a first file operation request initiated by a target application, then calls a file operation interface matching the first file operation request, and sends the first file operation request to a protocol parsing controller through program control based on locks and priorities, so that the protocol parsing controller encapsulates the first file operation request according to a preset protocol, generates a first message, and sends the first message to a server through an inter-core communication cache. Compared with the existing remote file system based on a network and communication protocol stack, a file operation method provided by the embodiment of the present application can effectively realize high real-time and lightweight embedded inter-core remote file operations of embedded heterogeneous multi-core devices by setting the above series of file request processing steps, thereby solving the problem that some CPU cores cannot directly operate storage media for file management.

[0053] The specific implementation of the above steps 110 to 120 is described in detail below.

[0054] In S110, during specific implementation, this step may be performed by a client in a multi-core device.

[0055] The client may include multiple applications, and the relevant user may initiate a first file operation request through a target application on the client, so that the client can receive the first file operation request initiated by the target application.

[0056] The first file operation request may be specifically used to request a first operation to be performed on a target file. The first operation may be, for example, an open operation, a write operation or a delete operation of the target file, and the present application does not impose any specific restrictions on this.

[0057] It should be noted that in an actual file operation scenario, the first file operation request may specifically include file information of the target file and first operation information.

[0058] The above-mentioned file information may be but is not limited to at least one of the information such as the file name, file directory and file size of the target file. The above-mentioned first operation information may be specifically used to characterize the operation content to be performed on the target file, for example, opening the file, reading and writing the file content, deleting the file, etc. This application does not impose any specific restrictions on this.

[0059] In S120, when implemented specifically, this step can be performed by a client in a multi-core device. Specifically, a file operation interface matching the first file operation request is called, and the first file operation request is sent to a protocol parsing controller through program control based on locks and priorities, so that the protocol parsing controller encapsulates the first file operation request according to a preset protocol, generates a first message, and sends the first message to the server through an inter-core communication cache.

[0060] In this embodiment, the client may include multiple file and directory operation interfaces, which may be provided by the file system, which is conducive to providing unified standards and specifications for file operations, thereby effectively improving the file operation efficiency of the client in the embedded heterogeneous multi-core device.

[0061] The types of the above-mentioned file interfaces may specifically include but are not limited to at least one of file system resource initialization, file system resource deinitialization, creating a file, opening a file, reading a file, writing a file, moving a file, renaming a file, copying a file, deleting a file, obtaining a file size, closing a file, etc.

[0062] In specific implementation, after receiving the first file operation request initiated by the target application, the client can call the matching file operation interface through the specific operation content included in the first file operation request, and send the first file operation request to the protocol parsing controller through program control based on locks and priorities. In the client, if the protocol parsing controller receives the first file operation request, it will encapsulate the first file operation request according to the preset protocol, generate a first message, and send the first message to the server through the inter-core communication cache.

[0063] It should be added that, corresponding to the client, another protocol parsing controller may also be deployed on the server. In this way, after the server receives the first message transmitted by the client, the protocol parsing controller included therein may parse the first message according to the preset protocol to obtain the above-mentioned first file operation request.

[0064] It should be noted that the above-mentioned inter-core communication cache can be implemented based on the inter-core communication mechanism of related cache hardware, and this application does not make any specific restrictions on this.

[0065] In some possible implementations, in order to further realize the high real-time and lightweight embedded inter-core remote file operation of the embedded heterogeneous multi-core device, the above-mentioned sending the first message to the server through the inter-core communication cache may specifically include:

[0066] The first message is sent to the server through the inter-core shared memory.

[0067] The above-mentioned inter-core communication cache can be specifically a shared memory between the client and the server. Specifically, the shared memory is a large-capacity memory that can be accessed by different CPU cores in an embedded heterogeneous multi-core device. After any cached data in the shared memory is updated by any CPU core, other cores can also access the corresponding cached data.

[0068] In specific implementation, after the client receives the first file operation request initiated by the target application, high-speed inter-core communication between the client and the server can be achieved through the shared memory between the client and the server, thereby further realizing high real-time and lightweight embedded inter-core remote file operations of embedded heterogeneous multi-core devices.

[0069] In this embodiment, the shared memory between the client and the server may be implemented based on RPMsg in the openAMP open source framework and using VirtIO to provide shared memory management.

[0070] In some possible implementations, considering that the client may include multiple applications, multiple applications may initiate corresponding file operation requests at the same time. Based on this, in order to effectively improve the efficiency and thread safety of the file operation process and improve the rationality of file operation processing, the above-mentioned calling of the file operation interface matching the first file operation request, through program control based on locks and priorities, sends the first file operation request to the protocol parsing controller, including:

[0071] In the case of receiving multiple file operation requests initiated by N applications at the same time, calling a file operation interface matching a first file operation request, and allocating lock resources to the first file operation request based on preset priorities of the N applications;

[0072] Sending the first file operation request after the lock resource is allocated to the protocol parsing controller;

[0073] The N applications may include a target application, the multiple file operation requests include a first file operation request, and the preset priority of the target application is the highest among the N applications.

[0074] In this way, when N applications in the client initiate file operation requests at the same time, that is, when multiple applications need to perform file operations at the same time, the client will allocate lock resources according to the priority of the application, thereby ensuring thread safety and file operation efficiency.

[0075] For applications that cannot obtain the lock, this embodiment provides three processing methods. The first is a blocking method, in which the file operation request of the application is blocked and waits for other file operation requests to be processed and then runs after the lock resources are released; the second is a non-blocking method, which directly returns failure; the third is a non-blocking method, in which the application continues to run and waits for the processing of its file operation request to be completed, and then notifies the application of the processing result of its file operation request through a task notify method.

[0076] In some possible implementations, considering that the client's access operation to a file often involves consecutive operation requests for the same file, for example, after requesting to open a file, it is often necessary to read and write the file content. Based on this, in order to further improve the efficiency of file operations between the server and the client, after sending the first message to the server through the inter-core communication cache, the file operation method may also include:

[0077] receiving a target file descriptor associated with a target file sent by a server; the target file is a file requested to be operated by the first file operation request;

[0078] Sending the second file operation request to the protocol parsing controller, so that the protocol parsing controller encapsulates the second file operation request according to the preset protocol, generates a second message, and sends the second message to the server through the inter-core communication cache; wherein the second operation request includes a target file descriptor; the second operation request is used to request to perform a second operation on the target file;

[0079] After receiving the second message, the server determines the target file based on the target file descriptor and performs the second operation on the target file.

[0080] The target file descriptor may specifically be a non-negative integer index value, pointing to the record table of the client opening the file maintained by the target file.

[0081] In a specific implementation, after the client sends the first message to the server through the inter-core communication cache, the server performs operations such as opening, reading or creating the target file based on the received first message. After that, the server associates a unique target file descriptor with the target file and returns the target file descriptor to the client.

[0082] In this way, after receiving the target file descriptor, the client can generate a corresponding second file operation request for the target file based on the target file descriptor when performing related file operations such as reading the target file. Accordingly, the second file operation request is sent to the protocol parsing controller, so that the protocol parsing controller encapsulates the second file operation request according to the preset protocol to generate a second message, and sends the second message to the server through the inter-core communication cache.

[0083] Thus, after receiving the second message, the server can obtain the second file operation request based on the second message parsed, and can directly use the target file descriptor in the second operation request to quickly locate the target file requested by the second file operation request, thereby performing the second operation on the target file.

[0084] In this embodiment, since a unique corresponding target file descriptor is associated with the target file, the subsequently generated second operation request does not need to include other file information, etc., which further realizes the lightweight of the information transmitted during the file operation process and can effectively improve the operational efficiency of the client in performing subsequent operations on the target file.

[0085] It should be added that, in some other implementations, in order to achieve reasonable utilization of resources, when the connection between the client and the server is disconnected, the server will correspondingly close all files opened by the client and release the file descriptors associated with each file.

[0086] In some possible implementations, in order to more reasonably solve the problem that some CPU cores cannot directly operate the storage medium to perform file management, the first file operation request may be used to request to perform a first operation on the target file; the server may establish communication with the underlying file system of the multi-core device in advance; after sending the first message to the server through the inter-core communication cache, the file operation method may further include:

[0087] The server performs a first operation on the target file by controlling the underlying file system according to the first message.

[0088] Specifically, the server may establish communication with the underlying file system in the multi-core device in advance. Thus, after receiving the first message sent by the client, the server may implement the first operation on the target file by controlling the underlying file system according to the first file operation request obtained after parsing the first message.

[0089] In this way, the server establishes communication with the underlying file system in advance, and specifically controls the underlying file system when performing file operations. This can more reasonably solve the problem that some CPU cores cannot directly operate the storage medium for file management, and can also effectively ensure the security of the file operation environment.

[0090] In some possible implementations, in order to effectively ensure the security of file operations in an embedded heterogeneous multi-core device, the first file operation request includes identification information of a client where a target application is located; and the server performs a first operation on the target file by controlling an underlying file system according to the first message, including:

[0091] The server verifies the file operation authority of the client according to the identification information of the client, and if the file operation authority of the client passes the verification, the server performs the first operation on the target file by controlling the underlying file system.

[0092] Specifically, after receiving the first operation request sent by the client, the server determines whether the client has the permission to execute the corresponding request, that is, the file operation permission, through the identification information in the first operation request. If it is detected that the client does not have the file operation permission, a failure may be returned. If the file operation permission check of the client passes, the first operation is performed on the target file by controlling the underlying file system.

[0093] In some possible implementations, in order to further improve the rationality of the overall inter-core file operation process, after sending the first message to the server through the inter-core communication cache, the file operation method may further include:

[0094] If the protocol analysis controller receives a response message sent by the server within a preset time period, the response message is detected, and if it is detected that the response message does not match the first message, the response message is discarded; and,

[0095] If no response message sent by the server is received within a preset time period, a processing failure result of the first file operation request is returned to the target application.

[0096] The protocol parsing controller may set the above-mentioned preset time period based on a timing mechanism. The above-mentioned preset time period may be determined according to the actual inter-core task processing speed, etc., and the present application does not impose any specific restrictions on this.

[0097] In specific implementation, the protocol parsing controller in the client can perform not only protocol encapsulation and parsing, but also reception detection of the response message of the server.

[0098] If a response message sent by the server is received within a predetermined preset time period, the response message is tested. Exemplarily, the response message may carry identification information related to the message it responds to, and during the detection, it may be tested whether the identification information related to the operation request it responds to is the identification information of the aforementioned first message.

[0099] In this way, if it is detected that the identification information related to the operation request it responds to is not the identification information of the aforementioned first message, it means that the response message does not match the aforementioned first message, and it is not a response message of the first message, and the response message will be discarded.

[0100] Furthermore, if the protocol parsing controller does not receive a response message sent by the server within a preset time period, it means that the server has not processed the first file operation request normally, and at this time, a processing failure result of the first file operation request is fed back to the target application.

[0101] In some possible implementations, in order to more reasonably implement the file operation request transmission between the client and the server in the multi-core device, before sending the first file operation request to the protocol parsing controller, the file operation method may also include:

[0102] When it is detected that the server is in a non-idle state, the first file operation request is cached; and when it is detected that the server has resumed an idle state, the cached first file operation request is processed according to the preset priority of the target application and the initiation time of the first file operation request, so that the first file operation request is sent to the protocol parsing controller.

[0103] In this embodiment, when the underlying file system associated with the server is busy, the server is in a non-idle state, and after the underlying file system associated with the server completes processing of the current task, the server is in an idle state.

[0104] In a specific implementation, when the server is in a non-idle state, the server can represent its non-idle state in the form of a specific state identifier or a state field, and transmit it to the client through the inter-core communication cache. After receiving the relevant information used to represent the non-idle state of the server, the client will cache the first file operation request.

[0105] When the server is in an idle state, the server can represent its idle state in the form of a specific state identifier or a state field, and send it to the client through the inter-core communication cache. After receiving the relevant information used to represent the idle state of the server, the client processes the cached first file operation request according to the preset priority of the target application and the initiation time of the first file operation request, so that the first file operation request is sent to the protocol parsing controller.

[0106] The above-mentioned processing of the cached first file operation request according to the preset priority of the target application and the initiation time of the first file operation request may be specifically: when the server is in a non-idle state, if the client has multiple applications initiating file operation requests, the multiple file operation requests will be cached. Then, when the server resumes the idle state, in order to avoid request processing confusion, the client may process the cached file operation requests in sequence according to the priority of the application, and when the priorities are the same, process them in sequence according to the time when the file processing requests were initiated.

[0107] It should be noted that in some other implementations, the client may also detect whether the server is in an idle state before sending the first file operation request. In this way, when the client detects that the server is in a non-idle state, the first file operation request is cached. When the client detects that the server has resumed an idle state, the first file operation request is processed accordingly.

[0108] In some possible implementations, in order to increase the effective load, the message protocol format of the first message may specifically adopt a field combination form of a type field, a length field, and a value field;

[0109] The type field is filled with the message type, the length field is filled with the content length, and the value field is filled with the payload transmitted by the first message.

[0110] Furthermore, the bytes occupied by the above fields can be limited to further increase the effective load and enhance the lightness and high speed of inter-core file transfer. For example, the above type field can be limited to occupy two bytes, the length field can be limited to occupy two bytes, etc. This application does not make specific restrictions on this.

[0111] In order to facilitate understanding of the file operation method provided by the above embodiment, the above method is described below with reference to a specific overall embodiment. Figure 2 A flowchart of an overall embodiment of the file operation method provided in an embodiment of the present application.

[0112] like Figure 2As shown, in the client, the operation request for the file is initiated by the upper-level application of the client, and the file operation interface matching the first file operation request is called. After program control based on locks and priorities, the first file operation request is sent to the protocol parsing controller, so that the protocol parsing controller encapsulates the first file operation request according to the preset protocol, generates a first message, and sends the first message to the server through the inter-core communication cache.

[0113] In this embodiment, if the server is in a non-idle state, the client can cache the first file operation request initiated by the upper-layer application and wait for the server to resume idle state before executing subsequent interface calls, protocol encapsulation and other steps.

[0114] After receiving the first message through the inter-core shared memory between the client and the server, the server first parses the first message according to the specified protocol to obtain the first file operation request, and then verifies the client's file operation permissions based on the parsed file operation request. If the verification passes, the underlying file system interface is called to implement file operation control, and the processing result of the operation request is returned to the client.

[0115] It should be noted that the process of returning the server processing results is opposite to the process of the operation request, but the functions of each step are basically the same. Ultimately, the processing result of the operation request is returned by the server to the upper-level application of the client, thereby completing the client's operation on the disk file.

[0116] This overall embodiment sets up the above series of reasonable and efficient file operation processes in multi-core devices, which can achieve high real-time and lightweight embedded inter-core remote file operations in embedded heterogeneous multi-core devices, and effectively solve the problem that some CPU cores cannot directly operate storage media for file management.

[0117] Based on the file operation method provided in the above embodiment, the present application also provides a file operation device corresponding to the above file operation method, and the file operation device is applied to a multi-core device. Figure 3 The file operation device of the present application is introduced in detail.

[0118] Figure 3 A schematic diagram of the structure of a file operation device provided in one embodiment of the present application is shown. Figure 3 The file operation device 300 shown includes:

[0119] A first receiving module 310 is used to receive a first file operation request, wherein the first file operation request is initiated by a target application;

[0120] The first processing module 320 is used to call the first file operation interface that matches the first file operation request, and send the first file operation request to the protocol parsing controller through program control based on locks and priorities, so that the protocol parsing controller encapsulates the first file operation request according to a preset protocol, generates a first message, and sends the first message to the server through the inter-core communication cache.

[0121] The file operation device of the embodiment of the present application receives a first file operation request initiated by a target application, then calls a file operation interface matching the first file operation request, and sends the first file operation request to a protocol parsing controller through program control based on locks and priorities, so that the protocol parsing controller encapsulates the first file operation request according to a preset protocol, generates a first message, and sends the first message to a server through an inter-core communication cache. Compared with the existing remote file system based on a network and communication protocol stack, a file operation device provided by the embodiment of the present application can effectively realize high real-time and lightweight embedded inter-core remote file operations of embedded heterogeneous multi-core devices by setting the above series of file request processing steps, thereby solving the problem that some CPU cores cannot directly operate storage media for file management.

[0122] In some possible implementations, in order to further realize the high real-time and lightweight embedded inter-core remote file operation of the embedded heterogeneous multi-core device, the above-mentioned sending the first message to the server through the inter-core communication cache may specifically include:

[0123] The first message is sent to the server through the inter-core shared memory.

[0124] In some possible implementations, considering that the client may include multiple applications, multiple applications may initiate corresponding file operation requests at the same time. Based on this, in order to effectively improve the efficiency and thread safety of the file operation process and improve the rationality of file operation processing, the above-mentioned calling of the file operation interface matching the first file operation request, through program control based on locks and priorities, sends the first file operation request to the protocol parsing controller, which may specifically include:

[0125] In the case of receiving multiple file operation requests initiated by N applications at the same time, calling a file operation interface matching a first file operation request, and allocating lock resources to the first file operation request based on preset priorities of the N applications;

[0126] Sending the first file operation request after the lock resource is allocated to the protocol parsing controller;

[0127] The N applications may include a target application, the multiple file operation requests may include a first file operation request, and the preset priority of the target application is the highest among the N applications.

[0128] In some possible implementations, considering that the client's access operation to a file often involves a coherent operation request to the same file, for example, after requesting to open a file, it is often necessary to read and write the file content. Based on this, in order to further improve the file operation efficiency between the server and the client, after sending the first message to the server through the inter-core communication cache, the file operation device may also include:

[0129] The second receiving module may be used to receive a target file descriptor associated with a target file sent by a server; the target file is a file requested to be operated by the first file operation request;

[0130] The first sending module may be used to send the second file operation request to the protocol parsing controller, so that the protocol parsing controller encapsulates the second file operation request according to the preset protocol, generates a second message, and sends the second message to the server through the inter-core communication cache; wherein the second operation request may include a target file descriptor; the second operation request is used to request to perform a second operation on the target file;

[0131] The first execution module can be used for the server to determine the target file based on the target file descriptor after receiving the second message, and to perform the second operation on the target file.

[0132] In some possible implementations, in order to more reasonably solve the problem that some CPU cores cannot directly operate the storage medium to perform file management, the first file operation request can be used to request to perform a first operation on the target file; the server establishes communication with the underlying file system of the multi-core device in advance; after sending the first message to the server through the inter-core communication cache, the file operation device may also include:

[0133] The second execution module can be used for the server to perform a first operation on the target file by controlling the underlying file system according to the first message.

[0134] In some possible implementations, in order to effectively ensure the security of file operations in an embedded heterogeneous multi-core device, the first file operation request may include identification information of the client where the target application is located; the second execution module may specifically include:

[0135] The server verifies the file operation authority of the client according to the identification information of the client, and if the file operation authority of the client passes the verification, the server performs the first operation on the target file by controlling the underlying file system.

[0136] In some possible implementations, in order to further improve the rationality of the overall inter-core file operation process, after sending the first message to the server through the inter-core communication cache, the file operation device may further include:

[0137] The detection module can be used for the protocol analysis controller to detect the response message if it receives the response message sent by the server within a preset time period;

[0138] The second processing module may be configured to discard the response message when it is detected that the response message does not match the first message; and

[0139] If no response message sent by the server is received within a preset time period, a processing failure result of the first file operation request is returned to the target application.

[0140] In some possible implementations, in order to more reasonably implement the file operation request transmission between the client and the server in the multi-core device, before sending the first file operation request to the protocol parsing controller, the file operation device may further include:

[0141] The file cache module can be used to cache the first file operation request when it is detected that the server is in a non-idle state; and when it is detected that the server has resumed an idle state, the cached first file operation request is processed according to the preset priority of the target application and the initiation time of the first file operation request, so that the first file operation request is sent to the protocol parsing controller.

[0142] In some possible implementations, in order to increase the effective load, the message protocol format of the first message may adopt a field combination form of a type field, a length field, and a value field;

[0143] The type field is filled with the message type, the length field is filled with the content length, and the value field is filled with the payload transmitted by the first message.

[0144] Figure 4 It is a structural diagram of a file operation device provided in one embodiment of the present application.

[0145] The file operation device may include a processor 401 and a memory 402 storing computer program instructions.

[0146] Specifically, the processor 401 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.

[0147] Memory 402 may include a large capacity memory for data or instructions. By way of example and not limitation, memory 402 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive or a combination of two or more of these. In appropriate cases, memory 402 may include a removable or non-removable (or fixed) medium. In appropriate cases, memory 402 may be inside or outside of an integrated gateway disaster recovery device. In a specific embodiment, memory 402 is a non-volatile solid-state memory.

[0148] The memory may include read-only memory (ROM), random access memory (RAM), magnetic disk storage media devices, optical storage media devices, flash memory devices, electrical, optical or other physical / tangible memory storage devices. Thus, typically, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to an aspect of the present disclosure.

[0149] The processor 401 implements any one of the file operation methods in the above embodiments by reading and executing the computer program instructions stored in the memory 402 .

[0150] In one example, the file operation device may further include a communication interface 403 and a bus 410. Figure 4 As shown, the processor 401, the memory 402, and the communication interface 403 are connected via a bus 410 and communicate with each other.

[0151] The communication interface 403 is mainly used to implement communication between various modules, devices, units and / or equipment in the embodiments of the present application.

[0152] Bus 410 includes hardware, software or both, and the parts of file operation equipment are coupled to each other. For example, but not limitation, bus may include accelerated graphics port (AGP) or other graphics bus, enhanced industrial standard architecture (EISA) bus, front side bus (FSB), hypertransport (HT) interconnection, industrial standard architecture (ISA) bus, infinite bandwidth interconnection, low pin count (LPC) bus, memory bus, micro channel architecture (MCA) bus, peripheral component interconnection (PCI) bus, PCI-Express (PCI-X) bus, serial advanced technology attachment (SATA) bus, video electronics standard association local (VLB) bus or other suitable bus or two or more of these combinations. In appropriate cases, bus 410 may include one or more buses. Although the present application embodiment describes and shows a specific bus, the present application considers any suitable bus or interconnection.

[0153] The file operation device executes the file operation method in the embodiment of the present application, thereby realizing Figure 1 Describes how to operate on files.

[0154] In addition, in combination with the file operation method in the above embodiment, the embodiment of the present application can provide a computer storage medium for implementation. The computer storage medium stores computer program instructions; when the computer program instructions are executed by a processor, any one of the file operation methods in the above embodiment is implemented.

[0155] It should be clear that the present application is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present application is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present application.

[0156] The functional blocks shown in the above-described block diagram can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present application are programs or code segments that are used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link by a data signal carried in a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio frequency (RF) links, etc. The code segment can be downloaded via a computer network such as the Internet, an intranet, etc.

[0157] It should also be noted that the exemplary embodiments mentioned in this application describe some methods or systems based on a series of steps or devices. However, this application is not limited to the order of the above steps, that is, the steps can be performed in the order mentioned in the embodiment, or in a different order from the embodiment, or several steps can be performed simultaneously.

[0158] Aspects of the present disclosure are described above with reference to the flowchart and / or block diagram of the method, device (system) and computer program product according to the embodiment of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device to produce a machine so that these instructions executed by the processor of the computer or other programmable data processing device enable the implementation of the function / action specified in one or more boxes of the flowchart and / or block diagram. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field programmable logic circuit. It can also be understood that each box in the block diagram and / or flowchart and the combination of boxes in the block diagram and / or flowchart can also be implemented by dedicated hardware that performs a specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions.

[0159] The above is only a specific implementation of the present application. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes of the systems, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. It should be understood that the protection scope of the present application is not limited to this. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in this application, and these modifications or replacements should be included in the protection scope of this application.

Claims

1. A file operation method, characterized in that: Applied to a multi-core device, the method comprises: receiving a first file operation request, wherein the first file operation request is initiated by a target application; Calling a file operation interface that matches the first file operation request, and sending the first file operation request to a protocol parsing controller through lock and priority-based program control, so that the protocol parsing controller encapsulates the first file operation request according to a preset protocol, generates a first message, and sends the first message to a server through an inter-core communication cache; The sending the first message to the server through the inter-core communication cache includes: Sending the first message to the server through the inter-core shared memory; The first file operation request is used to request to perform a first operation on a target file; the server establishes communication with the underlying file system of the multi-core device in advance; after the first message is sent to the server through the inter-core communication cache, the method further includes: The server performs the first operation on the target file by controlling the underlying file system according to the first message; The first file operation request includes identification information of the client where the target application is located; the server performs the first operation on the target file by controlling the underlying file system according to the first message, including: The server verifies the file operation authority of the client according to the identification information of the client, and if the file operation authority of the client passes the verification, performs the first operation on the target file by controlling the underlying file system.

2. The method according to claim 1, characterized in that The calling of the file operation interface matching the first file operation request, and sending the first file operation request to the protocol analysis controller through program control based on locks and priorities, includes: In the case of receiving multiple file operation requests initiated by N applications at the same time, calling a file operation interface matching the first file operation request, and allocating lock resources to the first file operation request based on preset priorities of the N applications; Sending the first file operation request after the lock resource is allocated to the protocol parsing controller; The N applications include the target application, the multiple file operation requests include the first file operation request, and the preset priority of the target application is the highest among the N applications.

3. The method according to claim 1, characterized in that After sending the first message to the server through the inter-core communication cache, the method further includes: receiving a target file descriptor associated with a target file sent by the server; the target file is a file requested to be operated by the first file operation request; Sending a second file operation request to a protocol parsing controller, so that the protocol parsing controller encapsulates the second file operation request according to a preset protocol, generates a second message, and sends the second message to the server through an inter-core communication cache; wherein the second operation request includes the target file descriptor; and the second operation request is used to request to perform a second operation on the target file; After receiving the second message, the server determines the target file based on the target file descriptor and performs the second operation on the target file.

4. The method according to claim 1, characterized in that: After sending the first message to the server through the inter-core communication cache, the method further includes: If the protocol analysis controller receives a response message sent by the server within a preset time period, it detects the response message, and discards the response message if it is detected that the response message does not match the first message; and If no response message sent by the server is received within the preset time period, a processing failure result of the first file operation request is returned to the target application.

5. The method according to claim 1, characterized in that Before sending the first file operation request to the protocol parsing controller, the method further includes: When it is detected that the server is in a non-idle state, the first file operation request is cached; and when it is detected that the server has resumed an idle state, the cached first file operation request is processed according to the preset priority of the target application and the initiation time of the first file operation request, so that the first file operation request is sent to the protocol parsing controller.

6. The method according to claim 1, characterized in that The message protocol format of the first message adopts a field combination form of a type field, a length field, and a value field; Among them, the type field is filled with the message type, the length field is filled with the content length, and the value field is filled with the payload transmitted by the first message.

7. A file operation device, characterized in that: Applied to a multi-core device, the device comprises: A first receiving module, configured to receive a first file operation request, wherein the first file operation request is initiated by a target application; a first processing module, configured to call a first file operation interface matching the first file operation request, and send the first file operation request to a protocol parsing controller through program control based on locks and priorities, so that the protocol parsing controller encapsulates the first file operation request according to a preset protocol, generates a first message, and sends the first message to a server through an inter-core communication cache; The sending the first message to the server through the inter-core communication cache includes: Sending the first message to the server through the inter-core shared memory; The first file operation request is used to request to perform a first operation on a target file; the server establishes communication with the underlying file system of the multi-core device in advance; after sending the first message to the server through the inter-core communication cache, the file operation device also includes: A second execution module, configured for the server to execute the first operation on the target file by controlling the underlying file system according to the first message; The first file operation request includes identification information of the client where the target application is located; the server performs the first operation on the target file by controlling the underlying file system according to the first message, including: The server verifies the file operation authority of the client according to the identification information of the client, and if the file operation authority of the client passes the verification, performs the first operation on the target file by controlling the underlying file system.

Citation Information

Patent Citations

  • Heterogeneous multi-core remote embedded memory system and method

    CN105302489A