Method and Apparatus for Processing Resource Data, Storage Medium, and Electronic Device

By setting only one storage area in the solid-state memory and performing erasing processing when the to-be-storage area is the same as the stored area, the problem of excessive erasing frequency is solved, and the performance and efficiency of the solid-state memory are improved.

CN119847450BActive Publication Date: 2025-07-22SHANDONG YUNHAI GUOCHUANG CLOUD COMPUTING EQUIP IND INNOVATION CENT CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510314486.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-03-17
Publication Date
2025-07-22
Estimated Expiration
2045-03-17

AI Technical Summary

Technical Problem

The erase frequency of solid-state memory is too high, resulting in a degradation of performance.

Method used

Only one first storage area for storing resource data is provided in the solid state memory, and an erase process is performed when the to-stored area is the same as the stored area, thereby reducing unnecessary erasing times.

Benefits of technology

By reducing the number of erases, the performance and efficiency of solid-state memory is improved, the generation of garbage data is reduced, and the service life is extended.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119847450B_ABST
    Figure CN119847450B_ABST
Patent Text Reader

Abstract

An embodiment of the present application provides a method and device for processing resource data, a storage medium, and an electronic device, which relate to the computer field and are applied to a solid-state memory. Only one first storage area for storing resource data is set in the solid-state memory, and the method includes: receiving a resource transfer request carrying the resource data to be stored, where the resource transfer request is used to store the resource data to be stored in the first storage area; in response to the resource transfer request, determining a to-be-stored area in the first storage area; the to-be-stored area is the area where the resource data to be stored is to be stored in the first storage area; in the case where the to-be-stored area in the first storage area is the same as the set stored area, performing an erasure process on the first storage area; the stored area is the area in the first storage area where resource data has been stored; storing the resource data to be stored in the first storage area after the erasure process. The performance of the solid-state memory is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present application relate to the field of computers, and more particularly, to a method and apparatus for processing resource data, a storage medium, and an electronic device. Background Art

[0002] In the field of storage systems, a solid-state drive (SSD) is a storage device that uses semiconductor flash memory as the core storage medium and has been widely used in recent years. It has many differences from traditional hard disk drives (HHDs) in terms of performance, power consumption, and reliability. From the perspective of the operating characteristics of flash memory, the main difference between an SSD and an HHD lies in the processing of write operations. An SSD cannot perform overwrite write operations on any physical address like an HHD. It can only erase an entire block of data as a unit.

[0003] To enable an SSD to support read and write operations at any location, in related technologies, a garbage collection mechanism is introduced. When a user wants to overwrite the data at a written location in the SSD, the internal software control layer of the SSD maps this location to a new physical address for the user to write, and marks the original address as garbage data. When the amount of garbage data in an entire block of data reaches a certain threshold, garbage collection processing is started. The valid data in this block of data is moved to other unused locations, then the entire block of data is erased, and the entire physical address is marked as an unused location for subsequent use, that is, the recycling is completed. Obviously, the proportion of the amount of garbage data in the amount of the entire block of data directly determines the capacity loss of the SSD, and too frequent garbage collection processing will cause losses to the operating performance of the SSD.

[0004] Therefore, the situation where the current erasure frequency of solid-state memory is relatively high, seriously affecting the performance of solid-state memory, has become an urgent problem to be solved. Summary of the Invention

[0005] Embodiments of the present application provide a method and apparatus for processing resource data, a storage medium, and an electronic device, so as to at least solve the problem that the current erasure frequency of solid-state memory is too high, affecting the write performance of solid-state memory.

[0006] According to an embodiment of the present application, a method for processing resource data is provided, which is applied to a solid-state memory. Only one first storage area for storing resource data is provided in the solid-state memory, and the method includes: receiving a resource transfer request carrying the resource data to be stored, where the resource transfer request is used to store the resource data to be stored into the first storage area; in response to the resource transfer request, determining a to-be-stored area of the first storage area; the to-be-stored area is the area where the resource data to be stored is to be stored into the first storage area; when the to-be-stored area of the first storage area is the same as the set stored area, performing an erasure process on the first storage area; the stored area is the area in the first storage area where resource data has been stored; storing the resource data to be stored into the first storage area after the erasure process.

[0007] In an exemplary embodiment, the to-be-stored area is determined by a first pointer parameter recorded for the first storage area; the stored area is determined by a second pointer parameter recorded for the first storage area; the first pointer parameter is used to record the storage location where the resource data to be stored is to be stored into the first storage area; the second pointer parameter is used to record the storage location of the oldest resource data among the resource data already stored in the first storage area; the performing an erasure process on the first storage area when the to-be-stored area of the first storage area is the same as the set stored area includes: performing an erasure on the first storage area when the first pointer parameter is equal to the second pointer parameter.

[0008] In an exemplary embodiment, a second storage area for at least storing resource status parameters associated with the resource data stored in the first storage area is further provided in the solid-state memory; the performing an erasure process on the first storage area includes: determining the data to be erased in the first storage area; updating the resource status parameters in the second storage area according to the data to be erased, and writing the updated resource status parameters into the second storage area; when writing the updated resource status parameters into the second storage area, performing an erasure process on the first storage area based on the determined data to be erased.

[0009] In an exemplary embodiment, after writing the updated resource status parameters into the second storage area, it further includes: updating a record pointer associated with the second storage area; when the record pointer associated with the second storage area reaches a preset first record pointer threshold, performing an erasure process on the second storage area.

[0010] In an exemplary embodiment, before performing an erasure process on the second storage area, the method further includes: determining the storage capacity of the second storage area and the single - data length of the second storage area; the single - data length is the maximum data length set for one - time writing to the second storage area; based on the quotient of the storage capacity and the single - data length, determining the first record - pointer threshold.

[0011] In an exemplary embodiment, the method further includes: when the to - be - stored area of the first storage area is different from the set stored area, directly writing the to - be - stored resource data into the to - be - stored area of the first storage area.

[0012] In an exemplary embodiment, a third storage area for storing a first pointer parameter and a second pointer parameter is further provided in the solid - state memory; the method further includes: obtaining a power - down instruction; wherein, the power - down instruction is an instruction generated when the solid - state memory enters a stop - working state; based on the power - down instruction, determining the storage location of the resource data in the first storage area, and updating the first pointer parameter and the second pointer parameter in the third storage area according to the storage location.

[0013] In an exemplary embodiment, after updating the first pointer parameter and the second pointer parameter in the third storage area, it further includes: updating the record pointer associated with the third storage area; when the record pointer associated with the third storage area reaches a preset second record - pointer threshold, performing an erasure process on the third storage area.

[0014] In an exemplary embodiment, the solid - state memory includes a first storage area, a second storage area, and a third storage area; before receiving a resource transfer request carrying to - be - stored resource data, it further includes at least one of the following: performing a clearing process on the first storage area, the second storage area, and the third storage area of the solid - state memory; resetting the first pointer parameter, the second pointer parameter, the record pointer associated with the second storage area, and the record pointer associated with the third storage area recorded for the first storage area; writing an empty record in the first storage area; initializing the resource - state parameter in the second storage area;

[0015] In an exemplary embodiment, the method further includes: responding to a resource query request; the resource query request includes at least one of a resource - change query request and a resource - storage query request; based on the resource query request, determining a query result that matches the resource query request.

[0016] In an exemplary embodiment, determining a query result that matches the resource query request based on the resource query request includes: when the resource query request includes the resource change query request, determining, based on the resource change query request, a first resource change record that matches the resource change query request from the resource status parameters stored in the second storage area; determining the address of the first resource change record; and determining the query result corresponding to the resource change query request according to the address; when the resource query request includes a resource storage query request, directly determining resource storage parameters from the memory corresponding to the solid-state memory.

