Data operation method and device, electronic equipment and storage medium

By matching data operation requests in the flash media, using the operation buffer area to reduce the number of RPMB reads, the problem of frequent RPMB data readings is solved, and the performance of the flash media is improved.

CN120386485AActive Publication Date: 2025-07-29ARTMEM TECHNOLOGY CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202510304719.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-14
Publication Date
2025-07-29
Estimated Expiration
2045-03-14

AI Technical Summary

Technical Problem

In the prior art, the number of replay protection memory blocks (RPMB) data reads often lead to a degradation of the performance of the flash memory medium.

Method used

By obtaining the data operation request, it is determined that the first target logic block of the historical data of the target cache area is in the RPMB, and according to the operation start position and number matching, the second target logic block is found, the historical data is copied to the first and second operation buffers for data operations, and the current data is copied to the target buffer area as new historical data.

Benefits of technology

Reduces the number of times data is read from RPMB and improves the performance of flash media.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120386485A_ABST
    Figure CN120386485A_ABST
Patent Text Reader

Abstract

The invention provides a data operation method and apparatus, an electronic device and a storage medium. The method comprises the steps of obtaining a data operation request including an operation initial position and an operation quantity of a logic block; determining a first target logic block to which the historical data of the target cache region belongs in the RPMB; the first target logic block is matched according to the operation starting position and the operation number, and when the matching result shows that the data operated this time is not completely matched with the first target logic block, the first target logic block is matched; based on the operation starting position, the operation quantity and the first target logic block, determining a second target logic block corresponding to target data, which is not matched with the first target logic block, in the data operated this time in the RPMB; copying historical data to a first operation cache region and data of a second target logic block to a second operation cache region, and performing data operation through the first operation cache region and the second operation cache region; and copying the current data of the second operation cache region to the target cache region. The embodiment of the invention can improve the performance of the flash memory medium.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of storage products, and particularly to a data operation method, apparatus, electronic device, and storage medium. Background Art

[0002] In the related art, a Replay Protectd Memory Block (RPMB) is a partition set in a flash memory medium Nand Flash. This partition is mainly used to store important user information in a small storage partition that prevents replay attacks and passes user verification.

[0003] Among them, when writing data, it is necessary to first read the old data from the RPMB, then replace the old data, and then write. When reading data, it is necessary to directly read the existing data from the RPMB. It is not difficult to see that when reading and writing data to the RPMB, the more times the RPMB reads data, the lower the performance of the flash memory medium will become. Summary of the Invention

[0004] The main purpose of the embodiments of this application is to propose a data operation method, apparatus, electronic device, and storage medium, aiming to reduce the number of times of reading data from the RPMB to improve the performance of the flash memory medium.

[0005] To achieve the above object, a first aspect of the embodiments of this application proposes a data operation method, including: obtaining a data operation request, where the data operation request includes an operation start position and an operation quantity of a logical block; determining a first target logical block to which historical data stored in a target buffer belongs in a Replay Protect Memory Block (RPMB), where the historical data is the data of the previous operation; matching the first target logical block according to the operation start position and the operation quantity to obtain a matching result; in the case that the matching result indicates that the data operated this time does not completely match the first target logical block, determining a second target logical block based on the operation start position, the operation quantity, and the first target logical block, where the second target logical block is the logical block corresponding to the target data that does not match the first target logical block in the data operated this time in the RPMB; copying the historical data to a first operation buffer and the data of the second target logical block to a second operation buffer, and performing data operations through the first operation buffer and the second operation buffer; copying the current data in the second operation buffer as new historical data to the target buffer.

[0006] In some embodiments, when the data operation is to read data, the data operation performed through the first operation buffer and the second operation buffer includes: Returning a data response to the host that sent the data operation request based on the current data in the first operation buffer and the second operation buffer.

[0007] In some embodiments, when the data operation is to write data, the data operation request further includes data to be written; The data operation performed through the first operation buffer and the second operation buffer includes: Replacing the data in the first operation buffer and the second operation buffer with the data to be written; Writing data based on the current data in the first operation buffer and the second operation buffer.

[0008] In some embodiments, after copying the current data in the second operation buffer as new historical data to the target buffer, the method further includes: Incrementally updating the write count of the RPMB; Performing redundant data writing on the flash medium where the RPMB is set based on the updated write count.

[0009] In some embodiments, after updating the write count of the RPMB, the method further includes: When writing data fails, decrementally updating the current write count; Performing redundant data writing on the flash medium based on the updated write count and discarding the data in the target buffer.

[0010] In some embodiments, when the data operation is to write data, the data operation request further includes data to be written; After obtaining the matching result, the method further includes: When the matching result indicates that the data operated on this time exactly matches the first target logical block, copying the historical data to the first operation buffer; Replacing the data in the first operation buffer with the data to be written; Writing data based on the current data in the first operation buffer; Copying the current data in the first operation buffer as new historical data to the target buffer.

[0011] In some embodiments, the target buffer, the first operation buffer, and the second operation buffer are all set to store data of 32 logical blocks, and both the historical data and the amount of data copied to the second operation buffer are 32 logical blocks.

[0012] To achieve the above object, a second aspect of the embodiments of the present application provides a data processing apparatus, the apparatus includes: A data operation request acquisition module, configured to acquire a data operation request, where the data operation request includes an operation start position and an operation amount of a logical block; A first target logical block determination module, configured to determine a first target logical block to which the historical data stored in the target buffer belongs in a replay protected memory block (RPMB), where the historical data is the data of the previous operation; A matching module, configured to match the first target logical block according to the operation start position and the operation amount to obtain a matching result; A second target logical block determination module, configured to, when the matching result indicates that the data operated this time does not completely match the first target logical block, determine a second target logical block based on the operation start position, the operation amount, and the first target logical block, where the second target logical block is the logical block corresponding to the target data that does not match the first target logical block in the data operated this time in the RPMB; A data operation module, configured to copy the historical data to the first operation buffer and the data of the second target logical block to the second operation buffer, and perform data operations through the first operation buffer and the second operation buffer; A target buffer data update module, configured to copy the current data in the second operation buffer to the target buffer as new historical data.

