Data writing method and electronic device

By flexibly selecting a mapping method based on the first and second dimensions in the SSD, data is written to the storage, solving the problem of poor write performance and achieving more efficient data writing and resource saving.

CN120909957BActive Publication Date: 2026-02-03INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202511419257.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-09-30
Publication Date
2026-02-03
Estimated Expiration
2045-09-30

AI Technical Summary

Technical Problem

Existing technologies suffer from poor write performance when writing data to solid-state drives (SSDs), especially in scenarios requiring large-capacity storage and high random write performance. Write amplification occurs during the write process, leading to excessive resource consumption.

Method used

When the target mapping unit is in the write state, the target data is mapped from the hard disk to the memory using a mapping method based on the first size and the second size. The first size is larger than the second size. The mapping method can be flexibly selected to reduce resource consumption and improve writing efficiency.

Benefits of technology

By flexibly selecting mapping methods, the efficiency and effectiveness of data writing are improved, resource consumption is reduced, and the flexibility and performance of data writing are enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120909957B_ABST
    Figure CN120909957B_ABST
Patent Text Reader

Abstract

The application discloses a data writing method and an electronic device, and relates to the technical field of data processing. The method comprises the following steps: in the case that the state of a target mapping unit is a writing state, determining, by a server, whether a target mapping mode of the target mapping unit from a hard disk to a memory is a first-size-based mapping mode or a second-size-based mapping mode according to a logical address of target data. Compared with the mode of directly mapping the target mapping unit from the hard disk to the memory based on the first-size-based mapping mode, the flexibility of mapping the target mapping unit from the hard disk to the memory is improved. Since the first size is greater than the second size, when the target data is written into the hard disk according to the target mapping mode, the second size needs to consume less resources, so that the writing effect of the target data is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing technology, and in particular to a data writing method and an electronic device. Background Technology

[0002] Solid-state drives (SSDs) are high-performance storage devices widely used in data centers, servers, and edge computing nodes. In some scenarios, SSDs need to simultaneously meet the requirements of large-capacity storage and high random write performance.

[0003] In related technologies, a server receives a data write request, which requests that data to be written be written to the server's hard drive. The server determines the target mapping unit of the data to be written based on the logical address of the data to be written indicated in the data write request, and maps the target mapping unit from the hard drive to the storage space of the memory based on a first-size mapping method. Then, the server writes the data to be written to the storage space of the memory according to the logical address of the data to be written, and writes all the data in the target mapping unit in the storage space to the hard drive, thereby achieving the writing of the data to be written to the server's hard drive. However, the above method has poor performance in writing data to the hard drive. Summary of the Invention

[0004] This application provides a data writing method and an electronic device to improve the writing effect of target data.

[0005] This application provides a data writing method, including:

[0006] Receive a data write request, which requests that target data be written to the hard disk; the hard disk includes at least one mapping unit.

[0007] Based on the logical address of the target data, determine the target mapping unit where the target data is to be written and the state of the target mapping unit in at least one mapping unit; wherein the state is one of the following: initial state, cache state, and write state.

[0008] When the target mapping unit is in the write state, the target mapping method of mapping the target mapping unit from the hard disk to the memory is determined according to the logical address of the target data; wherein, the mapping method is a mapping method based on a first size or a mapping method based on a second size, the first size is the size of the mapping unit, and the first size is larger than the second size.

[0009] Based on the logical address of the target data and the target mapping method, the target data is written to the hard disk.

[0010] This application also provides a data writing device, including:

[0011] The receiving module is used to receive data write requests, which request the target data to be written to the hard disk; the hard disk includes at least one mapping unit.

[0012] The first determining module is used to determine, based on the logical address of the target data, the target mapping unit to be written to in at least one mapping unit, and the state of the target mapping unit; wherein the state is one of the following: initial state, cache state, and write state.

[0013] The second determining module is used to determine the target mapping method of the target mapping unit from the hard disk to the memory based on the logical address of the target data when the state of the target mapping unit is the write state; wherein the mapping method is a mapping method based on a first size or a mapping method based on a second size, the first size is the size of the mapping unit, and the first size is larger than the second size.

[0014] The write module is used to write target data to the hard disk according to the logical address of the target data and the target mapping method.

[0015] This application also provides an electronic device, including: a memory for storing a computer program; and a processor for implementing the steps of any of the above data writing methods when executing the computer program.

[0016] This application also provides a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of any of the above-described data writing methods.

[0017] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the above-described data writing methods.

[0018] Through this application, when the target mapping unit is in the write state, the server determines whether the target mapping method for mapping the target mapping unit from the hard disk to the memory is a mapping method based on the first size or a mapping method based on the second size, according to the logical address of the target data. Compared with the method of directly mapping the target mapping unit from the hard disk to the memory using the mapping method based on the first size, the flexibility of mapping the target mapping unit from the hard disk to the memory is improved. Moreover, since the first size is larger than the second size, when writing the target data to the hard disk according to the target mapping method, the second size requires less resources, thereby improving the writing effect of the target data. Attached Figure Description

[0019] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0020] Figure 1 A flowchart illustrating a data writing method provided for related technologies;

[0021] Figure 2 This is a schematic diagram illustrating an application scenario provided in the embodiments of this application;

[0022] Figure 3 A flowchart illustrating a data writing method provided in an embodiment of this application;

[0023] Figure 4 A flowchart illustrating a method for determining a target mapping, provided in an embodiment of this application;

[0024] Figure 5 This application provides a schematic diagram of a process for writing target data to a hard disk according to an embodiment of the present application;

[0025] Figure 6 A schematic diagram illustrating a data storage recording method provided in an embodiment of this application;

[0026] Figure 7 This is a schematic diagram of the structure of a data writing device provided in an embodiment of this application;

[0027] Figure 8 A schematic diagram of the structure of the electronic device provided in this application. Detailed Implementation

[0028] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.

[0029] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.

[0030] First, the technical terms used in this application will be explained.

