File uploading method, electronic device and computer program product

By using a local persistent database to record historical upload records in the object storage system, it can determine the file update status and use breakpoint resuming to solve the problem of resource waste caused by service crashes or network interruptions during file uploads, and improve upload efficiency and resources. Utilization.

CN114584551BActive Publication Date: 2024-09-24HANGZHOU WANGSU TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210100289.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-27
Publication Date
2024-09-24
Estimated Expiration
2042-01-27

AI Technical Summary

Technical Problem

In the object storage system, if the S3FS service crashes or the network is interrupted during the file upload process, the file upload fails and needs to be rewritten into the memory and uploaded, which takes a long time and consumes a lot of resources.

Method used

By recording historical upload records in the local persistent database, it is determined whether the target file has been updated. If it is not updated, the file is uploaded by resuming the upload, and only the unsuccessful fragments are uploaded.

Benefits of technology

It achieves fast file upload speed and reduces resource consumption, avoiding retransmission time and resource waste caused by service crashes or network interruptions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114584551B
    Figure CN114584551B
Patent Text Reader

Abstract

The present application discloses a file uploading method, electronic device and computer program product. When the S3FS service uploads a target file, it first determines whether there is a historical upload record of the target file in the persistent database, so as to determine whether a partial fragment of the target file has been uploaded before this upload. If a partial fragment of the target file has been uploaded before, it continues to determine whether the target file has been updated. If the target file has not been updated, the target file is resumed, that is, only a partial fragment of the target file is uploaded to the S3 cloud, and the partial fragment is the fragment that was not successfully uploaded during the last upload. With this solution, the S3FS service temporarily stores the target file to be uploaded locally, and uploads the file by resuming the breakpoint upload, which is fast and reduces resource consumption.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of cloud storage technology, and in particular to a file uploading method, electronic device and computer program product. Background Art

[0002] At present, there are three main types of storage: block storage, file storage, and object storage. Among them, object storage has the advantages of high-speed direct access to disks of block storage, while also having the distributed sharing characteristics of file storage. Therefore, object storage is gradually occupying an increasingly important position in the field of cloud computing storage services.

[0003] Object storage is essentially a network storage system, which is generally accessed through an application programming interface (API). However, it is difficult for ordinary users to access object storage systems by writing code to call APIs. The S3FS service is a file system interface developed by Google that supports exporting buckets in object storage as files and is compatible with the Portable Operating System Interface (POSIX) semantics. The S3FS service is developed based on the Filesystem in Userspace (FUSE), allowing Linux and Mac OsX to mount S3 cloud buckets locally. The S3FS service can maintain the original format of the object. Therefore, the S3FS service can be used to convert object storage to file storage. In this way, ordinary users can access the object storage system just like accessing a file storage system.

[0004] When users access the object storage system like accessing the file storage system, they may create new files, modify files, etc., which requires uploading the newly created or modified files to the S3 cloud. The usual practice is to temporarily store the files to be uploaded in the memory of the electronic device that deploys the S3FS service, and then upload them from the memory to the S3 cloud.

[0005] During the file upload process, if the S3FS service crashes, the network is disconnected, or other problems occur, the file upload will fail and the entire file will need to be rewritten into the memory and uploaded again, which is time-consuming and occupies a lot of resources. Summary of the invention

[0006] The present application provides a file uploading method, electronic device and computer program product. The S3FS service temporarily stores the target file to be uploaded locally and uploads the file by breakpoint resumption, which is fast and reduces resource consumption.

[0007] In a first aspect, an embodiment of the present application provides a file upload method, which is applied to an S3FS service, and the method includes:

[0008] Determine whether there is a historical upload record of the target file in a persistent database, where the persistent database is a local database created for the S3FS service to store upload records, and the historical upload record is used to record parameters associated with the first multi-slice upload request, where the first multi-slice upload request is the multi-slice upload request that the S3FS service sent to the S3 cloud last time;

[0009] When the historical upload record exists in the persistent database, determining whether the target file has been updated;

[0010] When the target file is not updated, the target file is continued to be uploaded.

[0011] In a second aspect, an embodiment of the present application provides an electronic device, comprising: a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the electronic device implements the method described in the first aspect or various possible implementation methods of the first aspect.

[0012] In a third aspect, an embodiment of the present application provides a computer program product comprising a computing program, and when the computer program is executed by a processor, the method described in the first aspect or various possible implementation methods of the first aspect is implemented.

[0013] The file uploading method, electronic device and computer program product provided by the embodiments of the present application, when the S3FS service uploads the target file, first determines whether there is a historical upload record of the target file in the persistent database, so as to determine whether a partial fragment of the target file has been uploaded before the current upload. If a partial fragment of the target file has been uploaded before, then continue to determine whether the target file has been updated. If the target file has not been updated, then resume uploading the target file, that is, only upload a partial fragment of the target file to the S3 cloud, and the partial fragment is the fragment that was not successfully uploaded during the last upload. With this solution, the S3FS service temporarily stores the target file to be uploaded locally, and uploads the file by resuming the breakpoint upload, which is fast and reduces resource consumption. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0015] Figure 1Schematic diagram of a network architecture applicable to the file uploading method provided in the embodiment of the present application;