[0013] To achieve the above object, a third aspect of the embodiments of the present application provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and when the processor executes the computer program, the method described in the first aspect above is implemented.

[0014] To achieve the above object, a fourth aspect of the embodiments of the present application provides a computer-readable storage medium, the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described in the first aspect above is implemented.

[0015] A data operation method, apparatus, electronic device, and storage medium proposed in this application. The method can first obtain a data operation request, where the data operation request includes the operation start position and the operation quantity of a logical block. Then, determine the first target logical block to which the historical data stored in the target buffer belongs in the replay protection memory block (RPMB), where the historical data is the data of the previous operation. Then, match the first target logical block according to the operation start position and the operation quantity to obtain a matching result. When the matching result indicates that the data to be operated this time does not completely match the first target logical block, determine a second target logical block based on the operation start position, the operation quantity, and the first target logical block, where the second target logical block is the logical block corresponding to the target data that does not match the first target logical block in the data to be operated this time in the RPMB. Then, copy the historical data to the first operation buffer and the data of the second target logical block to the second operation buffer, and perform data operations through the first operation buffer and the second operation buffer. Then, copy the current data in the second operation buffer to the target buffer as the new historical data. Since the previous operation data (i.e., historical data) is stored in the target buffer, after receiving a data source operation request, the first target logical block can be matched according to the operation start position and the operation quantity to determine whether there is a completely covering matching relationship between the operation start position and the operation quantity, so as to determine whether it is necessary to read data from the RPMB. When the matching result indicates that the data to be operated this time does not completely match the first target logical block, it means that part of the data to be operated this time involves historical data. Therefore, the historical data can be copied to the first operation buffer, and only the target data that does not match the first target logical block is copied from the second target logical block in the RPMB, so that the historical data does not need to be read from the first target logical block in the RPMB, which helps to reduce the number of data reads, and thus can improve the performance of the flash memory medium. In addition, since after the data operation, the current data in the second operation buffer is copied to the target buffer as the new historical data, if the next data operation involves the current data in the second operation buffer, then the step of reading the current data in the second operation buffer from the RPMB can be reduced during the next data operation, which helps to reduce the number of data reads, and thus can further improve the performance of the flash memory medium. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1 is a flowchart of a data operation method provided by an embodiment of the present application; Figure 2 is a flowchart of a sub-step embodiment of step 150 when the data operation is a write operation; Figure 3 is a flowchart of a data operation method provided by another embodiment of the present application; Figure 4 It is a flowchart of a data operation method provided by another embodiment of the present application; Figure 5 It is a flowchart of a data operation method provided by yet another embodiment of the present application; Figure 6 It is a schematic structural diagram of a data operation device provided by an embodiment of the present application; Figure 7 It is a schematic hardware structure diagram of an electronic device provided by an embodiment of the present application. Detailed implementation manners

[0017] In order to make the objectives, technical solutions and advantages of the present application more clear and understandable, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0018] It should be noted that although functional module division is performed in the device schematic diagram and the logical sequence is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order from the module division in the device or the sequence in the flowchart. Terms such as "first" and "second" in the description, claims and the above-mentioned drawings are used to distinguish similar objects and do not necessarily need to describe a specific order or sequence.

[0019] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the technical field to which the present application belongs. The terms used herein are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application.

[0020] In the related technology of RPMB, when data needs to be written, it is necessary to first read the old data from the RPMB, then replace the old data, and then write it; when data needs to be read, the existing data needs to be directly read from the RPMB. It is not difficult to see that when data reading and writing are performed on the RPMB, the more times the RPMB reads data, the lower the performance of the flash memory medium will become.

[0021] In order to reduce the number of times of reading data from the RPMB to improve the performance of the flash memory medium, the embodiments of the present application provide a data operation method, a data operation device, an electronic device, and a computer-readable storage medium. The method may first obtain a data operation request, where the data operation request includes the operation start position and the operation quantity of a logical block; then, determine a first target logical block to which the historical data stored in the target buffer belongs in the replay protection memory block (RPMB), where the historical data is the data of the previous operation; then, match the first target logical block according to the operation start position and the operation quantity to obtain a matching result; in the case where the matching result indicates that the data to be operated this time does not completely match the first target logical block, determine a second target logical block based on the operation start position, the operation quantity, and the first target logical block, where the second target logical block is the logical block corresponding to the target data that does not match the first target logical block in the data to be operated this time in the RPMB; then, copy the historical data to the first operation buffer and the data of the second target logical block to the second operation buffer, and perform data operations through the first operation buffer and the second operation buffer; then, copy the current data in the second operation buffer to the target buffer as new historical data. Since the previous operation data (i.e., historical data) is stored in the target buffer, after receiving a data source operation request, it is possible to match the first target logical block according to the operation start position and the operation quantity to determine whether there is a completely covering matching relationship between the operation start position and the operation quantity, so as to determine whether it is necessary to read data from the RPMB. When the matching result indicates that the data to be operated this time does not completely match the first target logical block, it indicates that a part of the data to be operated this time involves historical data. Therefore, the historical data can be copied to the first operation buffer, and only the target data that does not match the first target logical block is copied from the second target logical block in the RPMB, so that the historical data does not need to be read from the first target logical block in the RPMB, which helps to reduce the number of data reads, and thus can improve the performance of the flash memory medium. In addition, since after the data operation, the current data in the second operation buffer is copied to the target buffer as new historical data, if the next data operation involves the current data in the second operation buffer, then the step of reading the current data in the second operation buffer from the RPMB can be reduced during the next data operation, which helps to reduce the number of data reads, and thus can further improve the performance of the flash memory medium.