[0031] Logical block address (LBA): This is the unit of data exchanged between the host and the SSD. Typically, an LBA corresponds to a memory size of 4KB. For example, assuming the host needs to write 400KB of data to the SSB, it can divide the 400KB of data into 100 LBAs and then write these 100 LBAs sequentially into the SSB.

[0032] Physical Block Addressing (PBA): A unique address identifier assigned to each physical block or page of NAND flash memory. PBA determines the storage location of data within an SSD. NAND flash memory is the core storage medium of an SSD and is a non-volatile memory.

[0033] With the development of big data and artificial intelligence (AI), the volume of data is exploding. Therefore, the demand for data storage capacity faces unprecedented challenges. In some embodiments, solid-state drive (SSD) technology is rapidly evolving towards larger capacities, a trend that has become a key path to improving the performance of massive data storage, optimizing costs, and reducing energy consumption.

[0034] In related technologies, data can be written to large-capacity SSDs based on a first-size mapping method, where the first-size mapping unit is typically 16KB or 64KB. Specifically, this can be combined with... Figure 1 To understand, Figure 1 A flowchart illustrating a data writing method provided for related technologies. For example... Figure 1 As shown, the process may include the following steps:

[0035] S101. Determine the target memory space corresponding to the memory size of the first-size mapping cell in the Dynamic Random Access Memory (DRAM).

[0036] When it is necessary to write target data to a large-capacity SSD, the memory space corresponding to the memory size of the first-size mapping unit is determined in DRAM.

[0037] S102. Based on the mapping unit of the first size and the logical address of the target data, determine the target mapping unit in the SSD where the target data is to be written.

[0038] S103. Map the data in the target mapping unit to the target memory space.

[0039] In some embodiments, after determining the target mapping unit, the data already stored in the target mapping unit is stored in the target memory space.

[0040] S104. Store the target data in the memory space according to the logical address of the target data to obtain the updated memory space.

[0041] The updated memory space includes the target data.

[0042] S105. Write all data in the updated memory space to the SSD.

[0043] However, when writing target data to SSD using the above data writing method, the server needs to read the data of the target mapping unit size into the DRAM storage space, then write the target data into the DRAM storage space, and then rewrite all the data of the target mapping unit in the DRAM storage space into the hard disk. That is, there is a write amplification problem in the process of writing target data to the hard disk, resulting in poor writing effect of target data.

[0044] Based on this, this application provides a data writing method. When the target mapping unit is in the writing state, the method determines whether the target mapping method for mapping the target mapping unit from the hard disk to the memory is a mapping method based on a first size or a mapping method based on a second size, according to the logical address of the target data. Compared with the method of directly mapping the target mapping unit from the hard disk to the memory using the mapping method based on the first size, this method improves the flexibility of mapping the target mapping unit from the hard disk to the memory. Furthermore, since the first size is larger than the second size, when writing the target data to the hard disk according to the target mapping method, the second size requires less resources, thereby improving the writing effect of the target data.

[0045] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0046] This section describes the specific application environment architecture or hardware architecture required for the execution of the data writing method. (References) Figure 2 , Figure 2 This is a schematic diagram illustrating an application scenario provided in an embodiment of this application. For example... Figure 2 As shown, it includes a first device 21 and a second device 22, wherein the second device 22 can be, for example, a server or other device, and the server includes a hard disk.

[0047] In practical applications, the first device 21 can communicate with the second device 22. For example, the first device 21 can send a data write request to the second device 22, which requests that target data be written to the hard disk. After receiving the data write request, the second device 22 writes the target data to the hard disk according to the data write request.

[0048] It should be noted that the execution subject in each embodiment of this application can be a processor, microprocessor, or a device integrating the aforementioned processor or microprocessor, such as a terminal device. The specific execution subject in each embodiment of this application is not limited and can be selected and set according to actual needs. In the following embodiments, a terminal device integrating the aforementioned processor or microprocessor is used as an example for description, which does not constitute a limitation on the actual execution subject.

[0049] It should be noted that, Figure 2 This is merely an example to illustrate one application scenario, and is not intended to limit the application scenario.

[0050] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.

[0051] Figure 3 This is a flowchart illustrating a data writing method provided in an embodiment of this application. Figure 3 As shown, the method may include the following steps:

[0052] S301, Receive a data write request, the data write request is used to request that target data be written to the hard disk; the hard disk includes at least one mapping unit.

[0053] The hard drive, for example, can be a high-capacity SSD, used for data storage. When it is necessary to write target data to the hard drive, the client can send a data write request to the server.

[0054] A mapping unit is a basic unit in a hard disk used to associate logical addresses with physical addresses. In some embodiments, one mapping unit corresponds to a memory space of a fixed size. In some embodiments, the memory space corresponding to a mapping unit may be, for example, 16KB or 64KB.

[0055] S302. Based on the logical address of the target data, determine the target mapping unit to be written to and the state of the target mapping unit in at least one mapping unit; wherein the state is one of the following: initial state, cache state, and write state.

[0056] A logical address is a data unit used for data exchange between a hard drive and an external device. A logical address can be, for example, an LBA, in which case the memory space corresponding to that logical address is 4KB in size. In some embodiments, a data write request is also used to indicate the logical address of the target data, signifying that the target data will be written to the storage location corresponding to that logical address on the hard drive.

[0057] In some embodiments, a mapping unit includes multiple logical addresses. For example, assuming the memory size of the memory space corresponding to a mapping unit is 16KB and the memory size of the memory space corresponding to the logical address is 4KB, then a mapping unit includes 16KB / 4KB = 4 logical addresses. Therefore, the mapping unit containing the logical address of the target data in at least one mapping unit can be identified as the target mapping unit.

[0058] The state of the target mapping unit is used to indicate the current data storage state of the target mapping unit. When the state of the target mapping unit is in the initial state, it means that the target mapping unit is a unit that has not stored data. That is, when writing target data to the target mapping unit, it is not necessary to read the original data in the target mapping unit. The memory space corresponding to the target mapping unit can be directly allocated in DRAM, and the target data can be written to the memory space corresponding to the target mapping unit according to the logical address of the target data.

