CN113741816A - Method, device and equipment for operating block equipment and machine-readable storage medium - Google Patents

Method, device and equipment for operating block equipment and machine-readable storage medium Download PDF

Info

Publication number
CN113741816A
CN113741816A CN202111015819.1A CN202111015819A CN113741816A CN 113741816 A CN113741816 A CN 113741816A CN 202111015819 A CN202111015819 A CN 202111015819A CN 113741816 A CN113741816 A CN 113741816A
Authority
CN
China
Prior art keywords
block device
reserved
target
application
storage space
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
Application number
CN202111015819.1A
Other languages
Chinese (zh)
Inventor
王士青
通景根
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Hikvision Digital Technology Co Ltd
Original Assignee
Hangzhou Hikvision Digital Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Hangzhou Hikvision Digital Technology Co Ltd filed Critical Hangzhou Hikvision Digital Technology Co Ltd
Priority to CN202111015819.1A priority Critical patent/CN113741816A/en
Publication of CN113741816A publication Critical patent/CN113741816A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/064Management of blocks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/061Improving I/O performance

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application provides an operation method, an operation device, equipment and a machine-readable storage medium of a block device, wherein the method comprises the following steps: reserving part of storage spaces from all storage spaces of original block equipment as reserved block equipment, and forming the residual storage spaces except the reserved block equipment in the original block equipment into target block equipment; providing mapping information corresponding to a storage space of the target block device to a first application so that the first application operates the target block device based on the mapping information; if an operation request sent by a second application is received, wherein the operation request comprises target data and address information of reserved block equipment, writing the target data into the reserved block equipment corresponding to the address information, so that the second application operates the original block equipment based on the target data in the reserved block equipment. Through the technical scheme of the application, the second application can directly operate the original block device without operating the original block device through the first application.

Description

