Method and system for expanding data storage space based on solid state hard disk
By periodically extracting the storage information of the SSD and arranging it according to the remaining space, allocating newly written data to the SSD with the largest remaining space, and building a storage index to support reading, it solves the problem that existing storage systems cannot support reading during writing. The problem of this has achieved the horizontal expansion of SSD and the improvement of data reading efficiency.
Patent Information
- Application Number
- CN202410696418.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-31
- Publication Date
- 2025-02-07
- Estimated Expiration
- 2044-05-31
AI Technical Summary
Existing storage systems cannot support data reading when data is written, resulting in low data reading efficiency and affecting the scalability of the storage system.
By periodically extracting the storage information of multiple solid state hard disks (SSDs), arranging it in descending order of remaining storage space, receiving newly written account status data and allocating it to the SSD storage with the largest remaining space, building a storage index, and locking it in the write operation When it is time to copy the copy data to support reading.
The horizontal expansion of multiple SSDs is achieved, giving priority to the use of the newly expanded SSD storage space, and providing replica data to support reading when writing data, improving data reading efficiency.
Smart Images

Figure CN118642650B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the technical field of computers and data storage, and specifically relates to a method and system for expanding data storage space based on a solid state drive. Background Art
[0002] For storage systems, such as blockchain, local databases are generally used to solve the problem of persistent storage of states. Therefore, existing storage technology solutions cannot effectively expand the storage system. In addition, existing storage systems cannot support data reading when data is written, which leads to low data reading efficiency of the storage system and affects data reading efficiency. Summary of the invention
[0003] The present application provides a method and system for expanding data storage space based on a solid-state hard disk, which can achieve effective horizontal expansion of an energy storage system and increase the storage space of the storage system.
[0004] In a first aspect, the present application provides a method for expanding data storage space based on a solid state drive, the method comprising the following steps:
[0005] A method for expanding data storage space based on a solid state hard disk, characterized in that the method comprises the following steps:
[0006] Periodically extract multiple storage information of multiple SSDs, each storage information includes the remaining storage space of each SSD, and arrange the multiple SSDs in descending order according to the remaining storage space to obtain a first SSD sequence;
[0007] Receive newly written account status data, and if the storage space required by the newly written account status data is less than the remaining storage space of the first SSD in the first SSD sequence, allocate the newly written account status data to the first SSD for storage, and construct a storage index for the newly written account status data, wherein the storage index includes: a storage path, a memory mapping, a write operation lock, a number of used bytes, and a number of allocated bytes. When the write operation lock is yes, copy a replica of the newly written account status data, and replace the storage path and memory mapping of the storage index with the storage path and memory mapping of the replica data;
[0008] A read instruction for newly written account status data is received, the storage index is extracted, and if the write operation lock in the storage index is negative, the newly written account status data is read according to the storage path and memory mapping; if the write operation lock in the storage index is yes, the copy data is read according to the replaced storage path and memory mapping.
[0009] In a second aspect, a system for expanding data storage space based on a solid state drive is provided, the system comprising:
[0010] An extraction unit, used for periodically extracting multiple storage information of multiple SSDs, each storage information including the remaining storage space of each SSD, and arranging the multiple SSDs in descending order according to the remaining storage space to obtain a first SSD sequence;
[0011] A receiving unit, used for receiving newly written account status data;
[0012] a processing unit, configured to allocate the newly written account status data to the first SSD for storage if the storage space required by the newly written account status data is less than the remaining storage space of the first SSD in the first SSD sequence, and construct a storage index for the newly written account status data, wherein the storage index includes: a storage path, a memory mapping, a write operation lock, a number of used bytes, and a number of allocated bytes; and when the write operation lock is yes, copy a replica of the newly written account status data, and replace the storage path and memory mapping of the storage index with the storage path and memory mapping of the replica;
[0013] The receiving unit is further used to receive a read instruction of the newly written account status data;
[0014] The processing unit is also used to extract the storage index, and if the write operation lock in the storage index is negative, read the newly written account status data according to the storage path and memory mapping; if the write operation lock in the storage index is yes, read the copy data according to the replaced storage path and memory mapping.
[0015] In a third aspect, the present application provides a computer storage medium storing a computer program for electronic data exchange, wherein the computer program enables a computer to execute some or all of the steps described in the first aspect of the present application.
[0016] The embodiments of the present application have the following beneficial effects:
[0017] The technical solution provided by the present application periodically extracts multiple storage information of multiple SSDs, each storage information includes the remaining storage space of each SSD, and arranges the multiple SSDs in descending order according to the remaining storage space to obtain a first SSD sequence; receives newly written account status data, and if the storage space required for the newly written account status data is less than the remaining storage space of the first SSD in the first SSD sequence, allocates the newly written account status data to the first SSD for storage, and constructs a storage index for the newly written account status data, wherein the storage index includes: storage path, memory mapping, write operation lock, The number of bytes used and the number of bytes allocated, when the write operation lock is (1), the newly written account status data is copied into a replica data, and the storage path and memory mapping of the replica data replace the storage path and memory mapping of the storage index; receiving the read instruction of the newly written account status data, extracting the storage index, if the write operation lock in the storage index is not (i.e. 0), then reading the newly written account status data according to the storage path and memory mapping; if the write operation lock in the storage index is (i.e. 1), reading the replica data according to the replaced storage path and memory mapping. The horizontal expansion of multiple SSDs can be well achieved through competition, so that the newly expanded SSD can use storage first, and the above technical solution provides replica data that can support reading at the same time when writing data, thereby improving the data reading efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0019] Figure 1 It is a structural diagram of a storage system provided in an embodiment of the present application;
[0020] Figure 2 It is a flowchart of a method for expanding data storage space based on a solid state drive provided in an embodiment of the present application;
[0021] Figure 3 It is a structural block diagram of a system for expanding data storage space based on a solid state drive provided in an embodiment of the present application. DETAILED DESCRIPTION
[0022] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0023] The terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, systems, products or devices.
[0024] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0025] SSD: Solid State Drive, short for Solid State Drives. Different from traditional mechanical hard drives, it uses flash memory chips to store data. SSD has faster read and write speeds and higher performance. This is because flash memory chips can access data faster and are not limited by rotation speed.
[0026] RAM: Random Access Memory, also called main memory, is the internal memory that directly exchanges data with the CPU.
[0027] The following is a schematic diagram of the architecture of a storage system involved in an embodiment of the present application.
[0028] See also Figure 1 , Figure 1 A schematic diagram of the structure of a storage system provided in this application, such as Figure 1As shown, the storage system includes multiple storage terminals, each storage terminal includes: at least one processor (processor) and a random access memory RAM, and may also include a communication interface (Communications Interface) and multiple solid-state hard disks SSD. Among them, the processor, RAM, communication interface and SSD can all communicate with each other through the bus. The communication interface can transmit information, and the communication interface can have a wireless communication function, and the wireless communication function can be a short-range wireless communication or a long-range communication function (such as NR mode). The processor can call the logic instructions in the memory to execute or support the method in the embodiment of the present application.
[0029] Among them, multiple SSDs can be combined into the overall capacity, and of course can also be combined into secure mirror storage or parity storage. Each SSD can also be accessed independently. Users can choose personalized usage or expansion space according to their own needs, and can also read the contents of the SSD through the network.
[0030] See also Figure 2 , Figure 2 A flowchart of a method for expanding data storage space based on a solid state drive is provided. Figure 2 As shown, the above method is Figure 1 The method is performed in the storage system shown in the figure, and includes the following steps:
[0031] Step S201, periodically extracting multiple storage information of multiple SSDs, each storage information including the remaining storage space of each SSD, and arranging the multiple SSDs in descending order according to the remaining storage space to obtain a first SSD sequence;
[0032] The above step S201 can be implemented by a processor, that is, the processor periodically extracts multiple storage information of multiple SSDs, and then can obtain the remaining storage space, so that multiple SSDs can be combined into a first SSD sequence, which is convenient for improving the utilization rate of the storage space of the SSD. And by extracting multiple storage information of multiple SSDs, the SSD can be horizontally expanded very conveniently. The above multiple storage information is in a one-to-one correspondence with the multiple SSDs.
[0033] Step S202: receiving newly written account status data; if the storage space required by the newly written account status data is less than the remaining storage space of the first SSD in the first SSD sequence, allocating the newly written account status data to the first SSD for storage, and constructing a storage index for the newly written account status data, wherein the storage index includes: a storage path, a memory mapping, a write operation lock, a number of used bytes, and a number of allocated bytes; when the write operation lock is (1), copying a replica of the newly written account status data, and replacing the storage path and memory mapping of the storage index with the storage path and memory mapping of the replica data;
[0034] The newly written account status data may specifically be data that needs to be stored. The account may be one or more accounts, each account corresponds to a target object (such as a user name, etc.). The status data includes but is not limited to: transaction data, interaction data, and other data bound to the account.
[0035] Step S203: Receive a read instruction for the newly written account status data, extract the storage index, and if the write operation lock in the storage index is negative (i.e., 0), read the newly written account status data according to the storage path and memory mapping; if the write operation lock in the storage index is yes (i.e., 1), read the copy data according to the replaced storage path and memory mapping.
[0036] The technical solution provided by the present application periodically extracts multiple storage information of multiple SSDs, each storage information includes the remaining storage space of each SSD, and arranges the multiple SSDs in descending order according to the remaining storage space to obtain a first SSD sequence; receives newly written account status data, and if the storage space required for the newly written account status data is less than the remaining storage space of the first SSD in the first SSD sequence, allocates the newly written account status data to the first SSD for storage, and constructs a storage index for the newly written account status data, wherein the storage index includes: storage path, memory mapping, write operation lock, The number of bytes used and the number of bytes allocated, when the write operation lock is (1), the newly written account status data is copied into a replica data, and the storage path and memory mapping of the replica data replace the storage path and memory mapping of the storage index; receiving the read instruction of the newly written account status data, extracting the storage index, if the write operation lock in the storage index is not (i.e. 0), then reading the newly written account status data according to the storage path and memory mapping; if the write operation lock in the storage index is (i.e. 1), reading the replica data according to the replaced storage path and memory mapping. The horizontal expansion of multiple SSDs can be well achieved through competition, so that the newly expanded SSD can use storage first, and the above technical solution provides replica data that can support reading at the same time when writing data, thereby improving the data reading efficiency.
[0037] In an optional technical scenario, the above method may further include:
[0038] After the write operation is completed, the write operation lock is restored to negative, the duplicate data is deleted, and the storage path and memory mapping of the storage index are restored to the storage path and memory mapping before replacement.
[0039] After the write operation is completed, that is, the newly written account status data has been updated, the write operation is restored to non-write, the copy data is deleted, and the storage path and memory mapping are restored. In this way, after the write operation is completed, the copy data is prevented from affecting the updated account status data, thereby improving the accuracy of subsequent data reading.
[0040] In an optional technical scenario, the above method may further include:
[0041] If the storage space required for the newly written account status data is greater than the remaining storage space of the first SSD in the first SSD sequence, the number x of accounts of the newly written account status data is determined, and the newly written account status data is split into x status sub-data with each account status data as a basic unit, each status sub-data is the status data of a single account, the number y of multiple SSDs is obtained, w number sequences arranged in descending order are randomly constructed, each of the w number sequences has y element values and the sum of the y element values is x, the first number sequence among the w number sequences is extracted, and the x status sub-data are allocated to y SSDs according to the y element values of the first number sequence, a new second SSD sequence is constructed (the construction method of the above-mentioned second SSD sequence can refer to the method of the first SSD sequence), the second moving total value of the second SSD sequence is calculated, the w number sequences are traversed to obtain w moving total values, the i-th number sequence corresponding to the minimum value is selected from the w moving total values, the x status sub-data are allocated to y SSDs according to the y element values of the i-th number sequence, and y storage indexes corresponding to y groups of status sub-data corresponding to the y element values are constructed.
[0042] When the newly written account status data requires a larger storage space, the number of newly written accounts is generally large, and the size of the general account status data is within 4MB (of course, it may be different for different storage systems. This is an empirical value, and it is only for example). In order to better allocate the newly written account status data, it is necessary to split all the account status data into x status sub-data by a single account, and then construct w number series, and then calculate the minimum moving value in the w number series to make the x status sub-data distribution more uniform. Through data collection, it is found that when the status data in the SSD is more balanced, the efficiency of data reading or writing will be higher. Therefore, the above method is used to allocate the account status data with a larger storage space. It should be noted that the above y element values can contain one or more element values of 0, but the number series must be arranged in descending order, and the minimum value of the y element values must be an integer greater than or equal to 0. Of course, the above w number series can also be found through multiple iterations to find the minimum value. The idea based on it is the same, so it will not be repeated here.
[0043] Taking y as 4 as an example, and w=3, the corresponding three number series can be: 4, 3, 2, 1; 5, 3, 1, 1; 5, 4, 1, 0.
[0044] In an optional technical scenario, the above-mentioned calculation of the second moving total value of the second SSD sequence may specifically include:
[0045] Extract ID1 of the first SSD of the first SSD sequence, extract position 1 corresponding to ID1 from the second SSD sequence, if the value of position 1 is less than the value of the position of the first SSD sequence, subtract the value of position 1 from the value of the position of the first SSD in the first SSD sequence to obtain the movement value of ID1, if the value of position 1 is greater than or equal to the value of the position of the first SSD sequence, determine that the movement value of ID1 is equal to 0, traverse y SSDs to obtain y movement values, and the second movement total value is equal to the sum of the y movement values.
[0046] The following is an actual example. It is assumed that the first SSD sequence is: SSD1, SSD2, SSD3, SSD4; the second SSD sequence is: SSD2, SSD1, SSD4, SSD3; then the moving total value of the second SSD sequence may specifically include:
[0047] The movement value of SSD1 = -1, the movement value of SSD2 = 0, the movement value of SSD3 = -1, and the movement value of SSD4 = 0, then the total movement value of the second SSD sequence = -2.
[0048] In an optional technical scenario, the above method may further include:
[0049] The total number of reads of each SSD within a set period (for example, one week or 24 hours) is counted to obtain α total numbers, where α is the total number of SSDs. The α total numbers are arranged in descending order to obtain a first number sequence. The first SSD and the last SSD in the first number sequence are combined into an SSD pair to obtain α / 2 SSD pairs. The two SSDs in each SSD pair are balanced to obtain two balanced SSDs. The above-mentioned balancing operation may specifically include:
[0050] Extract each storage index in the SSD pair and give it a unique number, extract the number of reads of each storage index, and construct a one-to-one mapping relationship between the unique number and the number of reads, arrange the number of reads in descending order to obtain a first subsequence, assign the account status data corresponding to the storage index corresponding to the odd bits in the first subsequence to one SSD of the SSD pair, and assign the account status data corresponding to the storage index corresponding to the even bits in the first subsequence to the other SSD of the SSD pair.
[0051] Here, it is assumed that there are 10 storage indexes, which are numbered 1, 2, 3, ... 10; the number of reads of each storage index is 10, 9, 8, ... 1, respectively. Then, the account status data corresponding to the storage indexes numbered 10, 8, 6, 4, 2 are assigned to SSD1 of the SSD pair, and the account status data corresponding to the storage indexes numbered 9, 7, 5, 3, 1 are assigned to SSD2 of the SSD pair. In this way, the number of reads can be balanced, and the number of reads of each SSD can be balanced as much as possible, thereby improving the reading efficiency. After each SSD pair is balanced, the read balance can be achieved for α SSDs.
[0052] The above-mentioned first and last SSD pairs can be specifically: if the first number sequence is: SSD1, SSD2, ... SSD10, then the first SSD1 and the last SSD10 are determined as an SSD pair, and SSD2 and SSD9 are determined as an SSD pair, so that 5 SSD pairs can be formed. Of course, if α is an odd number, it can be determined as (α-1 / 2) SSD pairs, and the intermediate SSD does not perform the balancing operation.
[0053] In an optional solution, the above balancing operation may specifically include:
[0054] Extract each storage index in the SSD pair and assign a unique number to it. Extract the number of reads of each storage index and build a one-to-one mapping relationship between the unique number and the number of reads. Form an array of the number of reads of all storage indexes. Arrange and combine the element values in the array to obtain multiple combinations. Each combination contains two sub-arrays. Calculate the deviation value of each group. Select the two sub-arrays corresponding to the i-th group with the smallest deviation value. Distribute the account status data corresponding to the two sub-arrays corresponding to the i-th group to the two SSDs of the SSD pair respectively.
[0055] The above deviation value = |S1 - S2|; wherein S1 is the sum of the element values of one of the two sub-arrays, and S2 is the sum of the element values of the other of the two sub-arrays.
[0056] Let's take an example to illustrate. Here, assuming the number of reads is: 10, 9, 8, 4, then the permutations and combinations have the following concentrated combinations: combination 1: 10; 9, 8, 3; combination 2: 10, 3; 9, 8. The ";" above indicates grouping; of course, there are many other combinations, which are not listed here one by one. The deviation value of combination 1 above = |10-20| = 10, and the deviation value of combination 2 = |13-17| = 4, so combination 2 is selected as the i-th group.
[0057] See also Figure 3 , Figure 3 A system for expanding data storage space based on a solid state drive is provided, the system comprising:
[0058] The extraction unit 301 is used to periodically extract multiple storage information of multiple SSDs, each storage information includes the remaining storage space of each SSD, and arrange the multiple SSDs in descending order according to the remaining storage space to obtain a first SSD sequence;
[0059] A receiving unit 302, configured to receive newly written account status data;
[0060] The processing unit 303 is configured to allocate the newly written account status data to the first SSD for storage if the storage space required by the newly written account status data is less than the remaining storage space of the first SSD in the first SSD sequence, and construct a storage index for the newly written account status data, wherein the storage index includes: a storage path, a memory mapping, a write operation lock, a number of used bytes, and a number of allocated bytes; when the write operation lock is yes, copy a replica of the newly written account status data, and replace the storage path and memory mapping of the storage index with the storage path and memory mapping of the replica data;
[0061] The receiving unit 302 is further used to receive a read instruction of the newly written account status data;
[0062] The processing unit 303 is also used to extract the storage index. If the write operation lock in the storage index is negative, the newly written account status data is read according to the storage path and memory mapping; if the write operation lock in the storage index is yes, the copy data is read according to the replaced storage path and memory mapping.
[0063] For example,
[0064] The processing unit 303 is further used to restore the write operation lock to negative after the write operation is completed, delete the copy data, and restore the storage path and memory mapping of the storage index to the storage path and memory mapping before replacement.
[0065] For example,
[0066] The processing unit 303 is further used to count the total number of reads of each SSD within a set period to obtain α total numbers, where α is the total number of SSDs, arrange the α total numbers in descending order to obtain a first number sequence, form an SSD pair with the first SSD and the last SSD in the first number sequence to obtain α / 2 SSD pairs, and perform a balancing operation on the two SSDs in each SSD pair to obtain two balanced SSDs.
[0067] For example, the balancing operation specifically includes:
[0068] Extract each storage index in the SSD pair and give it a unique number, extract the number of reads of each storage index, and construct a one-to-one mapping relationship between the unique number and the number of reads, arrange the number of reads in descending order to obtain a first subsequence, assign the account status data corresponding to the storage index corresponding to the odd bits in the first subsequence to one SSD of the SSD pair, and assign the account status data corresponding to the storage index corresponding to the even bits in the first subsequence to the other SSD of the SSD pair.
[0069] For example,
[0070] The balancing operation specifically includes:
[0071] Extract each storage index in the SSD pair and assign a unique number to it, extract the number of reads of each storage index, and build a one-to-one mapping relationship between the unique number and the number of reads. Form an array of the number of reads of all storage indexes, arrange and combine the element values in the array to obtain multiple combinations, each combination contains two sub-arrays, calculate the deviation value of each group, select the two sub-arrays corresponding to the i-th group with the smallest deviation value, and assign the account status data corresponding to the two sub-arrays corresponding to the i-th group to the two SSDs of the SSD pair respectively;
[0072] The above deviation value = |S1 - S2|; wherein S1 is the sum of the element values of one of the two sub-arrays, and S2 is the sum of the element values of the other of the two sub-arrays.
[0073] The above processing unit can also be used to perform the following steps: Figure 2 The detailed or extended solutions of the illustrated method embodiment will not be described in detail here.
[0074] The embodiment of the present application can divide the electronic device into functional units according to the above method example. For example, each functional unit can be divided according to each function, or two or more functions can be integrated into one processing unit. The above integrated unit can be implemented in the form of hardware or in the form of software functional units. It should be noted that the division of units in the embodiment of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation.
[0075] The above embodiments can be implemented in whole or in part by software, hardware, firmware or any other combination. When implemented using software, the above embodiments can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired or wireless means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that contains one or more available media sets. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium. The semiconductor medium can be a solid-state hard disk.
[0076] An embodiment of the present application also provides a computer storage medium, wherein the computer storage medium stores a computer program for electronic data exchange, wherein the computer program enables a computer to execute part or all of the steps of any method described in the above method embodiments, and the above computer includes an electronic device.
[0077] The embodiment of the present application also provides a computer program product, the computer program product includes a non-transitory computer-readable storage medium storing a computer program, the computer program is operable to cause a computer to execute some or all of the steps of any method described in the method embodiment. The computer program product may be a software installation package, and the computer includes an electronic device.
[0078] It should be understood that in the various embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0079] In the several embodiments provided in the present application, it should be understood that the disclosed methods, devices and systems can be implemented in other ways. For example, the device embodiments described above are merely schematic; for example, the division of the units is only a logical function division, and there may be other division methods in actual implementation; for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0080] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0081] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may be physically included separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0082] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform some steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: a USB flash drive, a mobile hard disk, a magnetic disk, an optical disk, a volatile memory or a non-volatile memory. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM) or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of random access memory (RAM) are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM) and direct RAM RAM (DR RAM). Various media that can store program code are available.
[0083] Although the present invention is disclosed as above, the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions without departing from the spirit and scope of the present invention, and can make various changes and modifications, including the combination of the above-mentioned different functions and implementation steps, including software and hardware implementation methods, all of which are within the scope of protection of the present invention.
Claims
1. A method for expanding data storage space based on a solid state drive, characterized in that: The method comprises the following steps: Periodically extract multiple storage information of multiple SSDs, each storage information includes the remaining storage space of each SSD, and arrange the multiple SSDs in descending order according to the remaining storage space to obtain a first SSD sequence; Receive newly written account status data, and if the storage space required by the newly written account status data is less than the remaining storage space of the first SSD in the first SSD sequence, allocate the newly written account status data to the first SSD for storage, and construct a storage index for the newly written account status data, wherein the storage index includes: a storage path, a memory mapping, a write operation lock, a number of used bytes, and a number of allocated bytes. When the write operation lock is yes, copy a replica of the newly written account status data, and replace the storage path and memory mapping of the storage index with the storage path and memory mapping of the replica data; A read instruction for newly written account status data is received, the storage index is extracted, and if the write operation lock in the storage index is negative, the newly written account status data is read according to the storage path and memory mapping; if the write operation lock in the storage index is yes, the copy data is read according to the replaced storage path and memory mapping.
2. The method for expanding data storage space based on a solid state drive according to claim 1, characterized in that: The method further comprises: After the write operation is completed, the write operation lock is restored to negative, the copy data is deleted, and the storage path and memory mapping of the storage index are restored to the storage path and memory mapping before replacement.
3. The method for expanding data storage space based on a solid state drive according to claim 1, characterized in that: The method further comprises: The total number of reads of each SSD within a set period is counted to obtain α total numbers, where α is the total number of SSDs. The α total numbers are arranged in descending order to obtain a first number sequence. The first SSD and the last SSD in the first number sequence are combined into an SSD pair to obtain α / 2 SSD pairs. The two SSDs in each SSD pair are balanced to obtain two balanced SSDs.
4. The method for expanding data storage space based on a solid state drive according to claim 3, characterized in that: The balancing operation specifically includes: Extract each storage index in the SSD pair and give it a unique number, extract the number of reads of each storage index, and construct a one-to-one mapping relationship between the unique number and the number of reads, arrange the number of reads in descending order to obtain a first subsequence, assign the account status data corresponding to the storage index corresponding to the odd bits in the first subsequence to one SSD of the SSD pair, and assign the account status data corresponding to the storage index corresponding to the even bits in the first subsequence to the other SSD of the SSD pair.
5. The method for expanding data storage space based on a solid state drive according to claim 3, characterized in that: The balancing operation specifically includes: Extract each storage index in the SSD pair and assign a unique number to it, extract the number of reads of each storage index, and build a one-to-one mapping relationship between the unique number and the number of reads. Form an array of the number of reads of all storage indexes, arrange and combine the element values in the array to obtain multiple combinations, each combination contains two sub-arrays, calculate the deviation value of each group, select the two sub-arrays corresponding to the i-th group with the smallest deviation value, and assign the account status data corresponding to the two sub-arrays corresponding to the i-th group to the two SSDs of the SSD pair respectively; The above deviation value = |S1 - S2|; wherein S1 is the sum of the element values of one of the two sub-arrays, and S2 is the sum of the element values of the other of the two sub-arrays.
6. A system for expanding data storage space based on a solid state hard disk, characterized in that: The system comprises: An extraction unit, used for periodically extracting multiple storage information of multiple SSDs, each storage information including the remaining storage space of each SSD, and arranging the multiple SSDs in descending order according to the remaining storage space to obtain a first SSD sequence; A receiving unit, used for receiving newly written account status data; a processing unit, configured to allocate the newly written account status data to the first SSD for storage if the storage space required by the newly written account status data is less than the remaining storage space of the first SSD in the first SSD sequence, and construct a storage index for the newly written account status data, wherein the storage index includes: a storage path, a memory mapping, a write operation lock, a number of bytes used, and a number of bytes allocated; and when the write operation lock is yes, copy a replica of the newly written account status data, and replace the storage path and memory mapping of the storage index with the storage path and memory mapping of the replica; The receiving unit is further used to receive a read instruction of the newly written account status data; The processing unit is also used to extract the storage index, and if the write operation lock in the storage index is negative, read the newly written account status data according to the storage path and memory mapping; if the write operation lock in the storage index is yes, read the copy data according to the replaced storage path and memory mapping.
7. The data storage space expansion system based on solid state hard disk according to claim 6, characterized in that: The processing unit is also used to restore the write operation lock to negative after the write operation is completed, delete the copy data, and restore the storage path and memory mapping of the storage index to the storage path and memory mapping before replacement.
8. The data storage space expansion system based on solid state hard disk according to claim 6, characterized in that: The processing unit is further used to count the total number of reads of each SSD within a set period to obtain α total numbers, where α is the total number of SSDs, arrange the α total numbers in descending order to obtain a first number sequence, form an SSD pair with the first SSD and the last SSD in the first number sequence to obtain α / 2 SSD pairs, and perform a balancing operation on the two SSDs in each SSD pair to obtain two balanced SSDs.
9. The data storage space expansion system based on solid state hard disk according to claim 8, characterized in that: The balancing operation specifically includes: Extract each storage index in the SSD pair and give it a unique number, extract the number of reads of each storage index, and construct a one-to-one mapping relationship between the unique number and the number of reads, arrange the number of reads in descending order to obtain a first subsequence, assign the account status data corresponding to the storage index corresponding to the odd bits in the first subsequence to one SSD of the SSD pair, and assign the account status data corresponding to the storage index corresponding to the even bits in the first subsequence to the other SSD of the SSD pair.
10. The data storage space expansion system based on solid state hard disk according to claim 8, characterized in that: The balancing operation specifically includes: Extract each storage index in the SSD pair and assign a unique number to it, extract the number of reads of each storage index, and build a one-to-one mapping relationship between the unique number and the number of reads. Form an array of the number of reads of all storage indexes, arrange and combine the element values in the array to obtain multiple combinations, each combination contains two sub-arrays, calculate the deviation value of each group, select the two sub-arrays corresponding to the i-th group with the smallest deviation value, and assign the account status data corresponding to the two sub-arrays corresponding to the i-th group to the two SSDs of the SSD pair respectively; The above deviation value = |S1 - S2|; wherein S1 is the sum of the element values of one of the two sub-arrays, and S2 is the sum of the element values of the other of the two sub-arrays.
Citation Information
Patent Citations
Solid state disk and data read-write method
CN101777013A
Storage method and reading method of solid state disk mapping relation and solid state disk
CN109684238A