[0059] When the target mapping unit is in the cached state, it means that data has been written to the target mapping unit and the data in the target mapping unit is temporarily stored in the memory. That is, when writing target data to the target mapping unit, it is not necessary to read the data in the target mapping unit from the hard disk. The target data can be written directly to the target mapping unit in the memory according to the logical address of the target data.

[0060] When the target mapping unit is in the write state, it means that data has been written to the target mapping unit and the data in the target mapping unit has been written to the hard disk.

[0061] S303. When the target mapping unit is in the write state, determine the target mapping method for mapping the target mapping unit from the hard disk to the memory according to the logical address of the target data; wherein the mapping method is a mapping method based on a first size or a mapping method based on a second size, the first size is the size of the mapping unit, and the first size is larger than the second size.

[0062] Since the target mapping unit is in a write state, it indicates that data has been stored in the target mapping unit and written to the hard disk. Therefore, when writing target data to the memory space corresponding to the target mapping unit, the target mapping unit needs to be mapped from the hard disk to the memory. Specifically, a memory space of the same size as the memory space corresponding to the target mapping unit can be determined in the memory. Then, the data stored in the target mapping unit is read from the hard disk and stored in the memory space of the memory. The memory is located in the server and is used to store data; in some embodiments, the memory can be, for example, DRAM.

[0063] In some embodiments, the target mapping unit can be mapped from the hard disk to the memory using a mapping method based on a first size, or the target mapping unit can be mapped from the hard disk to the memory using a mapping method based on a second size.

[0064] In this mapping method, the first size-based method allocates memory space of the corresponding size in memory, based on the size of the target mapping unit, to temporarily store the complete data of the target mapping unit. The second size-based method allocates memory space of the corresponding size in memory, based on the size of the LBA, to temporarily store the data of that LBA. The size of the target mapping unit refers to the memory size of the memory space corresponding to the target mapping unit; the size of the LBA refers to the memory size of the memory space corresponding to the LBA. In some embodiments, since the memory size of the memory space corresponding to the target mapping unit is larger than the memory size of the memory space corresponding to the LBA, the first size is larger than the second size. In some embodiments, since the first size is larger than the second size, the mapping method based on the first size can also be called a large-size mapping method, and the mapping method based on the second size can also be called a small-size mapping method.

[0065] S304. Write the target data to the hard disk according to the logical address and target mapping method of the target data.

[0066] In some embodiments, the location where the target data is written to the target mapping unit can be determined based on the logical address of the target data.

[0067] When the target mapping method is based on a first size, the target mapping unit is mapped to the memory space of the memory, and the target data is stored in that memory space according to the location where the target data is written to the target mapping unit. At this time, the data stored in the target mapping unit includes the data read from the hard disk and the target data. Therefore, writing all the data in the target mapping unit to the hard disk, that is, writing the data read from the hard disk and the target data to the hard disk, thereby realizing the writing of the target data to the hard disk.

[0068] When the target mapping method is based on the second size, the sub-unit containing the logical address of the target data in the target mapping unit is mapped to the memory space of the memory, and the target data is stored in that memory space according to the location where the target data is written to the target mapping unit. Finally, the target data in the sub-unit containing the logical address of the target data is written to the hard disk.

[0069] exist Figure 3 In the illustrated embodiment, when the target mapping unit is in the write state, the target mapping method for mapping the target mapping unit from the hard disk to the memory is determined based on the logical address of the target data. It is determined whether the target mapping method is based on the first size or the second size. Compared with the method of directly mapping the target mapping unit from the hard disk to the memory using the first size mapping method, the flexibility of mapping the target mapping unit from the hard disk to the memory is improved. Furthermore, since the first size is larger than the second size, when writing the target data to the hard disk according to the target mapping method, the second size requires less resources, thereby improving the writing effect of the target data.

[0070] exist Figure 3 Based on the illustrated embodiment, the following, in conjunction with Figure 4 The process of determining the target mapping method in this application will be further explained.

[0071] Figure 4 This is a flowchart illustrating a method for determining a target mapping as provided in an embodiment of this application. Figure 4 As shown, the process may include the following steps:

[0072] S401. Determine the target mapping unit where the target data is to be written, and the state of the target mapping unit, in at least one mapping unit.

[0073] In some embodiments, the target mapping unit and the state of the target mapping unit can be determined as follows: determine the number of logical addresses in the target mapping unit; determine the target mapping unit based on the memory size corresponding to the logical address of the target data and the number of logical addresses in the target mapping unit; determine the state of the target mapping unit based on the association between the states of the mapping units and the target mapping unit.

[0074] In some embodiments, since a mapping unit may include multiple logical addresses, the number of logical addresses in the target mapping unit can be determined based on the memory size of the memory space corresponding to the target mapping unit and the memory size of the memory space corresponding to the logical address.

[0075] For example, assuming the memory size corresponding to the target mapping unit is 16KB and the memory size corresponding to the logical address is 4KB, then the number of logical addresses in the target mapping unit is determined to be 16KB / 4KB=4.

[0076] In some embodiments, the ratio between the memory size corresponding to the logical address and the number of logical addresses in the target mapping unit can be calculated, and the ratio can be rounded to obtain the identifier of the target mapping unit. Then, the target mapping unit is determined based on the identifier of the target mapping unit.

[0077] For example, assuming the memory size corresponding to the logical address is 4KB and the number of logical addresses in the target mapping unit is 8, then the identifier of the target mapping unit is determined to be 0. In this case, the mapping unit with the identifier 0 is determined as the target mapping unit.

[0078] For example, suppose the relationship between the mapping unit and the state of the mapping unit is as shown in Table 1:

[0079] Table 1

[0080]

[0081] Assuming the target mapping unit is mapping unit 1, then the state of the target mapping unit is determined to be the initial state.

[0082] S402. When the target mapping unit is in the write state, obtain the association between the logical address and the mapping method.

[0083] In some embodiments, for each logical address among multiple logical addresses in the hard disk, the association between the logical address and the mapping method is used to record the mapping method used when data was last written to the memory corresponding to that logical address.

[0084] For example, assume the relationship between logical addresses and mapping methods is as shown in Table 2:

[0085] Table 2

[0086]

[0087] This means that when data was last written to the memory corresponding to logical address A, the mapping method used was the mapping method based on the first size; and when data was last written to the memory corresponding to logical address B, the mapping method used was the mapping method based on the second size.

[0088] S403. Based on the association relationship and the logical address of the target data, determine the candidate mapping method of the target mapping unit.

[0089] In some embodiments, the mapping method used when writing data to the memory corresponding to the logical address of the target data last time can be determined based on the association between the logical address and the mapping method and the logical address of the target data, and the mapping method can be determined as a candidate mapping method for the target mapping unit.

[0090] For example, assuming the relationship between logical address and mapping method is as shown in Table 2, and the logical address of the target data is logical address A, then the candidate mapping of the target mapping unit is determined to be the mapping method based on the first size.

[0091] S404. When the candidate mapping method is a mapping method based on the first size, the target mapping method is determined according to the record table; wherein, the record table is used to record the storage address of the sub-mapping unit in the hard disk.

[0092] The target mapping unit includes multiple sub-mapping units. In some embodiments, when mapping is performed based on the second size mapping method, the sub-mapping units corresponding to the logical addresses of the target data in the target mapping unit are mapped from the hard disk to the memory. Therefore, the memory size corresponding to the sub-mapping unit is the same as the size of the second size.

[0093] In some embodiments, for each of the plurality of sub-mapping units in a hard disk, when the sub-mapping unit was last mapped from the hard disk to memory using a second-size mapping method, a record table is used to record the storage address of the sub-mapping unit in the hard disk. The storage address is the physical address of the sub-mapping unit in the hard disk, and the storage address can be, for example, a PBA.

[0094] Therefore, the record table is used to record the storage address of each of at least one sub-mapping unit mapped based on the second-size mapping method in the hard disk.

[0095] In some embodiments, the target mapping method can be determined according to the record table as follows: if the number of storage addresses of the sub-mapping units recorded in the record table in the hard disk is greater than or equal to a first number, the target mapping method is determined to be a mapping method based on a first size; if the number of storage addresses of the sub-mapping units recorded in the record table in the hard disk is less than the first number, the target mapping method is determined to be a mapping method based on a second size.

[0096] In some embodiments, because the memory size corresponding to the sub-mapping unit is small, the number of sub-mapping units in the hard disk is large. If all sub-mapping units are mapped based on the second-size mapping method, the record table occupies a large amount of memory space. Therefore, to avoid the record table occupying too much memory space, the maximum number of storage addresses of the sub-mapping units that can be recorded in the record table on the hard disk can be preset in advance.

[0097] The first quantity is the maximum number of storage addresses of the sub-mapping units recorded in the record table on the hard disk. In other words, the first quantity is used to indicate the maximum number of sub-mapping units mapped based on the second-size mapping method.

[0098] In some embodiments, the first quantity can be determined by: obtaining a load index of the memory, the load index indicating the resource share and load size of the memory; determining, based on the load index, the ratio between the number of sub-mapping units based on a first-size mapping method and the number of sub-mapping units based on a second-size mapping method; and determining the first quantity based on the ratio and the number of sub-mapping units included in the hard disk.

[0099] Memory resource utilization can be, for example, the ratio of the amount of data stored in memory to the size of the memory's memory space; load can be, for example, the number of current read / write requests to the memory, the data transfer rate, etc. Therefore, load metrics are used to indicate memory resource consumption and task processing intensity. In some embodiments, a higher load metric indicates greater memory resource consumption and a higher task processing intensity; a lower load metric indicates less memory resource consumption and a lower task processing intensity.

[0100] Since a larger number of sub-mapping units based on the second-size mapping method results in a larger memory footprint for the record table, the number of sub-mapping units based on the second-size mapping method can be reduced when the load index is high, and conversely, the number of sub-mapping units based on the second-size mapping method can be increased when the load index is high. This allows for the determination of the ratio between the number of sub-mapping units based on the first-size mapping method and the number of sub-mapping units based on the second-size mapping method, based on the load index.

[0101] In some embodiments, the proportion of sub-mapping units based on the second-size mapping method in the total number of sub-mapping units included in the hard disk can be determined based on the ratio between the number of sub-mapping units based on the first-size mapping method and the number of sub-mapping units based on the second-size mapping method, and a first quantity can be determined based on the proportion and the number of sub-mapping units included in the hard disk.

[0102] For example, assuming the hard disk contains 100 sub-mapping units, and the ratio between the number of sub-mapping units based on the first size mapping method and the number of sub-mapping units based on the second size mapping method is 9:1, then the proportion of sub-mapping units based on the second size mapping method in the total number of sub-mapping units in the hard disk is determined to be 1 / 10, and thus the first quantity is determined to be 1 / 10 * 100 = 10.

[0103] If the number of storage addresses of the sub-mapping units recorded in the record table on the hard disk is greater than or equal to the first number, it indicates that the number of sub-mapping units mapped based on the second size mapping method has reached the maximum. At this time, the target mapping method is determined to be the mapping method based on the first size.

[0104] If the number of storage addresses of the sub-mapping units recorded in the record table on the hard disk is less than the first number, it indicates that the number of sub-mapping units mapped based on the second-size mapping method has not reached the maximum number. In this case, the target mapping method is determined to be the second-size mapping method.

[0105] In some embodiments, when the target mapping method is a mapping method based on a first size, the data type of the target data can be obtained; the update frequency of the target data can be determined according to the data type; if the update frequency is greater than or equal to a preset frequency, the third size can be determined as the first size; if the update frequency is less than the preset frequency, the fourth size can be determined as the first size, wherein the third size is smaller than the fourth size.

[0106] The target data can be of various data types, such as business data types and archive data types. In some embodiments, the update frequency of the target data varies depending on the data type. For example, if the target data is of a business data type, the update frequency is higher; if the target data is of an archive data type, the update frequency is lower.