[0017] In an exemplary embodiment, before determining the storage area to be stored in the first storage area in response to the resource transfer request, it further includes: storing the resource data to be stored in a cache; where the cache is a buffer area set for the solid-state memory; and when it is determined that the data volume of the resource data in the cache reaches a set quantity threshold, in response to the resource transfer request, determining the storage area to be stored in the first storage area.

[0018] According to another embodiment of the embodiments of the present application, there is also provided a processing device for resource data, including: a receiving module, configured to receive a resource transfer request carrying resource data to be stored, where the resource transfer request is used to store the resource data to be stored in the first storage area; a determining module, configured to determine, in response to the resource transfer request, the storage area to be stored in the first storage area; the storage area to be stored is the area where the resource data to be stored is to be stored in the first storage area; an erasing module, configured to perform an erasing process on the first storage area when the storage area to be stored in the first storage area is the same as a set stored area; the stored area is the area in the first storage area where resource data has been stored; and a storing module, configured to store the resource data to be stored in the first storage area after the erasing process.

[0019] According to still another embodiment of the present application, there is also provided a computer-readable storage medium, in which a computer program is stored, where the computer program is set to execute the steps in any one of the above method embodiments when running.

[0020] According to still another embodiment of the present application, there is also provided an electronic device, including a memory and a processor, where a computer program is stored in the memory, and the processor is set to run the computer program to execute the steps in any one of the above method embodiments.

[0021] According to another embodiment of the present application, a computer program product is further provided. The computer program product includes a computer program, and when the computer program is executed by a processor, the steps in any one of the above method embodiments are implemented.

[0022] Through the present application, a resource transfer request carrying resource data to be stored is received, where the resource transfer request is used to store the resource data to be stored in a first storage area, and the first storage area is a storage area only set in the solid-state memory for storing resource data; in response to the resource transfer request, a to-be-stored area of the first storage area is determined; the to-be-stored area is the area where the resource data to be stored is to be stored in the first storage area; only when the to-be-stored area of the first storage area is the same as the set stored area, the first storage area will be erased, and the stored area is the area in the first storage area where resource data has been stored, and the resource data to be stored is stored in the erased first storage area. That is to say, the present application will only start erasing when it is determined that the area to be stored in the first storage area is the same as the area where resource data has been stored. Compared with the erasing method based on the garbage collection mechanism in the traditional technology, the number of erasing times is effectively reduced, and the performance of the SSD is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] 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 to the present application. In the drawings:

[0024] Figure 1 is a hardware structure block diagram of a server device for a resource data processing method according to an embodiment of the present application;

[0025] Figure 2 is a flowchart of a resource data processing method according to an embodiment of the present application;

[0026] Figure 3 is a schematic diagram of the state change of a blockchain in the related art;

[0027] Figure 4 is a schematic diagram of the storage example of the first storage area according to an embodiment of the present application;

[0028] Figure 5 is a schematic diagram of the link structure of a linked list according to an embodiment of the present application;

[0029] Figure 6 is a structure block diagram of a resource data processing device according to an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0030] Embodiments of the present application will be described in detail below with reference to the accompanying drawings and in conjunction with embodiments.

[0031] It should be noted that the terms "first", "second", etc. in the specification, claims and the above-mentioned drawings of the present application are used to distinguish similar objects, and do not necessarily have to be used to describe a specific order or sequence.

[0032] The method embodiment for processing resource data provided in the embodiments of the present application can be executed in a server device or a similar computing device. Taking the operation on a server device as an example, Figure 1 is a hardware structure block diagram of a server device for a method of processing resource data according to an embodiment of the present application. As Figure 1 shown, the server device may include one or more ( Figure 1 only one is shown in the figure) processors 102 (the processor 102 may include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data. Among them, the above-mentioned server device may further include a transmission device 106 for communication functions and an input / output device 108. Those of ordinary skill in the art can understand that Figure 1 the structure shown is only schematic and does not limit the structure of the above-mentioned server device. For example, the server device may further include more or fewer components than Figure 1 shown in the figure, or have a different configuration from Figure 1 shown in the figure.

[0033] The memory 104 can be used to store computer programs. For example, software programs and modules of application software, such as the computer program corresponding to the method of processing resource data in the embodiments of the present application. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, implements the above-mentioned method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. Among them, only one first storage area for storing resource data is provided in the solid-state memory. In some instances, the memory 104 may further include a memory remotely disposed relative to the processor 102, and these remote memories may be connected to the server device through a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an enterprise intranet, a local area network, a mobile communication network, and combinations thereof.

[0034] The transmission device 106 is used to receive or send data via a network. Specific examples of the above-mentioned network may include a wireless network provided by a communication provider of a server device. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, abbreviated as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a Radio Frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0035] To solve the above problems existing in the related art, in this embodiment, a method for processing resource data is provided, which is applied to a solid-state memory. Only one first storage area for storing resource data is set in the solid-state memory, and its execution subject includes but is not limited to the SSD controller of the solid-state memory. The solid-state memory and the SSD controller can be deployed in Figure 1 the server device shown in Figure 2 As shown, the process includes the following steps S202 - S210:

[0036] Step S202: Receive a resource transfer request carrying the resource data to be stored, where the resource transfer request is used to store the resource data to be stored in the first storage area;

[0037] Among them, the resource data may include information of the resource transferor, information of the resource transferee, as well as the resource amount, the next record pointer of the resource transfer list, and the next record pointer of the resource transfer-in list. The resource transfer list is used to record the transfer situation of the user's resource data, and the resource transfer-in list is used to record the reception situation of the user's resource data. For each user, a resource transfer list and a resource transfer-in list can be set. When there is a resource transfer request, the resource transfer list and the resource transfer-in list will be updated, as well as the next record pointer of the resource transfer list and the next record pointer of the resource transfer-in list will be recorded.

[0038] In some embodiments, when there is a resource transfer request, if the resource transfer request is a request for transferring out resource data, the resource transfer list of the resource transferor is correspondingly updated, and the next record pointer of the resource transfer list is recorded; at the same time, for the resource transfer request, in addition to the resource transferor, there will also be a resource recipient, so the resource transfer-in list of the resource recipient also needs to be correspondingly updated, and the next record pointer of the resource transfer-in list is recorded. By recording the next record pointer, it can be used to query the resource transfer records subsequently. According to the recorded next record pointer, the resource transfer records can be queried in sequence according to the sequence of resource transfers.

[0039] In some embodiments, the regional capacity of the first storage area can be preset. It can be understood that when the first storage area is full of resource data, or the resource data already stored in the first storage area has occupied a preset proportion of the regional capacity, for example, it has occupied 80% of the regional capacity, then the first storage area can be erased. When specifically setting the regional capacity of the first storage area, various influencing factors can be considered. For example, the data length of the resource data to be stored each time. Since the information included in the resource data is consistent, such as including the information of the resource transferor, the information of the resource transferee, as well as the resource amount, the next record pointer of the resource transfer linked list, and the next record pointer of the resource receipt linked list, the data length of the resource data to be stored each time can also be set to a fixed value, that is, it is default that the data length of the resource data stored each time is the same. In addition to the data length of the resource data to be stored, the total number of users with resource transfer service requirements and the maximum resource amount of each user also need to be considered. The embodiments of the present application do not limit this here.

[0040] In some embodiments, the first storage area is used to store all resource data, and the resource data can specifically refer to transfer records. When the resource data is a transfer record, the resource data to be stored each time can include the following data: the transfer-out account number; the transfer-in account number; the transfer amount; the next record pointer of the resource transfer linked list; the next record pointer of the resource receipt linked list. The length of each resource data is lr, and lr at least satisfies: lr ≥ α + 2β + 2γ.

