CN115686347A - Data storage method, device, equipment and computer readable storage medium - Google Patents

Data storage method, device, equipment and computer readable storage medium Download PDF

Info

Publication number
CN115686347A
CN115686347A CN202110875240.6A CN202110875240A CN115686347A CN 115686347 A CN115686347 A CN 115686347A CN 202110875240 A CN202110875240 A CN 202110875240A CN 115686347 A CN115686347 A CN 115686347A
Authority
CN
China
Prior art keywords
storage
space
size
data
available
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110875240.6A
Other languages
Chinese (zh)
Inventor
任坤胜
陈烽英
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202110875240.6A priority Critical patent/CN115686347A/en
Publication of CN115686347A publication Critical patent/CN115686347A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application provides a data storage method, a device, equipment and a computer readable storage medium; the method comprises the following steps: acquiring data to be stored, and determining a first storage type corresponding to the data to be stored and a first storage space size required to be occupied; 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, determining a second available space size of a second storage device corresponding to the second storage type; when the second storage device is determined to meet the storage type conversion condition based on the first available space size, the first storage space size and the second available space size, obtaining an available target storage space in the second storage device; and converting the target storage space into a first storage type, and storing the data to be stored into the available storage space and the target storage space in the first storage device. By the method and the device, the flexibility of data storage can be improved.

Description