[0022] See Figure 1 , Figure 1 shows the flow of the data operation method provided by an embodiment of the present application. In the embodiment of the present application, the information processing method may include steps 110 to 160.

[0023] Step 110: Obtain a data operation request, where the data operation request includes the starting position and the number of operations of a logical block. Step 120: Determine the first target logical block to which the historical data stored in the target buffer belongs in the Replay Protected Memory Block (RPMB), where the historical data is the data of the previous operation. Step 130: Match the first target logical block according to the starting position and the number of operations to obtain a matching result. Step 140: In the case where the matching result indicates that the data operated this time does not completely match the first target logical block, determine a second target logical block based on the starting position, the number of operations, and the first target logical block, where the second target logical block is the logical block corresponding to the target data that does not match the first target logical block in the data operated this time in the RPMB. Step 150: Copy the historical data to the first operation buffer and the data of the second target logical block to the second operation buffer, and perform data operations through the first operation buffer and the second operation buffer. Step 160: Copy the data corresponding to the second target logical block in the current data of the second operation buffer to the target buffer as the new historical data.

[0024] In one embodiment, the data operation request refers to a request for operating on all the data in the logical block to which the data to be operated in the Replay Protected Memory Block (RPMB) belongs, with the logical block as the operation unit. Wherein, the data operation mentioned in the data operation request can be one of reading data or writing data, and specific limitations are not made here. In addition, the data operation request can be issued by a host (Host, specifically a terminal, etc.). In addition, the data size stored in the logical block can be a data frame (Frame, that is, 256 Byte).

[0025] Exemplarily, assume that the data to be operated according to the data operation request is A, and the data A is stored in the logical block A32 in the RPMB. Then, when the data A is operated, the data in the entire logical block A32 will be operated together.

[0026] In one embodiment, the starting position of the logical block operation refers to the position of the first logical block for operating on the RPMB during the data operation process. Wherein, the starting position of the logical block operation can specifically be the absolute address of the logical block, or the relative offset address of the logical block, etc., and specific limitations are not made here.

[0027] In one embodiment, the number of operations of a logical block refers to the number of operations of logical blocks other than the logical block where the operation starts. For example, assuming that the starting position of the logical block operation is M and the number of operations is N, then the finally operated logical blocks are from M to M + N.

[0028] In one embodiment, the target buffer refers to a buffer for storing historical data. Herein, the target buffer can be any idle buffer in the memory or a specifically designated buffer, which is not specifically limited herein. Additionally, the size of the target buffer can be determined according to multiples of the maximum number of data frames allowed by a single data operation command of the storage device (i.e., an instruction for indicating data reading or writing). Exemplarily, for example, the size of 16 data frames (2K), the size of 32 data frames (4K), etc., which is not specifically limited herein.

[0029] In one embodiment, when the historical data is data of the size of one logical block, then the target buffer stores the data of the operated logical block. When the historical data is data of the size of multiple logical blocks, based on the storage capacity of the target buffer, data storage starts from the data of the logical block that is the last in sorting among the historical data. Exemplarily, assuming that the target buffer can store data of 2 logical blocks, and the logical blocks to which the operated data belongs involve M to M + N, then the historical data stored in the target buffer is the data of the two logical blocks M + N - 1 and M + N; Another example, assuming that the target buffer can store data of 2 logical blocks, and the logical block to which the operated data belongs involves M, then the historical data stored in the target buffer is the data of the logical block M.

[0030] In one embodiment, when there is historical data stored in the target buffer and no data operation on the RPMB is performed within the preset operation waiting duration, then the historical data in the target buffer can be released to reduce the ineffective occupation of buffer resources, which is beneficial to improving the utilization rate of buffer resources.

[0031] In one embodiment, the first target logical block can be one or more, and the second target logical block can be one or more, which is not specifically limited herein.

[0032] In one embodiment, before the process of determining the first target logical block to which the historical data stored in the target buffer belongs in the replay protected memory block RPMB, specifically, it can first be confirmed whether the storage device supports data operation on the RPMB according to protocols such as the storage protocol and the operation protocol. If it is supported, subsequent steps including step 120 are performed; if it is not supported, the process ends, step 120 is not entered, and a response indicating operation failure is returned to the host Host.

[0033] In one embodiment, matching the first target logical block according to the operation start position and the number of operations to obtain a matching result means judging whether the logical block involved in the data operated this time can cover the first target logical block according to the operation start position and the number of operations of the logical block, and taking the judgment result as the matching result operation. It should be noted that this judgment process is actually indirectly corresponding to the data. Specifically, the operation start position and the number of operations of the logical block represent the data operated this time, and the first target logical block represents the historical data. Based on this, the matching result can represent whether the data operated this time can cover the historical data.

[0034] In one embodiment, before the process of matching the first target logical block according to the operation start position and the number of operations to obtain a matching result, specifically, the Message Authentication Code (MAC) can be calculated according to the operation start position and the number of operations to obtain the MAC to be verified. Then, the verified MAC sent by the host Host is obtained. Then, the MAC to be verified is compared with the verified MAC. When the MAC to be verified is different from the verified MAC, the data operation is ended, and a response indicating operation failure is returned to the host Host; when the MAC to be verified is the same as the verified MAC, data matching is performed.

