A data synchronization method, file access client and metadata service
By automatically triggering status change indicators during file operations, local data refresh and operation retry are achieved, solving the problem of opacity in file access clients in existing technologies, reducing business logic coupling, and ensuring data consistency and transparency.
Patent Information
- Application Number
- CN202611694910.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-30
- Publication Date
- 2026-11-27
AI Technical Summary
In existing technologies, when file access clients detect inconsistencies in the storage status of remote objects, they cannot automatically clean up the local cache and refresh the metadata, resulting in strong coupling between business logic and the underlying storage implementation, and the refresh process is not transparent to upper-layer applications.
By automatically triggering local data refresh and operation retry through status change indicators generated during file operations, the file content data is cleared and metadata is refreshed, and the operations are integrated into the same file operation call chain, avoiding the need for upper-layer applications to be aware of status change indicators.
This reduces the coupling between business logic and underlying storage, ensures transparent processing by upper-layer applications, avoids the mixing of old and new remote state data, and ensures that local files gradually converge to the current state of the remote object.
Smart Images

Figure CN123178358A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to a data synchronization method, a file access client, and a metadata service. Background Technology
[0002] In distributed file systems, to improve the performance of accessing remote object storage, files in the remote object storage are typically mapped to or imported into the local file system, and file metadata and file content data are cached locally. The locally cached file metadata includes a status identifier for the remote object, identifying the version of the remote object corresponding to the local cache. When a file access client initiates a file operation request for a target file, it includes this status identifier as the target status identifier in the request, enabling consistency checks when accessing the remote object storage is required.
[0003] In existing technologies, when a data access component detects a file operation request that needs to access remote object storage, it retrieves the current state identifier from the remote object storage and compares it with the target state identifier carried in the request. If the two are inconsistent, a state change indication is returned to the file access client. However, this solution can only perform inconsistency detection and cannot restore the local state. The file access client directly returns the state change indication to the upper-layer application, which needs to be aware of the indication and manually perform local cache cleanup, metadata refresh, and retry of the original operation. This results in strong coupling between business logic and the underlying storage implementation, and the refresh process is not transparent to the business logic. Summary of the Invention
[0004] This application is made in view of at least one of the above-mentioned technical problems existing in the prior art, and the application enables upper-layer applications to be unaware of processes such as updating cache.
[0005] In a first aspect, embodiments of this application provide a data synchronization method applied to a file access client, comprising: Send a file operation request for the target file to the data access component; wherein, the file operation request carries a target status identifier of the target file cached locally, and the file operation request is used to enable the data access component to recognize that the file operation request needs to access the remote object storage, obtain a first status identifier from the remote object storage, and return a status change indication to the file access client when the first status identifier is inconsistent with the target status identifier. In response to the status change indication, a refresh request carrying the target file identifier and the target status identifier is sent to the metadata service; wherein, the refresh request is used to instruct the metadata service to clear the file content data of the target file cached locally, and obtain the second status identifier from the remote object storage; Receive the second status identifier returned by the metadata service; Based on the second status identifier, update the metadata of the target file in the local cache, and based on the updated metadata of the target file, perform the following steps: send a file operation request for the target file to the data access component.
[0006] Secondly, embodiments of this application provide a data synchronization method applied to metadata services, including: Receive a refresh request for a target file sent by a file access client, the refresh request carrying the target file identifier and the target status identifier of the target file; In response to the refresh request, the data access component is instructed to clear the file content data of the target file cached locally and obtain a second status identifier from the remote object storage; Receive the second status identifier returned by the data access component; The second status identifier is returned to the file access client, so that the file access client updates the metadata of the target file in its local cache based on the second status identifier, and resends the file operation request for the target file to the data access component.
[0007] Thirdly, embodiments of this application provide a file access client, including: The first sending module is configured to send a file operation request for a target file to a data access component; wherein the file operation request carries a target status identifier of the target file cached locally, and the file operation request is used to enable the data access component to recognize that the file operation request needs to access remote object storage, obtain a first status identifier from the remote object storage, and return a status change indication to the file access client when the first status identifier is inconsistent with the target status identifier; in response to the status change indication, a refresh request carrying the target file identifier and the target status identifier is sent to the metadata service; wherein the refresh request is used to enable the metadata service to instruct the data access component to clear the file content data of the target file cached locally, and obtain a second status identifier from the remote object storage; The first receiving module is configured to receive the second status identifier returned by the metadata service; The update module is configured to update the metadata of the target file in the local cache based on the second status identifier, and to perform the following steps based on the updated metadata of the target file: sending a file operation request for the target file to the data access component.
[0008] Fourthly, embodiments of this application provide a metadata service, including: The second receiving module is configured to receive a refresh request for a target file sent by a file access client. The refresh request carries a target file identifier and a target status identifier of the target file. The processing module is configured to, in response to the refresh request, instruct the data access component to clear the file content data of the target file cached locally, and obtain a second status identifier from the remote object storage; and receive the second status identifier returned by the data access component. The second sending module is configured to return the second status identifier to the file access client, so that the file access client updates the metadata of the target file in its local cache based on the second status identifier, and resends the file operation request for the target file to the data access component.
[0009] This application provides a data synchronization method, a file access client, and a metadata service. By transforming state change indicators generated during file operations into trigger signals for local data refresh and operation retry, this application automatically clears locally cached file content data, refreshes metadata, and retryes the original file operation within the same file operation call chain. The entire process is transparent to upper-layer applications, which do not need to be aware of state change indicators or perform cache clearing and retries themselves, thus reducing the coupling between business logic and the underlying storage implementation. Furthermore, this method is triggered on demand: refresh is only performed when a file operation requires access to remote object storage and detects a state inconsistency; operations completely satisfied by locally loaded data do not require additional remote access. In addition, by clearing all local file content data of the target file and reverting the file to a data-unloaded state, the problem of mixing old and new remote state data is avoided, ensuring that subsequent on-demand loaded data is based on the updated state identifier, allowing the local file to gradually converge to the current state of the remote object. Attached Figure Description
[0010] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0011] Figure 1 This application provides a data synchronization method for a file access client, as one embodiment of the present application. Figure 2 This application provides a data synchronization method for metadata services, as exemplified by one embodiment of the present application. Figure 3 This is a schematic diagram of a file access client provided in one embodiment of this application; Figure 4 This is a metadata service provided in one embodiment of this application. Detailed Implementation
[0012] To enable those skilled in the art to better understand the technical solutions of the embodiments of this application, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0013] like Figure 1 As shown in the figure, this application provides a data synchronization method applied to a file access client, including: Step 101: Send a file operation request for the target file to the data access component; wherein, the file operation request carries the target status identifier of the target file cached locally. The file operation request is used to enable the data access component to recognize that when the file operation request needs to access the remote object storage, obtain the first status identifier from the remote object storage, and return a status change indication to the file access client when the first status identifier is inconsistent with the target status identifier.
[0014] File access clients can be file system clients running in the user space or kernel space of the operating system, or local proxy modules of object storage gateways, etc.
[0015] The file operation request carries a target status identifier for the target file cached locally. The file operation request can be a read operation request, write operation request, truncation operation request, or other file access operation request. The target status identifier is used to identify the version of the remote object corresponding to the local cache. In one implementation, the target status identifier is an entity tag provided by the remote object storage. In other implementations, the target status identifier can also be a version number, content hash value, timestamp, or other identifying information that can distinguish different states of the remote object. The target status identifier cached locally can be recorded in the local file metadata during data import, or it can be obtained from the metadata service and cached when the file is first opened.
[0016] The data access component can be a standalone data access process, a cache management module, or a data broker integrated with the file access client. The data access component is responsible for interacting with remote object storage and maintaining a cache of local file content data.
[0017] Upon receiving a file operation request, the data access component determines whether the request requires access to remote object storage. This determination can be based on whether the data range involved in the file operation request has been loaded into the local cache. If the local cache misses, the data needs to be retrieved from the remote object storage. In other implementations, the determination of whether to access remote object storage can also be based on the file operation type, local data validity flags, or caching strategies.
[0018] When accessing remote object storage is required, the data access component retrieves a first state identifier from the remote object storage. This first state identifier is the currently recorded state identifier in the remote object storage, used to identify the current version of the target file. The data access component compares the first state identifier with the target state identifier carried in the request. If they match, it means the version of the remote object corresponding to the local cache has not changed, and the data access component continues to perform the original file operation; if they do not match, it means the remote object has changed, the data access component stops this remote data access and returns a state change indication to the file access client.
[0019] In one implementation, the status change indicator is a preset error code. In other implementations, the status change indicator may also be an exception message, a callback notification, a status flag, or other signal that can convey the message "remote status has changed" to the file access client.
[0020] Step 102: In response to the state change indication, send a refresh request carrying the target file identifier and the target state identifier to the metadata service; wherein, the refresh request is used to instruct the metadata service to clear the file content data of the target file in the local cache and obtain the second state identifier from the remote object storage.
[0021] Upon receiving a status change indication, the file access client does not directly return the indication to the upper-layer application. Instead, it uses it as a refresh trigger signal. The file access client sends a refresh request to the metadata service. The refresh request carries the target file identifier and the target status identifier. The target file identifier is used to uniquely identify the target file, such as a file path, object key name, or other identifying information. The target status identifier is the local status identifier used by the file access client when triggering this status change indication.
[0022] A refresh request instructs the metadata service to tell the data access component to clear the target file's locally cached file content data and retrieve a second status identifier from remote object storage. The metadata service can be a centralized metadata server, a distributed metadata cluster, or a metadata management module integrated with the file access client. The metadata service maintains the target file's metadata, including status identifiers, file length, and other information.
[0023] Clearing the target file's locally cached file content data preferably includes clearing all locally stored file content data, reverting the target file to a state where only metadata is retained and the data is not loaded. All file content data includes cached data loaded from the remote object store and locally modified data. The reason for using full file cleanup instead of partial cleanup is that different local data ranges may all originate from the old remote object and may contain local modifications. Replacing only the data range that caused the error may result in a single file containing data corresponding to both the old and new remote states. After clearing all local file content data, subsequent data is retrieved as needed based on the updated state identifier, allowing the file to gradually converge to the current state of the remote object.
[0024] Step 103: Receive the second status identifier returned by the metadata service.
[0025] The second status identifier is the latest status identifier of the target file, which the data access component retrieves from the remote object storage. After the data access component successfully clears the local file content data and obtains the second status identifier, the metadata service returns the second status identifier to the file access client.
[0026] Step 104: Update the metadata of the target file in the local cache based on the second status identifier, and perform the following steps based on the updated metadata of the target file: send a file operation request for the target file to the data access component.
[0027] After receiving the second status identifier, the file access client uses it to update the metadata of the target file in its local cache, such as updating the status identifier in the file operation context. Once the update is complete, the file access client, based on the updated metadata, resends the file operation request for the target file to the data access component. Since the locally cached file content data has been cleared, the resent file operation request will trigger the data access component to reload the data from the remote object storage on demand. At this point, the status identifier obtained by the data access component from the remote storage is consistent with the updated target status identifier, so no status change indication will be returned again, and the original file operation is successfully executed.
[0028] This application transforms state change indicators generated during file operations into trigger signals for local data refresh and operation retries. Within the same file operation call chain, it automatically clears locally cached file content data, refreshes metadata, and retries the original file operation. The entire process is transparent to upper-layer applications, which do not need to be aware of state change indicators or perform cache clearing and retries themselves, thus reducing the coupling between business logic and the underlying storage implementation. Furthermore, this method is triggered on demand: refresh is only performed when a file operation requires access to remote object storage and detects a state inconsistency; operations entirely satisfied by locally loaded data do not require additional remote access. In addition, by clearing all local file content data of the target file and reverting the file to a data-unloaded state, the problem of mixing old and new remote state data is avoided, ensuring that subsequent on-demand loaded data is based on the updated state identifier, allowing the local file to gradually converge to the current state of the remote object.
[0029] In one embodiment of this application, before sending a refresh request carrying the target file identifier to the metadata service, the method further includes: Determine whether a refresh request for the target file has been sent to the metadata service. If so, return a status change indication to the upper-layer application. Otherwise, perform the following steps: send a refresh request carrying the target file identifier to the metadata service.
[0030] Specifically, a "refresh request for the target file" refers to a refresh request for the same target file triggered by the current upper-level file operation. The file access client can determine whether a refresh request has been sent in several ways. In one implementation, when the file access client first sends a refresh request, it sets a refresh flag in its local operation context, which is associated with the current file operation request. When it receives a status change indication again, the file access client checks the refresh flag: if the flag indicates that it has been triggered, it determines that a refresh request has been sent; if the flag indicates that it has not been triggered, it determines that a refresh request has not been sent.
[0031] The purpose of this judgment step is to limit the number of times the transparent refresh and retry process is triggered, preventing the file access client from getting stuck in an infinite recursive refresh loop due to repeated changes to the remote object in a short period of time. For example, if the data access component returns a status change indication again after the first refresh and retry of the original file operation, the file access client can determine through this judgment step that a refresh request has already been sent, and therefore will not initiate a new refresh, but will directly return the status change indication to the upper layer application, terminating the current processing flow.
[0032] In one embodiment of this application, the file operation request is one of a read operation request, an unaligned write operation request, a partial overwrite write operation request, or a truncation operation request; the unaligned write request or the partial overwrite write request requires access to the baseline data in the remote object storage when it is executed.
[0033] A read operation request is used to read a specified range of data from a target file. When the specified range of data has already been loaded from the local cache, the file access client can read it directly from the local cache without accessing the remote object storage, and therefore, no comparison of the remote state flag is triggered in this read operation. When the specified range of data has not yet been loaded from the local cache, the data access component needs to fetch the corresponding data from the remote object storage.
[0034] An unaligned write operation request refers to a write operation where the data range involved is not aligned with the boundary of the remote object's storage block, or the write offset is not an integer multiple of the storage block size. Such unaligned write operations cannot be completed based solely on the data being written. It is necessary to first retrieve existing data at the corresponding location from the remote object storage as reference data, merge the data being written with the reference data, and then form a complete block of data to write back to the remote object storage.
[0035] A partial overwrite write operation request refers to a write operation that only overwrites a portion of the target file's content, rather than replacing the entire remote object. This type of partial overwrite write operation requires first reading existing data within the corresponding range of the remote object as baseline data, merging the modified portion with the baseline data, and then writing it back to ensure that the unmodified data remains unchanged.
[0036] A truncation request is used to truncate the target file to a specified length. Truncation operations may involve modifying the metadata of the remote object, or may require accessing the remote object storage to obtain the current file length or the data needed for truncation.
[0037] For read and truncation requests, the decision to perform a state flag comparison is based on whether a remote object storage access is actually required, avoiding unnecessary remote accesses for operations that can be satisfied entirely by local data. For aligned append write operations that do not require access to remote baseline data, it is explicitly stated that a state flag comparison can be avoided, thus preventing unnecessary remote verification overhead and improving system performance.
[0038] like Figure 2 As shown in the figure, this application provides a data synchronization method applied to metadata services, including: Step 201: Receive a refresh request for the target file sent by the file access client. The refresh request carries the target file identifier and the target status identifier of the target file.
[0039] Metadata services can be centralized metadata servers, distributed metadata clusters, or metadata management modules integrated with file access clients. The metadata service maintains the metadata of the target file, including information such as status identifiers and file length.
[0040] A refresh request is a request sent by a file access client in response to a status change indication returned by the data access component. The refresh request carries a target file identifier and a target status identifier for the target file. The target file identifier is used to uniquely identify the target file, such as a file path, object key name, or other identifying information. The target status identifier is the local status identifier used by the file access client when this status change indication was triggered. In one implementation, the refresh request may also carry other information, such as the type of operation that triggered the refresh, the identifier of the file operation request, or the identifier of the file access client, to enable more granular concurrency control and logging by the metadata service.
[0041] Step 202: In response to the refresh request, instruct the data access component to clear the file content data of the target file cached locally, and obtain the second status identifier from the remote object storage.
[0042] Upon receiving a refresh request, the metadata service sends an instruction to the data access component. This instruction instructs the data access component to perform two operations: first, clear the file content data of the target file from its local cache; and second, retrieve a second status identifier from the remote object storage.
[0043] Clearing the file content data of the target file cached locally, preferably includes clearing all file content data of the target file stored locally, so that the target file reverts to a state where only the metadata is retained and the data is not loaded.
[0044] Retrieving the second status identifier from remote object storage refers to the data access component re-querying the current status identifier of the target file from the remote object storage after clearing the local file content data. The second status identifier is a status identifier currently recorded in the remote object storage that identifies the current version of the target file.
[0045] Step 203: Receive the second status identifier returned by the data access component.
[0046] After clearing the local file content data and obtaining the second status identifier, the data access component returns the execution result to the metadata service. If both clearing and obtaining are successful, the data access component returns the second status identifier to the metadata service. In one implementation, the data access component also returns the file length. If clearing or obtaining fails, the data access component returns a failure indication to the metadata service. Upon receiving the failure indication, the metadata service terminates the current refresh process, releases the target file lock, and returns an error message to the file access client. If partial failure occurs during the clearing process, the data access component should mark the entire cached file content data of the target file as unavailable to prevent subsequent file operations from continuing to use the old data remaining after the cleanup failure.
[0047] Step 204: Return a second status identifier to the file access client so that the file access client updates the metadata of the target file in the local cache based on the second status identifier and resends the file operation request for the target file to the data access component.
[0048] After receiving the second status identifier from the data access component, the metadata service returns it to the file access client. In one implementation, the metadata service also returns the file length simultaneously. The purpose of the metadata service returning the second status identifier to the file access client is to enable the file access client to update its locally cached metadata based on this identifier and then resend the file operation request for the target file to the data access component based on the updated metadata. Since the file content data of the target file in the local cache has been cleared, the resent file operation request will trigger the data access component to reload the data from the remote object storage on demand. At this time, the status identifier obtained by the data access component from the remote storage is consistent with the updated target status identifier, so no status change indication will be returned again, and the original file operation is successfully executed.
[0049] By returning a second state identifier to the file access client, the file access client can update its locally cached metadata and resend the file operation request, thus forming a complete closed loop with the methods on the file access client side. By clearing all local file content data of the target file and reverting the file to a data-unloaded state, the problem of mixing old and new remote state data is avoided, ensuring that subsequent data loaded on demand is based on the updated state identifier, allowing the local file to gradually converge to the current state of the remote object.
[0050] In one embodiment of this application, in response to a refresh request, before instructing the data access component to clear the file content data of the target file cached locally, the method further includes: Lock the target file; Before returning a second status flag to the file access client, the following is also included: Update the target file's metadata based on the second state identifier, and release the target file's lock.
[0051] Locking a target file means that the metadata service sets a lock flag in the target file's metadata to prevent other operations from concurrently modifying the target file during the refresh process. The locking scope is limited to the target file itself and does not affect concurrent access to other files in the same directory or other files in the same storage mapping relationship.
[0052] The purpose of setting this locking timing is to ensure that the entire refresh process, from clearing local file content data to updating the target file metadata, is not interfered with by other file operations or refresh requests targeting the target file. Without locking, during the clearing of local file content data, other file operations may access the target file, causing these operations to be performed based on partially cleared data, resulting in unexpected results; or other refresh requests may be triggered simultaneously, leading to duplicate cleanup and updates, wasting system resources.
[0053] Updating the target file's metadata based on the second status identifier means that after receiving the second status identifier returned by the data access component, the metadata service updates the status identifier recorded in the target file's metadata to the second status identifier.
[0054] By locking the target file before instructing the data access component to clear the file content data cached locally, the entire refresh process from clearing local data to updating metadata is ensured to be free from interference by other file operations or refresh requests targeting the target file, thus guaranteeing the atomicity and consistency of the refresh operation.
[0055] In one embodiment of this application, after locking the target file, the method further includes: Compare the target status identifier with the status identifier currently recorded in the target file's metadata; In response to both being identical, the following steps are executed: instruct the data access component to clear the file content data of the target file cached locally; In response to the difference between the two, the current status identifier of the target file's metadata is used as the second status identifier.
[0056] If the target status identifier is the same as the status identifier currently recorded in the target file's metadata, it means that the status identifier recorded in the metadata service has not been updated by other refresh tasks since the file access client obtained the target status identifier. At this time, this refresh request is the first request to trigger a refresh, and the metadata service continues to execute the following steps: instructing the data access component to clear the file content data of the target file cached locally, and obtaining the second status identifier from the remote object storage.
[0057] If the target status identifier differs from the status identifier currently recorded in the target file's metadata, it means that other concurrent refresh tasks have already completed refreshing the same target file before this refresh request arrived, updating the status identifier recorded in the metadata service to the new status identifier. In this case, the metadata service no longer performs data cleanup repeatedly; instead, it directly uses the status identifier currently recorded in the target file's metadata as the second status identifier and returns it to the file access client. This way, subsequent refresh requests do not need to clear the locally cached file content data again, nor do they need to retrieve the status identifier from remote object storage again, thus avoiding duplicate cleanup and duplicate network access.
[0058] In one embodiment of this application, the method further includes: Receive change events for the target file sent by the object storage event subscription service; In response to a change event, the following steps are performed: lock the target file, instruct the data access component to clear the file content data of the target file cached locally, obtain a second state identifier from the remote object storage, update the metadata of the target file based on the second state identifier, and release the lock on the target file.
[0059] The object storage event subscription service is a service component used to subscribe to object change events in remote object storage. When a remote object changes—for example, when the object is overwritten, replaced, deleted, or its metadata is modified—the object storage event subscription service generates a change event for the target file and sends this event to the metadata service. The change event must contain at least a target file identifier so that the metadata service can determine the target file that needs to be processed.
[0060] In response to a change event, the metadata service performs the following steps: First, it locks the target file. The locking operation is the same as the locking operation described above in response to a refresh request, used to prevent concurrent modifications to the target file by other operations during event processing. Second, it instructs the data access component to clear the file content data cached locally for the target file. The clearing operation preferably includes clearing all file content data stored locally for the target file, causing the target file to revert to a state where only metadata is retained and the data is not loaded. Third, it retrieves a second state identifier from the remote object storage. The second state identifier is a state identifier currently recorded in the remote object storage, used to identify the current version of the target file. Then, it updates the metadata of the target file based on the second state identifier. Finally, it releases the lock on the target file. These steps are completely consistent with the steps performed in response to a refresh request; that is, the two triggering channels reuse the same file-level locking, data cleanup, and metadata update paths, only the triggering source differs.
[0061] In this embodiment of the application, by receiving change events sent by the object storage event subscription service, the metadata service can proactively handle changes to remote objects. Even if the target file is not accessed by any file access client, it can promptly clear the locally cached file content data and update the metadata, thereby improving the system's proactivity and data consistency.
[0062] In one embodiment of this application, after receiving a refresh request for a target file sent by a file access client, the method further includes: Read the configuration items corresponding to the directory to which the target file belongs, which indicate whether the remote data priority function is enabled; In response to a configuration item indicating that remote data priority is not enabled, a dynamic refresh is not supported indication is returned to the file access client, so that the file access client returns a status change indication to the upper layer application. In response to a configuration item indicating that remote data priority is enabled, the following steps are performed: In response to a refresh request, the data access component is instructed to clear the file content data of the target file cached locally and obtain a second status identifier from the remote object storage.
[0063] Configuration items are parameters or flags used to indicate whether the remote data priority feature is enabled. Configuration items can be stored in the metadata service's configuration file, database, in-memory data structure, or in a separate configuration center that can communicate with the metadata service.
[0064] The configuration granularity of the configuration item is the directory to which the target file belongs. That is, the metadata service manages whether the remote data priority feature is enabled on a directory-by-directory basis. In one implementation, when the configuration item corresponding to a directory indicates that the remote data priority feature is enabled, all files in that directory have the remote data priority feature enabled; when the configuration item corresponding to that directory indicates that the remote data priority feature is not enabled, all files in that directory do not have the remote data priority feature enabled. In another implementation, the configuration granularity can also be a storage mapping relationship.
[0065] The configuration items corresponding to the directory to which the target file belongs can be read. This can be executed immediately after the metadata service receives the refresh request, or before or after the metadata service locks the target file.
[0066] In response to a configuration item indicating that remote data priority is not enabled, a "dynamic refresh not supported" indication is returned to the file access client, prompting the file access client to return a status change indication to the upper-layer application. Specifically, when the configuration item indicates that remote data priority is not enabled, the metadata service does not perform data cleanup and metadata update operations, but instead returns a "dynamic refresh not supported" indication to the file access client. This indication informs the file access client that the directory containing the current target file does not have remote data priority enabled, and the metadata service cannot perform dynamic refresh. Upon receiving this indication, the file access client no longer attempts to trigger the refresh process but instead returns the status change indication to the upper-layer application according to the original processing method. Therefore, in directories where remote data priority is not enabled, the system maintains the original error handling behavior, and the upper-layer application needs to handle remote status change errors itself. This setting allows remote data priority to be flexibly enabled based on directory or storage mapping relationships. After upgrading from the current version, this feature can be enabled only for the specified data import directory without affecting the original behavior of other directories.
[0067] In response to a configuration setting indicating that remote data priority is enabled, the following steps are executed: In response to a refresh request, the data access component is instructed to clear the locally cached file content data of the target file and retrieve a second status identifier from the remote object storage. Specifically, when the configuration setting indicates that remote data priority is enabled, the metadata service continues to execute the aforementioned steps, i.e., instructing the data access component to clear the locally cached file content data of the target file and retrieve a second status identifier from the remote object storage. Subsequently, the service receives the second status identifier returned by the data access component and returns it to the file access client. Thus, in directories where remote data priority is enabled, the system performs a transparent refresh and retry process, remaining transparent to upper-layer applications.
[0068] This application embodiment reads the configuration items corresponding to the directory to which the target file belongs. The metadata service can flexibly decide whether to execute the transparent refresh process based on the configuration, realizing the on-demand activation and fine-grained control of the remote data priority function.
[0069] like Figure 3 As shown, this application embodiment provides a file access client, including: The first sending module 301 is configured to send a file operation request for a target file to a data access component. The file operation request carries a target status identifier of the target file cached locally. The file operation request enables the data access component to recognize that the file operation request requires access to remote object storage, retrieve a first status identifier from the remote object storage, and return a status change indication to the file access client when the first status identifier is inconsistent with the target status identifier. In response to the status change indication, a refresh request carrying the target file identifier and the target status identifier is sent to the metadata service. The refresh request enables the metadata service to instruct the data access component to clear the file content data of the target file cached locally and retrieve a second status identifier from the remote object storage. The first receiving module 302 is configured to receive the second status identifier returned by the metadata service; The update module 303 is configured to update the metadata of the target file in the local cache based on the second status identifier, and performs the following steps based on the updated metadata of the target file: sending a file operation request for the target file to the data access component.
[0070] In one embodiment of this application, the first sending module 301 is configured to determine whether a refresh request for the target file has been sent to the metadata service. If so, it returns a status change indication to the upper-layer application; otherwise, it executes the step of sending a refresh request carrying the target file identifier to the metadata service.
[0071] like Figure 4 As shown, this application embodiment provides a metadata service, including: The second receiving module 401 is configured to receive a refresh request for a target file sent by a file access client. The refresh request carries the target file identifier and the target status identifier of the target file. Processing module 402 is configured to, in response to a refresh request, instruct the data access component to clear the file content data of the target file cached locally and obtain a second status identifier from the remote object storage; and receive the second status identifier returned by the data access component. The second sending module 403 is configured to return a second status identifier to the file access client, so that the file access client updates the metadata of the target file in the local cache based on the second status identifier and resends the file operation request for the target file to the data access component.
[0072] In one embodiment of this application, the processing module 402 is configured to lock the target file; update the metadata of the target file based on the second status identifier; and release the lock on the target file.
[0073] In one embodiment of this application, the processing module 402 is configured to compare the target status identifier with the status identifier of the target file's metadata currently recorded; in response to the two being the same, the following steps are performed: instructing the data access component to clear the file content data of the target file cached locally; in response to the two being different, using the status identifier of the target file's metadata currently recorded as the second status identifier.
[0074] In one embodiment of this application, the processing module 402 is configured to receive a change event for a target file sent by the object storage event subscription service; in response to the change event, the following steps are performed: locking the target file, instructing the data access component to clear the file content data of the target file cached locally, obtaining a second status identifier from the remote object storage, updating the metadata of the target file based on the second status identifier, and releasing the lock on the target file.
[0075] In one embodiment of this application, the processing module 402 is configured to read the configuration item corresponding to the directory to which the target file belongs, which indicates whether the remote data priority function is enabled; in response to the configuration item indicating that the remote data priority function is not enabled, it returns an indication that dynamic refresh is not supported to the file access client, so that the file access client returns a status change indication to the upper layer application; in response to the configuration item indicating that the remote data priority function is enabled, it performs the following steps: in response to a refresh request, it instructs the data access component to clear the file content data of the target file cached locally, and obtains a second status identifier from the remote object storage.
[0076] This application provides an electronic device, including a memory and a processor. The memory stores an executable program, and the processor executes the executable program to perform the steps of the methods described in any of the above embodiments.
[0077] This application provides a computer program product that, when executed by a processor, implements the methods of any of the above embodiments.
[0078] It should be understood that in the embodiments of this application, the processor may be a central processing unit (CPU), or it may be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0079] It should also be understood that the memory mentioned in the embodiments of the present invention can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. Specifically, non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDR SDRAM), Enhanced Synchronous DRAM (ESDRAM), Synchlink DRAM (SLDRAM), and Direct Rambus RAM (DR RAM).
[0080] It should be noted that when the processor is a general-purpose processor, DSP, ASIC, FPGA, or other programmable logic device, discrete gate or transistor logic device, or discrete hardware component, the memory (storage module) is integrated into the processor.
[0081] It should be noted that the memories described herein are intended to include, but are not limited to, these and any other suitable types of memories.
[0082] In addition to the data bus, this bus may also include a power bus, a control bus, and a status signal bus. However, for clarity, all buses are labeled "bus" in the diagram.
[0083] It should also be understood that the first, second, third, fourth and various numerical designations used herein are merely for descriptive convenience and are not intended to limit the scope of this application.
[0084] It should be understood that the term "and / or" in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this article generally indicates that the preceding and following related objects have an "or" relationship.
[0085] In implementation, each step of the above method can be completed by integrated logic circuits in the processor's hardware or by instructions in software. The steps of the method disclosed in the embodiments of this application can be directly implemented by a hardware processor, or by a combination of hardware and software modules in the processor. The software modules can reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. This storage medium is located in memory, and the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above method. To avoid repetition, detailed descriptions are omitted here.
[0086] In the various embodiments of this application, the order of the above-mentioned processes does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0087] Those skilled in the art will recognize that the various illustrative logical blocks (ILBs) and steps described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this application.
[0088] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0089] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0090] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0091] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive), etc.
[0092] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A data synchronization method, characterized in that, Applied to file access clients, including: Send a file operation request for the target file to the data access component; wherein, the file operation request carries a target status identifier of the target file cached locally, and the file operation request is used to enable the data access component to recognize that the file operation request needs to access the remote object storage, obtain a first status identifier from the remote object storage, and return a status change indication to the file access client when the first status identifier is inconsistent with the target status identifier. In response to the status change indication, a refresh request carrying the target file identifier and the target status identifier is sent to the metadata service; wherein, the refresh request is used to instruct the metadata service to clear the file content data of the target file cached locally, and obtain the second status identifier from the remote object storage; Receive the second status identifier returned by the metadata service; Based on the second status identifier, update the metadata of the target file in the local cache, and based on the updated metadata of the target file, perform the following steps: send a file operation request for the target file to the data access component.
2. The method as described in claim 1, characterized in that, Before sending a refresh request carrying the target file identifier to the metadata service, the following steps are also included: Determine whether a refresh request for the target file has been sent to the metadata service. If yes, return the status change indication to the upper-layer application. Otherwise, execute the following steps: send a refresh request carrying the target file identifier to the metadata service.
3. The method as described in claim 1, characterized in that, The file operation request is one of the following: a read operation request, an unaligned write operation request, a partial overwrite write operation request, or a truncation operation request; the unaligned write request or the partial overwrite write request needs to access the baseline data in the remote object storage when it is executed.
4. A data synchronization method, characterized in that, Applied to metadata services, including: Receive a refresh request for a target file sent by a file access client, the refresh request carrying the target file identifier and the target status identifier of the target file; In response to the refresh request, the data access component is instructed to clear the file content data of the target file cached locally and obtain a second status identifier from the remote object storage; Receive the second status identifier returned by the data access component; The second status identifier is returned to the file access client, so that the file access client updates the metadata of the target file in its local cache based on the second status identifier, and resends the file operation request for the target file to the data access component.
5. The method as described in claim 4, characterized in that, In response to the refresh request, before instructing the data access component to clear the file content data of the target file cached locally, the method further includes: Lock the target file; Before returning the second status identifier to the file access client, the method further includes: The metadata of the target file is updated based on the second status identifier, and the lock of the target file is released.
6. The method as described in claim 5, characterized in that, After locking the target file, the following is also included: Compare the target status identifier with the status identifier currently recorded in the metadata of the target file; In response to both being identical, the following steps are executed: instruct the data access component to clear the file content data of the target file cached locally; In response to the difference between the two, the current status identifier of the target file's metadata is used as the second status identifier.
7. The method as described in claim 5, characterized in that, Also includes: Receive change events for the target file sent by the object storage event subscription service; In response to the change event, the following steps are performed: lock the target file, instruct the data access component to clear the file content data of the target file cached locally, obtain a second status identifier from the remote object storage, update the metadata of the target file based on the second status identifier, and release the lock on the target file.
8. The method as described in claim 4, characterized in that, After receiving a refresh request for the target file from the file access client, the process also includes: Read the configuration item corresponding to the directory to which the target file belongs, which indicates whether the remote data priority function is enabled; In response to the configuration item indicating that the remote data priority function is not enabled, a dynamic refresh is not supported indication is returned to the file access client, so that the file access client returns the status change indication to the upper layer application; In response to the configuration item indicating that the remote data priority function has been enabled, the following steps are performed: In response to the refresh request, the data access component is instructed to clear the file content data of the target file cached locally, and to obtain a second status identifier from the remote object storage.
9. A file access client, characterized in that, include: The first sending module is configured to send a file operation request for a target file to a data access component; wherein the file operation request carries a target status identifier of the target file cached locally, and the file operation request is used to enable the data access component to recognize that the file operation request needs to access remote object storage, obtain a first status identifier from the remote object storage, and return a status change indication to the file access client when the first status identifier is inconsistent with the target status identifier; in response to the status change indication, a refresh request carrying the target file identifier and the target status identifier is sent to the metadata service; wherein the refresh request is used to enable the metadata service to instruct the data access component to clear the file content data of the target file cached locally, and obtain a second status identifier from the remote object storage; The first receiving module is configured to receive the second status identifier returned by the metadata service; The update module is configured to update the metadata of the target file in the local cache based on the second status identifier, and to perform the following steps based on the updated metadata of the target file: sending a file operation request for the target file to the data access component.
10. A metadata service, characterized in that, include: The second receiving module is configured to receive a refresh request for a target file sent by a file access client. The refresh request carries a target file identifier and a target status identifier of the target file. The processing module is configured to, in response to the refresh request, instruct the data access component to clear the file content data of the target file cached locally, and obtain a second status identifier from the remote object storage; and receive the second status identifier returned by the data access component. The second sending module is configured to return the second status identifier to the file access client, so that the file access client updates the metadata of the target file in its local cache based on the second status identifier, and resends the file operation request for the target file to the data access component.