[0016] Figure 2 is a flowchart of a file uploading method provided in an embodiment of the present application;

[0017] Figure 3 is another flow chart of the file uploading method provided in an embodiment of the present application;

[0018] Figure 4 is a flowchart of the file upload method provided in the embodiment of the present application'

[0019] Figure 5 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0020] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.

[0021] In order to facilitate ordinary users to use the object storage system, operation and maintenance personnel use open source software such as S3FS to convert object storage into file storage. In this way, ordinary users can access the object storage system just like accessing the file storage system. The file storage system contains a large amount of metadata, which is data used to describe data, mainly describing the attributes of the file, such as the file owner, permissions, modification time, creation time, etc.

[0022] Existing open source software such as S3FS is deployed on users' terminal devices or electronic devices such as servers. When users access object storage systems like accessing file storage systems, they may create new files, modify files, etc., which requires uploading new or modified files to the S3 cloud. During the upload process, the S3FS service writes the files to be uploaded into the memory of the electronic device and then uploads the files from the memory to the S3 cloud.

[0023] The above method of uploading files is a synchronous method, that is, after the S3FS service writes the file into the memory, it will synchronously upload the file in the memory to the S3 cloud. However, during the upload process, if the S3FS service crashes or there is a problem with the network between the S3FS service and the S3 cloud, the file upload will fail. The next time you retransmit, the S3FS service needs to rewrite the entire file into the memory and upload it again, which takes a long time and occupies a lot of bandwidth, memory and other resources.

[0024] Based on this, the embodiments of the present application provide a file uploading method, an electronic device and a computer program product. The S3FS service temporarily stores the target file to be uploaded locally, and uploads the file by resuming the breakpoint upload, which is fast and reduces resource consumption.

[0025] The relevant terms of the embodiments of the present application are explained as follows:

[0026] Bucket: A storage space used by users to manage objects. It is similar to the root directory or disk partition in a file storage system. Object storage systems manage objects through buckets.

[0027] File storage system: also known as file system, is a method of storing and organizing computer data, which makes it easy to access and find files. File storage system uses the abstract logical concept of files and tree directories to replace the concept of data blocks used by physical devices such as hard disks and optical disks. Users who use file storage systems to save data only need to remember the directory and file name of the file.

[0028] Metadata: Data used to describe data, mainly describing the attributes of the file, such as the file owner, permissions, modification time, creation time, etc.

[0029] File: can be called data, each file has its own metadata. In the embodiment of the present application, the data stored in the file storage system is called a file, and the data stored in the object storage system is called an object. It can be understood that the same data can be managed based on files or objects, and the user's operations on files can be converted into user operations on objects. For example, when a user adds a file, it is equivalent to adding a new object; when a user deletes a file, it is equivalent to deleting an object.

[0030] Persistent database: refers to the persistent database created for the S3FS service. This database is a database that can be persisted and can be implemented based on rocksdb, Redis or other types of database technologies. It is used to save the metadata involved in the process of users accessing the object storage system when accessing the file storage system. It is different from the memory and needs to be created on the disk. Generally speaking, when using the technical solution of this application, it is necessary to allocate disk space for the S3FS service in advance, such as adding a new disk on the device where the S3FS service is deployed, to store data for the persistent database of the S3FS service.

[0031] Target file: A file stored locally on the S3FS service and to be uploaded. For example, an electronic device that deploys the S3FS service has an independent disk or a new file system directory for storing target files. The independent disk is independent of the disk where the persistent database is located, or the storage space of an independent disk is divided into two independent spaces, one for the persistent database and the other for the target file. By storing the target file on an independent disk or file system directory, the target file will not be lost even if the network is interrupted or the S3FS service crashes, which facilitates subsequent retransmission.

[0032] Initial upload: Before the S3FS service uploads the target file to the S3 cloud, the target file has never been uploaded. Therefore, this upload is called the initial upload, which is also called the first upload and is represented by NEW_UPLOAD.

[0033] Retransmission: During the last upload of the target file to the S3 cloud, problems such as the S3FS service crash and the network interruption between the S3FS service and the S3 cloud occurred, resulting in some of the multiple shards of the target file being successfully uploaded to the S3 cloud, while others were not successfully uploaded. In addition, the user has updated the target file stored on the S3FS server, and needs to re-upload the entire updated target file. Therefore, this upload is called a retransmission, represented by RENEW_UPLOAD.

[0034] Resume: A problem occurred during the last upload of the target file, resulting in some of the multiple shards of the target file being successfully uploaded to the S3 cloud, while some shards were not successfully uploaded. In addition, the user did not update the target file on the S3FS server, so only some shards need to be uploaded this time, that is, the shards that were not successfully uploaded last time. Therefore, this upload is called a resume, represented by RESUME_UPLOAD. This transmission method is also called breakpoint resume, that is, the file uploaded this time and the file uploaded last time are different shards of the same file.

[0035] In cloud computing, storage type-related terms are usually file storage, object storage, etc., and are generally not called file storage systems or object storage systems. It can be understood that converting object storage to file storage means converting object data managed based on the object storage system to file data managed based on the file storage system. Unless otherwise specified below, object storage is equivalent to object storage system, and file storage is equivalent to file storage system.

