Data storage method and device

Through the double-layer inode structure and file state conversion, the problem of differential technology occupying CPU resources in mobile cloud storage is solved, efficient data storage and snapshot creation are achieved, and user experience and device performance are improved.

CN118625993APending Publication Date: 2024-09-10HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310245340.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-03-07
Publication Date
2024-09-10

AI Technical Summary

Technical Problem

When cloud storage is used in mobile phones, although differential technology reduces the number of network I/Os, it occupies a large amount of CPU resources, affecting the device's battery life and user experience.

Method used

Adopting a double-layer inode structure, the updated data is directly determined by storing the physical block addresses of the unupdated and updated data of the file without the need to calculate hash values, reducing CPU resource overhead, and distinguishing data differences through file status conversion to achieve zero-copy snapshots and reduce network I/O.

Benefits of technology

It effectively reduces the usage of CPU resources, reduces the number of network I/Os, saves bandwidth, and improves user experience and device battery life.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118625993A
    Figure CN118625993A
Patent Text Reader

Abstract

The invention discloses a data storage method and device, relates to the technical field of data storage, and can reduce the overhead of occupied CPU (Central Processing Unit) resources under the condition of reducing the network I / O (Input / Output) number. The method is applied to a first device and comprises the steps that in response to a data storage request for a first file, an inode corresponding to the first file is obtained, the inode comprises a first inode and a second inode, the first inode is used for storing a first PBA, the first PBA is a PBA corresponding to non-updated data of the first file, the second inode is used for storing a second PBA, and the second PBA is a PBA corresponding to updated data of the first file; determining update data according to the second PBA; and sending the update data to the second device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] Currently, mobile phone applications can use cloud storage to store data. Differential technology may be used when using cloud storage. Differential technology refers to dividing a file into multiple chunks, then calculating the hash value corresponding to the chunk to determine the modified chunk, and then uploading only the modified chunk to the cloud storage.

[0003] Differentiation technology can reduce the number of network input / output (I / O), but this method will occupy a large amount of central processing unit (CPU) resources. Summary of the invention

[0004] The present application provides a data storage method and device, which can reduce the overhead of occupied CPU resources while reducing the number of network I / Os.

[0005] In order to achieve the above objectives, this application adopts the following technical solutions:

[0006] In a first aspect, a data storage method is provided, which is applied to a first device, and the method includes: in response to a data storage request for a first file, obtaining an index node inode corresponding to the first file, the inode including a first inode and a second inode, the first inode is used to store a first physical block address PBA, the first PBA is a PBA corresponding to unupdated data of the first file, and the second inode is used to store a second PBA, the second PBA is a PBA corresponding to updated data of the first file; determining updated data according to the second PBA; and sending the updated data to the second device.

[0007] Based on the above technical solution, after receiving a data storage request for a file, the inode corresponding to the file is obtained. The inode is a double-layer inode structure, in which one inode is used to store the PBA corresponding to the unupdated data of the file, and the other inode is used to store the PBA corresponding to the updated data of the file. In this way, the updated data of the file can be determined directly based on the PBA corresponding to the updated data of the file, that is, the updated data of the file can be determined by a simple comparison and judgment, without the need for intensive calculation such as calculating the hash value, thereby reducing the CPU resource overhead. Then, only the updated data is sent to the cloud storage, which can reduce the number of network I / Os and save network bandwidth.

[0008] In a possible design, the second inode is also used to store the third PBA, and the third PBA is used to indicate that the PBA corresponding to the data of the first file is stored in the first inode. Based on this design, when the file uses a double-layer inode, the second inode is used to store the second PBA and the third PBA. In this way, the real PBA of the data can be determined to be in the second inode according to the second PBA, and the real PBA of the data can be determined to be in the first inode according to the third PBA, thereby achieving addressing of the data.

[0009] In a possible design, before obtaining the inode corresponding to the first file in response to a data storage request for the first file, the method also includes: creating a second file that does not include data, the second file corresponds to a third inode, and the third inode includes a fourth PBA; generating a second inode according to the third inode, the fourth PBA, and the third PBA; generating an inode corresponding to the first file according to the second inode and the first inode corresponding to the first file. Based on this design, in some scenarios, since the application is in user mode and the inode is in kernel mode, the application cannot directly create an inode. Therefore, an inode can be created by creating an empty file, and the single-layer inode structure of the file can be converted into a double-layer inode structure.

[0010] In a possible design, before sending the updated data to the second device, the method also includes: creating a third file that does not include data, the third file corresponds to a fourth inode, and the fourth inode includes a fourth PBA; setting the fourth PBA to the third PBA; generating a snapshot of the first file based on the third file, the fourth inode and the first inode. Based on this design, the third file shares the first inode with the first file, and the first inode is used to store the PBA corresponding to the unupdated data of the first file. Therefore, the first inode is read-only for the upper-layer application, so that the third file becomes a snapshot of the first file. This solution for creating a file snapshot, except for the overhead of creating the third file, does not read and write the data of the first file, and realizes zero-copy creation of a file snapshot, reduces the number of write I / Os generated, and can improve the user experience.

[0011] In a possible design, the first file is in a first state, and the first state is used to indicate that the first file has been modified; before sending the updated data to the second device, the method also includes: saving the second PBA in the first inode; setting the state of the first file to the second state, and the second state is used to indicate that the first file has not been modified. Based on this design, a file may be modified multiple times. If the PBA of the data updated this time and the PBA of the data updated last time are both saved in the second inode, it is impossible to distinguish the difference between the data updated this time and the data updated last time. Therefore, by converting the state of the file, it is possible to determine whether the file has been modified at present, and then the location where the file has been modified can be determined by only traversing the PBA in the second inode. Not only does it not need to reduce the CPU resource overhead by calculating the hash value in an intensive way, but it is also possible to distinguish the difference between the data updated this time and the data updated last time.

[0012] In a possible design, determining the updated data according to the second PBA includes: determining the updated data according to the second PBA stored in the first inode corresponding to the snapshot of the first file. Based on this design, the updated data in the snapshot of the file can be uploaded to the cloud, which can reduce the number of network I / Os and save network bandwidth while avoiding consistency problems caused by file changes during the upload process.

[0013] In a second aspect, a data storage device is provided, which is applied to a first device, and the device includes a processing unit and a communication unit; the processing unit is used to: in response to a data storage request for a first file, obtain an inode corresponding to the first file, the inode includes a first inode and a second inode, the first inode is used to store a first PBA, the first PBA is a PBA corresponding to the unupdated data of the first file, and the second inode is used to store a second PBA, the second PBA is a PBA corresponding to the updated data of the first file; determine the updated data according to the second PBA; the communication unit is used to: send the updated data to the second device.

[0014] In a possible design, the second inode is also used to store a third PBA, and the third PBA is used to indicate that the PBA corresponding to the data of the first file is stored in the first inode.

[0015] In one possible design, the processing unit is also used to: create a second file that does not include data, the second file corresponds to a third inode, and the third inode includes a fourth PBA; generate a second inode based on the third inode, the fourth PBA, and the third PBA; generate an inode corresponding to the first file based on the second inode and the first inode corresponding to the first file.

[0016] In one possible design, the processing unit is further used to: create a third file that does not include data, the third file corresponds to a fourth inode, and the fourth inode includes a fourth PBA; set the fourth PBA to the third PBA; and generate a snapshot of the first file based on the third file, the fourth inode and the first inode.

[0017] In one possible design, the first file is in a first state, and the first state is used to indicate that the first file has been modified; the processing unit is also used to: save the second PBA to the first inode; set the state of the first file to a second state, and the second state is used to indicate that the first file has not been modified.

[0018] In one possible design, the processing unit is specifically configured to determine the update data according to the second PBA stored in the first inode corresponding to the snapshot of the first file.