[0107] In some embodiments, the update frequency of the target data can be determined based on the mapping relationship between the data type and the update frequency. If the update frequency is greater than or equal to a preset frequency, it indicates that the update frequency of the target data is high; if the update frequency is less than the preset frequency, it indicates that the update frequency of the target data is low.

[0108] The third and fourth sizes are candidate sizes for the first size. For example, assuming the candidate sizes for the first size include 16KB and 64KB, the third size can be 16KB and the fourth size can be 64KB. Since write amplification occurs when the target mapping method is based on the first size, to minimize the impact of write amplification, when the target data is updated frequently, the third size can be determined as the first size. This reduces the degree of write amplification during each write operation or update of the target data.

[0109] When the target data is updated in a low frequency, the probability of write operations being triggered by data updates is low because the target data is in a relatively stable state. Therefore, the fourth size can be determined as the first size. In this way, although the degree of write amplification when writing target data is greater than that under the third size, the impact of write amplification on the hard drive is small because the target data is updated in a low frequency.

[0110] S405. If the candidate mapping method is a mapping method based on the second size, then the mapping method based on the second size shall be determined as the target mapping method.

[0111] In some embodiments, the record table is used to record the storage addresses of at least one sub-mapping unit in the hard disk for mapping based on the second-size mapping method. If the candidate mapping method is a mapping method based on the second size, the record table records the storage addresses of the sub-mapping units corresponding to the logical address of the target data in the hard disk. In this case, it can be determined that the target mapping method is a mapping method based on the second size.

[0112] exist Figure 4 In the illustrated embodiment, when the candidate mapping method is a mapping method based on a first size, the target mapping method is determined based on the number of storage addresses of the sub-mapping units recorded in the record table on the hard disk. Within the allowable range of the first number, the sub-mapping units are mapped from the hard disk to the memory as much as possible based on the mapping method based on a second size. In this way, while ensuring that the record table does not occupy too much memory space, mapping is performed as much as possible based on the mapping method based on the second size, reducing the number of mappings based on the mapping method based on the first size, thereby improving the efficiency of writing target data.

[0113] Based on the above embodiments, the following, in conjunction with Figure 5 The method of writing the target data to the hard disk in this application will be further explained.

[0114] Figure 5 This application provides a schematic diagram illustrating a process for writing target data to a hard disk, as described in an embodiment. Figure 5 As shown, the process may include the following steps:

[0115] S501. Determine the location to be written in the target mapping unit based on the logical address of the target data.

[0116] In some embodiments, the memory size corresponding to the logical address of the target data can be divided by the number of logical addresses in the target mapping unit. The remainder of the division determines the sub-mapping unit corresponding to the logical address of the target data in the target mapping unit. Then, the storage location corresponding to this sub-mapping unit is determined as the write location. The write location refers to the storage location of the target data to be written in the target mapping unit.

[0117] For example, assuming the logical address of the target data corresponds to a memory size of 4KB, and the number of logical addresses in the target mapping unit is 8, then the remainder when dividing the memory size corresponding to the logical address of the target data by the number of logical addresses in the target mapping unit is 5. Therefore, the sub-mapping unit corresponding to the logical address of the target data in the target mapping unit is determined to be the 5th sub-mapping unit in the target mapping unit. At this point, the storage location corresponding to the 5th sub-mapping unit in the target mapping unit is determined as the location to be written.

[0118] S502. According to the target mapping method, at least one sub-mapping unit in the target mapping unit is mapped to the target memory space in the memory.

[0119] The target memory space is the memory space in the storage used to store the target data. It should be noted that the size of the target memory space varies depending on the target mapping method.

[0120] Specifically, if the target mapping method is based on the first size, then the memory size of the target memory space is the memory size of the memory space corresponding to the target mapping unit. If the target mapping method is based on the second size, then the memory size of the target memory space is the memory size of the memory space corresponding to at least one sub-mapping unit corresponding to the target data.

[0121] In some embodiments, mapping at least one sub-mapping unit in the target mapping unit to a target memory space in the memory can be done as follows: when the target mapping method is a mapping method based on a first size, the target mapping unit is mapped to the target memory space; when the target mapping method is a mapping method based on a second size, at least one target sub-mapping unit is determined in the target mapping unit according to the location to be written; the at least one target sub-mapping unit is mapped to the target memory space; wherein, the target memory space includes the sub-memory space corresponding to each of the at least one target sub-mapping unit.

[0122] In some embodiments, if the target mapping method is a mapping method based on the second size, the sub-mapping unit corresponding to the location to be written in the target mapping unit is determined as the target sub-mapping unit. The target sub-mapping unit is the sub-mapping unit in the target mapping unit used to store the target data.

[0123] In some embodiments, the number of target sub-mapping units can be one or more. For example, assuming the memory size corresponding to a sub-mapping unit is 4KB, when the size of the target data is 4KB, the memory size of the memory space corresponding to the logical address of the target data is 4KB, and the number of target sub-mapping units is 1; when the size of the target data is 8KB, the memory size corresponding to the logical address of the target data is 8KB, and the number of target sub-mapping units is 2.

[0124] Mapping a target mapping unit to a target memory space means copying the existing data in the target mapping unit to the target memory space. In other words, after the target mapping unit is mapped to the target memory space, the data stored in the target memory space is consistent with the data in the target mapping unit.

[0125] Mapping at least one target sub-mapping unit to the target memory space means copying the data of each of the at least one target sub-mapping unit to the target memory space. In other words, after mapping at least one target sub-mapping unit to the target memory space, the data stored in the target memory space is consistent with that of the at least one target sub-mapping unit.

[0126] S503. Write the target data to the target memory space according to the location to be written.

[0127] In some embodiments, if data is already stored at the write location in the target memory space, the data already stored at the write location is deleted, and then the target data is written to the write location.

[0128] In some embodiments, if no data is stored at the write location in the target memory space, the target data is directly written to the write location.

[0129] In some embodiments, after the server writes the target data into the target memory space, it updates the association between the mapping units and the state of the mapping units, the association between the logical address and the mapping method, and at least one item in the record table.