[0036] Figure 1 This is a schematic diagram of the network architecture applicable to the file upload method provided in the embodiment of the present application. Figure 1 The network architecture includes an S3FS service 11 and an S3 cloud 12. The S3FS service 11 is deployed on a user's terminal device, gateway, server or other electronic device. When an S3FS service 11 mounts a bucket in an object storage, the user can access the object in the bucket like accessing a file.

[0037] S3 Cloud 12 is a platform that provides a simple storage service (S3), which can be deployed on a server or server cluster in the cloud and manages object data in the form of storage buckets. In other words, S3 Cloud stores data in the form of object storage.

[0038] The user writes the target file to a local independent disk or other location of the S3FS service 11. Once the target file is successfully uploaded to the disk, the S3FS service 11 returns an indication to the user that the target file has been uploaded. Then, the S3FS service 11 uploads the target file segments to the S3 cloud 12, thereby completing the synchronization between the S3FS service 11 and the S3 cloud 12. This method of uploading files is asynchronous, which optimizes service performance, reduces unnecessary resource consumption, and saves costs. During the synchronization process, the synchronization may fail due to network interruption, S3FS service 11 crash, and other problems. At this time, if the user has not updated the target file, after the network is restored or the S3FS service 11 is restored, the S3FS service 11 will continue to upload the target file, that is, upload the remaining segments to the S3 cloud, and the S3 cloud will merge the segments uploaded this time with the segments uploaded last time to obtain the target file.

[0039] Below, based on Figure 1 The implementation environment shown is used to describe in detail the file upload method provided in the embodiment of the present application. For example, please refer to Figure 2 .

[0040] Figure 2 Flowchart of the file upload method provided by the embodiment of the present application. This embodiment is described from the perspective of S3FS service. This embodiment includes:

[0041] 201. Determine whether there is a historical upload record of the target file in the persistent database. If there is a historical upload record in the persistent database, execute step 202; if there is no historical upload record in the persistent database, execute step 205.

[0042] The persistent database is a local database created for the S3FS service to store upload records, and the historical upload record is used to record the parameters associated with the first segment upload request, which is the segment upload request that the S3FS service sent to the S3 cloud last time. The parameters associated with the first segment upload request, i.e., the parameters recorded in the historical upload record, include the segment size, version number, serial number, etc. The segment size is used to indicate the size of each segment at the time of the last upload, the version number is used to indicate the version number of the target file when uploading the target file, and the serial number is used to identify the segment structure of the target file, and the segment structures belonging to the same target file have the same serial number.

[0043] In the embodiment of the present application, a persistent database is created on a local disk and can be used for persistent storage of data. It is a cache method different from memory. During the startup process, the S3FS service can obtain metadata related to the mounted bucket from the S3 cloud in advance and complete the full synchronization of metadata in advance. Among them, full synchronization means that the S3FS service synchronizes metadata with the S3 cloud before providing services to users. Specifically, the S3FS service needs to mount the bucket during the startup process to provide the object data in the bucket to the user in the form of a file. Generally speaking, there are two situations where full synchronization is required: initial mounting of the existing bucket and redeployment of the S3FS service for the same bucket, wherein the initial mounting refers to the first mounting of the bucket by the S3FS service; redeployment of the S3FS service for the same bucket means: the S3FS service has been deployed previously and the bucket has been mounted. When it needs to be redeployed due to equipment abnormalities and other reasons, and the bucket mounted by the service remains unchanged. In other words, during the startup process, when there is existing data in the storage bucket mounted by the S3FS service, it is necessary to obtain all the metadata in the storage bucket from the cloud in advance and write it to the persistent database, so that when a user access request arrives, it can be responded directly based on the metadata in the persistent database.

[0044] In addition to the metadata obtained by full synchronization, the persistent database also stores parameters associated with the uploaded records, which can also be regarded as metadata. This metadata is described in detail below.

[0045] For example, when a user accesses an object storage system through the S3FS service like accessing a file storage system, it is inevitable that new files will be added or modified, and the new or modified files need to be uploaded to the S3 cloud. The new or modified files are the target files to be uploaded. The upload process includes three steps:

[0046] Step 1: The S3FS service sends a shard upload request to the S3 cloud;

[0047] Step 2: The S3FS service slices the target file into multiple slices and uploads the slices;

[0048] Step 3: If all shards are successfully uploaded, instruct the S3 cloud to merge the shards; if one or more shards are not successfully uploaded, instruct the S3 cloud to clear the successfully uploaded shards.

[0049] The upload record stored in the persistent database is used to record the parameters associated with the multi-slice upload request in step 1. For example, each time a target file is uploaded, the S3FS service sends a multi-slice upload request carrying the slice size, bucket ID, etc. to the S3 cloud, and the S3 cloud sends a multi-slice upload response carrying a serial number to the S3FS service. In response to the multi-slice upload request, the S3FS service generates an upload record and stores it in the persistent database. The upload record is used to record the parameters associated with the multi-slice upload request, such as the slice size, bucket ID, serial number, target file ID, etc. Among them, the slice size is used to indicate the size of each slice in the multiple slices into which the target file is divided, the bucket ID is used to determine in which bucket the target file is stored, and the serial number is used to identify the slices belonging to the same target file.

