Data storage method, device, equipment and computer readable storage medium
By dynamically adjusting the storage type conversion of storage devices, the problem of poor storage space flexibility is solved, and a balance is achieved between data storage flexibility and the performance, capacity and lifespan of storage devices.
Patent Information
- Application Number
- CN202110875240.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-30
- Publication Date
- 2026-02-06
- Estimated Expiration
- 2041-07-30
AI Technical Summary
In existing storage devices, the areas used for storing random and sequential writes are fixed, resulting in poor storage space flexibility and an inability to meet the balanced performance, capacity, and cost requirements of different business needs.
By obtaining the storage type and space requirements of the data to be stored, the storage type conversion of the storage device can be dynamically adjusted, and the available space of different types of storage devices can be utilized to achieve data storage flexibility.
It improves the flexibility of data storage, ensures sufficient storage space to meet different business needs, and balances the capacity, performance, and lifespan of storage devices.
Smart Images

Figure CN115686347B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to storage technology, and in particular to a data storage method, device, equipment and computer readable storage medium. BACKGROUND
[0002] When data storage is needed, in order to meet various business requirements, the design of the storage medium is required to balance performance, capacity and cost. In order to balance the various business requirements, the NAND Flash-based SSD storage medium must use additional reserved space (OP, Over-Provisioning) to ensure the performance of random write, and about 10% of reserved space is required for read-intensive storage devices, and about 30% of reserved space is required for read-write mixed storage devices; and for sequential write business, basically no OP is required, which maximizes the user available storage capacity. At present, the storage area (or storage device) for storing random write business data and the storage area (or storage device) for storing sequential write business data in the storage device (set) in the electronic device are fixed, and the available storage space of the storage device (set) is also fixed. When different business data storage is performed, the flexibility is poor. SUMMARY
[0003] The embodiments of the present application provide a data storage method, device and computer readable storage medium, which can improve the flexibility of data storage.
[0004] The technical scheme of the embodiments of the present application is as follows:
[0005] The embodiments of the present application provide a data storage method, comprising:
[0006] Obtaining to-be-stored data, and determining a first storage type corresponding to the to-be-stored data and a first storage space size required to be occupied;
[0007] When a first available space size of a first storage device corresponding to the first storage type is smaller than the first storage space size, determining a second available space size of a second storage device corresponding to a second storage type;
[0008] When it is determined that the second storage device meets a storage type conversion condition based on the first available space size, the first storage space size and the second available space size, obtaining a target storage space available in the second storage device;
[0009] Converting the target storage space into the first storage type, and storing the to-be-stored data into the available storage space in the first storage device and the target storage space.
[0010] The embodiments of the present application provide a data storage device, comprising:
[0011] a first obtaining module, configured to obtain to-be-stored data, and determine a first storage type corresponding to the to-be-stored data and a first storage space size required to be occupied;
[0012] a first determining module, configured to determine a second available space size of a second storage device corresponding to a second storage type when a first available space size of a first storage device corresponding to the first storage type is smaller than the first storage space size;
[0013] a second obtaining module, configured to obtain a target storage space available in the second storage device when it is determined that the second storage device meets a storage type conversion condition based on the first available space size, the first storage space size and the second available space size;
[0014] a data storage module, configured to convert the target storage space into the first storage type, and store the to-be-stored data into the available storage space in the first storage device and the target storage space.
[0015] In some embodiments, the apparatus further includes:
[0016] a second determining module, configured to determine a to-be-increased space size based on the first available space size and the first storage space size;
[0017] a third determining module, configured to determine whether the second available space size is greater than or equal to the to-be-increased space size; when the second available space size is greater than or equal to the to-be-increased space size, it is determined that the second storage region meets a storage type conversion condition.
[0018] In some embodiments, when the first storage type is a sequential storage type and the second storage type is a random storage type, the second determining module is further configured to:
[0019] determine a first difference space size between the first available space size and the first storage space size;
[0020] determine a first number of first storage units required to be supplemented based on the first difference space size and a first unit space size, the first unit space size being a space size occupied by a first storage unit of the first storage type;
[0021] determine a second difference space size based on the first number and the first unit space size;
[0022] determine the second difference space size as the to-be-increased space size.
[0023] In some embodiments, when the first storage type is a random storage type and the second storage type is a sequential storage type, the second determining module is further configured to:
[0024] obtain a reserved space ratio corresponding to the random storage type;
[0025] determine a second number of first storage units that need to be supplemented based on the first difference space size, the first unit space size, and the reserved space ratio;
[0026] determine a third difference space size based on the second number and the first unit space size;
[0027] determine the third difference size as the to-be-increased space size.
[0028] In some embodiments, the second obtaining module is further configured to:
[0029] when the second storage device has a continuous available space of the to-be-increased space size, determine the continuous available space of the to-be-increased space size as the target storage space;
[0030] when the second storage device does not have the continuous available space, obtain storage state information of each second storage unit in the second storage device;
[0031] based on the storage state information, perform data migration on stored data in the second storage unit to obtain the target storage space of the to-be-increased space size.
[0032] In some embodiments, the second obtaining module is further configured to:
[0033] based on the storage state information, determine an idle second storage unit and an occupied second storage unit;
[0034] determine a used space size of the occupied second storage unit and an available space size of the occupied second storage unit;
[0035] based on the used space size and the available space size of the occupied second storage unit, perform data transfer between the occupied second storage units to obtain the target storage space of the to-be-increased space size.
[0036] In some embodiments, the apparatus further includes:
[0037] a fourth determining module configured to, when the second available space size is smaller than the to-be-increased space size, determine that the second storage device does not satisfy a storage type conversion condition;
[0038] a fifth determining module, configured to determine a fourth difference space size based on the second available space size and the to-be-increased space size;
[0039] a sixth determining module, configured to determine to-be-deleted data from the first storage device and / or from the second storage device based on storage time and access information of stored data in the first storage device and / or based on storage time and access information of stored data in the second storage device;
[0040] a first output module, configured to output prompt information of deleting data when a storage space size occupied by the to-be-deleted data is greater than or equal to the fourth difference space size;
[0041] a deleting module, configured to delete the to-be-deleted data in response to a received deleting instruction.
[0042] In some embodiments, the apparatus further includes:
[0043] a seventh determining module, configured to determine a minimum expansion space size based on a storage space size occupied by the to-be-deleted data and the fourth difference space size when the storage space size occupied by the to-be-deleted data is less than the fourth difference space size;
[0044] a second output module, configured to output prompt information that storage space is insufficient and needs to be expanded, the prompt information carrying the minimum expansion space size.
[0045] In some embodiments, the apparatus further includes:
[0046] a first control module, configured to control to pause input and output operations when the second storage region satisfies a storage type conversion condition;
[0047] Correspondingly, after storing the to-be-stored data into the available storage space in the first storage region and the target storage space, the apparatus further includes:
[0048] a second control module, configured to control to resume the input and output operations.
[0049] In some embodiments, the first determining module is further configured to:
[0050] predict an access heat value of the to-be-stored data based on the to-be-stored data;
[0051] determine that the first storage type is a random storage type when the access heat value is higher than a preset heat threshold value;
[0052] determine that the first storage type is a sequential storage type when the access heat value is lower than or equal to the heat threshold value.
[0053] In some embodiments, the apparatus further comprises:
[0054] a third obtaining module, configured to obtain respective second storage identifiers corresponding to respective second storage units included in the target storage space;
[0055] a fourth obtaining module, configured to obtain a maximum storage identifier of the first storage units in the first storage device;
[0056] an updating module, configured to update storage unit information in the first storage device and the second storage device based on the respective second storage identifiers and the maximum storage identifier.
[0057] An embodiment of the present application provides an electronic device, comprising:
[0058] a memory, configured to store executable instructions;
[0059] a processor, configured to execute the executable instructions stored in the memory, so as to implement the data storage method provided by the embodiment of the present application.
[0060] An embodiment of the present application provides a computer readable storage medium, which stores executable instructions, and is used to cause a processor to execute the data storage method provided by the embodiment of the present application.
[0061] The embodiment of the present application has the following beneficial effects:
[0062] After obtaining the to-be-stored data, first, the first storage type corresponding to the to-be-stored data and the first storage space size required to be occupied are determined, when the first available space size of the first storage device corresponding to the first storage type is smaller than the first storage space size, it is indicated that the first storage device does not have enough storage space, at this time, the second available space size of the second storage device corresponding to the second storage type can be determined, when it is determined that the second storage device satisfies the storage type conversion condition based on the first available space size, the first storage space size and the second available space size, the target storage space available in the second storage device is obtained, the target storage space is converted into the first storage type, and the to-be-stored data is stored into the available storage space in the first storage device and the target storage space, in this way, the corresponding storage device can be determined based on the storage type of the to-be-stored data, and when the storage space is insufficient, the available storage space of the storage device of other types can be updated to the storage type corresponding to the to-be-stored data through storage type conversion, so that enough storage space is ensured to store the to-be-stored data, and the flexibility of data storage can be improved. BRIEF DESCRIPTION OF DRAWINGS
[0063] Figure 1Ais a realization schematic diagram of a NAND write operation in the related art;
[0064] Figure 1B is a schematic diagram of sequential writing using ZNS technology;
[0065] Figure 1C is a comparison schematic diagram of CMR and SMR regions in a mechanical hard disk;
[0066] Figure 2 is a network architecture schematic diagram of a data storage system 100 provided by an embodiment of the present application;
[0067] Figure 3 is a structure schematic diagram of a server 400 provided by an embodiment of the present application;
[0068] Figure 4 is a realization flow schematic diagram of a data storage method provided by an embodiment of the present application;
[0069] Figure 5 is another realization flow schematic diagram of a data storage method provided by an embodiment of the present application;
[0070] Figure 6 is still another realization flow schematic diagram of a data storage method provided by an embodiment of the present application;
[0071] Figure 7 is another realization flow schematic diagram of a data storage method provided by an embodiment of the present application;
[0072] Figure 8 is still another realization flow schematic diagram of a data storage method provided by an embodiment of the present application. DETAILED DESCRIPTION
[0073] In order to make the purposes, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the drawings, and the described embodiments should not be regarded as limiting the present application, and all other embodiments obtained by those of ordinary skill in the art without making any creative labor fall within the scope of protection of the present application.
[0074] In the following description, “some embodiments” are related to a subset of all possible embodiments, but it can be understood that “some embodiments” can be the same or different subsets of all possible embodiments, and can be combined with each other without conflict.
[0075] In the following description, the terms "first", "second", "third" are merely used to distinguish similar objects, and do not represent a specific order or sequence of the objects. Understandably, the "first", "second", "third" can be interchanged in a specific order or sequence as allowed, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein.
[0076] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used in the specification is for describing the embodiments of the application only and is not intended to limit the application.
[0077] The relevant data collection and processing in the embodiments of the application should strictly comply with the requirements of relevant laws and regulations, obtain the informed consent or separate consent of the personal information subject, and carry out subsequent data use and processing behavior within the scope of authorization of laws and regulations and the personal information subject.
[0078] Before further detailing the embodiments of the application, the terms and phrases involved in the embodiments of the application are explained, and the terms and phrases involved in the embodiments of the application are applicable to the following explanations.
[0079] 1) Solid State Disk (SSD), also known as solid state drive, is a hard disk made of solid state electronic storage chip array.
[0080] 2) Zoned Namespace (ZNS), a technical standard of SSD, which stores data in zones and performs sequential writing in each zone.
[0081] 3) Over-Provisioning (OP), is the space reserved for solid state disk at the factory, generally accounts for more than 7% of the total capacity of solid state disk. Generally, this part of capacity cannot be changed.
[0082] 4) Logical Block Address (LBA), a general mechanism for describing the data block on the computer storage device, generally used in auxiliary memory devices such as hard disks. LBA can mean the address of a data block or the data block pointed to by an address. A logical block on a computer today is usually 512B or 4096B bit group.
[0083] 5) Zone based on ZNS technology, no OP space, only supports sequential writing.
[0084] 6) Normal Zone, Zone of non-ZNS technology SSD, with a certain OP ratio, supporting random write.
[0085] 7) Hard Disk (HDD, Hard Disk Controller), the most basic computer storage, commonly known as computer hard disk C, D partition belongs to hard disk drive.
[0086] 8) Shingled Magnetic Recording (SMR, Shingled Magnetic Recording), a high-capacity magnetic disk using a new type of magnetic storage technology. The SMR disk partially overlaps the data tracks on the disk, just like the tiles on the roof, and this technology is called Shingled Magnetic Recording technology. The technology has very small changes in manufacturing processes, but it can greatly increase the storage density of the disk.
[0087] 9) Conventional Magnetic Recording (CMR, Conventional Magnetic Recording), with a protective gap between tracks, and data is not repeatedly written.
[0088] In order to better understand the data storage method provided by the embodiments of the present application, first, the data storage method in the related art and the existing shortcomings are described.
[0089] In the related art, if the storage in the electronic device is SSD, for the storage of sequential write business data, ZNS technology is used to store data to ZNS Zone, and for the storage of random write business data, data is stored to Normal Zone. The storage medium of the SSD computer flash device (NAND) itself determines that it needs to be erased before writing (unlike the magnetic medium of the HDD, which can be directly overwritten), as shown in Figure 1A The erasing of NAND is in units of blocks 110 (usually more than 200 pages), but the writing is in units of pages 111 (about 16KB), so there is often a phenomenon that a page needs to be written, but the entire block needs to be erased first, which has a great impact on the service life of NAND.
[0090] The SSD of the electronic device needs to meet various business models, and the design of the SSD needs to balance performance, capacity and cost. In order to balance various business models, additional OP (guaranteeing the performance of random write) must be used, and OP is the user's unusable capacity.
[0091] The sequential write feature of ZNS technology can basically not require OP, maximizing the user's available storage capacity. Figure 1B A schematic diagram for using ZNS technology sequential write is shown in Figure 1BAs shown, ZNS Zone3 121 is the region currently being written, 1211 is the occupied region in ZNS Zone3 121, and 1212 is the unoccupied region. When a write request is received, data is written in 1212 in sequence, and there is no phenomenon of erasing an entire block for writing a page, thereby prolonging the actual service life of NAND.
[0092] Figure 1C A schematic diagram for comparison of CMR regions and SMR regions in mechanical hard disks is shown in FIG. 1B. Figure 1C As shown, in the SMR region 131, the data tracks partially overlap, like tiles on a roof, and therefore this technology is called shingled magnetic recording technology. This technology has very small variations in manufacturing processes, but can greatly improve the storage density of the disk. Similar to the ZNS technology in SSDs, it supports sequential writing. In the CMR region 132, there is a protective spacing between the tracks, and data is not repeatedly written, so it supports random writing.
[0093] In the related art, the ZNS Zone and the Normal Zone in SSDs and the CMR region and the SMR region in HDDs are all pre-set, and therefore the available storage space is fixed.
[0094] The embodiments of the present application provide a data storage method, device, equipment and computer readable storage medium, which can improve the flexibility of storing data. The following describes an exemplary application of an electronic device provided by the embodiments of the present application. The device provided by the embodiments of the present application can be implemented as a notebook computer, a tablet computer, a desktop computer, a set-top box, a mobile device (for example, a mobile phone, a portable music player, a personal digital assistant, a dedicated message device, a portable game device) and various types of user terminals, and can also be implemented as a server. The following describes an exemplary application when the device is implemented as a server.
[0095] Referring to Figure 2 , Figure 2 is a schematic diagram of a network architecture of a data storage system 100 provided by the embodiments of the present application, as shown in Figure 2 The network architecture includes a terminal 200, a network 300 and a server 400, wherein the terminal 200 is connected to the server 200 through the network 300, and the network 300 can be a wide area network or a local area network, or a combination of the two.
[0096] The terminal 200 can send the to-be-stored data to the server 400. After the server 400 receives the to-be-stored data, the server 400 first determines the first storage type corresponding to the to-be-stored data and the first storage space size to be occupied. When the first storage device corresponding to the first storage type has sufficient storage space, the to-be-stored data is directly stored. When the first storage device does not have sufficient storage space, the second available space size corresponding to the second storage type is determined. When the first available space size and the second available space size are sufficient to store the to-be-stored data, the target storage space is obtained from the second storage device, and the target storage space is converted into the first storage type, so that the to-be-stored data is stored in the target storage space and the first available space. In this way, through the mutual conversion of the storage types between the first storage device and the second storage device, sufficient storage space can be ensured for storage when data storage is required, the success rate of data storage is improved, and the flexibility of data storage is improved.
[0097] In some embodiments, the server 400 can be a standalone physical server, or a server cluster or a distributed system formed by multiple physical servers, or a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDNs, and basic cloud computing services such as big data and artificial intelligence platforms. When the server 400 is a server cluster, the first storage device can be a storage device in part of the servers in the server cluster, and the second storage device can be a storage device in another part of the servers in the server cluster.
[0098] In Figure 2 The network architecture shown is a data storage method applied to a scenario in which a terminal stores data in a server. The server can be a single physical server or a server cluster. In some embodiments, the data storage method can also be applied to a scenario in which a terminal stores data in a storage device of the terminal. In this case, the first storage device and the second storage device can be different hard disks in the terminal, or the first storage device and the second storage device can be different storage areas in the same hard disk in the terminal.
[0099] Referring to Figure 3 , Figure 3 is a structural schematic diagram of the server 400 provided by an embodiment of the present application, Figure 3 The server 400 shown in the figure includes at least one processor 410, a memory 440, and at least one network interface 420. The various components in the server 400 are coupled together through a bus system 430. It can be understood that the bus system 430 is used to realize the connection and communication between the components. The bus system 430 includes not only a data bus but also a power bus, a control bus, and a status signal bus. However, for the purpose of clear illustration, only the data bus is shown in the figure.Figure 3 Various buses are shown as bus system 430.
[0100] The processor 410 can be an integrated circuit chip that has a processing capability of signals, such as a general processor, a digital signal processor (DSP), or other programmable logic device, discrete gate or transistor logic device, discrete hardware component, etc., and the general processor can be a microprocessor or any conventional processor.
[0101] The memory 440 can be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state memory, hard disk drives, optical drives, etc. The memory 440 optionally includes one or more storage devices physically located in proximity to the processor 410.
[0102] The memory 440 includes volatile memory or non-volatile memory, and can also include both volatile and non-volatile memory. The non-volatile memory can be read-only memory (ROM), and the volatile memory can be random access memory (RAM). The memory 440 described in the embodiments of the present application is intended to include any suitable type of memory.
[0103] In some embodiments, the memory 440 is capable of storing data to support various operations, examples of which include programs, modules, and data structures or subsets or supersets thereof, which are exemplarily illustrated below.
[0104] The operating system 441 includes system programs for processing various basic system services and performing hardware-related tasks, such as a framework layer, a core library layer, a driver layer, etc., for implementing various basic services and processing hardware-based tasks;
[0105] The network communication module 442 is used to reach other computing devices via one or more (wired or wireless) network interfaces 420, and exemplary network interfaces 420 include Bluetooth, wireless compatibility authentication (WiFi), and universal serial bus (USB), etc.
[0106] In some embodiments, the apparatus provided by the embodiments of the present application can be realized in software, Figure 3Data storage 443 stored in memory 440 is shown, which can be software in the form of programs and plug-ins, etc., including the following software modules: a first acquisition module 4431, a first determination module 4432, a second acquisition module 4433, and data storage 4434, which are logical, and thus can be combined or further split according to the implemented functions.
[0107] The functions of the various modules will be described below.
[0108] In some embodiments, the apparatus provided by the embodiments of the present application can be implemented in a hardware manner. For example, the apparatus provided by the embodiments of the present application can be a processor in the form of a hardware decoding processor, which is programmed to execute the data storage method provided by the embodiments of the present application. For example, the processor in the form of a hardware decoding processor can use one or more application specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field programmable gate arrays (FPGAs), or other electronic elements.
[0109] The data storage method provided by the embodiments of the present application will be described in conjunction with an exemplary application and implementation of an electronic device provided by the embodiments of the present application.
[0110] The embodiments of the present application provide a data storage method, which is applied to an electronic device, which can be a terminal or a server. Figure 4 is a flowchart of an implementation of the data storage method provided by the embodiments of the present application, which will be described in conjunction with Figure 4 the steps shown.
[0111] In step S101, the data to be stored is acquired, and a first storage type corresponding to the data to be stored and a first storage space size required to be occupied are determined.
[0112] When the method is implemented by a server, the data to be stored can be acquired by the server receiving a data storage request sent by a terminal to acquire the data to be stored. When the method is implemented by a terminal, the data to be stored can be acquired by the terminal receiving a data storage instruction and acquiring the data to be stored based on the data storage instruction.
[0113] In implementation, the first storage type corresponding to the to-be-stored data can be determined by first predicting the hotness value of the to-be-stored data and determining the storage type according to whether the hotness value is greater than a hotness threshold. The first storage type can be a random storage type or a sequential storage type. When the hotness value of the to-be-stored data is high, it indicates that the to-be-stored data is likely to be read and written, and thus the requirement for read-write speed is relatively high. In this case, the first storage type can be determined as a random storage type. When the hotness value of the to-be-stored data is low, it indicates that the to-be-stored data is less likely to be read and written, and thus the requirement for read-write speed is not high. In this case, the first storage type can be determined as a sequential storage type.
[0114] In implementation, the first storage space size required by the to-be-stored data can be obtained based on an attribute value corresponding to an attribute of "occupied space" in the attribute information of the to-be-stored data.
[0115] In step S102, when the first available space size is less than the first storage space size, a second available space size of a second storage device corresponding to a second storage type is determined.
[0116] The first available space size is a free space size of a first storage device corresponding to the first storage type, and the second available space size is a space size not occupied in a second storage device corresponding to the second storage type. The first storage device can be different hard disks in the same electronic device, one of which is a ZNS SSD and the other of which is a Normal SSD. The ZNS SSD performs sequential storage based on the ZNS technology, and the Normal SSD performs random storage and has a reserved space. Alternatively, one of the hard disks is an SMR HDD, and the other is a CMR HDD. The first storage device can also be different storage areas in the same hard disk in the same electronic device, such as a ZNS Zone and a Normal Zone in the same hard disk. The first storage device can also be storage devices in different electronic devices, one of which performs sequential storage based on the ZNS technology, and the other of which performs random storage.
[0117] In some embodiments, after step S101, the first available space size is obtained, and it is determined whether the first available space size is less than the first storage space size. If the first available space size is not less than the first storage space size, it indicates that the first storage device has sufficient storage space, and the to-be-stored data can be stored in the first storage device according to the storage rule corresponding to the first storage type. When the first available space is less than the first storage space, it indicates that the first storage device does not have sufficient storage space, and storage type conversion is required to obtain more storage space.
[0118] In step S103, when it is determined that the second storage device meets the storage type conversion condition based on the first available space size, the first storage space size, and the second available space size, a target storage space available in the second storage device is obtained.
[0119] In implementation, the first available space size and the first storage space size are used to determine a to-be-increased space size, and when the second available space size is greater than or equal to the to-be-increased space size, it is determined that the second storage device meets the storage type conversion condition, and a target storage space available in the second storage device is obtained. The target storage space can have the same size as the to-be-increased space size, and in some embodiments, the target storage space can also have the same size as the to-be-increased space size.
[0120] In step S104, the target storage space is converted into the first storage type, and the to-be-stored data is stored in the available storage space in the first storage device and the target storage space.
[0121] In implementation, step S104 can be implemented by formatting the target storage space to convert the target storage space from the second storage type into the first storage type, so that the first storage type storage space can be used to store data, and the to-be-stored data is stored in the available storage space in the first storage device and the target storage space according to the storage rule corresponding to the first storage type.
[0122] In the data storage method provided in the embodiments of the present application, after obtaining the to-be-stored data, the first storage type corresponding to the to-be-stored data and the first storage space size required to be occupied are first determined. When the first available space size of the first storage device corresponding to the first storage type is less than the first storage space size, it indicates that the first storage device does not have enough storage space. At this time, the second available space size of the second storage device corresponding to the second storage type can be determined. When it is determined that the second storage device meets the storage type conversion condition based on the first available space size, the first storage space size, and the second available space size, a target storage space available in the second storage device is obtained, and the target storage space is converted into the first storage type, and the to-be-stored data is stored in the available storage space in the first storage device and the target storage space. In this way, the corresponding storage device can be determined based on the storage type of the to-be-stored data, and when the storage space is insufficient, the available storage space of the storage device of other types can be updated to the storage type corresponding to the to-be-stored data through storage type conversion, so as to ensure that there is enough storage space to store the to-be-stored data, and the flexibility of data storage can be improved, and a storage solution balancing the capacity, performance, and life of the storage device can be provided.
[0123] In some embodiments, the "determining the first storage type corresponding to the to-be-stored data" in the step S101 can be implemented through the following steps S1011-S1013, which will be described below.
[0124] In the step S1011, the access heat value of the to-be-stored data is predicted based on the to-be-stored data.
[0125] In the implementation of the step S1011, the access heat value of the to-be-stored data can be predicted based on the identifier of the to-be-stored data and / or according to the data content in the to-be-stored data. The access heat value can reflect the probability of the to-be-stored data being accessed or the number of times of being accessed.
[0126] In the step S1012, when the access heat value is higher than a preset heat threshold, the first storage type is determined as a random storage type.
[0127] When the access heat value is higher than the heat threshold, it indicates that the to-be-stored data has a high possibility of being read and written, and thus has a relatively high requirement on the read and write speed. In this case, the first storage type is determined as the random storage type, and the to-be-stored data can be stored randomly without being stored in the address sequence. The storage device of the random storage type needs to be provided with a reserved space.
[0128] In the step S1013, when the access heat value is lower than or equal to the heat threshold, the first storage type is determined as a sequential storage type.
[0129] When the access heat value of the to-be-stored data is lower than or equal to the heat threshold, it indicates that the to-be-stored data has a low possibility of being read and written, and thus has a low requirement on the read and write speed. In this case, the first storage type can be determined as the sequential storage type, and the to-be-stored data needs to be read and written in the address sequence. The storage device corresponding to the sequential storage type does not need to be provided with a reserved space.
[0130] In the steps S1011-S1013, the first storage type of the to-be-stored data can be determined by predicting the access heat value of the to-be-stored data. In some embodiments, the first storage type of the to-be-stored data can also be directly specified.
[0131] In some embodiments, as shown in FIG. 2, before the step S103, the following steps S201 and S202 also need to be performed, which will be described below in combination with FIG. 2. Figure 5 Figure 5 Before the step S103, the following steps S201 and S202 also need to be performed, which will be described below in combination with FIG. 2.
[0132] In the step S201, the to-be-added space size is determined based on the first available space size and the first storage space size.
[0133] The step, when implemented, can have different implementations based on different first storage types. When the first storage type is a sequential storage type and the second storage type is a random storage type, it indicates that part of the storage space in the second storage device needs to be converted from the random storage type to the sequential storage type. Since the sequential storage type does not need to set a reserved space, the reserved space does not need to be considered when determining the size of the space to be added. When the first storage type is a random storage type and the second storage type is a sequential storage type, it indicates that part of the storage space in the second storage device needs to be converted from the sequential storage type to the random storage type. Since the random storage type needs to set a reserved space, the reserved space needs to be considered when determining the size of the space to be added.
[0134] In step S202, it is determined whether the second available space size is greater than or equal to the size of the space to be added.
[0135] When the second available space size is greater than or equal to the size of the space to be added, it is determined that the second storage device meets the storage type conversion condition, and step S103 is entered. In some embodiments, when the second available space size is less than the size of the space to be added, it indicates that the second storage device does not meet the storage type conversion condition, and data deletion or expansion can be prompted.
[0136] In some embodiments, the first storage type can be a sequential storage type or a random storage type. Step S201, when implemented, can have different implementations based on different first storage types corresponding to the data to be stored. The following describes two implementations.
[0137] When the first storage type is a sequential storage type and the second storage type is a random storage type, step S201 "determining the size of the space to be added based on the first available space size and the first storage space size" can be implemented through the following steps S2011A to S2014A, which are described below.
[0138] In step S2011A, a first difference space size between the first available space size and the first storage space size is determined.
[0139] In implementation, the first difference space size is the value obtained by subtracting the first available space size from the first storage space size. For example, when the first storage space is 900 MB and the first available space size is 400 MB, the first difference space size is 500 MB.
[0140] In step S2012A, a first number of first storage units that need to be supplemented is determined based on the first difference space size and the first unit space size.
[0141] The first unit space size is a space size occupied by a first storage unit of the first storage type. In implementation, the first storage device can be divided into multiple storage units or storage areas, and each storage unit occupies the same storage space. In the embodiments of the present application, the first storage type is a sequential storage type, and the first storage unit can be a ZNS Zone.
[0142] In step S2012A, the first difference space size can be divided by the first unit space size, and the obtained quotient can be rounded up to obtain the first number. In the embodiments of the present application, the first unit space size is 200M. In the above example, the first number of the first storage unit to be supplemented is determined to be 3.
[0143] In step S2013A, the second difference space size is determined based on the first number and the first unit space size.
[0144] In implementation, the product of the first number and the first unit space size can be determined as the second difference size. In the above example, the first number is 3, and the first unit space size is 200M. Therefore, the second difference space size obtained at this time is 600M.
[0145] In step S2014A, the second difference space size is determined as the space size to be increased.
[0146] In steps S2011A to S2014A, since the storage units are divided in the first storage device, when determining the space size to be increased, the first number of the first storage unit to be increased is first determined, and then the actual space size to be increased is determined based on the first number. The implementation provided in steps S2011A to S2014A is applicable to the scenario that the first storage device and the second storage device are located in the same storage hard disk of the same electronic device, the first storage device has multiple first storage units, and the second storage device has multiple second storage units.
[0147] In some embodiments, when the first storage device and the second storage device are located in different storage hard disks of the same electronic device, or the first storage device and the second storage device are located in different electronic devices, the first difference space size can be directly determined as the space size to be increased.
[0148] When the first storage type is a random storage type and the second storage type is a sequential storage type, step S201“determining the space size to be increased based on the first available space size and the first storage space size” can be implemented through steps S2011B to S2014B, which will be described below.
[0149] Step S2011B, obtaining a reserved space ratio corresponding to the random storage type.
[0150] The reserved space ratio can be pre-set when the storage device is manufactured, or can be set by the user, but when set by the user, it needs to be set within the range of the specified minimum ratio and maximum ratio.
[0151] Step S2012B, determining a second number of first storage units that need to be supplemented based on the first difference value space size, the first unit space size, and the reserved space ratio.
[0152] When the first storage type is the random storage type, the first storage unit can be the Normal Zone, and the first unit space size includes the reserved space, and then the first difference value space size is the actual space size that can be occupied excluding the reserved space. In implementation, a fifth difference value space size including the reserved space can be first determined based on the first difference value space size and the reserved space ratio, and then the fifth difference value space size is divided by the first unit space size, and the obtained quotient is rounded up to obtain the second number.
[0153] For example, the first difference value space size is 500MB, and the reserved space ratio is 20%, and then the fifth difference value space size is obtained by the first difference value space size / (1-reserved space ratio), that is, 500 / (1-20%) = 625MB, and at this time, assuming that the first unit size corresponding to the storage unit of the random storage type is also 200MB, then 625 / 200 is obtained 3.125, and then the second number is rounded up to 4.
[0154] Step S2013B, determining a third difference value space size based on the second number and the first unit space size.
[0155] Step S2013, in implementation, the product of the second number and the first unit space size can be determined as the third difference value space size. In the above example, the second number is 4, and the first unit space size is 200MB, and then the third difference value space size is 800MB.
[0156] Step S2014B, determining the third difference value size as the to-be-increased space size.
[0157] The implementation manners provided by steps S2011B to S2014B are applicable to a scenario where the first storage device and the second storage device are located in the same storage hard disk of the same electronic device, the first storage device has a plurality of first storage units (Normal Zone), and the second storage device has a plurality of second storage units (ZNS Zone). Since the ZNS Zone without reserved space is converted into the Normal Zone with reserved space, the fifth difference space size including the reserved space needs to be determined by using the reserved space ratio and the first difference space size, so as to determine a second number of first storage units that need to be added based on the fifth difference space size, and then determine an actual space size that needs to be added based on the second number.
[0158] In some embodiments, when the first storage device and the second storage device are located in different storage hard disks of the same electronic device, or the first storage device and the second storage device are located in different electronic devices, if the storage units are not divided, the fifth difference space size can be directly determined as the space size to be added.
[0159] In some embodiments, Figure 4 The step S103 of obtaining the target storage space available in the second storage device can be implemented by the following steps.
[0160] In step S1031, it is determined whether the second storage device has continuous available storage space of the space size to be added.
[0161] In the embodiments of the present application, when the second storage device has continuous available storage space of the space size to be added, it is indicated that data migration is not needed and data can be directly stored, and in this case, step S1032 is entered; when the second storage device does not have continuous available storage space of the space size to be added, it is indicated that data migration is needed before data storage, and in this case, step S1033 is entered.
[0162] In step S1032, the continuous available storage space of the space size to be added is determined as the target storage space.
[0163] In step S1033, storage state information of each second storage unit in the second storage device is obtained.
[0164] The storage state information includes, but is not limited to, used storage space size, available storage space size, and start address of available storage space.
[0165] In step S1034, based on the storage state information, data migration is performed on the stored data in each second storage unit, to obtain the target storage space of the space size to be added.
[0166] In practical applications, the step S1034 can be implemented by the following steps:
[0167] In step S341, the idle second storage units and the occupied second storage units are determined based on the storage state information.
[0168] The idle second storage unit refers to a second storage unit that is not occupied at all, and the occupied second storage unit refers to a second storage unit that is occupied in whole or in part. In the implementation of step S341, whether the available storage space size in the storage state information is equal to the maximum available storage space size in the second storage unit can be used to determine the idle second storage unit and the occupied second storage unit.
[0169] In step S342, the used space size of the occupied second storage unit and the available space size of the occupied second storage unit are determined.
[0170] In the implementation of step S342, the used space size and the available space size can be determined based on the storage state information of the occupied second storage unit.
[0171] In step S343, data is transferred between the occupied second storage units based on the used space size and the available space size of the occupied second storage unit, and the target storage space with the to-be-increased space size is obtained.
[0172] In the implementation of step S343, the used space size and the available space size of the occupied second storage unit can be used to determine the source storage unit and the target storage unit from the occupied second storage unit, and the data in the source storage unit can be migrated to the target storage unit. Finally, the data in the source storage unit is migrated out, so as to obtain an idle source storage unit. When the data in the source storage unit cannot be migrated out at one time, the data migration can be performed repeatedly until the target storage space with the to-be-increased space size is obtained.
[0173] When the source storage unit and the target storage unit are determined from the occupied second storage unit, the occupied second storage units can be sorted according to the used space size to obtain a sorting result, and then the target storage unit and the source storage unit can be determined according to the available space size of the second storage unit in front of the sorting and the used space size of the second storage unit behind the sorting. Finally, the total available space size of the target storage unit is greater than or equal to the total occupied space size of the source storage unit.
[0174] For example, there are four occupied second storage units, the first occupied second storage unit has a used space size of 150 MB and an unoccupied space size of 50 MB, the second occupied second storage unit has a used space size of 100 MB and an unoccupied space size of 100 MB, the third occupied second storage unit has a used space size of 80 MB and an unoccupied space size of 120 MB, and the fourth occupied second storage unit has a used space size of 20 MB and an unoccupied space size of 180 MB. If the required to-be-increased space size is 400 MB, then two of the four occupied second storage units need to be migrated. In actual implementation, the first and second occupied second storage units can be determined as target storage units, and the third and fourth occupied second storage units can be determined as source storage units. In data migration, the data in the fourth occupied second storage unit can be migrated to the first occupied second storage unit, and the data in the third occupied second storage unit can be migrated to the second occupied second storage unit. In this way, the first occupied second storage unit has a used space size of 170 MB and an unoccupied space size of 30 MB, and the second occupied second storage unit has a used space size of 180 MB and an unoccupied space size of 20 MB. The third and fourth second storage units are idle second storage units, and thus 400 MB of target storage space is obtained.
[0175] In some embodiments, after obtaining the target storage space available in the second storage device or converting the target storage space into the first storage type, the following steps can be further performed:
[0176] In step S401, the second storage identifiers corresponding to the second storage units included in the target storage space are obtained.
[0177] Suppose that the second storage identifiers corresponding to the second storage units in the target storage space are 45 and 46 respectively.
[0178] In step S402, the maximum storage identifier of the first storage unit in the first storage device is obtained.
[0179] For example, there are 100 first storage units in the first storage device, and the corresponding first storage identifiers are 0 to 99. That is, the maximum storage identifier of the first storage unit is 99.
[0180] In step S403, the storage unit information in the first storage device and the second storage device is updated based on the second storage identifiers and the maximum storage identifier.
[0181] The step S403, when implemented, can be updating the storage unit information in the second storage device based on each second storage identifier, further can be deleting each second storage identifier from the storage unit information of the second storage device, updating the storage unit information in the first storage device based on the maximum storage identifier and each second storage identifier. When implemented, the number of first storage identifiers to be added can be determined based on each second storage identifier, and then a new first storage identifier is determined for each second storage unit based on the maximum storage identifier and the number of first storage identifiers to be added.
[0182] Through the steps S401 to S403 described above, the target storage space or the storage unit information in the storage devices corresponding to the first storage type and the second storage type can be updated after the storage type conversion of the target storage space, so as to ensure the accuracy of the storage information, and then ensure that the data can be accurately read and written.
[0183] Based on the foregoing embodiments, the embodiments of the present application further provide a data storage method, which is applied to Figure 2 the network architecture shown in the figure, Figure 6 for another implementation process of the data storage method provided by the embodiments of the present application, the following will be described in combination with Figure 6 the method provided by the embodiments of the present application.
[0184] Step S601, the terminal sends the to-be-stored data to the server.
[0185] Step S602, the server determines the first storage type corresponding to the to-be-stored data and the first storage space size to be occupied.
[0186] Step S603, the server judges whether the first available space size of the first storage device corresponding to the first storage type is less than the first storage space size.
[0187] When the first available space size is greater than or equal to the first storage space size, it means that there is enough storage space in the first storage device to store the to-be-stored data, and at this time, step S604 is entered; when the first available space size is less than the first storage space size, it means that there is not enough storage space in the first storage device to store the to-be-stored data, and at this time, step S605 is entered.
[0188] Step S604, the server stores the to-be-stored data to the first storage device.
[0189] Step S605, the server determines the second available space size of the second storage device corresponding to the second storage type.
[0190] Step S606, the server determines a to-be-increased space size based on the first available space size and the first storage space size.
[0191] Step S607, the server determines whether the second available space size is greater than or equal to the to-be-increased space size.
[0192] When the second available space size is greater than or equal to the to-be-increased space size, it is determined that the second storage area satisfies the storage type conversion condition, and step S608 is entered; when the second available space size is less than the to-be-increased space size, it is determined that the second storage area does not satisfy the storage type conversion condition, and step S613 is entered.
[0193] Step S608, the server controls to suspend input / output operations.
[0194] In the embodiments of the present application, in order to avoid read / write errors caused by input / output operations during storage type conversion, it is necessary to control to suspend input / output operations.
[0195] Step S609, the server acquires a target storage space available in the second storage device.
[0196] Step S610, the server converts the target storage space into the first storage type, and stores the to-be-stored data into the available storage space in the first storage device and the target storage space.
[0197] Step S611, the server controls to resume input / output operations.
[0198] In the embodiments of the present application, after the target storage space is converted into the first storage type, it is indicated that the storage type conversion has been completed, and input / output operations can be controlled to be resumed.
[0199] Step S612, the server determines a fourth difference space size based on the second available space size and the to-be-increased space size.
[0200] When it is determined that the second storage device does not satisfy the storage type conversion condition, it is indicated that the sum of the available spaces in the first storage device and the second storage device is also insufficient to store the to-be-stored data, and the fourth difference space size is determined by subtracting the second available space size from the to-be-increased space size, which is the size of the space occupied by the data to be deleted.
[0201] Step S613, the server determines to-be-deleted data from the first storage device and / or from the second storage device based on storage time and access information of the stored data in the first storage device and / or based on storage time and access information of the stored data in the second storage device.
[0202] When implementing step S613, the data to be deleted can first be determined from the first storage device based on the storage time and access information of the data already stored in the first storage device. If the storage space occupied by the data to be deleted is greater than or equal to the size of the fourth difference space, then it is not necessary to determine the data to be deleted from the second storage device. If the storage space occupied by the data to be deleted determined from the first storage device is less than the size of the fourth difference space, the data to be deleted can continue to be determined from the second storage device.
[0203] In some embodiments, the data to be deleted is determined from the first storage device based on the storage time and access information of the data already stored in the first storage device. In this implementation, data in the first storage device whose storage time is longer than the current time and whose access count is less than a preset number of times can be determined as data to be deleted.
[0204] In step S614, the server determines whether the storage space occupied by the data to be deleted is less than the size of the fourth difference space.
[0205] When the storage space occupied by the data to be deleted is greater than or equal to the size of the fourth difference space, it means that enough storage space can be obtained after deleting the data to be deleted, and then proceed to step S615; when the storage space occupied by the data to be deleted is less than the size of the fourth difference space, it means that enough storage space cannot be obtained even after deleting the data to be deleted, and then proceed to step S618.
[0206] In step S615, the server outputs a message indicating that the data has been deleted.
[0207] In implementation, it can be as follows: Figure 6 As shown, the server sends a prompt message to the terminal to delete data. This prompt message may include the data identifier of the data to be deleted. After receiving the prompt message, the terminal can either confirm the deletion or send a deletion command to the server; otherwise, it can send a command to the server to refuse deletion.
[0208] In step S616, the server responds to the received deletion command and deletes the data to be deleted.
[0209] In some embodiments, after deleting the data to be deleted, the server has enough storage space to store the data to be stored, and the data storage process can be executed subsequently.
[0210] Step S617: The server determines the minimum expansion space size based on the storage space occupied by the data to be deleted and the fourth difference space size.
[0211] In implementation, the fourth difference value space size can be subtracted from the storage space size occupied by the data to be deleted, so as to obtain the minimum expansion space size.
[0212] In step S618, the server outputs prompt information that the storage space is insufficient and needs to be expanded.
[0213] The prompt information carries the minimum expansion space size. In implementation of step S618, the server outputs prompt information that the storage space is insufficient and needs to be expanded, as shown in FIG. 6B, the server can send the prompt information to the terminal. Figure 6 In some embodiments, after receiving the prompt information, the terminal can perform expansion based on the minimum expansion space size carried in the prompt information. If the terminal does not perform expansion temporarily, the data to be stored fails to be stored.
[0214] In the data storage method provided in the embodiments of the present application, after obtaining the data to be stored, the first storage type corresponding to the data to be stored and the first storage space size required to be occupied are determined first. When the first available space size of the first storage device corresponding to the first storage type is smaller than the first storage space size, it is indicated that the first storage device does not have enough storage space. At this time, the second available space size of the second storage device corresponding to the second storage type can be determined. When it is determined that the second storage device satisfies the storage type conversion condition based on the first available space size, the first storage space size and the second available space size, the available target storage space in the second storage device is obtained, the target storage space is converted into the first storage type, and the data to be stored is stored in the available storage space in the first storage device and the target storage space. In this way, the corresponding storage device can be determined based on the storage type of the data to be stored. When the storage space is insufficient, the available storage space of the storage device of other types can be updated to the storage type corresponding to the data to be stored through storage type conversion, so as to ensure that there is enough storage space to store the data to be stored. If the second storage device does not satisfy the storage conversion condition, the data to be deleted can be determined from the first storage device and / or the second storage device, and the data to be deleted can be deleted when it is determined that the data to be deleted can be deleted, so as to leave enough storage space for the data to be stored. If there is still not enough storage space to store the data to be stored after the data to be deleted is deleted, expansion can be prompted, so as to improve the success rate of data storage.
[0215] In the following, an exemplary application of the embodiments of the present application in an actual application scenario will be described.
[0216] The storage method provided in this application adopts dynamic ZNS technology, which supports mutual conversion between ZNSzone and Normal Zone based on ZNS technology, with the conversion ratio implemented according to certain rules. This not only utilizes ZNS technology to increase the storage capacity of SSDs, but also uses Normal to adapt to non-sequential write operations (without requiring upper-layer application adaptation), thereby adaptively balancing the requirements of storage capacity, performance, and lifespan in server data centers.
[0217] The storage method provided in this application can be applied to a single SSD electronic device, and can also be applied between server devices using SSDs in cloud storage scenarios, especially in complex scenarios where storage capacity and performance are constantly changing.
[0218] Figure 7 This is a schematic diagram illustrating another implementation flow of the data storage method provided in the embodiments of this application. This storage method is applied to scenarios where single-disk services of a single electronic device change, such as... Figure 7 As shown, the process includes:
[0219] Step S701: When the single disk service changes, determine whether it is due to an increase in data volume or an increase in random write latency.
[0220] When data to be stored is obtained, the type of data to be stored can be determined first, and then it can be determined whether to store it in the ZNS Zone or the Normal Zone based on the type of data to be stored. If it needs to be stored in the ZNS Zone but the storage space of the ZNS Zone is insufficient, it means that the data volume demand has increased, and the process proceeds to step S702. If it needs to be stored in the Normal Zone but the storage space of the Normal Zone is insufficient, it means that the random write latency has increased, and the process proceeds to step S703.
[0221] Step S702: Identify the capacity bottleneck.
[0222] Step S703: Confirm the addition of ZNS Zone.
[0223] When a capacity bottleneck is reached, it indicates that the number of ZNS Zones needs to be increased and the number of Normal Zones needs to be reduced.
[0224] Step S704: Determine whether the first conversion condition is met.
[0225] The first conversion condition is a condition for converting the Normal Zone to the ZNS Zone. In implementation, the size of the storage to be added can be determined first, and it is determined whether the unused user space in the current Normal Zone is greater than or equal to the size of the storage to be added. If the unused user space in the current Normal Zone is greater than or equal to the size of the storage to be added, it is determined that the first conversion condition is met, and the process proceeds to step S705; if the unused user space in the current Normal Zone is less than the size of the storage to be added, it is determined that the first conversion condition is not met, and the process ends.
[0226] In step S705, the input and output (Block IO) is blocked.
[0227] In step S706, in-disk data migration is performed.
[0228] In this step, the data in the Normal Zone is migrated in-disk to obtain a space (address continuous) that can meet the required size of the storage to be added. In some embodiments, if all the spaces of the ZNS Zone required cannot be met at one time, the data migration can be performed in a loop until the space of the required size of the storage to be added is obtained.
[0229] In step S707, a first formatting operation is performed.
[0230] The first formatting operation is used to convert the space obtained in step S706 that meets the required size of the storage to be added from the Normal Zone to the ZNS Zone, and update the information of the ZNS Zone and the Normal Zone in the SSD, such as the number of ZNS Zones, the number of Normal Zones, the starting address of the ZNS Zone, the starting address of the Normal Zone, and the like.
[0231] In step S708, it is determined that the performance bottleneck is entered.
[0232] In step S709, it is determined to increase the Normal Zone.
[0233] When it is determined that the performance bottleneck is entered, it means that the number of Normal Zones needs to be increased and the number of ZNS Zones needs to be reduced. That is, part of the ZNS Zone is dynamically converted to the Normal Zone. Since space needs to be reserved in the Normal Zone, when the number of ZNS Zones is reduced and the number of Normal Zones is increased, the total available capacity of the SSD is reduced.
[0234] In step S710, it is determined whether a second conversion condition is met.
[0235] In implementation, first, according to the size of the space required to be occupied by the data to be stored and the size of the available storage space in the current Normal Zone, the size of the storage space required to be increased is determined. It should be noted that the size of the storage space required to be increased in this step includes the reserved space.
[0236] Then, it is judged whether the current total capacity of the ZNS Zone is greater than or equal to the size of the storage space required to be increased. When the current total capacity of the ZNS Zone is greater than or equal to the size of the storage space required to be increased, it is determined that the second conversion condition is met, at this time, step S705 is entered, and step S711 is executed after step S705; when the current total capacity of the ZNS Zone is less than the size of the storage space required to be increased, it is determined that the second conversion condition is not met, and the process ends.
[0237] Step S711, in-disk data migration is performed.
[0238] In this step, the data in the ZNS Zone is migrated between the ZNS Zones, thereby freeing the storage space required to be increased. In some embodiments, if the storage space required to be increased cannot be freed at one time, the space size of one or more ZNS Zones can be freed each time, and the data migration is performed in a loop until the storage space required to be increased is obtained.
[0239] Step S712, a second formatting operation is performed.
[0240] The second formatting operation is used to convert the space obtained in step S711, which satisfies the size of the storage space required to be increased, from the ZNS Zone to the Normal Zone, and update the information of the ZNS Zone and the Normal zone in the SSD at the same time.
[0241] Step S713, the IO operation is restored.
[0242] At this time, the input and output operation is restored, that is, the read and write operation is restored, and the data to be stored is stored in the ZNS Zone or the Normal Zone.
[0243] The implementation process of the dynamic ZNS technology applied to the inter-disk or inter-server is described below. Figure 8 Another implementation process of the data storage method provided by the embodiments of the present application is shown in FIG. 8. Figure 8 As shown in the figure, the process includes:
[0244] Step S801, server cluster scheduling.
[0245] In the embodiments of the present application, when the server cluster receives a data storage service, it is determined whether the server needs to increase the storage capacity or the server needs to improve the performance of random writing.
[0246] When the to-be-stored data is acquired, the type of the to-be-stored data can be determined first, so as to determine whether to store in the ZNS SSD or the Normal SSD based on the type of the to-be-stored data. When the to-be-stored data needs to be stored in the ZNS SSD and the storage space of the ZNS SSD is insufficient, it is indicated that the server capacity demand is increased, and step S802 is entered. When the to-be-stored data needs to be stored in the Normal SSD and the storage space of the Normal SSD is insufficient, it is indicated that the random writing delay is increased, and step S803 is entered.
[0247] In step S802, it is determined that the capacity bottleneck is entered.
[0248] In step S803, it is determined that the ZNS SSD is increased.
[0249] In step S704, it is determined whether the third conversion condition is met.
[0250] The first conversion condition is a condition for converting the Normal SSD into the ZNS SSD. If it is determined that the third conversion condition is met, step S805 is entered. If it is determined that the third conversion condition is not met, the process ends.
[0251] In step S805, the input and output are suspended.
[0252] In step S806, the inter-disk / inter-server data migration is performed.
[0253] In step S807, the first formatting operation is performed.
[0254] In step S808, it is determined that the performance bottleneck is entered.
[0255] In step S809, it is determined that the Normal SSD is increased.
[0256] In step S810, it is determined whether the fourth conversion condition is met.
[0257] When it is determined that the fourth conversion condition is met, step S805 is entered, and step S811 is performed after step S805. When it is determined that the fourth conversion condition is not met, the process ends.
[0258] In step S811, the inter-disk or inter-server data migration is performed.
[0259] In step S812, the second formatting operation is performed.
[0260] In step S813, the IO operation is restored.
[0261] In the embodiments of the present application, based on the "dynamic ZNS technology", the future potential is beneficial to the SSD component manufacturer, and the ZNS technology and the traditional technology are unified, so that the component manufacturer does not need to develop separately for ZNS products, reduces the development cycle, is beneficial to the development of the SSD industry, and also increases the flexibility of supply; and the server cluster can be flexibly established based on the SSD of the "dynamic ZNS technology", the proportion of the ZNS zone SSD is flexibly controlled based on the business demand, and the expansion is relatively simple, and the technology adopted by the SSD itself does not need to be considered; the current mainstream SSD of the server has 10%~30% of the extra space, and the "dynamic ZNS technology" can not only dynamically utilize 10%~30% of the storage space, but also can maintain the balance of the storage space and the performance life.
[0262] The following continues to illustrate an example structure of the data storage apparatus 443 provided by the embodiments of the present application as a software module, and in some embodiments, as shown in Figure 3 The software module stored in the data storage apparatus 443 of the memory 440 can include:
[0263] The first acquisition module 4431 is configured to acquire the to-be-stored data, and determine a first storage type corresponding to the to-be-stored data and a first storage space size required to be occupied;
[0264] The first determination module 4432 is configured to determine a second available space size of a second storage device corresponding to a second storage type when a first available space size of a first storage device corresponding to the first storage type is smaller than the first storage space size;
[0265] The second acquisition module 4433 is configured to acquire a target storage space available in the second storage device when it is determined that the second storage device meets a storage type conversion condition based on the first available space size, the first storage space size and the second available space size;
[0266] The data storage module 4434 is configured to convert the target storage space into the first storage type, and store the to-be-stored data into the available storage space in the first storage device and the target storage space.
[0267] In some embodiments, the apparatus further includes:
[0268] The second determination module is configured to determine a to-be-increased space size based on the first available space size and the first storage space size;
[0269] The third determining module is configured to determine whether the second available space size is greater than or equal to the to-be-increased space size; when the second available space size is greater than or equal to the to-be-increased space size, it is determined that the second storage area satisfies a storage type conversion condition.
[0270] In some embodiments, when the first storage type is a sequential storage type and the second storage type is a random storage type, the second determining module is further configured to:
[0271] determine a first difference space size between the first available space size and the first storage space size;
[0272] determine a first number of first storage units that need to be supplemented based on the first difference space size and a first unit space size, the first unit space size being a space size occupied by a first storage unit of the first storage type;
[0273] determine a second difference space size based on the first number and the first unit space size;
[0274] determine the second difference space size as the to-be-increased space size.
[0275] In some embodiments, when the first storage type is a random storage type and the second storage type is a sequential storage type, the second determining module is further configured to:
[0276] obtain a reserved space ratio corresponding to the random storage type;
[0277] determine a second number of first storage units that need to be supplemented based on the first difference space size, the first unit space size and the reserved space ratio;
[0278] determine a third difference space size based on the second number and the first unit space size;
[0279] determine the third difference size as the to-be-increased space size.
[0280] In some embodiments, the second obtaining module is further configured to:
[0281] when the second storage device has a continuous available space of the to-be-increased space size, determine the continuous available space of the to-be-increased space size as the target storage space;
[0282] when the second storage device does not have the continuous available space, obtain storage state information of each second storage unit in the second storage device;
[0283] Based on the storage state information, data migration is performed on the stored data in the second storage units to obtain the target storage space with the to-be-increased space size.
[0284] In some embodiments, the second obtaining module is further configured to:
[0285] Based on the storage state information, the idle second storage units and the occupied second storage units are determined.
[0286] The used space size of the occupied second storage units and the available space size of the occupied second storage units are determined.
[0287] Based on the used space size and the available space size of the occupied second storage units, data migration is performed between the occupied second storage units to obtain the target storage space with the to-be-increased space size.
[0288] In some embodiments, the apparatus further includes:
[0289] The fourth determining module is configured to determine that the second storage device does not meet the storage type conversion condition when the second available space size is smaller than the to-be-increased space size.
[0290] The fifth determining module is configured to determine a fourth difference space size based on the second available space size and the to-be-increased space size.
[0291] The sixth determining module is configured to determine to-be-deleted data from the first storage device and / or from the second storage device based on the storage time and access information of the stored data in the first storage device and / or based on the storage time and access information of the stored data in the second storage device.
[0292] The first output module is configured to output prompt information for deleting data when the storage space size occupied by the to-be-deleted data is greater than or equal to the fourth difference space size.
[0293] The deleting module is configured to delete the to-be-deleted data in response to a received deletion instruction.
[0294] In some embodiments, the apparatus further includes:
[0295] The seventh determining module is configured to determine a minimum expansion space size based on the storage space size occupied by the to-be-deleted data and the fourth difference space size when the storage space size occupied by the to-be-deleted data is smaller than the fourth difference space size.
[0296] The second output module is configured to output prompt information that storage space is insufficient and needs to be expanded, the prompt information carrying the minimum expansion space size.
[0297] In some embodiments, the apparatus further includes:
[0298] a first control module configured to control to suspend input / output operations when the second storage area meets a storage type conversion condition;
[0299] Correspondingly, after storing the to-be-stored data into the available storage space in the first storage area and the target storage space, the apparatus further includes:
[0300] a second control module configured to control to resume input / output operations.
[0301] In some embodiments, the first determination module is further configured to:
[0302] predict an access hotness value of the to-be-stored data based on the to-be-stored data;
[0303] determine that the first storage type is a random storage type when the access hotness value is higher than a preset hotness threshold;
[0304] determine that the first storage type is a sequential storage type when the access hotness value is lower than or equal to the hotness threshold.
[0305] In some embodiments, the apparatus further includes:
[0306] a third obtaining module configured to obtain a second storage identifier corresponding to each second storage unit included in the target storage space;
[0307] a fourth obtaining module configured to obtain a maximum storage identifier of the first storage unit in the first storage device;
[0308] an updating module configured to update storage unit information in the first storage device and the second storage device based on the second storage identifiers and the maximum storage identifier.
[0309] Embodiments of the present application provide a computer program product or a computer program, which includes computer instructions stored in a computer readable storage medium. A processor of a computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions, so that the computer device executes the data storage method provided by the embodiments of the present application.
[0310] Embodiments of the present application provide a computer readable storage medium storing executable instructions, wherein the executable instructions are stored in the computer readable storage medium. When the executable instructions are executed by a processor, the processor will execute the method provided by the embodiments of the present application, for example, as follows: Figure 4 , Figure 5、 Figure 6 The illustrated method.
[0311] In some embodiments, the computer-readable storage media can be a memory such as a FRAM, a ROM, a PROM, an EPROM, an EEPROM, a flash memory, a magnetic surface memory, an optical disk, or a CD-ROM, etc.; or various devices including one or any combination of the above memories.
[0312] In some embodiments, the executable instructions can take the form of a program, software, software modules, scripts, or code, written in any form of programming language, including compiled or interpreted languages, or declarative or procedural languages; and they can be deployed in any form, including as a stand-alone program or as a module, component, subroutine, or other unit suitable for use in a computing environment.
[0313] As an example, the executable instructions can or can not correspond to a file in a file system, can be stored in a part of a file that holds other programs or data, for example, in one or more scripts stored in a hypertext markup language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files, for example, files that store one or more modules, sub programs, or portions of code.
[0314] As an example, the executable instructions can be deployed to execute on one computer, or on multiple computers that are located at one site, or that are distributed across multiple sites and are interconnected by a communication network.
[0315] The above description is only some embodiments of the present application, and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, and improvement within the spirit and scope of the present application shall be included in the protection scope of the present application.
Claims
1. A data storage method, characterized by, The method comprises: acquiring to-be-stored data and determining a first storage space size required by the to-be-stored data; predicting an access heat value of the to-be-stored data based on the to-be-stored data; when the access heat value is higher than a preset heat threshold, determining that a first storage type is a random storage type; when the access heat value is lower than or equal to the heat threshold, determining that the first storage type is a sequential storage type; when a first available space size of a first storage device corresponding to the first storage type is smaller than the first storage space size, determining a second available space size of a second storage device corresponding to a second storage type; determining a to-be-increased space size based on the first available space size and the first storage space size; when the second available space size is greater than or equal to the to-be-increased space size, determining that the second storage device satisfies a storage type conversion condition, and acquiring a target storage space available in the second storage device; converting the target storage space into the first storage type, and storing the to-be-stored data into an available storage space in the first storage device and the target storage space.
2. The method of claim 1, wherein, when the first storage type is the sequential storage type and the second storage type is the random storage type, the determining of the to-be-increased space size based on the first available space size and the first storage space size comprises: determining a first difference value space size between the first available space size and the first storage space size; determining a first number of first storage units that need to be supplemented based on the first difference value space size and a first unit space size, the first unit space size being a space size occupied by one first storage unit of the first storage type; determining a second difference value space size based on the first number and the first unit space size; determining the second difference value space size as the to-be-increased space size.
3. The method of claim 1, wherein, when the first storage type is the random storage type and the second storage type is the sequential storage type, the determining of the to-be-increased space size based on the first available space size and the first storage space size comprises: determining a first difference value space size between the first available space size and the first storage space size; acquiring a reserved space ratio corresponding to the random storage type; determining a second number of first storage units that need to be supplemented based on the first difference value space size, a first unit space size and the reserved space ratio; determining a third difference value space size based on the second number and the first unit space size; determining the third difference value space size as the to-be-increased space size.
4. The method of claim 1, wherein, the acquiring of the target storage space available in the second storage device comprises: when the second storage device has a continuous available space of the to-be-increased space size, determining the continuous available space of the to-be-increased space size as the target storage space; when the second storage device does not have the continuous available space, acquiring storage state information of each second storage unit in the second storage device; Migrate the stored data in the second storage units according to the storage state information, to obtain the target storage space with the increased size.
5. The method of claim 4, wherein, The method further comprises: Determine the idle second storage units and the occupied second storage units according to the storage state information; Determine the used space size of the occupied second storage units and the available space size of the occupied second storage units; Migrate the stored data between the occupied second storage units according to the used space size and the available space size of the occupied second storage units, to obtain the target storage space with the increased size.
6. The method of claim 1, wherein, The method further comprises: When the second available space size is smaller than the to-be-increased space size, determine that the second storage device does not meet the storage type conversion condition; Determine a fourth difference space size according to the second available space size and the to-be-increased space size; Determine to-be-deleted data from the first storage device and / or from the second storage device according to the storage time and access information of the stored data in the first storage device and / or according to the storage time and access information of the stored data in the second storage device; When the storage space size occupied by the to-be-deleted data is greater than or equal to the fourth difference space size, output prompt information for deleting the data; In response to a received deletion instruction, delete the to-be-deleted data.
7. The method of claim 6, wherein, The method further comprises: When the storage space size occupied by the to-be-deleted data is smaller than the fourth difference space size, determine a minimum expansion space size according to the storage space size occupied by the to-be-deleted data and the fourth difference space size; Output prompt information that storage space is insufficient and needs to be expanded, and the prompt information carries the minimum expansion space size.
8. The method of claim 1, wherein, The method further comprises: When it is determined that the second storage device meets the storage type conversion condition, control the input and output operation to be paused; Correspondingly, after the to-be-stored data is stored in the available storage space in the first storage device and the target storage space, the method further comprises: Control the input and output operation to be resumed.
9. The method according to any one of claims 1 to 6, characterized in that, After the target storage space available in the second storage device is obtained, the method further comprises: Obtain second storage identifiers corresponding to the second storage units included in the target storage space; Obtain the maximum storage identifier of the first storage units in the first storage device; Update the storage unit information in the first storage device and the second storage device according to the second storage identifiers and the maximum storage identifier.
10. A data storage device, characterized by The method further comprises: A first obtaining module is configured to obtain to-be-stored data and determine a first storage space size required by the to-be-stored data; A first determining module is configured to predict an access heat value of the to-be-stored data according to the to-be-stored data; determining that the first storage type is a sequential storage type when the access hotness value is lower than or equal to the hotness threshold value; determining a second available space size of a second storage device corresponding to a second storage type when a first available space size of a first storage device corresponding to the first storage type is smaller than the first storage space size; the second determining module is configured to determine a to-be-increased space size based on the first available space size and the first storage space size; the third determining module is configured to determine that the second storage device meets a storage type conversion condition when the second available space size is greater than or equal to the to-be-increased space size; the second obtaining module is configured to obtain a target storage space available in the second storage device; the data storage module is configured to convert the target storage space into a first storage type, and store the to-be-stored data into an available storage space in the first storage device and the target storage space.
11. The apparatus of claim 10, wherein, when the first storage type is the sequential storage type and the second storage type is the random storage type, the second determining module is further configured to determine a first difference space size between the first available space size and the first storage space size, determine a first number of first storage units that need to be supplemented based on the first difference space size and a first unit space size, the first unit space size being a space size occupied by one first storage unit of the first storage type, determine a second difference space size based on the first number and the first unit space size, and determine the to-be-increased space size as the second difference space size.
12. The apparatus of claim 10, wherein, when the first storage type is the random storage type and the second storage type is the sequential storage type, the second determining module is further configured to determine a first difference space size between the first available space size and the first storage space size, obtain a reserved space ratio corresponding to the random storage type, determine a second number of first storage units that need to be supplemented based on the first difference space size, a first unit space size, and the reserved space ratio, determine a third difference space size based on the second number and the first unit space size, and determine the to-be-increased space size as the third difference space size.
13. The apparatus of claim 10, wherein, the second obtaining module is further configured to determine, when the second storage device has a continuous available space of the to-be-increased space size, the continuous available space of the to-be-increased space size as the target storage space, and obtain, when the second storage device does not have the continuous available space, each storage state information of each second storage unit in the second storage device. Based on the storage state information, data migration is performed on the stored data in the second storage units to obtain the target storage space with the to-be-increased size.
14. The apparatus of claim 13, wherein, The second obtaining module is further configured to determine, based on the storage state information, the idle second storage units and the occupied second storage units, determine the used size of the occupied second storage units and the available size of the occupied second storage units, and perform data migration between the occupied second storage units based on the used size and the available size of the occupied second storage units to obtain the target storage space with the to-be-increased size. The apparatus further includes:
15. The apparatus of claim 10, wherein, The fourth determining module is configured to determine that the second storage device does not satisfy the storage type conversion condition when the second available size is smaller than the to-be-increased size. The fifth determining module is configured to determine a fourth difference size based on the second available size and the to-be-increased size. The sixth determining module is configured to determine to-be-deleted data from the first storage device and / or from the second storage device based on the storage time and access information of the stored data in the first storage device and / or based on the storage time and access information of the stored data in the second storage device. The first output module is configured to output prompt information for deleting data when the storage space occupied by the to-be-deleted data is greater than or equal to the fourth difference size. The deleting module is configured to delete the to-be-deleted data in response to a received deletion instruction. The apparatus further includes:
16. The apparatus of claim 15, wherein, The seventh determining module is configured to determine a minimum expansion size based on the storage space occupied by the to-be-deleted data and the fourth difference size when the storage space occupied by the to-be-deleted data is smaller than the fourth difference size. The second output module is configured to output prompt information that storage space is insufficient and needs to be expanded, the prompt information carrying the minimum expansion size. The apparatus further includes:
17. The apparatus of claim 10, wherein, The first control module is configured to control to pause input and output operations when the second storage device satisfies the storage type conversion condition. Correspondingly, after the to-be-stored data is stored in the available storage space in the first storage device and the target storage space, the apparatus further includes: The second control module is configured to control to resume the input and output operations. The apparatus further includes:
18. The apparatus of any one of claims 10 to 15, wherein, The third obtaining module is configured to obtain second storage identifiers corresponding to the second storage units included in the target storage space. The fourth obtaining module is configured to obtain a maximum storage identifier of the first storage units in the first storage device. The updating module is configured to update the storage unit information in the first storage device and the second storage device based on the second storage identifiers and the maximum storage identifier. The apparatus includes:
19. An electronic device, comprising: A memory configured to store executable instructions. A processor configured to execute the executable instructions stored in the memory to implement the data storage method in any one of claims 1 to 9. 20. A computer-readable storage medium, characterized in that, executable instructions for causing a processor to implement the data storage method of any one of claims 1 to 9 when executed by the processor.
21. A computer program product comprising computer instructions, characterized in that, The computer instructions, when executed by a processor, implement the data storage method of any one of claims 1 to 9.
Citation Information
Patent Citations
Storage type conversion method, system, device and equipment
CN111858498A
Intelligent storage method, device and equipment of NVMe full-flash memory storage system
CN112650446A