[0035] In one embodiment, incomplete matching means a situation where the logical blocks involved in some of the data operated this time are the same as the target logical block, and the logical blocks involved in the other part of the data are different from the target logical block. For example, assume that the target buffer stores the data of logical blocks A32 and A33 in the RPMB (i.e., the so-called historical data), and the logical blocks involved in the data to be operated are A31 to A33. Then, among the data to be operated, the data involving logical blocks A32 and A33 matches the historical data, and the data involving logical block A31 does not match the historical data. This is incomplete matching.

[0036] In one embodiment, relative to an incomplete match, the match result may also indicate that the data being operated on this time is completely matched with the historical data. The complete match includes one of the following situations: being completely matched with all first target logical blocks; being completely matched with some logical blocks in the first target logical blocks. Among them, being completely matched with the first target logical blocks means that the logical blocks involved in the data being operated on this time are exactly the same as the target logical blocks to which the historical data belongs. For example, assuming that the target buffer stores the data of logical blocks A32 and A33 in the RPMB, and the logical blocks involved in the data to be operated on are from A32 to A33, then the data being operated on this time is completely matched with the first target logical blocks. In addition, being completely matched with some logical blocks in the first target logical blocks means that the logical blocks involved in the data being operated on this time are exactly the same as the target logical blocks to which some of the historical data belongs. For example, assuming that the target buffer stores the data of logical blocks A31 to A33 in the RPMB, and the logical blocks involved in the data to be operated on are from A32 to A33, then the data to be operated on is completely matched with some of the first target logical blocks in the first target logical blocks.

[0037] In one embodiment, relative to an incomplete match, the match result may also indicate that the data being operated on this time is completely unmatched with the first target logical blocks. The complete mismatch means that the logical blocks involved in the data being operated on this time are completely different from the target logical blocks to which the historical data belongs, and all the logical blocks involved in the data being operated on this time belong to the logical blocks outside the target logical blocks to which the historical data belongs. For example, assuming that the historical data is the data of logical blocks A32 to A33 in the RPMB, and the logical blocks involved in the data to be operated on are A30 to A31, then the data being operated on this time is completely unmatched with the first target logical blocks.

[0038] In one embodiment, when the data being operated on this time is completely unmatched with the first target logical blocks, regardless of whether the data operation is reading data or writing data, it is necessary to directly copy the data from the corresponding logical blocks of the RPMB to the first operation buffer according to the operation start position and the operation quantity. For the case where the data operation is reading data, the data in the first operation buffer is used to return a data response to the host. For the case where the data operation is writing data, the data in the first operation buffer is directly replaced by the data to be written, and then the data writing is performed through the current data in the first operation buffer. After that, regardless of whether the data operation is reading data or writing data, the current data in the first operation buffer is written into the target buffer as the new historical data.

[0039] In one embodiment, determining the second target logical block based on the operation start position, the number of operations, and the first target logical block means first determining the logical block corresponding to the data operated on this time based on the operation start position and the number of operations. Then, among the logical blocks corresponding to the data operated on this time, the logical blocks other than the first target logical block are determined as the operations of the second logical block.

[0040] Exemplarily, assume that the operation start position is A31, the number of operations is 3, and the first target logical block is from A31 to A32. Then, the logical blocks involved in the data operation this time are from A31 to A34. Through the logical blocks A31 to A34 and the target logical blocks A31 and A32, the logical blocks A33 and A34 can be determined as the second target logical blocks.

[0041] In one embodiment, the second target logical block is the logical block corresponding to the target data that does not match the first target logical block in the data operated on this time in the RPMB, which means the situation where the data operation involved in the target data that does not match the first target logical block in the data operated on this time involves logical blocks in the RPMB. Continuing with the example in the previous paragraph, the data involved in operating on the target logical blocks A31 and A32 in the data operated on this time corresponds to historical data, and the target data that does not match the first target logical block corresponds to the data of the second target logical blocks A33 and A34.

[0042] In one embodiment, copying the historical data to the first operation buffer and the data of the second target logical block to the second operation buffer means the operation of copying the historical data in the target buffer to the first operation buffer and copying the data of the second target logical block in the RPMB to the second operation buffer. Among them, the order of the two operations of "copying the historical data to the first operation buffer" and "copying the data of the second target logical block to the second operation buffer" can be changed, and no specific limitation is made here.

[0043] In one embodiment, when the data operation is a data read operation, performing the data operation through the first operation buffer and the second operation buffer means performing a data return response operation to the host Host that sends the data operation request through the current data in the first operation buffer and the second operation buffer. When the data operation is a data read operation, performing a data read response through the current data in the first operation buffer and the second operation buffer. In this way, in the response process, there is no need to read the historical data, but only the target data needs to be read in the RPMB, so that the repeated reading of the historical data operated on in the previous operation can be reduced, and further the reading frequency of the RPMB can be reduced, which helps to improve the reading performance.

[0044] In one embodiment, when the data operation is to write data, the data operation is performed through the first operation buffer and the second operation buffer, which means that the corresponding data in the first operation buffer and the second operation buffer is first replaced according to the data to be written, and then the data write operation is performed according to the current data in the first operation buffer and the second operation buffer.

[0045] In the related technology of RPMB, writing data needs to follow the mechanism of first reading and then writing. This makes it necessary to read data from the corresponding logical block when writing data, replace the read data with the data to be written, and then perform the write. When the data operation is to write data, the data write response is performed through the current data in the first operation buffer and the second operation buffer. In this way, there is no need to read historical data during the response process, but only the target data needs to be read in the RPMB, so that the repeated reading of the historical data operated in the previous operation can be reduced, and further the reading frequency of the RPMB can be reduced, which helps to improve the write performance.

[0046] It should be noted that during the data operation process, the operation order of the first operation buffer and the second operation buffer is limited, and the data in the first operation buffer is operated first and then the data in the second operation buffer is operated.