Method, device and equipment for operating block equipment and machine-readable storage medium
Technical Field
The present application relates to the field of storage technologies, and in particular, to an operating method, an operating device, an operating apparatus, and a machine-readable storage medium for a block device.
Background
I/O (Input/Output) devices are generally classified into two categories: a Block Device Driver and a Character Device Driver. The character device provides continuous data stream, the application program can read the data of the character device in sequence, and the character device is a keyboard, a serial port, a modem and the like. For a block device, an application program can randomly Read data of the block device, and the application program can determine the location of the data by itself, and a hard disk, a floppy disk, a CD-ROM (Compact disk Read-Only Memory), a magnetic disk, a flash Memory and the like are all block devices.
A block device may store data in fixed-size (e.g., 512B, etc.) blocks, where data can only be read from and written to in multiples of a block, and each block of the block device can be read from and written to independently of other blocks. To enable independent access of each block, each block has a physical address through which data in the block can be accessed.
In general, a block device is provided for a File System (File System), once the block device is used by the File System, all storage space of the block device is managed by the File System, the File System occupies all storage space of the block device, read-write operation on the block device is completed based on the File System, and other applications cannot directly operate the block device but only operate the block device through the File System. For example, when data is written, the data is transmitted to the file system, and when the data is written by the file system in the block device, and when the data needs to be read from the block device, a read command is transmitted to the file system, and the data is read from the block device by the file system.
Disclosure of Invention
The present application provides a method of operation of a block device, the method comprising:
reserving a part of storage space from all storage spaces of original block equipment as reserved block equipment, and forming the residual storage space except the reserved block equipment in the original block equipment into target block equipment;
providing mapping information corresponding to the storage space of the target block device to a first application so that the first application operates the target block device based on the mapping information;
if an operation request sent by a second application is received, wherein the operation request comprises target data and address information of reserved block equipment, the target data is written into the reserved block equipment corresponding to the address information, so that the second application operates original block equipment based on the target data in the reserved block equipment.
Illustratively, the reserving a part of the storage space from all the storage spaces of the original block device as a reserved block device includes: acquiring a configured reservation mode and acquiring a target storage capacity of a storage space to be reserved; selecting a reserved position matched with the reserved mode from all storage spaces of the original block device; and reserving a storage space matched with the target storage capacity as a reserved block device at the reserved position.
Illustratively, the reservation mode is a header reservation, or a tail reservation, or a head-tail reservation, or a designated reservation, or a segment reservation; if the reserved mode is the head reservation, the reserved position is the starting position of the original block device; or, if the reserved mode is tail reservation, the reserved position is the end position of the original block device; or, if the reserved mode is head-to-tail reservation, the reserved position is a start position and an end position of the original block device; or, if the reserved mode is a designated reservation, the reserved position is a designated position of the original block device; or, if the reservation mode is segment reservation, the reserved positions are multiple positions of the original block device, and the intervals between two adjacent positions are the same.
Illustratively, the mapping information includes a mapping relationship between a logical address of the storage space of the target block device and a physical address of the storage space of the original block device; the first application operates the target block device based on the mapping information, including: if data needs to be written into a storage space corresponding to a first logical address of the target block device, determining a first physical address corresponding to the first logical address based on the mapping relation, and writing the data into the storage space corresponding to the first physical address of the original block device; and/or if data needs to be read from a storage space corresponding to a second logical address of the target block device, determining a second physical address corresponding to the second logical address based on the mapping relationship, and reading data from the storage space corresponding to the second physical address of the original block device.
Illustratively, the second application is a DRBD application, and the target data includes metadata information corresponding to the DRBD application; the second application operates on an original block device based on target data in the reserved block device, including: the DRBD application performs a mirroring operation on the original block device based on the metadata information in the reserved block device to mirror data in the original block device to another block device.
Illustratively, the second application is a block device merge application, and the block device merge application is configured to combine the original block device and other block devices except the original block device into a merged block device, and the target data includes a correspondence between a logical address of a storage space of the merged block device and a physical address of the storage space of the original block device; the second application operates on an original block device based on target data in the reserved block device, including: if data needs to be written into a storage space corresponding to a third logical address of the merged block device and the third logical address is determined to correspond to a third physical address of the original block device based on the corresponding relationship, writing the data into the storage space corresponding to the third physical address of the original block device; and/or if data needs to be read from a storage space corresponding to a fourth logical address of the merged block device, and it is determined that the fourth logical address corresponds to the fourth physical address of the original block device based on the correspondence, the data is read from the storage space corresponding to the fourth physical address of the original block device.
Illustratively, the second application is a defragmentation application, the target data comprising defragmentation data in the target block device; the second application operates on an original block device based on target data in the reserved block device, including: after storing the fragmented data in the target block device into the reserved block device, if the total amount of data in the reserved block device reaches a preset threshold, the defragmentation application migrates the fragmented data in the reserved block device into the target storage area of the target block device.
The present application provides an operating device of a block device, the device including: the management module is used for reserving part of storage space from all storage space of original block equipment as reserved block equipment and forming the residual storage space except the reserved block equipment in the original block equipment into target block equipment; a providing module, configured to provide mapping information corresponding to a storage space of the target block device to a first application, so that the first application operates the target block device based on the mapping information; and the operation module is used for writing the target data into the reserved block device corresponding to the address information if an operation request sent by a second application is received, wherein the operation request comprises the target data and the address information of the reserved block device, so that the second application operates the original block device based on the target data in the reserved block device.
The management module is specifically configured to, when reserving a part of the storage space from all the storage spaces of the original block device as a reserved block device: acquiring a configured reservation mode, and acquiring a target storage capacity of a storage space to be reserved; selecting a reserved position matched with the reserved mode from all storage spaces of original block equipment; reserving a storage space matched with the target storage capacity as a reserved block device at the reserved position; the reservation mode is head reservation, tail reservation, head and tail reservation, designated reservation or segment reservation; if the reserved mode is the head reservation, the reserved position is the starting position of the original block device; or, if the reserved mode is tail reservation, the reserved position is the end position of the original block device; or, if the reserved mode is head-to-tail reservation, the reserved position is a start position and an end position of the original block device; or, if the reserved mode is a designated reservation, the reserved position is a designated position of the original block device; or, if the reservation mode is segment reservation, the reserved positions are multiple positions of the original block device, and the intervals between two adjacent positions are the same.
Illustratively, the mapping information includes a mapping relationship between a logical address of the storage space of the target block device and a physical address of the storage space of the original block device; the first application, when operating the target block device based on the mapping information, is specifically configured to: if data needs to be written into a storage space corresponding to a first logical address of the target block device, determining a first physical address corresponding to the first logical address based on the mapping relation, and writing the data into the storage space corresponding to the first physical address of the original block device; and/or if data needs to be read from a storage space corresponding to a second logical address of the target block device, determining a second physical address corresponding to the second logical address based on the mapping relationship, and reading data from the storage space corresponding to the second physical address of the original block device.
Exemplarily, the second application is a DRBD application, and the target data includes metadata information corresponding to the DRBD application; the second application, when operating the original block device based on the target data in the reserved block device, is specifically configured to: performing mirroring operation on the original block device based on the metadata information in the reserved block device to mirror data in the original block device to another block device; or the second application is a block device merge application, where the block device merge application is configured to combine an original block device and other block devices except the original block device into a merged block device, and the target data includes a correspondence between a logical address of a storage space of the merged block device and a physical address of the storage space of the original block device; the second application, when operating the original block device based on the target data in the reserved block device, is specifically configured to: if data needs to be written into a storage space corresponding to a third logical address of the merged block device and the third logical address is determined to correspond to a third physical address of the original block device based on the corresponding relationship, writing the data into the storage space corresponding to the third physical address of the original block device; and/or if data needs to be read from a storage space corresponding to a fourth logical address of the merged block device and it is determined that the fourth logical address corresponds to a fourth physical address of the original block device based on the correspondence, reading the data from the storage space corresponding to the fourth physical address of the original block device; or, the second application is a defragmentation application, and the target data includes defragmentation data in the target block device; the second application, when operating the original block device based on the target data in the reserved block device, is specifically configured to: after storing the fragmented data in the target block device into the reserved block device, if the total amount of data in the reserved block device reaches a preset threshold, the defragmentation application migrates the fragmented data in the reserved block device into the target storage area of the target block device.
The application provides an operating device of a block device, including: a processor and a machine-readable storage medium storing machine-executable instructions executable by the processor; wherein the processor is configured to execute the machine executable instructions to implement the method of operation of the block device described above.
The present application provides a machine-readable storage medium having stored thereon computer instructions which, when executed by a processor, enable a method of operation of a block device as described above.
As can be seen from the foregoing technical solutions, in the embodiments of the present application, an original block device may be divided into a reserved block device and a target block device, and the target block device is provided for a first application (such as a file system) to be used, that is, the first application only operates the target block device, the first application occupies all the storage space of the target block device, but does not occupy all the storage space of the original block device, that is, the first application does not occupy the reserved block device, so that a second application (any application except the first application) may operate the reserved block device, so that the second application may directly operate the original block device, and the operation efficiency of the original block device is improved without operating the original block device through the first application.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments of the present application or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments described in the present application, and other drawings can be obtained by those skilled in the art according to the drawings of the embodiments of the present application.
FIG. 1 is a flow diagram illustrating a method of operation of a block device in one embodiment of the present application;
fig. 2A-2F are schematic diagrams of reserved locations of original block devices in an embodiment of the present application;
FIG. 3 is an example of a block device merge application in one embodiment of the present application;
FIG. 4 is a schematic diagram of an operating device of a block device in one embodiment of the present application;
fig. 5 is a hardware configuration diagram of an operation device of a block device in an embodiment of the present application.
Detailed Description
The terminology used in the embodiments of the present application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in this application and the claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein is meant to encompass any and all possible combinations of one or more of the associated listed items.
It should be understood that although the terms first, second, third, etc. may be used in the embodiments of the present application to describe various information, the information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, first information may also be referred to as second information, and similarly, second information may also be referred to as first information, without departing from the scope of the present application. Depending on the context, moreover, the word "if" as used may be interpreted as "at … …" or "when … …" or "in response to a determination".
The block device includes, but is not limited to, a hard disk, a floppy disk, a CD-ROM, a magnetic disk, a flash memory, a usb (Secure Digital) card, and the like, and the type of the block device is not limited. The block device can store data in fixed-size (such as 512B) blocks, the data can be read and written only in multiples of the blocks, each block has a physical address for realizing independent access of each block, and the data in the block can be accessed through the physical address.
In general, a block device is provided for a file system to use, and once the block device is used by the file system, all storage spaces of the block device are managed by the file system, that is, the file system needs to occupy all storage spaces of the block device, and read and write operations on the block device are completed based on the file system, so that other applications cannot directly operate the block device, and only the block device can be operated through the file system.
For example, a Block Device may store data in a single disk, a RAID (Redundant array of Independent Disks), a Ceph (Distributed file system), and the like, and the Block Device may store a large amount of data, such as several T or even several tens of T, and may perform operations such as data migration and disk expansion in order to protect the large amount of data in the Block Device, whereas a DRBD (Distributed Replicated Block Device) application is a manner of implementing operations such as data migration, and the DRBD application is capable of implementing a remote copy function, and is a storage copy solution for mirroring the contents of the Block Device.
However, after the block device is used by the file system, all storage spaces of the block device are managed by the file system, so that no storage space capable of being managed by the DRBD application exists, that is, the metadata information corresponding to the DRBD application cannot be stored in the block device, and thus the block device cannot be used by the DRBD application, the DRBD application cannot directly operate the block device, and operations such as data migration cannot be realized.
In view of the above discovery, an operation method of a block device is provided in this embodiment of the present application, which may divide an original block device into a reserved block device and a target block device, and provide the target block device for a file system to use, that is, the file system does not occupy the reserved block device in the original block device, so that other applications may operate the reserved block device in the original block device, so that the other applications may directly operate the original block device.
For example, the DRBD application may store metadata information corresponding to the DRBD application in a reserved block device in the original block device, so that the original block device can be used by the DRBD application, and the DRBD application may directly operate the original block device, and may implement operations such as data migration.
The technical solutions of the embodiments of the present application are described below with reference to specific embodiments.
Referring to fig. 1, a flow diagram of a method for operating a block device is shown, where the method may include:
step 101, reserving a part of storage space from all storage spaces of the original block device as a reserved block device, and forming the remaining storage space except the reserved block device in the original block device into a target block device.
Wherein the reserved block device is a logical address contiguous block device, and the target block device is a logical address contiguous block device. For example, the physical addresses of the original block devices are 0-100 (i.e., the physical addresses are consecutive), the physical addresses 0-3, 10-13, 97-100 are used as the reserved block devices, and the remaining physical addresses are used as the target block devices. Then the logical addresses of the reserved block devices are 0-11 (i.e. the logical addresses of the reserved block devices are consecutive), the logical addresses 0-3 of the reserved block devices correspond to the physical addresses 0-3, the logical addresses 4-7 of the reserved block devices correspond to the physical addresses 10-13, and the logical addresses 8-11 of the reserved block devices correspond to the physical addresses 97-100. The logical addresses of the target block devices are 0-88 (i.e., the logical addresses of the target block devices are consecutive, the logical addresses of the target block devices are independent of the logical addresses of the reserved block devices, and all start from logical address 0), the logical addresses 0-5 of the target block devices correspond to physical addresses 4-9, and the logical addresses 6-88 of the target block devices correspond to physical addresses 14-96.
For example, for an original block device, before the original block device is provided for a first application (e.g. a file system) to use, the original block device needs to be divided into a reserved block device and a target block device, that is, a part of the storage space of the original block device is reserved as the reserved block device, and the remaining storage space except the reserved block device is made into the target block device, on the basis of which the target block device is provided for the first application to use, but not the original block device. For the convenience of distinction, the complete block device before division is referred to as an original block device, and the partial block devices after division except for the reserved block device are referred to as target block devices. For example, the original block device may include a storage space a, a storage space b, a storage space c, …, the storage space a may be used as a reserved block device, and the remaining storage space (e.g., the storage space b, the storage space c, etc.) except the storage space a may be made up into the target block device.
In a possible implementation manner, for step 101, the following steps may be adopted:
step 1011, obtaining a configured reservation mode, where the reservation mode includes but is not limited to: header reservation, trailer reservation, header reservation, designated reservation, segment reservation, although the above are just a few examples of reservation modes and are not limiting. For example, if the reserved mode is configured for header reservation, the configured reserved mode is acquired for header reservation; or, if the configured reservation mode is tail reservation, acquiring the configured reservation mode as tail reservation; or, if the configured reservation mode is head-to-tail reservation, acquiring the configured reservation mode as head-to-tail reservation; or, if the configured reservation mode is the designated reservation, acquiring the configured reservation mode as the designated reservation; or, if the configured reservation mode is the segment reservation, acquiring the configured reservation mode as the segment reservation.
For example, a reservation command issued by a user may be received, where the reservation command is used to indicate that a part of the storage space is reserved from the original block device as a reserved block device, and therefore, a part of the storage space needs to be reserved from all the storage spaces of the original block device as a reserved block device, see step 101. In the reservation command, a reservation mode field may be included, which includes a user-configured reservation mode, such as a header reservation, a trailer reservation, a designated reservation, a segment reservation, etc., and thus, the reservation mode may be parsed from the reservation command. Of course, the above is only an example, and other manners may be adopted to acquire the reservation mode.
Step 1012, obtaining the target storage capacity of the storage space to be reserved.
For example, a target storage capacity of the storage space to be reserved may be configured in advance, and on this basis, the configured target storage capacity may be obtained, where the target storage capacity is used to indicate the size of the reserved block device, for example, the target storage capacity is a. For example, in the reservation command, a reservation size field may be included, and the reservation size field includes a target storage capacity of the storage space to be reserved, so that the target storage capacity may be parsed from the reservation command.
As another example, the target storage capacity of the storage space to be reserved may be calculated based on a policy. Under one strategy, the target storage capacity may be calculated according to an application scenario, for example, in the application scenario, the second application needs to use a bytes to store data, and the target storage capacity may be greater than or equal to a bytes. In another strategy, the target storage capacity may be calculated according to the size of the original block device, for example, if the size of the original block device is m bytes, the target storage capacity may be n × m bytes, and n is a value greater than 0 and less than 1. In another strategy, the target storage capacity may be calculated according to the size of the original block device and the application scenario, for example, how many bytes of storage data the second application needs to use in the application scenario are calculated based on the size of the original block device, and the calculated value is the target storage capacity. Of course, the above are only a few examples and are not limiting.
In summary, the target storage capacity of the storage space to be reserved may be obtained and is denoted as the target storage capacity a.
Step 1013, a reserved location matching the reserved pattern is selected from all storage spaces of the original block device, where the reserved location may be a starting location of the reserved block device or an ending location of the reserved block device.
For example, refer to fig. 2A, which is a schematic diagram of all storage spaces of an original block device.
If the reserved mode is header reservation, the reserved location is the start location of the original block device, as shown in fig. 2B, which is a schematic diagram of the reserved location, and the reserved location is the start location of the reserved block device.
If the reserved mode is tail reservation, the reserved position is the end position of the original block device, as shown in fig. 2C, which is a schematic diagram of the reserved position, and the reserved position is used as the end position of the reserved block device.
If the reserved mode is head-to-tail reservation, the reserved positions are the start position and the end position of the original block device, as shown in fig. 2D, which is a schematic diagram of the reserved positions, that is, there are two reserved positions, one reserved position is the start position of the reserved block device, and the other reserved position is the end position of the reserved block device.
If the reserved mode is the designated reservation, the reserved position is the designated position of the original block device (may be located at any position of the original block device), as shown in fig. 2E, which is a schematic diagram of the reserved position, the reserved position may be used as an initial position of the reserved block device, the reserved position may also be used as an end position of the reserved block device, and the reserved position may also be used as an intermediate position of the reserved block device, which is not limited herein.
If the reserved mode is a segment reservation, the reserved location is a plurality of locations of the original block device, and for the plurality of locations, the interval between two adjacent locations is the same, as shown in fig. 2F, which is a schematic diagram of the reserved location, that is, there are a plurality of reserved locations, and each reserved location may be an initial location of the reserved block device, and of course, may also be an end location of the reserved block device or an intermediate location of the reserved block device. For example, the interval between the first position and the second position is k, the interval between the second position and the third position is k, the interval between the third position and the fourth position is k, and so on.
And 1014, reserving a storage space matched with the target storage capacity as a reserved block device at the reserved position, and forming the residual storage space except the reserved block device in the original block device into the target block device.
For example, referring to fig. 2B, the storage space of the target storage capacity a is selected from the reserved location to the back, the storage space of the target storage capacity a is used as the reserved block device, and the rest of the storage space is used as the target block device.
For another example, referring to fig. 2C, a storage space of the target storage capacity a is selected from the reserved location onward, the storage space of the target storage capacity a is taken as a reserved block device, and the rest of the storage space is taken as a target block device.
For another example, referring to fig. 2D, a storage space of a/2 size is selected backward from a front reserved location as a reserved block device, a storage space of a/2 size is selected forward from a rear reserved location as a reserved block device, and the rest of the storage space is used as a target block device.
For another example, referring to fig. 2E, if the reserved location is the starting location of the reserved block device, the storage space of the target storage capacity a is selected from the reserved location to the back, the storage space of the target storage capacity a is used as the reserved block device, and the rest of the storage space is used as the target block device. Or, if the reserved location is used as the termination location of the reserved block device, selecting the storage space of the target storage capacity a from the reserved location to the front as the reserved block device. Or, if the reserved position is used as the middle position of the reserved block device, selecting the storage space with the size of a/2 backwards from the reserved position, and selecting the storage space with the size of a/2 forwards from the reserved position.
For another example, referring to fig. 2F, assume that there are p reserved locations, and for each reserved location, a storage space of size a/p is chosen backward from the reserved location as a reserved block device.
To this end, step 101 is completed, and the original block device may be divided into a reserved block device and a target block device.
Step 102, providing mapping information corresponding to the storage space of the target block device to the first application, so that the first application operates the target block device based on the mapping information. It should be noted that, by providing the mapping information corresponding to the storage space of the target block device to the first application, the first application only operates on the target block device, and does not operate on the reserved block device of the original block device.
For example, after dividing the original block device into the reserved block device and the target block device, a mapping relationship between a logical address of the storage space of the target block device and a physical address of the storage space of the original block device (hereinafter referred to as mapping relationship 1) may be determined, and a mapping relationship between a logical address of the storage space of the reserved block device and a physical address of the storage space of the original block device (hereinafter referred to as mapping relationship 2) may be determined.
For example, the original block device includes a large number of blocks (called physical blocks or data blocks, and the data blocks are taken as examples in the following), each data block is of a fixed size (e.g., 512B, etc.), each data block corresponds to a physical address, the starting position of the data block can be known based on the physical address, and the data block can be found based on the physical address and the fixed size. For example, assuming that the physical address of the data block is P1, the data block is located between physical address P1 and physical address P2 (i.e., the sum of physical address P1 and the fixed size).
After dividing the original block device into the reserved block device and the target block device, the target block device includes a plurality of logical blocks, each logical block is of a fixed size (e.g., 512B, etc.), and each logical block corresponds to a logical address, based on which the start position of the logical block can be known, and based on which the logical address and the fixed size can be found. For example, assuming that the logical address of a logical block is Q1, it is between the logical address Q1 and the logical address Q2 (i.e., the sum of the logical address Q1 and the fixed size).
It should be noted that the logical block is not a real block, and data cannot be directly stored in the logical block, but the logical block of the target block device needs to be mapped to the data block of the original block device, and the data needs to be stored in the data block of the original block device. For example, if the logical block s1 of the target block device corresponds to the data block t1 of the original block device, the data needs to be stored in the logical block s1, and the data is stored in the data block t 1.
In order to implement the above functions, it is necessary to determine mapping relation 1 between the logical address of the storage space of the target block device and the physical address of the storage space of the original block device, as shown in table 1, which is an example of mapping relation 1.
TABLE 1
Logical address of memory space of target block device Physical address of memory space of original block device
Q1 P1
Q3 P3
As can be seen from table 1, when it is necessary to store data from the logical address Q1 of the target block device, it is actually the data from the physical address P1 of the original block device, and when it is necessary to store data from the logical address Q3 of the target block device, it is actually the data from the physical address P3 of the original block device.
After dividing the original block device into a reserved block device and a target block device, the reserved block device includes a small number of logical blocks, each logical block is of a fixed size (e.g., 512B, etc.), and each logical block corresponds to a logical address, based on which the start position of the logical block can be known, and based on which the logical address and the fixed size can be found. On this basis, it is necessary to determine the mapping relationship 2 between the logical address of the storage space of the reserved block device and the physical address of the storage space of the original block device, which is not described in detail herein.
To sum up, after dividing the original block device into the reserved block device and the target block device, mapping relation 1 and mapping relation 2 may be determined, and if the original block device needs to be provided for a first application (e.g., a file system) for use, mapping relation 1 may be provided for the first application, and since mapping relation 1 is a mapping relation between a logical address of a storage space of the target block device and a physical address of the storage space of the original block device, the first application may only operate the target block device and not operate the reserved block device based on mapping relation 1 (i.e., the logical address of the storage space of the target block device), that is, the first application only occupies the storage space of the target block device and does not occupy the storage space of the reserved block device.
In one possible implementation, the first application operates on the target block device based on the mapping information (which may include the mapping relation 1 described above), which may include but is not limited to: if data needs to be written into the storage space corresponding to the first logical address of the target block device, determining a first physical address corresponding to the first logical address based on the mapping relation 1, and writing the data into the storage space corresponding to the first physical address of the original block device. And/or if data needs to be read from the storage space corresponding to the second logical address of the target block device, determining a second physical address corresponding to the second logical address based on the mapping relation 1, and reading data from the storage space corresponding to the second physical address of the original block device.
For example, if data needs to be written into the storage space (i.e., logical block) corresponding to the logical address Q1 of the target block device, the mapping relation 1 in table 1 is looked up to determine that the logical address Q1 corresponds to the physical address P1, and therefore, the data is written into the storage space (i.e., data block) corresponding to the physical address P1 of the original block device.
For another example, if data needs to be read from the storage space (i.e., logical block) corresponding to the logical address Q3 of the target block device, the mapping relation 1 in table 1 is looked up to determine that the logical address Q3 corresponds to the physical address P3, and therefore, data is read from the storage space (i.e., data block) corresponding to the physical address P3 of the original block device.
Step 103, if an operation request sent by the second application is received, where the operation request includes target data and address information of a reserved block device, writing the target data into the reserved block device corresponding to the address information, so that the second application operates the original block device based on the target data in the reserved block device.
Illustratively, the execution subject of steps 101 to 103 is referred to as a target module, and the target module may be implemented by software or hardware, which is not limited to this. The target module may be loaded into the operating system in a kernel-driven manner, so that the target module performs the operation method of the block device, that is, performs steps 101 to 103, that is, the operating system may perform the operation method of the block device.
For example, if the second application (i.e. any application other than the first application, such as a DRBD application) needs to operate on the original block device, the second application may send an address request to the target module, where the address request is used to request address information of the reserved block device, and after receiving the address request, the target module may provide the address information of the reserved block device to the second application, so that the second application operates on the reserved block device based on the address information. Alternatively, the target module may also actively provide address information of the reserved block device to the second application, so that the second application operates the reserved block device based on the address information.
On this basis, if the second application needs to operate the original block device, based on the obtained address information of the reserved block device, the second application may send an operation request (i.e., a write request) to the target module, where the operation request includes the target data and the address information of the reserved block device, and indicates that the target data needs to be written into the reserved block device corresponding to the address information. After receiving the operation request sent by the second application, the target module may write the target data into the reserved block device corresponding to the address information.
If the second application needs to read data from the reserved block device, the second application may send a read request to the target module, where the read request includes address information of the reserved block device, and indicates that data needs to be read from the reserved block device corresponding to the address information. After receiving the read request sent by the second application, the target module may read data from the reserved block device corresponding to the address information, and return the data to the second application.
For example, the address information of the reserved block device may include a logical address (indicating a head address) and an offset (indicating an address length) of the reserved block device, and based on the logical address and the offset, a logical block (which may be one logical block or a plurality of logical blocks) in the reserved block device may be determined, and then the read-write operation is performed on the logical block in the reserved block device, so that the read-write operation of the reserved block device may be implemented.
For example, after receiving the operation request sent by the second application, the target module parses the target data and the address information of the reserved block device (e.g., the logical address a1 and the offset a2 of the reserved block device) from the operation request, determines the physical address b1 corresponding to the logical address a1 based on the mapping relation 2, determines the physical address b2 (i.e., the sum of the offset a2 and the physical address b 1) based on the offset a2 and the physical address b1, writes the target data into the data block between the physical address b1 and the physical address b2 of the reserved block device, implements the write operation on the reserved block device, and writes the target data into the reserved block device.
For another example, after receiving the read request sent by the second application, the destination module parses the address information (e.g., the logical address a3 and the offset a4) of the reserved block device from the read request, determines the physical address b3 corresponding to the logical address a3 based on the mapping relation 2, determines the physical address b4 (i.e., the sum of the offset a3 and the physical address b 3) based on the offset a4 and the physical address b3, reads data from the data block between the physical address b3 and the physical address b3 of the reserved block device, and implements the read operation on the reserved block device.
In one possible implementation, the message format may be agreed (for example, the message format is agreed through a specific interface, which is not limited), and the second application may send an operation request or a read request matching the message format to the target module, so that the target module can correctly parse the operation request or the read request.
In one possible embodiment, the original block device is divided into a reserved block device and a target block device, and the target block device is provided for the first application to use, and the reserved block device is not provided for the first application to use, then the second application may operate on the reserved block device, such as writing target data to the reserved block device, on the basis of which the second application may operate on the original block device based on the target data in the reserved block device.
In a possible implementation, the reserved block device may also be released, that is, the reserved block device and the target block device are restored to the original block device, and the original block device is provided for the first application to use.
As can be seen from the foregoing technical solutions, in the embodiments of the present application, an original block device may be divided into a reserved block device and a target block device, and the target block device is provided for a first application (such as a file system) to be used, that is, the first application only operates the target block device, the first application occupies all the storage space of the target block device, but does not occupy all the storage space of the original block device, that is, the first application does not occupy the storage space of the reserved block device, so that a second application (any application except the first application) may operate the reserved block device in the original block device, and the second application may directly operate the original block device without operating the original block device through the first application, thereby improving the operation efficiency of the original block device. Through carrying out the reservation of memory space to original block equipment, realize carrying out possibility and expansibility of operation to original block equipment, realized the ability to the self-defining use of original block equipment, increased the maneuverability and the variability of original block equipment. For the preprocessed target block device, the reserved block device is hidden outwards, so that the user can use the target block device exactly the same as the common block device. When the read-write operation is needed to be carried out on the reserved block device, the reserved block device can be accessed and read-written through the access interface.
In the above embodiment, for step 103, the target data needs to be written into the reserved block device, so that the second application operates the original block device based on the target data in the reserved block device, and this process is described below with reference to several specific application scenarios. It should be noted that, here, only a few examples of application scenarios are provided, and this is not a limitation as long as the reserved block device in the original block device can be operated.
Application scenario 1: the second application is a DRBD application and the target data includes metadata information corresponding to the DRBD application. On this basis, the DRBD application may perform a mirroring operation on the original block device based on the metadata information in the reserved block device to mirror the data in the original block device to another block device.
For example, when the DRBD application needs to perform data migration on an original block device, the DRBD application generates metadata information, and sends an operation request to the target module, where the operation request may include the metadata information and address information of a reserved block device, and after receiving the operation request, the target module may write the metadata information into the reserved block device corresponding to the address information. On this basis, the DRBD application may perform a mirroring operation on the original block device based on the metadata information in the reserved block device to mirror the data in the original block device to another block device, which is not limited in this embodiment.
Wherein the metadata information may include, but is not limited to, at least one of the following: equipment size: the device size refers to the size of the original block device, not the size of the target block device. Generation identification: for indicating the data freshness and old information between two DRBD blocks, i.e. which block device (i.e. the original block device) data is data before mirroring, and which block device (i.e. the other block device after mirroring) data is data after mirroring. Activity logging: for recording block activity, such as disconnect actions. Synchronizing the bitmap: the method is used for mapping each sector according to bits and recording whether the data of each sector are consistent. Internal metadata storage means. Of course, the above are only a few examples of metadata information, and the content of this metadata information is not limited.
The DRBD application can mirror the block devices, mirror the two block devices into the same data block according to the data bits, and realize storage and copy between the mirror block devices through management of metadata information.
The size of the metadata information can be obtained by adopting the following formula: msC8 +72, C denotes the pair Cs/218Down value, MsRepresenting metadata information, CsRepresents the size of the original block device, and thus, in the context of a DRBD application, may be based on the size C of the original block devicesCalculating a size M of metadata informationsOn this basis, the target storage capacity (see step 1012) in the above embodiment may be larger than or equal to the size M of the metadata informations. Of course, the above is only an example of the size of the metadata information, and no limitation is made to this.
The following describes a processing procedure under the DRBD application with reference to specific steps.
Step S11, a logical volume is created, which may be used as the original block device.
Step S12, calculating the size of the reserved block device based on the size of the original block device, for example, calculating the size of the metadata information based on the size of the original block device, and determining the target storage capacity of the storage space to be reserved based on the size of the metadata information, where the target storage capacity is the size of the reserved block device.
The metadata information here is metadata information corresponding to the DRBD application, that is, the metadata information generated by the DRBD application may include, but is not limited to, a device size, a generation identifier, an activity log, a synchronization bitmap, an internal metadata storage manner, and for specific explanation, reference is made to the above embodiments, and details are not described here.
And step S13, dividing the original block device into a target block device and a reserved block device based on the size of the reserved block device, wherein the sum of the size of the reserved block device and the size of the target block device is the size of the original block device.
Step S14, providing the target block device to the file System, for example, providing the target block device to the client through iSCSI (Internet Small Computer System Interface), and after the client connects to the target block device, the user performs read/write operation on the target block device in the file System.
Step S15, the DRBD application acquires the metadata information and writes the metadata information into the reserved block device.
Step S16, the DRBD application mirrors the data in the original block device to another block device based on the metadata information in the reserved block device.
Application scenario 2: the second application is a DRBD application and the target data includes metadata information corresponding to the DRBD application. On this basis, if the target module needs to provide the reserved block device for the DRBD application, the target module may merge the target block device and the reserved block device into the original block device (i.e., restore the original block device), and provide the mapping information corresponding to the storage space of the original block device to the DRBD application, so that the DRBD application operates the original block device based on the mapping information, which is similar to step 102, except that the mapping information corresponding to the storage space of the original block device (instead of the mapping information corresponding to the storage space of the target block device) is provided to the DRBD application, and the DRBD application operates the original block device (instead of operating the target block device), and specific processes are not repeated herein.
For example, after providing the mapping information corresponding to the storage space of the original block device to the DRBD application, the DRBD application may further obtain a target block device and a reserved block device in the original block device, for example, determine the reserved block device in the original block device based on the information such as the reserved mode and the target storage capacity of the storage space to be reserved, and the determining manner is referred to in step 101, which is not described herein again.
On this basis, the DRBD application may store the metadata information into the reserved block device when operating on the original block device, and may mirror the original block device to mirror the data in the original block device to another block device based on the metadata information in the reserved block device.
Of course, the above is only an example of the DRBD application operating on the original block device, and is not limited thereto.
Application scenario 3: the second application is a block device merge application, the block device merge application is configured to combine the original block device and another block device (e.g., at least one block device) other than the original block device into a merged block device, and the target data includes a correspondence between a logical address of a storage space of the merged block device and a physical address of the storage space of the original block device. On this basis, if data needs to be written into the storage space corresponding to the third logical address of the merged block device, and it is determined that the third logical address corresponds to the third physical address of the original block device based on the correspondence, the block device merge application writes the data into the storage space corresponding to the third physical address of the original block device. And/or if data needs to be read from the storage space corresponding to the fourth logical address of the merged block device, and the fourth logical address is determined to correspond to the fourth physical address of the original block device based on the correspondence, the block device merged application reads the data from the storage space corresponding to the fourth physical address of the original block device.
For example, the original block device 1 may be divided into the target block device 11 and the reserved block device 12, and the original block device 2 may be divided into the target block device 21 and the reserved block device 22, on which basis, the block device merge application may combine the original block device 1 and the original block device 2 into a merged block device, that is, the merged block device includes the original block device 1 and the original block device 2, the merged block device includes logical blocks, and the original block device 1 and the original block device 2 include data blocks. Then, the block device merge application may determine a correspondence 1 between the logical address of the storage space of the merged block device and the physical address of the storage space of the original block device 1, and determine a correspondence 2 between the logical address of the storage space of the merged block device and the physical address of the storage space of the original block device 2. Then, the block device merge application writes the correspondence 1 into the reserved block device 22 of the original block device 2, and writes the correspondence 2 into the reserved block device 12 of the original block device 1.
If data needs to be written into the storage space corresponding to the third logical address of the merged block device, the block device merge application queries the corresponding relationship 1 in the reserved block device 22 through the third logical address, and if the third logical address exists in the corresponding relationship 1 and the third logical address corresponds to the physical address x in the original block device 1 (that is, the physical address x is taken as the third physical address), the block device merge application writes the data into the storage space corresponding to the physical address x of the original block device 1. Or, if the third logical address does not exist in the correspondence relationship 1, the block device merge application queries the correspondence relationship 2 in the reserved block device 12 through the third logical address, and if the third logical address corresponds to the physical address y in the original block device 2 (that is, the physical address y is used as the third physical address), the block device merge application writes the data into the storage space corresponding to the physical address y of the original block device 2.
If data needs to be read from the storage space corresponding to the fourth logical address of the merged block device, the block device merge application queries the corresponding relationship 1 through the fourth logical address, and if the fourth logical address is queried to correspond to the physical address in the original block device 1, data is read from the storage space corresponding to the physical address of the original block device 1. Or, if the correspondence relationship 1 does not have the fourth logical address, the block device merge application queries the correspondence relationship 2 by using the fourth logical address, and if the fourth logical address is queried to correspond to the physical address in the original block device 2, reads data from the storage space corresponding to the physical address of the original block device 2.
In addition to the block device merge application, for other applications accessing the original block device 1, the corresponding relationship 2 may be read from the reserved block device 12 of the original block device 1, and then the corresponding relationship between the logical address of the storage space of the merged block device and the physical address of the storage space of the original block device 2 is known, that is, data may be stored in the original block device 2, or data may be read from the original block device 2, that is, the original block device 2 may be accessed, so that the original block device 1 and the original block device 2 are accessed.
In addition to the block device merge application, for other applications accessing the original block device 2, the corresponding relationship 1 may be read from the reserved block device 22 of the original block device 2, and then the corresponding relationship between the logical address of the storage space of the merged block device and the physical address of the storage space of the original block device 1 is known, that is, data may be stored in the original block device 1, or data may be read from the original block device 1, that is, the original block device 1 may be accessed, so that the original block device 1 and the original block device 2 are accessed.
Referring to fig. 3, for an example of a block device merge application, a connection operation of two original block devices (i.e., original block device 1 and original block device 2) may be implemented by head-to-tail reservation, that is, two original block devices are connected to be used by one large block device (i.e., a merge block device), and logical addresses of the merge block devices are consecutive. For example, a space reservation is made for the tail of the original block device 1 (i.e., the reserved block device is located at the tail of the original block device 1), and a space reservation is made for the head of the original block device 2 (i.e., the reserved block device is located at the head of the original block device 2). When connection is executed, the corresponding relation 1 is recorded to the reserved block device at the head position of the original block device 2, the corresponding relation 2 is recorded to the reserved block device at the tail position of the original block device 1, and the reserved block device of the original block device 1 is connected with the reserved block device of the original block device 2.
Application scenario 4: the second application is a defragmentation application and the target data includes fragmented data in the target block device (i.e., scattered data in different data blocks). On this basis, after the fragmented data in the target block device is stored in the reserved block device, if the total amount of data in the reserved block device reaches a preset threshold, the defragmentation application migrates the fragmented data in the reserved block device to the target storage area of the target block device.
For example, during the use of the target block device, the target block device may be repeatedly written and deleted with data, that is, the data may not occupy the entire target block device, so that the data in the target block device becomes fragmented data, and the fragmented data in the target block device needs to be defragmented. On this basis, the defragmentation application may send an operation request to the target module, where the operation request may include the fragmented data and address information of the reserved block device, and the target module may write the fragmented data into the reserved block device corresponding to the address information after receiving the operation request. On this basis, since a large number of target block devices all have fragmented data, the fragmented data needs to be written into the reserved block devices continuously, resulting in more and more fragmented data in the reserved block devices. If the total amount of data in the reserved block device reaches a preset threshold (which may be configured according to experience, for example, the total size m of the reserved block device is a numerical value greater than 0 and less than or equal to 1), the defragmentation application may migrate all fragmented data in the reserved block device to a target storage area of the target block device, that is, integrate the fragmented data in the same storage area of the target block device, and delete the fragmented data in the reserved block device, thereby releasing the storage space of the reserved block device, and may continue to write the fragmented data into the reserved block device.
In summary, the reserved block device may serve as a temporary storage space for defragmentation of the disk, and may temporarily copy the fragmented data to the reserved block device, so as to implement integration of the fragmented data through the reserved block device.
Based on the same application concept as the method, an embodiment of the present application provides an operating apparatus of a block device, which is shown in fig. 4 and is a schematic structural diagram of the apparatus, and the apparatus includes: a management module 41, configured to reserve a part of storage space from all storage spaces of an original block device as a reserved block device, and form a target block device from remaining storage spaces of the original block device except the reserved block device; a providing module 42, configured to provide mapping information corresponding to a storage space of a target block device to a first application, so that the first application operates on the target block device based on the mapping information; an operation module 43, configured to, if an operation request sent by a second application is received, where the operation request includes target data and address information of the reserved block device, write the target data into the reserved block device corresponding to the address information, so that the second application operates an original block device based on the target data in the reserved block device.
For example, when the management module 41 reserves a part of the storage space from all the storage spaces of the original block device as a reserved block device, it is specifically configured to: acquiring a configured reservation mode, and acquiring a target storage capacity of a storage space to be reserved; selecting a reserved position matched with the reserved mode from all storage spaces of original block equipment; and reserving a storage space matched with the target storage capacity as a reserved block device at the reserved position. The reservation mode is head reservation, tail reservation, head and tail reservation, designated reservation or segmented reservation; if the reserved mode is the head reservation, the reserved position is the starting position of the original block device; or, if the reserved mode is tail reservation, the reserved position is the end position of the original block device; or, if the reserved mode is head-to-tail reservation, the reserved position is a start position and an end position of the original block device; or, if the reserved mode is a designated reservation, the reserved position is a designated position of the original block device; or, if the reservation mode is segment reservation, the reserved positions are multiple positions of the original block device, and the intervals between two adjacent positions are the same.
Illustratively, the mapping information includes a mapping relationship between a logical address of the storage space of the target block device and a physical address of the storage space of the original block device; the first application, when operating the target block device based on the mapping information, is specifically configured to: if data needs to be written into a storage space corresponding to a first logical address of the target block device, determining a first physical address corresponding to the first logical address based on the mapping relation, and writing the data into the storage space corresponding to the first physical address of the original block device; and/or if data needs to be read from a storage space corresponding to a second logical address of the target block device, determining a second physical address corresponding to the second logical address based on the mapping relationship, and reading data from the storage space corresponding to the second physical address of the original block device.
Exemplarily, the second application is a DRBD application, and the target data includes metadata information corresponding to the DRBD application; the second application, when operating the original block device based on the target data in the reserved block device, is specifically configured to: performing mirroring operation on the original block device based on the metadata information in the reserved block device to mirror data in the original block device to another block device; or the second application is a block device merge application, where the block device merge application is configured to combine an original block device and other block devices except the original block device into a merged block device, and the target data includes a correspondence between a logical address of a storage space of the merged block device and a physical address of the storage space of the original block device; the second application, when operating the original block device based on the target data in the reserved block device, is specifically configured to: if data needs to be written into a storage space corresponding to a third logical address of the merged block device and the third logical address is determined to correspond to a third physical address of the original block device based on the corresponding relationship, writing the data into the storage space corresponding to the third physical address of the original block device; and/or if data needs to be read from a storage space corresponding to a fourth logical address of the merged block device and it is determined that the fourth logical address corresponds to a fourth physical address of the original block device based on the correspondence, reading the data from the storage space corresponding to the fourth physical address of the original block device; or, the second application is a defragmentation application, and the target data includes defragmentation data in the target block device; the second application, when operating the original block device based on the target data in the reserved block device, is specifically configured to: after storing the fragmented data in the target block device into the reserved block device, if the total amount of data in the reserved block device reaches a preset threshold, the defragmentation application migrates the fragmented data in the reserved block device into the target storage area of the target block device.
Based on the same application concept as the method, the embodiment of the present application provides an operating device of a block device, which is shown in fig. 5 and includes: a processor 51 and a machine-readable storage medium 52, the machine-readable storage medium 52 storing machine-executable instructions executable by the processor 51; wherein, the processor 51 is configured to execute the machine executable instructions to implement the operation method of the block device disclosed in the above example of the present application.
For example, the processor 51, when executing the machine executable instructions, can implement the following steps:
reserving a part of storage space from all storage spaces of original block equipment as reserved block equipment, and forming the residual storage space except the reserved block equipment in the original block equipment into target block equipment;
providing mapping information corresponding to the storage space of the target block device to a first application so that the first application operates the target block device based on the mapping information;
if an operation request sent by a second application is received, wherein the operation request comprises target data and address information of reserved block equipment, the target data is written into the reserved block equipment corresponding to the address information, so that the second application operates original block equipment based on the target data in the reserved block equipment.
Based on the same application concept as the method, embodiments of the present application further provide a machine-readable storage medium, where several computer instructions are stored, and when the computer instructions are executed by a processor, the method for operating the block device disclosed in the above example of the present application can be implemented.
For example, the computer instructions, when executed by a processor, implement the steps of:
reserving a part of storage space from all storage spaces of original block equipment as reserved block equipment, and forming the residual storage space except the reserved block equipment in the original block equipment into target block equipment;
providing mapping information corresponding to the storage space of the target block device to a first application so that the first application operates the target block device based on the mapping information;
if an operation request sent by a second application is received, wherein the operation request comprises target data and address information of reserved block equipment, the target data is written into the reserved block equipment corresponding to the address information, so that the second application operates original block equipment based on the target data in the reserved block equipment.
The machine-readable storage medium may be any electronic, magnetic, optical, or other physical storage device that can contain or store information such as executable instructions, data, and the like. For example, the machine-readable storage medium may be: a RAM (random Access Memory), a volatile Memory, a non-volatile Memory, a flash Memory, a storage drive (e.g., a hard drive), a solid state drive, any type of storage disk (e.g., an optical disk, a dvd, etc.), or similar storage medium, or a combination thereof.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. A typical implementation device is a computer, which may take the form of a personal computer, laptop computer, cellular telephone, camera phone, smart phone, personal digital assistant, media player, navigation device, email messaging device, game console, tablet computer, wearable device, or a combination of any of these devices.
For convenience of description, the above devices are described as being divided into various units by function, and are described separately. Of course, the functionality of the units may be implemented in one or more software and/or hardware when implementing the present application.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
Furthermore, these computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The above description is only an example of the present application and is not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (11)

