A method for fast copying of files in a file system

By utilizing the ioctl interface and the copy-on-write mechanism of the btree data structure in the file system to achieve metadata copying, the problems of copying latency and poor space utilization in traditional file systems are solved, resulting in a more efficient file copying effect.

CN115454935BActive Publication Date: 2026-04-28BEIJING YAN RONG TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING YAN RONG TECH CO LTD
Filing Date
2022-10-09
Publication Date
2026-04-28

AI Technical Summary

Technical Problem

Traditional file system copy operations have significant time delays and poor space utilization, especially when copying large files.

Method used

Logical copying is achieved by using the file system's ioctl interface, combined with the btree data structure and the Copy on Write (COW) mechanism. By copying metadata instead of the original data, the source and target files share the same physical storage space.

Benefits of technology

It achieves lower copy latency and better space utilization, reduces duplication of physical storage, and improves file copy efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115454935B_ABST
    Figure CN115454935B_ABST
Patent Text Reader

Abstract

The application discloses a method for fast copying of internal files of a file system, and relates to the technical field of file copying, and comprises the following steps: S1, judging whether a source file exists; S2, opening the source file; S3, opening a target file, and creating the target file if the target file does not exist; and S4, calling an ioctl interface realized by the file system to complete the relevant index of data content and the target file. The method for fast copying of internal files of the file system is different from physical copying of a traditional file system, utilizes the support of an efficient Copy on Write of a btree data structure, realizes a logical copying operation of the file system, and when a file is to be copied, the system does not copy original data of the file, but copies metadata describing the file, so that the source file and the target file share a same physical storage space, the effect of file copying is achieved, the logical copying has a lower time delay, and a better space utilization rate is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of file copying technology, specifically a method for fast file copying within a file system. Background Technology

[0002] Copying operations are frequent in daily life and work. Examples include copying and pasting a file or folder on your computer (cp -r); backing up your current work; and deploying a virtual machine on your computer using file extensions like .iso or .osa (this also involves copying the local file system). Furthermore, with the ever-increasing volume of data and the growing demands for efficient disk space utilization, the need for fast copying of large files is becoming increasingly important.

[0003] Traditional file systems do not provide an optimized copy operation. Therefore, any copy operation on a traditional file system is performed directly on the physical device (meaning that once you ask your computer to copy a file, two identical files will appear on your storage system). This is known as physical copy. The system immediately reads all the data of the file to be copied, then finds an area of ​​equal size in the storage system and writes the read file byte by byte into the area previously created by the system. Obviously, physical copy has a significant time delay and is also very inefficient in terms of storage system space utilization. Therefore, we propose a method for fast file copying within the file system. Summary of the Invention

[0004] To address the shortcomings of existing technologies, this invention provides a method for fast file copying within a file system, thus solving the problems mentioned in the background section.

[0005] To achieve the above objectives, the present invention provides the following technical solution: a method for fast file copying within a file system, comprising the following steps:

[0006] S1: Check if the source file exists;

[0007] S2: Open the source file;

[0008] S3: Open the target file; if the target file does not exist, create it.

[0009] S4: Call the ioctl interface implemented by the file system to complete the indexing of the data content and the target file.

[0010] Optionally, S4 calls the ioctl interface implemented by the file system to complete the relevant indexing steps of the data content and the target file. During the copy operation, the read operation of the source file and the write operation of the target file are omitted, so that the logical copy has a lower latency.

[0011] Optionally, S4 calls the ioctl interface implemented by the file system to complete the indexing steps related to the data content and the target file. By utilizing the btree data structure and efficient copy-on-write support, the logical copy operation of the file system is realized. When copying a file, the system does not copy the original data of the file, but instead copies the metadata describing the file, so that the source file and the target file share the same physical storage space, thereby achieving the effect of file copying.

[0012] Optionally, S4 calls the ioctl interface implemented by the file system to complete the logical copy used in the related indexing steps of the data content and the target file. Only the metadata of the description file is copied, while the data information is shared by the source file and the target file.

[0013] Optionally, in the step of S4 calling the ioctl interface implemented by the file system to complete the relevant indexing of data content and target file, a fast copy mechanism implemented using COW is utilized.

[0014] Optionally, in the step of S4 calling the ioctl interface implemented by the file system to complete the indexing of data content and target file, the system will not copy the original data of the file, but will instead copy the metadata describing the file.

[0015] Optionally, in the step S4, which calls the ioctl interface implemented by the file system to complete the indexing of the data content and the target file, the target file of the logical copy does not generate new physical space in the storage system for storing data, thus enabling the logical copy to have better physical space utilization.

[0016] Optionally, in the step S4, where the source file and the target file share the same data area, the source file and the target file call the ioctl interface implemented by the file system to complete the indexing of the data content and the target file.

[0017] This invention provides a method for fast file copying within a file system, which has the following advantages:

[0018] This method for fast file copying within a file system differs from traditional physical file system copying. It leverages the efficient copy-on-write support of the btree data structure to achieve logical copy operations. When copying a file, the system doesn't copy the original file data; instead, it copies the metadata describing the file. This allows the source and target files to share the same physical storage space, achieving the same file copying effect with lower latency and better space utilization. Attached Figure Description