[0050] In the embodiment of the present application, the upload record includes a historical upload record and a current upload record. A target file is sliced ​​into multiple slices. During the last upload, if the S3FS service crashes or the network between the S3FS service and the S3 cloud is disconnected during the upload of the target file, some of the multiple slices will be successfully uploaded to the S3 cloud, while some will not be successfully uploaded. The S3FS service will record the parameters associated with the slice upload request in the upload record and store the upload record in the local persistent database. For this upload, the upload record stored in the persistent database is the historical upload record.

[0051] When the S3FS service uploads the target file to the S3 cloud for the first time, or when the S3FS service re-uploads the target file to the S3 cloud, the S3FS service interacts with the S3 cloud, that is, the S3FS service sends a multi-slice upload request to the S3 cloud, and the S3 cloud returns an upload response. The S3FS service records the parameters associated with the multi-slice upload request, obtains the current upload record and stores it in the persistent database. It is understandable that if there is an interruption during the initial or retransmission of the target file, the current upload record will become the historical upload record when the target file is re-transmitted next time.

[0052] Each time you upload a target file, the S3FS service queries the local persistent database based on the target file's identifier. If there is a historical upload record of the target file in the persistent database, it means that the S3FS service has uploaded the target file before this upload. However, due to problems such as the S3FS service crash or network interruption between the S3FS service and the S3 cloud, some of the multiple shards of the target file have been successfully uploaded, while others have not been successfully uploaded. In this case, you need to determine whether to resume uploading the target file or retransmit it.

[0053] 202. Determine whether the target file has been updated. If the target file has not been updated, execute step 203; if the target file has been updated, execute step 204.

[0054] Exemplarily, the S3FS service determines whether the target file has been updated. If it has been updated, the entire updated target file needs to be retransmitted. If the target file has not been updated, only some fragments are uploaded, that is, the fragments that were not successfully uploaded last time.

[0055] The S3FS service can flexibly use different methods to determine whether the target file has been updated. For example, before uploading the target file each time, the S3FS service uses a preset algorithm to calculate the target file to obtain a checksum. Before uploading this time, the S3FS service compares the current checksum with the previous checksum. If the two checksums are the same, it means that the target file has not been updated, and then the partial fragments are uploaded using the resume method. If the two checksums are different, it means that the target file has been updated, and then the entire updated target file is uploaded using the retransmission method.

[0056] For another example, each time the S3FS service obtains a target file, it sets a version identifier (version-ID) for the target file, records it in the persistent database, and sends it to the S3 cloud in the multi-slice upload request. If the target file has been updated, the version identifier in the persistent database is updated. Before this upload, the S3FS service obtains the version identifier of the target file from the S3 cloud. When the version identifier is the same as the version identifier in the persistent database, it means that the target file has not been updated, and then the resume upload method is used to upload some shards. If the two version identifiers are different, it means that the target file has been updated, and then the retransmission method is used to upload the entire updated target file.

[0057] 203. Continue to transfer the original target file.

[0058] The S3FS service uploads only some of the fragments of the target file to the S3 cloud. Some of the fragments are the fragments that were not successfully uploaded during the last upload.

[0059] 204. Upload the updated target file to the S3 cloud.

[0060] 205. Upload the original target file to the S3 cloud.

[0061] For example, if there is no historical upload record in the persistent database, it means that the S3FS service is uploading the target file to the S3 cloud for the first time, and there is no situation where some pieces have been uploaded and some pieces have not been uploaded, but all pieces have not been uploaded. Therefore, the entire target file needs to be uploaded to the S3 cloud.

[0062] In the file uploading method provided by the embodiment of the present application, when the S3FS service uploads the target file, it first determines whether there is a historical upload record of the target file in the persistent database, so as to determine whether a partial fragment of the target file has been uploaded before the current upload. If a partial fragment of the target file has been uploaded before, it continues to determine whether the target file has been updated. If the target file has not been updated, the target file is resumed, that is, only a partial fragment of the target file is uploaded to the S3 cloud, and the partial fragment is the fragment that was not successfully uploaded during the last upload. With this solution, the S3FS service temporarily stores the target file to be uploaded locally, and uploads the file by resuming the breakpoint upload, which is fast and reduces resource consumption.

[0063] Optionally, in the above embodiment, when the target file is not updated, when the S3FS service continues to upload the target file, it first determines the fragment size from the historical upload record, slices the target file according to the fragment size to obtain multiple fragments, and then determines the target fragment that has not been uploaded to the S3 cloud from the multiple fragments, and uploads the target fragment to the S3 cloud.

[0064] Exemplarily, since it is a resumed upload, the S3FS service reuses the metadata of the first shard upload request, that is, the identifier of the shard upload request in the historical upload record, the shard size, etc. Therefore, the S3FS service obtains the shard size from the historical upload record, and slices the target file according to the shard size to obtain multiple shards. It should be noted that slicing means: reading the contents of a preset size from the target file into the memory in sequence, and these contents are shards, thereby slicing the target file, which does not mean that the target file on the independent disk is divided into multiple shards and stored on the independent disk.

