CN115454935A - Method for quickly copying internal file of file system - Google Patents
Method for quickly copying internal file of file system Download PDFInfo
- Publication number
- CN115454935A CN115454935A CN202211228202.2A CN202211228202A CN115454935A CN 115454935 A CN115454935 A CN 115454935A CN 202211228202 A CN202211228202 A CN 202211228202A CN 115454935 A CN115454935 A CN 115454935A
- Authority
- CN
- China
- Prior art keywords
- file
- copy
- target file
- file system
- target
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/13—File access structures, e.g. distributed indices
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/17—Details of further file system functions
- G06F16/172—Caching, prefetching or hoarding of files
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/17—Details of further file system functions
- G06F16/176—Support for shared access to files; File sharing support
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention discloses a method for quickly copying files in a file system, which relates to the technical field of file copying and comprises the following steps: s1: judging whether a source file exists or not; s2: opening a source file; s3: opening a target file, and if the target file does not exist, creating the target file; s4: the method is different from the physical Copy of the traditional file system, utilizes the support of an efficient Copy on Write of a btree data structure to realize the logical Copy operation of the file system, and when a file is to be copied, the system cannot Copy the original data of the file and then 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 Copy, ensuring that the logical Copy has lower time delay and better space utilization rate.
Description
Technical Field
The invention relates to the technical field of file copying, in particular to a method for quickly copying files in a file system.
Background
Copy operations often occur in real life and work, such as copy and paste operations (cp-r) on a file or a folder on a personal computer; or a backup operation for the current work; and for example, deploying a virtual machine on the computer by using a suffix file such as iso or osa (the operation also uses the copy operation of the local file system). In addition, with the increasing amount of data and the increasing requirement for disk space utilization, the need for fast copying large files is also becoming more and more important.
Conventional file systems do not provide an optimized copy operation, so any copy on a conventional file system will respond directly on the physical device (i.e. -once you ask you to copy you-one file, there will be two-modulo-like files on your storage system). This is known as physical copy (Physiccopy) and the system will read all the data of the file you want to copy immediately, then find an equal size area in the storage system and write the read file one byte worth onto the block of area previously created by the system. Obviously, there is a very significant delay in physical copying and a very poor utilization of storage system space, so we propose a method for fast copying of files within a file system.
Disclosure of Invention
Aiming at the defects of the prior art, the invention provides a method for quickly copying files in a file system, which solves the problems in the background technology.
In order to realize the purpose, the invention is realized by the following technical scheme: a method for quickly copying files in a file system comprises the following steps:
s1: judging whether a source file exists or not;
s2: opening a source file;
s3: opening a target file, and if the target file does not exist, creating the target file;
s4: and calling an ioctl interface realized by the file system to complete the related indexes of the data content and the target file.
Optionally, the S4 calls an ioctl interface implemented by the file system, and completes the step of indexing the data content and the target file, so that in the process of the copy operation, the read of the source file and the write operation of the target file are omitted, and the logical copy has a lower latency.
Optionally, the S4 calls an ioctl interface implemented by the file system, and the step of performing related indexing of the data content and the target file is performed, and the logical Copy operation of the file system is implemented by using a btree data structure and an efficient Copy on Write support, and when a file is to be copied, the system does not Copy the original data of the file, but 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 copying the file.
Optionally, in S4, an ioctl interface implemented by the file system is called, logical copying adopted in the step of indexing the data content and the target file is completed, only metadata describing the file is copied, and the data information is shared by the active file and the target file.
Optionally, in the step of S4 calling an ioctl interface implemented by the file system to complete the related index between the data content and the target file, a fast copy mechanism implemented by COW is used.
Optionally, in the step of calling an ioctl interface implemented by the file system to complete the related index between the data content and the target file in S4, the system does not copy the original data of the file, and instead copies the metadata describing the file.
Optionally, in the step of calling an ioctl interface implemented by the file system to complete the related indexing of the data content and the target file in S4, a new physical space is not generated in the storage system for storing the data for the target file of the logical copy, so that the logical copy has a better physical space utilization rate.
Optionally, in the step of S4 calling an ioctl interface implemented by the file system to complete the related indexes of the data content and the target file, the source file and the target file share the same data block region.
The invention provides a method for quickly copying files in a file system, which has the following beneficial effects:
the method for quickly copying the internal file of the file system is different from the physical copying of the traditional file system, and the logical copying operation of the file system is realized by utilizing the efficient support of Copy on Write of a data structure btree. When a file is to be copied, the system does not copy the original data of the file, but copies the metadata describing the file, so that the source file and the target file share the same physical storage space, the effect of file copying is achieved, and the logical copy has lower time delay and better space utilization rate.
Drawings
FIG. 1 is a schematic diagram of the process of the present invention;
FIG. 2 is a schematic diagram of a physical copy scheme according to the present invention;
FIG. 3 is a diagram illustrating a structure of modified file contents after being copied according to the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments.
Referring to fig. 1 to 3, the present invention provides a technical solution: a method for quickly copying files in a file system comprises the following steps:
s1: judging whether a source file exists or not;
s2: opening a source file;
s3: opening a target file, and if the target file does not exist, creating the target file;
s4: and calling an ioctl interface realized by the file system to complete the related indexes of the data content and the target file.
Further, S4 calls an ioctl interface realized by the file system, completes the related indexing step of the data content and the target file, and is used in the copying operation process, so that the read of the source file and the write operation of the target file are omitted, and the logic copy has lower time delay.
Further, S4 calls an ioctl interface realized by the file system to complete the related indexing steps of the data content and the target file, and the logical Copy operation of the file system is realized by utilizing a btree data structure and the support of an efficient Copy on Write.
Further, S4 calls an ioctl interface realized by the file system to complete logic copying adopted in the step of related indexing of the data content and the target file, only metadata describing the file is copied, and the data information active file and the target file are shared.
Further, S4 calls an ioctl interface realized by the file system, and a quick copy mechanism realized by COW is utilized in the step of finishing the related indexes of the data content and the target file.
Further, in the step of calling an ioctl interface realized by the file system to complete the related index of the data content and the target file, the system does not copy the original data of the file, but copies the metadata describing the file.
Further, in the step of calling an ioctl interface realized by the file system to complete the related indexing of the data content and the target file in S4, a new physical space is not generated in the storage system for storing data in the target file of the logical copy, so that the logical copy has a better physical space utilization rate.
Further, in the step of calling an ioctl interface realized by the file system and completing the related indexing of the data content and the target file in the S4, the source file and the target file share the same data area.
As shown in fig. 2: under directory A there is a file f1, each of which has several 4k blocks of data to make up [0,3]. We want to copy the file f1 to the file f2, the system will copy the inode of f1 to the inode of f2, which will point to the real data block [0,3] below f1 in the graph. During the copying operation, the read () operation of the source file and the write () operation of the target file are omitted, so that the logical copy has lower time delay; in addition, the logical copy only copies metadata describing files, and the data information active files and the target files are shared, so that the target files of the logical copy do not generate a new physical space in a storage system for storing data, and the logical copy has a better physical space utilization rate;
compared with the traditional file system, the fast copy mechanism realized by using the COW is used for lower time delay and better space utilization rate. The source file and the target file share the storage space, so that the processing mode of the file system is changed when the source file or the target file is modified;
as shown in fig. 3: when trying to modify any bit data in the file f2, the system has to clone the data of the block data block [4] where the bit is located, that is, 4k data, and then modify the bit data, in this case, the write operation is directly amplified, and a new physical space needs to be applied for storing the modified data.
The above description is only for the preferred embodiment of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art should be considered to be within the technical scope of the present invention, and the technical solutions and the inventive concepts thereof according to the present invention should be equivalent or changed within the scope of the present invention.
Claims (8)
1. A method for quickly copying files in a file system is characterized by comprising the following steps: the method comprises the following steps:
s1: judging whether a source file exists or not;
s2: opening a source file;
s3: opening a target file, and if the target file does not exist, creating the target file;
s4: and calling an ioctl interface realized by the file system to complete the related indexes of the data content and the target file.
2. The method according to claim 1, wherein the method comprises: and S4, calling an ioctl interface realized by the file system, finishing the related indexing steps of the data content and the target file, wherein the related indexing steps are used for omitting the read of the source file and the write operation of the target file in the copying operation process, so that the logical copy has lower time delay.
3. The method for fast copying the files in the file system according to claim 1, wherein: and S4, invoking an ioctl interface realized by the file system, completing the related indexing steps of the data content and the target file, and realizing the logical Copy operation of the file system by utilizing a btree data structure and the support of an efficient Copy on Write.
4. The method according to claim 1, wherein the method comprises: and S4, calling an ioctl interface realized by the file system, finishing logic copying adopted in the step of related indexing of the data content and the target file, only copying metadata of the description file, and sharing the data information active file and the target file.
5. The method according to claim 1, wherein the method comprises: and S4, calling an ioctl interface realized by the file system, and finishing the related indexing of the data content and the target file by using a quick copy mechanism realized by COW.
6. The method for fast copying the files in the file system according to claim 1, wherein: in the step of calling an ioctl interface realized by the file system to complete the related indexing of the data content and the target file, the system does not copy the original data of the file, but copies the metadata describing the file.
7. The method for fast copying the files in the file system according to claim 1, wherein: in the step of calling an ioctl interface realized by the file system to complete the related indexing of the data content and the target file, the target file of the logical copy does not generate a new physical space in the storage system for storing the data, so that the logical copy has a better physical space utilization rate.
8. The method according to claim 1, wherein the method comprises: and S4, in the step of calling an ioctl interface realized by the file system and finishing the related indexing of the data content and the target file, the source file and the target file share the same data area.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211228202.2A CN115454935A (en) | 2022-10-09 | 2022-10-09 | Method for quickly copying internal file of file system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211228202.2A CN115454935A (en) | 2022-10-09 | 2022-10-09 | Method for quickly copying internal file of file system |
Publications (1)
Publication Number | Publication Date |
---|---|
CN115454935A true CN115454935A (en) | 2022-12-09 |
Family
ID=84308711
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211228202.2A Pending CN115454935A (en) | 2022-10-09 | 2022-10-09 | Method for quickly copying internal file of file system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115454935A (en) |
-
2022
- 2022-10-09 CN CN202211228202.2A patent/CN115454935A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US7827368B2 (en) | Snapshot format conversion method and apparatus | |
US9015417B2 (en) | Deduplication-aware page cache | |
US10353636B2 (en) | Write filter with dynamically expandable overlay | |
US20120158674A1 (en) | Indexing for deduplication | |
US11647070B2 (en) | File sending method, file receiving method and file transceiving apparatus | |
US10901643B2 (en) | Using log objects in object storage for durability of file objects in volatile memory | |
US11899542B2 (en) | File data access method, apparatus, and computer-readable storage medium | |
US20190163575A1 (en) | Processing i/o operations in parallel while maintaining read/write consistency using range and priority queues in a data protection system | |
CN110704161A (en) | Virtual machine creation method and device and computer equipment | |
US20220253252A1 (en) | Data processing method and apparatus | |
CN114443364A (en) | Distributed block storage data processing method, device, equipment and storage medium | |
CN111158858A (en) | Cloning method and device of virtual machine and computer readable storage medium | |
WO2023241528A1 (en) | Data processing method and apparatus | |
CN115454935A (en) | Method for quickly copying internal file of file system | |
CN115687185A (en) | Handheld terminal low-power-consumption data acquisition method based on mmap memory mapping | |
US9170942B1 (en) | System, apparatus, and method of automatic data padding | |
CN111274176A (en) | Information processing method, electronic equipment, system and storage medium | |
WO2020151337A1 (en) | Distributed file processing method and apparatus, computer device and storage medium | |
US11755425B1 (en) | Methods and systems for synchronous distributed data backup and metadata aggregation | |
CN111090396A (en) | File processing method and device and electronic equipment | |
CN104461382A (en) | Internal writing method for file server operating multiple file systems and server | |
CN117311911B (en) | Virtual machine snapshot method and device, electronic equipment and storage medium | |
KR20200053052A (en) | Storage device and electronic device managing data transmitted to storage device | |
KR102413965B1 (en) | Memory efficient fork-based checkpointing method and apparatus thereof | |
WO2023070462A1 (en) | File deduplication method and apparatus, and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |