File processing method, electronic device, and computer storage medium

CN116737055BActive Publication Date: 2026-08-18ZTE CORP
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210207559.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-03
Publication Date
2026-08-18
Estimated Expiration
2042-03-03

AI Technical Summary

Technical Problem

目前,在计算机磁盘设备上部署多个文件系统的方法主要有磁盘分区、建立LVM(Logical Volume Manager,逻辑卷管理)设备层、将磁盘文件与伪设备绑定等方法,但这些方法均各自存在一些问题,例如不够灵活、效率低、操作流程较为繁琐等等

Benefits of technology

[0033]By pre-setting a mapping relationship between virtual block devices and disk block devices, the received first file operation instruction carrying the location information of the virtual block device is converted into a second file operation instruction carrying the location information of the disk block device according to the pre-set mapping relationship. The second file operation instruction is then sent to the disk block device, which can directly operate on the file to be processed corresponding to the location information according to the second file operation instruction. By virtualizing files on the disk block device into a virtual block device and deploying a file system, file operations targeting the virtual block device are converted into file operations targeting the actual disk block device, achieving file operation pass-through. This results in high access efficiency, minimal performance impact, and speeds close to direct access to the actual disk block device, without changing the original disk partitions and file system. This facilitates seamless switching during operating system version upgrades and rollbacks, and is also applicable to scenarios where block devices are originally required but pseudo-devices are not usable.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116737055B_ABST
    Figure CN116737055B_ABST
Patent Text Reader

Abstract

The present disclosure provides a file processing method, comprising: converting a received first file operation instruction into a second file operation instruction according to a preset mapping relationship, wherein the first file operation instruction comprises location information of a virtual block device, and the second file operation instruction comprises location information of a disk block device; and issuing the second file operation instruction to the disk block device, so that the disk block device operates on a to-be-processed file corresponding to the location information of the disk block device according to the second file operation instruction. The file on the disk block device is virtually regarded as a virtual block device, and the file operation on the virtual block device is converted into a file operation on an actual disk block device, so that the file operation is transparently transmitted, the access efficiency is high, the performance influence is small, the speed is close to direct access to the disk block device, and the original disk partition and file system do not need to be changed. The present disclosure also provides a file processing apparatus, an electronic device and a computer storage medium.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer storage technology, specifically to a file processing method, an electronic device, and a computer storage medium. Background Technology

[0002] A file system is a method and data structure used by an operating system to identify files on a disk or partition. Deploying multiple file systems on a computer's disk device offers advantages such as high performance, controllable sensitive data, and the ability to back up only the file system without backing up the entire disk. Currently, methods for deploying multiple file systems on computer disk devices mainly include disk partitioning, establishing an LVM (Logical Volume Manager) device layer, and binding disk files to pseudo-devices. However, each of these methods has its own problems, such as lack of flexibility, low efficiency, and cumbersome operation procedures. Summary of the Invention

[0003] This disclosure addresses the aforementioned deficiencies in the prior art by providing a file processing method, an electronic device, and a computer storage medium.

[0004] In a first aspect, embodiments of this disclosure provide a file processing method, wherein the method includes:

[0005] The received first file operation instruction is converted into a second file operation instruction according to a preset mapping relationship, wherein the first file operation instruction includes the location information of the virtual block device, and the second file operation instruction includes the location information of the disk block device;

[0006] The second file operation instruction is sent to the disk block device so that the disk block device can operate on the file to be processed corresponding to the location information of the disk block device according to the second file operation instruction.

[0007] In some embodiments, the preset mapping relationship includes a mapping relationship between file identifier, virtual block device identifier, and disk block device sector location identifier.

[0008] In some embodiments, before converting the received first file operation instruction into a second file operation instruction according to a preset mapping relationship, the method further includes:

[0009] The virtual block device is created based on the file to be processed.

[0010] In some embodiments, creating the virtual block device based on the file to be processed includes:

[0011] The file path of the file to be processed is passed to a pre-configured file interface. The file interface and the file path are used to view the file to be processed, set the file to be processed as a file that can create virtual block devices, and delete the virtual block devices.

[0012] Lock the file to be processed so that it is in an unmodifiable state;

[0013] Determine the virtual block device information corresponding to the file to be processed, wherein the virtual block device information includes at least a virtual block device identifier;

[0014] The device tree is updated based on the virtual block device information to complete the pre-creation of the virtual block device;

[0015] Based on the identifier of the disk block device sector location storing the file to be processed, the file identifier of the file to be processed, and the virtual block device identifier of the virtual block device, the preset mapping relationship is established to complete the creation of the virtual block device.

[0016] In some embodiments, locking the file to be processed to make it unmodifiable includes:

[0017] Parse the file path of the file to be processed to obtain the identification number of the file to be processed;

[0018] Acquire the access lock for the file to be processed;

[0019] The file attributes of the file to be processed are set according to the identification number and the access lock, so that the file to be processed is in an unmodifiable state.

[0020] In some embodiments, converting the received first file operation instruction into a second file operation instruction according to a preset mapping relationship includes:

[0021] Determine the virtual block device identifier of the virtual block device;

[0022] The corresponding disk block device sector location identifier is determined based on the preset mapping relationship and the virtual block device identifier of the virtual block device;

[0023] The first file operation instruction is converted into the second file operation instruction based on the determined disk block device sector location identifier.

[0024] In some embodiments, both the first file operation instruction and the second file operation instruction are file refresh operation instructions, the location information of the virtual block device includes the virtual block device identifier, the location information of the disk block device includes the disk block device identifier, and the step of converting the first file operation instruction into the second file operation instruction based on the determined disk block device sector location identifier includes:

[0025] Replace the virtual block device identifier in the first file operation instruction with the disk block device identifier corresponding to the determined disk block device sector location identifier.

[0026] In some embodiments, both the first file operation instruction and the second file operation instruction are file read / write operation instructions, the location information of the virtual block device includes a virtual block device sector location identifier, the location information of the disk block device includes a disk block device sector location identifier, and the step of converting the first file operation instruction into the second file operation instruction based on the determined disk block device sector location identifier includes:

[0027] Replace the virtual block device sector location identifier in the first file operation instruction with the determined disk block device sector location identifier.

[0028] In a second aspect, embodiments of this disclosure provide an electronic device, including:

[0029] One or more processors;

[0030] A storage device on which one or more programs are stored;

[0031] When the one or more programs are executed by the one or more processors, the one or more processors implement the file processing method as described above.

[0032] Thirdly, embodiments of this disclosure provide a computer storage medium having a computer program stored thereon, wherein the program, when executed, implements the file processing method as described above.

[0033] By pre-setting a mapping relationship between virtual block devices and disk block devices, the received first file operation instruction carrying the location information of the virtual block device is converted into a second file operation instruction carrying the location information of the disk block device according to the pre-set mapping relationship. The second file operation instruction is then sent to the disk block device, which can directly operate on the file to be processed corresponding to the location information according to the second file operation instruction. By virtualizing files on the disk block device into a virtual block device and deploying a file system, file operations targeting the virtual block device are converted into file operations targeting the actual disk block device, achieving file operation pass-through. This results in high access efficiency, minimal performance impact, and speeds close to direct access to the actual disk block device, without changing the original disk partitions and file system. This facilitates seamless switching during operating system version upgrades and rollbacks, and is also applicable to scenarios where block devices are originally required but pseudo-devices are not usable. Attached Figure Description

[0034] Figure 1 This is a flowchart illustrating the file processing method provided in the embodiments of this disclosure. Figure 1 ;

[0035] Figure 2 This is a flowchart illustrating the file processing method provided in the embodiments of this disclosure. Figure 2 ;

[0036] Figure 3 This is a flowchart illustrating the file processing method provided in the embodiments of this disclosure. Figure 3 ;

[0037] Figure 4 This is a flowchart illustrating the file processing method provided in the embodiments of this disclosure. Figure 4 ;

[0038] Figure 5 This is a schematic diagram of a computer system provided in an embodiment of this disclosure;

[0039] Figure 6 This is a flowchart illustrating the file processing method provided in the embodiments of this disclosure. Figure 5 ;

[0040] Figure 7 This is a schematic diagram of the module of the file processing apparatus provided in the embodiments of this disclosure.

[0041] Figure label:

[0042] 1. File interface 2. Structure 3. Virtual block device

[0043] 4. Disk block device 5. File to be processed 6. Computer system Detailed Implementation

[0044] Exemplary embodiments will be described more fully below with reference to the accompanying drawings; however, these exemplary embodiments may be embodied in different forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will enable those skilled in the art to fully understand the scope of this disclosure.

[0045] As used herein, the term “and / or” includes any and all combinations of one or more related enumerated entries.

[0046] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit this disclosure. As used herein, the singular forms “a” and “the” are also intended to include the plural forms unless the context clearly indicates otherwise. It will also be understood that when the terms “comprising” and / or “made of” are used in this specification, the presence of the said feature, integral, step, operation, element, and / or component is specified, but the presence or addition of one or more other features, integrals, steps, operations, elements, components, and / or groups thereof is not excluded.

[0047] The embodiments described herein can be described with reference to plan views and / or cross-sectional views using the ideal schematic diagrams of this disclosure. Therefore, the example illustrations can be modified according to manufacturing techniques and / or tolerances. Therefore, the embodiments are not limited to those shown in the drawings, but include modifications to configurations formed based on manufacturing processes. Therefore, the areas illustrated in the drawings are schematic in nature, and the shapes of the areas shown in the figures illustrate specific shapes of areas of an element, but are not intended to be limiting.

[0048] Unless otherwise specified, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art. It will also be understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and this disclosure, and will not be interpreted as having an idealized or overly formal meaning, unless expressly so defined herein.

[0049] Currently, the main methods for deploying multiple file systems on computer disk devices include disk partitioning, establishing an LVM device layer, and binding disk files to pseudo devices, but these methods all have some problems.

[0050] Disk partitioning involves dividing the entire hard drive into multiple partitions. In traditional disk management, a hard drive is divided into two main types of partitions: primary partitions and extended partitions. Primary partitions are used to install the operating system and boot the computer. These partitions can be formatted directly, and then the system can be installed and files stored. After partitioning the disk, file systems can be deployed on different partitions. However, if a new partitioning is needed, the disk needs to be repartitioned and formatted, which is inflexible. Establishing an LVM device layer is more cumbersome and requires the deployment of corresponding tools. Binding disk files to pseudo-devices—that is, binding files on the disk to pseudo-devices in the computer system (such as the loop device in Linux)—allows for mounting through pseudo-devices and deployment of multiple file systems. However, reading and writing data requires passing through two file systems, resulting in low efficiency, and there are also issues with pseudo-devices not working in some scenarios.

[0051] In view of this, this disclosure proposes that if large files on a disk are virtualized into block devices and a file system is deployed, it is lightweight and highly flexible. The key to virtualizing files into block devices is to provide a mapping relationship between the virtual block devices that the files are virtualized into and the actual disk block devices that store the files, so that when it is necessary to operate on the files, the files can be found on the actual disk block devices based on the mapping relationship.

[0052] like Figure 1 As shown in the figure, this disclosure provides a file processing method, which may include the following steps:

[0053] In step S11, the received first file operation instruction is converted into a second file operation instruction according to a preset mapping relationship. The first file operation instruction includes the location information of the virtual block device, and the second file operation instruction includes the location information of the disk block device.

[0054] In step S12, a second file operation instruction is sent to the disk block device so that the disk block device can operate on the file to be processed corresponding to the location information of the disk block device according to the second file operation instruction.

[0055] Here, the virtual block device is the virtual block device created from the file to be processed, and the disk block device is the actual disk block device storing the file to be processed. This mapping relationship is further established after the file to be processed is virtualized into a virtual block device. File operation instructions need to carry the file's location information. The first file operation instruction can be issued directly to the virtual block device, thus carrying the virtual block device's location information. Based on the preset mapping relationship, the first file operation instruction can be converted into a second file operation instruction carrying the disk block device's location information. After conversion, the disk block device can operate on the file to be processed corresponding to the disk block device's location information according to the second file operation instruction.

[0056] It should be noted that file operation instructions usually need to carry specific operation content. After the received first file operation instruction is converted into a second file operation instruction according to the preset mapping relationship, the operation content carried by the second file operation instruction does not change compared to the first file operation instruction.

[0057] As can be seen from steps S11-S12 above, the file processing method provided in this embodiment of the present disclosure, by pre-setting a mapping relationship between virtual block devices and disk block devices, converts the received first file operation instruction carrying the location information of the virtual block device into a second file operation instruction carrying the location information of the disk block device according to the pre-set mapping relationship. The second file operation instruction is then sent to the disk block device, which can directly operate on the file to be processed corresponding to the location information according to the second file operation instruction. By virtualizing the file on the disk block device into a virtual block device and deploying a file system, the file operation for the virtual block device is converted into the file operation for the actual disk block device, realizing file operation pass-through. This results in high access efficiency, minimal performance impact, and speed close to direct access to the actual disk block device. Furthermore, it does not require changes to the original disk partitions and file system, which is beneficial for seamless switching during operating system version upgrades and rollbacks. It can also be applied to some scenarios where block devices are originally needed but pseudo-devices cannot be used.

[0058] After the file to be processed is virtualized into a virtual block device in advance, the mapping relationship between the file to be processed, the virtual block device, and the disk block device can be further set. Specifically, in some embodiments, the preset mapping relationship may include the mapping relationship between the file identifier, the virtual block device identifier, and the disk block device sector location identifier.

[0059] The virtual block device identifier may include the minor device number of the virtual block device, and the disk block device sector location identifier is an identifier that can represent a sector on a disk block device.

[0060] Before converting the received first file operation instruction into a second file operation instruction according to a preset mapping relationship, the process may further include steps of virtualizing the file to be processed into a virtual block device and establishing a mapping relationship. Correspondingly, in some embodiments, before converting the received first file operation instruction into a second file operation instruction according to a preset mapping relationship (i.e., step S11), such as... Figure 2 As shown, the method may further include the following steps:

[0061] In step S21, a virtual block device is created based on the file to be processed.

[0062] Specifically, in some embodiments, such as Figure 3 As shown, the step of creating a virtual block device based on the file to be processed (i.e., step S21) may include the following steps:

[0063] In step S211, the file path of the file to be processed is passed to the pre-configured file interface. The file interface and file path are used to view the file to be processed, set the file to be processed as a file that can create virtual block devices, and delete virtual block devices.

[0064] In step S212, the file to be processed is locked so that it is in an unmodifiable state.

[0065] In step S213, the virtual block device information corresponding to the file to be processed is determined, and the virtual block device information includes at least the virtual block device identifier.

[0066] In step S214, the device tree is updated according to the virtual block device information to complete the creation of the virtual block device.

[0067] In step S215, a preset mapping relationship is established based on the identifier of the disk block device sector location storing the file to be processed, the file identifier of the file to be processed, and the virtual block device identifier of the virtual block device, so as to complete the creation of the virtual block device.

[0068] Among them, the identifier of the disk block device sector location storing the file to be processed is the disk block device sector location identifier.

[0069] A configuration file interface can be pre-configured. Users can use this interface to set files as virtual block devices, view files virtualized as virtual block devices, and delete virtual block devices. The specific implementation of the configuration file interface is existing technology and will not be elaborated here. After passing the file path of the file to be processed to the pre-configured file interface, users can use this interface and the file path of the file to be processed to view the file, set the file to be processed as a virtual block device, and delete the virtual block devices virtualized by the file to be processed.

[0070] It should be understood that once the virtual block device is created in step S214, the action of deleting the virtual block device created from the file to be processed can only be performed after step S214. If an incorrect file path is detected during the creation of the virtual block device, or if the file to be processed is not actually stored on the disk block device, the creation will fail.

[0071] The phrase "the file to be processed is in an unmodifiable state" means that the file cannot be mistakenly modified by the computer's defragmentation function. Using the file processing method provided in this disclosure, since files are virtualized as virtual block devices, multiple files can be virtualized as different virtual block devices, or multiple files can be virtualized as a single virtual block device (of course, a large file can also be virtualized as multiple virtual block devices, as long as the different virtual block devices are correctly distinguished). When multiple files are virtualized as a single virtual block device, the file to be processed can include multiple sub-files, which can then be stored separately on the disk block device. Regardless of whether the file to be processed is a single file or includes multiple sub-files, locking the file to be processed to make it unmodifiable and preventing accidental modification by the computer's defragmentation function effectively protects the file to be processed. The computer system can request a major device number for the virtual block device during initialization. All virtual block devices can share a major device number. After locking the file to be processed to make it unmodifiable, it is only necessary to request the corresponding virtual block device identifier, i.e., the minor device number, for the file to be processed. Each virtual block device has a unique minor device number to correctly distinguish different virtual block devices.

[0072] In some embodiments, the virtual block device information may include: a virtual block device identifier, the structure information of the file to be processed, the size of the virtual block device, the set of operation functions, and the demand queue, etc. Accordingly, determining the virtual block device information corresponding to the file to be processed (i.e., step 213) may include the following steps: requesting a virtual block device identifier for the file to be processed; determining the structure information of the file to be processed; determining the size of the virtual block device based on the size of the file to be processed; and initializing the set of operation functions and the demand queue of the virtual block device.

[0073] The size of the virtual block device is determined based on the size of the file to be processed. When the size of the virtual block device needs to be changed, only the size of the file to be processed needs to be changed, making the operation more flexible. It should be noted that after applying for a virtual block device identifier for the file to be processed, the virtual block device identifier can already be used to characterize the virtual block device. Therefore, the size of the virtual block device, the set of operation functions for the virtual block device, and the demand queue can be determined based on the size of the file to be processed.

[0074] The device tree is used to store device information in a computer system. When the machine boots, the OS (Operating System) builds this tree using information obtained through drivers and other components, and updates it when devices are added or removed. The device tree is typically a structure, with each node representing a device node. Updating the device tree based on virtual block device information involves adding the virtual block device information to the tree as a new node.

[0075] After updating the device tree based on the virtual block device information, the virtual block device is pre-created. After establishing a preset mapping relationship based on the file identifier of the file to be processed, the virtual block device identifier of the virtual block device, and the disk block device sector location identifier of the disk block device storing the file to be processed, the virtual block device is officially created.

[0076] After creating a virtual block device based on the file to be processed, the virtual block device identifier of the virtual block device can be obtained. The file identifier of the file to be processed and the disk block device sector location identifier storing the file's sector location are known. Therefore, a mapping relationship can be directly established between the file identifier of the file to be processed, the virtual block device identifier (created from the file), and the disk block device sector location identifier storing the file's sector location. Specifically, the file identifier, virtual block device identifier, and disk block device sector location identifier can be encapsulated in a structure to establish the mapping relationship. When establishing the mapping relationship, virtual block device information such as the major device number, operation function set, demand queue, and size can also be recorded.

[0077] When it is necessary to delete a virtual block device, the virtual block device to be deleted can be entered through the file interface. The file interface can be used to delete the virtual block device from the system device tree, unregister the structure (i.e., mapping relationship) corresponding to the virtual block device, the set of operation functions and the demand queue, and delete the file attributes of the file. No special tools need to be deployed, and the operation is simple and convenient.

[0078] In some embodiments, such as Figure 4 As shown, locking the file to be processed so that it is in an unmodifiable state (i.e., step S212) may include the following steps:

[0079] In step S2121, the file path of the file to be processed is parsed to obtain the identification number of the file to be processed.

[0080] In step S2122, an access lock for the file to be processed is acquired.

[0081] In step S2123, the file attributes of the file to be processed are set according to the identification number and access lock so that the file to be processed is in an unmodifiable state.

[0082] The identification number is used to locate the file to be processed in the sector of the disk block device, and the access lock is used to obtain the permission to modify the file attributes of the file to be processed.

[0083] It should be noted that after step S2122, the method may further include the following steps: determining whether the file to be processed belongs to the category of delayed allocation of actual storage space; if so, then forcibly allocating actual storage space for the file to be processed.

[0084] The following combination Figure 5 The following is a brief description of the file processing method provided in the embodiments of this disclosure. For example... Figure 5 The diagram shows a computer system provided in an embodiment of this disclosure. First, the file interface 1 corresponding to the file to be processed 5 is configured. The file path of the file to be processed 5 is passed to the file interface 1. It is determined whether the file path is correct and whether the file to be processed 5 is stored on the actual disk block device 4. Otherwise, the creation fails. If yes, the file path of the file to be processed 5 is parsed to obtain the identification number of the file to be processed 5. The file to be processed 5 is found on the disk block device 4 according to the identification number. The access lock of the file to be processed 5 is obtained. It is determined whether the file to be processed belongs to the category of delayed allocation of actual storage space. If yes, actual storage space is forcibly allocated for the file to be processed 5. Otherwise, the file attributes of the file to be processed 5 are set according to the access lock to make the file to be processed 5 in an unmodifiable state. The corresponding virtual block device identifier is applied for for the file to be processed 5. The main structure of the file to be processed 5 is cached. The operation function set and demand queue of the virtual block device 3 are initialized, etc., and the size of the virtual block device 3 is determined according to the size of the file to be processed 5. The virtual block device 3 is added to the system device tree. The virtual block device identifier of virtual block device 3, the file identifier of file 5 to be processed, and the disk block device sector location identifier of disk block device 4 are encapsulated into a structure to establish a mapping relationship. When computer system 6 receives the first file operation instruction, it converts the first file operation instruction into a second file operation instruction according to the mapping relationship, and sends the second file operation instruction to disk block device 4 so that disk block device 4 can operate on the file to be processed according to the second file operation instruction.

[0085] In some embodiments, such as Figure 6 As shown, the step of converting the received first file operation instruction into a second file operation instruction according to a preset mapping relationship (i.e., step S11) may include the following steps:

[0086] In step S111, the virtual block device identifier of the virtual block device is determined.

[0087] In step S112, the corresponding disk block device sector location identifier is determined according to the preset mapping relationship and the virtual block device identifier of the virtual block device.

[0088] In step S113, the first file operation instruction is converted into a second file operation instruction based on the determined disk block device sector location identifier.

[0089] Upon receiving a first file operation instruction, since the instruction carries the location information of the virtual block device, the virtual block device identifier can be determined based on this information. A preset mapping relationship includes the mapping between the file identifier, the virtual block device identifier, and the disk block device sector location identifier. Based on the virtual block device identifier and the mapping relationship, the corresponding disk block device sector location identifier can be determined. Using the determined disk block device sector location identifier, the first file operation instruction can be converted into a second file operation instruction carrying the disk block device location information.

[0090] In this embodiment of the disclosure, the file operation instructions can be Input / Output (I / O) operation instructions, specifically, they can include file flush (e.g., flush) operation instructions and file read / write operation instructions.

[0091] When a file refresh operation needs to be performed on an actual disk block device, existing technologies typically generate I / O operation instructions that carry the actual disk block device identifier and then send the I / O operation instructions to the actual disk block device. However, in this embodiment, since the file to be processed is virtualized as a virtual block device, the I / O operation instructions carry a virtual block device identifier. If the I / O operation instructions are directly sent to the actual disk block device, the actual disk block device cannot recognize the virtual block device identifier and therefore cannot perform the corresponding refresh operation on the file to be processed. Therefore, it is necessary to replace the virtual block device identifier in the first file operation instruction with the disk block device identifier.

[0092] Accordingly, in some embodiments, both the first file operation instruction and the second file operation instruction are file refresh operation instructions. The location information of the virtual block device includes a virtual block device identifier, and the location information of the disk block device includes a disk block device identifier. The step of converting the first file operation instruction into the second file operation instruction according to the determined disk block device sector location identifier (i.e., step S113) may include the following steps: replacing the virtual block device identifier in the first file operation instruction with the disk block device identifier corresponding to the determined disk block device sector location identifier.

[0093] File flushing commands such as Flush do not involve specific sector locations. Therefore, the second file operation command only needs to carry the disk block device identifier. The disk block device sector location identifier is an identifier that can represent a sector on a disk block device. Based on the disk block device sector location identifier, the disk block device identifier can be determined. The virtual block device identifier in the first file operation command can be directly replaced with the determined disk block device identifier.

[0094] When file read / write operations need to be performed on an actual disk block device, existing technologies typically generate I / O operation instructions. These instructions carry the actual disk block device sector location and the specific read / write operation content, and are then sent to the actual disk block device. However, in this embodiment, since the file to be processed is virtualized as a virtual block device, the I / O operation instructions carry the virtual block device sector location and the specific read / write operation content. If the I / O operation instructions are directly sent to the actual disk block device, the actual disk block device cannot recognize the virtual block device sector location and therefore cannot perform the corresponding read / write operations on the file to be processed. Therefore, it is necessary to replace the virtual block device sector location identifier in the first file operation instruction with the disk block device sector location identifier.