[0047] In one embodiment, during the process of performing data operation through the first operation buffer and the second operation buffer, specifically, it can be first determined whether the data in the first operation buffer and the second operation buffer conforms to the position sorting of the logical block according to the operation start position, the operation quantity, and the target logical block. If it conforms, the data operation is performed. If it does not conform, the data in the first operation buffer and the second operation buffer is swapped based on the position sorting of the logical block, and then the data operation is performed.

[0048] Exemplarily, assume that the historical data is the data of logical blocks A32 and A33 in the RPMB, and the logical blocks involved in the data operated this time are A31 to A34. Then, the historical data is first copied to the first operation buffer, and the data of logical blocks A31 and A34 involved (that is, the data not matched with the historical data in logical blocks A32 and A33) is copied to the second operation buffer. At this time, the data in the first operation buffer and the second operation buffer does not conform to the position sorting of the logical block. Therefore, the data corresponding to logical block A33 in the historical data can be swapped to the second operation buffer, and then the data involved in logical block A31 is swapped to the first operation buffer. At this time, the data in the first operation buffer is the data involved in logical block A31 and the data corresponding to logical block A32 in the historical data, and the data in the second operation buffer is the data corresponding to logical block A33 in the historical data and the data involved in logical block A34.

[0049] Exemplarily, assume that the historical data are the data of logical blocks A32 and A33 in RPMB, and the logical blocks involved in the data being operated this time are A31 to A33. Then, the historical data are first copied to the first operation buffer. For the data of logical block A31 involved, at this time, the data in the first operation buffer and the second operation buffer conform to the position sorting of the logical blocks. Therefore, there is no need to perform data swapping in the operation buffer based on the position sorting of the logical blocks for the data in the first operation buffer and the second operation buffer.

[0050] In one embodiment, when the data operation is to read data, during the process of data operation through the first operation buffer and the second operation buffer, specifically, no data replacement operation needs to be performed in the first operation buffer and the second operation buffer, and only the current data in the first operation buffer and the second operation buffer are used to return a data response to the host Host.

[0051] In one embodiment, when the data operation is to write data, during the process of data operation through the first operation buffer and the second operation buffer, specifically, the data to be written this time can be used to replace the corresponding data in the first operation buffer and the second operation buffer first, and then, the current data in the first operation buffer and the second operation buffer are written into the first target logical block and the second target logical block.

[0052] In one embodiment, copying the data corresponding to the second target logical block in the current data of the second operation buffer to the target buffer as the new historical data means first releasing the historical data currently stored in the target buffer, and then copying all the current data in the second operation buffer to the target buffer as the new historical data.

[0053] Exemplarily, assume that the historical data are the data of logical blocks A32 and A33 (the two logical blocks are the so-called first target logical blocks) in RPMB, and the data of logical blocks A33 and A34 are stored in the second operation buffer. Then, logical block A34 is the second target logical block. In the case where the data operation is to read data, the data corresponding to logical block A34 in the second operation buffer is the data originally stored in the RPMB partition of logical block A34 (i.e., the target data). Based on this, the target buffer will store the data of logical blocks A33 and A34.

[0054] Exemplarily, assume that the historical data is the data of logical blocks A32 and A33 in the RPMB (the two logical blocks are the so-called first target logical blocks), and the data of logical blocks A33 and A34 is stored in the second operation buffer. Then, logical block A34 is the second target logical block. In the case where the data operation is writing data, the data corresponding to logical block A34 in the second buffer is the data after replacement of the data originally stored in the RPMB partition of logical block A34 (i.e., the target data) by the writing data. The target buffer will store the data currently written for logical block A34 and the data of logical block A33.

[0055] See Figure 2 , Figure 2 shows a flowchart of a sub-step embodiment of step 150 in the case where the data operation is writing data. In one embodiment, the data operation request further includes the data to be written, and step 150 may include the following steps.

[0056] Step 210: Perform data replacement on the data in the first operation buffer and the second operation buffer based on the data to be written; Step 220: Perform data writing through the current data in the first operation buffer and the second operation buffer.

[0057] In one embodiment, performing data replacement on the data in the first operation buffer and the second operation buffer based on the data to be written means first determining the data corresponding to the data to be written in the data of the first operation buffer and the second operation buffer, and then replacing the corresponding data with the data to be written to obtain an operation of combined data formed by the original data in the RPMB and the data to be written.

[0058] Exemplarily, assume that the first target logical blocks are A31 and A32, the second target logical blocks are A33 and A34, and the data to be written A, B, and C with the logical block size respectively correspond to writing to logical block A32, logical block A33, and logical block A34. Then, data A will replace the data of the first target logical block A32 in the first operation buffer, data B will replace the data of the second target logical block A33 in the second operation buffer, and data C will replace the data of the second target logical block A34 in the second operation buffer. Finally, the data in the first operation buffer is A31 and A, and the data in the second operation buffer is B and C.

[0059] When the data operation is to write data, by replacing the data in the first operation buffer and the second operation buffer based on the data to be written, in this way, the data to be written can be replaced in data of multiple logical block sizes, and then, the data can be written through the current data in the first operation buffer and the second operation buffer, so that the data to be written can be written by notifying the data write amount, and further, the read and write performance of the RPMB can be improved.

[0060] See Figure 3 , Figure 3 shows the flow of the data operation method provided by another embodiment of the present application. In one embodiment, after step 160, the data operation method may further include the following steps.

[0061] Step 310: Incrementally update the write count of the RPMB; Step 320: Write redundant data to the flash memory medium with the RPMB based on the updated write count.

[0062] In one embodiment, incrementally updating the write count of the RPMB means performing an increment operation of adding one based on the current write count of the RPMB. For example, in the previous operation, the write count of the RPMB was X. When the data operation is to write data, after writing data through the first operation buffer and the second operation buffer, the write count of the RPMB is updated to X + 1.