[0041] Wherein, α refers to the number of bytes occupied by each transfer amount; β is the number of bytes occupied by each account number (including the transfer-out account number and the transfer-in account number); γ refers to the number of bytes occupied by the next record pointer. The regional capacity of the first storage area can be defined as: n1 := r * lr, where r is the number of transfer records determined according to the number of users and the account user quota, and ":=" is a symbol indicating the definition meaning. Set lr | Cb (indicating that Cb can divide lr evenly, Cb is the erasure unit, and the size of Cb is determined by the hardware attributes of the SSD itself); , wherein, rb represents the number of transfer records included in each erasure block. And set rb | r (indicating that r can divide rb evenly); , wherein, rc represents the number of erasure blocks included in the entire first storage area.

[0042] In some embodiments, it can be set that: α = 8; β = 2; γ = 4; Cb = 20MB = 20 × 2 20 ; then lr = 20, m = 264, n = 216, r = 232, which exactly satisfies lr | Cb, so rb = 220 , which also exactly satisfies rb|r, so rc = 2 12 . The calculated capacity of the first storage area is: n1 = 80GB.

[0043] Step S204: In response to the resource transfer request, determine the area to be stored in the first storage area; the area to be stored is the area where the resource data to be stored is to be stored in the first storage area.

[0044] It can be understood that on the basis that the area capacity of the first storage area has been determined, it is also possible to determine how much resource data can be stored in the first storage area. In the first storage area, according to the area capacity and the data length of the pre-calculated resource data, the first storage area can be divided into multiple storage areas.

[0045] Among them, the area to be stored is the determined area where the resource data is to be stored in the first storage area, that is, the determined position where the data to be stored is to be written. When determining the area to be stored, it can be determined based on the first pointer parameter of the first storage area.

[0046] It can be understood that the first pointer parameter can be represented by numbers, letters, and feature codes, etc. The first pointer parameter can correspond to the storage areas in the first storage area. For example, there are 12 storage areas in the first storage area. When representing the first pointer parameter by numbers, the pointer parameters are 0, 1, 2... 11 respectively. Among them, 0 can correspond to the first storage area, and 11 can correspond to the 12th storage area. When writing the resource data to be stored into the first storage area, it can be written in sequence. For example, first write the resource data to be stored into the first storage area, then write the resource data to be stored into the second storage area... and so on, until writing to the 12th storage area. At this time, it means that the first storage area has been filled.

[0047] It should be noted that before storing the resource data to be stored into the first storage area, the first pointer parameter needs to be determined first, and the area to be stored is determined according to the first pointer parameter. If the determined first pointer parameter is 0, it can indicate that the area to be stored is the first storage area.

[0048] Optionally, for each storage area, multiple resource data can be stored. The specific number of resource data that can be stored can be determined by the area capacity of the storage area, the data length of the resource data, etc.

[0049] Step S206: When the area to be stored in the first storage area is the same as the set stored area, perform an erasure process on the first storage area; the stored area is the area in the first storage area where resource data has been stored.

[0050] Among them, the stored area is the area in the determined first storage area where resource data has been stored. When determining the stored area, it can be determined based on the second pointer parameter recorded for the first storage area.

[0051] It can be understood that the second pointer parameter can be represented by numbers, letters, feature codes, etc. The second pointer parameter can correspond to the storage areas in the first storage area.

[0052] Optionally, the second pointer parameter can be corresponded to the storage area where resource data is first stored in the first storage area, that is, the second pointer parameter points to the oldest storage area, and the oldest storage area can be understood as the position where resource data is first written in the first storage area.

[0053] In an exemplary embodiment, the area to be stored is determined by a first pointer parameter recorded for the first storage area; the stored area is determined by a second pointer parameter recorded for the first storage area; the first pointer parameter is used to record the storage position where the resource data to be stored is to be stored into the first storage area; the second pointer parameter is used to record the storage position of the oldest resource data among the resource data already stored in the first storage area; when the area to be stored in the first storage area is the same as the set stored area, the erasing process for the first storage area includes: when the first pointer parameter is equal to the second pointer parameter, erasing the first storage area.

[0054] Among them, the oldest resource data can be understood as the resource data first written in the first storage area. As the erasing process is completed, the second pointer parameter will change, and the oldest resource data will also change.

[0055] Specifically, the first pointer parameter is used to represent the storage area that will be used to store the resource data to be stored, and the second pointer parameter is used to represent the storage area of the oldest resource data in the first storage area, that is, it points to the oldest stored area in the first storage area. When the first pointer parameter is equal to the second pointer parameter, it indicates that the storage space of the first storage area is full, that is, when the area to be stored in the first storage area is the same as the oldest stored area pointed to by the second pointer parameter, at this time, it is necessary to erase the resource data already stored in the first storage area so that the resource data to be stored can be written into the first storage area.

[0056] In the above embodiment, when determining whether it is necessary to perform an erasing process on the first storage area, only the first pointer parameter and the second pointer parameter need to be obtained. By comparing the first pointer parameter and the second pointer parameter, when the first pointer parameter and the second pointer parameter are the same, the first storage area can be erased, improving the processing efficiency of resource data.

[0057] In an exemplary embodiment, a second storage area is further provided in the solid-state memory for storing at least resource status parameters associated with the resource data stored in the first storage area; the erasing process for the first storage area includes: determining the data to be erased in the first storage area; updating the resource status parameters in the second storage area according to the data to be erased, and writing the updated resource status parameters into the second storage area; when writing the updated resource status parameters into the second storage area, performing an erasing process on the first storage area based on the determined data to be erased.

[0058] Among them, the resource status parameters may include the first resource transfer record of each resource account, that is, the initialization record, and the initial resource amount of each resource account, etc. Among them, the resource account can either initiate a resource transfer operation as a resource transfer party or receive a resource transfer as a resource receiving party. Before the data to be erased is erased, the initial resource amount, the first resource transfer record, etc. of the resource account related to the data to be erased can be updated correspondingly.

[0059] In some embodiments, in addition to storing resource status parameters, the second storage area may further store the following system control parameters, and these system control parameters may be constants set based on the hardware performance of the SSD, such as may include the number of bytes occupied by the resource amount of each resource transfer party, the number of bytes occupied by the account numbers of each resource transfer party and resource receiving party, the number of bytes occupied by the transfer record number, etc.

[0060] It can be understood that after determining the data to be erased, the resource status parameters in the second storage area are updated according to the data to be erased, so that even if the subsequent data to be erased is erased, its resource status parameters are also updated, ensuring the accuracy of the subsequent resource query process.

[0061] In the above embodiment, after determining the data to be erased, the resource status parameters in the second storage area are also updated based on the data to be erased, avoiding the situation of errors in resource amounts caused by the data erasing process, and effectively improving the processing accuracy of resource data.

[0062] In an exemplary embodiment, the determining the data to be erased in the first storage area includes: determining the length of the data to be erased based on the attributes of the solid-state memory; determining the data to be erased with the length from the first storage area according to the storage time of the resource data stored in the first storage area.

[0063] Specifically, the attributes of the solid-state memory refer to the hardware performance of the solid-state memory, and the data length of the resource data that can be deleted at one time is determined by the hardware performance of the solid-state memory.

[0064] In the above embodiment, the data length of the data that can be erased each time during the erase process is determined by the hardware performance of the solid-state memory, and then the data length of the data to be erased each time is determined, effectively improving the data erase efficiency.

[0065] In an exemplary embodiment, after writing the updated resource status parameter into the second storage area, the method further includes: updating the record pointer associated with the second storage area; and performing an erase process on the second storage area when the record pointer associated with the second storage area reaches a preset first record pointer threshold.