Data storage method, device, equipment and computer readable storage medium
Technical Field
The present application relates to storage technologies, and in particular, to a data storage method, apparatus, device, and computer readable storage medium.
Background
To meet various business requirements when data storage is required, storage media are required to be designed to balance performance, capacity, and cost. In order to balance and respond to various service requirements, an SSD storage medium based on NAND Flash must use extra reserved space (OP) so as to ensure the performance of random writing, about 10% of reserved space is needed for reading intensive storage equipment, and about 30% of reserved space is needed for reading and writing mixed storage equipment; for the sequential writing service, an OP (operational clock) is basically not needed, and the available storage capacity of a user is improved to the maximum extent. At present, in a storage device (set) in an electronic device, a storage area (or a storage device) for storing random write service data and a storage area (or a storage device) for storing sequential write service data are both fixed, an available storage space of the storage device (set) is also fixed, and when data storage of different services is performed, flexibility is poor.
Disclosure of Invention
The embodiment of the application provides a data storage method, a data storage device and a computer-readable storage medium, which can improve the flexibility of data storage.
The technical scheme of the embodiment of the application is realized as follows:
an embodiment of the present application provides a data storage method, including:
acquiring data to be stored, and determining a first storage type corresponding to the data to be stored and a first storage space size required to be occupied;
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, determining a second available space size of a second storage device corresponding to a second storage type;
when the second storage device is determined to meet the storage type conversion condition based on the first available space size, the first storage space size and the second available space size, obtaining an available target storage space in the second storage device;
and converting the target storage space into a first storage type, and storing the data to be stored into an available storage space in the first storage device and the target storage space.
An embodiment of the present application provides a data storage device, including:
the device comprises a first acquisition module, a second acquisition module and a storage module, wherein the first acquisition module is used for acquiring data to be stored and determining a first storage type corresponding to the data to be stored and a first storage space size required to be occupied;
the first determining module is used for determining a second available space size of a second storage device corresponding to a second storage type when the first available space size of a first storage device corresponding to the first storage type is smaller than the first storage space size;
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 the storage type conversion condition based on the first available space size, the first storage space size, and the second available space size;
and the data storage module is used for converting the target storage space into a first storage type and storing the data to be stored into the available storage space in the first storage device and the target storage space.
In some embodiments, the apparatus further comprises:
a second determining module, configured to determine, based on the first available space size and the first storage space size, a size of a space to be increased;
a third determining module, configured to determine whether the size of the second available space is greater than or equal to the size of the space to be increased; when the second available space size is larger than or equal to the to-be-increased space size, determining that the second storage area meets storage type conversion conditions.
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:
determining a first difference space size between the first available space size and the first storage space size;
determining a first number of first storage units needing to be supplemented based on the first difference space size and a first unit space size, wherein the first unit space size is a space size occupied by one first storage unit of the first storage type;
determining a second difference space size based on the first number and the first unit space size;
and determining the second difference space size as the space size to be increased.
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:
acquiring a reserved space proportion corresponding to the random storage type;
determining a second number of first storage units needing to be supplemented based on the first difference space size, the first unit space size and the reserved space proportion;
determining a third difference space size based on the second number and the first unit space size;
and determining the third difference value as the size of the space to be increased.
In some embodiments, the second obtaining module is further configured to:
when the second storage device has a continuous available space with the size of the space to be increased, determining the continuous available space with the size of the space to be increased as a 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;
and performing data migration on the stored data in each second storage unit based on each piece of storage state information to obtain the target storage space of the size of the space to be increased.
In some embodiments, the second obtaining module is further configured to:
determining an idle second storage unit and an occupied second storage unit based on the storage state information;
determining a size of used space of the occupied second storage unit and a size of available space of the occupied second storage unit;
and performing data transfer between the occupied second storage units based on the size of the used space and the size of the available space of the occupied second storage units to obtain the target storage space of the size of the space to be increased.
In some embodiments, the apparatus further comprises:
a fourth determining module, configured to determine that the second storage device does not satisfy the storage type conversion condition when the size of the second available space is smaller than the size of the space to be increased;
a fifth determining module, configured to determine a fourth difference space size based on the second available space size and the size of the space to be increased;
a sixth determining module, configured to determine data to be deleted from the first storage device and/or from the second storage device based on the storage time and the access information of the stored data in the first storage device and/or based on the storage time and the access information of the stored data in the second storage device;
the first output module is used for outputting prompt information of the deleted data when the size of the storage space occupied by the data to be deleted is larger than or equal to the size of the fourth difference space;
and the deleting module is used for responding to the received deleting instruction and deleting the data to be deleted.
In some embodiments, the apparatus further comprises:
a seventh determining module, configured to determine, when the size of the storage space occupied by the data to be deleted is smaller than the fourth difference space size, a minimum expansion space size based on the size of the storage space occupied by the data to be deleted and the fourth difference space size;
and the second output module is used for outputting prompt information which is insufficient in storage space and needs capacity expansion, and the prompt information carries the minimum capacity expansion space size.
In some embodiments, the apparatus further comprises:
the first control module is used for controlling to pause input and output operations when the second storage area is determined to meet the storage type conversion condition;
correspondingly, after storing the data to be stored in the available storage space in the first storage area and the target storage space, the apparatus further includes:
and the second control module is used for controlling and recovering the input and output operation.
In some embodiments, the first determining module is further to:
predicting an access heat value of the data to be stored based on the data to be stored;
when the access heat value is higher than a preset heat threshold, determining that the 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.
In some embodiments, the apparatus further comprises:
a third obtaining module, configured to obtain each second storage identifier corresponding to each second storage unit included in the target storage space;
a fourth obtaining module, configured to obtain a maximum storage identifier of a first storage unit in the first storage device;
and the updating module is used for updating the storage unit information in the first storage equipment and the second storage equipment based on the second storage identifications and the maximum storage identification.
An embodiment of the present application provides an electronic device, including:
a memory for storing executable instructions;
and the processor is used for realizing the data storage method provided by the embodiment of the application when executing the executable instructions stored in the memory.
The embodiment of the application provides a computer-readable storage medium, which stores executable instructions for causing a processor to execute, so as to implement the data storage method provided by the embodiment of the application.
The embodiment of the application has the following beneficial effects:
after data to be stored is acquired, a first storage type corresponding to the data to be stored and a first storage space size required to be occupied are determined, 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, it is indicated that the first storage device does not have enough storage space, at this time, a second available space size of a second storage device corresponding to a second storage type can be determined, 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, an available target storage space in the second storage device is acquired, the target storage space is converted into the first storage type, and the data to be stored is stored into the available storage space and the target storage space in the first storage device, so that the corresponding storage device can be determined based on the storage type of the data to be stored, and when the storage space is insufficient, the available storage space of other types of storage devices can be updated to the storage space corresponding to the data to be stored, and thus, the flexibility of the data to be stored can be improved.
Drawings
FIG. 1A is a schematic diagram of an implementation of a NAND write operation in the related art;
FIG. 1B is a schematic diagram of sequential writing using ZNS techniques;
FIG. 1C is a schematic diagram of a CMR area and an SMR area in a hard disk drive for comparison;
FIG. 2 is a schematic diagram of a network architecture of a data storage system 100 provided by an embodiment of the present application;
fig. 3 is a schematic structural diagram of a server 400 provided in an embodiment of the present application;
FIG. 4 is a schematic flow chart of an implementation of a data storage method provided by an embodiment of the present application;
FIG. 5 is a schematic flowchart of another implementation of a data storage method according to an embodiment of the present application;
fig. 6 is a schematic flowchart of another implementation of the data storage method according to the embodiment of the present application;
fig. 7 is a schematic flowchart of another implementation of a data storage method according to an embodiment of the present application;
fig. 8 is a schematic flowchart of still another implementation of the data storage method according to the embodiment of the present application.
Detailed Description
In order to make the objectives, technical solutions and advantages of the present application clearer, the present application will be described in further detail with reference to the attached drawings, the described embodiments should not be considered as limiting the present application, and all other embodiments obtained by a person of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
In the following description, reference is made to "some embodiments" which describe a subset of all possible embodiments, but it is understood that "some embodiments" may be the same subset or different subsets of all possible embodiments, and may be combined with each other without conflict.
In the following description, references to the terms "first \ second \ third" are only to distinguish similar objects and do not denote a particular order, but rather the terms "first \ second \ third" are used to interchange specific orders or sequences, where appropriate, so as to enable the embodiments of the application described herein to be practiced in other than the order shown or described herein.
Unless defined otherwise, 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 herein is for the purpose of describing embodiments of the present application only and is not intended to be limiting of the application.
Before further detailed description of the embodiments of the present application, terms and expressions referred to in the embodiments of the present application will be described, and the terms and expressions referred to in the embodiments of the present application will be used for the following explanation.
1) Solid State Disks (SSDs), also referred to as Solid State drives, are hard disks made of arrays of Solid State electronic memory chips.
2) Partitioned namespace (ZNS), a SSD technology standard, uses partitions to store data, with sequential writes in each partition.
3) The reserved space (OP) is a space reserved for the solid state disk when the solid state disk is shipped from a factory, and generally occupies more than 7% of the total capacity of the solid state disk, and generally, the capacity of the part cannot be changed.
4) Logical Block Address (LBA), a common mechanism for describing the Block in which data is located on a computer storage device, is commonly used in an auxiliary memory device such as a hard disk. The LBA may mean an address of a certain data block or a data block to which a certain address points. A so-called logical block on a computer today is typically a 512B or 4096B byte.
5) The ZNS Zone (Zone), a Zone based on the ZNS technology, has no OP space, only supports sequential writing.
6) The Normal Zone (Normal Zone), a Zone of the SSD based on non-ZNS technology, has a certain OP proportion and supports random writing.
7) The mechanical Hard Disk (HDD), the most basic computer memory, often referred to as a computer Hard Disk C Disk and a computer Hard Disk D Disk, belong to a Hard Disk drive.
8) Shingled Magnetic Recording (SMR) is a high-capacity Magnetic disk that employs a novel Magnetic storage technology. SMR disks partially overlap data tracks on the disks, just like tiles on a roof, a technique known as shingled magnetic recording. The technology has very small variation in the manufacturing process, but can greatly improve the storage density of the magnetic disk.
9) In Conventional Magnetic Recording (CMR), a guard space is left between tracks, and data is not repeatedly written over.
In order to better understand the data storage method provided by the embodiments of the present application, a description is first made of a data storage method and the existing disadvantages in the related art.
In the related art, if the memory in the electronic device is the SSD, the data is stored to the ZNS Zone for the storage of the sequential write service data using the ZNS technique, and the data is stored to the Normal Zone for the storage of the random write service data. The storage medium of the SSD, the computer flash memory device (NAND) itself determines that erasing is required before writing (unlike HDD magnetic media that can be directly overwritten), and as shown in fig. 1A, erasing of NAND is in units of blocks (blocks) 110 (usually larger than 200 pages), but writing is in units of pages 111 (about 16 KB), so there is often a phenomenon that the whole block needs to be erased first in order to write one page, and thus the NAND lifetime is greatly affected.
SSDs of electronic devices require a design of SSDs that balances performance, capacity, and cost in order to satisfy a variety of business models. To balance the need to use an extra OP (to guarantee the performance of random writes) for coping with a wide variety of business models, the OP is the user's unavailable capacity.
The sequential writing feature of the ZNS technique can substantially eliminate the need for OP, maximizing the storage capacity available to the user. Fig. 1B is a schematic diagram of sequential writing by using the ZNS technique, and as shown in fig. 1B, when a ZNS Zone3 is a currently writing area, 1211 is an occupied area, and 1212 is an unoccupied area, data are sequentially written in 1212 when a write request is received, and there is no phenomenon that the entire block is erased to write one page, and thus the actual service life of the NAND is also extended.
FIG. 1C is a schematic diagram comparing CMR and SMR regions in a mechanical hard disk, as shown in FIG. 1C, where data tracks partially overlap in the SMR region 131, like tiles on a roof, and therefore is called shingled magnetic recording technology, which varies slightly in manufacturing process, but can greatly improve disk storage density, similar to ZNS technology in SSD, supporting sequential writing. A guard space is left between tracks in the CMR region 132, so that data is not repeatedly overwritten and random writing is supported.
In the related art, both the ZNS Zone and the Normal Zone in the SSD and the CMR area and the SMR area in the HDD are preset, and thus the available memory space is also fixed.
The following describes an exemplary application of the electronic device provided in the embodiments of the present application, and the device provided in the embodiments of the present application may be implemented as various types of user terminals such as a notebook computer, a tablet computer, a desktop computer, a set-top box, a mobile device (e.g., a mobile phone, a portable music player, a personal digital assistant, a dedicated messaging device, and a portable game device), and may also be implemented as a server. In the following, an exemplary application will be explained when the device is implemented as a server.
Referring to fig. 2, fig. 2 is a schematic diagram of a network architecture of the data storage system 100 provided in an embodiment of the present application, and as shown in fig. 2, the network architecture includes a terminal 200, a network 300, and a server 400, where the terminal 200 is connected to the server 200 through the network 300, and the network 300 may be a wide area network or a local area network, or a combination of both.
The terminal 200 may send data to be stored to the server 400, after the server 400 receives the data to be stored, first, a first storage type corresponding to the data to be stored and a size of a first storage space that needs to be occupied are determined, when a first storage device corresponding to the first storage type has a sufficient storage space, the data to be stored is directly stored, when the first storage device does not have a sufficient storage space, a size of a second available space corresponding to the second storage type needs to be determined, when the size of the first available space and the size of the second available space are sufficient to store the data to be stored, a 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 data to be stored is stored in the target storage space and the first available space.
In some embodiments, the server 400 may be an independent physical server, may also be a server cluster or a distributed system formed by a plurality of physical servers, and may also be a cloud server providing basic cloud computing services such as a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a network service, cloud communication, a middleware service, a domain name service, a security service, a CDN, and a big data and artificial intelligence platform. When the server 400 is a server cluster, the first storage device may be a storage device in a portion of the servers in the server cluster, and the second storage device may be a storage device in another portion of the servers in the server cluster.
In the network architecture shown in fig. 2, the data storage method is applied to a scenario in which a terminal stores data in a server, and the server may be a single physical server or a server cluster. In some embodiments, the data storage method may also be applied to a scenario in which the terminal stores data to its own storage device, where the first storage device and the second storage device may be different hard disks in the terminal, and the first storage device and the second storage device may also be different storage areas in the same hard disk in the terminal.
Referring to fig. 3, fig. 3 is a schematic structural diagram of a server 400 according to an embodiment of the present application, where the server 400 shown in fig. 3 includes: at least one processor 410, memory 440, at least one network interface 420. The various components in server 400 are coupled together by bus system 430. It is understood that the bus system 430 is used to enable connected communication between these components. The bus system 430 includes a power bus, a control bus, and a status signal bus in addition to a data bus. For clarity of illustration, however, the various buses are designated as bus system 430 in FIG. 3.
The Processor 410 may be an integrated circuit chip having Signal processing capabilities, such as a general purpose Processor, a Digital Signal Processor (DSP), or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, etc., wherein the general purpose Processor may be a microprocessor or any conventional Processor, etc.
The memory 440 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid state memory, hard disk drives, optical disk drives, and the like. Memory 440 optionally includes one or more storage devices physically located remote from processor 410.
Memory 440 includes volatile memory or nonvolatile memory, and can include both volatile and nonvolatile memory. The nonvolatile memory may be a Read Only Memory (ROM), and the volatile memory may be a Random Access Memory (RAM). The memory 440 described in embodiments herein is intended to comprise any suitable type of memory.
In some embodiments, 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, as exemplified below.
An operating system 441 including system programs for handling 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;
a network communication module 442 for communicating to other computing devices via one or more (wired or wireless) network interfaces 420, exemplary network interfaces 420 including: bluetooth, wireless compatibility authentication (WiFi), and Universal Serial Bus (USB), and the like;
in some embodiments, the apparatus provided by the embodiments of the present application may be implemented in software, and fig. 3 illustrates a data storage 443 stored in the memory 440, which may be software in the form of programs and plug-ins, and the like, and includes the following software modules: the first acquisition module 4431, the first determination module 4432, the second acquisition module 4433, and the data store 4434 are logical and thus may be arbitrarily combined or further separated depending on the functionality implemented.
The functions of the respective modules will be explained below.
In other embodiments, the apparatus provided in the embodiments of the present Application may be implemented in hardware, and for example, the apparatus provided in the embodiments of the present Application may be a processor in the form of a hardware decoding processor, which is programmed to execute the data storage method provided in the embodiments of the present Application, for example, the processor in the form of the hardware decoding processor may be 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 components.
The data storage method provided by the embodiment of the present application will be described in conjunction with exemplary applications and implementations of the electronic device provided by the embodiment of the present application.
The embodiment of the application provides a data storage method, which is applied to electronic equipment, wherein the electronic equipment can be a terminal or a server. Fig. 4 is a schematic flow chart of an implementation of a data storage method provided in an embodiment of the present application, and will be described with reference to the steps shown in fig. 4.
Step S101, data to be stored is obtained, and a first storage type corresponding to the data to be stored and a first storage space size required to be occupied are determined.
When the method is implemented by a server, the step of acquiring the data to be stored may be that the server receives a data storage request sent by a terminal, so as to acquire the data to be stored. When the method is implemented by the terminal, the step of acquiring the data to be stored may be that the terminal receives a data storage instruction and acquires the data to be stored based on the data storage instruction.
When it is determined that the first storage type corresponding to the data to be stored is implemented, the heat value of the data to be stored may be predicted first, and the storage type may be determined by whether the heat value is greater than a heat threshold. The first storage type may be a random storage type or a sequential storage type. When the heat value of the data to be stored is higher, the probability that the data to be stored is read and written is higher, so that the requirement on the reading and writing speed is also higher, and at the moment, the first storage type can be determined as a random storage type; when the heat value of the data to be stored is low, it indicates that the possibility of reading and writing the data to be stored is low, so that the requirement on the reading and writing speed is not high, and at this time, the first storage type may be determined as the sequential storage type.
When determining that the size of the first storage space required to be occupied by the data to be stored is implemented, the first storage space can be obtained based on an attribute value corresponding to an attribute of "occupied space" in the attribute information of the data to be stored.
Step S102, when the first available space size is smaller than the first storage space size, determining a second available space size of a second storage device corresponding to the second storage type.
The first available space is the size of the free space of the first storage device corresponding to the first storage type, and the second available space is the size of the unoccupied space in the second storage device corresponding to the second storage type. The first storage device can be different hard disks in the same electronic device, one hard disk is a ZNS SSD and is stored in sequence based on ZNS technology, the other hard disk is a Normal SSD and is stored randomly and provided with a reserved space; or one hard disk is an HDD of the SMR, and the other hard disk is a CMR HDD; or may be different storage areas in the same hard disk in the same electronic device, for example, a ZNS Zone and a Normal Zone in the same hard disk; the storage device may also be a storage device in different electronic devices, where one electronic device is sequentially stored based on the ZNS technology and another electronic device is randomly stored.
In some embodiments, after step S101, it is required to obtain a first available space size, and determine whether the first available space size is smaller than a first storage space size, and if the first available space size is not smaller than the first storage space size, it indicates that the first storage device has a sufficient storage space, and at this time, the data to be stored is stored in the first storage device according to a storage rule corresponding to the first storage type; when the first available space is smaller than the first storage space, which indicates that there is not enough storage space in the first storage device, the storage type conversion needs to be used to obtain more storage space.
Step S103, when the second storage device is determined to meet the storage type conversion condition based on the first available space size, the first storage space size and the second available space size, obtaining the available target storage space in the second storage device.
When the method is realized, the size of the space to be increased is determined based on the first available space size and the first storage space size, when the second available space size is larger than or equal to the size of the space to be increased, the second storage device is determined to meet the storage type conversion condition, and at the moment, the available target storage space in the second storage device is obtained. The size of the target storage space may be the same as the size of the space to be added, and in some embodiments, the size of the target storage space may also be the same as the size of the space to be added.
Step S104, converting the target storage space into a first storage type, and storing the data to be stored into an available storage space in the first storage device and the target storage space.
When the step S104 is implemented, the target storage space may be formatted to convert the target storage space from the second storage type to the first storage type, so that the storage space of the first storage type can be ensured to store data, and at this time, the data to be stored is stored into the available storage space and the target storage space in the first storage device according to the storage rule corresponding to the first storage type.
In the data storage method provided by the embodiment of the application, after data to be stored is acquired, a first storage type corresponding to the data to be stored and a first storage space size required to be occupied are determined, 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, it is indicated that the first storage device does not have enough storage space, at this time, a second available space size of a second storage device corresponding to a second storage type can be determined, 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, an available target storage space in the second storage device is acquired, the target storage space is converted into the first storage type, the data to be stored is stored into an available storage space in the first storage device and the target storage space, so that the corresponding storage device can be determined based on the storage type of the data to be stored, and when the storage space is insufficient, the available storage space of other types of the storage device and the target storage space and the storage device can provide a high storage capacity and a high storage capacity for the data to be stored, and thus a high storage capacity scheme can be provided.
In some embodiments, the "determining the first storage type corresponding to the data to be stored" in step S101 may be implemented in steps S1011 to S1013 described below, and the following description is provided.
Step S1011, predicting an access heat value of the data to be stored based on the data to be stored.
When the step S1011 is implemented, an access heat value of the data to be stored may be predicted based on the identifier of the data to be stored and/or according to the data content in the data to be stored, where the access heat value may reflect the probability of the data to be stored being accessed or the number of times of accessing.
Step S1012, when the access heat value is higher than a preset heat threshold, determining that the first storage type is a random storage type.
When the access heat value is higher than the heat threshold, the possibility that the data to be stored is read and written is high, so that the requirement on the reading and writing speed is relatively high, at the moment, the first storage type is determined to be a random storage type, and when the data to be stored is stored, the data to be stored can be randomly stored instead of being stored according to the address sequence. A random access type storage device needs to set a reserved space.
Step S1013, 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 the heat value of the data to be stored is lower than or equal to the heat threshold, it indicates that the possibility of reading and writing the data to be stored is low, so that the requirement on the reading and writing speed is not high, at this time, the first storage type may be determined as a sequential storage type, and sequential reading and writing based on an address is required when the data to be stored is stored. The reserved space does not need to be set in the storage device corresponding to the sequential storage type.
In the above steps S1011 to S1013, the first storage type of the data to be stored may be determined by predicting an access heat value of the data to be stored, and in some embodiments, the first storage type of the data to be stored may also be directly specified.
In some embodiments, as shown in fig. 5, before step S103, the following steps S201 and S202 are also required to be performed, which is described below with reference to fig. 5.
Step S201, determining a size of a space to be increased based on the size of the first available space and the size of the first storage space.
When the step is implemented, different implementation manners are available based on different first storage types, wherein when the first storage type is a sequential storage type and the second storage type is a random storage type, it is described that a part of the storage space in the second storage device needs to be converted from the random storage type to the sequential storage type, and 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 increased. When the first storage type is a random storage type and the second storage type is a sequential storage type, it is described that a part of the storage space in the second storage device needs to be converted from the sequential storage type to the random storage type.
Step S202, determining whether the second available space size is greater than or equal to the size of the space to be increased.
When the size of the second available space is greater than or equal to the size of the space to be increased, it is determined that the second storage device meets the storage type conversion condition, at this time, step S103 is entered, and in some embodiments, when the size of the second available space is smaller than the size of the space to be increased, it is stated that the second storage device does not meet the storage type conversion condition, at this time, data deletion may be prompted or capacity expansion may be prompted to be performed.
In some embodiments, the first storage type may be a sequential storage type or a random storage type, and when the step S201 is implemented, there are different implementation manners based on different first storage types corresponding to the data to be stored, and the following two implementation manners are described.
When the first storage type is a sequential storage type and the second storage type is a random storage type, step S201 "determine the size of the space to be added based on the first available space size and the first storage space size" may be implemented by the following steps S2011A to S2014A, which will be described below.
In step S2011A, a first difference space size between the first available space size and the first storage space size is determined.
In this implementation, the first difference space size is also a value obtained by subtracting the first available space size from the first storage space size. For example, when the first storage space is 900MB and the first available space size is 400MB, the first difference space size is 500MB.
Step S2012A, determining a first number of the first storage units that need to be supplemented based on the first difference space size and the first unit space size.
The first unit space size is a space size occupied by one first storage unit of the first storage type. When implemented, the first storage device may be divided into a plurality of storage units, or storage areas, and the storage space occupied by each storage unit may be the same. In an embodiment of the present application, the first storage type is a sequential storage type, and the first storage unit may be a ZNS Zone.
In step S2012A, when implemented, the first difference space size may be divided by the first unit space size, and the obtained quotient is rounded up, so as to obtain the first number. In the embodiment of the present application, the first cell space size is assumed to be 200M. Taking the above example as a support, the first number of the first memory cells to be replenished is determined to be 3.
Step S2013A, determining a second difference space size based on the first number and the first unit space size.
When implemented, the product of the first number and the first cell space size may be determined as the second difference size. For the above example, the first number is 3, the first unit space size is 200M, and then the second difference space size is 600M.
Step S2014A, determining the second difference space size as a space size to be increased.
In the above steps S2011A to S2014A, since the storage units are divided in the first storage device, when determining the size of the space to be increased, the first number of the first storage units to be increased is determined first, and then the size of the space to be actually increased is determined based on the first number. The implementation manners provided in steps S2011A to S2014A are applicable to a scenario in which the first storage device and the second storage device are located on the same storage hard disk of the same electronic device, and the first storage device has a plurality of first storage units, and the second storage device has a plurality of second storage units.
In some embodiments, when the first storage device and the second storage device are different storage hard disks located on the same electronic device; or when the first storage device and the second storage device are located in different electronic devices, the first difference space size may be directly determined as the size of the space to be increased.
When the first storage type is a random storage type and the second storage type is a sequential storage type, step S201 "determine the size of the space to be added based on the first available space size and the first storage space size" may be implemented by the following steps S2011B to S2014B, which will be described below.
Step S2011B, obtains the ratio of the reserved space corresponding to the random access memory type.
The reserved space ratio may be preset when the storage device leaves a factory, or may be set by the user, but when the user sets the reserved space ratio by himself, the reserved space ratio needs to be set within a range of a specified minimum ratio and a specified maximum ratio.
Step S2012B determines a second number of the 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.
When the first storing type is a random storing type, the first storing unit may be a Normal Zone, and the first unit space size includes a reserved space, then the first difference space size is a space size that can be actually occupied except the reserved space. In implementation, a fifth difference space size including the reserved space may be determined based on the first difference space size and the reserved space proportion, and then the fifth difference space size is divided by the first unit space size, and the obtained quotient is rounded up to obtain the second number.
For example, if the first difference space size is 500MB and the reserved space ratio is 20%, then the fifth difference space size needs to be obtained by the first difference 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 access memory type is also 200MB, then 3.125 is obtained by 625/200, and then rounding up is performed to obtain the second number of 4.
Step S2013B, determining a third difference space size based on the second number and the first unit space size.
Step S2013, when implemented, may determine a product of the second number and the first unit space size as a third difference space size. For the above example, the second number is 4, the first unit space size is 200MB, and the third difference space size is 800MB.
Step S2014B, determining the third difference as the size of the space to be increased.
The implementation manners provided in steps S2011B to S2014B are applicable to a scenario where the first storage device and the second storage device are located on the same storage hard disk of the same electronic device, and the first storage device has a plurality of first storage units (Normal zones), and the second storage device has a plurality of second storage units (ZNS zones), and since the ZNS zones without the reserved space are converted into the Normal zones with the reserved space, a fifth difference space size including the reserved space needs to be determined according to the reserved space ratio and the first difference space size, so that the second number of the first storage units that need to be increased is determined based on the fifth difference space size, and then the space size that actually needs to be increased is determined based on the second number.
In some embodiments, when the first storage device and the second storage device are different storage hard disks located on the same electronic device; or when the first storage device and the second storage device are located in different electronic devices, if the storage unit is not divided, the fifth difference space size may be directly determined as the space size to be increased.
In some embodiments, the step S103 of fig. 4 of "obtaining the target storage space available in the second storage device" may be implemented by:
step S1031, determining whether there is a continuously available storage space in the second storage device with the size of the space to be increased.
In this embodiment of the application, when the second storage device has a continuous available space with the size of the space to be increased, it indicates that data can be directly stored without data migration, and then step S1032 is performed; when the second storage device does not have a continuous available space with a size of the space to be increased, it indicates that data storage is not performed until data migration is performed, and then the process proceeds to step S1033.
Step S1032, determining the continuous available space of the size of the space to be increased as the target storage space.
Step S1033, obtaining respective storage state information of the respective second storage units in the second storage device.
The storage status information includes, but is not limited to, the size of the used storage space, the size of the available storage space, the starting address of the available storage space, and the like.
Step S1034, based on the storage status information, performing data migration on the stored data in each second storage unit, to obtain a target storage space of the size of the space to be increased.
In practical applications, the step S1034 can be implemented by the following steps:
step S341, based on the storage state information, determines an idle second storage unit and an occupied second storage unit.
The free second storage unit is the second storage unit which is not occupied at all, and the occupied second storage unit is the second storage unit which is occupied completely or partially. When implemented, step S341 may determine the free second storage unit and the occupied second storage unit according to whether the size of the available storage space in each storage status information is equal to the size of the maximum available storage space in the second storage unit.
In step S342, the size of the used space of the occupied second storage unit and the size of the available space of the occupied second storage unit are determined.
Step S342, when implemented, may be to determine the size of the used space and the size of the available space through the respective storage status information of the occupied second storage unit.
Step S343, based on the size of the used space and the size of the available space of the occupied second storage unit, performing data transfer between the occupied second storage units to obtain the target storage space of the size of the space to be increased.
In the implementation of step S343, the used space and the available space of the occupied second storage unit may be used to determine the source storage unit and the target storage unit from the occupied second storage unit, and migrate the data in the source storage unit to the target storage unit, and finally migrate all the data in the source storage unit, so as to obtain an idle source storage unit.
When determining the source storage unit and the target storage unit from the occupied second storage units, the occupied second storage units may be sorted according to the size of the used space to obtain a sorting result, and then the target storage unit and the source storage unit are determined according to the size of the available space of the second storage unit sorted before and the size of the used space of the second storage unit sorted after, and finally the total size of the available space of the target storage unit is greater than or equal to the total size of the occupied space of the source storage unit.
For example, if there are 4 occupied second storage units, the size of the used space of the first occupied second storage unit is 150MB, the size of the unoccupied space is 50MB, the size of the used space of the second occupied second storage space is 100MB, and the size of the unoccupied space is 100MB, the size of the used space of the third occupied second storage space is 80MB, and the size of the unoccupied space is 120MB, the size of the used space of the fourth occupied storage unit is 20MB, and the size of the unoccupied space is 180MB, and the size of the required space to be added is 400MB, 2 storage units need to be migrated from the 4 occupied second storage units, and when the implementation is implemented, the first and second occupied second storage units can be determined as the target storage unit, determining the third and fourth occupied second storage units as source storage units, and when data migration is performed, migrating data in the fourth occupied second storage unit to the first occupied second storage unit, migrating data in the third occupied second storage unit to the second occupied second storage unit, so that the size of used space of the first occupied second storage unit is 170MB, the size of unoccupied space is 30MB, the size of used space of the second occupied second storage unit is 180MB, and the size of unoccupied space is 20MB, and the third and fourth second storage units can be idle second storage units, so that a target storage space of 400MB is obtained.
In some embodiments, after obtaining the available target storage space in the second storage device, or after converting the target storage space into the first storage type, the following steps may be further performed:
step S401, obtaining each second storage identifier corresponding to each second storage unit included in the target storage space.
Assume that the second storage identities corresponding to the respective second storage units in the target storage space are 45 and 46, respectively.
Step S402, obtaining a maximum storage identifier of a first storage unit in the first storage device.
For example, there are currently 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.
Step S403, updating the 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.
In the implementation of step S403, the storage unit information in the second storage device may be updated based on each second storage identifier, further, each second storage identifier may be deleted from the storage unit information in the second storage device, and when the storage unit information in the first storage device is updated based on the maximum storage identifier and each second storage identifier, the number of the first storage identifiers that need to be added may 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 the first storage identifiers that need to be added.
Through the steps S401 to S403, the target storage space can be acquired, or after the storage type conversion is performed on the target storage space, the storage unit information in the storage device corresponding to the first storage type and the second storage type can be updated, so that the accuracy of the storage information can be ensured, and the data can be accurately read and written.
Based on the foregoing embodiments, an embodiment of the present application further provides a data storage method, which is applied to the network architecture shown in fig. 2, fig. 6 is a schematic diagram of a further implementation flow of the data storage method provided in the embodiment of the present application, and the method provided in the embodiment of the present application is described below with reference to fig. 6.
Step S601, the terminal sends data to be stored to the server.
Step S602, the server determines a first storage type corresponding to the data to be stored and a first storage space size required to be occupied.
Step S603, the server determines whether the first available space size of the first storage device corresponding to the first storage type is smaller than the first storage space size.
When the first available space size is greater than or equal to the first storage space size, it indicates that there is enough storage space in the first storage device to store the data to be stored, and then step S604 is performed; when the first available space size is smaller than the first storage space size, it indicates that there is not enough storage space in the first storage device to store the data to be stored, and then the process proceeds to step S605.
Step S604, the server stores the data to be stored in the first storage device.
In step S605, the server determines a second available space size of a second storage device corresponding to the second storage type.
Step S606, the server determines the size of the space to be added based on the size of the first available space and the size of the first storage space.
In step S607, the server determines whether the second available space size is greater than or equal to the to-be-added space size.
When the size of the second available space is greater than or equal to the size of the space to be increased, determining that the second storage area meets the storage type conversion condition, and then entering step S608; when the second available space size is smaller than the to-be-added space size, it is determined that the second storage area does not satisfy the storage type conversion condition, and then step S613 is performed.
In step S608, the server controls to suspend the input/output operation.
In the embodiment of the present application, in order to avoid easily causing a read/write error when performing an input/output operation when performing a storage type conversion, it is necessary to control to suspend the input/output operation.
In step S609, the server obtains an available target storage space in the second storage device.
Step S610, the server converts the target storage space into a first storage type, and stores the data to be stored in the available storage space in the first storage device and the target storage space.
In step S611, the server controls the resume input/output operation.
In the embodiment of the present application, after the target storage space is converted into the first storage type, it indicates that the storage type conversion is completed, and at this time, the resume input/output operation may be controlled.
Step S612, the server determines a fourth difference space size based on the second available space size and the size of the space to be increased.
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 not enough to store the data to be stored, and at this time, a fourth difference space size, that is, a space size occupied by the data to be deleted, needs to be determined by subtracting the second available space size from the space size to be increased.
Step S613, the server determines data to be deleted 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.
Step S613, when the data to be deleted is to be deleted, may first be determined from the first storage device based on the storage time and the access information of the stored data in the first storage device, and if the size of the storage space occupied by the determined data to be deleted is greater than or equal to the fourth difference space size, the data to be deleted may not be determined from the second storage device; and if the size of the storage space occupied by the data to be deleted determined from the first storage device is smaller than the fourth difference space size, continuing to determine the data to be deleted from the second storage device.
In some embodiments, when determining that data to be deleted is implemented from the first storage device based on the storage time and the access information of the stored data in the first storage device, an interval duration between the storage time in the first storage device and the current time may be greater than a preset duration threshold, and data with access times smaller than a preset time threshold may be determined as the data to be deleted.
In step S614, the server determines whether the size of the storage space occupied by the data to be deleted is smaller than the size of the fourth difference space.
When the size of the storage space occupied by the data to be deleted is greater than or equal to the size of the fourth difference space, it indicates that sufficient storage space can be obtained after the data to be deleted is deleted, and then step S615 is performed; when the size of the storage space occupied by the data to be deleted is smaller than the fourth difference space size, which indicates that sufficient storage space cannot be obtained even after the data to be deleted is deleted, the process proceeds to step S618.
In step S615, the server outputs a prompt message to delete the data.
In implementation, the server may send a prompt message to the terminal to delete the data, as shown in fig. 6. The prompt message may carry a data identifier of the data to be deleted. After receiving prompt information of deleting data, the terminal sends a deleting instruction to the server if the data is determined to be deleted; if the data is not deleted, an instruction to refuse to delete the data may be sent to the server.
In step S616, the server deletes the data to be deleted in response to the received deletion instruction.
In some embodiments, after the data to be deleted is deleted, the server has enough storage space to store the data to be stored, and the data storage process can be executed subsequently.
In step S617, the server determines, based on the size of the storage space occupied by the data to be deleted and the size of the fourth difference space, the minimum size of the expansion space.
In implementation, the size of the storage space occupied by the data to be deleted may be subtracted from the size of the fourth difference space, so as to obtain the minimum size of the expansion space.
In step S618, the server outputs a prompt message indicating that the storage space is insufficient and needs to be expanded.
And the prompt information carries the minimum expansion space size. When step S618 is implemented, the server outputs the prompt information that the storage space is insufficient and the capacity needs to be expanded, as shown in fig. 6, the server may send the prompt information to the terminal. In some embodiments, after receiving the prompt message, the terminal may perform capacity expansion based on the minimum capacity expansion space size carried in the prompt message. And if the terminal does not expand the capacity for the moment, the data to be stored fails to be stored.
In the data storage method provided by the embodiment of the application, after the data to be stored is acquired, a first storage type corresponding to the data to be stored and a 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, indicating that the first storage device does not have enough storage space, a second available space size of a second storage device corresponding to the second storage type may be determined, when the second storage device is determined to meet the storage type conversion condition based on the first available space size, the first storage space size and the second available space size, acquiring a target storage space available in the second storage device, converting the target storage space into a first storage type, and storing the data to be stored into an available storage space in the first storage device and the target storage space, so that the corresponding storage device can be determined based on the storage type of the data to be stored, and when the storage space is insufficient, the available storage space of other types of storage devices can be updated to the storage type corresponding to the data to be stored through storage type conversion, thereby ensuring that there is sufficient storage space to store the data to be stored, and if the second storage device does not satisfy the storage transition condition, the data to be deleted may be determined from the first storage device and/or the second storage device, and when the deletion is determined to be possible, deleting the data to be deleted to reserve enough storage space for the data to be stored, if the data to be deleted is deleted and the storage space is still insufficient to store the data to be stored, the capacity expansion can be prompted, and therefore the success rate of data storage is improved.
Next, an exemplary application of the embodiment of the present application in a practical application scenario will be described.
The storage method provided by the embodiment of the application adopts the dynamic ZNS technology, and supports the mutual conversion between the ZNS Zone and the Normal Zone on the basis of the ZNS technology, and the conversion ratio is realized on the basis of a certain rule. Therefore, the storage capacity of the SSD can be improved by using the ZNS technology, and the Noraml can be adapted to the non-sequential write service (without upper-layer application adaptation), so that the requirements on the storage capacity, the performance and the service life can be adaptively balanced in a server data center.
The storage method provided by the embodiment of the application can be applied to a single SSD electronic device, and can also be applied to the application between SSD server devices in a cloud storage scene, particularly a complex scene with constantly changing storage capacity and performance.
Fig. 7 is a schematic view of another implementation flow of a data storage method provided in an embodiment of the present application, where the storage method is applied to a scenario of a single-disk service change of a single electronic device, as shown in fig. 7, the flow includes:
step S701, when the single disk service changes, determines whether the data volume service increases or the random write delay increases.
When data to be stored is acquired, the type of the data to be stored may be determined first, so as to determine whether to store the ZNS Zone or the Normal Zone based on the type of the data to be stored, where when the ZNS Zone needs to be stored and the storage space of the ZNS Zone is insufficient, it is indicated that the data volume requirement is increased, and then step S702 is performed; when the Normal Zone needs to be stored and the storage space of the Normal Zone is insufficient, it indicates that the random write latency is increased, and the process proceeds to step S703.
Step S702, determine to enter a capacity bottleneck.
Step S703 determines to add a ZNS Zone.
When entering the capacity bottleneck, it is indicated that the number of ZNS zones needs to be increased and the number of Normal zones needs to be decreased.
In step S704, it is determined whether the first conversion condition is satisfied.
The first converting condition is a condition for converting Normal Zone to ZNS Zone. In implementation, the storage size that needs to be increased may be determined, and it may be determined whether the user space that is not used in the current Normal Zone is greater than or equal to the storage size that needs to be increased, if the user space that is not used in the current Normal Zone is greater than or equal to the storage size that needs to be increased, it is determined that the first conversion condition is satisfied, at this time, step S705 is performed; and if the user space which is not used in the current Normal Zone is smaller than the storage size which needs to be increased, determining that the first conversion condition is not met, and ending the process.
In step S705, input/output (Block IO) is suspended.
Step S706, performs in-disk data migration.
In this step, the data in the Normal Zone is migrated in the disk, so as to obtain a space (address continuation) that can satisfy the increased storage size required. In some embodiments, if the required space of all the ZNS zones cannot be satisfied at once, the data migration may be looped until the space of the required increased storage size is obtained.
In step S707, a first formatting operation is performed.
The first formatting operation is used to convert the space obtained in step S706, which satisfies the required increased storage size, from the Normal Zone to the ZNS Zone, and update the information of the ZNS Zone and the Normal Zone inside the SSD, such as updating the number of the ZNS zones, the number of the Normal zones, the starting address of the ZNS Zone, the starting address of the Normal Zone, and so on.
Step S708, determining to enter a performance bottleneck.
In step S709, it is determined to add the Normal Zone.
When the situation that the performance bottleneck is entered is determined, the number of Normal zones needs to be increased, and the number of ZNS zones is reduced. That is, a part of the ZNS zones is dynamically converted into a Normal Zone, and since the Normal Zone needs to reserve a space, when the number of the ZNS zones is decreased, the number of the Normal zones is increased, and for the SSD, the total available capacity is decreased.
In step S710, it is determined whether the second conversion condition is satisfied.
When the method is implemented, firstly, the size of the storage space needing to be increased is determined according to the size of the space occupied by the data to be stored and the size of the available storage space in the current Normal Zone. It should be noted that the size of the storage space required to be increased in this step includes a reserved space.
Then judging whether the current remaining total capacity of the ZNS Zone is larger than or equal to the size of the storage space needing to be increased or not, when the current remaining total capacity of the ZNS Zone is larger than or equal to the size of the storage space needing to be increased, determining that a second conversion condition is met, then, entering a step S705, and executing a step S711 after the step S705; and when the current remaining total capacity of the ZNS Zone is smaller than the size of the storage space needing to be increased and the second conversion condition is not met, ending the process.
In step S711, in-disk data migration is performed.
In this step, the data in the ZNS zones are migrated between the ZNS zones, thereby leaving free the required increased storage space. In some embodiments, if the required storage space cannot be left in one time, the data migration may be performed in a loop by leaving the space size of one or more ZNS zones in one time until the space with the required storage space size is obtained.
In step S712, a second formatting operation is performed.
The second formatting operation is to convert the space obtained in step S711 that satisfies the required increased storage size from the ZNS Zone to a Normal Zone, and update the information of the ZNS Zone and the Normal Zone inside the SSD at the same time.
In step S713, the IO operation is resumed.
At this time, the input and output operation, that is, the read-write operation, is recovered, and the data to be stored is stored in the ZNSZone or the Normal Zone.
In the following description of an implementation process of the dynamic ZNS technology applied between disks or servers, fig. 8 is a schematic flow chart of another implementation of the data storage method provided by the embodiment of the present application, as shown in fig. 8, where the flow chart includes:
step S801, server cluster scheduling.
In the embodiment of the application, when a server cluster receives a data storage service, whether the server needs to increase the storage capacity or the server needs to improve the random writing performance is judged.
When data to be stored is acquired, the type of the data to be stored can be determined firstly, and then whether the data to be stored is stored in the ZNS SSD or the Normal SSD is determined based on the type of the data to be stored, wherein when the data needs to be stored in the ZNS SSD and the storage space of the ZNS SSD is insufficient, the requirement on the capacity of a server is increased, and then the step S802 is executed; when the Normal SSD needs to be stored and the storage space of the Normal SSD is not enough, it indicates that the random write latency is increased, and the process proceeds to step S803.
Step S802, determine to enter a capacity bottleneck.
Step S803, it is determined to add the ZNS SSD.
Step S704, it is determined whether the third conversion condition is satisfied.
The first conversion condition is a condition for converting Normal SSD into ZNS SSD. If it is determined that the third conversion condition is satisfied, the process proceeds to step S805; if it is determined that the third conversion condition is not satisfied, the flow ends at this time.
In step S805, input and output are suspended.
In step S806, inter-disk/inter-server data migration is performed.
In step S807, a first formatting operation is performed.
Step S808, determining to enter a performance bottleneck.
In step S809, it is determined to increase Normal SSD.
Step S810, it is determined whether the fourth conversion condition is satisfied.
When it is determined that the fourth conversion condition is satisfied, the flow proceeds to step S805, and step S811 is performed after step S805; when it is determined that the fourth conversion condition is not satisfied, the flow ends.
In step S811, inter-disk or inter-server data migration is performed.
In step S812, a second formatting operation is performed.
Step S813, the IO operation is resumed.
In the embodiment of the application, based on the dynamic ZNS technology, SSD component manufacturers are potentially facilitated in the future, the ZNS technology and the traditional technology are unified, so that the component manufacturers do not need to develop ZNS products independently, the development period is shortened, the development of the SSD industry is facilitated, and the supply flexibility is increased; the SSD based on the dynamic ZNS technology can flexibly establish a server cluster, the proportion of the ZNS zone SSD is flexibly controlled based on the service requirement, meanwhile, the capacity expansion is relatively simple, and the technology adopted by the SSD is not required to be considered; the main stream SSD of the current server has 10% -30% of extra space, and the dynamic ZNS technology can not only dynamically and fully utilize 10% -30% of storage space, but also keep the balance of the storage space and the performance life.
Continuing with the exemplary structure of the data storage 443 provided by the embodiments of the present application as a software module, in some embodiments, as shown in fig. 3, the software modules stored in the data storage 443 of the memory 440 may include:
a first obtaining module 4431, configured to obtain data to be stored, and determine a first storage type corresponding to the data to be stored and a size of a first storage space that needs to be occupied;
a first determining module 4432, 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;
a second obtaining module 4433, configured to obtain a target storage space available in the second storage device 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 data storage module 4434, configured to convert the target storage space into a first storage type, and store the data to be stored into an available storage space in the first storage device and the target storage space.
In some embodiments, the apparatus further comprises:
a second determining module, configured to determine, based on the first available space size and the first storage space size, a size of a space to be increased;
a third determining module, configured to determine whether the size of the second available space is greater than or equal to the size of the space to be increased; when the second available space size is larger than or equal to the to-be-increased space size, determining that the second storage area meets storage type conversion conditions.
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:
determining a first difference space size between the first available space size and the first storage space size;
determining a first number of first storage units needing to be supplemented based on the first difference space size and a first unit space size, wherein the first unit space size is the space size occupied by one first storage unit of the first storage type;
determining a second difference space size based on the first number and the first unit space size;
and determining the second difference space size as the space size to be increased.
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:
acquiring a reserved space proportion corresponding to the random storage type;
determining a second number of first storage units needing to be supplemented based on the first difference space size, the first unit space size and the reserved space proportion;
determining a third difference space size based on the second number and the first unit space size;
and determining the third difference value as the size of the space to be increased.
In some embodiments, the second obtaining module is further configured to:
when the second storage device has a continuous available space with the size of the space to be increased, determining the continuous available space with the size of the space to be increased as a 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;
and performing data migration on the stored data in each second storage unit based on each piece of storage state information to obtain the target storage space of the space to be increased.
In some embodiments, the second obtaining module is further configured to:
determining an idle second storage unit and an occupied second storage unit based on the storage state information;
determining a size of used space of the occupied second storage unit and a size of available space of the occupied second storage unit;
and performing data transfer between the occupied second storage units based on the size of the occupied space and the size of the available space of the occupied second storage unit to obtain the target storage space of the size of the space to be increased.
In some embodiments, the apparatus further comprises:
a fourth determining module, configured to determine that the second storage device does not satisfy the storage type conversion condition when the second available space size is smaller than the size of the space to be increased;
a fifth determining module, configured to determine a fourth difference space size based on the second available space size and the size of the space to be increased;
a sixth determining module, configured to determine data to be deleted from the first storage device and/or from the second storage device based on the storage time and access information of the data stored in the first storage device and/or based on the storage time and access information of the data stored in the second storage device;
the first output module is used for outputting prompt information of the deleted data when the size of the storage space occupied by the data to be deleted is larger than or equal to the size of the fourth difference space;
and the deleting module is used for responding to the received deleting instruction and deleting the data to be deleted.
In some embodiments, the apparatus further comprises:
a seventh determining module, configured to determine, when the size of the storage space occupied by the data to be deleted is smaller than the fourth difference space size, a minimum expansion space size based on the size of the storage space occupied by the data to be deleted and the fourth difference space size;
and the second output module is used for outputting prompt information which is insufficient in storage space and needs capacity expansion, and the prompt information carries the minimum capacity expansion space size.
In some embodiments, the apparatus further comprises:
the first control module is used for controlling the input and output operation to be suspended when the second storage area meets the storage type conversion condition;
correspondingly, after storing the data to be stored in the available storage space in the first storage area and the target storage space, the apparatus further includes:
and the second control module is used for controlling and recovering the input and output operations.
In some embodiments, the first determining module is further to:
predicting an access heat value of the data to be stored based on the data to be stored;
when the access heat value is higher than a preset heat threshold, determining that the first storage type is a random storage type;
when the access hot degree value is lower than or equal to the hot degree threshold value, determining that the first storage type is a sequential storage type.
In some embodiments, the apparatus further comprises:
a third obtaining module, configured to obtain each second storage identifier corresponding to each second storage unit included in the target storage space;
a fourth obtaining module, configured to obtain a maximum storage identifier of a first storage unit in the first storage device;
and the updating module is used for updating the storage unit information in the first storage equipment and the second storage equipment based on the second storage identifications and the maximum storage identification.
Embodiments of the present application provide a computer program product or computer program comprising computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and executes the computer instructions, so that the computer device executes the data storage method described in the embodiment of the present application.
Embodiments of the present application provide a computer-readable storage medium storing executable instructions, which when executed by a processor, will cause the processor to perform the methods provided by embodiments of the present application, for example, the methods as shown in fig. 4, fig. 5, and fig. 6.
In some embodiments, the computer-readable storage medium may be memory such as FRAM, ROM, PROM, EP ROM, EEPROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; or may be various devices including one or any combination of the above memories.
In some embodiments, executable instructions may be written in any form of programming language (including compiled or interpreted languages), in the form of programs, software modules, scripts or code, and may 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.
By way of example, executable instructions may correspond, but do not necessarily have to correspond, to files in a file system, and may be stored in a portion of a file that holds other programs or data, such as in one or more scripts in a hypertext Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files that store one or more modules, sub-programs, or portions of code).
As an example, executable instructions may be deployed to be executed on one computing device or on multiple computing devices located at one site or distributed across multiple sites and interconnected by a communication network.
The above description is only an example of the present application, and is not intended to limit the scope of the present application. Any modification, equivalent replacement, and improvement made within the spirit and scope of the present application are included in the protection scope of the present application.