[0019] Figure 1 This is a schematic diagram of the method structure of the present invention;

[0020] Figure 2 This is a schematic diagram of the physical copying method of the present invention;

[0021] Figure 3 This is a schematic diagram illustrating the structure of a file after copying and modifying its contents according to the present invention. Detailed Implementation

[0022] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.

[0023] Please see Figures 1 to 3 This invention provides a technical solution: a method for fast file copying within a file system, comprising the following steps:

[0024] S1: Check if the source file exists;

[0025] S2: Open the source file;

[0026] S3: Open the target file; if the target file does not exist, create it.

[0027] S4: Call the ioctl interface implemented by the file system to complete the indexing of the data content and the target file.

[0028] Furthermore, S4 calls the ioctl interface implemented by the file system to complete the relevant indexing steps of the data content and the target file. During the copy operation, the read operation of the source file and the write operation of the target file are omitted, so that the logical copy has a lower latency.

[0029] Furthermore, S4 calls the ioctl interface implemented by the file system to complete the relevant indexing steps of the data content and the target file. By utilizing the btree data structure and efficient copy-on-write support, the logical copy operation of the file system is realized. When copying a file, the system does not copy the original data of the file, but instead copies the metadata describing the file, so that the source file and the target file share the same physical storage space, thereby achieving the effect of file copying.

[0030] Furthermore, S4 calls the ioctl interface implemented by the file system to complete the logical copy used in the indexing steps of the data content and the target file. Only the metadata of the description file is copied, while the data information is shared by the source file and the target file.

[0031] Furthermore, S4 utilizes the COW (Copy-on-Write) mechanism to perform the fast copy mechanism by calling the ioctl interface implemented by the file system to complete the step of indexing the data content with the target file.

[0032] Furthermore, in the step of S4 calling the ioctl interface implemented by the file system to complete the indexing of the data content and the target file, the system does not copy the original data of the file, but instead copies the metadata describing the file.

[0033] Furthermore, in the step where S4 calls the ioctl interface implemented by the file system to complete the indexing of the data content and the target file, the target file of the logical copy does not generate new physical space in the storage system for storing data, thus enabling the logical copy to have better physical space utilization.

[0034] Furthermore, in the step where S4 calls the ioctl interface implemented by the file system to complete the indexing of the data content and the target file, the source file and the target file share the same data area.

[0035] like Figure 2 As shown: Directory A contains a file named f1, each consisting of several 4KB data blocks [0, 3]. We want to copy file f1 to file f2. The system will copy the inode of f1 to the inode of f2. The inode of f2 will then point to the actual data blocks [0, 3] below f1 in the diagram. Here, the read() operation of the source file and the write() operation of the target file are omitted during the copy operation, resulting in lower latency for logical copying. Furthermore, logical copying only copies the metadata describing the file, while the data information is shared between the source and target files. Therefore, the target file of logical copying does not generate new physical space in the storage system for storing data, resulting in better physical space utilization for logical copying.

[0036] Compared to traditional file systems, the COW (Copy-on-Write) mechanism offers faster copying, resulting in lower latency and better space utilization. Because the source and target files share storage space, the way the file system handles modifications to either the source or target file changes.

[0037] like Figure 3 As shown: When attempting to modify any bit of data in file f2, the system has to clone the data of the block data block[4] containing that bit, which is 4k data, before it can modify that bit data. In this case, the write operation is directly amplified, and new physical space needs to be allocated to store the modified data.

[0038] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.

Claims

1. A method for fast file copying within a file system, characterized in that: Includes the following steps: S1: Check if the source file exists; S2: Open the source file; S3: Open the target file; if the target file does not exist, create it. S4: Call the ioctl interface implemented by the file system to complete the indexing of data content and target file; The S4 calls the ioctl interface implemented by the file system to complete the relevant indexing steps of the data content and the target file. During the copy operation, the read operation of the source file and the write operation of the target file are omitted, so that the logical copy has a lower latency. The S4 calls the ioctl interface implemented by the file system to complete the relevant indexing steps of the data content and the target file. By utilizing the btree data structure and a high-efficiency copy-on-write support, the logical copy operation of the file system is realized. When a file is to be copied, the system does not copy the original data of the file, but instead copies the metadata describing the file, so that the source file and the target file share the same physical storage space, thereby achieving the effect of file copying. The S4 calls the ioctl interface implemented by the file system to complete the logical copy used in the indexing steps of the data content and the target file. Only the metadata of the description file is copied, while the data information is shared by the source file and the target file. The S4 step of calling the ioctl interface implemented by the file system to complete the relevant indexing of data content and target file utilizes the fast copy mechanism implemented by COW. In the step of S4 calling the ioctl interface implemented by the file system to complete the indexing of data content and target file, the system does not copy the original data of the file, but instead copies the metadata describing the file. In the step of S4 calling the ioctl interface implemented by the file system to complete the indexing of data content and target file, the target file of the logical copy does not generate new physical space in the storage system for storing data, so that the logical copy has better physical space utilization. In the step of S4 calling the ioctl interface implemented by the file system to complete the indexing of data content and target file, the source file and target file share the same data area.

Citation Information

Patent Citations

  • File copying method, device and equipment and readable storage medium

    CN110795416A