[0066] Among them, the record pointer associated with the second storage area is used to record the number of times of updating the resource status parameter. After each time the updated resource status parameter is written into the second storage area, the record pointer will be updated correspondingly. For example, a number can be used to represent the record pointer associated with the second storage area, and the initial value of the record pointer associated with the second storage area can be set to 0. When a new resource status parameter is written each time, the record pointer associated with the second storage area will be incremented by 1.

[0067] The first pointer record threshold is a set threshold for determining whether the second storage area is full. After the updated record pointer associated with the second storage area reaches the first record pointer threshold, an erase process can be performed on the second storage area.

[0068] In the above embodiment, by updating the record pointer associated with the second storage area, when the record pointer reaches the first record pointer threshold, it can be determined that the second storage area is full, and then the second storage can be erased in a timely manner, improving the processing efficiency and accuracy of the resource data.

[0069] Specifically, when determining the first pointer record threshold, it can be determined according to the storage capacity of the second storage area.

[0070] In an exemplary embodiment, before performing an erase process on the second storage area, the method further includes: determining the storage capacity of the second storage area and the single data length of the second storage area; the single data length is the maximum data length set for one-time writing into the second storage area; and determining the first record pointer threshold based on the quotient of the storage capacity and the single data length.

[0071] Specifically, the storage capacity of the second storage area can be set to the size of one erasure unit, and the erasure unit can be the smallest erasure unit set according to the performance of the SSD. Relatively speaking, the storage capacity of the second storage area is smaller than that of the first storage area. The quotient obtained by dividing the storage capacity of the second storage area by the single data length is determined as the first record pointer threshold.

[0072] Step S208: Store the resource data to be stored in the first storage area after erasure processing.

[0073] In an exemplary embodiment, the storing the resource data to be stored in the first storage area after erasure processing includes: determining a new area to be stored in the first storage area after erasure processing; writing the resource data to be stored into the new area to be stored in the first storage area.

[0074] In an exemplary embodiment, the method further includes: directly writing the resource data to be stored into the area to be stored in the first storage area when the area to be stored in the first storage area is different from the set stored area.

[0075] In the above steps S202 - S208, a resource transfer request carrying resource data to be stored is received, where the resource transfer request is used to store the resource data to be stored in the first storage area, and the first storage area is the only storage area set in the solid - state memory for storing resource data; in response to the resource transfer request, the area to be stored in the first storage area is determined; the area to be stored is the area where the resource data to be stored is to be stored in the first storage area; the first storage area is erased only when the area to be stored in the first storage area is the same as the set stored area, and the stored area is the area in the first storage area where resource data has been stored, and the resource data to be stored is stored in the first storage area after erasure processing. That is, in this application, the first storage area is erased only when the area to be stored in the first storage area is the same as the set stored area. That is to say, erasure is only carried out when it is determined that the area to be stored in the first storage area is the same as the area where resource data has been stored. Compared with the erasure method based on the garbage collection mechanism in the traditional technology, the number of erasures is effectively reduced, and the performance of the SSD is improved.

[0076] In an exemplary embodiment, a third storage area for storing a first pointer parameter and a second pointer parameter is further provided in the solid-state memory; the method further includes: obtaining a power-down instruction; wherein, the power-down instruction is an instruction generated when the solid-state memory enters a stop working state; based on the power-down instruction, determining the storage location of the resource data in the first storage area, and updating the first pointer parameter and the second pointer parameter in the third storage area according to the storage location.

[0077] It can be understood that the solid-state memory entering the stop working state can be that the solid-state memory normally enters the sleep state, or the state entered when receiving a shutdown operation. Of course, the solid-state memory entering the stop working state can also be that the solid-state memory has an abnormal power failure. No matter what causes the solid-state memory to enter the stop working state, the storage location of the resource data in the first storage area will be determined, and the first pointer parameter and the second pointer parameter in the third storage area will be updated according to the storage location.

[0078] In the above embodiment, by updating the first pointer parameter and the second pointer parameter during power-down, when the solid-state memory works normally subsequently, the storage of resource data can be carried out based on the recorded first pointer parameter and second pointer parameter, improving the storage efficiency.

[0079] In an exemplary embodiment, after updating the first pointer parameter and the second pointer parameter in the third storage area, it further includes: updating a record pointer associated with the third storage area; and performing an erasing process on the third storage area when the record pointer associated with the third storage area reaches a preset second record pointer threshold.

[0080] Wherein, the second record pointer is used to record the number of times of updating the first pointer parameter and the second pointer parameter. After each time the updated first pointer parameter and second pointer parameter are written into the third storage area, the record pointer associated with the third storage area will be correspondingly updated. For example, a number can be used to represent the record pointer associated with the third storage area, and the initial value of the record pointer associated with the third storage area can be set to 0. When a new resource state parameter is written each time, the record pointer associated with the third storage area will be incremented by 1.

[0081] The second pointer record threshold is a set threshold for judging whether the third storage area is full. After the record pointer associated with the third storage area after update reaches the second record pointer threshold, an erasing process can be performed on the second storage area.

[0082] In an exemplary embodiment, the solid-state memory includes a first storage area, a second storage area, and a third storage area; before receiving a resource transfer request carrying resource data to be stored, it further includes at least one of the following: clearing the first storage area, the second storage area, and the third storage area of the solid-state memory; resetting the first pointer parameter, the second pointer parameter, the record pointer associated with the second storage area, and the record pointer associated with the third storage area recorded for the first storage area; writing an empty record in the first storage area; initializing the resource status parameter in the second storage area.

[0083] In the above embodiment, before receiving a resource transfer request carrying resource data to be stored, the memory variables of the solid-state memory can be initialized. Through the initialization process, the normal operation of the subsequent solid-state memory can be ensured, and the processing accuracy of resource data can be improved.

[0084] In an exemplary embodiment, the method further includes: responding to a resource query request; the resource query request includes at least one of a resource change query request and a resource storage query request; based on the resource query request, determining a query result that matches the resource query request.

[0085] It can be understood that for the solid-state memory, in addition to the request to write resource data into the solid-state memory, a resource query request can also be sent to the solid-state memory. The resource query request can include at least one of a resource change query request and a resource storage query request.

[0086] In an exemplary embodiment, the determining, based on the resource query request, a query result that matches the resource query request includes: in the case where the resource query request includes the resource change query request, based on the resource change query request, determining a first resource change record that matches the resource change query request from the resource status parameters stored in the second storage area; determining the address of the first resource change record; according to the address, determining the query result corresponding to the resource change query request; in the case where the resource query request includes a resource storage query request, directly determining the resource storage parameter from the memory corresponding to the solid-state memory.

[0087] It should be noted that the resource change query request may include requests generated when resources are transferred out or transferred in. For the resource change query request, the resource first change record that matches the resource change query request may be determined from the resource status parameters stored in the second storage area first, that is, the resource first change record of the resource transferor in the resource change request. After determining the resource first change record, the address of the resource first change record may be determined based on the resource transfer list and the resource transfer-in list of the resource transferor, and then the query result may be obtained.

[0088] In an exemplary embodiment, for any resource account numbered K, when querying all its incoming (outgoing) records, the main execution process is as follows: obtain the number of the first incoming record of account K from the data in the second storage area and obtain the number of the first outgoing record of account K from the data in the first storage area, and find the first incoming (outgoing) record of account K from the first storage area according to the number of the first incoming record and the number of the first outgoing record; trace each incoming (outgoing) record along the incoming (outgoing) record list, and read the transferred-in account, the transferred-out account, and the transfer amount information from it and return them to the user.

[0089] In an exemplary embodiment, before determining the storage area to be stored in the first storage area in response to the resource transfer request, it further includes: storing the resource data to be stored in a cache; where the cache is a buffer set for the solid-state memory; in the case where the data volume of the resource data in the cache reaches a set quantity threshold, in response to the resource transfer request, determine the storage area to be stored in the first storage area.

