Metadata mapping method and device, storage medium and program product
By obtaining the starting address of the target data and the bit length of the relative offset in the SMR disk, a metadata mapping relationship is constructed, which solves the problem of large space occupancy of metadata in SMR disk and realizes efficient memory utilization.
Patent Information
- Application Number
- CN202510467462.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-14
- Publication Date
- 2025-07-25
AI Technical Summary
For shingle track layout (SMR) disks, the prior art requires recording metadata of global logical address offsets and global physical address offsets, resulting in a large storage space occupancy, especially when the server memory is limited, it is difficult to effectively manage.
By obtaining the starting logical address and starting physical address of the target data in the target logical data block, and determining the bit length of the relative logical address offset and the relative physical address offset, metadata is constructed to record the mapping relationship of data, reducing the memory space occupied by metadata.
It effectively reduces the memory space occupied by metadata, saves storage resources, and is suitable for electronic devices such as servers.
Smart Images

Figure CN120371208A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate to the field of computer and network communication technologies, and in particular, to a metadata mapping method, device, storage medium, and program product. Background Art
[0002] During the disk read and write process, it is usually necessary to perform the conversion between logical addresses and physical addresses, and the mapping from logical addresses to physical addresses can be based on metadata.
[0003] For some disks that only support sequential writing, such as disks with a shingled magnetic recording (SMR) layout, in the metadata for the mapping from the logical addresses of the data in a logical data block (Chunk) to physical addresses, it is necessary to record the global logical address offset, logical address length, global physical address offset, and physical address length of the data, resulting in a large amount of metadata and occupying more storage space. Summary of the Invention
[0004] Embodiments of the present disclosure provide a metadata mapping method, device, storage medium, and program product to overcome the above problems.
[0005] In a first aspect, embodiments of the present disclosure provide a metadata mapping method, including:
[0006] When multiple target data are continuously written into a target disk partition in a target logical data block, obtain the starting logical address of the multiple target data in the target logical data block, and the starting physical address of the multiple target data in the target disk partition;
[0007] Determine a first bit length of the relative logical address offset of the multiple target data relative to the starting logical address and a second bit length of the relative physical address offset of the multiple target data relative to the starting physical address;
[0008] For each of the multiple target data, obtain a relative logical address offset of the corresponding first bit length and a relative physical address offset of the second bit length;
[0009] According to the starting logical address, the starting physical address, the first bit length, the second bit length, and the relative logical address offsets and relative physical address offsets of the multiple target data, construct the metadata of the multiple target data, where the metadata is used to determine the mapping relationship between the logical addresses and physical addresses of the multiple target data.
[0010] In a second aspect, embodiments of the present disclosure provide a metadata mapping device, including:
[0011] A starting address determination unit, configured to obtain a starting logical address of the plurality of target data in the target logical data block and a starting physical address of the plurality of target data in the target disk partition when the plurality of target data are continuously written into the target disk partition;
[0012] A bit length determination unit, configured to determine a first bit length of a relative logical address offset of the plurality of target data relative to the starting logical address and a second bit length of a relative physical address offset relative to the starting physical address;
[0013] A relative offset determination unit, configured to obtain, for each of the plurality of target data, a relative logical address offset of a corresponding first bit length and a relative physical address offset of a second bit length;
[0014] A construction unit, configured to construct metadata of the plurality of target data according to the starting logical address, the starting physical address, the first bit length, the second bit length, and the relative logical address offsets and relative physical address offsets of the plurality of target data, where the metadata is used to determine a mapping relationship between the logical addresses and physical addresses of the plurality of target data.
[0015] In a third aspect, an embodiment of the present disclosure provides an electronic device, including: a processor and a memory;
[0016] The memory stores computer-executable instructions;
[0017] The processor executes the computer-executable instructions stored in the memory, so that the at least one processor executes the metadata mapping method as described in the first aspect and various possible designs of the first aspect above.
[0018] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium, in which computer-executable instructions are stored, and when the processor executes the computer-executable instructions, the metadata mapping method as described in the first aspect and various possible designs of the first aspect above is implemented.
[0019] In a fifth aspect, an embodiment of the present disclosure provides a computer program product, including a computer program, and when the computer program is executed by a processor, the metadata mapping method as described in the first aspect and various possible designs of the first aspect above is implemented.
[0020] The metadata mapping method, device, storage medium, and program product provided by the embodiments of the present disclosure obtain the starting logical address of multiple target data in a target logical data block and the starting physical address of the multiple target data in a target disk partition when the multiple target data are continuously written to the target disk partition; determine the first bit length of the relative logical address offset of the multiple target data relative to the starting logical address and the second bit length of the relative physical address offset relative to the starting physical address; obtain the corresponding relative logical address offset of the first bit length and the relative physical address offset of the second bit length for each of the multiple target data; and construct the metadata of the multiple target data according to the starting logical address, starting physical address, first bit length, second bit length, and the relative logical address offset and relative physical address offset of the multiple target data, where the metadata is used to determine the mapping relationship between the logical address and the physical address of the multiple target data. In this embodiment, by determining the starting logical address of the target data in the target logical data block and the starting physical address in the target disk partition, and determining appropriate bit lengths to record the relative logical address offset and relative physical address offset, compared with directly recording the global logical address offset and global physical address offset, the size of the metadata occupied in memory can be reduced, and the memory space for storing the metadata can be saved. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present disclosure. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0022] Figure 1 A schematic diagram of a metadata mapping in the prior art;
[0023] Figure 2 A schematic flowchart of the metadata mapping method provided by an embodiment of the present disclosure;
[0024] Figure 3 A schematic diagram of a preset data structure for storing device metadata provided by an embodiment of the present disclosure;
[0025] Figure 4 A schematic flowchart of the metadata mapping method provided by an embodiment of the present disclosure;
[0026] Figure 5 A block diagram of the structure of the metadata mapping device provided by an embodiment of the present disclosure;
[0027] Figure 6Schematic diagram of the hardware structure of the metadata mapping device provided by an embodiment of the present disclosure. Detailed implementation manners
[0028] To make the objectives, technical solutions, and advantages of the embodiments of the present disclosure clearer, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present disclosure. Apparently, the described embodiments are some but not all of the embodiments of the present disclosure. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present disclosure without creative efforts shall fall within the protection scope of the present disclosure.
[0029] In traditional perpendicular magnetic recording (PMR) technology, the tracks are parallel and independent of each other, like a series of parallel tracks, and the writing and reading of data do not affect each other. In shingled magnetic recording (SMR), the tracks overlap each other like tiles. For an HDD (Hard Disk Drive) of the same size, SMR can have more stacked tracks, thereby providing a higher storage density. However, due to this track layout method, SMR disks only support sequential writing.
[0030] For the above SMR disks, in the metadata for mapping the logical address of the data in a logical data block (chunk, the size of which can be specified) to the physical address, it is necessary to record the global logical address offset of the data, the logical address length, the global physical address offset, and the physical address length, so as to map chunk<offset, length> to a specific physical location <zone_id, zone_offset, zone_length>. The specific mapping process can be as follows Figure 1 As shown, first, according to the data reading request, determine the chunkId of the data block where the data to be read is located, and then find the corresponding metadata chunkMeta of this chunkId in the metadata map chunkMap according to the chunkId of the data block. The metadata chunkMeta contains all the index information of this data block chunk; find the entry Entry corresponding to the data to be read in the index information of the chunk according to <offset, length> in the data reading request. One entry Entry contains the mapping of the logical address of a piece of data to the physical address; then the data can be read from the disk according to the physical address.
[0031] For different file systems, metadata management can adopt the real-time disk write mode. In this mode, after the metadata is modified, the modified metadata will be immediately written to the disk, which can ensure that the stored metadata is always up-to-date. This mode provides high data reliability, but it will generate additional disk I / O overhead. Each I / O not only needs to write the actual data of the I / O, but also needs to write the metadata once, which will cause frequent head movement. Therefore, there is another mode where the metadata is stored entirely in memory. In this mode, all the metadata information involved above is stored in memory. In this way, during the operation of the file system, the access and operation of the metadata are mainly carried out in memory, and there is no need to frequently read or write the metadata from the disk. This mode can ensure data reliability through regular disk writes plus additional recovery strategies, but there is still another technical challenge: the current general server memory capacity is generally 256 GiB, and it is necessary to solve how to store all the metadata for different disk sizes in the memory of such servers.
[0032] Specifically, the space occupied by the metadata is related to many factors: the capacity of the disk, the design method of the metadata management module, etc. For SMR disks, where logic offset represents the logical offset of this continuous data in the chunk data, logic length represents the corresponding size of the data, zone offset represents the physical offset of the data in the zone, and zone length represents the physical length occupied by the data in the zone. For a 4 GiB-sized chunk, in the extreme case, the logic offset needs 4 bytes to represent, and the logic length can be obtained by calculating the next Entry; for a 256 MiB-sized zone (the data in the zone is aligned according to the data unit of 4 KiB, that is, 256 MiB / 4096 == 65536 data units), the zone offset is represented in units of data units, and in the extreme scenario, 2 bytes are needed to represent it; the zone length can be obtained by converting the logic length according to the set byte alignment. If each Entry is represented by a fixed-size byte, 6 bytes are needed, occupying 48 bits. In this metadata management mode that records the global logical address offset (logic offset) and the global physical address offset (zone offset) of the data, the amount of metadata is large and occupies more storage space.
[0033] It should be noted that chunk only supports sequential writing, and the number of simultaneously open zones in SMR disks is limited. The data of a chunk is first written to fill one zone and then to the next zone. Therefore, the data contained in one zone is always continuous at the chunk logical level. Moreover, for local I / O of a chunk, there are always some correlations. If 6 bytes are always used for representation, it will result in a large consumption of memory space.
[0034] To solve the above technical problems, the embodiments of the present disclosure provide a metadata mapping method. In the metadata, the global logical address offset and the global physical address offset are not used. Instead, by determining the starting logical address of the target data in the target logical data block and the starting physical address in the target disk partition, and determining an appropriate bit length to record the relative logical address offset relative to the starting logical address and the relative physical address offset relative to the starting physical address, compared with directly recording the global logical address offset and the global physical address offset, the size of the memory occupied by the metadata can be reduced, saving the memory space for storing the metadata.
[0035] The metadata mapping method of the present disclosure will be introduced in detail below with specific embodiments.
[0036] Refer to Figure 2 , Figure 2 which is a schematic flowchart of the metadata mapping method provided by an embodiment of the present disclosure. The method of this embodiment can be applied to electronic devices such as terminal devices or servers. The metadata mapping method includes:
[0037] S201. When multiple target data are continuously written to a target disk partition in a target logical data block, obtain the starting logical address of the multiple target data in the target logical data block and the starting physical address of the multiple target data in the target disk partition.
[0038] In this embodiment, for the data in a certain target logical data block (chunk), it may be stored in one or more target disk partitions (zones). One target disk partition may also store the data in one or more logical data blocks. For disks with a shingled magnetic recording (SMR) layout, only sequential writing and random reading are supported. Therefore, when multiple consecutive target data in a certain target logical data block (chunk) are sequentially written to a certain target disk partition, the logical offsets of the metadata of the multiple target data are continuous.
[0039] On this basis, when multiple target data are continuously written into the target disk partition in the target logical data block, the starting logical address of the multiple target data in the target logical data block and the starting physical address of the multiple target data in the target disk partition can be obtained. Furthermore, based on the continuity of the metadata of the multiple target data, the relative logical address offset relative to the starting logical address can be recorded based on the starting logical address, and the relative physical address offset relative to the starting physical address can be recorded based on the starting physical address. Furthermore, by combining the starting logical address and the relative logical address offset, the global logical address offset can also be determined, and by combining the starting physical address and the relative physical address offset, the global physical address offset can also be determined. In this embodiment, considering that the lengths of the global logical address offset and the global physical address offset are relatively long, and their lengths are related to the sizes of the target logical data block and the target disk partition. If the global logical address and the global physical address are recorded for each target data, the memory occupied is relatively large, while the lengths of the relative logical address offset and the relative physical address offset can be shorter than those of the global logical address offset and the global physical address offset, thereby saving the memory space occupied by the metadata.
[0040] S202. Determine a first bit length of the relative logical address offset of the multiple target data relative to the starting logical address and a second bit length of the relative physical address offset of the multiple target data relative to the starting physical address.
[0041] In this embodiment, since the lengths of the relative logical address offset and the relative physical address offset can be shorter than those of the global logical address offset and the global physical address offset, and they are related to the maximum relative offset of the multiple target data in the target logical data block and the target disk partition. For example, the total length of the multiple target data in the target logical data block is 64 MiB, and the relative offset starts from 0, and the maximum relative offset is 64 MiB - 1. Each relative logical address offset can be represented by 26 bit lengths, which is shorter than using the global logical address offset. Of course, the relative logical address offset can also be represented by more than 26 bit lengths (with the high bits being 0). Since the minimum storage unit in the target disk partition is 4 KiB, the relative physical address offset needs to be divided by 4 KiB to obtain the number of the required minimum storage units, and then the actual bit length is obtained based on the number of the required minimum storage units. By determining the first bit length of the relative logical address offset and the second bit length of the relative physical address offset, the relative logical address offset of each target data in the multiple target data can be recorded using the first bit length, and the relative physical address offset of each target data in the multiple target data can be recorded using the second bit length, thus saving the memory space of the metadata.
[0042] Of course, in the above example, if the relative offset of 64 MiB - 1 is represented by more than 26 bit lengths (with the high bits being 0), although it can be represented, it will cause waste of some bits and waste of memory space. Therefore, in this embodiment, the smallest first bit length that can represent the relative logical address offset and the smallest second bit length that can represent the relative physical address offset can be selected. Of course, those that are not the smallest are also acceptable.
[0043] S203. For each of the multiple target data, obtain the relative logical address offset of the corresponding first bit length and the relative physical address offset of the second bit length.
[0044] In this embodiment, after determining the starting logical address of the multiple target data in the target logical data block, the starting physical address of the multiple target data in the target disk partition, and determining the first bit length of the relative logical address offset and the second bit length of the relative physical address offset, for each target data, the relative logical address offset relative to the starting logical address can be obtained and represented by the first bit length to obtain the relative logical address offset of the first bit length. For each target data, the relative physical address offset relative to the starting physical address can be obtained and represented by the second bit length to obtain the relative physical address offset of the second bit length.
[0045] S204. According to the starting logical address, the starting physical address, the first bit length, the second bit length, and the relative logical address offset and relative physical address offset of the multiple target data, construct the metadata of the multiple target data, where the metadata is used to determine the mapping relationship between the logical address and the physical address of the multiple target data.
[0046] In this embodiment, based on the starting logical address, the starting physical address, the first bit length, the second bit length, and the relative logical address offset and relative physical address offset of the multiple target data, the global logical address offset and the global physical address offset of the multiple target data can be determined. Therefore, the above information can be used as the metadata of the multiple target data to determine the mapping relationship between the logical address and the physical address of the multiple target data.
[0047] Optionally, in this embodiment, a preset data structure can be used to store the metadata of the multiple target data, such as Figure 3As shown, since multiple target data share a starting logical address, a starting physical address, a first bit length, and a second bit length, the starting logical address, the starting physical address, the first bit length, and the second bit length are determined as the header information (Header) of the preset data structure; and the relative logical address offsets and relative physical address offsets of the multiple target data are used as the entry list (EntryList) in the preset data structure, and the relative logical address offset and relative physical address offset of each target data are used as an entry. In this way, when it is necessary to determine the global logical address offset and the global physical address offset of a certain target data among the multiple target data, the starting logical address, the starting physical address, the first bit length, and the second bit length can be read from the header information, and the corresponding relative logical address offset and relative physical address offset can be read from the entry list, so that the global logical address offset and the global physical address offset can be finally determined.
[0048] Optionally, in the metadata of the preset data structure, the header information and the entry list can be stored together in the memory, or they can be stored separately. For example, the header information of the preset data structure is stored in the first memory area; the entry list of the preset data structure is stored in the second memory area, and the starting memory address of the entry list of the preset data structure in the second memory area is added to the header information of the preset data structure. When reading the metadata, the reading starting logical address, starting physical address, first bit length and second bit length can be obtained from the header information. Based on the starting memory address in the header information, the corresponding relative logical address offset and relative physical address offset can be read from the entry list in the second memory area, so that the memory space can be reasonably utilized.
[0049] In addition, to facilitate storage and subsequent reading and calculation, if the memory occupied by the entries of the preset data structure is less than a preset number of bytes, such as 8 bytes, byte padding is performed to fill the memory occupied by the entries of the preset data structure to the preset number of bytes.
[0050] Of course, the present embodiment is not limited to using the above data structure to store metadata of multiple target data, and other feasible methods may be used for storage, which is not limited in the present embodiment.
[0051] The metadata mapping method provided in this embodiment obtains the starting logical address of multiple target data in the target logical data block and the starting physical address of the multiple target data in the target disk partition when the multiple target data are continuously written into the target disk partition; determines the first bit length of the relative logical address offset of the multiple target data relative to the starting logical address and the second bit length of the relative physical address offset relative to the starting physical address; obtains the relative logical address offset of the corresponding first bit length and the relative physical address offset of the second bit length for the multiple target data respectively; constructs the metadata of the multiple target data according to the starting logical address, the starting physical address, the first bit length, the second bit length, and the relative logical address offset and relative physical address offset of the multiple target data, where the metadata is used to determine the mapping relationship between the logical address and the physical address of the multiple target data. In this embodiment, by determining the starting logical address of the target data in the target logical data block and the starting physical address in the target disk partition, and determining the appropriate bit length to record the relative logical address offset of the target data relative to the starting logical address and the relative physical address offset relative to the starting physical address, compared with directly recording the global logical address offset and the global physical address offset, the size of the metadata occupied in memory can be reduced, and the memory space for storing the metadata can be saved.
[0052] The technical effects of this embodiment will be illustrated by the following example: Assume that zone1 contains 128 entries of chunk1, and the size of each entry is assumed to be 64 KiB. Then the total data size of chunk1 contained in zone1 is: logic_size = 64 KiB * 128 = 8 MB. Assume that the physical space spanned by this 8 MB of data is 16 MB. If the traditional metadata format with a fixed size of 6 bytes (4 bytes for the logical address offset and 2 bytes for the physical address offset) is used, a total of 6 * 128 = 768 bytes are required.
[0053] If the metadata format of this embodiment is used, the relative logical address offset of 8 MiB in the target logical data block requires at most 23 bits to represent, corresponding to 16 MiB in the target disk partition. Since the minimum storage unit in the target disk partition is usually 4 KiB, 16 MiB corresponds to 4096 minimum storage units, and the maximum relative physical address offset requires at most 12 bits to represent. Therefore, each entry only needs 23 + 12 = 35 bits to represent. Because the maximum size of a chunk within a zone is 256 MiB, and the maximum relative logical offset is 256 MiB - 1, a bit size (logic_bits_count) of 28 bits can represent the maximum relative logical address offset; the maximum space of a zone is 256 MiB, which is 64 * 1024 storage units, and a second bit length (physical_bits_count) of 16 bits can represent the maximum relative physical address offset. At most two bytes are required to store the information of the two bit lengths. logic_start_offset uses 4 bytes, physic_start_offset uses 2 bytes, and total_logic_size also uses 4 bytes. Considering 4-byte alignment, physic_start_offset uses 4 bytes, and the memory space for storing the size of the two bit lengths uses 4 bytes, so 16 bytes are required. Therefore, the total space used by the metadata format of this embodiment is: (35 * 128) / 8 + 16 = 576 bytes. Compared with the previous 768 bytes, 25% of the space is saved.
[0054] The above example is just an example to prove the benefits of this embodiment. Under a single-machine storage engine similar to Chunkserver, using a dynamic metadata format scheme to establish the mapping between the logical position and the physical position of the data block can also achieve the purpose of reducing the metadata size and saving memory space.
[0055] Based on any of the above embodiments, determining the first bit length of the relative logical address offset of the multiple target data with respect to the starting logical address and the second bit length of the relative physical address offset with respect to the starting physical address in S202 includes:
[0056] Determining the minimum bit length capable of representing the relative logical address offset of the multiple target data according to the maximum relative offset of the multiple target data in the target logical data block, and using it as the first bit length;
[0057] Determining the minimum bit length capable of representing the relative physical address offset of the multiple target data according to the maximum relative offset of the multiple target data in the target disk partition, and using it as the second bit length.
[0058] In this embodiment, in order to minimize the memory space occupied by the relative logical address offsets and relative physical address offsets of multiple target data, the minimum first bit length of the relative logical address offsets and the minimum second bit length of the relative physical address offsets of the multiple target data can be determined.
[0059] Specifically, first, determine the maximum relative offset of multiple target data in the target logical data block. The number of right shifts can be determined by right shifting (i.e., dividing by 2), and the cumulative number of right shifts when it is shifted to 0 is determined as the minimum first bit length. For example, assume that the maximum relative offset of multiple target data in the target logical data block is 8 MiB (the offset starts from 0). For the first right shift, that is, the maximum relative offset divided by 2 becomes 4 MiB, and the cumulative number of right shifts is 1. For the second right shift, the maximum relative offset divided by 2 becomes 2 MiB, and the cumulative number of right shifts is 2. For the third right shift, the maximum relative offset divided by 2 becomes 1 MiB, and the cumulative number of right shifts is 3. For the fourth right shift, the maximum relative offset becomes 512 * 1024 B, and the cumulative number of right shifts is 4, and so on. That is, the minimum first bit length of the relative logical address offsets of multiple target data with a maximum relative offset of 8 MiB is 24 bits.
[0060] Similarly, for the minimum second bit length, first, determine the maximum relative offset of multiple target data in the target disk partition. The number of right shifts can be determined by right shifting, and the cumulative number of right shifts when it is shifted to 0 is determined as the minimum second bit length. For example, assume that the maximum relative offset of multiple target data in the target disk partition is 8 MiB. Since the minimum physical storage unit is 4 KiB, first calculate the number of minimum storage units as 2 KiB. For the first right shift, that is, the maximum relative offset divided by 2 becomes 1 KiB, and the cumulative number of right shifts is 1. For the second right shift, the maximum relative offset divided by 2 becomes 512, and the cumulative number of right shifts is 2. For the third right shift, the maximum relative offset divided by 2 becomes 256, and the cumulative number of right shifts is 3. For the fourth right shift, the maximum relative offset becomes 128, and the cumulative number of right shifts is 4, and so on. That is, the minimum second bit length of the relative physical address offsets of multiple target data with a maximum relative offset of 8 MiB is 12 bits.
[0061] Of course, the minimum first bit length and the minimum second bit length can also be determined by other methods, as long as the lengths can represent all the relative logical address offsets and relative physical address offsets.
[0062] Based on any of the above embodiments, as Figure 4 shown, after completing the construction of the metadata of multiple target data, if it is necessary to determine the global logical address offset and global physical address offset of a certain data to be read among the multiple target data, the following process can be implemented:
[0063] S401. Determine the order of the data to be read among the multiple target data;
[0064] S402. Obtain the relative logical address offset and relative physical address offset of the data to be read from the metadata according to the order, the first bit length, and the second bit length;
[0065] S403. Determine the global logical address offset of the data to be read according to the starting logical address and the relative logical address offset of the data to be read;
[0066] S404. Determine the global physical address offset of the data to be read according to the starting physical address and the relative physical address offset of the data to be read.
[0067] In this embodiment, first, determine the order (denoted as idx) of the data to be read among the multiple target data, that is, which target data the data to be read is among the multiple target data. Then, according to the order, the first bit length, and the second bit length, obtain the relative logical address offset and relative physical address offset of the data to be read from the metadata. That is, the relative logical address offset and relative physical address offset of each target data are respectively the first bit length and the second bit length. Given the order of the data to be read among the multiple target data, the relative logical address offset and relative physical address offset of the target data before the data to be read can be skipped, and the relative logical address offset and relative physical address offset of the data to be read can be read.
[0068] Further, based on the starting logical address and combined with the relative logical address offset of the data to be read, determine the global logical address offset of the data to be read. Specifically, given the starting logical address, the global logical address offset corresponding to the starting logical address can be determined. On the basis of the global logical address offset, add the relative logical address offset of the data to be read to obtain the global logical address offset of the data to be read.
[0069] Similarly, based on the starting physical address and combined with the relative physical address offset of the data to be read, determine the global physical address offset of the data to be read. Specifically, given the starting physical address, the global physical address offset corresponding to the starting physical address can be determined. On the basis of the global physical address offset, add the relative physical address offset of the data to be read to obtain the global physical address offset of the data to be read.
[0070] Based on the above embodiments, when obtaining the relative logical address offset and relative physical address offset of the data to be read from the metadata according to the order, the first bit length, and the second bit length, it may specifically include:
[0071] According to the order, the first bit length, and the second bit length, determine the starting byte of the starting position of the relative logical address offset and relative physical address offset of the data to be read in the entry list, and the starting bit position in the starting byte;
[0072] Obtain entry data of a preset number of bytes starting from the starting byte in the entry list, and obtain the relative logical address offset and relative physical address offset of the data to be read from the entry data of the preset number of bytes according to the first bit length, the second bit length, and the starting bit position.
[0073] In this embodiment, considering that each entry in the entry list is continuously stored in memory, and electronic devices such as computers usually cannot read data bit by bit from memory, but usually read data in units of bytes. For example, in this embodiment, it is also necessary to read the relative logical address offset and relative physical address offset of the data to be read in units of bytes. However, the relative logical address offset and relative physical address offset of the data to be read may not exactly occupy an integer number of bytes. It is necessary to determine the starting byte of the starting position of the relative logical address offset and relative physical address offset of the data to be read in the entry list according to the order, the first bit length, and the second bit length, and the starting bit position in the starting byte, that is, to determine from which byte the relative logical address offset and relative physical address offset of the data to be read start, and from which bit position in that byte they start. Furthermore, it is possible to obtain entry data of a preset number of bytes starting from the starting byte in the entry list in units of bytes, and then obtain the relative logical address offset of the first bit length and the relative physical address offset of the second bit length from the entry data of the preset number of bytes according to the first bit length, the second bit length, and the starting bit position, that is, the relative logical address offset and relative physical address offset of the data to be read.
[0074] Among them, the calculation process can be as follows:
[0075] First, determine the starting bit position bits_count in the entry list of the relative logical address offset and relative physical address offset of the data to be read:
[0076] bits_count = idx × (the first bit length + the second bit length);
[0077] Determine again the starting byte byte_offset in the entry list of the starting positions of the relative logical address offset and the relative physical address offset of the data to be read, and the starting bit position traling_bits_count in the starting byte:
[0078] byte_offset = bits_count / 8
[0079] traling_bits_count = bits_count % 8
[0080] Optionally, after obtaining the entry data of the preset number of bytes, the relative logical address offset and the relative physical address offset of the data to be read can be obtained through logical operations. The specific process is as follows:
[0081] Right-shift the entry data of the preset number of bytes to obtain the second entry data, so that the relative logical address offset of the data to be read starts from the lowest bit of the second entry data;
[0082] Construct a first data of the preset number of bytes according to the first bit length. The bit value corresponding to the relative logical address offset of the data to be read in the first data is 1, and the values of the remaining bits are 0; perform an AND operation on the second entry data and the first data to obtain the relative logical address offset of the data to be read;
[0083] Right-shift the second entry data to obtain the third entry data, so that the relative physical address offset of the data to be read starts from the lowest bit of the third entry data; construct a second data of the preset number of bytes according to the second bit length. The bit value corresponding to the relative physical address offset of the data to be read in the second data is 1, and the values of the remaining bits are 0; perform an AND operation on the third entry data and the second data to obtain the relative physical address offset of the data to be read.
[0084] In this embodiment, since in the entry data of the preset number of bytes, the relative logical address offset and the relative physical address offset of the data to be read start from the starting bit position traling_bits_count of the first byte, the entry data of the preset number of bytes can be right-shifted by a number of bits equal to traling_bits_count, so that the relative logical address offset of the data to be read starts from the lowest bit of the second entry data.
[0085] For example, the entry data before right-shifting is as follows:
[0086]
[0087] The second entry data is obtained by shifting to the right, as shown below:
[0088]
[0089] Furthermore, a first data with a preset number of bytes can be constructed according to the first bit length. The bit value corresponding to the relative logical address offset of the data to be read in the first data is 1, and the values of the remaining bits are 0. For example, the first data can be constructed as shown below:
[0090] … 0 0 0 … 0 0 0 1 1 1 … 1 1 1
[0091] The second entry data after shifting to the right is AND-operated with the second data to obtain the relative logical address offset of the data to be read, as shown below:
[0092] … 0 0 0 … 0 0 0 1 1 0 … 0 1 0
[0093] Among them, the construction method of the first data can be: the data obtained by shifting 1 to the left by the first bit length minus 1.
[0094] Furthermore, the second entry data can be further shifted to the right to obtain the third entry data, so that the relative physical address offset of the data to be read starts from the lowest bit of the third entry data. For example, the second entry data is shifted to the right to obtain the third entry data as follows:
[0095]
[0096] A second data with a preset number of bytes can be constructed according to the second bit length. The bit value corresponding to the relative physical address offset of the data to be read in the second data is 1, and the values of the remaining bits are 0; the second data can be as shown below:
[0097] 0 0 0 0 … 0 0 0 1 1 1 … 1 1 1
[0098] The third entry data after shifting to the right is AND-operated with the second data to obtain the relative physical address offset of the data to be read, as shown below:
[0099] 0 0 0 0 … 0 0 0 1 0 1 … 1 1 0
[0100] Among them, the construction method of the second data can be: the data obtained by shifting 1 to the left by the second bit length minus 1.
[0101] Of course, other methods can also be used to obtain the relative logical address offset and relative physical address offset of the data to be read from the entry data with a preset number of bytes according to the first bit length, the second bit length, and the starting bit. This is not limited here.
[0102] Based on the above embodiments, since the global logical address offset of the data to be read can be determined, the global logical address offset of the data after the data to be read can also be determined. Furthermore, based on the global logical address offset of the data to be read and the global logical address offset of the data after the data to be read, the length of the data to be read in the target logical data block can be determined, that is, the difference between the global logical address offset of the data after the data to be read and the global logical address offset of the data to be read;
[0103] Furthermore, based on the length of the data to be read in the target logical data block, the length of the data to be read in the target disk partition can be determined. Specifically, the target disk partition stores data in the smallest storage unit of a fixed size, such as 4 KiB. Therefore, the length of the data to be read in the target disk partition (i.e., the physical length) is an integer multiple of the smallest storage unit. Specifically, it is the integer multiple of the smallest storage unit obtained by rounding up the length of the data to be read in the target logical data block (i.e., the logical length) to the nearest integer multiple of the smallest storage unit. Taking the smallest storage unit as 4 KiB as an example, the physical length of the data to be read = Align(logical length, 4 KiB), that is, the logical length is rounded up to the nearest multiple of 4 KiB through memory alignment operations.
[0104] Furthermore, the obtained global logical address offset of the data to be read, the length of the data to be read in the target logical data block, the global physical address offset of the data to be read, and the length of the data to be read in the target disk partition can be used as the complete metadata of the data to be read.
[0105] Corresponding to the metadata mapping method in the above embodiments, Figure 5 This is a structural block diagram of the metadata mapping device provided by the embodiments of the present disclosure. For ease of explanation, only parts related to the embodiments of the present disclosure are shown. Referring to Figure 5 , the metadata mapping device 500 includes: a start address determination unit 501, a bit length determination unit 502, a relative offset determination unit 503, and a construction unit 504.
[0106] Among them, the start address determination unit 501 is configured to obtain the start logical address of the multiple target data in the target logical data block and the start physical address of the multiple target data in the target disk partition when the multiple target data are continuously written into the target disk partition;
[0107] The bit length determination unit 502 is configured to determine the first bit length of the relative logical address offset of the multiple target data relative to the start logical address and the second bit length of the relative physical address offset of the multiple target data relative to the start physical address;
[0108] A relative offset determination unit 503 is configured to respectively obtain a relative logical address offset of a first bit length and a relative physical address offset of a second bit length corresponding to the multiple target data;
[0109] A construction unit 504 is configured to construct metadata of the multiple target data according to the starting logical address, the starting physical address, the first bit length, the second bit length, and the relative logical address offset and relative physical address offset of the multiple target data, where the metadata is used to determine a mapping relationship between the logical address and the physical address of the multiple target data.
[0110] In one or more embodiments of the present disclosure, when determining the first bit length of the relative logical address offset of the multiple target data relative to the starting logical address and the second bit length of the relative physical address offset relative to the starting physical address, the bit length determination unit 502 is configured to:
[0111] According to the maximum relative offset of the multiple target data in the target logical data block, determine the minimum bit length capable of representing the relative logical address offset of the multiple target data as the first bit length;
[0112] According to the maximum relative offset of the multiple target data in the target disk partition, determine the minimum bit length capable of representing the relative physical address offset of the multiple target data as the second bit length.
[0113] In one or more embodiments of the present disclosure, when constructing metadata of the multiple target data according to the starting logical address, the starting physical address, the first bit length, the second bit length, and the relative logical address offset and relative physical address offset of the multiple target data, the construction unit 504 is configured to:
[0114] Construct metadata of a preset data structure for the multiple target data, where the starting logical address, the starting physical address, the first bit length, and the second bit length are determined as the header information of the preset data structure; and the relative logical address offset and relative physical address offset of the multiple target data are used as an entry list in the preset data structure.
[0115] In one or more embodiments of the present disclosure, when constructing metadata of a preset data structure for the multiple target data, the construction unit 504 is further configured to:
[0116] Store the header information of the preset data structure in a first memory area;
[0117] Store the entry list of the preset data structure in the second memory area, and add the starting memory address of the entry list of the preset data structure in the second memory area to the header information of the preset data structure.
[0118] In one or more embodiments of the present disclosure, when storing the entries of the preset data structure in the second memory area, the building unit 504 is further configured to:
[0119] If the memory occupied by the entry of the preset data structure is less than the preset number of bytes, perform byte filling to make the memory occupied by the entry of the preset data structure reach the preset number of bytes.
[0120] In one or more embodiments of the present disclosure, the device further includes a reading unit, configured to:
[0121] Determine the order of the data to be read among the multiple target data;
[0122] According to the order, the first bit length, and the second bit length, obtain the relative logical address offset and the relative physical address offset of the data to be read from the metadata;
[0123] According to the starting logical address and the relative logical address offset of the data to be read, determine the global logical address offset of the data to be read;
[0124] According to the starting physical address and the relative physical address offset of the data to be read, determine the global physical address offset of the data to be read.
[0125] In one or more embodiments of the present disclosure, when obtaining the relative logical address offset and the relative physical address offset of the data to be read from the metadata according to the order, the first bit length, and the second bit length, the reading unit is configured to:
[0126] According to the order, the first bit length, and the second bit length, determine the starting byte of the starting position of the relative logical address offset and the relative physical address offset of the data to be read in the entry list, and the starting bit position in the starting byte;
[0127] Obtain the entry data of the preset number of bytes starting from the starting byte in the entry list, and obtain the relative logical address offset and the relative physical address offset of the data to be read from the entry data of the preset number of bytes according to the first bit length, the second bit length, and the starting bit position.
[0128] In one or more embodiments of the present disclosure, when obtaining the relative logical address offset and relative physical address offset of the data to be read from the entry data of the preset number of bytes according to the first bit length, the second bit length, and the starting bit position, the reading unit is configured to:
[0129] Right-shift the entry data of the preset number of bytes to obtain second entry data, such that the relative logical address offset of the data to be read starts from the lowest bit of the second entry data;
[0130] Construct a first data of the preset number of bytes according to the first bit length, where the bit value corresponding to the relative logical address offset of the data to be read in the first data is 1, and the bit values of the remaining bits are 0; perform an AND operation on the second entry data and the first data to obtain the relative logical address offset of the data to be read;
[0131] Right-shift the second entry data to obtain third entry data, such that the relative physical address offset of the data to be read starts from the lowest bit of the third entry data; construct a second data of the preset number of bytes according to the second bit length, where the bit value corresponding to the relative physical address offset of the data to be read in the second data is 1, and the bit values of the remaining bits are 0; perform an AND operation on the third entry data and the second data to obtain the relative physical address offset of the data to be read.
[0132] In one or more embodiments of the present disclosure, the reading unit is further configured to:
[0133] Determine the length of the data to be read in the target logical data block according to the global logical address offset of the data to be read and the global logical address offset of the data after the data to be read;
[0134] Determine the length of the data to be read in the target disk partition according to the length of the data to be read in the target logical data block.
[0135] The device provided in this embodiment can be used to execute the technical solutions of the above method embodiments, and its implementation principle and technical effects are similar, which will not be elaborated here in this embodiment.
[0136] To implement the above embodiments, the embodiments of the present disclosure further provide an electronic device.
[0137] Reference Figure 6, which shows a schematic structural diagram of an electronic device 600 for implementing embodiments of the present disclosure. The electronic device 600 can be a terminal device or a server. Among them, the terminal device can include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, personal digital assistants (PDAs), tablet computers, portable media players (PMPs), in-vehicle terminals (such as in-vehicle navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 6 The electronic device shown is merely an example and should not impose any limitations on the functions and usage scope of the embodiments of the present disclosure.
[0138] As Figure 6 shown, the electronic device 600 may include a processing device (such as a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 602 or the program loaded from the storage device 608 into the random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. The input / output (I / O) interface 605 is also connected to the bus 604.
[0139] Generally, the following devices can be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 can allow the electronic device 600 to communicate with other devices wirelessly or wiredly to exchange data. Although Figure 6 the electronic device 600 with various devices is shown, it should be understood that it is not required to implement or have all the shown devices. More or fewer devices can be alternatively implemented or had.
[0140] In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, an embodiment of the present disclosure includes a computer program product that includes a computer program carried on a computer-readable medium, and the computer program includes program code for performing the methods shown in the flowcharts. In such an embodiment, the computer program can be downloaded and installed from a network via a communication device 609, or installed from a storage device 608, or installed from a ROM 602. When the computer program is executed by a processing device 601, the above functions defined in the methods of the embodiments of the present disclosure are performed. The implementation principles and technical effects are similar, and will not be elaborated herein.
[0141] It should be noted that the above computer-readable medium in the present disclosure can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, the computer-readable storage medium can be any tangible medium that contains or stores a program, and the program can be used by or in combination with an instruction execution system, apparatus, or device. In the present disclosure, the computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, in which computer-readable program code is carried. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium can also be any computer-readable medium other than the computer-readable storage medium, and the computer-readable signal medium can send, propagate, or transmit a program for use by or in combination with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted by any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0142] The above computer-readable medium can be included in the above electronic device; or it can exist separately without being assembled into the electronic device.
[0143] The above computer-readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to perform the methods shown in the above embodiments. The implementation principles and technical effects are similar, and will not be elaborated here in this embodiment.
[0144] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or combinations thereof. The programming languages include object-oriented programming languages such as Java, Smalltalk, C++, and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, executed as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (for example, by connecting through an Internet service provider using the Internet).
[0145] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code that contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and the combinations of blocks in the block diagram and / or flowchart, may be implemented by a dedicated hardware-based system for performing the specified functions or operations, or may be implemented by a combination of dedicated hardware and computer instructions.
[0146] The units involved in the embodiments described in the present disclosure may be implemented in software or in hardware. Among them, the name of the unit does not constitute a limitation to the unit itself in some cases. For example, the first acquisition unit may also be described as "the unit for acquiring at least two Internet protocol addresses".
[0147] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that can be used include: Field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), Systems on Chip (SOCs), Complex Programmable Logic Devices (CPLDs), and so on.
[0148] In a first aspect, according to one or more embodiments of the present disclosure, there is provided a metadata mapping method, including:
[0149] When multiple target data are continuously written into a target disk partition in a target logical data block, obtain the starting logical address of the multiple target data in the target logical data block, and the starting physical address of the multiple target data in the target disk partition;
[0150] Determine a first bit length of the relative logical address offset of the multiple target data relative to the starting logical address and a second bit length of the relative physical address offset relative to the starting physical address;
[0151] For each of the multiple target data, obtain a corresponding relative logical address offset of the first bit length and a relative physical address offset of the second bit length;
[0152] According to the starting logical address, the starting physical address, the first bit length, the second bit length, and the relative logical address offsets and relative physical address offsets of the multiple target data, construct metadata for the multiple target data, where the metadata is used to determine the mapping relationship between the logical addresses and physical addresses of the multiple target data.
[0153] According to one or more embodiments of the present disclosure, the determining the first bit length of the relative logical address offset of the multiple target data relative to the starting logical address and the second bit length of the relative physical address offset relative to the starting physical address includes:
[0154] According to the maximum relative offset of the multiple target data in the target logical data block, determine the minimum bit length capable of representing the relative logical address offset of the multiple target data as the first bit length;
[0155] According to the maximum relative offset of the multiple target data in the target disk partition, determine the minimum bit length capable of representing the relative physical address offset of the multiple target data as the second bit length.
[0156] According to one or more embodiments of the present disclosure, constructing metadata of the multiple target data according to the starting logical address, the starting physical address, the first bit length, the second bit length, and the relative logical address offset and relative physical address offset of the multiple target data includes:
[0157] Constructing metadata of a preset data structure for the multiple target data, wherein the starting logical address, the starting physical address, the first bit length, and the second bit length are determined as the header information of the preset data structure; and the relative logical address offset and relative physical address offset of the multiple target data are used as an entry list in the preset data structure.
[0158] According to one or more embodiments of the present disclosure, constructing metadata of a preset data structure for the multiple target data further includes:
[0159] Storing the header information of the preset data structure in a first memory area;
[0160] Storing the entry list of the preset data structure in a second memory area, and adding the starting memory address of the entry list of the preset data structure in the second memory area to the header information of the preset data structure.
[0161] According to one or more embodiments of the present disclosure, storing the entries of the preset data structure in the second memory area further includes:
[0162] If the memory occupied by the entries of the preset data structure is less than a preset number of bytes, byte padding is performed to make the memory occupied by the entries of the preset data structure reach the preset number of bytes.
[0163] According to one or more embodiments of the present disclosure, after constructing the metadata of the multiple target data, it further includes:
[0164] Determining the order of the data to be read among the multiple target data;
[0165] Obtaining the relative logical address offset and relative physical address offset of the data to be read from the metadata according to the order, the first bit length, and the second bit length;
[0166] Determining the global logical address offset of the data to be read according to the starting logical address and the relative logical address offset of the data to be read;
[0167] Determining the global physical address offset of the data to be read according to the starting physical address and the relative physical address offset of the data to be read.
[0168] According to one or more embodiments of the present disclosure, obtaining the relative logical address offset and the relative physical address offset of the data to be read from the metadata according to the order, the first bit length, and the second bit length includes:
[0169] Determine the starting byte of the starting position of the relative logical address offset and the relative physical address offset of the data to be read in the entry list according to the order, the first bit length, and the second bit length, and the starting bit position in the starting byte;
[0170] Obtain entry data of a preset number of bytes starting from the starting byte in the entry list, and obtain the relative logical address offset and the relative physical address offset of the data to be read from the entry data of the preset number of bytes according to the first bit length, the second bit length, and the starting bit position.
[0171] According to one or more embodiments of the present disclosure, obtaining the relative logical address offset and the relative physical address offset of the data to be read from the entry data of the preset number of bytes according to the first bit length, the second bit length, and the starting bit position includes:
[0172] Right-shift the entry data of the preset number of bytes to obtain second entry data, such that the relative logical address offset of the data to be read starts from the least significant bit of the second entry data;
[0173] Construct a first data of the preset number of bytes according to the first bit length, where the bit value corresponding to the relative logical address offset of the data to be read is 1 and the values of the remaining bits are 0; perform an AND operation on the second entry data and the first data to obtain the relative logical address offset of the data to be read;
[0174] Right-shift the second entry data to obtain third entry data, such that the relative physical address offset of the data to be read starts from the least significant bit of the third entry data; construct a second data of the preset number of bytes according to the second bit length, where the bit value corresponding to the relative physical address offset of the data to be read is 1 and the values of the remaining bits are 0; perform an AND operation on the third entry data and the second data to obtain the relative physical address offset of the data to be read.
[0175] According to one or more embodiments of the present disclosure, the method further includes:
[0176] Determine the length of the data to be read in the target logical data block according to the global logical address offset of the data to be read and the global logical address offset of the data after the data to be read.
[0177] Determine the length of the data to be read in the target disk partition according to the length of the data to be read in the target logical data block.
[0178] In a second aspect, according to one or more embodiments of the present disclosure, there is provided a metadata mapping device, including:
[0179] A starting address determination unit, configured to obtain the starting logical address of the multiple target data in the target logical data block and the starting physical address of the multiple target data in the target disk partition when the multiple target data are continuously written into the target disk partition in the target logical data block;
[0180] A bit length determination unit, configured to determine a first bit length of the relative logical address offset of the multiple target data relative to the starting logical address and a second bit length of the relative physical address offset of the multiple target data relative to the starting physical address;
[0181] A relative offset determination unit, configured to respectively obtain a relative logical address offset of the corresponding first bit length and a relative physical address offset of the second bit length for the multiple target data;
[0182] A construction unit, configured to construct metadata of the multiple target data according to the starting logical address, the starting physical address, the first bit length, the second bit length, and the relative logical address offset and relative physical address offset of the multiple target data, where the metadata is used to determine the mapping relationship between the logical address and the physical address of the multiple target data.
[0183] According to one or more embodiments of the present disclosure, when determining the first bit length of the relative logical address offset of the multiple target data relative to the starting logical address and the second bit length of the relative physical address offset of the multiple target data relative to the starting physical address, the bit length determination unit is configured to:
[0184] Determine the minimum bit length capable of representing the relative logical address offset of the multiple target data according to the maximum relative offset of the multiple target data in the target logical data block, and use it as the first bit length;
[0185] Determine the minimum bit length capable of representing the relative physical address offset of the multiple target data according to the maximum relative offset of the multiple target data in the target disk partition, and use it as the second bit length.
[0186] According to one or more embodiments of the present disclosure, when constructing metadata of the multiple target data according to the starting logical address, the starting physical address, the first bit length, the second bit length, and the relative logical address offset and relative physical address offset of the multiple target data, the constructing unit is configured to:
[0187] Construct metadata of a preset data structure for the multiple target data, where the starting logical address, the starting physical address, the first bit length, and the second bit length are determined as the header information of the preset data structure; and the relative logical address offset and relative physical address offset of the multiple target data are used as an entry list in the preset data structure.
[0188] According to one or more embodiments of the present disclosure, when constructing metadata of a preset data structure for the multiple target data, the constructing unit is further configured to:
[0189] Store the header information of the preset data structure in a first memory area;
[0190] Store the entry list of the preset data structure in a second memory area, and add the starting memory address of the entry list of the preset data structure in the second memory area to the header information of the preset data structure.
[0191] According to one or more embodiments of the present disclosure, when storing the entries of the preset data structure in the second memory area, the constructing unit is further configured to:
[0192] If the memory occupied by the entry of the preset data structure is less than the preset number of bytes, perform byte padding to make up the memory occupied by the entry of the preset data structure to the preset number of bytes.
[0193] According to one or more embodiments of the present disclosure, the device further includes a reading unit, configured to:
[0194] Determine the order of the data to be read among the multiple target data;
[0195] Obtain the relative logical address offset and relative physical address offset of the data to be read from the metadata according to the order, the first bit length, and the second bit length;
[0196] Determine the global logical address offset of the data to be read according to the starting logical address and the relative logical address offset of the data to be read;
[0197] Determine the global physical address offset of the data to be read according to the starting physical address and the relative physical address offset of the data to be read.
[0198] According to one or more embodiments of the present disclosure, when obtaining the relative logical address offset and relative physical address offset of the data to be read from the metadata according to the order, the first bit length, and the second bit length, the reading unit is configured to:
[0199] Determine the starting byte of the starting position of the relative logical address offset and relative physical address offset of the data to be read in the entry list according to the order, the first bit length, and the second bit length, and the starting bit position in the starting byte;
[0200] Obtain entry data of a preset number of bytes starting from the starting byte in the entry list, and obtain the relative logical address offset and relative physical address offset of the data to be read from the entry data of the preset number of bytes according to the first bit length, the second bit length, and the starting bit position.
[0201] According to one or more embodiments of the present disclosure, when obtaining the relative logical address offset and relative physical address offset of the data to be read from the entry data of the preset number of bytes according to the first bit length, the second bit length, and the starting bit position, the reading unit is configured to:
[0202] Right-shift the entry data of the preset number of bytes to obtain second entry data, such that the relative logical address offset of the data to be read starts from the lowest bit of the second entry data;
[0203] Construct a first data of the preset number of bytes according to the first bit length, where the bit value corresponding to the relative logical address offset of the data to be read in the first data is 1, and the values of the remaining bits are 0; perform an AND operation on the second entry data and the first data to obtain the relative logical address offset of the data to be read;
[0204] Right-shift the second entry data to obtain third entry data, such that the relative physical address offset of the data to be read starts from the lowest bit of the third entry data; construct a second data of the preset number of bytes according to the second bit length, where the bit value corresponding to the relative physical address offset of the data to be read in the second data is 1, and the values of the remaining bits are 0; perform an AND operation on the third entry data and the second data to obtain the relative physical address offset of the data to be read.
[0205] According to one or more embodiments of the present disclosure, the reading unit is further configured to:
[0206] Determine the length of the data to be read in the target logical data block according to the global logical address offset of the data to be read and the global logical address offset of the data immediately following the data to be read;
[0207] Determine the length of the data to be read in the target disk partition according to the length of the data to be read in the target logical data block.
[0208] In a third aspect, according to one or more embodiments of the present disclosure, there is provided an electronic device, including: at least one processor and a memory;
[0209] The memory stores computer-executable instructions;
[0210] The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor executes the metadata mapping method as described in the first aspect above and various possible designs of the first aspect.
[0211] In a fourth aspect, according to one or more embodiments of the present disclosure, there is provided a computer-readable storage medium, in which computer-executable instructions are stored, and when the processor executes the computer-executable instructions, the metadata mapping method as described in the first aspect above and various possible designs of the first aspect is implemented.
[0212] In a fifth aspect, according to one or more embodiments of the present disclosure, there is provided a computer program product, including a computer program, and when the computer program is executed by a processor, the metadata mapping method as described in the first aspect above and various possible designs of the first aspect is implemented
[0213] The above description is only a preferred embodiment of the present disclosure and an explanation of the applied technical principle. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solution formed by the specific combination of the above technical features, and should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosure concept. For example, a technical solution formed by mutually replacing the above features with technical features having similar functions disclosed in the present disclosure (but not limited to).
[0214] Moreover, although the operations are depicted in a particular order, this should not be construed as requiring that the operations be performed in the particular order shown or in sequential order. In certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although several specific implementation details are included in the foregoing discussion, these should not be construed as limitations on the scope of the present disclosure. Certain features that are described in the context of separate embodiments may also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment may also be implemented separately or in any suitable subcombination in multiple embodiments.
[0215] Although the subject matter has been described in language specific to structural features and / or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely example forms of implementing the claims.
Claims
1. A metadata mapping method, characterized in that, Including: When multiple target data are continuously written to a target disk partition in a target logical data block, obtaining a starting logical address of the multiple target data in the target logical data block and a starting physical address of the multiple target data in the target disk partition; Determining a first bit length of a relative logical address offset of the multiple target data relative to the starting logical address and a second bit length of a relative physical address offset of the multiple target data relative to the starting physical address; Obtaining, for each of the multiple target data, a relative logical address offset of the corresponding first bit length and a relative physical address offset of the second bit length; Constructing metadata of the multiple target data according to the starting logical address, the starting physical address, the first bit length, the second bit length, and the relative logical address offset and relative physical address offset of the multiple target data, where the metadata is used to determine a mapping relationship between the logical address and the physical address of the multiple target data.
2. The method according to claim 1, characterized in that, The determining a first bit length of a relative logical address offset of the multiple target data relative to the starting logical address and a second bit length of a relative physical address offset of the multiple target data relative to the starting physical address includes: Determining, according to a maximum relative offset of the multiple target data in the target logical data block, a minimum bit length capable of representing the relative logical address offset of the multiple target data as the first bit length; Determining, according to a maximum relative offset of the multiple target data in the target disk partition, a minimum bit length capable of representing the relative physical address offset of the multiple target data as the second bit length.
3. The method according to claim 1, characterized in that, The constructing metadata of the multiple target data according to the starting logical address, the starting physical address, the first bit length, the second bit length, and the relative logical address offset and relative physical address offset of the multiple target data includes: Constructing metadata of a preset data structure for the multiple target data, where the starting logical address, the starting physical address, the first bit length, and the second bit length are determined as header information of the preset data structure; and the relative logical address offset and relative physical address offset of the multiple target data are used as an entry list in the preset data structure.
4. The method according to claim 3, wherein The constructing metadata of a preset data structure for the multiple target data further includes: Storing the header information of the preset data structure in a first memory area; Storing the entry list of the preset data structure in a second memory area, and adding a starting memory address of the entry list of the preset data structure in the second memory area to the header information of the preset data structure.
5. The method according to claim 4, wherein The storing the entry of the preset data structure in the second memory area further includes: If the memory occupied by the entry of the preset data structure is less than a preset number of bytes, performing byte padding to make the memory occupied by the entry of the preset data structure reach the preset number of bytes.
6. The method according to claim 3, characterized in that, After constructing the metadata of the multiple target data, further including: Determine the order of the data to be read among the multiple target data; Obtain the relative logical address offset and relative physical address offset of the data to be read from the metadata according to the order, the first bit length, and the second bit length; Determine the global logical address offset of the data to be read according to the starting logical address and the relative logical address offset of the data to be read; Determine the global physical address offset of the data to be read according to the starting physical address and the relative physical address offset of the data to be read.
7. The method according to claim 6, wherein The step of obtaining the relative logical address offset and relative physical address offset of the data to be read from the metadata according to the order, the first bit length, and the second bit length includes: Determine the starting byte of the starting position of the relative logical address offset and relative physical address offset of the data to be read in the entry list according to the order, the first bit length, and the second bit length, and the starting bit position in the starting byte; Obtain entry data of a preset number of bytes starting from the starting byte in the entry list, and obtain the relative logical address offset and relative physical address offset of the data to be read from the entry data of the preset number of bytes according to the first bit length, the second bit length, and the starting bit position.
8. The method according to claim 7, wherein The step of obtaining the relative logical address offset and relative physical address offset of the data to be read from the entry data of the preset number of bytes according to the first bit length, the second bit length, and the starting bit position includes: Right-shift the entry data of the preset number of bytes to obtain second entry data, such that the relative logical address offset of the data to be read starts from the least significant bit of the second entry data; Construct a first data of the preset number of bytes according to the first bit length, where the bit value corresponding to the relative logical address offset of the data to be read in the first data is 1, and the bit values of the remaining bits are 0; perform an AND operation on the second entry data and the first data to obtain the relative logical address offset of the data to be read; Right-shift the second entry data to obtain third entry data, such that the relative physical address offset of the data to be read starts from the least significant bit of the third entry data; construct a second data of the preset number of bytes according to the second bit length, where the bit value corresponding to the relative physical address offset of the data to be read in the second data is 1, and the bit values of the remaining bits are 0; perform an AND operation on the third entry data and the second data to obtain the relative physical address offset of the data to be read.
9. The method according to claim 3, characterized in that The method further includes: Determine the length of the data to be read in the target logical data block according to the global logical address offset of the data to be read and the global logical address offset of the data after the data to be read; Determine the length of the data to be read in the target disk partition according to the length of the data to be read in the target logical data block.
10. A metadata mapping device, characterized in that, including: A starting address determination unit, configured to obtain a starting logical address of the plurality of target data in the target logical data block and a starting physical address of the plurality of target data in the target disk partition when the plurality of target data are continuously written to the target disk partition; A bit length determination unit, configured to determine a first bit length of a relative logical address offset of the plurality of target data relative to the starting logical address and a second bit length of a relative physical address offset of the plurality of target data relative to the starting physical address; A relative offset determination unit, configured to respectively obtain a relative logical address offset with a corresponding first bit length and a relative physical address offset with a second bit length for the plurality of target data; A construction unit, configured to construct metadata of the plurality of target data according to the starting logical address, the starting physical address, the first bit length, the second bit length, and the relative logical address offset and relative physical address offset of the plurality of target data, where the metadata is used to determine a mapping relationship between the logical address and the physical address of the plurality of target data.
11. An electronic device, characterized in that, Comprising: A processor and a memory; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory, so that the processor executes the method according to any one of claims 1-9.
12. A computer-readable storage medium, characterized in that, Computer-executable instructions are stored in the computer-readable storage medium, and when the processor executes the computer-executable instructions, the method according to any one of claims 1-9 is implemented.
13. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, the method according to any one of claims 1-9 is implemented.