[0019] According to a third aspect, a device is provided, comprising a processor, a memory and a communication interface, wherein the memory and the communication interface are coupled to the processor, the communication interface is used to communicate with other devices, the memory is used to store computer program code, and the computer program code comprises computer instructions, and the processor reads the computer instructions from the memory so that the device executes the method described in the first aspect and any one of the designs thereof.

[0020] Optionally, the memory may be coupled to the processor, or may be independent of the processor.

[0021] Exemplarily, the communication interface may be a transceiver, an input / output interface, an interface circuit, an output circuit, an input circuit, a pin or a related circuit, etc.

[0022] In one possible design, the device also includes a display screen, which can be used for the device to perform display operations.

[0023] In a fourth aspect, a computer-readable storage medium is provided, the computer-readable storage medium comprising a computer program, and when the computer program runs on a device, the device executes the method described in the first aspect and any one of the designs thereof.

[0024] In a fifth aspect, a computer program product is provided. When the computer program product runs on a computer, the computer executes the method described in the first aspect and any one of the designs thereof.

[0025] In a sixth aspect, a chip system is provided, comprising at least one processor and at least one interface circuit, wherein the at least one interface circuit is used to perform transceiver functions and send instructions to at least one processor, and when the at least one processor executes the instructions, the at least one processor executes the method described in the first aspect and any one of the designs thereof.

[0026] In a seventh aspect, a communication system is provided, including a first device and a second device, wherein the first device and the second device implement the method provided in an embodiment of the present application through interaction.

[0027] It should be noted that the technical effects brought about by any design in the above-mentioned second to seventh aspects can refer to the technical effects brought about by the corresponding design in the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1 A schematic diagram of determining a physical block of a file on a disk according to a mapping relationship between LBA and PBA provided in an embodiment of the present application;

[0029] Figure 2 A schematic diagram of the structure of a file system provided in an embodiment of the present application;

[0030] Figure 3 A schematic diagram of the architecture of a communication system provided in an embodiment of the present application;

[0031] Figure 4 A schematic diagram of the architecture of a centralized storage system provided in an embodiment of the present application;

[0032] Figure 5 A schematic diagram of the hardware structure of a host provided in an embodiment of the present application;

[0033] Figure 6 A software structure block diagram of a host provided in an embodiment of the present application;

[0034] Figure 7 A schematic diagram of a double-layer inode structure provided in an embodiment of the present application;

[0035] Figure 8 A schematic diagram of a PBA stored in a double-layer inode structure provided in an embodiment of the present application;

[0036] Fig. 9 A schematic diagram of a mapping relationship between LBA and PBA stored in a double-layer inode structure provided in an embodiment of the present application;

[0037] Fig.10 A schematic diagram of a process of converting a single-layer inode structure into a double-layer inode structure provided in an embodiment of the present application;

[0038] Fig.11 A schematic diagram of a process for creating a file snapshot provided in an embodiment of the present application;

[0039] Fig.12A schematic diagram of a process of file state conversion provided in an embodiment of the present application;

[0040] Fig.13 A schematic diagram of a data storage method provided in an embodiment of the present application;

[0041] Fig.14 A schematic diagram of the structure of a data storage device provided in an embodiment of the present application;

[0042] Fig.15 A schematic diagram of the structure of a chip system provided in an embodiment of the present application. DETAILED DESCRIPTION

[0043] In the description of this application, unless otherwise specified, " / " indicates that the objects associated with each other are in an "or" relationship, for example, A / B can represent A or B; "and / or" in this application is merely a description of the association relationship between associated objects, indicating that three relationships may exist, for example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural.

[0044] In the description of this application, unless otherwise specified, "plurality" means two or more than two. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b, or c can mean: a, b, c, a and b, a and c, b and c, a and b and c, where a, b, and c can be single or multiple.

[0045] In addition, in order to clearly describe the technical solutions of the embodiments of the present application, in the embodiments of the present application, words such as "first" and "second" are used to distinguish the same items or similar items with substantially the same functions and effects. Those skilled in the art can understand that words such as "first" and "second" do not limit the quantity and execution order, and words such as "first" and "second" do not necessarily limit the difference.

[0046] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a concrete way for easy understanding.

[0047] The features, structures or characteristics in this application may be combined in one or more embodiments in any suitable manner. In various embodiments of this application, the size of the sequence number of each process does not mean 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.

[0048] Some optional features in the embodiments of the present application may be implemented independently in some scenarios without relying on other features to solve corresponding technical problems and achieve corresponding effects. They may also be combined with other features in some scenarios as needed.

[0049] In this application, unless otherwise specified, the same or similar parts between the various embodiments can refer to each other. In each embodiment of this application, if there is no special description and logical conflict, the terms and / or descriptions between different embodiments are consistent and can be referenced to each other, and the technical features in different embodiments can be combined to form new embodiments according to their inherent logical relationships. The implementation methods of this application do not constitute a limitation on the scope of protection of this application.

[0050] In addition, the network architecture and business scenarios described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Ordinary technicians in this field can know that with the evolution of network architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

[0051] To facilitate understanding, the technical terms and related concepts that may be involved in the embodiments of the present application are first introduced below.

[0052] 1. I / O operations

[0053] In a computer, all elements are files, and files are the external manifestation of a stream. In the process of information exchange, computers operate on these streams, referred to as I / O operations. For example, reading data from a stream and writing data to a stream are all I / O operations.

[0054] 2. Cloud Storage

[0055] Cloud storage is an online storage model that stores data on multiple virtual servers usually hosted by a third party, rather than storing data on a computer's hard drive or other local storage device. Cloud storage refers to a system that uses cluster applications, network technology, or distributed file systems to bring together various types of storage devices in the network through application software to work together and provide external data storage and business access functions.

[0056] 3. Snapshot

[0057] Snapshot is a point-in-time data copy technology that can record and save data at a certain moment. Snapshots can be used to restore data. For example, when data needs to be restored in the event of a certain failure, snapshots can be used to restore data to the state at the point in time recorded by the snapshot.

[0058] Snapshot technology is divided into two categories: physical copy and logical copy. Physical copy is a complete copy of the original data. Logical copy is a copy of only the data that has changed.

[0059] 4. Zero Copy

[0060] Zero copy means that when a computer performs I / O operations, the CPU does not need to copy data from one storage area to another storage area, thereby reducing context switching and CPU copy time.

[0061] 5. Index node (inode)

[0062] Files are stored on the hard disk. The smallest storage unit of the hard disk is called a sector, and each sector stores 512 bytes. When the operating system reads the hard disk, it does not read sectors one by one, which is too inefficient. Instead, it reads multiple sectors continuously at one time, that is, it reads a block (or physical block, or physical block, etc.) at one time. Block is the smallest unit of file access. The most common block size is 4 (Kilobyte, KB), that is, 8 consecutive sectors make up a block. The data of the file is stored in the block, and the area used to store the file's meta information (such as: the creator of the file, the creation date, the file size, etc.) is called inode.

[0063] In addition to storing the metadata of the file, the inode can also store the index information of the file storage block, which can be called the physical block address (PBA). Among them, PBA specifies the address rules according to the hardware characteristics of the storage device. Different physical storage devices have different PBA codes. The only PBA is the original addressing mechanism when the hard disk leaves the factory and is fixed.

[0064] For example, if the block size is 4KB, and the file size is 8KB, the file is stored in two blocks on the disk. Then the inode can index the two blocks by the PBAs of the two blocks saved. For example, if the first data block of the file is located at the 100th block on the disk, and the second data block is located at the 200th block on the disk, then the PBAs of the two blocks on the disk corresponding to the file can be PBA=100 and PBA=200.

[0065] The first data block, the second data block, etc. of a file can be called a logical block (or a logical block, or a data block, etc.), and each logical block has a corresponding logical block address (logical block address, LBA). Among them, LBA can refer to the address of a data block. For example, if the data blocks of a file are located by numbering from 1, then the LBA corresponding to the first data block of the above file is 1, and the LBA corresponding to the second data block is 2, etc.