[0090] It can be understood that there are different data granularities for the write operations of different flash memories (i.e., solid-state memories), and these granularities may not necessarily be aligned with the minimum write granularity of the flash memory. To avoid the actual write granularity exceeding the requirement by a large amount and thus resulting in too many write times, in specific implementation, a cache mechanism is introduced to collect various write operations. When enough write operations are collected in the cache, the write from the cache to the flash memory is then implemented.

[0091] In some embodiments, all data in the second storage area and the third storage area can be updated and read in the cache, and are synchronized with the flash memory only when necessary. If the user needs to perform too many operations of querying incoming (outgoing) records, some or all of the following data can be cached: the complete incoming and outgoing records of some frequently queried accounts; the latest partial incoming and outgoing records of all accounts to avoid calling the flash memory for query operations multiple times.

[0092] Obviously, the above-described embodiments are only a part of the embodiments of the present invention, rather than all embodiments. To better understand the above method, the following will describe the above process in conjunction with embodiments, but it is not used to limit the technical solutions of the embodiments of the present invention. Specifically:

[0093] In the related art, in order to enable a solid-state drive (SSD) to support read and write operations at any position, a garbage collection mechanism needs to be introduced. When a user wants to overwrite the data at a written position in a block, the SSD introduces a garbage collection mechanism to mark the data at the written position as garbage data. When the amount of garbage data reaches a certain level, the unmarked data in the entire block is transferred to other free blocks, and then the entire block is erased. Due to the randomness of SSD data reading and writing, there may be garbage data in many blocks of the SSD. In this way, not only do many blocks need to transfer data, but also erase processing is required, seriously affecting the performance of the SSD.

[0094] Blockchain technology has received extensive attention in recent years. In essence, it is a distributed accounting storage. From the perspective of users, a blockchain is essentially a complete virtual machine that can be operated by all users of the network, but in fact, it may be distributed in any corner of the entire Internet. It uses a certain authentication mechanism based on voting (such as PoW, PoS, or PoA). PoW, PoS, and PoA are three different authentication mechanisms of the blockchain, referring to authentication based on workload, authentication based on collateral, and authentication based on authority respectively, to ensure that there is a unique acceptable state at any time. Its core implementation mechanism is to strictly record each state change (Transaction) of the virtual machine, determine the state set, and then assemble a certain number of Transactions into Blocks according to time and capacity requirements, select the accepted Blocks according to the authentication mechanism, and further assemble the Blocks into a chain to save the history of state changes, as Figure 3 shown, are different state changes (Transactions): Trans1…TransN, and the corresponding state sets, Stat1…StatN. Currently, this type of technology is mainly used in the financial field. For example, it can ensure the credibility and traceability of each transaction in the absence of a centralized certification authority.

[0095] Inspired by blockchain technology, this application considers dedicating SSDs to accounting storage, that is, storing resource data. Suppose there are several fixed accounts, and each account corresponds to a certain amount of deposit. Accounting storage means not only recording the deposit amount of each account but also recording the transfer history between accounts. Hereinafter, this dedicated SSD is called ASSD (Account Solid State Drive). Similar to the implementation strategy of blockchain, this type of storage requirement can adopt incremental storage, that is, each transfer operation only needs to add a record of the transferred amount (i.e., the resource amount), the source account (the resource transferor), and the target account (the resource recipient), while modifying the information of the source account itself as little as possible, which exactly suits the erasure operation characteristics of the SSD storage medium. Therefore, if SSDs are dedicated to accounting storage, the generation of garbage data can be avoided as much as possible, and thus the capacity loss caused by garbage collection operations can be avoided. ASSD can be bound to a specific application of an SSD with FDP (Flexible Data Placement) function and a specific RUG in the SSD to enable a part of the storage space of the SSD to be dedicated to ASSD without affecting the use of the remaining storage space.

[0096] For the above storage application, this application includes the following basic steps: 1. Format the ASSD, that is, initialize the accounting storage; 2. Add a transfer record to the ASSD; 3. Query all incoming records of a certain account; 4. Query all outgoing records of a certain account; 5. Query the deposit balance of a certain account; 6. When the transfer record space is insufficient, a certain number of the oldest transfer records need to be erased, and the corresponding account information is updated at the same time; 7. Power on; 8. Power off.

[0097] In this application, for the sake of clarity, the following assumptions are first made about the structure of the flash space organization (i.e., the storage area) in the ASSD: The flash space organization is a one-dimensional linear structure [0, Ca) ⊂ Z. For a flash medium with an actual high-dimensional structure, the high-dimensional structure can be expanded into a one-dimensional structure in any way. Where Ca is the capacity of the entire flash user space. The erasure operation unit of the flash is a continuous interval in the above one-dimensional structure, that is, [iCb, (i + 1)Cb), i = 0, 1,..., Ca / Cb.

[0098] Among them, Cb is the space size of an erasure unit, and Cb|Ca. Hereinafter, the erasure unit is called an erasure block. All capacities and space sizes in this application are in bytes as the unit. All addresses mentioned hereinafter refer to the above linear addresses. Suppose a total of α bytes are used to save the account balance and the transfer amount. That is, the maximum balance of each account is m := 2^8 α Suppose the total number of accounts is n := 2^8 β. That is, use β bytes to save the account number, and the value range of the account number is [0, n−1]. Among them, the number n −1 represents a special source-sink account, that is, money can be arbitrarily generated and eliminated from this account. Suppose use γ≥β bytes to save the transfer record pointer (number), that is, at most r:=2 8γ transfer records can be saved. The user flash space of the entire ASSD is divided into three areas. The first storage area is used to save all transfer records. Each record includes the following data: the transfer-out account number, the transfer-in account number, the transfer amount, the pointer to the next record in the income record linked list, and the pointer to the next record in the expenditure record linked list. Suppose the length of each transfer record is lr, then lr should at least satisfy lr ≥ α + 2β + 2γ. Note that the first transfer record of each account is the initialization record, that is, the transfer-in account number is n – 1, representing a special account. Since this area is used cyclically, the system will maintain a set of head and tail pointers to manage the writing behavior. Among them, the head pointer points to the current position to be written, denoted as pr, and the tail pointer points to the position of the oldest record, denoted as pt. Refer to Figure 4 shown. The innermost circle shows a storage example of the first storage area. The data area stores resource data. By selecting the erasure area from the data area, a blank area can be obtained. Each block represents a continuous storage space of size lr. Since the blocks are used cyclically, they are shown as a ring. In this example, rb = 4, rc = 3, r = 12.

[0099] The second storage area contains an erasure block for saving the system control information of the entire system. Suppose the length of the system control information is ls, and it satisfies ns:=⌊Cls⌋≥1. A pointer ps to the position to be written can be maintained. This pointer is used cyclically according to mod ns throughout the area. After each write, set ps:=ps +1mod ns. Every time ns writes are completed, erase the entire block and rewrite the data of the latest write into the erased space, and update ps one more time. In the system control information, the writing time and ps will be included.