Claims (14)

1. A method of storing data, comprising:
acquiring data to be stored, and determining a first storage type corresponding to the data to be stored and a first storage space size required to be occupied;
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, determining a second available space size of a second storage device corresponding to a second storage type;
when the second storage device is determined to meet the storage type conversion condition based on the first available space size, the first storage space size and the second available space size, obtaining an available target storage space in the second storage device;
and converting the target storage space into a first storage type, and storing the data to be stored into the available storage space in the first storage device and the target storage space.
2. The method of claim 1, further comprising:
determining the size of a space to be increased based on the first available space size and the first storage space size;
determining 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 larger than or equal to the space size to be increased, determining that the second storage area meets the storage type conversion condition.
3. The method of claim 2, wherein when the first storage type is a sequential storage type and the second storage type is a random storage type, determining a size of space to be added based on the first available space size and the first storage space size comprises:
determining a first difference space size between the first available space size and the first storage space size;
determining a first number of first storage units needing to be supplemented based on the first difference space size and a first unit space size, wherein the first unit space size is a space size occupied by one first storage unit of the first storage type;
determining a second difference space size based on the first number and the first unit space size;
and determining the second difference space size as the space size to be increased.
4. The method of claim 2, wherein when the first storage type is a random storage type and the second storage type is a sequential storage type, determining a size of space to be added based on the first available space size and the first storage space size comprises:
acquiring a reserved space proportion corresponding to the random storage type;
determining a second number of first storage units needing to be supplemented based on the first difference space size, the first unit space size and the reserved space proportion;
determining a third difference space size based on the second number and the first unit space size;
and determining the third difference value as the size of the space to be increased.
5. The method of claim 2, wherein the obtaining the target storage space available in the second storage device comprises:
when the second storage device has a continuous available space with the size of the space to be increased, determining the continuous available space with the size of the space to be increased as a target storage space;
when the continuous available space is not available in the second storage device, acquiring storage state information of each second storage unit in the second storage device;
and performing data migration on the stored data in each second storage unit based on each piece of storage state information to obtain the target storage space of the space to be increased.
6. The method according to claim 5, wherein the performing data migration on the stored data in each second storage unit based on the storage status information to obtain the target storage space of the to-be-increased space size comprises:
determining an idle second storage unit and an occupied second storage unit based on the storage state information;
determining a size of used space of the occupied second storage unit and a size of available space of the occupied second storage unit;
and performing data transfer between the occupied second storage units based on the size of the used space and the size of the available space of the occupied second storage units to obtain the target storage space of the size of the space to be increased.
7. The method of claim 2, further comprising:
when the second available space size is smaller than the space size to be increased, determining that the second storage device does not meet storage type conversion conditions;
determining a fourth difference space size based on the second available space size and the space size to be increased;
determining data to be deleted 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;
when the size of the storage space occupied by the data to be deleted is larger than or equal to the size of the fourth difference space, outputting prompt information of deleting the data;
and in response to the received deleting instruction, deleting the data to be deleted.
8. The method of claim 7, further comprising:
when the size of the storage space occupied by the data to be deleted is smaller than the size of the fourth difference space, determining the size of a minimum expansion space based on the size of the storage space occupied by the data to be deleted and the size of the fourth difference space;
and outputting prompt information which is insufficient in storage space and needs to be expanded, wherein the prompt information carries the minimum expansion space.
9. The method of claim 1, further comprising:
when the second storage area is determined to meet the storage type conversion condition, controlling to pause input and output operations;
correspondingly, after storing the data to be stored in the available storage space in the first storage area and the target storage space, the method further includes:
and controlling and recovering the input and output operation.
10. The method according to any one of claims 1 to 7, wherein the determining the first storage type corresponding to the data to be stored comprises:
predicting an access heat value of the data to be stored based on the data to be stored;
when the access heat value is higher than a preset heat threshold, determining that the 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.
11. The method of any of claims 1 to 7, after obtaining the target storage space available in the second storage device, the method further comprising:
acquiring each second storage identifier corresponding to each second storage unit included in the target storage space;
acquiring a maximum storage identifier of a first storage unit in the first storage device;
and updating the storage unit information in the first storage equipment and the second storage equipment based on the second storage identifications and the maximum storage identification.
12. A memory device, comprising:
the device comprises a first acquisition module, a second acquisition module and a storage module, wherein the first acquisition module is used for acquiring data to be stored and determining a first storage type corresponding to the data to be stored and a first storage space size required to be occupied;
the first determining module is used for determining a second available space size of a second storage device corresponding to a second storage type when the first available space size of a first storage device corresponding to the first storage type is smaller than the first storage space size;
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 satisfies the storage type conversion condition based on the first available space size, the first storage space size, and the second available space size;
and the data storage module is used for converting the target storage space into a first storage type and storing the data to be stored into the available storage space in the first storage device and the target storage space.
13. An electronic device, comprising:
a memory for storing executable instructions;
a processor, when executing executable instructions stored in the memory, implementing the storage method of any one of claims 1 to 11.
14. A computer-readable storage medium storing executable instructions for implementing the storage method of any one of claims 1 to 11 when executed by a processor.
CN202110875240.6A 2021-07-30 2021-07-30 Data storage method, device, equipment and computer readable storage medium Pending CN115686347A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110875240.6A CN115686347A (en) 2021-07-30 2021-07-30 Data storage method, device, equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110875240.6A CN115686347A (en) 2021-07-30 2021-07-30 Data storage method, device, equipment and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN115686347A true CN115686347A (en) 2023-02-03