[0130] Specifically, if the association between the states of the mapping units indicates that the state of the target mapping unit is either the initial state or the write state, then the state of the target mapping unit in the association between the states of the mapping units is updated to the cache state, thus obtaining the updated association between the states of the mapping units.

[0131] If the mapping method corresponding to the logical address of the target data in the association between logical addresses and mapping methods is a mapping method based on the first size, and the target mapping method is a mapping method based on the second size, then the mapping method corresponding to the logical address of the target data in the association between logical addresses and mapping methods is updated to the mapping method based on the second size. Furthermore, the position of the logical address of the target data in the record table is determined using a binary search method, and the record table is updated according to the logical address of the target data and its storage address on the hard disk, resulting in an updated record table.

[0132] In some embodiments, the memory also stores the association between mapping units and memory addresses, and a data record table for the mapping units, wherein the data record table for the mapping units is used to record whether the data at each bit position in the mapping unit is valid. After the server writes the target data into the target memory space, it can also update the association between the mapping units and memory addresses, and the data record table for the mapping units.

[0133] S504: Write the data in the target memory space to the hard disk.

[0134] In some embodiments, the method of writing data in the target memory space to the hard disk may be as follows: when the target mapping method is a mapping method based on a first size, determine whether the number of data stored in the target memory space is greater than or equal to a second number; if the number of data stored in the target memory space is greater than or equal to the second number, write the data in the target memory space to the hard disk; or, when the target mapping method is a mapping method based on a second size, for the sub-memory space corresponding to each target sub-mapping unit, determine whether the number of data stored in the sub-memory space is greater than or equal to a third number; if the number of data stored in the sub-memory space is greater than or equal to the third number, write the data in the sub-memory space to the hard disk.

[0135] In some embodiments, to reduce the number of writes to the hard disk, the data in the target memory space can be written to the hard disk when the amount of data stored in the target memory space reaches a certain threshold.

[0136] The second quantity is the maximum amount of data stored in the target memory space based on the mapping method of the first size. The third quantity is the maximum amount of data stored in the target memory space based on the mapping method of the second size.

[0137] Therefore, when the target mapping method is based on the first size, if the amount of data stored in the target memory space is greater than or equal to the second size, it indicates that the amount of data stored in the target memory space based on the first size mapping method has reached the maximum data volume. In this case, the data in the target memory space is written to the hard disk. If the amount of data stored in the target memory space is less than the second size, it indicates that the amount of data stored in the target memory space based on the first size mapping method has not reached the maximum data volume. In this case, the data in the target memory space is temporarily stored in the memory.

[0138] When the target mapping method is based on the second size, if the amount of data stored in the target memory space is greater than or equal to the third size, it means that the amount of data stored in the target memory space based on the second size mapping method has reached the maximum data volume. In this case, the data in the target memory space is written to the hard disk. If the amount of data stored in the target memory space is less than the third size, it means that the amount of data stored in the target memory space based on the second size mapping method has not reached the maximum data volume. In this case, the data in the target memory space is temporarily stored in the memory.

[0139] exist Figure 5 In the illustrated embodiment, under the mapping method based on the first size, the entire target mapping unit is mapped into the target memory space; under the mapping method based on the second size, at least one sub-mapping unit is mapped into the target memory space. This reduces the possibility of write amplification problems when writing target data to the hard disk using the mapping method based on the first size, thus improving the efficiency of writing target data to the hard disk. Furthermore, by combining the second and third quantities as the basis for determining whether to write data from the target space to the hard disk, the number of write operations to the hard disk is reduced while maintaining the memory space utilization rate of the storage device, thereby reducing wear and tear on the hard disk.

[0140] The above embodiments introduced the data writing method provided by this application. To better manage data written using the data writing method provided by this application, embodiments of this application also provide a data storage and recording method. Below, in conjunction with... Figure 6 The data storage and recording methods in the embodiments of this application will be described in detail.

[0141] Figure 6 This is a schematic diagram illustrating a data storage recording method provided in an embodiment of this application. For example... Figure 6 As shown, the memory also stores the association between logical addresses and mapping methods, the association between mapping units and storage addresses, the data record table of the mapping units, and the record table.

[0142] The association between logical addresses and mapping methods is used to indicate that logical address A is mapped using a mapping method based on the first size, logical address B is mapped using a mapping method based on the second size, and logical address C is mapped using a mapping method based on the first size.

[0143] The association between the mapping unit and the storage address is used to indicate that the storage address of mapping unit 1 is 0X123415, the storage address of mapping unit 2 is 0X154325, and the storage address of mapping unit 3 is 0X215165.

[0144] Taking mapping unit 1 as an example, the data record table of mapping unit 1 is used to indicate: the data at the first bit position in mapping unit 1 is valid, the data at the second bit position in mapping unit 1 is invalid, and the data at the third bit position in mapping unit 1 is valid.

[0145] The record table is used to indicate that the storage address of the first sub-mapping unit in the target mapping unit is 0Xaabb, the storage address of the second sub-mapping unit is 0Xccdd, and the storage address of the third sub-mapping unit is 0Xaacc.

[0146] Based on the above records, the written data can be better managed. Specifically, let's take the data reading process as an example:

[0147] In some embodiments, the server receives a data read request, which is used to request the reading of target data. The server determines the target mapping unit at the time of writing the target data, as well as the state of the target mapping unit, based on the logical address of the target data.

[0148] If the target mapping unit is in the initial state, it means that the target data has not been written to the target mapping unit. At this time, the server sends a prompt message to the client to indicate that the target data reading failed.

[0149] When the target mapping unit is in cached state, the server determines the write position of the target data in the target mapping unit based on the memory size corresponding to the logical address of the target data and the number of logical addresses in the target mapping unit, and then reads the target data in the target mapping unit according to the write position.

[0150] When the target mapping unit is in the write state, the server determines the mapping method corresponding to the target data based on the association between the logical address and the mapping method, as well as the logical address of the target data. Assuming the logical address of the target data is logical address A, the mapping method corresponding to the target data is determined to be a mapping method based on the first size.