[0065] After slicing is completed, the S3FS service accesses the S3 cloud to obtain the list of uploaded shards. The S3FS service determines the target shards to be uploaded based on the shard list. For example, a target file is divided into 10 shards, shard 1 to shard 10, and the shard list contains shard 1 to shard 5. Therefore, the S3FS service determines that the target shards to be uploaded are shards 6 to shard 10, and uploads these target shards to the S3 cloud.

[0066] With this solution, the S3FS service reuses the parameters associated with the last allocated upload request to continue uploading the target file, without sending multi-slice upload requests to the S3 cloud, thus reducing the number of interactions between the S3FS service and the S3 cloud and improving file upload efficiency.

[0067] Optionally, in the above embodiment, when the S3FS service uploads the target shard to the S3 cloud, it first encapsulates the shard according to the parameters in the historical upload record to obtain a shard structure. When there are two or more target shards, each shard structure is sent to the S3 cloud in a concurrent manner, thereby achieving breakpoint resume.

[0068] Exemplarily, the S3FS service reuses the parameters associated with the last shard upload request, that is, obtains metadata such as the sequence number and bucket identifier from the historical upload record, constructs a shard structure based on these metadata and shards, and sends it to the S3 cloud in a concurrent manner. Among them, the sequence number is used to mark the shards belonging to the same target file. If several shard structures carry the same sequence number, the S3 cloud considers these shard structures to be shard structures of different shards of the same target file.

[0069] With this solution, the S3FS service sends the shard structure to the S3 cloud in a concurrent manner, which is fast.

[0070] The S3FS service sends the shard structure of each shard to the S3 cloud. For each shard, if the S3 cloud successfully receives the shard structure, it returns an indication of successful upload to the S3FS service. If the S3 cloud fails to successfully receive a shard structure, the S3 cloud returns an indication of failed reception to the S3FS service. In addition, if the network between the S3FS service and the S3 cloud is interrupted and the S3FS service does not receive the indication information for a preset period of time, the S3FS service considers that the S3 cloud has failed to receive it successfully.

[0071] If the shard structure of a shard is not successfully uploaded to the S3 cloud, the S3FS service re-uploads the shard structure to the S3 cloud. For the sake of clarity, the shard corresponding to the shard structure that needs to be re-uploaded is referred to as a retransmitted shard. When the retransmitted shard is still not successfully uploaded after the preset number of retransmissions, the S3FS service sends an interrupt request to the S3 cloud to instruct the S3 cloud to perform garbage collection. At the same time, the S3FS service deletes the historical upload records in the local persistent database and records in the local log that the target file has not been successfully uploaded.

[0072] After receiving the interrupt request, the S3 cloud determines that among the multiple target shards of the target file, there is a target shard that has not been successfully uploaded. Therefore, the S3 cloud deletes the shard structure of the successfully uploaded target shard.

[0073] In this way, the S3FS service determines that the target file has not been successfully uploaded by reading the local log, and the entire target file will be re-uploaded the next time the target file is uploaded to the S3 cloud.

[0074] With this solution, when the shard structure is not successfully uploaded after the preset number of uploads, the S3FS service interrupts the upload of the target file, thus preventing the resources of the S3FS service from being occupied for a long time and affecting other businesses.

[0075] Optionally, in the above embodiment, after all the fragments of the target file are uploaded to the S3 cloud, the S3FS service sends a completion request to the S3 cloud, so that the S3 cloud merges the fragments to obtain the target file. At the same time, the S3FS service deletes the historical upload record from the persistent database.

[0076] Exemplarily, after the shard structure of each shard is successfully uploaded to the S3 cloud, the S3 cloud returns an indication of successful upload to the S3FS service. After the S3FS service receives the indication of successful upload corresponding to each target shard, it sends a completion request to the S3 cloud. For example, a target file is divided into 10 shards, and shards 1 to 5 were successfully uploaded during the last upload. During this upload, the S3FS service only uploads shards 6 to 10. After the S3 cloud returns the indication of successful upload of each shard in shards 6 to 10 to the S3FS service, the S3FS service sends a completion request to the S3 cloud. After receiving the completion request, the S3 cloud merges shards 1 to 10 to obtain the target file. It can be understood that the S3 cloud receives the shard structure of each shard. Therefore, during the merging process, the S3 cloud connects all the slave shards in series through metadata records to obtain the target file.

[0077] This solution indicates to the S3 cloud that each shard has been successfully uploaded, so that the S3 cloud can merge the shards in time to obtain the target file, thereby improving file upload efficiency.

[0078] The above is how the S3FS service continues to transfer the target file when the target file is not updated. The following is a detailed description of how the S3FS service retransmits the target file after the target file is updated.

[0079] After the S3FS service determines that the target file has been updated, the S3FS service sends an interrupt request to the S3 cloud to instruct the S3 cloud to delete the fragment structure of the successfully uploaded target fragment among the multiple target fragments of the target file. At the same time, the S3FS service deletes the historical upload record.

[0080] For example, if the target file is updated, since the last segment successfully uploaded to the S3 cloud is the segment of the target file before the update, the S3 cloud needs to delete these successfully uploaded segments to ensure that after the updated target file is successfully uploaded this time, the S3 cloud saves the latest version of the target file.

[0081] At the same time, the S3FS service deletes historical upload records from the local persistent database to avoid the S3FS service from reusing the parameters of the multi-segment upload request when uploading the old version of the target file last time when uploading the updated target file, ensuring that the new version of the target file is uploaded correctly.