[0066] In some embodiments, a mapping relationship between LBA and PBA can be constructed. In combination with the examples described above, two mapping relationships can be constructed, such as a mapping relationship between LBA=1 and PBA=100. A mapping relationship between LBA=2 and PBA=200, etc. This mapping relationship can be used to find the corresponding physical block in the disk according to the data block of the file. This mapping relationship between LBA and PBA can be called a block map (or block index), etc.

[0067] In some embodiments, the mapping relationship between LBA and PBA can be stored in the inode.

[0068] For example, Figure 1 A schematic diagram of determining the physical block of a file on a disk according to a mapping relationship between LBA and PBA provided by an embodiment of the present application is shown.

[0069] like Figure 1 As shown in the figure, file 1 includes three data blocks, data block 1, data block 2 and data block 3. The LBAs corresponding to these three data blocks are LBA=1, LBA=2 and LBA=3 respectively. By searching the mapping relationship between LBA and PBA in the inode, it can be determined that LBA=1 corresponds to PBA=100, LBA=2 corresponds to PBA=101, and LBA=3 corresponds to PBA=201. Then, according to the PBA, the physical block on the disk corresponding to the data block of the file can be found (such as Figure 1 medium black square).

[0070] 6. File System

[0071] A file system is a structured way of storing and organizing data files. For example, Figure 2 A schematic diagram of the structure of a file system provided in an embodiment of the present application is shown.

[0072] All data in a computer are 0s and 1s. A series of 01 combinations stored on hardware media is completely indistinguishable and unmanageable for a computer. Therefore, computers use the concept of "files" to organize these data. Data for the same purpose is organized into different types of files according to the structure required by different applications. Different suffixes are usually used to refer to different types, and then the computer gives each file a name that is easy to understand and remember.

