Data storage method and system, electronic equipment, storage medium and program product
By dividing the hard disk into multiple track areas and distributing storage according to data popularity, the problem of reduced throughput performance caused by increased hard disk capacity is solved, and data storage performance is improved.
Patent Information
- Application Number
- CN202410362642.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-27
- Publication Date
- 2025-09-30
AI Technical Summary
As hard disk capacity increases, the throughput performance of the hard disk per unit time decreases, and existing technologies have failed to effectively solve this problem.
The hard disk is divided into multiple track areas, and the data is stored in the corresponding track area according to its heat. Hot data is stored in the area farther away from the center of the disk, and cold data is stored in the area closer to the center of the disk.
Without increasing costs, the data storage performance of hard drives is improved in scenarios with high concentration of hot data and large traffic.
Smart Images

Figure CN120723142A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and in particular to a data storage method, system, electronic device, storage medium, and program product. Background Art
[0002] Currently, to lower data storage costs, the capacity of HDDs (hard disk drives) is increasing. While the mechanical structure of the disk remains unchanged, that is, the seek time and rotation speed of the HDD remain unchanged, the larger addressing range in random read and write scenarios leads to a decrease in IOPS (Input / Output Operations Per Second) per terabyte (Terabyte).
[0003] To address the above-mentioned problems, no effective solutions have been proposed so far. Summary of the Invention
[0004] The embodiments of the present application provide a data storage method, system, electronic device, storage medium and program product to at least solve the technical problem that the throughput performance of the hard disk per unit time decreases as the hard disk capacity increases.
[0005] According to one aspect of an embodiment of the present application, a data storage method is provided, including: obtaining target data to be stored, and determining a target heat of the target data; determining a target track area corresponding to the target heat from multiple track areas of a target hard disk based on a preset mapping relationship, wherein, in the mapping relationship, the higher the data heat, the farther the corresponding track area is from the center of the disk; determining a storage space status of the target track area, and determining a target storage strategy based on the storage space status, wherein the target storage strategy includes: storing the target data in the target track area, or storing the target data in an alternative track area corresponding to the target track area; and storing the target data according to the target storage strategy.
[0006] Optionally, the storage space status of the target track area is determined, and the target storage strategy is determined based on the storage space status, including: determining whether there is a free sub-area in the target track area; if there is a free sub-area in the target track area, determining the target storage strategy to store the target data in the target track area; if there is no free sub-area in the target track area, determining an alternative track area corresponding to the target track area, and determining the target storage strategy to store the target data in the alternative track area.
[0007] Optionally, determining the alternative track area corresponding to the target track area includes: if the target heat of the target data is higher than the preset heat, starting from the target track area, detecting the next track area with a free sub-area in order from near to far from the center of the disk as the alternative track area; if there is still no free sub-area until the outermost track area is detected, starting from the target track area, detecting the next track area with a free sub-area in order from far to near from the center of the disk as the alternative track area; if the target heat of the target data is not higher than the preset heat, starting from the target track area, detecting the next track area with a free sub-area in order from far to near from the center of the disk as the alternative track area; if there is still no free sub-area until the innermost track area is detected, starting from the target track area, detecting the next track area with a free sub-area in order from near to far from the center of the disk as the alternative track area.
[0008] Optionally, each track area in the target hard disk corresponds to a first bitmap mark, and the first bitmap mark is used to indicate whether there is a free sub-area in the track area; determining whether there is a free sub-area in the target track area includes: detecting the first bitmap mark corresponding to the target track area, and determining whether there is a free sub-area in the target track area based on the first bitmap mark.
[0009] Optionally, each track area in the target hard disk stores data with blocks as storage granularity, wherein each block includes a preset number of logical block addresses, and each logical block address corresponds to a sector of a preset size.
[0010] Optionally, the target data is stored according to the target storage strategy, including: if the target storage strategy is to store the target data in the target track area, determining each free block in the target track area one by one, and writing the target data into the free blocks until the target data storage is completed; when there are no free blocks in the target track area but the target data has not been stored completely, determining each free block in the alternative track area one by one, and continuing to write the target data into the free blocks until the target data storage is completed; if the target storage strategy is to store the target data in the alternative track area, determining each free block in the alternative track area one by one, and writing the target data into the free blocks until the target data storage is completed; when there are no free blocks in the alternative track area but the target data has not been stored completely, determining each free block in the next alternative track area corresponding to the alternative track area one by one, and continuing to write the target data into the free blocks until the target data storage is completed.
[0011] Optionally, each block in each track area in the target hard disk corresponds to a second bitmap mark, and the second bitmap mark is used to indicate whether the block is a free block.
[0012] Optionally, the process of determining the free block includes: starting from the starting position of the target area, detecting the second bitmap mark corresponding to each block one by one, and determining whether the detected block is a free block based on the second bitmap mark; wherein the target area includes one of the following: the target track area, the alternative track area, and the next alternative track area corresponding to the alternative track area.
[0013] Optionally, for each track area, each time data storage is completed, the target position of the last block of stored data in the track area is recorded.
[0014] Optionally, the process of determining the free block includes: starting from the target position recorded when the target area last stored data, detecting the second bitmap mark corresponding to each block one by one, and determining whether the detected block is a free block based on the second bitmap mark; if no free block is detected until the end of the target area, starting again from the starting position of the target area, detecting the second bitmap mark corresponding to each block one by one, and determining whether the detected block is a free block based on the second bitmap mark; wherein the target area includes one of the following: a target track area, an alternative track area, and a next alternative track area corresponding to the alternative track area.
[0015] Optionally, determining the target heat of the target data includes: determining the target heat of the target data using a pre-trained heat prediction model, wherein the heat prediction model is trained using historical data as training samples and using the heat of the historical data as sample labels.
[0016] Optionally, the target hard disk is a mechanical hard disk, and all tracks of the mechanical hard disk are divided into a target number of track areas from far to near from the center of the disk based on a preset ratio; the data temperature is divided from hot to cold into: a target number of temperature levels corresponding to the target number of track areas from far to near from the center of the disk.
[0017] Optionally, after obtaining the target data to be stored, the method also includes: determining the target capacity of the target data and determining the remaining storage capacity of the target hard disk; if the target capacity is greater than the remaining storage capacity, outputting an alarm message, wherein the alarm message is used to prompt that the storage capacity of the target hard disk is full and data storage cannot continue; if the target capacity is not greater than the remaining storage capacity, continuing to determine the target track area corresponding to the target heat.
[0018] According to one aspect of an embodiment of the present application, a data storage method is also provided, including: obtaining target data to be stored, and determining a target heat of the target data; determining a target hard disk corresponding to the target heat from a plurality of hard disks based on a preset mapping relationship; when the target hard disk is a solid-state hard disk, storing the target data in the solid-state hard disk; when the target hard disk is a mechanical hard disk, determining a target track area corresponding to the target heat from a plurality of track areas of the mechanical hard disk based on a mapping relationship, wherein, in the mapping relationship, the higher the heat of the data, the farther the corresponding track area is from the center of the disk; determining a storage space status of the target track area, and determining a target storage strategy based on the storage space status, wherein the target storage strategy includes: storing the target data in the target track area, or storing the target data in an alternative track area corresponding to the target track area; storing the target data according to the target storage strategy.
[0019] Optionally, all tracks of the mechanical hard disk are divided into a target number of track areas from far to near from the center of the disk based on a preset ratio; data temperature is divided from hot to cold into: the highest temperature level corresponding to the solid-state hard disk, and a target number of temperature levels with a temperature lower than the highest temperature level corresponding to the target number of track areas from far to near from the center of the disk.
[0020] According to one aspect of an embodiment of the present application, a data storage method is also provided, including: obtaining target data to be stored, and obtaining a specified track area of the target data in a target hard disk, wherein the target hard disk includes multiple track areas; determining the storage space status of the specified track area, and determining a target storage strategy based on the storage space status, wherein the target storage strategy includes: storing the target data in the specified track area, or storing the target data in an alternative track area corresponding to the specified track area; and storing the target data according to the target storage strategy.
[0021] According to another aspect of an embodiment of the present application, a data storage system is also provided, including: a file management system and a storage hard disk, wherein the type of the storage hard disk includes at least a mechanical hard disk, and the mechanical hard disk includes multiple track areas; a file management system for executing the methods in each embodiment of the present application.
[0022] According to another aspect of the embodiments of the present application, an electronic device is provided, including: a memory storing an executable program; and a processor for running the program, wherein the program executes the methods in the various embodiments of the present application when running.
[0023] According to another aspect of an embodiment of the present application, a computer-readable storage medium is also provided, which includes a stored executable program, wherein when the executable program is running, the device where the computer-readable storage medium is located is controlled to execute the methods in various embodiments of the present application.
[0024] According to another aspect of the embodiments of the present application, a computer program product is further provided, including a computer program, which implements the methods in various embodiments of the present application when executed by a processor.
[0025] In an embodiment of the present application, when storing data, first obtain the target data to be stored and determine the target heat of the target data; then determine the target track area corresponding to the target heat from multiple track areas of the target hard disk based on a preset mapping relationship, wherein, in the mapping relationship, the higher the data heat, the farther the corresponding track area is from the center of the disk; then determine the storage space status of the target track area, and determine the target storage strategy based on the storage space status, wherein the target storage strategy includes: storing the target data in the target track area, or storing the target data in the alternative track area corresponding to the target track area; finally, store the target data according to the target storage strategy. In this solution, by dividing the target hard disk into multiple track areas and shunting the target storage status, i.e., hot and cold data, into different track areas, the data storage performance of the target hard disk can be improved without increasing costs in scenarios where the hot data concentration is high and the traffic is large, effectively solving the technical problem that the throughput performance of the hard disk per unit time decreases as the hard disk capacity increases.
[0026] It is easy to notice that the above general description and the following detailed description are merely for the purpose of exemplifying and explaining the present application, and do not constitute a limitation of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0028] Figure 1 is a schematic structural diagram of an optional storage hard disk according to an embodiment of the present application;
[0029] Figure 2 is a schematic structural diagram of an optional data storage system according to an embodiment of the present application;
[0030] Figure 3 is a schematic diagram of an optional method for determining an idle sub-area according to an embodiment of the present application;
[0031] Figure 4 is a flow chart of an optional data storage method according to an embodiment of the present application;
[0032] Figure 5 is a flowchart of another optional data storage method according to an embodiment of the present application;
[0033] Figure 6 is a flowchart of another optional data storage method according to an embodiment of the present application;
[0034] Figure 7 is a schematic structural diagram of an optional data storage device according to an embodiment of the present application;
[0035] Figure 8 is a schematic structural diagram of another optional data storage device according to an embodiment of the present application;
[0036] Figure 9 is a schematic structural diagram of another optional data storage device according to an embodiment of the present application;
[0037] Figure 10 It is a schematic structural diagram of an optional electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0038] In order to enable those skilled in the art to better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this application.
[0039] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in a sequence other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0040] First, some nouns or terms that appear in the description of the embodiments of the present application are subject to the following interpretations:
[0041] LBA (Logical Block Addressing): It is a common mechanism for describing the blocks where data is located on computer storage devices.
[0042] Example 1
[0043] Figure 1 A schematic diagram of the structure of an optional storage hard disk is shown. Figure 1 As shown, a storage hard disk includes: a platter, inner and outer tracks, sectors, and cylinders. A platter is a circular magnetic disk. A platter can have two surfaces, and both the front and back sides can be read and written ( Figure 1 Only one disk surface is used as an example); the inner and outer tracks are the circles of tracks on the disk, the inner tracks are closer to the center of the circle, and the outer tracks are farther away from the center of the circle; sectors are small areas on the disk tracks separated by numbers ( Figure 1 1, 4, 31, 34 in the disk). Since the size of the sector is fixed, the number of sectors on the outer track is greater and the number of sectors on the inner track is less. The cylinder is a hollow cylinder composed of the tracks at the same position on the disk ( Figure 1 dark part in the image).
[0044] The reading and writing of storage hard disks mainly rely on the movement of two places: the magnetic arm controls the movement of the magnetic head between the circumference and the center of the circle. The movement range is the radius of the disk surface. In this way, the appropriate track can be found; the disk rotates around the center of the circle to move the appropriate sector under the magnetic head; when the disk is empty, the traditional data writing order is from the outer track to the inner track. When the disk rotates at the same angle, the outer track rotates a larger area, so the writing speed of the outer track is faster than that of the inner track. Based on this feature, the outer track performance of the hard disk is better, and the inner track performance is worse.
[0045] Currently, in order to achieve lower costs, the capacity of storage hard drives is getting larger and larger. While the mechanical structure of the disk reading and writing itself remains unchanged, that is, the seek time and disk rotation speed remain unchanged, in random read and write scenarios, the addressing range is larger, resulting in a decrease in the number of read and write operations per second on a single TB.
[0046] In order to solve the above problems, the embodiment of the present application takes into account the different data storage performance in different track areas of the storage hard disk, divides the storage hard disk into multiple track areas from the outside to the inside according to the tracks, and stores the target data in the corresponding track area according to the thermal state of the target data to be written, thereby achieving the purpose of improving the data storage performance of the storage hard disk.
[0047] The present application provides a data storage system. Figure 2 As shown, the system includes: a file management system 21 and a storage hard disk 22, wherein:
[0048] The storage hard disk 22 includes at least a mechanical hard disk, which includes multiple track areas;
[0049] The file management system 21 can implement different data storage methods.
[0050] The functions of each module of the data storage system are described below in conjunction with a specific implementation process.
[0051] Since traditional file systems cannot specify the LBA location to be written by themselves, staff can only know the file semantic interface provided by the file system. Therefore, the file management system in the embodiment of the present application uses a self-developed file system, which can specify the file to be written to the inner LBA or outer LBA of the mechanical hard disk.
[0052] In some scenarios, the storage hard disk is only a mechanical hard disk. In this case, the self-developed file system will store the target data in different track areas of the mechanical hard disk according to the data popularity.
[0053] As an optional implementation, the target data to be stored can be obtained, and the target heat of the target data can be determined; the target track area corresponding to the target heat can be determined from multiple track areas of the target hard disk based on a preset mapping relationship, wherein, in the mapping relationship, the higher the data heat, the farther the corresponding track area is from the center of the disk; the storage space status of the target track area can be determined, and the target storage strategy can be determined based on the storage space status, wherein the target storage strategy includes: storing the target data in the target track area, or storing the target data in an alternative track area corresponding to the target track area; and storing the target data according to the target storage strategy.
[0054] Optionally, all tracks of the mechanical hard disk are divided into a target number of track areas from far to near from the center of the disk based on a preset ratio; data temperature is divided from hot to cold into: a target number of temperature levels corresponding to the target number of track areas from far to near from the center of the disk.
[0055] Among them, the preset ratio and target number can be set according to actual needs. For example, 10% of the tracks from the outside to the inside are divided into the outer track area, 60% are divided into the middle track area, and 30% are divided into the inner track area. The data heat level can be divided into high heat, medium heat and low heat. In the mapping relationship, high heat corresponds to the outer track area, medium heat corresponds to the middle track area, and low heat corresponds to the inner track area.
[0056] Optionally, the target heat of the target data can be determined in the following manner: the target heat of the target data is determined using a pre-trained heat prediction model, wherein the heat prediction model is trained using historical data as training samples and the heat of the historical data as sample labels, wherein the heat of the historical data can be determined by users labeling it themselves.
[0057] When storing data, in order to avoid the situation where the storage hard disk is full and cannot continue to store data, after obtaining the target data to be stored, the target capacity of the target data can be determined first, and the remaining storage capacity of the target hard disk can be determined; if the target capacity is greater than the remaining storage capacity, an alarm message is output, wherein the alarm message is used to prompt that the storage capacity of the target hard disk is full and data storage cannot continue; if the target capacity is not greater than the remaining storage capacity, the target track area corresponding to the target temperature is further determined.
[0058] Optionally, after determining the target track area, the storage space status of the target track area can be determined in the following manner, and the target storage strategy can be determined based on the storage space status: determine whether there is a free sub-area in the target track area; if there is a free sub-area in the target track area, determine the target storage strategy to store the target data in the target track area; if there is no free sub-area in the target track area, determine the alternative track area corresponding to the target track area, and determine the target storage strategy to store the target data in the alternative track area.
[0059] Since the track area is user-defined, the remaining capacity of each track area cannot be directly obtained. Therefore, a user-defined bitmap mark can be used to determine whether each track area is full.
[0060] Specifically, each track area in the target hard disk corresponds to a first bitmap mark, and the first bitmap mark is used to indicate whether there is a free sub-area in the track area; when determining whether there is a free sub-area in the target track area, the first bitmap mark corresponding to the target track area can be detected, and whether there is a free sub-area in the target track area can be determined based on the first bitmap mark.
[0061] Optionally, when there is no free sub-area in the target track area, the alternative track area corresponding to the target track area can be determined in the following manner: if the target heat of the target data is higher than the preset heat, starting from the target track area, the next track area with a free sub-area is detected in order from near to far from the center of the disk as the alternative track area; if there is still no free sub-area until the outermost track area is detected, starting from the target track area, the next track area with a free sub-area is detected in order from far to near from the center of the disk as the alternative track area; if the target heat of the target data is not higher than the preset heat, starting from the target track area, the next track area with a free sub-area is detected in order from far to near from the center of the disk as the alternative track area; if there is still no free sub-area until the innermost track area is detected, starting from the target track area, the next track area with a free sub-area is detected in order from near to far from the center of the disk as the alternative track area.
[0062] It can be understood that if the target data is hot, a track area with free sub-areas that is closer to the target track area is selected from the outer track as the alternative track area; if the target data is hot, a track area with free sub-areas that is closer to the target track area is selected from the inner track as the alternative track area.
[0063] Taking the track area as an example, if the data heat is high and higher than the preset heat, the target track area is the outer track area, and its corresponding alternative track areas are: middle track area, inner track area; if the data heat is medium and higher than the preset heat, the target track area is the middle track area, and its corresponding alternative track areas are: outer track area, inner track area; if the data heat is medium and lower than the preset heat, the target track area is the middle track area, and its corresponding alternative track areas are: inner track area, outer track area; if the data heat is low and lower than the preset heat, the target track area is the inner track area, and its corresponding alternative track areas are: middle track area, outer track area.
[0064] Optionally, each track area in the target hard disk stores data with blocks as storage granularity, wherein each block includes a preset number of logical block addresses, and each logical block address corresponds to a sector of a preset size.
[0065] It can be understood that in the self-developed file system, the writing granularity is block, and the specific size of the block can be set according to actual needs. For example, 1 block is 1MB, and the sector represented by 1 logical block LBA is 4K, then 1 block has 256 sectors.
[0066] When storing the target data according to the target storage strategy, it can be done as follows: if the target storage strategy is to store the target data in the target track area, determine each free block in the target track area one by one, and write the target data into the free block until the target data storage is completed; when there are no free blocks in the target track area but the target data has not been stored completely, determine each free block in the alternative track area one by one, and continue to write the target data into the free block until the target data storage is completed; if the target storage strategy is to store the target data in the alternative track area, determine each free block in the alternative track area one by one, and write the target data into the free block until the target data storage is completed; when there are no free blocks in the alternative track area but the target data has not been stored completely, determine each free block in the next alternative track area corresponding to the alternative track area one by one, and continue to write the target data into the free block until the target data storage is completed.
[0067] Optionally, each block in each track area of the target hard disk corresponds to a second bitmap flag, and the second bitmap flag is used to indicate whether the block is a free block. For example, the second bitmap flag can be represented by a bit value, taking a value of 0 or 1. When the bit value is 0, it indicates that no data has been written to the block, and when the bit value is 1, it indicates that data already exists in the block.
[0068] Optionally, a method for determining free blocks in a track area includes: starting from the starting position of the target area, detecting the second bitmap mark corresponding to each block one by one, and determining whether the detected block is a free block based on the second bitmap mark; wherein the target area includes one of the following: a target track area, an alternative track area, and the next alternative track area corresponding to the alternative track area.
[0069] It can be understood that the above solution is applicable to the case where the disk usage capacity of the storage hard disk is low. In this case, each block in the target storage area can be traversed, and as long as a block with no data written is detected, the corresponding target data can be stored in the corresponding block.
[0070] Taking into account the case where the disk usage capacity of the storage hard disk is high, if data is continued to be stored in the form of blocks traversing the target storage area as described above, it may take a lot of time and reduce storage efficiency. For example, there is a target data that is specified to be stored in the outer track area, but all the free sub-areas of the outer track area and the middle track area are not enough to store the complete target data. In this case, this storage needs to retrieve all the blocks in the outer track area and the middle track area. In the worst case, it may also be necessary to retrieve all the blocks in the inner track area. In this case, it is necessary to adopt another method to determine the free blocks in the track area.
[0071] Specifically, to improve the efficiency of free block retrieval, for each track area, each time data storage is completed, the target position of the last block of stored data in the track area may be recorded.
[0072] When determining the free blocks in the track area, you can start from the target position recorded when the target area was last stored with data, detect the second bitmap mark corresponding to each block one by one, and determine whether the detected block is a free block based on the second bitmap mark; if no free block is detected until the end of the target area, considering that some blocks before the target position may become free blocks due to data deletion, you can start again from the starting position of the target area, detect the second bitmap mark corresponding to each block one by one, and determine whether the detected block is a free block based on the second bitmap mark; wherein the target area includes one of the following: a target track area, an alternative track area, and a next alternative track area corresponding to the alternative track area.
[0073] Figure 3 A schematic diagram of determining free blocks is shown, such as Figure 3 As shown, starting from the third block of the target position recorded last time, the second bitmap mark of each block is determined in sequence. When the second bitmap mark of the fifth block is detected to be 0, it is determined that the fifth block is an available free block, and the target data can be written into the fifth block. After the writing is completed, the second bitmap mark of the fifth block is updated to 1; thereafter, there are no free blocks until the end of the target area, and the second bitmap mark of each block can be determined in sequence starting from the starting position of the target area, that is, the first block. When the second bitmap mark of the second block is detected to be 0, it is determined that the second block is an available free block, and the target data can be continued to be written into the second block. After the writing is completed, the second bitmap mark of the second block is updated to 1; thereafter, if the target data storage is completed, the process ends. If the target data storage is not completed, the above process is repeated in the next target area until the target data storage is completed.
[0074] In some scenarios, storage hard drives include both mechanical hard drives and solid-state drives. In this case, the self-developed file system can store the target data in different hard drives according to data popularity.
[0075] As an optional implementation, the target data to be stored can be obtained, and the target temperature of the target data can be determined; the target hard disk corresponding to the target temperature can be determined from multiple hard disks based on a preset mapping relationship; when the target hard disk is a solid-state hard disk, the target data is stored in the solid-state hard disk; when the target hard disk is a mechanical hard disk, the target track area corresponding to the target temperature can be determined from multiple track areas of the mechanical hard disk based on the mapping relationship, wherein, in the mapping relationship, the higher the temperature of the data, the farther the corresponding track area is from the center of the disk; the storage space status of the target track area is determined, and the target storage strategy is determined based on the storage space status, wherein the target storage strategy includes: storing the target data in the target track area, or storing the target data in the alternative track area corresponding to the target track area; storing the target data according to the target storage strategy.
[0076] Optionally, all tracks of the mechanical hard disk are divided into a target number of track areas from far to near from the center of the disk based on a preset ratio; data temperature is divided from hot to cold into: the highest temperature level corresponding to the solid-state hard disk, and a target number of temperature levels with a temperature lower than the highest temperature level corresponding to the target number of track areas from far to near from the center of the disk.
[0077] For example, from the outside to the inside, 10% of the mechanical hard disk tracks are divided into the outer track area, 60% are divided into the middle track area, and 30% are divided into the inner track area. The data heat level can be divided into ultra-high heat, high heat, medium heat and low heat. In the mapping relationship, ultra-high heat corresponds to the solid-state hard disk, high heat corresponds to the outer track area, medium heat corresponds to the middle track area, and low heat corresponds to the inner track area.
[0078] In some scenarios, users will also specify a storage location to store the target data. At this time, the self-developed file system can obtain the target data to be stored and obtain the specified track area of the target data in the target hard disk, where the target hard disk includes multiple track areas; determine the storage space status of the specified track area, and determine the target storage strategy based on the storage space status, where the target storage strategy includes: storing the target data in the specified track area, or storing the target data in the alternative track area corresponding to the specified track area; storing the target data according to the target storage strategy.
[0079] In an embodiment of the present application, by dividing the target hard disk into multiple track areas and storing the target storage status, i.e., hot and cold data, in different track areas, the data storage performance of the target hard disk can be improved without increasing the cost in scenarios with high hot data concentration and large traffic, effectively solving the technical problem of the decrease in the throughput performance of the hard disk per unit time as the hard disk capacity increases.
[0080] Example 2
[0081] Based on the data storage system provided in Example 1, the embodiment of the present application also provides a data storage method. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0082] Figure 4 Flowchart of the data storage method according to the embodiment of the present application. Figure 4 As shown, the method may include the following steps:
[0083] Step S402: acquiring target data to be stored and determining the target popularity of the target data;
[0084] Step S404: determining a target track area corresponding to the target temperature from multiple track areas of the target hard disk according to a preset mapping relationship, wherein, in the mapping relationship, the higher the data temperature, the farther the corresponding track area is from the center of the disk;
[0085] Step S406: determining the storage space status of the target track area, and determining a target storage strategy based on the storage space status, wherein the target storage strategy includes: storing the target data in the target track area, or storing the target data in an alternative track area corresponding to the target track area;
[0086] Step S408: Store the target data according to the target storage policy.
[0087] The following describes each step of the data storage method in conjunction with a specific implementation process.
[0088] Optionally, the target hard disk is a mechanical hard disk, and all tracks of the mechanical hard disk are divided into a target number of track areas from far to near from the center of the disk based on a preset ratio; data heat is divided from hot to cold into: a target number of heat levels corresponding to the target number of track areas from far to near from the center of the disk.
[0089] Optionally, the target heat of the target data can be determined in the following manner: the target heat of the target data is determined using a pre-trained heat prediction model, wherein the heat prediction model is trained using historical data as training samples and the heat of the historical data as sample labels, wherein the heat of the historical data can be determined by users labeling it themselves.
[0090] When storing data, in order to avoid the situation where the storage hard disk is full and cannot continue to store data, after obtaining the target data to be stored, the target capacity of the target data can be determined first, and the remaining storage capacity of the target hard disk can be determined; if the target capacity is greater than the remaining storage capacity, an alarm message is output, wherein the alarm message is used to prompt that the storage capacity of the target hard disk is full and data storage cannot continue; if the target capacity is not greater than the remaining storage capacity, the target track area corresponding to the target temperature is further determined.
[0091] Optionally, after determining the target track area, the storage space status of the target track area can be determined in the following manner, and the target storage strategy can be determined based on the storage space status: determine whether there is a free sub-area in the target track area; if there is a free sub-area in the target track area, determine the target storage strategy to store the target data in the target track area; if there is no free sub-area in the target track area, determine the alternative track area corresponding to the target track area, and determine the target storage strategy to store the target data in the alternative track area.
[0092] Since the track area is user-defined, the remaining capacity of each track area cannot be directly obtained. Therefore, a user-defined bitmap mark can be used to determine whether each track area is full.
[0093] Specifically, each track area in the target hard disk corresponds to a first bitmap mark, and the first bitmap mark is used to indicate whether there is a free sub-area in the track area; when determining whether there is a free sub-area in the target track area, the first bitmap mark corresponding to the target track area can be detected, and whether there is a free sub-area in the target track area can be determined based on the first bitmap mark.
[0094] Optionally, when there is no free sub-area in the target track area, the alternative track area corresponding to the target track area can be determined in the following manner: if the target heat of the target data is higher than the preset heat, starting from the target track area, the next track area with a free sub-area is detected in order from near to far from the center of the disk as the alternative track area; if there is still no free sub-area until the outermost track area is detected, starting from the target track area, the next track area with a free sub-area is detected in order from far to near from the center of the disk as the alternative track area; if the target heat of the target data is not higher than the preset heat, starting from the target track area, the next track area with a free sub-area is detected in order from far to near from the center of the disk as the alternative track area; if there is still no free sub-area until the innermost track area is detected, starting from the target track area, the next track area with a free sub-area is detected in order from near to far from the center of the disk as the alternative track area.
[0095] It can be understood that if the target data is hot, a track area with free sub-areas that is closer to the target track area is selected from the outer track as the alternative track area; if the target data is hot, a track area with free sub-areas that is closer to the target track area is selected from the inner track as the alternative track area.
[0096] Optionally, each track area in the target hard disk stores data with blocks as storage granularity, wherein each block includes a preset number of logical block addresses, and each logical block address corresponds to a sector of a preset size.
[0097] When storing the target data according to the target storage strategy, it can be done as follows: if the target storage strategy is to store the target data in the target track area, determine each free block in the target track area one by one, and write the target data into the free block until the target data storage is completed; when there are no free blocks in the target track area but the target data has not been stored completely, determine each free block in the alternative track area one by one, and continue to write the target data into the free block until the target data storage is completed; if the target storage strategy is to store the target data in the alternative track area, determine each free block in the alternative track area one by one, and write the target data into the free block until the target data storage is completed; when there are no free blocks in the alternative track area but the target data has not been stored completely, determine each free block in the next alternative track area corresponding to the alternative track area one by one, and continue to write the target data into the free block until the target data storage is completed.
[0098] Optionally, each block in each track area in the target hard disk corresponds to a second bitmap mark, and the second bitmap mark is used to indicate whether the block is a free block.
[0099] On this basis, a method for determining the free blocks in the track area includes: starting from the starting position of the target area, detecting the second bitmap mark corresponding to each block one by one, and determining whether the detected block is a free block based on the second bitmap mark; wherein the target area includes one of the following: the target track area, the alternative track area, and the next alternative track area corresponding to the alternative track area.
[0100] It can be understood that the above solution is applicable to the case where the disk usage capacity of the storage hard disk is low. In this case, each block in the target storage area can be traversed, and as long as a block with no data written is detected, the corresponding target data can be stored in the corresponding block.
[0101] Taking into account the case where the disk usage capacity of the storage hard disk is high, if data is continued to be stored in the form of blocks traversing the target storage area as described above, it may take a lot of time and reduce storage efficiency. For example, there is a target data that is specified to be stored in the outer track area, but all the free sub-areas of the outer track area and the middle track area are not enough to store the complete target data. In this case, this storage needs to retrieve all the blocks in the outer track area and the middle track area. In the worst case, it may also be necessary to retrieve all the blocks in the inner track area. In this case, it is necessary to adopt another method to determine the free blocks in the track area.
[0102] Specifically, to improve the efficiency of free block retrieval, for each track area, each time data storage is completed, the target position of the last block of stored data in the track area may be recorded.
[0103] When determining the free blocks in the track area, you can start from the target position recorded when the target area was last stored with data, detect the second bitmap mark corresponding to each block one by one, and determine whether the detected block is a free block based on the second bitmap mark; if no free block is detected until the end of the target area, considering that some blocks before the target position may become free blocks due to data deletion, you can start again from the starting position of the target area, detect the second bitmap mark corresponding to each block one by one, and determine whether the detected block is a free block based on the second bitmap mark; wherein the target area includes one of the following: a target track area, an alternative track area, and a next alternative track area corresponding to the alternative track area.
[0104] In an embodiment of the present application, by dividing the target hard disk into multiple track areas and storing the target storage status, i.e., hot and cold data, in different track areas, the data storage performance of the target hard disk can be improved without increasing the cost in scenarios with high hot data concentration and large traffic, effectively solving the technical problem of the decrease in the throughput performance of the hard disk per unit time as the hard disk capacity increases.
[0105] Example 3
[0106] Based on the data storage system provided in Example 1, this embodiment of the application also provides a data storage method, such as Figure 5 As shown, the method may include the following steps:
[0107] Step S502: acquiring target data to be stored and determining the target popularity of the target data;
[0108] Step S504, determining a target hard disk corresponding to the target temperature from the multiple hard disks according to a preset mapping relationship;
[0109] Step S506, when the target hard disk is a solid state hard disk, storing the target data in the solid state hard disk;
[0110] Step S508, when the target hard disk is a mechanical hard disk, determine the target track area corresponding to the target temperature from multiple track areas of the mechanical hard disk based on the mapping relationship, wherein, in the mapping relationship, the higher the temperature of the data, the farther the corresponding track area is from the center of the disk; determine the storage space status of the target track area, and determine the target storage strategy based on the storage space status, wherein the target storage strategy includes: storing the target data in the target track area, or storing the target data in the alternative track area corresponding to the target track area; storing the target data according to the target storage strategy.
[0111] The following describes each step of the data storage method in conjunction with a specific implementation process.
[0112] Among them, all tracks of the mechanical hard disk are divided into a target number of track areas from far to near from the center of the disk based on a preset ratio; data temperature is divided from hot to cold into: the highest temperature level corresponding to the solid-state hard disk, and a target number of temperature levels with a temperature lower than the highest temperature level corresponding to the target number of track areas from far to near from the center of the disk.
[0113] For example, from the outside to the inside, 10% of the mechanical hard disk tracks are divided into the outer track area, 60% are divided into the middle track area, and 30% are divided into the inner track area. The data heat level can be divided into ultra-high heat, high heat, medium heat and low heat. In the mapping relationship, ultra-high heat corresponds to the solid-state hard disk, high heat corresponds to the outer track area, medium heat corresponds to the middle track area, and low heat corresponds to the inner track area.
[0114] When the target hard disk is a mechanical hard disk, the data storage method is the same as the process in Example 2. Since Example 2 has been described in detail, it will not be repeated here.
[0115] In an embodiment of the present application, by dividing the target hard disk into multiple track areas and storing the target storage status, i.e., hot and cold data, in different track areas, the data storage performance of the target hard disk can be improved without increasing the cost in scenarios with high hot data concentration and large traffic, effectively solving the technical problem of the decrease in the throughput performance of the hard disk per unit time as the hard disk capacity increases.
[0116] Example 4
[0117] Based on the data storage system provided in Example 1, this embodiment of the application also provides a data storage method, such as Figure 6 As shown, the method may include the following steps:
[0118] Step S602, obtaining target data to be stored, and obtaining a designated track area of the target data in the target hard disk, wherein the target hard disk includes multiple track areas;
[0119] Step S604: determining the storage space status of the designated track area, and determining a target storage strategy based on the storage space status, wherein the target storage strategy includes: storing the target data in the designated track area, or storing the target data in an alternative track area corresponding to the designated track area;
[0120] Step S606: Store the target data according to the target storage policy.
[0121] Among them, the above scheme is mainly aimed at the scenario where the target hard disk is a mechanical hard disk. The process of determining the target storage strategy and storing the target data based on the storage space status of the specified track area can refer to the process of determining the target storage strategy and storing the target data based on the storage space status of the target track area in Example 2. Since Example 2 has been described in detail, it will not be repeated here.
[0122] It should be noted that this solution can also be extended to scenarios where the storage hard disks include both mechanical hard disks and solid-state hard disks. When the user specifies that the target hard disk is a solid-state hard disk, the target data can be directly stored in the solid-state hard disk.
[0123] In an embodiment of the present application, by dividing the target hard disk into multiple track areas and storing the target storage status, i.e., hot and cold data, in different track areas, the data storage performance of the target hard disk can be improved without increasing the cost in scenarios with high hot data concentration and large traffic, effectively solving the technical problem of the decrease in the throughput performance of the hard disk per unit time as the hard disk capacity increases.
[0124] It should be noted that for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by this application.
[0125] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0126] Example 5
[0127] According to an embodiment of the present application, a data storage device for implementing the above data storage method is also provided. Figure 7 As shown, the device includes: an acquisition module 71, a first determination module 72, a second determination module 73 and a storage module 74, wherein:
[0128] The acquisition module 71 can acquire the target data to be stored and determine the target heat of the target data;
[0129] The first determining module 72 may determine a target track area corresponding to the target temperature from multiple track areas of the target hard disk according to a preset mapping relationship, wherein, in the mapping relationship, the higher the data temperature, the farther the corresponding track area is from the center of the disk;
[0130] The second determining module 73 may determine the storage space status of the target track area and determine a target storage strategy based on the storage space status, wherein the target storage strategy includes: storing the target data in the target track area, or storing the target data in an alternative track area corresponding to the target track area;
[0131] The storage module 74 may store the target data according to the target storage policy.
[0132] It should be noted that the above modules correspond to steps S402 to S408 in Example 2, and the examples and application scenarios implemented by each module and the corresponding steps are the same, but are not limited to the contents disclosed in Example 2. It should be noted that the above modules or units can be hardware components or software components stored in a memory and processed by one or more processors.
[0133] It should be noted that the preferred implementation scheme involved in the above embodiments of this application is the same as the scheme provided in Example 2, as well as the application scenario and implementation process, but is not limited to the scheme provided in Example 2.
[0134] Example 6
[0135] According to an embodiment of the present application, a data storage device for implementing the above data storage method is also provided. Figure 8 As shown, the device includes: an acquisition module 81, a first determination module 82, a storage module 83 and a second determination module 84, wherein:
[0136] The acquisition module 81 can acquire the target data to be stored and determine the target heat of the target data;
[0137] The first determination module 82 may determine a target hard disk corresponding to the target heat from a plurality of hard disks according to a preset mapping relationship;
[0138] The storage module 83 may store the target data in a solid-state hard disk when the target hard disk is a solid-state hard disk;
[0139] When the target hard disk is a mechanical hard disk, the second determination module 84 can determine the target track area corresponding to the target temperature from multiple track areas of the mechanical hard disk based on a mapping relationship, wherein, in the mapping relationship, the higher the temperature of the data, the farther the corresponding track area is from the center of the disk; determine the storage space status of the target track area, and determine the target storage strategy based on the storage space status, wherein the target storage strategy includes: storing the target data in the target track area, or storing the target data in an alternative track area corresponding to the target track area; and storing the target data according to the target storage strategy.
[0140] It should be noted that the above modules correspond to steps S502 to S508 in Example 3, and the examples and application scenarios implemented by each module and the corresponding steps are the same, but are not limited to the contents disclosed in the above Example 3. It should be noted that the above modules or units can be hardware components or software components stored in a memory and processed by one or more processors.
[0141] It should be noted that the preferred implementation scheme involved in the above embodiments of this application is the same as the scheme provided in Example 3, as well as the application scenario and implementation process, but is not limited to the scheme provided in Example 3.
[0142] Example 7
[0143] According to an embodiment of the present application, a data storage device for implementing the above data storage method is also provided. Figure 9 As shown, the device includes: an acquisition module 91, a determination module 92 and a storage module 93, wherein:
[0144] The acquisition module 91 can acquire target data to be stored and acquire a designated track area of the target data in the target hard disk, wherein the target hard disk includes multiple track areas;
[0145] The determination module 92 may determine the storage space status of the designated track area and determine a target storage strategy based on the storage space status, wherein the target storage strategy includes: storing the target data in the designated track area, or storing the target data in an alternative track area corresponding to the designated track area;
[0146] The storage module 93 may store the target data according to the target storage policy.
[0147] It should be noted that the above modules correspond to steps S602 to S606 in Example 4, and the examples and application scenarios implemented by each module and the corresponding steps are the same, but are not limited to the contents disclosed in the above Example 4. It should be noted that the above modules or units can be hardware components or software components stored in a memory and processed by one or more processors.
[0148] It should be noted that the preferred implementation scheme involved in the above embodiments of this application is the same as the scheme provided in Example 4, as well as the application scenario and implementation process, but is not limited to the scheme provided in Example 4.
[0149] Example 8
[0150] The embodiment of the present application may provide an electronic device, which may be any electronic device in a group of electronic devices. Optionally, in this embodiment, the electronic device may also be replaced by a terminal device such as a mobile terminal.
[0151] Optionally, in this embodiment, the electronic device may be located in at least one network device among a plurality of network devices of a computer network.
[0152] In this embodiment, the computer terminal can execute the program code in the method.
[0153] Optionally, FIG is a structural block diagram of an electronic device according to an embodiment of the present application. Figure 10 As shown, the electronic device A may include: one or more (only one is shown in the figure) processors 102, a memory 104, a storage controller, and a peripheral interface, wherein the peripheral interface is connected to a radio frequency module, an audio module and a display.
[0154] Among them, the memory can be used to store software programs and modules, such as program instructions / modules corresponding to the methods and devices in the embodiments of the present application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, implementing the methods in the above embodiments. The memory may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include a memory remotely located relative to the processor, and these remote memories may be connected to terminal A via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0155] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: obtain the target data to be stored and determine the target temperature of the target data; determine the target track area corresponding to the target temperature from multiple track areas of the target hard disk according to a preset mapping relationship, wherein, in the mapping relationship, the higher the data temperature, the farther the corresponding track area is from the center of the disk; determine the storage space status of the target track area, and determine the target storage strategy based on the storage space status, wherein the target storage strategy includes: storing the target data in the target track area, or storing the target data in the alternative track area corresponding to the target track area; storing the target data according to the target storage strategy.
[0156] Optionally, the processor may also execute the program code of the following steps: obtaining the target data to be stored, and determining the target heat of the target data; determining the target hard disk corresponding to the target heat from a plurality of hard disks according to a preset mapping relationship; when the target hard disk is a solid-state hard disk, storing the target data in the solid-state hard disk; when the target hard disk is a mechanical hard disk, determining the target track area corresponding to the target heat from a plurality of track areas of the mechanical hard disk according to the mapping relationship, wherein, in the mapping relationship, the higher the heat of the data, the farther the corresponding track area is from the center of the disk; determining the storage space status of the target track area, and determining the target storage strategy based on the storage space status, wherein the target storage strategy includes: storing the target data in the target track area, or storing the target data in the alternative track area corresponding to the target track area; storing the target data according to the target storage strategy.
[0157] Optionally, the processor may also execute the program code of the following steps: obtaining the target data to be stored, and obtaining the specified track area of the target data in the target hard disk, wherein the target hard disk includes multiple track areas; determining the storage space status of the specified track area, and determining the target storage strategy based on the storage space status, wherein the target storage strategy includes: storing the target data in the specified track area, or storing the target data in the alternative track area corresponding to the specified track area; and storing the target data according to the target storage strategy.
[0158] Those skilled in the art will appreciate that the structure shown in the figure is for illustrative purposes only, and the electronic device may also be a smartphone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (MID), a PAD, or other terminal device. This figure does not limit the structure of the above-mentioned electronic devices. For example, electronic device A may include more or fewer components (such as a network interface, a display device, etc.) than shown in the figure, or have a configuration different from that shown in the figure.
[0159] A person skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium, which may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a hard disk or an optical disk, etc.
[0160] Example 9
[0161] The embodiment of the present application further provides a computer-readable storage medium. Optionally, in this embodiment, the computer-readable storage medium can be used to store the program code executed by the method provided in the above embodiment.
[0162] Optionally, in this embodiment, the storage medium may be located in any electronic device in a group of electronic devices in a computer network, or in any mobile terminal in a group of mobile terminals.
[0163] Optionally, in this embodiment, the computer-readable storage medium is configured to store program code for executing the following steps: obtaining target data to be stored, and determining a target heat of the target data; determining a target track area corresponding to the target heat from multiple track areas of the target hard disk based on a preset mapping relationship, wherein, in the mapping relationship, the higher the data heat, the farther the corresponding track area is from the center of the disk; determining the storage space status of the target track area, and determining a target storage strategy based on the storage space status, wherein the target storage strategy includes: storing the target data in the target track area, or storing the target data in an alternative track area corresponding to the target track area; storing the target data according to the target storage strategy.
[0164] Optionally, the computer-readable storage medium is also configured to store program code for performing the following steps: obtaining target data to be stored and determining a target heat of the target data; determining a target hard disk corresponding to the target heat from a plurality of hard disks based on a preset mapping relationship; when the target hard disk is a solid-state hard disk, storing the target data in the solid-state hard disk; when the target hard disk is a mechanical hard disk, determining a target track area corresponding to the target heat from a plurality of track areas of the mechanical hard disk based on a mapping relationship, wherein, in the mapping relationship, the higher the heat of the data, the farther the corresponding track area is from the center of the disk; determining a storage space status of the target track area, and determining a target storage strategy based on the storage space status, wherein the target storage strategy includes: storing the target data in the target track area, or storing the target data in an alternative track area corresponding to the target track area; storing the target data according to the target storage strategy.
[0165] Optionally, the computer-readable storage medium is also configured to store program code for executing the following steps: obtaining target data to be stored, and obtaining a specified track area of the target data in the target hard disk, wherein the target hard disk includes multiple track areas; determining the storage space status of the specified track area, and determining a target storage strategy based on the storage space status, wherein the target storage strategy includes: storing the target data in the specified track area, or storing the target data in an alternative track area corresponding to the specified track area; and storing the target data according to the target storage strategy.
[0166] Example 10
[0167] The embodiment of the present application further provides a computer program product. Optionally, in this embodiment, the computer program product may include a computer program, and when the computer program is executed by a processor, the method provided in the embodiment is implemented.
[0168] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0169] In the above embodiments of the present application, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0170] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0171] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0172] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0173] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0174] The above is only a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A data storage method, characterized in that: include: Acquire target data to be stored, and determine target popularity of the target data; Determining a target track area corresponding to the target temperature from multiple track areas of the target hard disk according to a preset mapping relationship, wherein, in the mapping relationship, the higher the data temperature, the farther the corresponding track area is from the center of the disk; Determining a storage space status of the target track area, and determining a target storage strategy based on the storage space status, wherein the target storage strategy includes: storing the target data in the target track area, or storing the target data in an alternative track area corresponding to the target track area; The target data is stored according to the target storage policy.
2. The method according to claim 1, characterized in that Determining a storage space status of the target track area and determining a target storage strategy based on the storage space status includes: Determine whether there is an idle sub-area in the target track area; If there is an idle sub-area in the target track area, determining the target storage strategy to store the target data in the target track area; If there is no free sub-area in the target track area, a candidate track area corresponding to the target track area is determined, and the target storage strategy is determined to store the target data in the candidate track area.
3. The method according to claim 2, characterized in that Determining a candidate track area corresponding to the target track area includes: If the target heat of the target data is higher than the preset heat, starting from the target track area, in order from near to far from the center of the disk, a track area with a free sub-area is detected as the candidate track area; if no free sub-area exists after detecting the outermost track area, starting from the target track area, in order from far to near from the center of the disk, a track area with a free sub-area is detected as the candidate track area; If the target heat of the target data is not higher than the preset heat, starting from the target track area, the next track area with a free sub-area is detected in order from far to near from the center of the disk as the alternative track area. If there is still no free sub-area until the innermost track area is detected, starting from the target track area, the next track area with a free sub-area is detected in order from near to far from the center of the disk as the alternative track area.
4. The method according to claim 3, characterized in that Each track area in the target hard disk corresponds to a first bitmap mark, and the first bitmap mark is used to indicate whether there is an idle sub-area in the track area; Determining whether there is an idle sub-area in the target track area includes: detecting a first bitmap mark corresponding to the target track area, and determining whether there is an idle sub-area in the target track area according to the first bitmap mark.
5. The method according to claim 1, wherein Each track area in the target hard disk stores data with blocks as storage granularity, wherein each block includes a preset number of logical block addresses, and each logical block address corresponds to a sector of a preset size.
6. The method according to claim 5, characterized in that Storing the target data according to the target storage policy includes: If the target storage strategy is to store the target data in the target track area, each free block in the target track area is determined one by one, and the target data is written into the free blocks until the target data is stored; if there are no free blocks in the target track area but the target data is not stored, each free block in the candidate track area is determined one by one, and the target data is continued to be written into the free blocks until the target data is stored; If the target storage strategy is to store the target data in the alternative track area, determine each free block in the alternative track area one by one, and write the target data into the free blocks until the target data storage is completed; when there are no free blocks in the alternative track area but the target data has not been stored, determine each free block in the next alternative track area corresponding to the alternative track area one by one, and continue to write the target data into the free blocks until the target data storage is completed.
7. The method according to claim 6, characterized in that Each block in each track area of the target hard disk corresponds to a second bitmap mark, and the second bitmap mark is used to indicate whether the block is a free block.
8. The method according to claim 7, characterized in that The process of determining the free blocks includes: Starting from the starting position of the target area, detecting the second bitmap mark corresponding to each block one by one, and determining whether the detected block is a free block according to the second bitmap mark; The target area includes one of the following: the target track area, the candidate track area, and the next candidate track area corresponding to the candidate track area.
9. The method according to claim 7, characterized in that The method further comprises: For each track area, each time data storage is completed, the target position of the last block of stored data in the track area is recorded.
10. The method according to claim 9, characterized in that The process of determining the free blocks includes: Starting from the target position recorded when data was last stored in the target area, detecting the second bitmap mark corresponding to each block one by one, and determining whether the detected block is a free block according to the second bitmap mark; If no free block is detected at the end of the target area, starting again from the beginning of the target area, detecting the second bitmap mark corresponding to each block one by one, and determining whether the detected block is a free block based on the second bitmap mark; The target area includes one of the following: the target track area, the candidate track area, and the next candidate track area corresponding to the candidate track area.
11. The method according to claim 1, wherein Determining the target popularity of the target data includes: The target heat of the target data is determined using a pre-trained heat prediction model, wherein the heat prediction model is trained using historical data as training samples and using the heat of the historical data as sample labels.
12. The method according to claim 1, characterized in that The target hard disk is a mechanical hard disk, and all tracks of the mechanical hard disk are divided into a target number of track areas based on a preset ratio in descending order of distance from the center of the disk; The data temperatures are divided into a target number of temperature levels from hot to cold, which correspond to a target number of track areas from far to near the center of the disk.
13. The method according to claim 1, wherein After acquiring the target data to be stored, the method further includes: Determining a target capacity of the target data and determining a remaining storage capacity of the target hard disk; If the target capacity is greater than the remaining storage capacity, outputting a warning message, wherein the warning message is used to prompt that the storage capacity of the target hard disk is full and data storage cannot continue; If the target capacity is not greater than the remaining storage capacity, continue to determine a target track area corresponding to the target temperature.
14. A data storage method, characterized in that: include: Acquire target data to be stored, and determine target popularity of the target data; Determining a target hard disk corresponding to the target temperature from a plurality of hard disks according to a preset mapping relationship; When the target hard disk is a solid-state hard disk, storing the target data in the solid-state hard disk; When the target hard disk is a mechanical hard disk, a target track area corresponding to the target temperature is determined from multiple track areas of the mechanical hard disk based on the mapping relationship, wherein, in the mapping relationship, the higher the temperature of the data, the farther the corresponding track area is from the center of the disk; the storage space status of the target track area is determined, and a target storage strategy is determined based on the storage space status, wherein the target storage strategy includes: storing the target data in the target track area, or storing the target data in an alternative track area corresponding to the target track area; and storing the target data according to the target storage strategy.
15. The method according to claim 14, characterized in that All tracks of the mechanical hard disk are divided into a target number of track areas based on a preset ratio in descending order of distance from the center of the disk; Data heat is divided into the following categories from hot to cold: the highest heat level corresponding to the solid-state hard drive, and a target number of heat levels with heat lower than the highest heat level corresponding to a target number of track areas from far to near the center of the disk.
16. A data storage method, characterized in that: include: Acquire target data to be stored, and acquire a designated track area of the target data in a target hard disk, wherein the target hard disk includes multiple track areas; Determining a storage space status of the designated track area, and determining a target storage strategy based on the storage space status, wherein the target storage strategy includes: storing the target data in the designated track area, or storing the target data in an alternative track area corresponding to the designated track area; The target data is stored according to the target storage policy.
17. A data storage system, characterized in that: include: A file management system and a storage hard disk, wherein the storage hard disk includes at least a mechanical hard disk, and the mechanical hard disk includes multiple track areas; The file management system is used to execute the data storage method according to any one of claims 1 to 16.
18. An electronic device, characterized in that: include: a memory storing an executable program; A processor, configured to run the program, wherein when the program is run, the data storage method according to any one of claims 1 to 16 is executed.
19. A computer-readable storage medium, characterized in that The computer-readable storage medium includes a stored executable program, wherein when the executable program is running, the device where the computer-readable storage medium is located is controlled to execute the data storage method according to any one of claims 1 to 16.
20. A computer program product, characterized in that The invention comprises a computer program, which implements the data storage method according to any one of claims 1 to 16 when being executed by a processor.
Citation Information
Patent Citations
Data storage method and device and electronic equipment
CN109992210A
Method and system for data placement in a hard disk drive based on access frequency for improved IOPS and utilization efficiency
CN110633051A
Data storage method and device, computer equipment and storage medium
CN114661249A
Secure data deletion method for staggered recording disk and related equipment
CN115079948A
Strip unit allocation method and device, computer equipment and storage medium
CN117149098A