[0082] Afterwards, the S3FS cloud uploads the updated target file. Figure 3 is another flow chart of the file upload method provided in the embodiment of the present application. This embodiment includes:

[0083] 301. The S3FS service sends a second shard upload request to the S3 cloud.

[0084] Correspondingly, the S3 cloud receives the second multi-slice upload request. The first multi-slice upload request is the multi-slice upload request sent by the S3FS service to the S3 cloud when uploading the target file last time; the second multi-slice upload request is the multi-slice upload request sent by the S3FS service to the S3 cloud when uploading the target file this time.

[0085] The second segment upload request carries the segment size and the bucket identifier of the storage bucket used to store the target file.

[0086] Exemplarily, the S3FS service determines the shard size, the identifier of the storage bucket for storing the target file, etc. according to the configuration sent by the user, etc. The shard size carried by the second shard upload request may be the same as or different from the shard size carried by the first shard upload request. In addition, the second shard upload request also carries the identifier of the target file, etc. The identifier may be the file name of the target file, etc.

[0087] 302. The S3 cloud sends a multi-segment upload response to the S3FS service.

[0088] Correspondingly, the S3FS service receives the multi-segment upload response from the S3 cloud.

[0089] The segment upload response carries a serial number, and the serial number is used to identify the segment structures belonging to the same target file.

[0090] Exemplarily, after receiving the second shard upload request, the S3 cloud stores the shard size, bucket identifier, etc., and assigns a unique serial number to the target file. When the S3FS service subsequently uploads shards, if the shards of the same target file carry the same serial number, the S3 cloud will merge the shards with the same serial number.

[0091] 303. The S3FS service records the parameters associated with the second shard upload request to obtain and store the current upload record.

[0092] Before retransmission, the S3FS service deletes the historical upload record in the local persistent database. During this retransmission, the S3FS service generates the current upload record based on the parameters associated with the second shard upload request and stores the current upload record in the local persistent database.

[0093] Exemplarily, after receiving the shard upload response from the S3 cloud, the S3FS service generates a current upload record and writes the current upload record to a persistent database.

[0094] 304. The S3FS service slices the target file according to the slice size to obtain multiple slices.

[0095] 305. The S3FS service encapsulates the bucket identifier and the serial number for each of the multiple shards to obtain multiple shard structures.

[0096] 306. The S3FS service sends each of the shard structures to the S3 cloud.

[0097] Correspondingly, the S3 cloud receives each shard structure.

[0098] With this solution, if the user updates the target file, the S3FS service instructs the S3 cloud to delete the old version of the target file's fragments and re-upload the entire updated target file to ensure that the file uploaded to the S3 cloud is correct.

[0099] Figure 4 Flowchart of the file uploading method provided by the embodiment of the present application. This embodiment includes:

[0100] 401. The S3FS service determines whether to obtain metadata of the target file and the version number of the target file from the S3 cloud. If the metadata and the version number are obtained, step 402 is executed; if the metadata and the version number are not obtained, step 409 is executed.

[0101] Exemplarily, the S3FS service sends a query request to the S3 cloud, and the query request carries the identity of the target file. After receiving the query request, the S3 cloud checks whether the metadata, version number, etc. of the target file are stored in the S3 cloud according to the identity. Generally speaking, if the S3FS service has sent a multi-slice upload request for the target file to the S3 cloud before the S3FS service executes step 401, that is, the first multi-slice upload request mentioned above, then the S3 cloud will have the metadata and version number of the target file, and at this time, the S3FS service executes step 402. If the S3FS service has never sent a multi-slice upload request for the target file before executing step 401, it means that the target file is a file that is uploaded in multi-slices for the first time, and the S3FS service executes step 409.

[0102] 402. The S3FS service determines whether there is a historical upload record of the target file in the persistent database. If there is a historical upload record of the target file in the persistent database, execute step 403; if there is no historical upload record of the target file in the persistent database, execute step 409.

[0103] Exemplarily, the S3FS service queries the local persistent database according to the metadata obtained in step 401. If there is a historical upload record of the target file in the persistent database, it means that before the S3FS service executes step 401, it has sent a first shard upload request to the S3 cloud, and after receiving the shard upload response corresponding to the first shard upload request, it generates an upload record and successfully writes it into the persistent data. The S3FS service may have uploaded the shard. At this time, the S3FS service executes step 403 to continue to determine whether to retransmit or continue the transmission next; if there is no historical record in the persistent database, it means that after the S3FS service successfully sends the first shard upload request, the upload record is not successfully written into the persistent data stream due to various reasons. The reasons include but are not limited to the following reasons: after the S3 cloud receives the first shard upload request, the network between the S3 cloud and the S3FS service is interrupted; after the S3FS service receives the shard upload response corresponding to the first shard upload request, it crashes, resulting in the S3FS service not generating an upload record; after the S3FS service generates the upload record corresponding to the first shard upload request, it crashes, resulting in the S3FS service failing to write the upload record into the persistent database.

[0104] 403. The S3FS service determines whether the target file has been updated. If the target file has not been updated, step 404 is executed; if the target file has been updated, step 406 is executed.