1. A method of operation of a block device, the method comprising:
reserving a part of storage space from all storage spaces of original block equipment as reserved block equipment, and forming the residual storage space except the reserved block equipment in the original block equipment into target block equipment;
providing mapping information corresponding to the storage space of the target block device to a first application so that the first application operates the target block device based on the mapping information;
if an operation request sent by a second application is received, wherein the operation request comprises target data and address information of reserved block equipment, the target data is written into the reserved block equipment corresponding to the address information, so that the second application operates original block equipment based on the target data in the reserved block equipment.
2. The method of claim 1, wherein reserving a portion of the memory space from all memory space of the original block device as a reserved block device comprises:
acquiring a configured reservation mode and acquiring a target storage capacity of a storage space to be reserved;
selecting a reserved position matched with the reserved mode from all storage spaces of the original block device;
and reserving a storage space matched with the target storage capacity as a reserved block device at the reserved position.
3. The method of claim 2, wherein the reservation mode is a header reservation, or a trailer reservation, or a header and trailer reservation, or a designated reservation, or a segment reservation;
if the reserved mode is the head reservation, the reserved position is the starting position of the original block device; or, if the reserved mode is tail reservation, the reserved position is the end position of the original block device; or, if the reserved mode is head-to-tail reservation, the reserved position is a start position and an end position of the original block device; or, if the reserved mode is a designated reservation, the reserved position is a designated position of the original block device; or, if the reservation mode is segment reservation, the reserved positions are multiple positions of the original block device, and the intervals between two adjacent positions are the same.
4. The method according to claim 1, wherein the mapping information comprises a mapping relationship between a logical address of the storage space of the target block device and a physical address of the storage space of the original block device;
the first application operates the target block device based on the mapping information, including:
if data needs to be written into a storage space corresponding to a first logical address of the target block device, determining a first physical address corresponding to the first logical address based on the mapping relation, and writing the data into the storage space corresponding to the first physical address of the original block device; and/or the presence of a gas in the gas,
and if data needs to be read from the storage space corresponding to the second logical address of the target block device, determining a second physical address corresponding to the second logical address based on the mapping relation, and reading the data from the storage space corresponding to the second physical address of the original block device.
5. The method of claim 1, wherein the second application is a Distributed Replicated Block Device (DRBD) application, and the target data comprises metadata information corresponding to the DRBD application; the second application operates on an original block device based on target data in the reserved block device, including:
the DRBD application performs a mirroring operation on the original block device based on the metadata information in the reserved block device to mirror data in the original block device to another block device.
6. The method according to claim 1, wherein the second application is a block device merge application, and the block device merge application is configured to combine the original block device and other block devices except the original block device into a merged block device, and the target data includes a correspondence relationship between a logical address of a storage space of the merged block device and a physical address of the storage space of the original block device; the second application operates on an original block device based on target data in the reserved block device, including:
if data needs to be written into a storage space corresponding to a third logical address of the merged block device and the third logical address is determined to correspond to a third physical address of the original block device based on the corresponding relationship, writing the data into the storage space corresponding to the third physical address of the original block device; and/or the presence of a gas in the gas,
and if data needs to be read from a storage space corresponding to a fourth logical address of the merged block device and the fourth logical address is determined to correspond to the fourth physical address of the original block device based on the corresponding relationship, reading the data from the storage space corresponding to the fourth physical address of the original block device.
7. The method of claim 1, wherein the second application is a defragmentation application, and wherein the target data comprises defragmentation data in the target block device; the second application operates on an original block device based on target data in the reserved block device, including:
after storing the fragmented data in the target block device into the reserved block device, if the total amount of data in the reserved block device reaches a preset threshold, the defragmentation application migrates the fragmented data in the reserved block device into the target storage area of the target block device.
8. An operating device of a block device, characterized in that the device comprises: the management module is used for reserving part of storage space from all storage space of original block equipment as reserved block equipment and forming the residual storage space except the reserved block equipment in the original block equipment into target block equipment;
a providing module, configured to provide mapping information corresponding to a storage space of the target block device to a first application, so that the first application operates the target block device based on the mapping information;
and the operation module is used for writing the target data into the reserved block device corresponding to the address information if an operation request sent by a second application is received, wherein the operation request comprises the target data and the address information of the reserved block device, so that the second application operates the original block device based on the target data in the reserved block device.
9. The apparatus of claim 8,
the management module is specifically configured to, when reserving a part of the storage space from all the storage spaces of the original block device as a reserved block device: acquiring a configured reservation mode, and acquiring a target storage capacity of a storage space to be reserved; selecting a reserved position matched with the reserved mode from all storage spaces of original block equipment; reserving a storage space matched with the target storage capacity as a reserved block device at the reserved position; the reservation mode is head reservation, tail reservation, head and tail reservation, designated reservation or segment reservation; if the reserved mode is the head reservation, the reserved position is the starting position of the original block device; or, if the reserved mode is tail reservation, the reserved position is the end position of the original block device; or, if the reserved mode is head-to-tail reservation, the reserved position is a start position and an end position of the original block device; or, if the reserved mode is a designated reservation, the reserved position is a designated position of the original block device; or, if the reservation mode is segment reservation, the reservation positions are multiple positions of the original block device, and the intervals between two adjacent positions are the same;
the mapping information comprises a mapping relation between a logical address of a storage space of the target block device and a physical address of a storage space of the original block device; the first application, when operating the target block device based on the mapping information, is specifically configured to: if data needs to be written into a storage space corresponding to a first logical address of the target block device, determining a first physical address corresponding to the first logical address based on the mapping relation, and writing the data into the storage space corresponding to the first physical address of the original block device; and/or if data needs to be read from a storage space corresponding to a second logical address of the target block device, determining a second physical address corresponding to the second logical address based on the mapping relationship, and reading data from the storage space corresponding to the second physical address of the original block device;
the second application is a DRBD application, and the target data comprises metadata information corresponding to the DRBD application; the second application, when operating the original block device based on the target data in the reserved block device, is specifically configured to: performing mirroring operation on the original block device based on the metadata information in the reserved block device to mirror data in the original block device to another block device; alternatively, the first and second electrodes may be,
the second application is a block device merge application, the block device merge application is configured to combine an original block device and other block devices except the original block device into a merged block device, and the target data includes a correspondence between a logical address of a storage space of the merged block device and a physical address of the storage space of the original block device; the second application, when operating the original block device based on the target data in the reserved block device, is specifically configured to: if data needs to be written into a storage space corresponding to a third logical address of the merged block device and the third logical address is determined to correspond to a third physical address of the original block device based on the corresponding relationship, writing the data into the storage space corresponding to the third physical address of the original block device; and/or if data needs to be read from a storage space corresponding to a fourth logical address of the merged block device and it is determined that the fourth logical address corresponds to a fourth physical address of the original block device based on the correspondence, reading the data from the storage space corresponding to the fourth physical address of the original block device;
or, the second application is a defragmentation application, and the target data includes defragmentation data in the target block device; the second application, when operating the original block device based on the target data in the reserved block device, is specifically configured to: after storing the fragmented data in the target block device into the reserved block device, if the total amount of data in the reserved block device reaches a preset threshold, the defragmentation application migrates the fragmented data in the reserved block device into the target storage area of the target block device.
10. An operating device of a block device, comprising: a processor and a machine-readable storage medium storing machine-executable instructions executable by the processor;
wherein: the processor is configured to execute the machine executable instructions to perform the method steps of any of claims 1-7.
11. A machine-readable storage medium, having stored thereon computer instructions, which, when executed by a processor, are capable of performing the method steps of any one of claims 1-7.
CN202111015819.1A 2021-08-31 2021-08-31 Method, device and equipment for operating block equipment and machine-readable storage medium Pending CN113741816A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111015819.1A CN113741816A (en) 2021-08-31 2021-08-31 Method, device and equipment for operating block equipment and machine-readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111015819.1A CN113741816A (en) 2021-08-31 2021-08-31 Method, device and equipment for operating block equipment and machine-readable storage medium