[0073] When there are many files, the computer divides them into several groups (such as Figure 2 Each group of files is placed in the same directory (or folder, such as Figure 2 In addition to files, there can also be sub-directories (called sub-directories or sub-folders) under the directory, and all files and directories form a tree structure. This tree structure has a special name: file system. There are many types of file systems, the common ones are FAT / FAT32 / NTFS in Windows, EXT2 / EXT3 / EXT4 / XFS / BtrFS in Linux, etc.

[0074] To facilitate searching, we start from the root node and go down the directories one level at a time until we reach the file itself. We concatenate the names of these directories, subdirectories, and files with special characters (e.g., "\" for Windows / DOS and " / " for Unix-like systems). This string of characters is called a file path, such as " / etc / systemd / system.conf" in Linux or "C:\Windows\System32\taskmgr.exe" in Windows. A path is a unique identifier for accessing a specific file. For example, D:\data\file.exe in Windows is a file path, which indicates the file.exe file in the data directory under the D partition.

[0075] In some scenarios, when the mobile phone application uses cloud storage to store data, for each file in the application, a snapshot of the file is first created by physical copying, and then the data in the snapshot is uploaded to avoid consistency problems caused by file changes during the upload process. It can be understood that the consistency problem can refer to the modification of the file during the upload process to the cloud, which causes the data uploaded to the cloud to be inconsistent with the original data after being restored. This is called a consistency problem. Therefore, by creating a snapshot of the file and then uploading the data in the snapshot to the cloud, when the original file is modified, it will not affect the upload of the data in the snapshot, thereby ensuring data consistency.

[0076] However, in this solution, since a snapshot of a file needs to be created by physical copying, a large amount of write I / O will be generated, which will block the writing of other applications and affect the user experience.

[0077] Based on this, in related solutions, the new generation file system (XFS) and B-tree file system (BtrFS) provide reflink features to achieve zero-copy snapshot creation of files. The reflink feature refers to copying a file without generating a large amount of write I / O. However, since XFS and BtrFS are designed for server loads, their random write performance is poor and they are not suitable for installation and use in mobile phones.

[0078] In other scenarios, when mobile phone applications use cloud storage to store data, they may use differential technology. Differential technology refers to dividing a file into multiple chunks, each of which has a corresponding hash value. When a chunk is modified, the hash value corresponding to the chunk will also change. Therefore, by calculating the hash value corresponding to the chunk to determine the modified chunk, only the modified chunk is uploaded to the cloud storage. Differential technology can reduce the number of network I / Os and save network bandwidth. However, it will occupy a large amount of CPU resources. And for mobile phones, which have weak hardware conditions and high power consumption requirements, this method will not only compete with other applications for CPU resources, but also affect the battery life of the mobile phone.

[0079] Based on this, in the relevant scheme, the combination of remote synchronization (Rsync) and Inotify can realize real-time monitoring of the information of each file operation (such as the address offset of the newly written file, the file size, etc.), so as to determine the location where the file is modified, and only upload the data of the modified location to the cloud. Among them, Inotify can be used to monitor which file is modified, and Rsync can be used to monitor which specific location in the modified file is modified. However, Inotify is used in the server. Due to the strict file permission management mechanism in the mobile phone, one application cannot monitor the information of file operations of other applications, that is, it is impossible to monitor the information of file operations across applications. Therefore, Inotify cannot be used in the mobile phone to realize the monitoring of file operation information.

[0080] Based on the above technical problems, the embodiment of the present application provides a data storage method that can achieve zero-copy snapshot creation of files, reduce the number of write I / Os generated, and improve user experience. It is also possible to determine the location where the file is modified without calculating the hash value, and then only upload the data at the modified location to the cloud, while reducing the number of network I / Os and saving network bandwidth, and reducing the overhead of CPU resources.

[0081] For example, Figure 3 The schematic diagram of the architecture of a communication system for applying a data storage method provided in an embodiment of the present application is shown. Figure 3 As shown, the communication system 10 includes one or more hosts 11 ( Figure 3 Only one is shown) and a storage device 12.

[0082] Among them, Figure 3 In the application scenario shown, users can access data through applications. The computer running these applications can be called a "host". The host can be a physical machine or a virtual machine (VM). Physical hosts include but are not limited to desktop computers, servers, and mobile devices. Exemplary, mobile devices can include but are not limited to mobile phones, tablet computers, laptops, personal digital assistants (PDAs), augmented reality (AR) devices, virtual reality (VR) devices, artificial intelligence (AI) devices, wearable devices, etc.

[0083] Optionally, the operating system installed on the host 11 includes but is not limited to Or other operating systems. This application does not limit the specific type of the host 11 or the installed operating system.

[0084] In an optional implementation, the host may run on the storage device 12 .

[0085] It is worth noting that, in some cases, the above-mentioned host may also be referred to as a client.

[0086] The storage device 12 may be any storage device with storage capacity, such as a server or a cloud device. The server may be a single server or a server cluster composed of multiple servers. The present application does not impose any limitation on the specific type of the storage device 12.

[0087] Optionally, the storage device 12 and the host 11 may be devices of the same type or devices of different types.

[0088] For example, Figure 3 The host 11 is shown as a mobile phone and the storage device 12 is shown as a server.

[0089] In a possible example, the host accesses the storage device 12 through a network to access data. For example, the network may include a switch (not shown in the figure).

[0090] In another possible example, the host may also communicate with the storage device 12 to access data through a wired connection, such as a universal serial bus (USB) or a peripheral component interconnect express (PCIe) high-speed bus.

[0091] It can be understood that the embodiment of the present application does not impose any limitation on the communication method adopted between the host 11 and the storage device 12.

[0092] Optional, Figure 3 The simplified schematic diagram is provided for ease of understanding. In actual applications, the above system may further include other devices which are not shown in the figure.

[0093] The data storage method provided in the embodiment of the present application can be executed by the host 11. Optionally, the storage system used by the host 11 can be a centralized storage system or a distributed storage system. Among them, the centralized storage system is characterized by having a unified entrance, and all data from external devices must pass through this entrance. This entrance is the engine of the centralized storage system. The engine is the most core component of the centralized storage system, and many advanced functions of the storage system are implemented in it.

[0094] For example, host 11 uses a centralized storage system. Figure 4 A schematic diagram of the architecture of a centralized storage system provided in an embodiment of the present application is shown.

[0095] like Figure 4 As shown, the engine 121 may have one or more controllers. Figure 4 The example of the engine 121 including one controller is used for explanation. In a possible example, if the engine 121 has multiple controllers, any two controllers may have a mirror channel to achieve the function of any two controllers backing up each other, thereby preventing the entire host 11 from being unavailable due to hardware failure.

[0096] The engine 121 further includes a front-end interface 1211 and a back-end interface 1214, wherein the front-end interface 1211 is used to communicate with other devices, and the back-end interface 1214 is used to communicate with the hard disk to expand the capacity of the host 11. Through the back-end interface 1214, the engine 121 can connect more hard disks to form a very large storage resource pool.

[0097] In hardware, such as Figure 4 As shown, the controller includes at least a processor 1212 and a memory 1213. The processor 1212 is a central processing unit (CPU) for processing data access requests from outside the host 11 (server or other storage system), and is also used to process requests generated inside the host 11. The processor in the embodiment of the present application can also be a neural processing unit (NPU) or a graphics processing unit (GPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. The general-purpose processor can be a microprocessor or any conventional processor.

[0098] Exemplarily, when the processor 1212 receives write data requests sent by other devices through the front-end interface 1211, the data in these write data requests will be temporarily stored in the memory 1213. When the total amount of data in the memory 1213 reaches a certain threshold, the processor 1212 sends the data stored in the memory 1213 to at least one of the mechanical hard disk drive (HDD) 1221, the mechanical hard disk 1222, the solid state drive (SSD) 1223 or other hard disks 1224 through the back-end port for persistent storage. In one example, the other hard disk 1224 can be a HDD, an SSD, a shingled magnetic recording (SMR) disk, or an SSD that supports a zoned namespace (ZNS), or other storage, such as a persistent memory (PMEM), etc.

[0099] Memory 1213 refers to an internal memory that directly exchanges data with the processor. It can read and write data at any time and at a very fast speed. It serves as a temporary data storage for the operating system or other running programs. Memory includes at least two types of memory. For example, memory can be either a random access memory or a read-only memory (ROM). For example, the random access memory is DRAM or SCM. DRAM is a semiconductor memory, and like most random access memories (RAM), it is a volatile memory device. However, DRAM and SCM are only exemplary descriptions in this embodiment. Memory can also include other random access memories, such as static random access memory (SRAM), etc. As for read-only memory, for example, it can be a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), etc. In addition, the memory 1213 can also be a dual in-line memory module or a dual-line memory module (Dual In-line Memory Module, abbreviated as DIMM), that is, a module composed of dynamic random access memory (DRAM), or an SSD. In practical applications, multiple memories 1213 and different types of memories 1213 can be configured in the controller. This embodiment does not limit the number and type of memory 1213. In addition, the memory 1213 can be configured to have a power preservation function. The power preservation function means that when the system loses power and then powers on again, the data stored in the memory 1213 will not be lost. A memory with a power preservation function is called a non-volatile memory.

[0100] The memory 1213 stores a software program, and the processor 1212 runs the software program in the memory 1213 to manage the hard disk.

[0101] Exemplarily, the above-mentioned memory 1213 may also be other memories, which can be used to store a set of computer instructions; when the processor 1212 executes the set of computer instructions, the method provided by the embodiment of the present invention can be implemented. For example, the other memory may be, but is not limited to, a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a ROM, a PROM, an EPROM, an electrically erasable programmable read-only memory (Electrically EPROM, EEPROM) or a flash memory. The volatile memory may be a RAM, which is used as an external cache. By way of exemplary but not limiting description, many forms of RAM are available, such as SRAM, DRAM, synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous connection dynamic random access memory (SLDRAM) and direct rambus RAM (DR RAM).

[0102] in addition, Figure 4 Only one engine 121 is shown in the figure. However, in actual applications, the storage system may include two or more engines 121, and redundancy or load balancing is performed between the multiple engines 121.

[0103] in addition, Figure 4 The host 11 shown can also adopt a distributed storage system, which includes a computing node cluster and a storage node cluster. The computing node cluster includes one or more computing nodes, and each computing node can communicate with each other. The computing node can be a server, a desktop computer, or a controller of a storage array. In hardware, the computing node can include a processor, a memory, and a network card. Among them, the processor is a CPU for processing data access requests from outside the computing node, or requests generated inside the computing node. Exemplarily, when the processor receives a write data request sent by a user, the data in these write data requests will be temporarily stored in the memory. When the total amount of data in the memory reaches a certain threshold, the processor sends the data stored in the memory to the storage node for persistent storage. In addition, the processor is also used for data calculation or processing, such as metadata management, deduplication, data compression, virtualized storage space, and address conversion.

[0104] For example, Figure 5 A schematic diagram of the hardware structure of a host 11 provided in an embodiment of the present application is shown.

[0105] The host 11 includes at least one processor 201 , a communication line 202 , a memory 203 and at least one communication interface 204 .

[0106] The processor 201 may be a general-purpose CPU, a microprocessor, an ASIC, or one or more integrated circuits for controlling the execution of the program of the present application.

[0107] The communication link 202 may include a pathway to transmit information between the above-mentioned components.

[0108] The communication interface 204 is used to communicate with other devices. In the embodiment of the present application, the communication interface 204 can be a module, a circuit, a bus, an interface, a transceiver or other device capable of implementing a communication function. Optionally, when the communication interface is a transceiver, the transceiver can be an independently arranged transmitter, which can be used to send information to other devices, and the transceiver can also be an independently arranged receiver for receiving information from other devices. The transceiver can also be a component that integrates the functions of sending and receiving information, and the embodiment of the present application does not limit the specific implementation of the transceiver.

[0109] The memory 203 may be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM) or other types of dynamic storage devices that can store information and instructions, or an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, an optical disc storage (including a compressed optical disc, a laser disc, an optical disc, a digital versatile disc, a Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of an instruction or data structure and can be accessed by a computer. The memory 203 may exist independently and be connected to the processor 201 via the communication line 202. The memory 203 may also be integrated with the processor 201.

[0110] The memory 203 is used to store computer-executable instructions for implementing the solution of the present application. The processor 201 is used to execute the computer-executable instructions stored in the memory 203, thereby implementing the method provided in the embodiment of the present application.

[0111] Optionally, the computer-executable instructions in the embodiments of the present application may also be referred to as application code, instructions, computer program or other names, which are not specifically limited in the embodiments of the present application.

[0112] In a specific implementation, as an embodiment, the processor 201 may include one or more CPUs, such as Figure 5 CPU0 and CPU1 in.

[0113] In a specific implementation, as an embodiment, the host 11 may include multiple processors, such as Figure 5 201 and processor 205 in the embodiment of the present invention. Each of these processors may be a single-CPU processor or a multi-CPU processor. The processor herein may refer to one or more devices, circuits, and / or processing cores for processing data (e.g., computer program instructions).

[0114] The host 11 mentioned above may be a general device or a dedicated device, and the embodiment of the present application does not limit the type of the host 11.

[0115] In some other embodiments of the present application, the host 11 may include Figure 5 More or fewer components shown, or some components are combined, or some components are split, or some components are replaced, or different component arrangements are arranged. The components shown in the figure can be implemented in hardware, software, or a combination of software and hardware.

[0116] In some embodiments, the software system of the host 11 may adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present invention takes the layered architecture as an example to exemplify the software structure of the host 11.

[0117] Figure 6 A software structure block diagram of a host 11 provided in an embodiment of the present application is shown.

[0118] The layered architecture divides the software into several layers, each with a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the host 11 includes two layers, namely, the application layer and the kernel layer from top to bottom.

[0119] The application layer may include a series of application programs, such as the first application, as well as a file upload module, an interface module, etc. Among them, the application program may be used to implement data access. The file upload module may be used to upload data in the host 11 to other device storage, such as the cloud, etc. The interface module may be used to start the file difference detection module included in the file system to determine the location where the file is modified, so as to achieve the purpose of uploading the data at the location to other device storage.

[0120] The kernel layer includes the file system and the virtual file system (VFS) layer.

[0121] Exemplarily, the file system can be a flash friendly file system (F2FS). F2FS has a log-structured feature, which means that when the file system writes new data, it will not write the new data to the storage location where the old data is stored, but will write the new data to a new storage location, and then release the storage location of the old data for the new data to use. This feature can significantly improve performance for random write scenarios. Of course, the file system can also be other file systems, such as EXT4, etc., and this application does not make specific restrictions on this.

[0122] As an abstract layer, the VFS layer provides a unified file access interface for the application layer upwards and is compatible with various file systems downwards. The VFS layer includes an inode conversion module and a snapshot creation module. Among them, the inode conversion module can be used to convert a single-layer inode structure into a double-layer inode structure. In some embodiments, the converted double-layer inode structure can include an upper inode (U-inode) and a lower inode (L-inode). For the introduction of U-inode and L-inode, please refer to the following description.

[0123] like Figure 7 As shown, file 1 has a single-layer inode structure, such as only including inode 1. The single-layer inode structure of file 1 can be converted into a double-layer inode structure, such as including U-inode and L-inode, by the inode conversion module.

[0124] The snapshot creation module can be used to create a snapshot of a file with zero copy. For the specific creation process, please refer to the following description.

[0125] The file system includes a difference detection module, which can be used to find the LBA stored in the U-inode and / or L-inode, determine the location where the file is modified based on the difference of the stored LBA, and then find the modified data.

[0126] Understandably, Figure 6 The division of the levels and the modules included in each level are only exemplary and do not constitute a limitation of the present application. In practical applications, there may be other division methods, and each module may also be located at a different level, such as: the difference detection module may also be located at the VFS layer.

[0127] The technical solutions involved in the following embodiments can all be implemented in Figure 4 , Figure 5 , Figure 6 The device of the structure shown, and Figure 1 The system is implemented in the system with the architecture shown.

[0128] It can be understood that in the following embodiments of the present application, the host 11 is described as the host and the storage device 12 is described as the storage device.

[0129] The embodiment of the present application provides a data storage method, after a host receives a data storage request for a file, the host can send the file data to a storage device according to the data storage request. Correspondingly, after the storage device receives the data from the host, the storage device can store the data.

[0130] In some embodiments, the file in the host may adopt a single-layer inode structure, that is, one file has one inode. After the host receives a data storage request for the file, in response to the data storage request, the single-layer inode structure of the file may be converted into a double-layer inode structure, that is, one file has two inodes, such as a U-inode and an L-inode. Of course, if the file in the host already has a double-layer inode structure, the solution described in this embodiment may not be executed.

[0131] Optionally, in the embodiment of the present application, the data storage request for a file may refer to a request to store the data of the file in a storage device. Exemplarily, the data storage request for a file may be triggered by an application corresponding to the file, or by a user, etc.

[0132] In some embodiments, L-inode can be used to save the existing data (or data blocks) of the file before the file is converted into a two-layer inode structure, that is, one or more of the LBA, PBA, and mapping relationship between LBA and PBA corresponding to the original data. U-inode can be used to save the LBA, PBA, and mapping relationship between LBA and PBA corresponding to the updated data of the file after the file is converted into a two-layer inode structure. Optionally, the updated data may include but is not limited to data after the original data is changed, newly written data, etc.

[0133] In some embodiments, after a file is converted into a double-layer inode structure, before the data of the file is modified, the value of the PBA stored in the U-inode is R. R can be used to indicate that the real value of the PBA is located in the L-inode. Of course, R can also use other identifiers, and this application does not limit this.

[0134] For example, Figure 8 As shown in (1), in the double-layer inode structure of file 1, the value of PBA in U-inode is PBA=R, and the value of PBA in L-inode is PBA=101, PBA=102, PBA=103, PBA=104. When the application accesses file 1, it can first access U-inode. Since the value of PBA stored in U-inode is "R", the application can determine that the real PBA is stored in L-inode according to this indication and needs to access L-inode. Finally, the application can access the data with PBA 101 to 104.

[0135] In some scenarios, since file 1 is updated with data, for example, the data in PBA 103 and PBA 104 are modified (or updated), the host will save the PBA of the updated data in the U-inode. Figure 8 As shown in (2), PBA=301 and PBA=302 stored in U-inode are the PBAs of the updated data. Later, when the application accesses the data of file 1 again, it can first access U-inode. Since non-R PBAs are stored in U-inode, the application can directly access the data in these non-R PBAs without accessing the data in L-inode. In other words, the application can access the data in PBAs 101, 102, 301, and 302.

[0136] Understandably, Figure 8 Only the PBA stored in the inode is shown, and the inode may also store the LBA and the mapping relationship between the LBA and the PBA. Figure 8 , Fig. 9 An example of a mapping relationship between LBA and PBA stored in a U-inode and a L-inode provided in an embodiment of the present application is shown.

[0137] Similarly, combined Fig. 9 As shown in (1), when the application accesses the data block with LBA 1 in file 1, it can also first access the U-inode. Since the PBA value corresponding to LBA=1 stored in the U-inode is R, the application can determine that it needs to access the L-inode based on this indication. The PBA value corresponding to LBA=1 stored in the L-inode is 101, so the application will eventually access the data in PBA 101.

[0138] like Fig. 9As shown in (2), if file 1 is updated, for example, data blocks with LBA 3 and LBA 4 are changed, the host saves the PBA of the updated data blocks in the U-inode, specifically PBA 301 and PBA 302. Later, when the application accesses the data block with LBA 3 in file 1, it can also access the U-inode first. Since the PBA value corresponding to LBA 3 in the U-inode is 301, not R, application 1 can determine to directly access the data in PBA 301.

[0139] Optionally, the order of accessing the U-inode and the L-inode may be to first access the U-inode and then access the L-inode. In this way, when there is a non-R PBA in the U-inode, the application directly accesses the U-inode to determine to find data according to the non-R PBA in the U-inode. For these PBAs, there is no need to further access the L-inode. This can save data access overhead, speed up data access efficiency, and save power consumption.

[0140] Of course, it is also possible to access the L-inode first and then the U-inode. In this way, the application may need to access both the L-inode and the U-inode before determining which inode to use to access the data based on the PBA stored therein.

[0141] In this embodiment, as a possible implementation, Fig.10 A schematic diagram of a process of converting a single-layer inode structure of a file into a double-layer inode structure provided by an embodiment of the present application is shown.

[0142] like Fig.10As shown, file 1 has a single-layer inode structure, and there is only one corresponding inode, such as inode1. The inode1 stores the PBA corresponding to the data of file 1, such as PBA=101, PBA=102, PBA=103, etc. The host first creates an empty file (or intermediate file, etc.), such as file 2. The empty file does not contain any data, so the inode corresponding to the empty file (such as inode2) does not contain any data, that is, the value of PBA in inode2 is empty (NULL). Then the host initializes the value of PBA in inode2 to R. After the initialization is completed, inode2 replaces inode1 in file 1. Finally, inode2 can be linked to inode1 by pointer. In other words, inode2 can store the pointer (or index, or address, etc.) of inode1 to facilitate the search for inode1. In this way, inode2 is the U-inode of file 1, and inode1 is the L-inode of file 1, which completes the conversion of the double-layer inode structure of file 1. In this process, since no physical copy operation is generated, the overhead of the host system is low.

[0143] Optional, Fig.10 The described scheme is based on the example of creating inode 2 by creating file 2. Of course, in other embodiments, inode 2 may also be created directly to achieve the conversion of the double-layer inode structure of file 1, and this application does not limit this.

[0144] In some embodiments, after the host receives a data storage request for a file, it can also create a snapshot of the file in response to the data storage request and before sending the file data to the storage device, and then send the data in the snapshot to the storage device to avoid consistency problems caused by file modifications during the upload process.

[0145] For example, Fig.11 A schematic diagram of a process of creating a file snapshot provided in an embodiment of the present application is shown.

[0146] like Fig.11As shown, file 1 is the file to be uploaded to the storage device. File 1 has a double-layer inode structure, inode 1 is the L-inode of file 1, and inode 2 is the U-inode of file 1. The host first creates a file 3 with a single-layer inode structure. File 3 is an empty file. The empty file does not contain any data. Therefore, the inode of file 3 (such as inode 3) does not contain any data, that is, the value of PBA in inode 3 is empty (NULL). Then the host initializes the value of PBA in inode 3 to R. After the initialization is completed, inode 3 is linked to inode 1 by means of a pointer. For the implementation of the pointer, please refer to the above description. In this way, inode 3 is the U-inode of file 3, and inode 1 is the L-inode of file 3, that is, a double-layer inode structure of file 3 is established.

[0147] Since the PBA of the updated data of file 1 is stored in the U-inode, that is, inode2, inode1 is used as an L-inode only to store the PBA of the original data of file 1. Therefore, inode1 is read-only for upper-layer applications, that is, the PBA in inode1 remains unchanged. In this way, file 3 becomes a snapshot of file 1. In addition to the overhead of creating file 3, this solution for creating a file snapshot does not read or write the data of file 1, and realizes zero-copy creation of file snapshots, reduces the number of write I / Os generated, and can improve user experience.

[0148] In some embodiments, after the host receives a data storage request for a file, in response to the data storage request, before sending the file data to the storage device, it can also first determine the modified data of the file, and then only send the modified data to the storage device, so as to reduce the number of network I / Os and save network bandwidth.

[0149] based on Figure 8 In the dual-layer inode structure, for a file, since the U-inode corresponding to the file is used to store the PBA of the updated data of the file, and the U-inode is used to store the PBA of the original data of the file, the host can determine the modified data of the file according to the value of the PBA in the U-inode, such as the PBA in the U-inode with a value other than R, which is the PBA corresponding to the modified data of the file.

[0150] Based on this solution, the location where the file is modified can be determined by traversing the PBA in the U-inode corresponding to the file, without the need for intensive calculations such as calculating hash values. Only the modified data is uploaded to the cloud, reducing the number of network I / Os and saving network bandwidth, while reducing the overhead of occupied CPU resources.

[0151] In some scenarios, a file may be modified multiple times. If the PBA of the updated data and the PBA of the last updated data are both stored in the U-inode, the host cannot distinguish the difference between the updated data and the last updated data.

[0152] Based on this, the embodiment of the present application provides a state machine solution. For each file, there are two states, S0 and S1. Among them, S0 is used to indicate that the file has not been modified, and the value of PBA in the U-inode corresponding to the file is R. S1 is used to indicate that the file has been modified, and the U-inode corresponding to the file contains a PBA with a value other than R.

[0153] For example, Fig.12 (a) indicates that the file is in S0 state. The PBA values ​​stored in the U-inode of the file are all R. The PBAs included in the L-inode (such as PBA=101 to PBA=106, etc.) are the PBAs corresponding to the original data of the file. Later, the file is modified. For example, if the data in the PBAs 103 to 106 of the file are modified, the PBAs corresponding to the modified data are 301 to 304. The values ​​of these PBAs are stored in the U-inode. Then the state of the file changes from Fig.12 The S0 state shown in (a) is converted to Fig.12 The host can determine the location where the file is modified based on the value of the PBA in the U-inode corresponding to the file in the S1 state. For example, the data in the PBA in the U-inode with a value other than R is the data of the file that has been modified. The host can then send only the modified data to the storage device.

[0154] Furthermore, the host synchronizes the PBA corresponding to the modified data in the U-inode, that is, the non-R PBA, to the L-inode, and the status of the file is changed from Fig.12 The S1 state shown in (b) is transformed again to Fig.12 The S0 state shown in (c) is shown in the figure. Fig.12 The U-inode corresponding to the file in the S0 state shown in (c) can record the PBA corresponding to the next modified data again.

[0155] Optionally, the data corresponding to the non-R PBA stored in the U-inode corresponding to the file in the S1 state can be uploaded to the cloud first, and then the non-R PBA stored in the U-inode is synchronized to the L-inode. Alternatively, the non-R PBA stored in the U-inode corresponding to the file in the S1 state can be synchronized to the L-inode first, and then the data corresponding to the non-R PBA is uploaded to the cloud.

[0156] It can be understood that the technical solutions described in the various embodiments of the present application can be used separately, and can also be used in any combination without conflict.

[0157] It can also be understood that in the embodiment of the present application, the first device can perform some or all of the steps in the embodiment of the present application, and these steps or operations are only examples. The embodiment of the present application can also perform other operations or variations of various operations. In addition, the various steps can be performed in different orders presented in the embodiment of the present application, and it is possible that not all operations in the embodiment of the present application need to be performed.

[0158] For example, Fig.13 A flow chart of a data storage method provided by an embodiment of the present application is shown, and the method can be executed by a first device. Exemplarily, the first device can be the above-mentioned host or a processor in the host. The method includes the following steps:

[0159] S1301. In response to a data storage request for a first file, obtain an inode corresponding to the first file.

[0160] Exemplarily, the first file may be any file stored in the host.

[0161] The inode corresponding to the first file is a double-layer inode structure. The double-layer inode structure, i.e., the inode corresponding to the first file, includes a first inode, i.e., an L-inode, and a second inode, i.e., an U-inode. The first inode is used to store a first PBA, which is a PBA corresponding to the unupdated data of the first file, and the second inode is used to store a second PBA, which is a PBA corresponding to the updated data of the first file.

[0162] In some embodiments, the second inode is also used to store a third PBA, that is, a PBA with a value of R. The third PBA can be used to indicate that the PBA corresponding to the data of the first file is stored in the first inode, that is, the real PBA corresponding to the data of the first file is located in the first inode.

[0163] In some embodiments of the present application, updated data and unupdated data refer to whether the current data has been updated relative to the last data. For example, if a file is modified for the first time, the updated data may refer to the data after the first modification of the file, and the unupdated data may refer to the data before the first modification of the file. If a file is modified for the second time, the updated data may refer to the data after the second modification of the file, and the unupdated data may refer to the data before the second modification of the file, but the data before the second modification of the file includes the data after the first modification of the file.

[0164] S1302. Determine update data according to the second PBA.

[0165] S1303: Send update data to the second device. Correspondingly, the second device receives the update data from the first device. Optionally, the second device may store the update data.

[0166] Based on the above scheme, after receiving a data storage request for a file, the inode corresponding to the file is obtained. The inode is a double-layer inode structure, in which one inode is used to store the PBA corresponding to the unupdated data of the file, and the other inode is used to store the PBA corresponding to the updated data of the file. In this way, the updated data of the file can be determined directly based on the PBA corresponding to the updated data of the file, without the need for intensive calculation such as calculating the hash value, thereby reducing the overhead of occupied CPU resources. Then, only the updated data is sent to the cloud storage, which can reduce the number of network I / Os and save network bandwidth.

[0167] In some embodiments, the file in the first device, such as the first file, may adopt a single-layer inode structure. Therefore, before step S1301, Fig.13 The method may further include steps S1301a to S1301c (not shown in the figure).

[0168] S1301a: Create a second file that does not include data.

[0169] The second file, that is, the empty file, corresponds to the third inode. The third inode includes the fourth PBA, that is, the PBA whose value is NULL.

[0170] S1301b. Generate a second inode according to the third inode, the fourth PBA, and the third PBA.

[0171] Exemplarily, the fourth PBA may be set to the third PBA, so that the third inode becomes the second inode.

[0172] S1301c. Generate an inode corresponding to the first file according to the second inode and the first inode corresponding to the first file.

[0173] It can be understood that the first inode corresponding to the first file may refer to the inode corresponding to the first file when the first file adopts a single-layer inode.

[0174] Exemplarily, the second inode may be linked to the first inode by means of a pointer, etc., so that an inode corresponding to the first file is generated.

[0175] Based on this solution, in some scenarios, since the application is in user mode and the inode is in kernel mode, the application cannot directly create an inode. Therefore, an inode can be created by creating an empty file, and the single-layer inode structure of the file can be converted to a double-layer inode structure.

[0176] In some embodiments, Fig.13 Before step S1303 shown, Fig.13 The method shown also includes steps S1303a to S1303c (not shown in the figure).

[0177] S1303a: Create a third file that does not include data.

[0178] The third file, that is, the empty file, corresponds to the fourth inode. The fourth inode includes the fourth PBA, that is, the PBA whose value is not empty.

[0179] S1303b. Set the fourth PBA as the third PBA.

[0180] That is, the value of PBA is set from empty to R.

[0181] S1303c. Generate a snapshot of the first file according to the third file, the fourth inode, and the first inode.

[0182] Exemplarily, the fourth inode may be linked to the first inode by means of a pointer, so that the third file becomes a snapshot of the first file.

[0183] Based on this solution, the third file shares the first inode with the first file, and the first inode is used to store the PBA corresponding to the unupdated data of the first file. Therefore, the first inode is read-only for the upper-layer application, so that the third file becomes a snapshot of the first file. In addition to the overhead of creating the third file, this solution for creating a file snapshot does not read or write the data of the first file, and realizes zero-copy creation of a file snapshot, reduces the number of write I / Os generated, and can improve user experience.

[0184] In some embodiments, the first file is in the first state, that is, the above-mentioned S1 state, and the first state is used to indicate that the first file is modified. Fig.13 Before step S1303 shown, Fig.13 The method shown also includes steps S1303d to S1303e (not shown in the figure).

[0185] S1303d. Save the second PBA into the first inode.

[0186] In some embodiments, when the first file is in the first state, the second inode corresponding to the first file may store only the second PBA, or may store both the second PBA and the third PBA. Thus, after the second PBA in the second inode is stored in the first inode, the second inode may store only the third PBA, or only the fourth PBA.

[0187] S1303e. Set the state of the first file to the second state.

[0188] The second state, namely the above-mentioned S0 state, is used to indicate that the first file has not been modified.

[0189] Based on this scheme, a file may be modified multiple times. If the PBA of the data updated this time and the PBA of the data updated last time are both saved in the second inode, it is impossible to distinguish the difference between the data updated this time and the data updated last time. Therefore, by changing the state of the file, it is possible to determine whether the file has been modified, and then the location where the file has been modified can be determined by only traversing the PBA in the second inode. Not only does it not require intensive calculations such as calculating hash values, it is also possible to distinguish the difference between the data updated this time and the data updated last time.

[0190] In this embodiment, as a specific implementation, Fig.13 The method step S1302 shown can be specifically implemented as follows: determine the updated data according to the second PBA stored in the first inode corresponding to the snapshot of the first file. Among them, since the first file and the snapshot of the first file share the first inode, the first inode corresponding to the snapshot of the first file is also the first inode corresponding to the first file. Based on this scheme, the second PBA in the first inode of the first file can be accessed through the snapshot of the first file, and the second PBA is the PBA corresponding to the updated data stored in the second inode. In this way, the updated data in the snapshot of the file can be uploaded to the cloud, and the number of network I / Os can be reduced and network bandwidth can be saved while avoiding consistency problems caused by file changes during the upload process.

[0191] It can be understood that a snapshot of a file can be created before or after the file is modified, and the present application does not limit the timing of creating a snapshot.

[0192] The following takes the first file as file 1, and when no data storage request for file 1 is received, file 1 adopts a single-layer inode structure as an example to specifically introduce the implementation.

[0193] When the first device receives a data storage request for file 1, in response to the data storage request, the single-layer inode structure of file 1 is converted into a double-layer inode structure. Subsequently, a snapshot of file 1 is created, and the snapshot of file 1 shares an L-inode with file 1. The values ​​of PBA in the snapshot of file 1 and the U-inode of file 1 are both R. At this time, the data of file 1 is the same as the data in the snapshot of file 1. Subsequently, file 1 is modified, and the PBA of the updated data of file 1 is stored in the U-inode of file 1. At this time, the first device can determine file 1 according to the snapshot of file 1, and then determine the updated data of file 1 according to the PBA stored in the U-inode of file 1. Subsequently, the PBA corresponding to the updated data is recorded in the memory, and then the PBA of the updated data in the U-inode of file 1 is synchronized to the L-inode. After synchronization, the value of PBA in the U-inode of file 1 is R or NULL. Finally, according to the memory record, the PBA corresponding to the new data stored in the L-inode can be accessed through the snapshot of file 1 to determine the updated data, and then only the updated data can be uploaded to the cloud.

[0194] It can be understood that this example is based on first creating a snapshot of file 1, and then synchronizing the PBA of the updated data in U-inode to L-inode. It is also possible to first synchronize the PBA of the updated data in U-inode to L-inode, and then create a snapshot of file 1, and the embodiment of the present application is not limited to this.

[0195] It can also be understood that in the embodiment of the present application, a double-layer inode structure is used to distinguish updated data from non-updated data, and the double-layer inode structure can also be an inode structure with more than two layers, such as a three-layer inode structure, a four-layer inode structure, etc. Updated data and non-updated data can also be distinguished in inodes of different levels to determine the location where the file is modified.

[0196] Taking the three-layer inode structure as an example, the first-layer inode can be used to store the PBA corresponding to the unupdated data, the second-layer inode can be used to store the PBA corresponding to the data updated for the first time, and the third-layer inode can be used to store the PBA corresponding to the data updated for the second time. Optionally, the PBA corresponding to the second updated data stored in the subsequent third-layer inode can also be synchronized to the second-layer inode, and / or the first-layer inode. Optionally, the PBA corresponding to the first updated data stored in the second-layer inode can also be synchronized to the first-layer inode. Further, the second-layer inode can be used to store the PBA corresponding to the data updated for the third time. The third-layer inode can be used to store the PBA corresponding to the data updated for the fourth time, and so on.

[0197] It can be understood that the solution provided in the embodiment of the present application and applicable to a two-layer inode structure is also applicable to an inode structure with more than two layers.

[0198] The above mainly introduces the solution provided by the embodiment of the present application from the perspective of the method. It is understandable that, in order to realize the above functions, the data storage device includes a hardware structure and / or software module corresponding to the execution of each function. In combination with the units and algorithm steps of each example described in the embodiment disclosed in this application, the embodiment of the present application can be implemented in the form of hardware or a combination of hardware and software. Whether a function is executed in a hardware or software-driven hardware manner depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the technical solution of the embodiment of the present application.

[0199] The present application is an embodiment that can divide the data storage device into functional modules according to the above method example. For example, each functional module can be divided corresponding to each function, or two or more functions can be integrated into one processing unit. The above integrated unit can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of units in the embodiment of the present application is schematic and is only a logical functional division. There may be other division methods in actual implementation.

[0200] like Fig.14 1400 is a schematic diagram of a data storage device provided in an embodiment of the present application. The data storage device 1400 can be applied to a first device to implement the methods described in the above method embodiments. Exemplarily, the data storage device 1400 may include: a processing unit 1401 and a communication unit 1402.

[0201] The processing unit 1401 is used to support the data storage device 1400 to execute Fig.13 And / or, the processing unit 1401 is further configured to support the data storage device 1400 in executing other steps executed by the first device in the embodiment of the present application.

[0202] The communication unit 1402 is used to support the data storage device 1400 to execute Fig.13 And / or, the communication unit 1402 is further configured to support the data storage device 1400 in executing other steps executed by the first device in the embodiment of the present application.

[0203] Optional, Fig.14 The data storage device 1400 shown may also include a display unit ( Fig.14 The display unit may be used to perform display operations, etc.

[0204] Optional, Fig.14 The data storage device 1400 shown may also include a storage unit 1403, which stores a program or instruction. When the processing unit 1401 executes the program or instruction, Fig.14 The data storage device 1400 shown may perform Fig.13 The method shown in et al.

[0205] Fig.14 The technical effect of the data storage device 1400 shown can be referred to Fig.13 The technical effects of the methods shown in the above will not be repeated here. Fig.14 The processing unit 1401 involved in the data storage device 1400 shown can be implemented by a processor or a processor-related circuit component, and can be a processor or a processing module. The communication unit 1402 can be implemented by a transceiver or a transceiver-related circuit component, and can be a transceiver or a transceiver module.

[0206] The present application also provides a chip system, such as Fig.15 As shown, the chip system includes at least one processor 1501 and at least one interface circuit 1502. The processor 1501 and the interface circuit 1502 can be interconnected via lines. For example, the interface circuit 1502 can be used to receive signals from other devices. For another example, the interface circuit 1502 can be used to send signals to other devices (such as processor 1501). Exemplarily, the interface circuit 1502 can read instructions stored in the memory and send the instructions to the processor 1501. When the instructions are executed by the processor 1501, the first device can execute the various steps performed by the first device in the above embodiment. Of course, the chip system can also include other discrete devices, which are not specifically limited in the embodiments of the present application.

[0207] Optionally, the processor in the chip system may be one or more. The processor may be implemented by hardware or by software. When implemented by hardware, the processor may be a logic circuit, an integrated circuit, etc. When implemented by software, the processor may be a general-purpose processor implemented by reading software code stored in a memory.

[0208] Optionally, the memory in the chip system may be one or more. The memory may be integrated with the processor or may be separately provided with the processor, which is not limited in the present application. Exemplarily, the memory may be a non-transient processor, such as a read-only memory ROM, which may be integrated with the processor on the same chip or may be provided on different chips. The present application does not specifically limit the type of memory and the arrangement of the memory and the processor.

[0209] Exemplarily, the chip system can be a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on chip (SoC), a central processor unit (CPU), a network processor (NP), a digital signal processor (DSP), a microcontroller unit (MCU), a programmable logic device (PLD) or other integrated chips.

[0210] It should be understood that each step in the above method embodiment can be completed by an integrated logic circuit of hardware in a processor or by instructions in the form of software. The method steps disclosed in the embodiments of the present application can be directly embodied as being executed by a hardware processor, or by a combination of hardware and software modules in a processor.

[0211] An embodiment of the present application provides a computer-readable storage medium, which includes a computer program. When the computer program runs on a device, the device executes the method described in the above method embodiment.

[0212] An embodiment of the present application provides a computer program product, which includes: a computer program or instructions, when the computer program or instructions are executed on a device or a computer, the device or computer executes the method described in the above method embodiment.

[0213] An embodiment of the present application provides a communication system, which includes a first device and a second device. The first device and the second device implement the method described in the above embodiment through interaction.

[0214] In addition, an embodiment of the present application also provides a device, which can specifically be a chip, component or module, and the device may include a connected processor and memory; wherein the memory is used to store execution instructions, and when the device is running, the processor can execute the execution instructions stored in the memory so that the device executes the methods in the above-mentioned method embodiments.

[0215] Among them, the equipment, communication system, computer-readable storage medium, computer program product or chip provided in this embodiment are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding methods provided above, and will not be repeated here.

[0216] Through the description of the above implementation methods, technical personnel in the relevant field can understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0217] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The various embodiments can be combined with each other or referenced to each other without conflict. The device embodiments described above are merely schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0218] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0219] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0220] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to perform all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.