[0095] Accordingly, in some embodiments, both the first file operation instruction and the second file operation instruction are file read / write operation instructions. The location information of the virtual block device includes a virtual block device sector location identifier, and the location information of the disk block device includes a disk block device sector location identifier. The step of converting the first file operation instruction into the second file operation instruction based on the determined disk block device sector location identifier (i.e., step S113) may include the following steps: replacing the virtual block device location information in the first file operation instruction with the determined disk block device sector location identifier.

[0096] Based on the same technological concept, such as Figure 7 As shown in the embodiments of this disclosure, a document processing apparatus is also provided, which may include:

[0097] The processing module 101 is used to convert the received first file operation instruction into a second file operation instruction according to a preset mapping relationship, wherein the first file operation instruction includes the location information of the virtual block device and the second file operation instruction includes the location information of the disk block device.

[0098] The sending module 102 is used to send the second file operation instruction to the disk block device, so that the disk block device can operate on the file to be processed corresponding to the location information of the disk block device according to the second file operation instruction.

[0099] In some embodiments, the preset mapping relationship includes a mapping relationship between file identifier, virtual block device identifier, and disk block device sector location identifier.

[0100] In some embodiments, the processing module 101 is further configured to:

[0101] The virtual block device is created based on the file to be processed.

[0102] In some embodiments, the processing module 101 is configured to:

[0103] Pass the file path of the file to be processed to the pre-configured file interface. The file interface and file path are used to view the file to be processed, set the file to be processed as a file that can create virtual block devices, and delete virtual block devices.

[0104] Lock the file to be processed so that it is in an unmodifiable state;

[0105] Determine the virtual block device information corresponding to the file to be processed. The virtual block device information includes at least the virtual block device identifier.

[0106] Update the device tree based on the virtual block device information to complete the pre-creation of the virtual block device;

[0107] A preset mapping relationship is established based on the identifier of the disk block device sector location storing the file to be processed, the file identifier of the file to be processed, and the virtual block device identifier of the virtual block device, so as to complete the creation of the virtual block device.

[0108] In some embodiments, the processing module 101 is configured to:

[0109] Parse the file path of the file to be processed and obtain the identification number of the file to be processed;

[0110] Acquire the access lock for the file to be processed;

[0111] The file attributes of the file to be processed are set according to the identification number and access lock, so that the file to be processed is in an unmodifiable state.

[0112] In some embodiments, the processing module 101 is configured to:

[0113] Determine the virtual block device identifier of the virtual block device;

[0114] The corresponding disk block device sector location identifier is determined based on the preset mapping relationship and the virtual block device identifier of the virtual block device;

[0115] The first file operation instruction is converted into the second file operation instruction based on the determined disk block device sector location identifier.

[0116] In some embodiments, the first file operation instruction and the second file operation instruction are both file refresh operation instructions, the location information of the virtual block device includes the virtual block device identifier, the location information of the disk block device includes the disk block device identifier, and the processing module 101 is configured to:

[0117] Replace the virtual block device identifier in the first file operation instruction with the disk block device identifier corresponding to the determined disk block device sector location identifier.

[0118] In some embodiments, the first file operation instruction and the second file operation instruction are both file read / write operation instructions, the location information of the virtual block device includes a virtual block device sector location identifier, the location information of the disk block device includes a disk block device sector location identifier, and the processing module 101 is used to:

[0119] Replace the virtual block device sector location identifier in the first file operation instruction with the determined disk block device sector location identifier.

[0120] This disclosure also provides an electronic device, including:

[0121] One or more processors;

[0122] A storage device on which one or more programs are stored;

[0123] When the one or more programs are executed by the one or more processors, the one or more processors implement the file processing method as described in the preceding embodiments.

[0124] This disclosure also provides a computer storage medium storing a computer program thereon, wherein the program, when executed, implements the file processing method as described in the preceding embodiments.

[0125] It will be understood by those skilled in the art that all or some of the steps in the methods disclosed above, and the functional modules / units in the apparatus, can be implemented as software, firmware, hardware, and suitable combinations thereof. In hardware implementations, the division between functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed collaboratively by several physical components. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include computer storage media (or non-transitory media) and communication media (or transient media). As is known to those skilled in the art, the term computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and can be accessed by a computer. Furthermore, it is well known to those skilled in the art that communication media typically contain computer-readable instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium.