[0100] The third storage area saves the record pointer information, that is, the position where the new record in the second storage area is to be written, in units of records, and the size is an erasure block. The saving method is similar to that of the first storage area. Suppose the length of each write is lp, and define np:=⌊Cblp⌋≥1, which is the number of times that can be written in the entire third storage area. Every time the power is turned off, the record pointer information needs to be written to the third storage area once. The system maintains a pointer p p to the position to be written. This pointer is used cyclically according to mod np throughout the area. After each write, set p p := p p+1 mod np. After every np writes, the entire block is erased and the data of the latest write is rewritten to the erased space, and p is updated one more time. p . Each write contains the following information: the write management pointers pr and pt of the second region, where pr, pt ∈ [0, r); the time when the pointer information of this record is updated: p p ∈ [0, np). So lp ≥ 4×2 + 8 + γ. For the above example, lp = 20 and np = 1M. That is, the third storage region needs to be erased only once every 1 million power-downs. For the second and third storage regions, every time the power is on, the firmware system traverses all the control information records in this region and loads the record with the latest write time into the system. Counting, the system control information in the first storage region needs to include at least the following content: constant information such as α, β, γ, ls, lr, lp, rb, rc, r, ns, np, etc.; the write time of the current system control information; the write position ps of the next system control information, where ps ∈ [0, ns); the first transfer record (initialization record) uk of all accounts, where uk ∈ [0, r), k ∈ [0, n); the original amount O k ∈ [0, m), k ∈ [0, n).

[0101] Considering that the other data except time is saved using 4 bytes and the time data is saved using 8 bytes, then each time at least ls = 4×12 + 8 + n(α + γ) bytes need to be written in total. Here, ls = 12×216 + 48 + 8 = 786488 and ns = 26. When the second storage region is full, the system needs to perform an erase operation. At this time, the system control information is updated and a write is completed. Whenever the system control information is written ns - 1 times, the first storage region needs to perform an erase operation. In this example, whenever the first storage region performs 25 erase operations, the second storage region needs to perform an erase operation.

[0102] To maintain the linked list of all historical incoming and outgoing records of each account, the head and tail pointers of the above linked list of each account need to be saved in memory, denoted as , , , . Among them, k is the record number, is the address of the earliest existing incoming record. is the address of the latest existing incoming record, is the address of the earliest existing outgoing record, is the address of the latest existing outgoing record. Figure 5Shows the linked structure of the linked list. Assume there are three accounts in the figure, Account 1, Account 2, and Account 3. Figure 5 It is the structure diagram of the linked list of the incoming and outgoing account records for each account. Is the address of the earliest existing incoming account record representing Account 1 in the Nand physical medium. Is the address of the earliest existing incoming account record representing Account 1 in the memory variable. Similarly, Is the address of the earliest existing incoming account record representing Account 2 in the Nand physical medium. Is the address of the earliest existing incoming account record representing Account 2 in the memory variable. Is the address of the earliest existing incoming account record representing Account 3 in the Nand physical medium. Is the address of the earliest existing incoming account record representing Account 3 in the memory variable. The solid line connection indicates the next transfer record with the income account of this transfer record as the transfer destination account, and the dotted line connection indicates the next transfer record with the expenditure account of this transfer record as the transfer source account. Traverse along the link until a null pointer is encountered, which means all incoming (outgoing) account records with a certain account as the destination (source) have been traversed. For example, the numbers of all incoming account records of Account 2 in the figure are {3, 14}, and the numbers of all outgoing account records are {6, 17}. The record numbers here have the same meaning as Figure 2 The innermost numbers in are the same meaning, both representing the record addresses in Region 1. At the same time, in order to facilitate querying the account balance, the balance d of each account also needs to be maintained in the memory k .

[0103] First, consider the formatting (initialization) of the ASSD operation. This operation mainly includes the following processes: 1. Clear the storage spaces of the three storage areas; 2. Confirm the correctness of the above values such as α, β, γ, ls, lr, lp, rb, rc, r, ns, np, etc.; 3. Reset the pointer p s = 0, p t = 0, pr = 1, pp = 0; 4. Write an empty record at the record position 0 in the first storage area; 5. Initialize the account information O in the second storage area k , , ; 6. Initialize the memory variables , , , , d k .

[0104] Next, consider adding a transfer record to the ASSD. The main process of this operation is as follows: 1. Query the account balance of the transfer source account and determine whether the balance meets the requirements of the transfer record to be processed. If it does not meet the requirements, terminate the execution and return failure to the user. 2. Determine whether the storage space in the first storage area is full (pt = pr). If it is full, execute the following erasure process. 3. Write the transfer-in account number, transfer-out account number, and transfer amount to the record position pointed to by pr, and note that the record pointer fields of the two linked lists are kept empty. 4. According to the direction of the transfer operation, write the address of this transfer record to the record pointer field in the record pointed to by or . 5. Update or as the address of this transfer record; 6. Update the account balance d in the memory k .

[0105] Next, consider querying all incoming (outgoing) records of an account with the number k. The main execution process is as follows: 1. Obtain , from the data in the second storage area; 2. Find the first incoming (outgoing) record of account k from the first storage area according to , ; 3. Trace each incoming (outgoing) record along the incoming (outgoing) record linked list, and read the transfer-in account, transfer-out account, and transfer amount information from it and return it to the user.

[0106] The main process of querying the deposit balance of an account with the number k is as follows: 1. Directly return d in the memory k ;

[0107] When the transfer record space is insufficient, it is necessary to execute a first storage area erasure process. The execution process can be described as follows: 1. Merge the transfer records in the area to be erased into the original total amount for each account, and then update O k (the amount of each account); 2. Update , ; 3. Update the memory variables , ; 4. Execute an erasure operation on the current area to be erased in the first storage area; 5. Set a new area to be erased for the first storage area; 6. Execute a system control information write to the second storage area to update p s .

[0108] Each time the system is powered on, the following operations need to be performed: 1. Read the latest system control information from area two, including various system constants and account information O k , , ; 2. Read the latest record pointer information from Region 3 and assign it to variables pt and pr; 3. According to the read O k , 、 Update the variables in memory 、 、 、 , specifically: (a) = , = . (b) By tracking the income (expenditure) linked list of account k to the last record, , can be obtained. 4. Scan all the incoming records of each account and calculate the total incoming amount ti; 5. Scan all the outgoing records of each account and calculate the total outgoing amount to; 6. Update d k :=O k + ti – to.

[0109] Each time the system powers off, the following operations need to be performed: 1. According to the variables p t , p r , perform a write operation of record pointer information on the third storage area to update Pp.

[0110] Through the resource data processing method of this application, the amount of garbage data in ASSD is significantly lower than that of general SSD. Along with the reduction of the amount of garbage data, the number of erase operations performed per unit time will also decrease, thereby extending the service life of SSD. The garbage quantity of general SSD is theoretically evaluated and then compared with the garbage quantity of ASSD. Secondly, from the power-on and power-off process, it can be seen that the power-off process of ASSD is simple, which is beneficial to power off through the limited capacitor power in case of abnormal power-off. Under this setting, only when the transfer records fill up the first storage area, will an erase process be performed on the first storage area. Correspondingly, after an erase process is performed on the first storage area, the control information stored in the second storage area will be updated. Among them, the second storage area maintains a record parameter. Whenever the control information stored in the first storage area is updated once, this record parameter will be incremented by 1. When the number of the updated record parameter reaches the set number, an erase process will be performed on the second storage area. For the third storage area, the third storage area also maintains a record parameter. Whenever the SSD system powers off, the record pointer stored in the third storage area will be updated once, and this record parameter will be incremented by 1. When the number of the updated record parameter reaches the set number, an erase process will be performed on the third storage area.

[0111] Compared with the garbage collection mechanism in the prior art, when a region is not yet full, it is possible to perform an erasure process on this region. The present application can effectively reduce the number of erasures and improve the performance of the SSD. When all positions in a physical block in the system are written full, garbage collection is required. Starting from the state where the block is vacant (i.e., just recycled) until it is written full, how many times of repeated writes are generated within the physical address range of the block. Since each repeated write will result in the generation of one unit of garbage data, the above number is equal to the amount of garbage data generated during this period, and this amount is called the garbage generation amount. In other words, if the garbage collection strategy is to start garbage collection only after the data block is completely filled, then as the recycled block gradually increases, the ratio of the amount of garbage data generated to the amount of the entire block of data tends to infinity. Table 1 shows the ESm calculated when m takes different values with n = 1000, where n refers to the maximum data capacity within the data block, m refers to the data occupancy threshold for starting garbage collection, and ESm refers to the ratio of the amount of garbage data generated to the amount of the entire block of data. For the ASSD, all garbage data is concentrated in the second storage area and the third storage area. Since the sizes of the second storage area and the third storage area are limited within two erasure blocks, the amount of its garbage data is also less than the sizes of two erasure blocks. However, if a general SSD is used as the accounting storage, garbage data will be generated in the erasure blocks of all user data, and the amount of garbage data will increase with the growth of the transfer records. Therefore, for accounting storage, in terms of the amount of garbage data generated, using the ASSD will be significantly better than using a general SSD.