[0221] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A data storage method, characterized in that: Applied to a first device, the method includes: In response to a data storage request for a first file, an index node inode corresponding to the first file is obtained, the inode includes a first inode and a second inode, the first inode is used to store a first physical block address PBA, the first PBA is a PBA corresponding to the unupdated data of the first file, and the second inode is used to store a second PBA, the second PBA is a PBA corresponding to the updated data of the first file; determining the update data according to the second PBA; The update data is sent to the second device.

2. The method according to claim 1, characterized in that The second inode is further used to store a third PBA, and the third PBA is used to indicate that a PBA corresponding to the data of the first file is stored in the first inode.

3. The method according to claim 2, characterized in that Before obtaining the inode corresponding to the first file in response to the data storage request for the first file, the method further includes: Creating a second file that does not include data, the second file corresponds to a third inode, and the third inode includes a fourth PBA; Generate the second inode according to the third inode, the fourth PBA, and the third PBA; An inode corresponding to the first file is generated according to the second inode and the first inode corresponding to the first file.

4. The method according to claim 2 or 3, characterized in that: Before sending the update data to the second device, the method further includes: Creating a third file that does not include data, the third file corresponds to a fourth inode, and the fourth inode includes a fourth PBA; Setting the fourth PBA to the third PBA; A snapshot of the first file is generated according to the third file, the fourth inode, and the first inode.