Family

ID=85059620

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110875240.6A Pending CN115686347A (en) 2021-07-30 2021-07-30 Data storage method, device, equipment and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN115686347A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116884464A (en) * 2023-09-06 2023-10-13 上海芯存天下电子科技有限公司 flash chip erasing method and device and flash chip

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116884464A (en) * 2023-09-06 2023-10-13 上海芯存天下电子科技有限公司 flash chip erasing method and device and flash chip
CN116884464B (en) * 2023-09-06 2023-12-05 上海芯存天下电子科技有限公司 flash chip erasing method and device and flash chip

Similar Documents

Publication Publication Date Title
US10860217B2 (en) System and method of management of multi-tier storage systems
CN107844431B (en) Mapping table updating method, memory control circuit unit and memory storage device
US6823417B2 (en) Memory controller for memory card manages file allocation table
KR100375533B1 (en) Data processing system, block erasing type memory device and memory medium storing program for controlling memory device
US6459644B2 (en) Semiconductor memory device with block alignment function
JP4415356B2 (en) Double journaling storage method and storage medium thereof
US7647470B2 (en) Memory device and controlling method for elongating the life of nonvolatile memory
US8589617B2 (en) Write once recording device
WO2005015406A1 (en) Semiconductor memory card, and accessing device and method
CN101276282B (en) External storage device and method of automatically operating the same
CN107908571B (en) Data writing method, flash memory device and storage equipment
WO2005050453A1 (en) File recording device
CN108628542B (en) File merging method and controller
KR101049617B1 (en) Memory and memory systems
KR20200040544A (en) Memory controller, storage device including the same, and operating method of the memory controller
US20110022645A1 (en) Access device, information recording device, information recording system, file management method, and program
CN111796759B (en) Computer readable storage medium and method for fragment data reading on multiple planes
US9015444B2 (en) Access apparatus and available storage space calculation method
JP5962140B2 (en) Program, control method, control apparatus and system
CN115686347A (en) Data storage method, device, equipment and computer readable storage medium
CN102200946B (en) Data access method, memory controller and storage system
JP2017049897A (en) Storage device, storage device control program, and storage device control method
CN101078972B (en) Data storing device and data access method
CN115562595B (en) Volume creating method and device, volume reading and writing method and device, and electronic equipment
US20100217787A1 (en) Controller, information recording device, access device, information recording system, and information recording method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40081291

Country of ref document: HK