[0112] Table 1

[0113]

[0114] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by means of software plus a necessary general hardware platform. Of course, it can also be implemented by hardware, but in many cases, the former is a better implementation method. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disc), and includes several instructions to enable a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in various embodiments of the present application.

[0115] In this embodiment, a processing device for resource data is further provided to implement the above-mentioned embodiments and preferred implementation manners, which have been described and will not be repeated here. As used hereinafter, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the modules described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware is also possible and contemplated.

[0116] Figure 6 FIG. 4 is a structural block diagram of a processing device for resource data according to an embodiment of the present application. The device includes:

[0117] A receiving module 602, configured to receive a resource transfer request carrying resource data to be stored, where the resource transfer request is used to store the resource data to be stored in the first storage area;

[0118] A determining module 604, configured to determine a storage area to be stored in the first storage area in response to the resource transfer request; the storage area to be stored is the area where the resource data to be stored is to be stored in the first storage area;

[0119] An erasing module 606, configured to perform an erasing process on the first storage area when the storage area to be stored in the first storage area is the same as a set stored area; the stored area is the area in the first storage area where resource data has been stored;

[0120] A storage module 608, configured to store the resource data to be stored in the first storage area after the erasing process.

[0121] The above device receives a resource transfer request carrying resource data to be stored, where the resource transfer request is used to store the resource data to be stored in the first storage area, and the first storage area is the only storage area for storing resource data set in the solid-state memory; in response to the resource transfer request, it determines the storage area to be stored in the first storage area; the storage area to be stored is the area where the resource data to be stored is to be stored in the first storage area; the first storage area will be erased only when the storage area to be stored in the first storage area is the same as the set stored area, and the stored area is the area in the first storage area where resource data has been stored, and the resource data to be stored is stored in the first storage area after the erasing process. That is, in the present application, the first storage area will be erased only when the storage area to be stored in the first storage area is the same as the set stored area, that is, only when it is determined that the area to be stored in the first storage area is the same as the area where resource data has been set and stored, the erasing will be started. Compared with the erasing method based on the garbage collection mechanism in the traditional technology, the number of erasing times is effectively reduced, and the performance of the SSD is improved.

[0122] In an exemplary embodiment, the to-be-stored area is determined by a first pointer parameter recorded for the first storage area; the stored area is determined by a second pointer parameter recorded for the first storage area; the first pointer parameter is used to record the storage location where the resource data to be stored is to be stored into the first storage area; the erasing module 606 is further configured to erase the first storage area when the first pointer parameter is equal to the second pointer parameter.

[0123] In an exemplary embodiment, a second storage area for storing at least resource state parameters associated with the resource data stored in the first storage area is further provided in the solid-state memory; the erasing module 606 is further configured to determine the data to be erased in the first storage area; update the resource state parameters in the second storage area according to the data to be erased, and write the updated resource state parameters into the second storage area; when writing the updated resource state parameters into the second storage area, perform an erasing process on the first storage area based on the determined data to be erased.

[0124] In an exemplary embodiment, the erasing module 606 is further configured to update a record pointer associated with the second storage area; and perform an erasing process on the second storage area when the record pointer associated with the second storage area reaches a preset first record pointer threshold.

[0125] In an exemplary embodiment, the apparatus further includes a threshold calculation module; the threshold calculation module is configured to determine the storage capacity of the second storage area and the single-data length of the second storage area; the single-data length is the maximum data length set for one-time writing into the second storage area; and determine the first record pointer threshold based on the quotient of the storage capacity and the single-data length.

[0126] In an exemplary embodiment, the storage module 608 is further configured to directly write the resource data to be stored into the to-be-stored area of the first storage area when the to-be-stored area of the first storage area is different from the set stored area.

[0127] In an exemplary embodiment, a third storage area for storing a first pointer parameter and a second pointer parameter is further provided in the solid-state memory; the device further includes an update module; the update module is configured to obtain a power-down instruction; wherein, the power-down instruction is an instruction generated when the solid-state memory enters a stop working state; based on the power-down instruction, determine the storage location of the resource data in the first storage area, and update the first pointer parameter and the second pointer parameter in the third storage area according to the storage location.

[0128] In an exemplary embodiment, the erasing module 606 is further configured to update a record pointer associated with the third storage area; and in a case where the record pointer associated with the third storage area reaches a preset second record pointer threshold, perform an erasing process on the third storage area.

[0129] In an exemplary embodiment, the solid-state memory includes a first storage area, a second storage area, and a third storage area; the device further includes an initialization module, and the initialization module is configured to clear the first storage area, the second storage area, and the third storage area of the solid-state memory; reset the first pointer parameter, the second pointer parameter, the record pointer associated with the second storage area, and the record pointer associated with the third storage area recorded for the first storage area; write an empty record in the first storage area; and initialize the resource status parameter in the second storage area.

[0130] In an exemplary embodiment, the device further includes a query module, and the query module is configured to respond to a resource query request; the resource query request includes at least one of a resource change query request and a resource storage query request; and based on the resource query request, determine a query result that matches the resource query request.

[0131] In an exemplary embodiment, the query module is further configured to, in a case where the resource query request includes the resource change query request, based on the resource change query request, determine a resource first change record that matches the resource change query request from the resource status parameters stored in the second storage area; determine the address of the resource first change record; and according to the address, determine the query result corresponding to the resource change query request; in a case where the resource query request includes a resource storage query request, directly determine the resource storage parameter from the memory corresponding to the solid-state memory.

[0132] In an exemplary embodiment, the device further includes a cache module; the cache module is configured to store the resource data to be stored in a cache; wherein, the cache is a buffer area set for the solid-state memory; in the case where the data volume of the resource data in the cache reaches a set quantity threshold, in response to the resource transfer request, determine the area to be stored in the first storage area.

[0133] It should be noted that the above-mentioned various modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to this: the above-mentioned modules are all located in the same processor; or, the above-mentioned various modules are respectively located in different processors in any combination form.

[0134] An embodiment of the present application also provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps in any one of the above method embodiments when running.

[0135] Optionally, in this embodiment, the above computer program can be configured to execute the following steps through a computer program:

[0136] S1, receive a resource transfer request carrying resource data to be stored, wherein the resource transfer request is used to store the resource data to be stored in the first storage area;

[0137] S2, in response to the resource transfer request, determine the area to be stored in the first storage area; the area to be stored is the area where the resource data to be stored is to be stored in the first storage area;

[0138] S3, in the case where the area to be stored in the first storage area is the same as the set stored area, perform an erasure process on the first storage area; the stored area is the area in the first storage area where resource data has been stored;

[0139] S4, store the resource data to be stored in the first storage area after the erasure process.

[0140] In an exemplary embodiment, the above computer-readable storage medium may include, but is not limited to: various media such as a USB flash drive, a read-only memory (ROM for short), a random access memory (RAM for short), a mobile hard disk, a magnetic disk, or an optical disc that can store a computer program.

[0141] Embodiments of the present application further provide an electronic device, which includes a memory and a processor. A computer program is stored in the memory, and the processor is configured to execute the steps in any of the above method embodiments through the computer program.