5. The method according to claim 4, characterized in that The first file is in a first state, and the first state is used to indicate that the first file is modified; Before sending the update data to the second device, the method further includes: Saving the second PBA in the first inode; The state of the first file is set to a second state, where the second state is used to indicate that the first file has not been modified.

6. The method according to claim 5, characterized in that The determining the update data according to the second PBA comprises: The updated data is determined according to a second PBA stored in the first inode corresponding to the snapshot of the first file.

7. A data storage device, characterized in that: The apparatus is applied to a first device, and comprises a processing unit and a communication unit; The processing unit is used for: In response to a data storage request for a first file, an inode corresponding to the first file is obtained, the inode including a first inode and a second inode, the first inode is used to store a first PBA, the first PBA is a PBA corresponding to the unupdated data of the first file, and the second inode is used to store a second PBA, the second PBA is a PBA corresponding to the updated data of the first file; determining the update data according to the second PBA; The communication unit is used for: The update data is sent to the second device.

8. The device according to claim 7, characterized in that The second inode is further used to store a third PBA, and the third PBA is used to indicate that a PBA corresponding to the data of the first file is stored in the first inode.

9. The device according to claim 8, characterized in that The processing unit is further used for: Creating a second file that does not include data, the second file corresponds to a third inode, and the third inode includes a fourth PBA; Generate the second inode according to the third inode, the fourth PBA, and the third PBA; An inode corresponding to the first file is generated according to the second inode and the first inode corresponding to the first file.