[0126] Example embodiments have been disclosed herein, and while specific terminology has been used, it is for illustrative purposes only and should be construed as such, and is not intended to be limiting. In some instances, it will be apparent to those skilled in the art that features, characteristics, and / or elements described in connection with particular embodiments may be used alone, or in combination with features, characteristics, and / or elements described in connection with other embodiments, unless otherwise expressly indicated. Therefore, those skilled in the art will understand that various changes in form and detail may be made without departing from the scope of this disclosure as set forth by the appended claims.

Claims

1. A file processing method, wherein, The method includes: The received first file operation instruction is converted into a second file operation instruction according to a preset mapping relationship. The first file operation instruction includes the location information of the virtual block device, and the second file operation instruction includes the location information of the disk block device. The preset mapping relationship includes the mapping relationship between the file identifier of the file to be processed, the virtual block device identifier of the virtual block device, and the sector location identifier of the disk block device. The virtual block device is a virtual block device virtualized from the file to be processed, and the disk block device is the actual disk block device storing the file to be processed. The second file operation instruction is sent to the disk block device so that the disk block device can operate on the file to be processed corresponding to the location information of the disk block device according to the second file operation instruction.

2. The method according to claim 1, wherein, Before converting the received first file operation instruction into a second file operation instruction according to a preset mapping relationship, the method further includes: The virtual block device is created based on the file to be processed.

3. The method according to claim 2, wherein, The step of creating the virtual block device based on the file to be processed includes: The file path of the file to be processed is passed to a pre-configured file interface. The file interface and the file path are used to view the file to be processed, set the file to be processed as a file that can create virtual block devices, and delete the virtual block devices. Lock the file to be processed so that it is in an unmodifiable state; Determine the virtual block device information corresponding to the file to be processed, wherein the virtual block device information includes at least a virtual block device identifier; The device tree is updated based on the virtual block device information to complete the pre-creation of the virtual block device; Based on the sector location identifier of the disk block device storing the file to be processed, the file identifier of the file to be processed, and the virtual block device identifier of the virtual block device, the preset mapping relationship is established to complete the creation of the virtual block device.

4. The method according to claim 3, wherein, Locking the file to be processed, so that the file to be processed is in an unmodifiable state, includes: Parse the file path of the file to be processed to obtain the identification number of the file to be processed; Acquire the access lock for the file to be processed; The file attributes of the file to be processed are set according to the identification number and the access lock, so that the file to be processed is in an unmodifiable state.

5. The method according to any one of claims 1-4, wherein, The step of converting the received first file operation instruction into a second file operation instruction according to a preset mapping relationship includes: Determine the virtual block device identifier of the virtual block device; The sector location identifier of the corresponding disk block device is determined according to the preset mapping relationship and the virtual block device identifier of the virtual block device; The first file operation instruction is converted into the second file operation instruction based on the sector location identifier of the determined disk block device.

6. The method according to claim 5, wherein, Both the first file operation instruction and the second file operation instruction are file refresh operation instructions. The location information of the virtual block device includes the virtual block device identifier, and the location information of the disk block device includes the disk block device identifier. The step of converting the first file operation instruction into the second file operation instruction based on the determined sector location identifier of the disk block device includes: Replace the virtual block device identifier in the first file operation instruction with the disk block device identifier corresponding to the sector location identifier of the determined disk block device.

7. The method according to claim 5, wherein, Both the first file operation instruction and the second file operation instruction are file read / write operation instructions. The location information of the virtual block device includes a virtual block device sector location identifier, and the location information of the disk block device includes a disk block device sector location identifier. The step of converting the first file operation instruction into the second file operation instruction based on the determined disk block device sector location identifier includes: Replace the virtual block device sector location identifier in the first file operation instruction with the determined disk block device sector location identifier.

8. An electronic device, comprising: One or more processors; A storage device on which one or more programs are stored; When the one or more programs are executed by the one or more processors, the one or more processors implement the file processing method as described in any one of claims 1-7.

9. A computer storage medium having a computer program stored thereon, wherein, When the program is executed, it implements the file processing method as described in any one of claims 1-7.

Citation Information

Patent Citations

  • Method and device for processing read / write request in physical host

    CN106201349A