[0151] When the mapping method corresponding to the target data is based on the first size, the data record table of the target mapping unit and the bit offset of the target data in the target mapping unit are determined according to the logical address of the target data and the number of bits in the target mapping unit. The validity of the target data is then determined in the data record of the target mapping unit based on the offset.

[0152] If the target data is determined to be valid, the storage address of the target mapping unit is determined based on the mapping relationship between the mapping unit and the storage address, and the target mapping unit itself. Then, the target data is read from the storage address of the target mapping unit according to the write position of the target data in the target mapping unit. For example, assuming the target mapping unit is mapping unit 1, the storage address of the target mapping unit is determined to be 0x123415. If the write position of the target data in the target mapping unit is 3, then the target data is determined to be 2.

[0153] When the mapping method corresponding to the target data is a second-size-based mapping method, the storage address on the hard disk in the sub-mapping unit of the target data is determined according to the logical address of the target data and the record table. For example, assuming the sub-mapping unit of the target data is determined to be the first sub-mapping unit in the target mapping unit based on the logical address of the target data, then the storage address of the target data on the hard disk is determined to be 0Xaabb. At this time, the target data is read from storage address 0Xaabb.

[0154] In some embodiments, the server sends the target data to the client after reading the target data from the hard drive.

[0155] exist Figure 6 In the embodiments shown, after providing the data writing method described above, this application also provides a data storage recording method adapted to the data writing method, so as to better manage the data written based on the data writing method provided by this application and ensure the accuracy and integrity of data writing and reading.

[0156] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method.

[0157] Figure 7 This is a schematic diagram of a data writing device provided in an embodiment of this application. Figure 7 As shown, embodiments of this application also provide a data writing device 70, which includes a receiving module 71, a first determining module 72, a second determining module 73, and a writing module 74, wherein:

[0158] The receiving module 71 is used to receive a data write request, which requests that target data be written to the hard disk; the hard disk includes at least one mapping unit.

[0159] The first determining module 72 is used to determine, based on the logical address of the target data, the target mapping unit to be written to in at least one mapping unit, and the state of the target mapping unit; wherein the state is one of the following: initial state, cache state, and write state.

[0160] The second determining module 73 is used to determine the target mapping method for mapping the target mapping unit from the hard disk to the memory based on the logical address of the target data when the target mapping unit is in the write state; wherein the mapping method is a mapping method based on a first size or a mapping method based on a second size, the first size being the size of the mapping unit, and the first size being larger than the second size.

[0161] The write module 74 is used to write the target data to the hard disk according to the logical address of the target data and the target mapping method.

[0162] In one possible implementation, the second determining module 73 is specifically used for:

[0163] Obtain the association between logical addresses and mapping methods;

[0164] Based on the association relationship and the logical address of the target data, determine the candidate mapping method for the target mapping unit;

[0165] When the candidate mapping method is a mapping method based on the first size, the target mapping method is determined according to the record table; wherein, the record table is used to record the storage address of the sub-mapping unit on the hard disk;

[0166] If the candidate mapping method is a mapping method based on the second size, then the mapping method based on the second size will be determined as the target mapping method.

[0167] In one possible implementation, the second determining module 73 is specifically used for:

[0168] If the number of storage addresses of the sub-mapping units recorded in the record table on the hard disk is greater than or equal to a first number, the target mapping method is determined to be a mapping method based on the first size.

[0169] If the number of storage addresses of the sub-mapping units recorded in the record table on the hard disk is less than the first number, the target mapping method is determined to be a mapping method based on the second size.

[0170] In one possible implementation, the writing module 74 is specifically used for:

[0171] Based on the logical address of the target data, determine the location in the target mapping unit where the target data will be written;

[0172] According to the target mapping method, at least one sub-mapping unit in the target mapping unit is mapped to the target memory space in the memory;

[0173] Write the target data to the target memory space according to the location to be written;

[0174] Write the data in the target memory space to the hard disk.

[0175] In one possible implementation, the writing module 74 is specifically used for:

[0176] When the target mapping method is a mapping method based on the first size, the target mapping unit is mapped into the target memory space;

[0177] When the target mapping method is a mapping method based on the second size, at least one target sub-mapping unit is determined in the target mapping unit according to the location to be written; the at least one target sub-mapping unit is mapped to the target memory space; wherein, the target memory space includes the sub-memory space corresponding to each of the at least one target sub-mapping unit.

[0178] In one possible implementation, the writing module 74 is specifically used for:

[0179] If the target mapping method is based on the first size, determine whether the amount of data stored in the target memory space is greater than or equal to the second amount; if the amount of data stored in the target memory space is greater than or equal to the second amount, write the data in the target memory space to the hard disk.

[0180] or,

[0181] When the target mapping method is based on the second size, for each target sub-mapping unit, determine whether the number of data stored in the sub-memory space is greater than or equal to the third number; if the number of data stored in the sub-memory space is greater than or equal to the third number, write the data in the sub-memory space to the hard disk.

[0182] In one possible implementation, the first determining module 72 is specifically used for:

[0183] Determine the number of logical addresses in the target mapping unit;

[0184] The target mapping unit is determined based on the memory size corresponding to the logical address of the target data and the number of logical addresses in the target mapping unit;

[0185] The state of the target mapping unit is determined based on the relationship between the states of the mapping units and the target mapping unit.

[0186] In one possible implementation, the data writing device 70 further includes a first processing module, wherein the first processing module is specifically used for:

[0187] Obtain the memory load metrics, which indicate the resource utilization and load of the memory.

[0188] Based on the load index, determine the ratio between the number of sub-mapping units based on the first size mapping method and the number of sub-mapping units based on the second size mapping method;

[0189] The first quantity is determined based on the ratio and the number of sub-mapping units included in the hard disk.

[0190] In one possible implementation, the data writing device 70 further includes a second processing module, wherein the second processing module is specifically used for:

[0191] Obtain the data type of the target data;

[0192] Determine the update frequency of the target data based on the data type;

[0193] If the update frequency is greater than or equal to the preset frequency, the third dimension is determined as the first dimension;

[0194] If the update frequency is less than the preset frequency, the fourth dimension is determined as the first dimension, wherein the third dimension is smaller than the fourth dimension.