Publications (1)

Publication Number Publication Date
CN113741816A true CN113741816A (en) 2021-12-03

Family

ID=78734444

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111015819.1A Pending CN113741816A (en) 2021-08-31 2021-08-31 Method, device and equipment for operating block equipment and machine-readable storage medium

Country Status (1)

Country Link
CN (1) CN113741816A (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103714007A (en) * 2012-09-29 2014-04-09 联想(北京)有限公司 Data writing method and electronic equipment
US20140325157A1 (en) * 2013-04-26 2014-10-30 Netapp, Inc. Data access request monitoring to reduce system resource use for background operations
US8949526B1 (en) * 2010-12-13 2015-02-03 Emc Corporation Reserving storage space in data storage systems
US20170212690A1 (en) * 2016-01-22 2017-07-27 Netapp, Inc. Recovery from low space condition of an extent store
CN110019083A (en) * 2017-09-20 2019-07-16 阿里巴巴集团控股有限公司 Storage method, device, electronic equipment and the storage medium of distributed file system
CN110727403A (en) * 2019-09-12 2020-01-24 华为技术有限公司 Metadata management method and device
CN110895445A (en) * 2018-09-12 2020-03-20 华为技术有限公司 Data processing method and system

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8949526B1 (en) * 2010-12-13 2015-02-03 Emc Corporation Reserving storage space in data storage systems
CN103714007A (en) * 2012-09-29 2014-04-09 联想(北京)有限公司 Data writing method and electronic equipment
US20140325157A1 (en) * 2013-04-26 2014-10-30 Netapp, Inc. Data access request monitoring to reduce system resource use for background operations
US20170212690A1 (en) * 2016-01-22 2017-07-27 Netapp, Inc. Recovery from low space condition of an extent store
CN110019083A (en) * 2017-09-20 2019-07-16 阿里巴巴集团控股有限公司 Storage method, device, electronic equipment and the storage medium of distributed file system
CN110895445A (en) * 2018-09-12 2020-03-20 华为技术有限公司 Data processing method and system
CN110727403A (en) * 2019-09-12 2020-01-24 华为技术有限公司 Metadata management method and device

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
MOHIT SAXENA等: "FlashTier: a lightweight, consistent and durable storage cache", PROCEEDINGS OF THE 7TH ACM EUROPEAN CONFERENCE ON COMPUTER SYSTEMS, pages 267 *
舒辉;董卫宇;康绯;: "通过磁盘隔离技术实现重要信息系统安全", 信息网络安全, no. 02, pages 30 - 33 *

Similar Documents

Publication Publication Date Title
CN107807794B (en) Data storage method and device
EP3617867B1 (en) Fragment management method and fragment management apparatus
CN106055431B (en) The method and device of backup and recovery based on the online rollback of snapshot
US7725655B2 (en) Method of operating distributed storage system in which data is read from replicated caches and stored as erasure-coded data
US7761663B2 (en) Operating a replicated cache that includes receiving confirmation that a flush operation was initiated
US20180232314A1 (en) Method for storing data by storage device and storage device
CN107729536B (en) Data storage method and device
US8832356B2 (en) Apparatus and method for flash memory address translation
US11698728B2 (en) Data updating technology
CN112114753B (en) Data writing method, device and equipment
US10572335B2 (en) Metadata recovery method and apparatus
CN107329704B (en) Cache mirroring method and controller
US11403021B2 (en) File merging method and controller
US11449402B2 (en) Handling of offline storage disk
CN106033320B (en) Processing method and device for high-performance Redundant Array of Inexpensive Disks (RAID) mechanism
CN102033793A (en) Snapshot method and solid-state hard disk
KR20110139956A (en) Data storage device and data management method for processing of mapping table
CN109407985B (en) Data management method and related device
CN108491290B (en) Data writing method and device
CN114827178A (en) Data processing method, device and equipment and readable storage medium
US20220129346A1 (en) Data processing method and apparatus in storage system, and storage system
CN110427347A (en) Method, apparatus, memory node and the storage medium of data de-duplication
CN108334457B (en) IO processing method and device
CN113741816A (en) Method, device and equipment for operating block equipment and machine-readable storage medium
CN113360095B (en) Hard disk data management method, device, equipment and medium

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