[0105] Exemplarily, the S3FS service compares the version number obtained in step 401 with the version number in the local persistent database. If the two are consistent, it means that the user has not updated the target file; if the two are inconsistent, it means that the user has updated the target file, and the fragments uploaded before step 401 are fragments of the old version of the target file. The old version of the fragments needs to be deleted and the target file needs to be retransmitted.

[0106] 404. Confirm to use the resume upload method to upload the target file.

[0107] 405. The S3FS service obtains the shard list from the S3 cloud, and then executes step 410.

[0108] The shards in the shard list are the shards that were successfully uploaded to the S3 cloud last time.

[0109] 406. The S3FS service determines the target file to be retransmitted.

[0110] 407. The S3FS service sends an interrupt request to the S3 cloud, so that the S3 cloud deletes the shard structure of the successfully uploaded target shard among the multiple target shards.

[0111] Exemplarily, the S3FS service aborts the last unfinished shard upload request, i.e., the first shard upload request, according to the historical upload records in the persistent database. In actual implementation, the S3FS service sends an abort request to the S3 cloud. After receiving the abort request, the S3 cloud deletes the shard structure of the successfully uploaded target shard, and at the same time, deletes the metadata of the target file, such as the shard, sequence number, etc.

[0112] 408. The S3FS service initiates a new shard upload request, generates a current upload record and stores it in a persistent database. Then, step 410 is executed.

[0113] The new multi-slice upload request is the second multi-slice upload request. The S3FS service sends the second multi-slice upload request carrying the size of the slice, the identifier of the bucket, etc. to the S3 cloud, and the S3 cloud returns a multi-slice upload response carrying the sequence number, etc.

[0114] The S3FS service generates a current upload record according to the shard size, sequence number, bucket ID, etc. associated with the second shard upload request, and stores the current upload record in a persistent database.

[0115] 409 . The S3FS service determines that the target file is the target file for initial transmission, and then executes step 408 .

[0116] 410. The S3FS service slices the target file into multiple shards according to the shard size and constructs a shard structure.

[0117] For step 405, since it is a resumed upload, in step 410, the S3FS service reuses the parameters associated with the first slicing request, that is, the S3FS service slices the target file according to the parameters in the historical upload record.

[0118] For step 408, since it is an initial transmission or a retransmission, in step 410, the S3FS service slices the target file according to the parameters associated with the second slicing request, that is, the parameters in the current upload record.

[0119] 411. The S3FS service identified unuploaded shards.

[0120] For example, for the initial transmission or retransmission, all the segments of the target file are segments that have not been uploaded; for the continued transmission, the S3FS service determines the segments that have not been uploaded from the multiple segments according to the segment list in step 405. After determining the segments that have not been uploaded, the S3FS service encapsulates the segments with serial numbers, storage bucket identifiers, etc., to construct a segment structure.

[0121] 412. The S3FS service concurrently uploads the shard structures.

[0122] This solution is used to achieve the purpose of initial transmission or retransmission of the target file in fragments.

[0123] 413. The S3FS service determines whether each shard structure is uploaded successfully. If each shard structure is uploaded successfully, execute step 414; if there is at least one shard structure that is not uploaded successfully, execute step 415.

[0124] Exemplarily, after a shard structure is successfully uploaded, the S3 cloud sends an indication of successful upload to the S3FS service. If the upload fails, an indication of upload failure is sent to the S3FS service. Alternatively, if the S3FS service does not receive any indication within a preset time period, the upload is deemed to have failed.

[0125] 414. The S3FS service sends a completion request to the S3 cloud, so that the S3 cloud merges the shards to obtain the target file; at the same time, the S3FS service clears the upload record.

[0126] The upload record may be a historical upload record or a current upload record. For example, when the S3FS service initially uploads or retransmits the target file, the upload record is the current upload record; when the S3FS service continues to upload the target file, the upload record is the historical upload record.

[0127] After the S3 cloud merges the shards to obtain the target file, it returns an indication that the target file has been successfully uploaded to the S3FS service.

[0128] 415. S3FS service retransmits fragment structure.

[0129] Exemplarily, if a shard structure of a shard is not successfully uploaded, the S3FS service retransmits the shard structure. This shard is called a retransmitted shard. If the retransmitted shard is still not successfully uploaded after a preset number of retransmissions, the S3FS service sends an interrupt request to the S3 cloud, so that the S3 cloud deletes the shard structure of the target shard that has been successfully uploaded among the multiple target shards. At the same time, the S3FS service deletes the historical upload record from the persistent database and records in the local log that the target file has not been successfully uploaded.

[0130] In this way, the S3FS service releases the resources used to upload the target file in time to avoid affecting other services of the S3FS service. The target files that have not been uploaded are recorded locally to facilitate the S3FS service to retry uploading the target files in pieces later.

[0131] In step 415, if the retransmitted segments are finally successfully uploaded, the S3 cloud merges the segments to obtain the target file and returns the indication information that the target file is successfully uploaded to the S3FS service. If the retransmitted segments are finally not successfully uploaded, the S3 cloud returns the indication information that the target file fails to be uploaded.

[0132] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 5 As shown, the electronic device 500 is, for example, a device that deploys the S3FS service, and the electronic device 500 includes:

[0133] Processor 51 and memory 52;