[0063] In one embodiment, writing redundant data to the flash memory medium with the RPMB based on the updated write count means writing the updated write count as redundant data of the RPMB partition data to the Nand Flash of the flash memory medium.

[0064] When the operation of writing data to the RPMB partition is successful, the updated write count needs to wait for the time of writing data to the flash memory medium twice. The first time is to wait for the RPMB data to be written to the flash memory medium, and the second time is to wait for the updated write count to be written to the flash memory medium. By writing the updated write count as redundant data, in this way, only the time for the RPMB data to be written to the flash memory medium needs to be waited, so that the updated write count does not need to wait for the time of writing data twice, thereby improving the write efficiency; and, it can reduce the updated write count to be written to the flash memory medium separately by the page write method, improving the data write performance. In addition, since the updated write count is written as redundant data, when an abnormal power failure occurs, the latest write count can also be recovered by the device reconstruction method, improving the safety redundancy of recording the write count.

[0065] See Figure 4 , Figure 4The flowchart of a data operation method provided by another embodiment of the present application is shown. In one embodiment, after step 310, the data operation method may further include the following steps.

[0066] Step 410: After the data writing fails, decrement and update the current write count. Step 420: Write redundant data to the flash medium based on the updated write count, and discard the data in the target buffer.

[0067] In one embodiment, after the data writing fails, decrementing and updating the current write count means restoring the updated write count to the count corresponding to the previous write operation by decrementing it by one. For example, in the previous operation, the write count of the RPMB was X. When the data operation is data writing, after writing data through the first operation buffer and the second operation buffer, the write count of the RPMB is updated to X + 1. However, this data writing fails. At this time, the write count of the RPMB is updated back to X.

[0068] When the data writing fails, the write count can be restored to the original write count by decrementing and updating, and the currently restored write count is written as redundant data to the flash medium. In this way, the correctness of the write count can be maintained. Since the data writing fails, the data in the first operation buffer and the second operation buffer no longer belongs to the "historical data" relative to the data of the next operation. By discarding the data in the target buffer, the situation of using the incorrect historical data generated by the failure of this data operation for the next data operation can be reduced, thereby improving the accuracy of the next data operation.

[0069] See Figure 5 , Figure 5 The flowchart of a data operation method provided by another embodiment of the present application is shown. In one embodiment, when the data operation is data writing, the data operation request may further include the data to be written. After step 130, the data operation method may further include the following steps.

[0070] Step 510: When the matching result indicates that the data operated on this time exactly matches the first target logical block, copy the historical data to the first operation buffer. Step 520: Replace the data in the first operation buffer based on the data to be written. Step 530: Write data through the current data in the first operation buffer. Step 540: Copy the current data in the first operation buffer to the target buffer as the new historical data.

[0071] In one embodiment, when the complete match between the data being operated on this time and the first target logical block is a complete match with all the first target logical blocks, performing data replacement on the data in the first operation buffer based on the data to be written refers to the operation of replacing all the historical data in the first operation buffer with the data to be written.

[0072] In one embodiment, when the complete match between the data being operated on this time and the first target logical block is a complete match with some of the logical blocks in the first target logical block, performing data replacement on the data in the first operation buffer based on the data to be written refers to first determining the first target logical blocks in all the first target logical blocks that correspond to the data to be written, and then, in the historical data of the first operation buffer, replacing the data in the first target logical blocks that correspond to the data to be written with the data to be written.

[0073] In one embodiment, when the complete match between the data being operated on this time and the first target logical block is a complete match with all the first target logical blocks, the current data in the first operation buffer refers to the data to be written.

[0074] In one embodiment, when the complete match between the data being operated on this time and the first target logical block is a complete match with some of the logical blocks in the first target logical block, the current data in the first operation buffer refers to the combined data composed of the data in the historical data that has not been replaced by the data to be written and the data to be written.

[0075] When the data operation is to write data, by performing data replacement on the first operation buffer based on the data to be written, in this way, the data to be written can be replaced in data of multiple logical block sizes, and then, the data can be written through the current data in the first operation buffer, so that the data to be written can be written by notifying the data write amount, and thus the read and write performance of the RPMB can be improved.

[0076] For example, when the complete match between the data being operated on this time and some of the logical blocks in the first target logical block, assuming the first target logical blocks are A31 to A34, and the data to be written A and B with the write logical block size respectively correspond to the logical block A33 and the logical block A34 to be written, then the data corresponding to the logical block A33 and the logical block A34 in the first operation buffer will be correspondingly replaced with the data A and the data B. Then, at this time, the data written to the RPMB through the first operation buffer becomes the original data of the logical block A31, the original data of the logical block A32, the data A, and the data B.

[0077] For example, in the case where the data being operated on this time is an exact match with all of the first target logical blocks, assuming the first target logical blocks are A31 to A32, and the data to be written, A and B, with the write logical block size respectively correspond to the logical block A31 and the logical block A32 to be written, then the data corresponding to the logical block A31 and the logical block A32 in the first operation buffer will be correspondingly replaced with the data A and the data B. Then, at this time, the data written to the RPMB through the first operation buffer becomes the data A and the data B.

[0078] In one embodiment, when the data operation is a data read operation, after step 130, the data operation method may further include the following steps.

[0079] Step 610: When the matching result indicates that the data being operated on this time is an exact match with the first target logical blocks, copy the historical data to the first operation buffer; Step 620: Use the current data in the first operation buffer to return a data response to the host that sent the data operation request.

[0080] When the data operation is a data read operation, a data read response is made using the current data in the first operation buffer and the second operation buffer. Whether the data being operated on this time is an exact match with all of the first target logical blocks or an exact match with some of the logical blocks in the first target logical blocks, historical data does not need to be read during the response process. Thus, the situation of repeatedly reading the historical data that was operated on last time can be reduced, and furthermore, the read frequency of the RPMB can be reduced, which helps to improve the read performance.

