Data storage method and system for disk management
By establishing a disk block array and an update mechanism, the problems of excessively large mapping tables and hash collisions in large-capacity disk management are solved, achieving efficient data storage and retrieval.
Patent Information
- Application Number
- CN202411109926.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-14
- Publication Date
- 2024-11-05
- Estimated Expiration
- 2044-08-14
AI Technical Summary
In traditional disk management, the mapping table for large-capacity disks is too large, resulting in low data retrieval efficiency. Hash algorithms also incur additional time overhead when resolving hash collisions.
By establishing a disk block array, using a hash function to calculate the initial code of free disk blocks, and updating the disk block array after storing data blocks, free disk blocks are always at the forefront, avoiding hash collisions and directly determining the storage location.
It effectively improves data storage and query efficiency, avoids additional time overhead caused by hash collisions, and improves disk utilization.
Smart Images

Figure CN118642664B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data storage, and in particular to a data storage method and system for disk management. Background Art
[0002] In traditional disk management strategies, disks are usually logically divided according to block sizes, such as 4k, and a mapping table from real data IDs to logical addresses is established and maintained. When a 4k data block is written to the disk, the disk service will update this mapping table, record the number of the 4k data block and the location where it is stored on the disk; when the data of the 4k data block is to be read, the disk service needs to look up this mapping table based on the number of the 4k data block, find the location of the data block on the disk, and then read the data out.
[0003] When the disk capacity is relatively large, it means that there are a lot of blocks divided according to the 4k logic, which directly leads to a very large mapping table, which in turn affects the storage efficiency and ultimately affects the speed of reading data. Therefore, in order to solve the problem that the above-mentioned large-capacity disk uses data block logic to store a large amount of data, resulting in a large mapping table that affects the efficiency of subsequent data searches, technicians consider using a certain algorithm to map the data block ID to be written with the disk logic block as a reference; the advantage of this method is that there is no need to look up the mapping table at all, and only calculation is needed to determine the location information where the data block should be stored on the disk. When designing the above algorithm, the following two issues need to be considered: 1. Different data blocks must fall on different disk blocks; 2. After the data block is calculated, it cannot fall on an already occupied disk block.
[0004] The hash algorithm can map data block IDs to disk block IDs, but the hash algorithm has a fatal flaw: different data block IDs may be mapped to the same disk block, that is, there is a hash conflict. There are generally four ways to solve hash conflicts, and only the open address method meets the first requirement; the open address method means that when a hash conflict occurs, the next free disk block is selected until a free disk block is found; although the hash algorithm that selects the open address method solves the problem of low query efficiency caused by the large size of the disk storage mapping table, it adds extra time overhead when applied. Summary of the invention
[0005] The present invention aims to provide a data storage method and system for disk management, and proposes a method of re-encoding free disk blocks for multiple rounds, recording the encoding rounds, and establishing a disk block array, so as to ensure that each disk block determined when calculating the disk block for data block storage by using an algorithm is a free disk block, and there is no need for a free disk block search and confirmation process, thereby solving the technical problem of increasing additional time overhead when an open address method is applied to hash conflicts.
[0006] To achieve the above object, the present invention proposes the following technical solutions:
[0007] In a first aspect, a data storage method for disk management is provided, comprising: establishing a disk block array, wherein the initial numbers of all the disk blocks are stored in the disk block array in a one-to-one correspondence, and the subscripts of the disk block array are 0, 1, 2, ..., m-1; wherein m is the total number of disk blocks;
[0008] Get any data block to be stored and its ID, use the hash function to take the remainder of the total number of free disk blocks, and get the remainder;
[0009] Determine the subscript of the disk block array that is equal to the remainder value in the disk block array, and determine the initial code of the free disk block to store the data block according to the subscript;
[0010] The data block is stored in the free disk block corresponding to the initial code, and storage location information corresponding to the data block is recorded.
[0011] Furthermore, it also includes: updating the disk block array, swapping the array corresponding to the initial code of the disk block that completes data storage with the array corresponding to the initial code of the free disk block that is located at the end of the disk block array, so that the initial codes corresponding to the remaining free disk blocks are always located at the front column of the disk block array, and the subscript of the disk block array remains unchanged.
[0012] Furthermore, it also includes: obtaining the current storage information of the disk and determining the total number and location information of the free disk blocks;
[0013] Re-encode all the free disk blocks, record and store the encoding ID of each free disk block and the encoding round of the re-encoding; wherein the re-encoding ID is 0, 1, 2, ..., n-1, and n is the total number of free disk blocks;
[0014] Obtain any data block to be stored and its ID, and use a hash function to take the remainder of the total number of free disk blocks to obtain the remainder;
[0015] The free disk block corresponding to the coding ID equal to the remainder value is used as the disk block for storing the data block, and the storage location information of the data block is determined according to the coding ID of the free disk block; wherein the storage location information includes the ID of the data block, the coding ID of the free disk block and the coding round corresponding to the coding ID;
[0016] The data block is stored, and the storage location information corresponding to the data block is recorded.
[0017] Furthermore, it also includes: receiving disk block recovery information, determining the initial code of the free disk block after the data is released and its corresponding array in the disk block array; wherein the disk block recovery information includes file deletion information and file formatting information;
[0018] The disk block array is updated, and the corresponding array of the free disk blocks after the data is released is swapped with the array corresponding to the initial code of the non-empty disk block located at the front first in the disk block array.
[0019] Furthermore, it also includes: obtaining disk block damage information, determining the initial code of the damaged disk block and its corresponding array in the disk block array;
[0020] Setting the value of the corresponding array of the damaged disk block in the disk block array to a special value;
[0021] Update the disk block array. When the damaged disk block is a non-empty disk block, swap the corresponding array of the disk block with the array corresponding to the initial code of the first non-empty disk block at the end of the disk block array. When the damaged disk block is a free disk block, first swap the corresponding array of the damaged disk block with the array corresponding to the initial code of the free disk block at the front end of the disk block array, and then swap it with the array corresponding to the initial code of the first non-empty disk block at the end of the disk block array.
[0022] In a second aspect, a disk-managed data storage system is provided, comprising:
[0023] An establishing module is used to establish a disk block array, in which the initial serial numbers of all the disk blocks are stored one by one, and the subscripts of the disk block array are 0, 1, 2, ..., m-1; wherein m is the total number of disk blocks;
[0024] The first acquisition module is used to acquire any data block to be stored and its ID, and to obtain the remainder by taking the remainder of the total number of free disk blocks using a hash function;
[0025] A first determining module, configured to determine, in the disk block array, a subscript of the disk block array that is equal to the remainder value, and determine an initial code of the free disk block to store the data block according to the subscript;
[0026] The first storage module is used to store the data block in the free disk block corresponding to the initial code.
[0027] Furthermore, it also includes:
[0028] The first array update module is used to update the disk block array, and swap the array corresponding to the initial code of the disk block that completes data storage with the array corresponding to the initial code of the free disk block located at the first end of the disk block array, so that the initial codes corresponding to the remaining free disk blocks are always located at the front column of the disk block array, and the subscript of the disk block array remains unchanged.
[0029] Furthermore, it also includes:
[0030] The second acquisition module is used to obtain the current storage information of the disk and determine the total number and location information of free disk blocks;
[0031] A coding recording module, used for re-encoding all the free disk blocks, recording and storing the coding ID of each free disk block and the coding round of re-encoding; wherein the re-encoding ID is 0, 1, 2, ..., n-1, and n is the total number of free disk blocks;
[0032] The third acquisition module is used to acquire any data block to be stored and its ID, and to obtain the remainder by taking the remainder of the total number of free disk blocks using a hash function;
[0033] A second determination module is used to use the free disk block corresponding to the coding ID equal to the remainder value as the disk block for storing the data block, and determine the storage location information of the data block according to the coding ID of the free disk block; wherein the storage location information includes the ID of the data block, the coding ID of the free disk block and the coding round corresponding to the coding ID;
[0034] The second storage module is used to store the data block and record the storage location information corresponding to the data block.
[0035] Furthermore, it also includes:
[0036] A receiving and determining module, used for receiving disk block recovery information, determining the initial code of the free disk block after data is released and its corresponding array in the disk block array; wherein the disk block recovery information includes file deletion information and file formatting information;
[0037] The second array update module is used to update the disk block array, and swap the corresponding array of the free disk blocks after data release with the array corresponding to the initial code of the non-empty disk block located at the front first in the disk block array.
[0038] In a third aspect, an electronic device is proposed, comprising at least one processor; the processor is coupled to a memory, the memory being used to store one or more computing instructions, wherein the one or more computer instructions are executed by the processor during operation to implement the steps of the above-mentioned disk management data storage method.
[0039] It can be seen from the above technical solutions that the technical solutions of the present invention have the following beneficial effects:
[0040] The data storage method and system for disk management disclosed in the present invention include: establishing a disk block array, wherein the initial numbers of all the disk blocks are stored one by one in the disk block array, and the subscripts of the disk block array are 0, 1, 2, ..., m-1; wherein m is the total number of disk blocks; obtaining any data block to be stored and its ID, and taking the remainder of the total number of free disk blocks using a hash function; determining the subscript of the disk block array equal to the remainder in the disk block array, and determining the initial code of the free disk block to store the data block according to the subscript; and storing the data block in the free disk block corresponding to the initial code. The present invention establishes a disk block array, stores the initial code of the disk block in the array, and moves the array corresponding to the initial code of the disk block after each data block is stored to the end of the disk block array, fully ensuring that the disk blocks corresponding to the disk block array before the array are all free disk blocks, realizing the use of the array subscript as a transfer, and solving the problem of additional time overhead when the open address method is applied to hash conflicts.
[0041] In addition, the present invention also adopts a method of re-encoding the free disk blocks for multiple rounds to solve the problem of additional time overhead when the open address method is applied to hash conflicts, ensuring that the disk blocks storing data blocks each time are free disk blocks, without the need for free disk block search process. At the same time, the free disk blocks generated by clearing expired data from the disk blocks are immediately applied.
[0042] It should be appreciated that all combinations of the foregoing concepts, as well as additional concepts described in greater detail below, may be considered to be part of the inventive subject matter of the present disclosure, provided such concepts are not mutually inconsistent.
[0043] The foregoing and other aspects, embodiments and features of the present invention can be more fully understood from the following description in conjunction with the accompanying drawings. Other additional aspects of the present invention, such as the features and / or beneficial effects of the exemplary embodiments, will be apparent from the following description or learned from the practice of the specific embodiments according to the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] The accompanying drawings are not drawn to scale according to actual reference objects. In the accompanying drawings, each identical or nearly identical component shown in various figures may be represented by the same reference numeral. For the sake of clarity, not every component is labeled in each figure. Now, embodiments of various aspects of the present invention will be described by way of example and with reference to the accompanying drawings, in which:
[0045] Figure 1 The data storage method process of the disk management disclosed in the embodiment Figure 1 ;
[0046] Figure 2 The data storage method process of the disk management disclosed in the embodiment Figure 2 ;
[0047] Figure 3 Disk block array update process disclosed in the embodiment Figure 1 ;
[0048] Figure 4 Disk block array update process disclosed in the embodiment Figure 2 ;
[0049] Figure 5 A flowchart of reading a data block in a disk disclosed in an embodiment;
[0050] Figure 6 A structural block diagram of a data storage system for disk management disclosed in an embodiment;
[0051] Figure 7 A schematic diagram of an electronic device disclosed in an embodiment;
[0052] Figure 8 This is a schematic diagram of using a disk block array to store data blocks according to an embodiment disclosed in the disclosure. DETAILED DESCRIPTION
[0053] In order to make the purpose, technical solution and advantages of the embodiment of the present invention clearer, the technical solution of the embodiment of the present invention will be clearly and completely described below in conjunction with the drawings of the embodiment of the present invention. Obviously, the described embodiment is a part of the embodiment of the present invention, not all of the embodiments. Based on the described embodiment of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention. Unless otherwise defined, the technical terms or scientific terms used herein should be the common meaning understood by people with general skills in the field to which the present invention belongs.
[0054] The words "first", "second" and similar words used in the patent application specification and claims of the present invention do not indicate any order, quantity or importance, but are only used to distinguish different components. Similarly, unless the context clearly indicates otherwise, the singular form of "a", "an" or "the" and other similar words do not indicate a quantitative limitation, but indicate the existence of at least one. "Include" or "comprise" and other similar words mean that the elements or objects appearing before "include" or "comprise" cover the features, wholes, steps, operations, elements and / or components listed after "include" or "comprise", and do not exclude the existence or addition of one or more other features, wholes, steps, operations, elements, components and / or their collections. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0055] When the hash algorithm is used to calculate and determine the storage location of a data block on a disk, an open address method is used to solve the hash conflict in the algorithm application. This solution causes the data block to be judged whether it is free one by one when selecting free disk blocks for storage, which generates a lot of extra time overhead. Therefore, the present invention aims to propose a data storage method and system for disk management, which only calculates the location information stored in the free disk blocks, avoids the free disk block judgment process one by one, and solves the problem of increased time overhead when the hash algorithm is used.
[0056] For example, a disk divided into four disk blocks is numbered 0, 1, 2, and 3; when two data blocks are written successively, two hash calculations must be performed; assuming that the hash algorithm is the simplest, the remainder of the total number of disk blocks is taken; when the result of the first calculation is 1, the data block is written to the disk block numbered 1; when the second calculation is performed, the disk blocks that have already stored data are not considered, and each subsequent data block storage is selected by hashing from the remaining disk blocks to ensure that the disk blocks storing data blocks will never have hash conflicts.
[0057] The data storage method and system for disk management disclosed in the embodiments of the present invention will be further specifically introduced below in conjunction with the accompanying drawings and specific embodiments.
[0058] Combination Figure 1 As shown, the data storage method of disk management disclosed in the embodiment includes the following steps:
[0059] Step S102, establishing a disk block array, wherein the initial serial numbers of all the disk blocks are stored in the disk block array in a one-to-one correspondence, and the subscripts of the disk block array are 0, 1, 2, ..., m-1; wherein m is the total number of disk blocks;
[0060] A completely idle disk first determines the total number and location information of free disk blocks based on the disk partition, and then performs initial free disk block ID encoding;
[0061] Step S104, obtaining any data block to be stored and its ID, and using a hash function to obtain a remainder of the total number of free disk blocks;
[0062] Step S106, determining the subscript of the disk block array equal to the remainder value in the disk block array, and determining the initial code of the free disk block to be stored in the data block according to the subscript; that is, the initial code stored in the array corresponding to the subscript equal to the remainder value is the initial code of the free disk block to be stored in the data block;
[0063] Step S108, storing the data block in the free disk block corresponding to the initial code, and recording storage location information corresponding to the data block.
[0064] The above solution uses the disk block array as a transfer to determine the free disk blocks used to store data blocks, directly avoiding additional time overhead and effectively improving the efficiency of data block storage and query; in order to avoid hash conflicts, such as Figure 2 As shown, after the data block storage is completed according to the disk block array, the disk block array needs to be updated to achieve that the plurality of arrays storing free disk blocks are concentrated in the front row of the disk block array. Specifically, the updating process of the disk block array after the data block storage is completed includes: step S110, updating the disk block array, swapping the array corresponding to the initial code of the disk block that has completed the data storage with the array corresponding to the initial code of the free disk block located at the first position at the end of the disk block array, so that the initial codes corresponding to the remaining free disk blocks are always located in the front row of the disk block array, and the subscript of the disk block array remains unchanged.
[0065] Take the disk divided into 4 disk blocks as an example, create a disk block array; combine Figure 8As shown, first, the initial numbers of the four disk blocks are stored in the array, and the remainder of the first hash calculation is 1, which corresponds to the array with subscript 1 in the disk block array; the initial numbers of the disk blocks stored in the array are taken out at the corresponding positions of the disk block array, and the disk block 1 where the data block ID1 is stored is determined; after the data storage is completed, the array corresponding to the initial code of the disk block that has stored the data block is moved to the end of the disk block array, and the array with a bottom of 3 is moved to the array position with a subscript of 1, ensuring that the disk blocks corresponding to the initial codes stored in all arrays before the array storing the initial code of the disk block have no data stored; the remainder of the second hash calculation is 1, and the initial code stored in the array with a subscript of 1 is 3 at this time, and the data block ID2 is stored in the disk block with an initial code of 3, and the array with a subscript of 1 is moved before the data block with an initial code of 1 that has completed data storage in the previous round.
[0066] The present invention is not limited to the above-mentioned method of taking the remainder using a hash function, and other algorithms that can achieve the above-mentioned determination of the array index by taking the remainder can be applied in this solution.
[0067] As an optional implementation, the embodiment of the present invention also proposes a data storage method for disk management, such as Figure 3 As shown, it includes: Step S202, obtaining the current storage information of the disk, determining the total number and location information of the free disk blocks; this step is performed after receiving the data storage request, and the current disk storage information is obtained according to the data storage request, and storage can only be performed under the premise that the current disk has free disk blocks. Step S204, re-ID-encode all the free disk blocks, record and store the encoding ID of each free disk block and the encoding round of the re-ID encoding; wherein the re-encoded ID is 0, 1, 2, ..., n-1, and n is the total number of free disk blocks; by recording the re-encoded encoding round, the disk blocks with the same encoding ID are distinguished, so that the storage disk blocks can be accurately found when reading data. Step S206, obtain any data block to be stored and its ID, use a hash function to take the modulus of the total number of free disk blocks to obtain a remainder; step S208, use the free disk block corresponding to the coding ID equal to the remainder value as the disk block for storing the data block, and determine the storage location information of the data block according to the coding ID of the free disk block; wherein the storage location information includes the ID of the data block, the coding ID of the free disk block and the coding round corresponding to the coding ID; step S210, store the data block and record the storage location information corresponding to the data block.
[0068] The above disk management data storage method specifically solves the problem of additional time overhead when the open address method is applied to hash conflicts. It adopts a method of multiple rounds of re-encoding of free disk blocks. Each time a data block is stored, only free disk blocks are considered to avoid hash conflicts. At the same time, since this scheme counts free disk blocks before each storage, the disk performs data cleaning. For example, the free disk blocks generated by cleaning expired data can be immediately used for storage again, effectively improving the utilization rate of the disk.
[0069] As an optional implementation scheme, when the disk block array is used to calculate and determine the disk block code of the storage data block, the free disk blocks generated in real time due to disk block recycling are re-encoded into the disk block array in the following manner to improve the utilization rate of the disk; the specific method is as follows: Figure 4 As shown, it includes: step S302, receiving disk block recovery information, determining the initial code of the free disk block after data is released and its corresponding array in the disk block array; wherein the disk block recovery information includes file deletion information and file formatting information; in some disk applications, in order to improve the application efficiency of the disk, disk data cleaning is performed regularly according to the preset data cleaning cycle. At this time, based on the array update process when the disk block array is used to store data, the disk block array corresponding to the initial code of the disk block at the end of the disk block array has the longest storage time. Therefore, according to the storage time and data cleaning cycle of each disk block, it can be determined whether the array in the disk block is updated, and the disk block with the first expired data in the block can be cleaned first. Step S304, updating the disk block array, swapping the corresponding array of the free disk block after data is released with the array corresponding to the initial code of the non-empty disk block located at the front of the disk block array; that is, the array corresponding to the initial code of the free disk block after cleaning is compiled before the array corresponding to the initial code of the disk block storing data, so as to ensure that the array corresponding to the initial code of the free disk block is always in the front row of the disk block array.
[0070] Combined with the specific application scenarios of the disk, there are still cases where the disk block is damaged; for such cases where the disk block is damaged or fixed and not used, the processing method when using the disk block array to store data is as follows: obtain the disk block damage information, determine the initial code of the damaged disk block and its corresponding array in the disk block array; set the value of the corresponding array of the damaged disk block in the disk block array as a special value; update the disk block array, when the damaged disk block is a non-empty disk block, the corresponding array of the disk block is swapped with the array corresponding to the initial code of the first non-empty disk block at the end of the disk block array; when the damaged disk block is a free disk block, the corresponding array of the damaged disk block is first swapped with the array corresponding to the initial code of the free disk block at the end of the disk block array, and then swapped with the array corresponding to the initial code of the first non-empty disk block at the end of the disk block array. When storing data, if it is found that the content stored in the array is a special value, the array is directly skipped and not stored.
[0071] Combination Figure 5 As shown, the data storage method of the present invention uses the following process to complete data reading after data storage, including: step S402, receiving a data update request, and determining the ID of the data block to be updated according to the data update request; step S404, determining the encoding ID of the disk block stored in the data block and the encoding round corresponding to the encoding ID according to the ID of the data block and the mapping table; step S406, updating the data of the data block stored in the disk block according to the data update request. Optionally, when a disk block array is used for data storage, the content of step S404 is to determine the initial encoding of the disk block stored in the data block according to the ID of the data block and the mapping table.
[0072] In an embodiment of the present application, an electronic device is also provided, including a computer program, the computer program being stored in a computer-readable storage medium; when a processor of the electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, so that the electronic device executes the steps of the above-mentioned disk management data storage method. Taking an electronic device running on a computer as an example, Figure 7 As shown, the electronic device may include one or more (only one is shown in the figure) processors (the processor may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory for storing data, and a transmission device for communication functions. A person skilled in the art can understand that Figure 7 The structure shown is for illustration only and does not limit the structure of the above-mentioned electronic device.
[0073] The above program can be run in the processor, or it can be stored in the memory, that is, in the computer-readable medium, which includes permanent and non-permanent, removable and non-removable media. Information storage can be achieved by any method or technology. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined in this article, computer-readable media does not include temporary computer-readable media, such as modulated data signals and carrier waves. These computer programs can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps of the functions specified in a block or multiple blocks may be implemented by different modules corresponding to different method steps.
[0074] In this embodiment, such a device or system is provided. The system can be called a disk-managed data storage system. Figure 6 As shown, it includes: an establishment module, used for establishing a disk block array, in which the initial numbers of all the disk blocks are stored one by one, and the subscripts of the disk block array are 0, 1, 2, ..., m-1; wherein m is the total number of disk blocks; a first acquisition module, used for acquiring any data block to be stored and its ID, and using a hash function to take the remainder of the total number of free disk blocks to obtain a remainder; a first determination module, used for determining the subscript of the disk block array equal to the remainder value in the disk block array, and determining the initial code of the free disk block to store the data block according to the subscript; a first storage module, used for storing the data block in the free disk block corresponding to the initial code.
[0075] The steps of the system for implementing the disk management data storage method disclosed in the above embodiment have been described and will not be repeated here.
[0076] For example, the data storage system of disk management also includes: a second acquisition module, which is used to obtain the current storage information of the disk and determine the total number and location information of free disk blocks; a coding and recording module, which is used to re-ID-encode all the free disk blocks, record and store the coding ID of each free disk block and the coding round of the re-ID coding; wherein the re-encoded ID is 0, 1, 2, ..., n-1, and n is the total number of free disk blocks; a third acquisition module, which is used to obtain any data block to be stored and its ID, and use a hash function to take the remainder of the total number of free disk blocks to obtain the remainder; a second determination module, which is used to use the free disk block corresponding to the coding ID equal to the remainder value as the disk block for storing the data block, and determine the storage location information of the data block according to the coding ID of the free disk block; wherein the storage location information includes the ID of the data block, the coding ID of the free disk block and the coding round corresponding to the coding ID; a second storage module, which is used to store the data block and record the storage location information corresponding to the data block.
[0077] For another example, the data storage system for disk management further includes: a first array update module, used to update the disk block array, and swap the array corresponding to the initial code of the disk block that completes data storage with the array corresponding to the initial code of the free disk block that is located at the first position at the end of the disk block array, so that the initial codes corresponding to the remaining free disk blocks are always located at the front column of the disk block array, and the subscript of the disk block array remains unchanged.
[0078] For another example, the disk management data storage system further includes:
[0079] A receiving and determining module is used to receive disk block recovery information, determine the initial code of the free disk block after the data is released and its corresponding array in the disk block array; wherein the disk block recovery information includes file deletion information and file formatting information; a second array updating module is used to update the disk block array, and swap the corresponding array of the free disk block after the data is released with the array corresponding to the initial code of the non-empty disk block located at the front first position in the disk block array.
[0080] For another example, the data storage system for disk management further includes: an acquisition and determination module, used to acquire disk block damage information, determine the initial code of the damaged disk block and its corresponding array in the disk block array; a setting module, used to set the value of the corresponding array of the damaged disk block in the disk block array to a special value; a third array update module, used to update the disk block array, when the damaged disk block is a non-empty disk block, the corresponding array of the disk block is swapped with the array corresponding to the initial code of the first non-empty disk block at the end of the disk block array; when the damaged disk block is a free disk block, the corresponding array of the damaged disk block is first swapped with the array corresponding to the initial code of the free disk block at the front end of the disk block array, and then swapped with the array corresponding to the initial code of the first non-empty disk block at the end of the disk block array.
[0081] The data storage method and system for disk management disclosed in the present invention, on the one hand, establish a disk block array, store the initial code of the disk block in the array, determine the array index by hash calculation modulus, and then determine the disk block storing the data block, and move the array corresponding to the initial code of the disk block after each data block is stored to the end of the disk block array, fully ensuring that the disk blocks corresponding to the disk block array before the array are all free disk blocks, and using the disk block array index as a transfer to solve the problem of additional time overhead when the open address method is applied to hash conflicts; on the other hand, adopt a method of re-encoding the free disk blocks for multiple rounds, determine the coding ID and coding round of the free disk blocks by hash calculation modulus, ensure that the disk block storing the data block each time is a free disk block, and there is no need to search for the free disk blocks one by one, so as to solve the problem of additional time overhead when the open address method is applied to hash conflicts.
[0082] Although the present invention has been disclosed as above with preferred embodiments, it is not intended to limit the present invention. A person with ordinary knowledge in the technical field to which the present invention belongs may make various changes and modifications without departing from the spirit and scope of the present invention. Therefore, the protection scope of the present invention shall be determined by the definition of the claims.
Claims
1. A data storage method for disk management, characterized in that: include: Establishing a disk block array, wherein the initial serial numbers of all the disk blocks are stored in the disk block array in a one-to-one correspondence, and the subscripts of the disk block array are 0, 1, 2, ..., m-1; wherein m is the total number of disk blocks; Get any data block to be stored and its ID, use the hash function to take the remainder of the total number of free disk blocks, and get the remainder; Determine the subscript of the disk block array that is equal to the remainder value in the disk block array, and determine the initial code of the free disk block to store the data block according to the subscript; Storing the data block in the free disk block corresponding to the initial code; Update the disk block array, and swap the array corresponding to the initial code of the disk block that completes data storage with the array corresponding to the initial code of the free disk block that is located at the end of the disk block array, so that the initial codes corresponding to the remaining free disk blocks are always located at the front column of the disk block array, and the subscript of the disk block array remains unchanged.
2. The data storage method for disk management according to claim 1, characterized in that: Also includes: Receiving disk block recovery information, determining the initial code of the free disk block after the data is released and its corresponding array in the disk block array; wherein the disk block recovery information includes file deletion information and file formatting information; The disk block array is updated, and the corresponding array of the free disk blocks after the data is released is swapped with the array corresponding to the initial code of the non-empty disk block located at the front first in the disk block array.
3. The data storage method for disk management according to claim 1, characterized in that: Also includes: Obtaining disk block damage information, determining the initial code of the damaged disk block and its corresponding array in the disk block array; Setting the value of the corresponding array of the damaged disk block in the disk block array to a special value; Update the disk block array. When the damaged disk block is a non-empty disk block, swap the corresponding array of the disk block with the array corresponding to the initial code of the first non-empty disk block at the end of the disk block array. When the damaged disk block is a free disk block, first swap the corresponding array of the damaged disk block with the array corresponding to the initial code of the free disk block at the front end of the disk block array, and then swap it with the array corresponding to the initial code of the first non-empty disk block at the end of the disk block array.
4. A disk-managed data storage system, characterized in that: include: An establishing module is used to establish a disk block array, in which the initial serial numbers of all the disk blocks are stored one by one, and the subscripts of the disk block array are 0, 1, 2, ..., m-1; wherein m is the total number of disk blocks; The first acquisition module is used to acquire any data block to be stored and its ID, and to obtain the remainder by taking the remainder of the total number of free disk blocks using a hash function; A first determining module, configured to determine, in the disk block array, a subscript of the disk block array that is equal to the remainder value, and determine an initial code of the free disk block to store the data block according to the subscript; A first storage module, used for storing the data block in the free disk block corresponding to the initial code; The first array update module is used to update the disk block array, and swap the array corresponding to the initial code of the disk block that completes data storage with the array corresponding to the initial code of the free disk block located at the first end of the disk block array, so that the initial codes corresponding to the remaining free disk blocks are always located at the front column of the disk block array, and the subscript of the disk block array remains unchanged.
5. The disk-managed data storage system according to claim 4, characterized in that: Also includes: A receiving and determining module, used for receiving disk block recovery information, determining the initial code of the free disk block after data is released and its corresponding array in the disk block array; wherein the disk block recovery information includes file deletion information and file formatting information; The second array update module is used to update the disk block array, and swap the corresponding array of the free disk blocks after data release with the array corresponding to the initial code of the non-empty disk block located at the front first in the disk block array.
6. An electronic device, characterized in that: It includes at least one processor; the processor is coupled to a memory, and the memory is used to store one or more computing instructions, wherein the one or more computer instructions are executed by the processor when it is running to implement the steps of the disk management data storage method described in any one of claims 1 to 3.