10. The device according to claim 8 or 9, characterized in that The processing unit is further used for: Creating a third file that does not include data, the third file corresponds to a fourth inode, and the fourth inode includes a fourth PBA; Setting the fourth PBA to the third PBA; A snapshot of the first file is generated according to the third file, the fourth inode, and the first inode.

11. The device according to claim 10, characterized in that The first file is in a first state, and the first state is used to indicate that the first file is modified; The processing unit is further used for: Saving the second PBA in the first inode; The state of the first file is set to a second state, where the second state is used to indicate that the first file has not been modified.

12. The device according to claim 11, characterized in that The processing unit is specifically configured to determine the updated data according to a second PBA stored in the first inode corresponding to the snapshot of the first file.

13. A device, characterized in that: The device comprises a processor, a memory and a communication interface, wherein the memory and the communication interface are coupled to the processor, the communication interface is used to communicate with other devices, the memory is used to store computer program code, the computer program code comprises computer instructions, and the processor reads the computer instructions from the memory so that the device executes the method according to any one of claims 1 to 6.

14. A computer-readable storage medium, characterized in that: The computer-readable storage medium comprises a computer program, and when the computer program is executed on a device, the device is caused to perform the method according to any one of claims 1 to 6.

15. A computer program product, characterized in that When the computer program product is run on a computer, the computer is caused to execute the method according to any one of claims 1 to 6.