[0081] For example, in the case where the data being operated on this time is an exact match with some of the logical blocks in the first target logical blocks, assuming the first target logical blocks are A31 to A34, and the data of the logical blocks A33 and A34 are to be read, then the data of the logical blocks A33 and A34 are returned to the host through the first operation buffer.

[0082] For example, in the case where the data being operated on this time is an exact match with all of the first target logical blocks, assuming the first target logical blocks are A31 to A32, and the data of the logical blocks A31 and A32 are to be read, then all of the historical data is returned to the host through the first operation buffer.

[0083] In one embodiment, the target buffer, the first operation buffer, and the second operation buffer are all set to store data of 32 logical blocks (i.e., a storage size of 4K). Both the historical data and the amount of data copied to the second operation buffer are 32 logical blocks. Since copying data, reading data, and writing data are all performed in units of 32 logical blocks, the historical data and the data copied to the second operation buffer can both meet the requirement of 4K alignment. In this way, regardless of whether the data operated on this time is completely matched, the specific data operations of reading data or writing data can operate on a read / write data volume of more than 4K, thereby improving the performance of reading and writing data from the RPMB partition of the flash memory medium.

[0084] In one embodiment, when the data operation is data writing, after step 120, specifically, 4K alignment determination can be performed according to the operation start position and the operation quantity. When both the operation start position and the operation quantity meet the 4K alignment, the historical data is copied to the first operation buffer, and then the data to be written replaces all the data in the first operation buffer. Then, data operations are performed through the first operation buffer, and then the current data in the first operation buffer is copied to the target buffer as the new historical data. When at least one of the operation start position and the operation quantity does not meet the 4K alignment, steps 130 to 160 are entered.

[0085] In one embodiment, during the process of performing 4K alignment determination according to the operation start position and the operation quantity, specifically, it can be respectively determined whether the remainder of the operation start position and the number of logical blocks divided by 32 is 0. If both are 0, then the 4K alignment is met. If the remainder result of one of them is not 0, then the 4K alignment is not met.

[0086] See Figure 6 , the embodiment of the present application further provides a data operation device, which can implement the above method. The data operation device 700 includes: A data operation request acquisition module 710, which can be used to acquire a data operation request, where the data operation request includes the operation start position and the operation quantity of a logical block; A first target logical block determination module 720, which can be used to determine the first target logical block to which the historical data stored in the target buffer belongs in the replay protection memory block (RPMB), where the historical data is the data of the previous operation; A matching module 730, which can be used to match the first target logical block according to the operation start position and the operation quantity to obtain a matching result; The second target logical block determination module 740 can be used to determine a second target logical block based on the operation start position, the operation quantity, and the first target logical block when the matching result indicates that the data being operated on this time does not completely match the first target logical block. Here, the second target logical block is the logical block corresponding to the target data that does not match the first target logical block in the data being operated on this time in the RPMB; The data operation module 750 can be used to copy historical data to the first operation buffer and the data of the second target logical block to the second operation buffer, and perform data operations through the first operation buffer and the second operation buffer; The target buffer data update module 760 can be used to copy the current data in the second operation buffer to the target buffer as new historical data.

[0087] The specific implementation manner of this data operation device is basically the same as the specific embodiments of the above data operation method, and will not be elaborated here.

[0088] An embodiment of this application also provides an electronic device. The electronic device includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, the above data operation method is implemented. This electronic device can be any intelligent terminal including a tablet computer, an in-vehicle computer, etc.

[0089] Please refer to Figure 7 , Figure 7 which schematically shows the hardware structure of an electronic device in another embodiment. The electronic device 800 includes: A processor 801, which can be implemented in a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, etc., and is used to execute relevant programs to implement the technical solutions provided by the embodiments of this application; A memory 802, which can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM), etc. The memory 802 can store an operating system and other application programs. When implementing the technical solutions provided by the embodiments of this specification through software or firmware, the relevant program codes are stored in the memory 802, and the processor 801 is used to call and execute the data operation method of the embodiments of this application; An input / output interface 803, which is used to implement information input and output; A communication interface 804 for implementing communication interaction between this device and other devices, which can achieve communication through wired means (such as USB, network cable, etc.) or through wireless means (such as mobile network, WIFI, Bluetooth, etc.); A bus 805 for transmitting information between various components of the device (such as a processor 801, a memory 802, an input / output interface 803, and a communication interface 804); Among them, the processor 801, the memory 802, the input / output interface 803, and the communication interface 804 are communicatively connected to each other inside the device through the bus 805.

[0090] The embodiment of the present application also provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the above data operation method is implemented.

[0091] As a non-transitory computer-readable storage medium, the memory can be used to store non-transitory software programs and non-transitory computer-executable programs. In addition, the memory can include high-speed random access memory, and can also include non-transitory memory, such as at least one magnetic disk storage device, a flash memory device, or other non-transitory solid-state storage devices. In some embodiments, the memory can include memories remotely provided with respect to the processor, and these remote memories can be connected to the processor through a network. Examples of the above network include but are not limited to the Internet, an enterprise intranet, a local area network, a mobile communication network, and combinations thereof.

[0092] The embodiments described in the embodiments of the present application are for more clearly illustrating the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided by the embodiments of the present application. Those skilled in the art know that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of the present application are equally applicable to similar technical problems.

[0093] Those skilled in the art can understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than those shown in the figures, or combine certain steps, or different steps.

[0094] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separated, that is, they may be located in one place, or may be distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0095] Those of ordinary skill in the art will understand that all or some of the steps in the methods disclosed above, and the functional modules / units in systems and devices, can be implemented as software, firmware, hardware, or a suitable combination thereof.