[0195] For a description of the features in the embodiment corresponding to the data writing device 70, please refer to the relevant description in the embodiment corresponding to the data writing method, which will not be repeated here.

[0196] Figure 8 A schematic diagram of the structure of the electronic device provided in this application. Figure 8 As shown, the electronic device 80 provided in this embodiment includes at least one processor 801 and a memory 802. Optionally, the electronic device 80 further includes a communication component 803. The processor 801, memory 802, and communication component 803 are connected via a bus.

[0197] In a specific implementation, at least one processor 801 executes computer execution instructions stored in memory 802, causing at least one processor 801 to execute the above-described data writing method embodiment.

[0198] The specific implementation process of processor 801 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.

[0199] In the above embodiments, it should be understood that the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the application can be directly manifested as being executed by a hardware processor, or executed by a combination of hardware and software modules within the processor.

[0200] The memory may include random access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk storage device.

[0201] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.

[0202] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above-described data writing method embodiments when running.

[0203] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.

[0204] Embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above-described data writing method embodiments.

[0205] Embodiments of this application also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps in any of the above-described data writing method embodiments.

[0206] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0207] The data writing method and electronic device provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are only for the purpose of helping to understand the method and its core ideas. It should be noted that those skilled in the art can make several improvements and modifications to this application without departing from the principles of this application, and these improvements and modifications also fall within the protection scope of the claims of this application.

Claims

1. A data writing method, characterized in that, The method includes: A data write request is received, the data write request being used to request that target data be written to a hard disk; the hard disk includes at least one mapping unit; Based on the logical address of the target data, the target mapping unit to which the target data is to be written and the state of the target mapping unit are determined in the at least one mapping unit; wherein the state is one of the following: initial state, cache state, and write state; When the target mapping unit is in the write state, a target mapping method for mapping the target mapping unit from the hard disk to the memory is determined according to the logical address of the target data; wherein the mapping method is a mapping method based on a first size or a mapping method based on a second size, the first size being the size of the mapping unit, and the first size being larger than the second size; Based on the logical address of the target data and the target mapping method, the target data is written to the hard disk; The step of determining the target mapping method from the hard disk to the memory based on the logical address of the target data includes: Obtain the association between logical addresses and mapping methods. For each logical address among multiple logical addresses in the hard disk, the association between the logical address and the mapping method is used to record the mapping method used when data was last written to the memory corresponding to that logical address. Based on the association relationship and the logical address of the target data, determine the candidate mapping method for the target mapping unit; When the candidate mapping method is a mapping method based on the first size, the target mapping method is determined according to a record table; wherein, the record table is used to record the storage addresses of the sub-mapping units in the hard disk; determining the target mapping method according to the record table includes: if the number of storage addresses of the sub-mapping units recorded in the record table in the hard disk is greater than or equal to a first number, the target mapping method is determined to be a mapping method based on the first size; if the number of storage addresses of the sub-mapping units recorded in the record table in the hard disk is less than the first number, the target mapping method is determined to be a mapping method based on the second size; If the candidate mapping method is a mapping method based on the second size, then the mapping method based on the second size is determined as the target mapping method.

2. The method according to claim 1, characterized in that, The step of writing the target data to the hard disk according to the logical address of the target data and the target mapping method includes: Based on the logical address of the target data, determine the location in the target mapping unit where the target data will be written; According to the target mapping method, at least one sub-mapping unit in the target mapping unit is mapped to the target memory space in the memory; According to the location to be written, the target data is written into the target memory space; Write the data in the target memory space to the hard disk.

3. The method according to claim 2, characterized in that, The step of mapping at least one sub-mapping unit in the target mapping unit to the target memory space in the memory according to the target mapping method includes: When the target mapping method is a mapping method based on the first size, the target mapping unit is mapped to the target memory space; When the target mapping method is a mapping method based on the second size, at least one target sub-mapping unit is determined in the target mapping unit according to the location to be written; the at least one target sub-mapping unit is mapped to the target memory space; wherein, the target memory space includes the sub-memory space corresponding to each of the at least one target sub-mapping unit.

4. The method according to claim 3, characterized in that, The step of writing the data in the target memory space to the hard disk includes: If the target mapping method is a mapping method based on the first size, determine whether the amount of data stored in the target memory space is greater than or equal to a second amount; if the amount of data stored in the target memory space is greater than or equal to the second amount, write the data in the target memory space to the hard disk; or, When the target mapping method is a mapping method based on the second size, for each target sub-mapping unit, it is determined whether the number of data stored in the sub-memory space is greater than or equal to a third number; if the number of data stored in the sub-memory space is greater than or equal to the third number, the data in the sub-memory space is written to the hard disk.

5. The method according to claim 1, characterized in that, The step of determining the target mapping unit where the target data is to be written, and the state of the target mapping unit, in the at least one mapping unit includes: Determine the number of logical addresses in the target mapping unit; The target mapping unit is determined based on the memory size corresponding to the logical address of the target data and the number of logical addresses in the target mapping unit; The state of the target mapping unit is determined based on the association between the states of the mapping units and the target mapping unit.

6. The method according to claim 1, characterized in that, The method further includes: Obtain the load metric of the memory, which indicates the resource utilization and load size of the memory; Based on the load index, determine the ratio between the number of sub-mapping units based on the first size mapping method and the number of sub-mapping units based on the second size mapping method; The first quantity is determined based on the ratio and the number of sub-mapping units included in the hard disk.

7. The method according to claim 1, characterized in that, When the target mapping method is the mapping method based on the first size, the method further includes: Obtain the data type of the target data; The update frequency of the target data is determined based on the data type. If the update frequency is greater than or equal to the preset frequency, the third size is determined to be the first size; If the update frequency is less than the preset frequency, the fourth size is determined to be the first size, wherein the third size is smaller than the fourth size.

8. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the data writing method as described in any one of claims 1 to 7 when executing the computer program.

Citation Information

Patent Citations

  • Method and device for accessing target memory, electronic equipment and storage medium

    CN116049037A