[0134] The memory 52 stores computer instructions;

[0135] The processor 51 executes the computer instructions stored in the memory 52, so that the processor 51 executes the file upload method implemented by the S3FS service as above.

[0136] The specific implementation process of the processor 51 can be found in the above method embodiment, and its implementation principle and technical effect are similar, so this embodiment will not be repeated here.

[0137] Optionally, the electronic device 500 further includes a communication component 53 , wherein the processor 51 , the memory 52 and the communication component 53 may be connected via a bus 54 .

[0138] An embodiment of the present application further provides a computer-readable storage medium, in which computer instructions are stored. When the computer instructions are executed by a processor, they are used to implement the file upload method implemented by the S3FS service as described above.

[0139] An embodiment of the present application also provides a computer program product, which includes a computer program. When the computer program is executed by a processor, it implements the file upload method implemented by the S3FS service as above.

[0140] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.

[0141] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

Claims

1. A file uploading method, characterized in that: Applied to the S3FS service, the method includes: Determine whether there is a historical upload record of the target file in the persistent database, the persistent database is a local database created for the S3FS service for storing upload records, the historical upload record is used to record parameters associated with the first multi-slice upload request, the first multi-slice upload request is the multi-slice upload request sent by the S3FS service to the S3 cloud last time, the target file is a newly created file in the storage bucket when the S3FS service accesses the storage bucket mounted by the S3FS service; or, the target file is a file in the storage bucket mounted by the S3FS service that is modified when the S3FS service accesses the storage bucket, the target file is a file to be uploaded stored on a local independent disk of the S3FS service; or, the target file is a file to be uploaded stored on a local independent space of the S3FS service; When the historical upload record exists in the persistent database, determining whether the target file has been updated; When the target file is not updated, continue to transfer the target file to synchronize the S3 cloud and the S3FS service; When the target file is not updated, continuing to transfer the target file comprises: Determine the shard size from the historical upload records; Slicing the target file according to the slice size to obtain a plurality of slices; Determine a target shard that has not been uploaded to the S3 cloud from the multiple shards; Upload the target shard to the S3 cloud.

2. The method according to claim 1, characterized in that The uploading the target shard to the S3 cloud comprises: When there are multiple target fragments, encapsulate each target fragment according to the parameters associated with the first fragment upload request recorded in the historical upload record to obtain multiple fragment structures; Each of the shard structures is sent to the S3 cloud in a concurrent manner.

3. The method according to claim 1, characterized in that Also includes: If there are retransmission segments that have not been successfully uploaded among the multiple target segments, then re-upload the retransmission segments; When the retransmitted segment fails to be uploaded after being retransmitted for a preset number of times, an interrupt request is sent to the S3 cloud, so that the S3 cloud deletes the segment structure of the successfully uploaded target segment among the multiple target segments; The historical upload record is deleted from the persistent database, and a record is made in the local log that the target file has not been successfully uploaded.

4. The method according to claim 1 or 2, characterized in that: When the target file is not updated, after continuing to transfer the target file, the method further includes: After all the fragments of the target file are uploaded to the S3 cloud, a completion request is sent to the S3 cloud, so that the S3 cloud merges the fragments to obtain the target file; The historical upload record is deleted from the persistent database.

5. The method according to any one of claims 1 to 3, characterized in that: Also includes: When the target file has been updated, an interrupt request is sent to the S3 cloud to instruct the S3 cloud to delete the fragment structure of the target fragment that has been successfully uploaded among the multiple target fragments of the target file; Delete the historical upload record.

6. The method according to claim 5, characterized in that After deleting the historical upload record, the method further includes: Sending a second multi-slice upload request to the S3 cloud, where the second multi-slice upload request carries the size of the slice and the bucket identifier of the bucket used to store the target file; Receive a segment upload response from the S3 cloud, where the segment upload response carries a sequence number, and the sequence number is used to identify a segment structure belonging to the same target file; Slicing the target file according to the slice size to obtain a plurality of slices; Recording the parameters associated with the second segment upload request to obtain a current upload record; Encapsulating the bucket identifier and the serial number for each of the multiple slices to obtain multiple slice structures; Send each of the shard structures to the S3 cloud.

7. The method according to any one of claims 1 to 3, characterized in that: The step of determining whether there is a historical upload record of the target file in the persistent database includes: Sending a query request carrying the identity of the target file to the S3 cloud; Receiving a query response sent by the S3 cloud; When the query response indicates that the metadata and version number of the target file exist in the S3 cloud, it is determined whether there is a historical upload record of the target file in the persistent database.

8. The method according to any one of claims 1 to 3, characterized in that: Also includes: The target file is stored on an independent disk or in a file system directory of the electronic device where the S3FS service is deployed.

9. The method according to any one of claims 1 to 3, characterized in that: The step of determining whether the target file has been updated comprises: Obtain the version number and serial number of the target file from the S3 cloud; When the version number in the historical upload record is different from the version number obtained from the S3 cloud, it is determined that the target file has been updated, and the parameters recorded in the historical upload record include at least the version number of the target file and a serial number, and the serial number is used to identify the shard structure belonging to the target file.

10. An electronic device comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the electronic device implements the method according to any one of claims 1 to 9.

11. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.