[0096] As used in the specification of this application and the above-mentioned drawings, the terms "first", "second", "third", "fourth", etc. (if any) are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data may be interchanged under appropriate circumstances so that the embodiments of this application described herein can be implemented in an order different from those illustrated or described herein. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that comprises a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products, or devices.

[0097] It should be understood that in this application, "at least one (item)" means one or more, and "a plurality" means two or more. "And / or" is used to describe the association relationship of associated objects and indicates that three relationships may exist. For example, "A and / or B" may mean: only A exists, only B exists, and both A and B exist simultaneously. Here, A and B may be singular or plural. The character " / " generally indicates that the associated objects before and after are in an "or" relationship. "At least one (one)" or a similar expression thereof refers to any combination of these items, including any combination of single items (one) or plural items (ones). For example, at least one (one) of a, b, or c may mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c may be single or multiple.

[0098] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the above-mentioned unit division is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling, direct coupling, or communication connection to each other may be through some interfaces. The indirect coupling or communication connection of devices or units may be in electrical, mechanical, or other forms.

[0099] The units described above as separate components may or may not be physically separated. The components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0100] In addition, the functional units in various embodiments of the present application may be integrated in a processing unit, or each unit may exist physically alone, or two or more units may be integrated in one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.

[0101] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes multiple instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods in various embodiments of the present application. The aforementioned storage medium includes: various media that can store programs such as USB flash drives, mobile hard disks, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical discs.

[0102] The preferred embodiments of the embodiments of the present application have been described above with reference to the accompanying drawings, and thus do not limit the scope of the rights of the embodiments of the present application. Any modifications, equivalent replacements, and improvements made by those skilled in the art without departing from the scope and essence of the embodiments of the present application shall be within the scope of the rights of the embodiments of the present application.

Claims

1. A data operation method, characterized in that, Including: Obtaining a data operation request, where the data operation request includes an operation start position and an operation quantity of a logical block; Determining a first target logical block to which historical data stored in a target buffer belongs in a replay protected memory block (RPMB), where the historical data is data of a previous operation; Matching the first target logical block according to the operation start position and the operation quantity to obtain a matching result; In a case where the matching result indicates that the data operated this time does not completely match the first target logical block, determining a second target logical block based on the operation start position, the operation quantity, and the first target logical block, where the second target logical block is a logical block corresponding to target data that is not matched with the first target logical block in the data operated this time in the RPMB; Copying the historical data to a first operation buffer and copying data of the second target logical block to a second operation buffer, and performing data operations through the first operation buffer and the second operation buffer; Copying the current data in the second operation buffer to the target buffer as new historical data.

2. The method according to claim 1, wherein In a case where the data operation is a data read operation, the performing data operations through the first operation buffer and the second operation buffer includes: Returning a data response to a host that sent the data operation request through the current data in the first operation buffer and the second operation buffer.

3. The method according to claim 1, characterized in that, In a case where the data operation is a data write operation, the data operation request further includes data to be written; The performing data operations through the first operation buffer and the second operation buffer includes: Performing data replacement on the data in the first operation buffer and the second operation buffer based on the data to be written; Performing data writing through the current data in the first operation buffer and the second operation buffer.

4. The method according to claim 3, characterized in that, After copying the current data in the second operation buffer to the target buffer as new historical data, the method further includes: Incrementally updating the write count of the RPMB; Performing redundant data writing on a flash memory medium provided with the RPMB based on the updated write count.

5. The method according to claim 4, characterized in that After updating the write count of the RPMB, the method further includes: When a data write fails, decrementally updating the current write count; Performing redundant data writing on the flash memory medium based on the updated write count, and discarding data in the target buffer.

6. The method according to claim 1, wherein In a case where the data operation is a data write operation, the data operation request further includes data to be written; After obtaining the matching result, the method further includes: When the matching result indicates that the data operated this time completely matches the first target logical block, copying the historical data to the first operation buffer; Performing data replacement on the data in the first operation buffer based on the data to be written; Performing data writing through the current data in the first operation buffer; Copy the current data in the first operation buffer as new historical data to the target buffer.

7. The method according to claim 1, characterized in that, The target buffer, the first operation buffer, and the second operation buffer are all set to store data of 32 logical blocks, and both the historical data and the data copied to the second operation buffer are 32 logical blocks.

8. A data operation device, characterized in that, The device includes: A data operation request acquisition module, configured to acquire a data operation request, where the data operation request includes an operation start position and an operation quantity of a logical block; A first target logical block determination module, configured to determine a first target logical block to which the historical data stored in the target buffer belongs in a replay protection memory block (RPMB), where the historical data is the data of the previous operation; A matching module, configured to match the first target logical block according to the operation start position and the operation quantity to obtain a matching result; A second target logical block determination module, configured to, when the matching result indicates that the data operated this time does not completely match the first target logical block, determine a second target logical block based on the operation start position, the operation quantity, and the first target logical block, where the second target logical block is the logical block corresponding to the target data that does not match the first target logical block in the data operated this time in the RPMB; A data operation module, configured to copy the historical data to the first operation buffer and the data of the second target logical block to the second operation buffer, and perform data operations through the first operation buffer and the second operation buffer; A target buffer data update module, configured to copy the current data in the second operation buffer as new historical data to the target buffer.

9. An electronic device, characterized in that, The electronic device includes a memory and a processor, the memory stores a computer program, and when the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, the method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Storage device and operating method thereof

    CN110096908A

  • Data processing method and device, equipment and storage medium

    CN112948281A

  • Data processing method and device, electronic equipment and computer readable storage medium

    CN116880746A

  • Data operation method and device, equipment and storage medium

    CN117112546A

  • Data processing method and device, storage equipment and storage medium

    CN119002815A