[0142] Optionally, in this embodiment, the above processor may be configured to execute the following steps through a computer program:

[0143] S1. Receive a resource transfer request carrying resource data to be stored, where the resource transfer request is used to store the resource data to be stored in the first storage area;

[0144] S2. In response to the resource transfer request, determine the area to be stored in the first storage area; the area to be stored is the area where the resource data to be stored is to be stored in the first storage area;

[0145] S3. When the area to be stored in the first storage area is the same as the set stored area, perform an erasure process on the first storage area; the stored area is the area in the first storage area where resource data has been stored;

[0146] S4. Store the resource data to be stored in the first storage area after the erasure process.

[0147] Specific examples in this embodiment may refer to the examples described in the above embodiments and exemplary embodiments, and will not be elaborated here.

[0148] Embodiments of the present application further provide a computer program product. The above computer program product includes a computer program, and when the computer program is executed by a processor, it implements the steps in any of the above method embodiments.

[0149] Embodiments of the present application further provide another computer program product, including a non-volatile computer-readable storage medium. The non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements the steps in any of the above method embodiments.

[0150] Embodiments of the present application further provide a computer program, which includes computer instructions. The computer instructions are stored in a computer-readable storage medium; a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the steps in any of the above method embodiments.

[0151] Obviously, those skilled in the art should understand that the above-mentioned modules or steps of the present application can be implemented by a general-purpose computing device. They can be concentrated on a single computing device or distributed on a network composed of multiple computing devices. They can be implemented by program codes executable by the computing device. Thus, they can be stored in a storage device and executed by the computing device. And in some cases, the steps shown or described can be executed in a sequence different from that here, or they can be separately fabricated into individual integrated circuit modules, or multiple modules or steps among them can be fabricated into a single integrated circuit module for implementation. In this way, the present application is not limited to any specific combination of hardware and software.

[0152] The above are only the preferred embodiments of the present application and are not used to limit the present application. For those skilled in the art, the present application can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the principle of the present application shall be included within the protection scope of the present application.

Claims

1. A method for processing resource data, characterized in that Applied to a solid-state memory, in which only a first storage area for storing resource data is provided, the method includes: Receiving a resource transfer request carrying the resource data to be stored, where the resource transfer request is used to store the resource data to be stored in the first storage area; Responding to the resource transfer request, determining the area to be stored in the first storage area; the area to be stored is the area where the resource data to be stored is to be stored into the first storage area; When the area to be stored in the first storage area is the same as the set stored area, performing an erasure process on the first storage area; the stored area is the area in the first storage area where resource data has been stored; Storing the resource data to be stored in the first storage area after the erasure process.

2. The method according to claim 1, wherein The area to be stored is determined by a first pointer parameter recorded for the first storage area; the stored area is determined by a second pointer parameter recorded for the first storage area; the first pointer parameter is used to record the storage location where the resource data to be stored is to be stored into the first storage area; The second pointer parameter is used to record the storage location of the oldest resource data among the resource data already stored in the first storage area; The performing an erasure process on the first storage area when the area to be stored in the first storage area is the same as the set stored area includes: Performing an erasure on the first storage area when the first pointer parameter is equal to the second pointer parameter.

3. The method according to claim 1, characterized in that In the solid-state memory, a second storage area is further provided for storing at least resource status parameters associated with the resource data stored in the first storage area; The performing an erasure process on the first storage area includes: Determining the data to be erased in the first storage area; Updating the resource status parameters in the second storage area according to the data to be erased, and writing the updated resource status parameters into the second storage area; When writing the updated resource status parameters into the second storage area, performing an erasure process on the first storage area based on the determined data to be erased.

4. The method according to claim 3, wherein After writing the updated resource status parameters into the second storage area, it further includes: Updating the record pointer associated with the second storage area; When the record pointer associated with the second storage area reaches a preset first record pointer threshold, performing an erasure process on the second storage area.

5. The method according to claim 4, wherein Before performing an erasure process on the second storage area, the method further includes: Determining the storage capacity of the second storage area and the single-data length of the second storage area; the single-data length is the maximum data length set for one-time writing into the second storage area; Determining the first record pointer threshold based on the quotient of the storage capacity and the single-data length.

6. The method according to claim 1, characterized in that, The method further includes: When the area to be stored in the first storage area is different from the set stored area, directly writing the resource data to be stored into the area to be stored in the first storage area.

7. The method according to claim 1, characterized in that, A third storage area for storing the first pointer parameter and the second pointer parameter is further provided in the solid-state memory; the method further includes: Obtaining a power-down instruction; wherein, the power-down instruction is an instruction generated when the solid-state memory enters a stop working state; Based on the power-down instruction, determining the storage location of the resource data in the first storage area, and updating the first pointer parameter and the second pointer parameter in the third storage area according to the storage location.

8. The method according to claim 7, wherein After updating the first pointer parameter and the second pointer parameter in the third storage area, it further includes: Updating the record pointer associated with the third storage area; When the record pointer associated with the third storage area reaches a preset second record pointer threshold, performing an erasure process on the third storage area.

9. The method according to claim 1, characterized in that, The solid-state memory includes a first storage area, a second storage area, and a third storage area; before receiving a resource transfer request carrying resource data to be stored, it further includes at least one of the following: Performing a clearing process on the first storage area, the second storage area, and the third storage area of the solid-state memory; Resetting the first pointer parameter, the second pointer parameter recorded for the first storage area, the record pointer associated with the second storage area, and the record pointer associated with the third storage area; Writing an empty record in the first storage area; Initializing the resource status parameter in the second storage area.

10. The method according to claim 1, characterized in that The method further includes: Responding to a resource query request; the resource query request includes at least one of a resource change query request and a resource storage query request; Based on the resource query request, determining a query result that matches the resource query request.

11. The method according to claim 10, wherein The determining, based on the resource query request, a query result that matches the resource query request includes: When the resource query request includes the resource change query request, based on the resource change query request, determining a resource first change record that matches the resource change query request from the resource status parameters stored in the second storage area; Determining the address of the resource first change record; According to the address, determining the query result corresponding to the resource change query request; When the resource query request includes a resource storage query request, directly determining resource storage parameters from the memory corresponding to the solid-state memory.

12. The method according to claim 1, wherein Before responding to the resource transfer request and determining the storage area to be stored in the first storage area, it further includes: Storing the resource data to be stored in a cache; wherein, the cache is a buffer area set for the solid-state memory; When it is determined that the data volume of the resource data in the cache reaches a set quantity threshold, in response to the resource transfer request, determining the storage area to be stored in the first storage area.

13. A processing device for resource data, which is applied to a solid-state memory, and only one first storage area for storing resource data is provided in the solid-state memory, and is characterized in that It includes: A receiving module, configured to receive a resource transfer request carrying resource data to be stored, where the resource transfer request is used to store the resource data to be stored into the first storage area; A determining module, configured to determine a storage area to be stored in the first storage area in response to the resource transfer request; the storage area to be stored is the area where the resource data to be stored is to be stored into the first storage area; An erasing module, configured to perform an erasing process on the first storage area when the storage area to be stored in the first storage area is the same as a set stored area; the stored area is the area in the first storage area where resource data has been stored; A storing module, configured to store the resource data to be stored into the first storage area after the erasing process.

14. A computer-readable storage medium, characterized in that a computer program is stored in the computer-readable storage medium, wherein when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 12 are implemented.

15. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that when the processor executes the computer program, the steps of the method according to any one of claims 1 to 12 are implemented.

Citation Information

Patent Citations

  • Solid state disk, configuration data management method and device thereof and storage medium

    CN110658995A

  • Resource processing method and device

    CN114647384A