Data access method, device and equipment

By centrally storing secure data with near-term protection periods in SSDs and updating it using an append-only write method, the capacity reduction problem caused by mixing secure data and ordinary data in SSDs is solved, achieving more efficient storage space management.

CN121680711APending Publication Date: 2026-03-17CHENGDU HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-29
Publication Date
2026-03-17

AI Technical Summary

Technical Problem

Solid-state drives (SSDs) cannot promptly delete invalidated data when storing secure and ordinary data due to the limitations of erase block granularity, resulting in reduced storage space and impacting capacity utilization.

Method used

By concentrating secure data within the same block in an SSD and storing it in blocks with similar or identical protection periods, the secure data is updated using append-only writes, and garbage collection is performed promptly, avoiding the need to wait for the secure data to become invalid before erasing it.

Benefits of technology

It improves the capacity utilization of SSDs, ensuring that invalid data is promptly reclaimed without affecting secure data access restrictions, thereby enhancing the effective use of storage space.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121680711A_ABST
    Figure CN121680711A_ABST
Patent Text Reader

Abstract

The invention discloses a data access method, device and equipment, and the method comprises the steps that an SSD receives a first data writing instruction, and the first data writing instruction is used for requesting to write first data; the SSD determines a first target block for the first data. The first target block meets part or all of the following conditions: condition 1, data in the first target block are all secure data; the second condition is that the time difference between the first time and the second time is not larger than a first time threshold value, the first time is the expiration time of the protection period of the security data in the first target block, and the second time is the expiration time of the protection period of the first data. The SSD stores the first data in the first target block. By means of the storage mode, it can be guaranteed that the security data in the blocks where the security data are stored becomes common data at the same time or close time, or the security data are concentrated in the same blocks, it is not needed to wait for a long time when garbage collection is conducted on the blocks, and the capacity utilization rate in the SSD is effectively guaranteed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of communication technology, and in particular to a data access method, apparatus and device. Background Technology

[0002] Write-once-read-many (WORM) is a storage technology feature that can be implemented through various means, including software, hardware, physical structure, or storage media. This feature ensures that important or high-security data, once written to the storage device, can only be read and cannot be tampered with.

[0003] The existence of this storage technology characteristic, or similar characteristics, leads to the division of data into ordinary data and secure data, which refers to data with restricted access. All data other than secure data is ordinary data. Storage devices can store both ordinary data and secure data.

[0004] Taking a solid-state drive (SSD) as an example, a block within an SSD can simultaneously store both secure data and regular data. However, SSDs erase data at the block level. Data within a block can only be erased when all data within that block is invalid. When a block stores both secure and regular data, even if the regular data becomes invalid, the SSD must wait until the secure data is no longer restricted and has also become invalid before it can move the data from that block and erase the block. This prevents the SSD from promptly deleting invalidated regular data, which continues to occupy storage space, thus reducing the available capacity of the SSD. Summary of the Invention

[0005] This application provides a data access method, apparatus, and device for improving the capacity utilization of SSDs.

[0006] Firstly, this application provides a data access method applicable to storage devices. Taking an SSD as an example, the method involves: the SSD receiving a first data write instruction, which requests the writing of first data. Upon receiving the first data write instruction, the SSD determines a first target block to be written for the first data. This first target block satisfies some or all of the following conditions:

[0007] Condition 1: All data within the first target block is secure data;

[0008] Condition 2: The time difference between the first time and the second time is not greater than the first time threshold. Here, the first time is the expiration time of the protection period of the security data in the first target block, the second time is the expiration time of the protection period of the first data, the protection period of the security data is the time period during which access to the security data is restricted, and the protection period of the first data is the time period during which access to the first data is restricted.

[0009] After determining the first target block, the SSD stores the first data in the first target block.

[0010] Using the methods described above, secure data can be grouped into the same blocks within an SSD. This ensures that blocks storing secure data do not contain ordinary data, while ordinary data can be grouped into other blocks. The SSD can then perform garbage collection on blocks containing ordinary data promptly, improving the SSD's capacity utilization. Furthermore, secure data with similar or near-same expiration dates can be grouped into the same blocks. This storage method guarantees that secure data within blocks becomes ordinary data at the same or near-same time, eliminating the need for lengthy garbage collection times and effectively ensuring high capacity utilization.

[0011] In one possible implementation, the first data is secure data, meaning the first device has a protection policy. When determining the first target block, the SSD first obtains the protection policy for the first data. The protection policy for the first data describes the access restrictions for the first data, including the protection period for the first data.

[0012] Using the above method, the SSD determines the second time by acquiring the protection policy of the first data, so as to select the first target block from the various blocks in the SSD that can be used to write the first data.

[0013] In one possible implementation, the SSD can obtain the protection policy for the first data in many ways. For example, the SSD determines the protection policy for the first data by analyzing the data type of the first data. Another example is that the first data write instruction carries the protection policy for the first data, and the SSD obtains the protection policy from the first data write instruction. Yet another example is that the first data write instruction carries an identifier for the protection policy for the first data, and the SSD obtains the identifier for the protection policy for the first data from the first data write instruction and determines the protection policy for the first data based on the identifier.

[0014] There are many ways to obtain the first data protection strategy for SSDs using the methods described above, which are suitable for different application scenarios.

[0015] In one possible implementation, the SSD can also determine the blocks to be written in a similar way for ordinary data. The following explanation uses ordinary data as the second data as an example. The SSD receives a second data write command, which requests the writing of second data, which is not considered secure data. The SSD determines the second target block, which satisfies some or all of the following conditions:

[0016] Condition 1: The time difference between the expiration time of the security data in the second target block and the current time is less than the second time threshold. The expiration time of the security data is the expiration time of the protection period of the security data.

[0017] Condition 2: The data within the second target block is not considered secure data.

[0018] The SSD stores the second data in the second target block.

[0019] Using the above methods, ordinary data within an SSD can be concentrated in the same block, or stored in a block where secure data is about to expire, making it easier for the SSD to perform timely garbage collection on the blocks containing ordinary data.

[0020] In one possible implementation, security data updates are also permitted within the SSD. The following explanation uses updating the first data as an example to illustrate the security data update process. The SSD receives a third data write command, which requests that the first data be updated to the third data. The SSD first determines whether the protection policy of the first data allows updating the first data. If the protection policy of the first data indicates that updating the first data is permitted, the SSD determines a third target block. The third target block satisfies some or all of the following conditions:

[0021] Condition 1: All data within the third target block is secure data.

[0022] Condition 2: The time difference between the third time and the fourth time is not greater than the first time threshold, where the third time is the expiration time of the protection period of the security data in the third target block, and the fourth time is the expiration time of the protection period of the third data.

[0023] The SSD stores the third data in the third target block.

[0024] Using the above method, the SSD updates security data by appending the data. The updated security data (such as the third data) is written in a similar way to the security data before the update (such as the first data). This ensures that the data in the block containing the updated security data (such as the third target block) is all security data or that the expiration time of the security data in that block is close, which facilitates the SSD to perform garbage collection on that block in a timely manner.

[0025] In one possible implementation, the third data is secure data, meaning the third device has a protection policy. When determining the third target block, the SSD first obtains the protection policy for the third data. This protection policy describes the access restrictions for the third data and includes the protection period. The protection policy for the third data can be the same as the protection policy for the first data; that is, the SSD can use the protection policy for the first data as its own. Alternatively, the protection policy for the third data can differ from the protection policy for the first data. The way the SSD obtains the protection policy for the third data is similar to how it obtains the protection policy for the first data, such as by including the protection policy in the third data write instruction. For details, please refer to the foregoing explanation; further elaboration is omitted here.

[0026] Using the above method, the SSD determines the third target block for the third data by obtaining the protection policy of the third data.

[0027] In one possible implementation, the SSD receives a data read command, which is used to request the reading of first data;

[0028] The SSD reads the first data from the first target block if the protection policy for the first data indicates that reading the first data is permitted.

[0029] Using the above method, when the SSD reads the first data, it needs to first determine whether the protection policy of the first data indicates that reading the first data is allowed, thus ensuring the security of the first data.

[0030] In one possible implementation, after the protection period for all secure data in the first target block expires, the SSD marks the first target block as pending reclaiming. The SSD can then perform garbage collection on the first target block when all data within it becomes invalid.

[0031] By using the above method, since the data in the first target block is all secure data or the expiration time of the security data protection period is close, the SSD can mark the first target block as pending recycling in a timely manner, thereby improving the efficiency of garbage collection and ensuring the utilization rate of the SSD's content.

[0032] In one possible implementation, when the SSD stores third data in the third target block, it determines the physical address of the third data within the third target block; it writes the third data to the physical address of the third data and records the mapping relationship between the logical address of the first data and the physical address of the third data; then it deletes the recorded mapping relationship between the logical address and the physical address of the first data. The SSD can delete the mapping relationship between the logical address and the physical address of the first data in the FTL and record the mapping relationship between the logical address and the physical address of the first data in other storage spaces for subsequent recovery of the first data.

[0033] Using the method described above, the third data is written to the SSD in an append-only manner, which is simpler and more efficient. Furthermore, since the first data is still retained within the SSD, it facilitates subsequent recovery of the first data.

[0034] In one possible implementation, the expiration time of the protection period for secure data (such as the first time, the second time, the third time, and the fourth time) can be determined based on the SSD's clock, or it can be determined based on other clocks obtained by the SSD (such as the host's clock obtained by the SSD).

[0035] Using the methods described above, SSDs can determine the expiration time of the protection period for secure data based on various clocks, which are suitable for different scenarios.

[0036] Secondly, this application also provides a storage device that has the functionality to implement the behavior in the method examples of the first aspect described above. The beneficial effects are described in the first aspect description and will not be repeated here. The functionality can be implemented by hardware or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above-described functionality. In one possible design, the storage device structure includes an acquisition module, a determination module, and a storage module. These modules can perform the corresponding functions in the method examples of the first aspect described above, as detailed in the method examples and will not be repeated here.

[0037] Thirdly, this application also provides a computing device, which includes a processor and a storage device, and may further include memory. The storage device receives data read instructions, a first data write instructions, a second data write instructions, or a third data write instructions from the processor, and executes the method provided in the first aspect or any possible implementation of the first aspect.

[0038] Fourthly, this application provides a storage device including a main controller and a storage medium. The storage device may further include memory. The storage medium is used to store data. The main controller is used to execute the method provided in the first aspect or any possible implementation of the first aspect. Alternatively, the main controller executes computer program instructions in memory to implement the method provided in the first aspect or any possible implementation of the first aspect. The memory is coupled to the main controller and stores the computer program instructions and data necessary for determining data access.

[0039] Fifthly, this application provides a computer-readable storage medium that, when executed by a storage device (or computing device), performs the method provided in the first aspect or any possible implementation thereof. The computer-readable storage medium stores computer program instructions. This computer-readable storage medium includes, but is not limited to, volatile memory, such as random access memory, and non-volatile memory, such as flash memory.

[0040] Sixthly, this application provides a computing device program product, which includes computer program instructions. When executed by a storage device (or computing device), the storage device (or computing device) performs the methods provided in the first aspect or any possible implementation thereof. The computer program product can be a software installation package, which can be downloaded and executed on a computing device when the methods provided in the first aspect or any possible implementation thereof are required.

[0041] In a seventh aspect, this application also provides a computer chip connected to a memory, the chip being used to read and execute computer program instructions stored in the memory, and to execute the methods described in the first aspect and various possible implementations of the first aspect.

[0042] For the technical effects that can be achieved in the second to seventh aspects mentioned above, please refer to the description of the technical effects that can be achieved by the corresponding design scheme in the first aspect mentioned above. This application will not repeat them here. Attached Figure Description

[0043] Figure 1 A schematic diagram of the structure of a data access system provided as an example of this application;

[0044] Figure 2A A schematic diagram of the structure of a storage device is provided as an example of this application;

[0045] Figure 2B A schematic diagram of an SSD structure is provided for the example of this application;

[0046] Figure 3 A schematic diagram of the structure of a die in an SSD is provided as an example of this application;

[0047] Figure 4 A schematic diagram of the FTL structure in an SSD is provided as an example of this application.

[0048] Figure 5 A schematic diagram of a data access method provided for this application example;

[0049] Figure 6 A schematic diagram of data distribution within a storage device is provided as an example of this application.

[0050] Figure 7 This is a schematic diagram of a storage device provided as an example of this application. Detailed Implementation

[0051] Before introducing a data access method, apparatus, and device provided in the embodiments of this application, some concepts involved in the embodiments of this application will be explained first.

[0052] (1) Data: security data, ordinary data.

[0053] In this embodiment of the application, the storage device can store data sent by the host under the instruction of the host. That is, the host requests the data to be stored by the storage device by initiating a data write instruction; after receiving the data write instruction, the storage device stores the data to be written carried in the data write instruction.

[0054] Based on the access restrictions, the data to be written can be divided into two categories: restricted data and data with access restrictions. After being stored on a storage device, access to this type of data is subject to certain restrictions. In other words, when a host initiates read, update, or other access operations on this type of data through the storage device, the access operation can only be executed if certain conditions are met, such as successfully reading or successfully modifying the data. This type of data typically has high security requirements and requires special protection. For ease of explanation, this type of data is referred to as secure data, such as the first data and third data mentioned in the embodiments of this application. A host initiating an access operation on data in a storage device means that the host sends a data access request to the storage device to request access to the data in that storage device.

[0055] One type of data is unrestricted access data, which, after being stored on a storage device, cannot be accessed by the host without restriction. In other words, the host can access this type of data on the storage device at any time, such as reading or updating it. For ease of explanation, this type of data is referred to as ordinary data, such as the second data mentioned in the embodiments of this application.

[0056] (2) Data access commands: data read commands, data write commands (such as data new write commands, data update commands).

[0057] A host can send data access commands to a storage device to request access to data. Depending on the host's method of data access, these data access commands include: data read commands and data write commands.

[0058] The data read instruction is used to request data to be read from the storage device, and it carries the logical address of the data to be read. The data write instruction is used to request data to be written to the storage device. It carries the logical address of the data to be written and the data itself.

[0059] For data write instructions, given the method of writing data, these data write instructions include data new write instructions and data update instructions. A data new write instruction is used to request the writing of new data into the storage device. This instruction carries the new data and its logical address. A data update instruction is used to request the updating of data already stored in the storage device. This instruction carries the logical address of the data already stored in the storage device and the updated data. For ease of explanation, the stored data is referred to as the data before the update; this data before the update can be called the old data, and the updated data can be called the new data. Data update refers to updating old data with new data. A data new write instruction is a data write instruction initiated by the host when requesting the storage device to store data for the first time, such as the first data write instruction mentioned in this application. A data update instruction is a data write instruction initiated by the host when requesting the storage device to store the same data again, such as the third data write instruction mentioned in this application.

[0060] (3) Protection strategy.

[0061] Secure data has a protection policy, which describes access restrictions for the secure data. The specific content of the protection policy is not limited in this application embodiment. Any information that can describe access restrictions for secure data can be used as a protection policy. The protection policy indicates some or all of the following: protection period, access permissions, number of accesses, and access type.

[0062] ① The protection period is the time during which access to secure data is restricted. That is, during this protection period, access operations on the secure data are prohibited. From the perspective of access operations, this protection period can be divided into: read protection period and update protection period. The read protection period indicates the restricted time period for reading secure data; that is, reading the secure data is prohibited during the read protection period. The update protection period indicates the restricted time period for updating secure data; that is, updating the secure data is prohibited during the update protection period.

[0063] It should be noted that update operations on this security data can include modifying or deleting the data included within it, as well as modifying the physical address of the security data, i.e., moving the physical storage location of the security data within the storage device. Therefore, based on the specific type of update operation, the update protection period can be divided into data update protection period and location update protection period. The data update protection period indicates the restricted time period for modifying or deleting security data; that is, modification or deletion of the security data is prohibited during the data update protection period. In other words, updating the security data itself is not allowed during the data update protection period. The location update protection period indicates the restricted time period for moving security data; that is, modifying the physical address of the security data is prohibited during the location update protection period. During the location update protection period, movement operations on the security data triggered externally to the storage device are not allowed. If a host initiates an instruction regarding the security data during this location update protection period, and the execution of the instruction requires the storage device to modify the physical address of the security data, the storage device can reject the instruction.

[0064] Regarding secure data movement, within a storage device, there may be situations where secure data needs to be moved for protection purposes, such as when the storage unit containing the secure data is damaged or its performance is affected. In these cases, the storage device can modify the physical address of the secure data, and the movement operation is not affected by the location update protection period.

[0065] The following are some storage devices that support the physical location of host data movement:

[0066] Open Channel SSDs are a simplified type of SSD that removes the FTL (Framework Leader) and delegates data management to the host connected to the SSD. The host can perceive and manage the physical storage space within the SSD, such as assigning physical addresses to data, triggering the SSD to move data to different physical locations (i.e., modifying the physical addresses of data), and initiating garbage collection. Storage devices supporting the zoned namespace (ZNS) protocol are based on Open Channel. This means that a host connected to a ZNS-enabled storage device can perceive and manage the physical storage space of that device. For storage devices such as Open Channel SSDs and storage devices that support the ZNS protocol, the host connected to such storage devices can trigger data movement operations. For example, the host can send a garbage collection command to instruct the storage device to perform garbage collection on one or more storage cells within the storage device. After receiving the garbage collection command, the storage device moves the physical location of the valid data in the one or more storage cells, migrates the valid data to other storage cells, and erases the data in the one or more storage cells.

[0067] Due to the protection period, time is divided into two categories: the period within the protection period and the period outside the protection period. The period outside the protection period can be referred to as the protection period expired or the protection period has expired. In this embodiment of the application, the protection period expired or the protection period has expired means that the current time is no longer within the protection period.

[0068] This application does not limit the way the protection policy indicates the protection period. For example, the protection policy records the start and end times of the protection period. For instance, the protection policy for data A records "Access is prohibited between 11:00 and 12:00." Similarly, the protection policy for data B records "Updates are prohibited between 11:30 and 12:00." Another example is that the protection policy records the duration of the protection period. After obtaining the protection policy for the security data, the storage device uses the time of obtaining the protection policy for the security data as the start time of the protection period, or the time of receiving the data write instruction carrying the security data as the start time of the protection period. The storage device adds the duration recorded by the protection policy to the start time of the protection period to obtain the end time of the protection period. For example, if the protection policy for data A records "Access is prohibited for 30 minutes," then the duration of the protection period is 30 minutes. If the storage device uses the time of receiving the data write instruction carrying data A, 11:00, as the start time of the protection period, then the end time of the protection period is 11:30.

[0069] It should be noted that in this embodiment, the storage device obtains the protection period of the security data (such as the first data) from the protection policy of the security data. The start and end times, termination times (i.e., expiration times), or duration of the protection period can be determined based on the storage device's own clock. Correspondingly, when the storage device needs to determine whether the current time falls within the protection period, the current time is also determined based on the storage device's own clock. Of course, in some special scenarios, the storage device can also determine the current time, the start and end times, the termination times, or the duration of the protection period based on other clocks. For example, after the storage device connects to the host, it obtains the host's clock and uses that clock to determine the current time, the start and end times, the termination times, or the duration of the protection period.

[0070] Furthermore, multiple different clocks are allowed within a storage device, such as the storage device's own clock and a clock obtained from the host. Each storage cell containing secure data within the storage device corresponds to a clock; different storage cells may use the same or different clocks. For any storage cell containing secure data, the start and end times, termination times, or duration of the protection period for that secure data are determined based on its corresponding clock. Similarly, when determining whether the current time falls within the protection period of the secure data in a storage cell, the storage device also uses the clock corresponding to that storage cell. For example, within an SSD, some blocks correspond to the SSD's own clock. The SSD determines the start and end times and the termination times of the protection period for the secure data within that block based on its own clock, and it also determines whether the current time falls within the protection period of the secure data within that block based on its own clock. Some blocks correspond to a trusted clock obtained by the SSD from an external source (such as the host clock obtained from the host). The SSD determines the start and end times of the protection period for the secure data within the block based on this trusted clock. The SSD also determines whether the current time falls within the protection period for the secure data within the block based on this trusted clock.

[0071] ② Access permissions refer to the "access endpoint" that is allowed to access secure data. An access endpoint is understood as the party that triggers the access operation for that secure data. This access endpoint includes, but is not limited to: applications, users, and computing devices.

[0072] For secure data within a storage device, a host connected to the storage device can initiate an access operation for that secure data. In other words, the host can send a data access command to the storage device, which is used to request access to the secure data.

[0073] For the host, access to the secure data can be initiated by an application deployed on the host. That is, when an application deployed on the host needs to access secure data, the host sends a data access command to the storage device. Access can also be initiated by a user. A user can directly perform operations on the host to query or update the secure data; upon detecting the user's operation, the host sends a data access command to the storage device. Users can also operate computing devices deployed on the user's side to query or update the secure data; upon detecting the user's operation, the computing device sends a data access request to the host to request access to the secure data, and upon receiving the data access request, the host sends a data access command. Access can also be initiated by a computing device connected to the host. The computing device can send a data access request to access the secure data, and upon receiving the data access request, the host sends a data access command to the storage device.

[0074] ③ The number of accesses refers to the maximum number of access operations allowed to be performed on secure data.

[0075] ④ The access type indicates the type of access operation allowed to be performed on the secure data. The access type includes some or all of the following: read data, delete data, modify data, move data (i.e., modify the physical address of the secure data).

[0076] The above only lists the specific content that a protection strategy may protect; a protection strategy may include some or all of the above. In practical applications, the protection strategy may also include other content, such as access frequency (i.e., the number of access operations allowed on secure data per unit of time).

[0077] (4) Waste recycling and the particle size of waste recycling.

[0078] Storage devices employ an internal garbage collection mechanism. Garbage collection refers to the deletion of invalid data within a storage device, retaining only valid data. The basic principle is that valid data from one or more storage units is moved to a new storage unit, and then the data on that new storage unit is erased. The erased storage unit then becomes a new, usable storage unit. The storage unit is the granularity of garbage collection; that is, during garbage collection, data movement and erasure are always performed at the storage unit level. The granularity of garbage collection varies depending on the type of storage device. For example, solid-state drives (SSDs) perform garbage collection at the block level. Storage devices supporting zoned namespaces (ZNS) protocols perform garbage collection at the zone level.

[0079] There are many ways for a storage device to determine whether the stored data is valid or invalid. Here are a few possible methods:

[0080] Method 1: The storage device learns of invalid data from the host.

[0081] The host informs the storage device of the logical address of invalid data. After obtaining the logical address of the invalid data, the storage device can determine the physical address of the invalid data based on the logical address, and thus determine which data is invalid. This application embodiment does not limit the specific method by which the host informs the storage device of the logical address of invalid data. For example, the host sends an invalid data instruction to the storage device, which informs the storage device which data is invalid. This invalid data instruction carries the logical address of the invalid data. After receiving the invalid data instruction, the storage device records the logical address of the invalid data so that it can determine which data in the storage unit is valid and which is invalid during garbage collection.

[0082] Method 2: The storage device treats the old data before the update as invalid data.

[0083] In this embodiment, the host can instruct the storage device to update the data itself. When the host instructs the storage device to update the data, the host can send a data update instruction to the storage device to request an update of the data stored in the storage device. This data access instruction carries the logical address of the old data and the new data. After receiving the data access instruction, the storage device can update the data using an append-only write method. An append-only write means that the storage device does not directly update the already stored old data, but instead finds a new, free physical address, writes the new data to that physical address, and records the mapping relationship between the logical address of the old data and the new physical address. The previously recorded mapping relationship between the logical address and physical address of the old data is marked as invalid or deleted by the storage device. In the append-only write method, both the old data and the new data are retained in the storage device simultaneously. After storing the new data, the storage device can treat the old data as invalid data.

[0084] Method 3: The storage device treats intermediate data generated during the operation of the storage device as invalid data.

[0085] Storage devices generate intermediate data during operation to maintain their functionality. Intermediate data refers to temporary data created to support the operation of the storage device, and it is only used by the storage device within a specific time period or moment. Examples include the operation logs within the storage device. When the storage device no longer needs this intermediate data, it can be treated as invalid data.

[0086] like Figure 1 The diagram shown is a schematic representation of a data access system according to an embodiment of this application. The data access system includes a host 20 and a storage device 10. The host 20 can be a computing device. The host 20 includes, but is not limited to, a personal computer, server, mobile phone, tablet computer, or smart car. The storage device 10 is connected to the host 20.

[0087] The host 20 can access data in the storage device 10 by issuing data access commands to the storage device 10, such as writing data to or reading data from the storage device 10. The storage device 10 provides data storage space for the host 20 and can complete data reading and data writing under the command of the host 20.

[0088] When host 20 needs to write data to storage device 10, host 20 sends a data write instruction to storage device 10 (such as the first data write instruction, second data write instruction, and third data write instruction mentioned in the embodiments of this application). This data write instruction requests that data be written to storage device 10. The data write instruction carries the data to be written (such as the first data, second data, and third data mentioned in the embodiments of this application) and the logical address of the data to be written. Storage device 10 receives the data write instruction and stores the data according to the logical address of the data to be written. For a description of the data write instruction, please refer to the foregoing content; it will not be repeated here.

[0089] When host 20 needs to retrieve data from storage device 10, host 20 sends a data read instruction to storage device 10. This data read instruction requests the data and carries the logical address of the data to be read (such as the first data and second data mentioned in the embodiments of this application). After receiving the data read instruction, storage device 10 reads the data based on its logical address and returns the data to host 20.

[0090] Storage device 10 is connected to host 20. Storage device 10 can be used as an external storage device for host 20 or deployed inside host 20, such as by being installed on the motherboard or backplane of host 20. Storage device 10 exchanges data with host 20 through a bus. The bus can be a peripheral component interconnect express (PCIe) bus, or a compute express link (CXL) protocol, universal serial bus (USB) protocol, or a bus of other protocols.

[0091] The storage device 10 can serve as an external module with storage capabilities for the host 20, providing extended storage space for the host 20. In other words, the host 20's data can be stored on the storage device 10, which provides storage space for the host 20.

[0092] In this embodiment of the application, after receiving a data write instruction from the host 20, if the storage device 10 determines that the data to be written is secure data (such as the first data or the third data), the storage device 10 determines the storage unit to which the data to be written (such as the first storage unit or the third storage unit involved in this embodiment of the application); the storage unit meets the target conditions. The target conditions include some or all of the following: all data already stored in the storage unit is secure data (i.e., all have a protection period); the time difference between the first time and the second time is not greater than the first time threshold; the storage unit is a blank storage unit.

[0093] The first time period is the expiration time of the protection period for all secure data within the storage unit, and the second time period is the expiration time of the protection period for the data to be written. The size of the storage unit is the garbage collection granularity of the storage device.

[0094] After determining a storage unit, storage device 10 stores the data to be written in that storage unit. When storing the data, storage device 10 allocates a physical address for the data in the storage unit and stores the data at that physical address. Storage device 10 can also record the mapping relationship between the logical address and the physical address of the data. Storage device 10 can also record the protection policy for the data.

[0095] The storage device 10 receives two types of data write instructions: a data write-new instruction and a data update instruction. When the storage device 10 receives a data write-new instruction, it processes it in a manner similar to that described above for processing data write instructions. When the storage device 10 receives a data update instruction, it instructs the storage device 10 to update the data already stored with the data to be written. The storage device 10 then determines whether to allow the update of the stored data based on the protection policy of the stored data.

[0096] If updating the stored data is permitted, storage device 10 updates the stored data with the data to be written. Storage device 10 can update the stored data using an append-only write method. If updating the stored data is not permitted, storage device 10 rejects the data update instruction.

[0097] In this embodiment of the application, after receiving a data read instruction from the host 20, the storage device 10, upon determining that the data to be read is secure data, further determines a protection strategy for the data to be read.

[0098] Storage device 10 determines whether to allow reading the data based on the protection policy of the data to be read. If reading the data is allowed, storage device 10 acquires the data and sends it back to host 20. If reading the data is not allowed, storage device 10 rejects the data read command.

[0099] In addition, the storage device 10 also has a garbage collection mechanism. For any storage cell within the storage device 10, if the data in the storage cell is ordinary data, the storage device 10 can perform garbage collection on the data in the storage cell after the ordinary data becomes invalid data. If the data in the storage cell is secure data, the storage device 10 will perform garbage collection on the storage cell after the protection period of the secure data expires and the secure data becomes invalid data.

[0100] In storage device 10, the method of writing secure data (i.e., determining storage cells and storing secure data in those cells) ensures that the expiration dates of the security data protection periods within the same storage cell are close to or the same. In other words, the secure data within that storage cell will expire at the same or similar times. After the security data protection period expires, when performing garbage collection within storage device 10, garbage collection can be performed on the entire storage cell, improving garbage collection efficiency and preventing a reduction in the available capacity of the storage device.

[0101] The structure of the host 20 and the storage device 10 is described below. (See attached text.) Figure 1 The host 20 includes a network card 230, a processor 210, and memory 220. The network card 230, processor 210, and memory 220 can be connected via a system cable. This bus can be a peripheral component interconnect express (PCIe) bus, or a compute express link (CXL), universal serial bus (USB) protocol, or a bus using other protocols.

[0102] The network interface card 230 is used to communicate with devices located outside the host. The processor 210 is the core of the host 20's processing and control; it can be a central processing unit (CPU) or other specific integrated circuits. The processor 210 can also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The processor 210 can send data access commands to the storage device 10 to access data in the storage device 10.

[0103] Memory 220 is typically used to store computer program instructions. Memory 220 can also be used for temporary data storage. Memory 220 can be Dynamic Random Access Memory (DRAM). Besides DRAM, memory 220 can also be other types of random access memory, such as Static Random Access Memory (SRAM) and Storage Class Memory (SCM). Additionally, memory 220 can also be Read Only Memory (ROM). For example, ROM can be Programmable Read Only Memory (PROM) or Erasable Programmable Read Only Memory (EPROM). Memory 220 can also be a Dual In-Line Memory Module (DIMM), Flash Memory, etc. Memory 220 is also understood as main memory.

[0104] The structure of storage device 10 will be described below. In this embodiment, storage device 10 is a persistent storage device, such as SCM, hard disk disk (HDD) or solid state disk (SSD).

[0105] like Figure 2AThe diagram shown is a structural schematic of a storage device provided in an embodiment of this application. The storage device 10 includes a main controller 11 and a storage medium 12.

[0106] The main controller 11 is the management module within the storage device 10. The main controller 11 can control the writing or reading of data, maintain the normal operation of the storage device 10, monitor the usage of the storage space within the storage device 10, and perform garbage collection, etc.

[0107] In this embodiment, the main controller 11 is capable of processing data access instructions from a host (such as processor 210). Furthermore, the main controller 11 can also perform garbage collection. The processing of data access instructions and the execution of garbage collection can be found in the aforementioned description of how the storage device 10 processes data access instructions and performs garbage collection, and will not be repeated here.

[0108] Storage medium 12 is the medium for data storage in storage device 10. This application embodiment does not limit the specific type of storage medium 12; it can be flash memory or other media. Any medium that can be used to store data can be used as this storage medium. The storage medium 12 includes multiple storage units. Each storage unit is of the same size. Each storage unit is a physical storage space formed by physically dividing the storage medium 10.

[0109] When storing data (which can be ordinary data or secure data) into the storage medium 12, the main controller 11 determines a storage unit from the storage medium 12. After determining the storage unit, the main controller 11 stores the data in that storage unit. That is, it allocates a physical address in the storage unit and writes the data to that physical address.

[0110] When performing garbage collection, the main controller 11 performs garbage collection at the storage unit level.

[0111] Although not shown, the storage device 10 also includes memory 13, which can be used to store computer program instructions and data. For example, the memory of the storage device 10 can store computer program instructions required by the main controller 11 to process data access instructions and perform garbage collection.

[0112] Here, we will take SSD100 as an example to explain the structure of storage device 10.

[0113] The SSD100 is a storage device that primarily uses NAND flash memory as its permanent storage medium. For example... Figure 2BAs shown, the SSD 100 includes NAND flash memory and a host controller (hereinafter referred to as the controller) 110. The NAND flash memory includes multiple flash memory chips 120 for storing data. The controller 110 is the central brain of the SSD 100, responsible for complex tasks such as managing data storage, maintaining the performance and lifespan of the SSD 100, etc. The controller 110 can be an embedded microchip, which includes a processor 112, which functions like a command center, issuing all operational instructions for the SSD 100. For example, the processor 112 can perform functions such as reading / writing data, garbage collection, and wear leveling through its firmware.

[0114] In this embodiment of the application, the processor 112 can process data access instructions from the host 20 and can also perform garbage collection. The method of processing data access instructions and the method of performing garbage collection can be found in the foregoing description, and will not be repeated here.

[0115] The SSD100 controller 110 also includes a host interface 111 and several channel controllers 113. The host interface 111 is used for communication with the host 20. Each channel corresponds to one channel controller 113, and each channel controller 113 controls the flash memory chip 120 within its corresponding channel. Through several channel controllers 113, the controller 110 can operate multiple flash memory chips 120 in parallel, thereby improving the underlying bandwidth. For example, assuming there are eight channels between the controller 110 and the flash memory chips 120, the controller 110 can read and write data to eight flash memory chips 120 in parallel through these eight channels.

[0116] like Figure 3 As shown, a die is a package of one or more flash memory chips 120. A die can contain multiple planes; multi-plane NAND is a design that can effectively improve performance. This design approach provides the possibility of multi-plane operation, that is, allowing multiple planes to operate in parallel within a single die. Figure 3 As shown, this example only illustrates a die comprising two planes. Each plane contains multiple blocks. When a die comprises two planes, the block numbers within the two planes are alternately numbered (odd and double). During operations on this die (such as writing or reading data), an alternately numbered (odd and double) operation can be performed, operating the two planes in parallel to improve the read and write performance of the SSD100.

[0117] A block consists of several pages. Taking a 16GB flash memory chip 120 as an example, each 4314 * 8 = 34512 basic NAND units (such as cells) logically form a page. Each page can store 4KB of content and 218B of parity data. The page is also the smallest unit of data operation within the SSD 100. Every 128 pages form a block, and every 2048 blocks form a panel. A complete flash memory chip 120 consists of two planes: one plane stores odd-numbered blocks, and the other stores even-numbered blocks. The two planes can operate in parallel. This is just an example; the page size, block capacity, and flash memory chip 120 capacity can all have different specifications, which are not limited in this embodiment.

[0118] Host 20 can access SSD 100 via logical block addresses (LBAs), meaning the logical address carried by data access commands (such as write or read commands) initiated by host 20 includes the LBA. Each LBA represents a logical storage unit (such as a sector). Internally, controller 110 accesses SSD 100 in units of pages (a page is the granularity of data operations on the SSD, such as 4KB). Each time controller 110 writes data equal to a page size, it finds a page to write the data to; the address of the page is called the physical block address (PBA). SSD 100 internally records a mapping from LBA to PBA. With this mapping, the next time host 20 needs to read data from a certain LBA, SSD 100 knows where to read the data from flash memory chip 120.

[0119] like Figure 4 The diagram shown is a schematic of the flash translation layer (FTL), which is located in the main controller 110. Figure 4 As shown, each time host 20 writes new data, a new mapping relationship is generated. This mapping relationship is added to (first write) or modified (overwrite write) the FTL. When reading certain data, SSD100 first looks up the PBA corresponding to the LBA of that data in the FTL, and then reads the corresponding data according to the PBA.

[0120] In this embodiment of the application, within the SSD 100, after receiving a data write instruction from the host 20, the controller 110 determines the block to be written for the data, allocates a PBA for the data to be written in the block, writes the data into the PBA, and records the mapping relationship between the LBA and the PBA of the data in the FTL.

[0121] After receiving a data read instruction from the host 20, the main controller 110 obtains the LBA of the data to be read from the data read instruction, queries the FTL according to the logical address of the data, determines the PBA of the data, reads the data based on the PBA of the data, and feeds the data back to the host 20.

[0122] Typically, flash memory chip 120 does not support overwrite operations. When host 20 modifies data on a certain LBA, it cannot directly modify the corresponding PBA; it must write to a new PBA and add a mapping in the FTL. For example, if there is a mapping between LBAD and PBAD in the FTL, when host 20 sends a data update command requesting modification of data in LBAD, SSD 100 finds a new location (PBA E) to write the data and adds a mapping between LBAD and PBAE in the FTL. This causes the data on PBA D to become invalid. Invalid data (also called garbage data) refers to data that has no mapping relationship pointing to it. This data will not be accessed by the user. As data continues to be written, the storage space inside SSD 100 gradually decreases until it is exhausted. If this garbage data is not cleared in time, host 20 will be unable to write. The SSD100 has an internal garbage collection mechanism. The SSD100 performs garbage collection at the block level. Its basic principle is to move the valid data from one or more blocks to a new block, and then erase the one or more blocks, thus creating new usable blocks.

[0123] like Figure 5 The above describes a data access method provided in an embodiment of this application. Figure 5The illustrated embodiment uses secure data as the first data and ordinary data as the second data as an example. The method comprises three parts: First, a first data writing process, in which the host 20 initiates a first data write instruction (a new data write instruction), writing data into the storage device 10. See steps 501 to 50X for details. Second, a data reading process, in which the host 20 reads data from the storage device 10 by sending a data read instruction. Third, a data rewriting process, in which the host 20 initiates a third data write instruction (a data update instruction), updating the data stored in the storage device 10 by sending a data update instruction. See steps 501 to 50X for details.

[0124] Step 501: The host 20 sends a first data write instruction to the storage device 10, which requests to write first data. The first data write instruction carries the first data and the logical address of the first data.

[0125] Step 502: After receiving the first data write instruction, the storage device 10 determines that the first data is secure data.

[0126] This application does not limit the method by which the storage device 10 determines the first data as secure data. Several methods are listed below:

[0127] Method 1: Host 20 informs storage device 10 that the first data is secure data.

[0128] The host 20 can carry a security data identifier in the write instruction for the first data, and the storage device 10 determines that the first data is secure data upon recognizing the security data identifier. In other words, any data requested to be written by a data write instruction carrying a security data identifier is secure data.

[0129] Method 2: Storage device 10 determines that the first data is secure data based on the data type of the first data.

[0130] The storage device 10 contains records of the data type of security data, and the storage device 10 determines the data type of the first data. If the data type of the first data matches the data type of the recorded security data, the storage device 10 determines that the first data is security data.

[0131] For example, the data that host 20 needs to store can be of various types, such as data generated by applications, intermediate data generated during the operation of host 20, configuration data of host 20 system, and key data. Among these different types of data, some are security data, such as configuration data and key data of host 20 system, while others are ordinary data, such as data generated by applications.

[0132] This application does not limit the way in which the storage device 10 determines the data type of the first data. For example, the host 20 may carry the data type of the first data in the first data write instruction (that is, the data write instruction carries information indicating the data type of the first data), and the storage device 10 may obtain the data type of the first data from the first data write instruction. Alternatively, the storage device 10 may have an identification function that can analyze the first data and then identify the data type of the first data.

[0133] Method 3: Storage device 10 determines that the first data is secure data based on the ownership of the first data.

[0134] Data ownership can refer to the user to whom the data belongs, or the application that generated the data. Among this data, data belonging to one or more users, one or more applications, can be defined as secure data.

[0135] The storage device 10 records the ownership of security data, and the storage device 10 determines the ownership of the first data. If the ownership of the first data matches the ownership of the recorded security data, the storage device 10 determines that the first data is security data.

[0136] For example, storage device 10 records the ownership of various types of security data. For instance, storage device 10 records data belonging to user 1 and user 3 as security data, while storage device 10 records data belonging to user 2 as ordinary data. When storage device 10 determines that the first piece of data belongs to user 1 or user 3, storage device 10 can determine that the first piece of data is security data.

[0137] This application does not limit the method by which the storage device 10 determines the ownership of the first data. For example, the host 20 may carry the ownership of the first data in the first data write instruction (that is, the data write instruction carries information indicating the ownership of the first data), and the storage device 10 may obtain the ownership of the secure data from the first data write instruction. Alternatively, the storage device 10 may have an identification function that can analyze the first data and then identify the ownership of the first data.

[0138] Step 503: Storage device 10 obtains the protection period of the first data and determines the first storage unit where the first data needs to be written. The first storage unit satisfies the following conditions: all data in the first storage unit is secure data, and / or the time difference between the first time and the second time is not greater than the first time threshold. The first time is the expiration time of the protection period of the data in the first storage unit, and the second time is the expiration time of the protection period of the first data.

[0139] The protection strategy for the first data includes a first data protection period. When the storage device 10 obtains the protection period of the first data, the storage device 10 can obtain the protection strategy for the first data and obtain the protection period of the first data from the protection strategy for the first data.

[0140] The protection strategies for different types of security data can be the same or different. For any given security data, the protection strategy can be configured by the host 20, determined by the data type of the security data, or determined by the ownership of the security data. Several methods for the storage device 10 to obtain the protection strategy for the first data are listed below.

[0141] 1) The storage device 10 obtains the protection strategy of the first data from the first data write instruction.

[0142] The host 20 may carry the protection policy of the first data in the first data write instruction, and the storage device 10 may obtain the protection policy of the first data from the first data write instruction after receiving the first data write instruction.

[0143] The host 20 may also carry a policy identifier for the first data. This policy identifier identifies the protection policy for the first data. Upon receiving a first data write instruction, the storage device 10 retrieves the policy identifier for the first data from the instruction. The storage device 10 then determines the protection policy for the first data based on this policy identifier. In other words, the storage device 10 may have multiple different protection policies. For any given protection policy, the host 20 and the storage device 10 pre-agree on a policy identifier; therefore, the storage device 10 can determine the protection policy for the first data using the policy identifier.

[0144] 2) Storage device 10 determines the protection strategy for the first data based on the data type of the first data.

[0145] The data that the host 20 needs to store in the storage device 10 includes ordinary data and security data. Ordinary data does not have a protection policy, while security data does have a protection policy. The protection policies for security data are also different depending on the data type.

[0146] The protection policies correspond to the data types of the security data, and the storage device 10 stores the protection policies corresponding to various data types. These protection policies corresponding to various data types can be pre-configured in the storage device 10, or they can be provided to the storage device 10 in advance by the host 20.

[0147] After receiving the first data write instruction, storage device 10 determines the data type of the first data. The method by which storage device 10 determines the data type of the first data can be found in the relevant description of step 502, and will not be repeated here. After determining the data type of the first data, storage device 10 determines the protection strategy for the first data based on the protection strategies corresponding to the various data types already saved.

[0148] 3) Storage device 10 determines the protection strategy for the first data based on the ownership of the first data.

[0149] The data protection strategies differ depending on the ownership of the secure data. In this approach, the protection strategy corresponds to the ownership of the secure data, and the storage device 10 stores various ownership-related protection strategies. These ownership-related protection strategies can be pre-configured in the storage device 10, or they can be pre-informed to the storage device 10 by the host 20.

[0150] After receiving the first data write instruction, storage device 10 determines the ownership of the first data. The method by which storage device 10 determines the ownership of the first data can be found in the relevant description of step 502, and will not be repeated here. After determining the ownership of the first data, storage device 10 determines the protection policy for the first data based on the various protection policies corresponding to the saved ownership.

[0151] For example, storage device 10 records the ownership of various security data and the corresponding protection policies. For instance, storage device 10 records that data belonging to user 1 and user 3 is security data, and records the protection policies for user 1 and user 3.

[0152] Once the ownership of the first data is determined, the storage device 10 can determine the protection policy for the first data. For example, if the storage device 10 determines that the first data belongs to user 1, the protection policy for the first data will be the protection policy for user 1.

[0153] After obtaining the protection policy for the first data, storage device 10 can obtain the protection period for the first data. After obtaining the protection period for the first data, storage device 10 determines a first storage unit from among a plurality of storage units in storage device 10. The first storage unit must satisfy some or all of the following two conditions:

[0154] Condition 1: All data in the first storage unit is secure data.

[0155] The first storage unit satisfies condition one, indicating that all data in the first storage unit is secure data. This method of determining the first storage unit can ensure that secure data in the storage device 10 can be concentrated in one or more storage units, and ordinary data is not stored in the one or more storage units.

[0156] Condition 2: The time difference between the first time and the second time is not greater than the first time threshold. The first time is the expiration time of the protection period for all security data in the first storage unit, and the second time is the expiration time of the protection period for the first data.

[0157] The expiration time of the protection period is the expiration time of that protection period. The fact that the first storage unit satisfies condition one indicates that the expiration time of the protection period for all secure data within that first storage unit is close to or the same as the expiration time of the protection period for the first data. This method of determining the first storage unit ensures that the expiration times of the protection periods for secure data within a single storage unit of the storage device 10 are close to or the same. Simply put, in a certain storage unit of the storage device 10, access to the secure data within that storage unit is no longer restricted at any given moment, or access to the secure data within that storage unit gradually becomes unrestricted over a short period starting from a certain moment.

[0158] Of course, in practical applications, if there is no free storage space in the storage units that already contain secure data within the storage device 10, the storage device 10 can also select a blank storage unit as the first storage unit. A blank storage unit refers to a storage unit that does not contain any data.

[0159] Since all storage units in storage device 10 that already contain secure data are occupied, meaning there is no free storage space within the storage units, storage device 10 can select a blank storage unit as the first storage unit.

[0160] Step 504: Storage device 10 stores the first data into the first storage cell.

[0161] The storage device 10 allocates a physical address for the first data in the first storage unit, and stores the first data at that physical address. The storage device 10 can also record the mapping relationship between the logical address and the physical address of the first data, and can also record the logical address of the first data.

[0162] Taking the storage device 10 as an example, the SSD 100 determines a block from the SSD 100. The block satisfies some or all of the two conditions mentioned above, that is, the data in the block is all secure data, and / or, the time difference between the expiration time of the protection period of the secure data in the block and the expiration time of the protection period of the first data is not greater than the first time threshold.

[0163] SSD100 allocates a PBA for the first data within this block, and stores the first data on the PBA. SSD100 can record the mapping relationship between the LBA and PBA of the first data in the FTL. SSD100 can also record the protection policy for the first data, such as recording the protection policy for the first data in the FTL.

[0164] Step 505: After storing the first data, the storage device 10 sends a first data write response to the host 20, which indicates that the first data was successfully written.

[0165] At this point, the writing process for the first data is complete. Steps 501 to 505 describe the process of writing secure data to storage device 10. The writing process for ordinary data is similar. Here, we will explain the writing process for ordinary data using the example of host 20 sending a second data write command to request the writing of second data. After receiving the second data write command, storage device 10 determines that the second data is ordinary data. The way storage device 10 determines that the second data is ordinary data is similar to the method executed by storage device 10 in step 502; storage device 10 determines that the second data is ordinary data when it determines that the second data does not contain secure data. Storage device 10 determines a second storage unit from its multiple storage units, which satisfies some or all of the following conditions: the time difference between the expiration time of the secure data in the second storage unit and the current time is less than a second time threshold; and the data already stored in the second storage unit is all ordinary data, i.e., it has a protection period. If the time difference between the expiration time of the secure data in the second storage unit and the current time is less than the second time threshold, it means that the secure data in the second storage unit will expire in a short time, and access to the expired secure data is unrestricted.

[0166] Storage device 10 stores the second data in the second storage unit. That is, it allocates a physical address for the second data in the second storage unit and records the logical address and physical address of the second data.

[0167] Taking storage device 10 as SSD100 as an example, when SSD100 receives the first data write instruction, SSD100 determines the first target block from the block of SSD100. The first target block satisfies some or all of the three conditions mentioned above, namely: the data in the first target block is all secure data, the time difference between the expiration time of the protection period of the secure data in the first target block and the expiration time of the protection period of the first data is not greater than the first time threshold, and the first target block is a blank block.

[0168] SSD 100 allocates a PBA for the first data within the first target block, and stores the first data on the PBA. SSD 100 can record the mapping relationship between the LBA and PBA of the first data in the FTL. SSD 100 can also record the protection policy of the first data, such as recording the protection policy of the first data in the FTL.

[0169] When SSD100 receives the second data write instruction, SSD100 determines the second target block from the block of SSD100. The second target block satisfies some or all of the two conditions mentioned above, namely: the data in the second target block is all ordinary data, and the time difference between the expiration time of the protection period of the security data in the second target block and the current time is not greater than the second time threshold.

[0170] Of course, in practical applications, the SSD100 can also select a blank block as the second target block.

[0171] SSD100 allocates a PBA for the second data within the second target block, and stores the second data on the PBA. SSD100 can record the mapping relationship between the LBA and PBA of the second data in the FTL.

[0172] As shown in Figure 6, this is a flowchart of a data writing process provided in an embodiment of this application. Figure 6 In the process, the main controller in SSD100 receives data write commands from host 20, and SSD100 stores the security data to be written and ordinary data into the block within SSD100.

[0173] For secure data, within the SSD100, secure data with the same expiration time are grouped into one or more blocks. For example... Figure 6Secure data expiring within 10 minutes is stored in blocks A1 and A2. Secure data expiring within 20 minutes is stored in blocks B1 and B2. Secure data expiring within 30 minutes is stored in blocks C1 and C2.

[0174] For regular data, the SSD100 will centralize the data into one or more blocks, such as... Figure 6 In this process, ordinary data is stored in block-D1, block-D2, block-D3, and block-D4.

[0175] After instructing the storage device 10 to write first data by sending a first data write command, the host 20 can also read the first data. The method of reading the first data is described below.

[0176] Step 506: The host 20 sends a data read instruction to the storage device 10, which instructs the reading of first data. The data read instruction carries the logical address of the first data.

[0177] Step 507: After receiving the data read instruction, the storage device 10 determines whether to allow reading the first data according to the protection policy of the first data.

[0178] Because the first data is secure data, access to the first data is restricted. Storage device 10 obtains the recorded protection policy for the first data and determines whether to allow reading the first data based on the protection policy.

[0179] For example, if the protection policy for the first data specifies a read protection period, and the current time falls within that read protection period, then reading the first data is prohibited, i.e., reading the first data is not allowed. If the protection policy for the first data specifies a read protection period, and the current time does not fall within that read protection period, then reading the first data is allowed.

[0180] For example, if the access type specified in the protection policy for the first data does not include reading data, then reading the first data is not allowed. If the access type specified in the protection policy for the first data includes reading data, then reading the first data is allowed.

[0181] For example, if the protection policy for the first data indicates that user 1 does not have access rights, and the data read command is triggered by user 1, then reading the first data is not allowed. If the data read command is triggered by user 2, then reading the first data is allowed.

[0182] For example, the protection policy for the first data indicates an access frequency of no more than 3 accesses per unit time. If the first data has been accessed 3 times per unit time, then the storage device 10 determines that reading the first data is not allowed. If the first data has been accessed less than 3 times per unit time, then the storage device 10 determines that reading the first data is allowed.

[0183] Step 508: If reading the first data is permitted, the storage device 10 reads the first data from the first storage cell.

[0184] The storage device 10 determines the physical address of the first data based on the logical address of the first data, and the storage device 10 reads the first data from the physical address of the first data in the first storage cell.

[0185] Step 509: Storage device 10 sends a data read response to host 20, which carries the first data.

[0186] Step 510: If reading the first data is not allowed, the storage device 10 rejects the data read instruction, that is, the storage device 10 notifies the host 20 that it cannot read the first data or that the first data read has failed.

[0187] Taking the storage device 10 as an example of an SSD 100, when the host 20 reads the first data from the SSD 100, the SSD 100 first determines whether to allow reading the first data according to the protection policy of the first data. When it is determined that reading the first data is allowed, the SSD 100 queries the mapping relationship between the LBA and PBA of the first data from the FTL, and then determines the PBA of the first data, reads the first data from the PBA of the first data, and feeds back the first data to the host 20.

[0188] The above description uses the storage device 10 reading the first data as an example. For ordinary data, such as the second data, since there is no protection policy for ordinary data, when the storage device 10 reads the second data, it directly determines the physical address of the second data based on the logical address of the second data, and then reads the second data from the physical address of the second data and sends the second data back to the host 20.

[0189] After instructing the storage device 10 to write first data by sending a first data write command, the host 20 can also update the first data. The method of updating the first data is described below.

[0190] Step 511: The host 20 sends a third data write instruction to the storage device 10, which instructs the first data to be updated to the third data. The third data write instruction carries the third data and the logical address of the first data.

[0191] Step 512: After receiving the third data write instruction, the storage device 10 determines whether to allow the first data to be updated according to the protection policy of the first data.

[0192] Because the first data is secure data, access to it is restricted. Storage device 10 obtains the recorded protection policy for the first data and determines whether to allow updating the first data based on that policy. Several scenarios are listed below for determining whether to allow updating the first data:

[0193] Scenario 1: The protection policy for the first data indicates an update to the protection period.

[0194] If the protection policy for the first data specifies an update protection period, and the current time falls within that update protection period, then updating the first data is prohibited, i.e., not allowed. If the protection policy for the first data specifies an update protection period, and the current time does not fall within that update protection period, then updating the first data is allowed.

[0195] For example, the protection period indicator for the first data specifies the start and end times of the update protection period as 11:00 and 12:00, respectively. If the current time is 11:30, then updating the first data is currently prohibited. If the current time is 12:30, meaning the update protection period has expired, then updating the first data is allowed.

[0196] Scenario 2: The protection policy for the first data indicates the access type.

[0197] If the access type specified in the protection policy for the first data does not include updating data, then updating the first data is not allowed. If the access type specified in the protection policy for the first data includes updating data, then updating the first data is allowed.

[0198] For example, a protection policy for the first data may specify that updating the first data is prohibited, meaning that updating the first data is not allowed at any time. A protection policy for the first data may specify that moving the first data is prohibited, meaning that the physical location of the first data cannot be modified at any time. Other access types besides moving the first data are permitted, meaning updating the first data is allowed. A protection policy for the first data may specify that reading and updating the first data are permitted, meaning that reading and updating the first data are allowed at any time. Storage device 10 and the protection policy for the first data can determine whether updating the first data is permitted.

[0199] Scenario 3: The protection policy for the first data specifies access permissions.

[0200] If the access permissions specified in the protection policy for the first data are inconsistent with the triggering party of the update operation for the first data, then updating the first data is not allowed. If the access type specified in the protection policy for the first data is consistent with the triggering party of the update operation for the first data, then updating the first data is allowed.

[0201] For example, if the protection policy for the first data indicates that user 1 does not have access rights, and the third data write command is triggered by user 1, then updating the first data is not allowed. If the third data write command is triggered by user 2, then updating the first data is allowed.

[0202] Scenario 4: The protection policy for the first data indicates the number of accesses.

[0203] If, after performing an update operation on the first data, the number of accesses to the first data exceeds the number of accesses indicated by the protection policy, then updating the first data is not permitted; that is, the current number of accesses to the first data is equal to the number of accesses indicated by the policy. Conversely, if, after performing an update operation on the first data, the number of accesses to the first data is not greater than the number of accesses indicated by the protection policy, then updating the first data is permitted; that is, the current number of accesses to the first data is less than the number of accesses indicated by the policy.

[0204] For example, if the protection policy for the first data specifies an access limit of 10 times, and the first data has already been accessed 10 times, the storage device 10 determines that updating the first data is not allowed. If the first data has already been accessed 9 times, the storage device 10 determines that updating the first data is allowed.

[0205] The above examples are merely illustrations. In practical applications, the protection policy for the first data can simultaneously indicate multiple aspects, such as access permissions, access types, and protection periods. Therefore, when determining whether to allow updating the first data, storage device 10 will only allow updating if the access operation to the first data complies with the protection policy for that first data; otherwise, updating the data will not be permitted.

[0206] Step 513: If updating the first data is permitted, storage device 10 updates the first data to the third data.

[0207] When storage device 10 updates the first data to the third data, it can do so by appending to the first data. When storing the third data, storage device 10 needs to determine a third storage unit from multiple storage units. This third storage unit needs to meet some or all of the following conditions: Condition 1, all data in the third storage unit is secure data; Condition 2, the time difference between the third time and the fourth time is not greater than the first time threshold, where the third time is the expiration time of the protection period for all secure data within the third storage unit, and the fourth time is the expiration time of the protection period for the third data. Of course, in practical applications, a blank storage unit can also be selected as the third storage unit.

[0208] Regarding the protection period of the third data, the protection period of the third data can be the same as that of the first data, meaning that the host 20 only modifies the first data but does not change its protection period. Alternatively, the protection period of the third data can be different from that of the first data. For example, the host 20 can reconfigure the protection policy for the third data and inform the storage device 10 of the protection period for the third data. The way the host 20 informs the storage device 10 of the protection period for the third data is similar to the way the host 20 informs the storage device 10 of the protection period for the first data, and will not be elaborated further here.

[0209] After determining the third storage unit, storage device 10 stores the third data in the third storage unit. That is, it allocates a physical address for the third data in the third storage unit and stores the third data at that physical address. Storage device 10 can also record the mapping relationship between the logical address of the first data and the physical address of the third data, and storage device 10 can mark or delete the previously recorded mapping relationship between the logical address and physical address of the first data. Storage device 10 can also store the protection policy for the third data.

[0210] It should be noted that for invalid mapping relationships, such as the mapping between the logical address and the physical address of the previously recorded first data, the storage device 10 can also find storage space on the storage device 10 to store these invalid mapping relationships. The purpose of storing invalid mapping relationships is to facilitate subsequent data recovery. Based on these invalid mapping relationships, the storage device 10 can determine the physical address of the old data and then read the old data from the physical address of the old data to perform data recovery.

[0211] Taking SSD100 as an example, when executing step 513, SSD100 adds a mapping relationship between the LBA of the first data and the PBA of the third data in the FTL, and then deletes the mapping relationship between the LBA and PBA of the first data in the FTL. SSD100 can store the mapping relationship between the LBA and PBA of the first data in other storage areas within SSD100. For example, SSD100 can store the mapping relationship between the LBA and PBA of the first data in out-of-band (OOB) space. Each page in SSD100 has out-of-band space. SSD100 can store the mapping relationship between the LBA and PBA of the first data in the out-of-band space of the page where the PBA of the third data is located.

[0212] Furthermore, for the first data, the storage device 10 can also generate a data log, which records the access operations performed on the first data. This data log includes, but is not limited to, the type of access operation performed on the first data, the execution method of the access operation, and the execution time of the access operation. By analyzing the log of the first data, the storage device 10 can clearly understand each access operation performed on the first data. When data recovery is needed, the first data can be restored to its state at any previous point in time based on the log of the first data. For example, after updating the first data to the third data, if it is necessary to restore the third data to the first data, the storage device 10 can obtain the data log and learn from it what changes occurred during the update process, such as determining the physical address of the first data, and then reading the first data from its physical address.

[0213] The foregoing description describes updating the first data using an append-only write method. In practical applications, the first data can also be updated using an overwrite write method, which replaces the first data stored at the physical address of the first data with the third data. In this method, since the first data is replaced, meaning the old data is no longer retained in the storage device 10, after updating the first data to the third data, the system reverts to the first data based on the third data.

[0214] Step 514: Storage device 10 sends a third data write response to host 20, which indicates that the first data update was successful.

[0215] After updating the first data, storage device 10 can promptly notify host 20 that the first data update was successful through a third data write response.

[0216] Step 515: If updating the first data is not allowed, storage device 10 rejects the third data write instruction. Storage device 10 may notify host 20 that the first data update failed or that updating the first data is not allowed.

[0217] Taking storage device 10 as an example, when host 20 initiates a third data write request to update the first data to the third data, SSD 100 obtains the protection policy of the first data. If, based on the protection policy, it is determined that updating the first data is permitted, SSD 100 determines a third target block from the SSD 100. This third target block satisfies some or all of the two conditions mentioned above, namely: all data in the third target block is secure data; and the time difference between the expiration time of the protection period of the secure data in the third target block and the expiration time of the protection period of the third data is not greater than a first time threshold. Of course, in practical applications, SSD 100 can also select a blank block as the third target block.

[0218] SSD100 allocates a PBA for the third data within this block, and stores the third data on the PBA. SSD100 can record the mapping relationship between the LBA of the first data and the PBA of the third data in the FTL, delete the mapping relationship between the LBA and PBA of the first data, or mark the mapping relationship between the LBA and PBA of the first data as invalid. SSD100 can also record the protection policy for the third data, such as recording the protection policy for the third data in the FTL.

[0219] The above description uses the updating of first data by storage device 10 as an example. For ordinary data, such as second data, since there is no protection policy for ordinary data, storage device 10 can update the second data using an append-only method. For details on the append-only method, please refer to the aforementioned description; it will not be repeated here. Specifically, storage device 10 determines the storage unit for storing the updated second data. The method for determining this storage unit is similar to the method for determining the storage unit where the second data needs to be stored, as explained above; it will not be repeated here. After the second data is updated, it will become invalid.

[0220] Figure 5 The illustrated embodiments describe the process of reading or writing data within the current storage device 10. In this embodiment, the storage device 10 can also perform garbage collection.

[0221] Storage device 10 can periodically scan the data stored within it and mark invalid data. Invalid data may include invalid data notified by host 20, security data whose protection period has expired, old data before an update operation, and unused intermediate data. Storage units containing marked invalid data are candidate storage units for garbage collection.

[0222] When performing garbage collection, storage device 10 selects some or all of the candidate storage units for garbage collection according to a collection strategy (such as the Greedy algorithm, the Cost-Benefit algorithm, etc.). The collection strategy describes the method of selecting candidate storage units, and the collection strategy can be a Greedy algorithm, a Cost-Benefit algorithm, etc.

[0223] This application embodiment also defines the triggering method for the storage device 10 to perform garbage collection. For example, the storage device 10 can monitor its own storage space, and perform garbage collection when the free storage space of the storage device 10 is less than a capacity threshold. Another example is that the storage device 10 can monitor the data status within each storage unit, and perform garbage collection on that storage unit when all the data in that storage unit becomes invalid. Yet another example is that the host 20 can monitor the storage space of the storage device 10. If the storage device 10 is a storage device supporting OpenChannel or ZNS, the host 20 can determine the timing of garbage collection. For example, if the host 20 monitors that the free storage space of the storage device 10 is less than a capacity threshold, it sends a garbage collection command to the storage device 10 to instruct it to perform garbage collection. Yet another example is that the host 20 can monitor the data status within each storage unit, and send a garbage collection command to the storage device 10 when all the data in that storage unit becomes invalid, instructing it to perform garbage collection on that storage unit.

[0224] Based on the same inventive concept as the method embodiments, this application also provides a storage device for executing the method executed by the storage device 10 in the above method embodiments. For example... Figure 7 As shown, the storage device 700 includes an acquisition module 701, a determination module 702, and a storage module 703. Specifically, in the storage device 700, the modules are connected to each other through a communication path.

[0225] The acquisition module 701 is used to receive a first data write instruction, which is used to request the writing of first data.

[0226] Module 702 is used to determine a first target block, which satisfies some or all of the following conditions:

[0227] Condition 1: All data within the first target block is secure data.

[0228] Condition 2: The time difference between the first time and the second time is not greater than the first time threshold. Here, the first time is the expiration time of the protection period of the security data in the first target block, the second time is the expiration time of the protection period of the first data, the protection period of the security data is the time period during which access to the security data is restricted, and the protection period of the first data is the time period during which access to the first data is restricted.

[0229] Storage module 703 is used to store first data in the first target block.

[0230] As one possible implementation, the first data is secure data. The acquisition module 701 acquires the protection policy of the first data. The protection policy of the first data describes the access restrictions of the first data and includes the protection period of the first data.

[0231] As one possible implementation, the first data write instruction carries a protection strategy for the first data.

[0232] In one possible implementation, the acquisition module 701 receives a second data write instruction, which is used to request the writing of second data, which is not considered secure data.

[0233] The determination module 702 determines the second target block, which satisfies some or all of the following: the time difference between the expiration time of the security data in the second target block and the current time is less than the second time threshold, and the data in the second target block are not security data.

[0234] Storage module 703 stores the second data in the second target block.

[0235] As one possible implementation, the acquisition module receives a third data write instruction, which is used to request that the first data be updated to the third data.

[0236] If the protection policy of the first data indicates that updating the first data is permitted, module 702 determines a third target block, wherein the third target block satisfies some or all of the following conditions:

[0237] Condition 1: All data within the third target block is secure data;

[0238] Condition 2: The time difference between the third time and the fourth time is not greater than the first time threshold, where the third time is the expiration time of the protection period of the security data in the third target block, and the fourth time is the expiration time of the protection period of the third data.

[0239] Storage module 703 stores third data in the third target block.

[0240] As one possible implementation, the acquisition module 701 acquires the protection strategy of the third data, which includes the protection period of the third data.

[0241] As one possible implementation, the protection strategy for the third data is the same as the protection strategy for the first data, or the protection strategy for the third data is carried in the third data write instruction.

[0242] As one possible implementation, the acquisition module 701 receives a data read instruction, which is used to request the reading of first data.

[0243] Storage module 703 reads the first data from the first target block if the protection policy of the first data indicates that reading the first data is permitted.

[0244] As one possible implementation, after the protection period for all security data in the first target block expires, the storage module 703 marks the first target block as pending reclaim.

[0245] As one possible implementation, the storage module 703 determines the physical address of the third data in the third target block; the storage module 703 writes the third data to the physical address of the third data, records the mapping relationship between the logical address of the first data and the physical address of the third data, and deletes the recorded mapping relationship between the logical address of the first data and the physical address of the first data.

[0246] As one possible implementation, the first and second times are determined based on the SSD's clock.

[0247] The module division in this application embodiment is illustrative and only represents one logical functional division. In actual implementation, other division methods may be used. Furthermore, the functional modules in the various embodiments of this application can be integrated into a single processor, exist as separate physical entities, or be integrated into a single module. The integrated modules described above can be implemented in hardware or as software functional modules.

[0248] If the integrated module is implemented as a software functional module 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 this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a terminal device (which may be a personal computer, mobile phone, or network device, etc.) or processor to execute all or part of the steps of the methods in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0249] The descriptions of the processes corresponding to the above-mentioned figures each have their own emphasis. For parts of a process that are not described in detail, please refer to the relevant descriptions of other processes.

[0250] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented, in whole or in part, in the form of a computer program product. A computer program product includes computer program instructions, which, when loaded and executed on a computer, generate, in whole or in part, the product according to the embodiments of the present invention. Figure 3 The process or function described.

[0251] The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium may be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., SSD).

[0252] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A data access method, characterized by, The method is applied to a solid state drive (SSD) and includes the following steps. A first data write instruction is received, and the first data write instruction is used to request writing of first data. A first target block is determined, and the first target block meets one or more of the following conditions: Condition one: all data in the first target block is secure data. Condition two: a time difference between a first time and a second time is not greater than a first time threshold, wherein the first time is an expiration time of a protection period of secure data in the first target block, the second time is an expiration time of a protection period of the first data, the protection period of the secure data is a time period during which the secure data is restricted from being accessed, and the protection period of the first data is a time period during which the first data is restricted from being accessed. The first data is stored in the first target block.

2. The method of claim 1, wherein, The first data is secure data, and the method further includes the following steps. A protection policy of the first data is obtained, the protection policy of the first data describes access restriction of the first data, and the protection policy of the first data includes the protection period of the first data.

3. The method of claim 2, wherein, The protection policy of the first data is carried in the first data write instruction.

4. The method according to any one of claims 1 to 3, characterized in that, The method further includes the following steps. A second data write instruction is received, and the second data write instruction is used to request writing of second data, wherein the second data is not secure data. A second target block is determined, and the second target block meets one or more of the following conditions: a time difference between an expiration time of secure data in the second target block and a current time is less than a second time threshold, and all data in the second target block is not secure data. The second data is stored in the second target block.

5. The method according to any one of claims 1 to 4, characterized in that, The method further includes the following steps. A third data write instruction is received, and the third data write instruction is used to request updating of the first data to the third data. In a case where the protection policy of the first data indicates that the first data is allowed to be updated, a third target block is determined, and the third target block meets one or more of the following conditions: Condition one: all data in the third target block is secure data. Condition two: a time difference between a third time and a fourth time is not greater than the first time threshold, wherein the third time is an expiration time of a protection period of secure data in the third target block, and the fourth time is an expiration time of a protection period of the third data. The third data is stored in the third target block.

6. The method of claim 5, wherein, The method further includes the following steps. A protection policy of the third data is obtained, and the protection policy of the third data includes a protection period of the third data.

7. The method of claim 6, wherein, The protection policy of the third data is the protection policy of the first data, or the protection policy of the third data is carried in the third data write instruction.

8. The method according to any one of claims 1 to 7, characterized in that, The method further includes the following steps. A data read instruction is received, and the data read instruction is used to request reading of the first data. In a case where the protection policy of the first data indicates that the first data is allowed to be read, the first data is read from the first target block.

9. The method according to any one of claims 1 to 8, characterized in that, The method further includes the following steps. After the protection period of all secure data in the first target block expires, the first target block is marked as to be recycled.

10. The method of claim 5 or 6, wherein, The storing the third data in the third target block comprises: determining a physical address of the third data in the third target block; writing the third data at the physical address of the third data and recording a mapping relationship between the logical address of the first data and the physical address of the third data, and deleting the recorded mapping relationship between the logical address of the first data and the physical address of the first data.

11. The method according to any one of claims 1 to 10, characterized in that, The first time and the second time are determined based on a clock of the SSD.

12. A memory device, comprising: The storage device is deployed in a solid state disk (SSD), and the storage device comprises: The obtaining module is configured to receive a first data write instruction, the first data write instruction being used to request writing of first data. The determining module is configured to determine a first target block, the first target block satisfying one or more of the following conditions: Condition one, data in the first target block are all secure data; Condition two, a time difference between a first time and a second time is not greater than a first time threshold, wherein the first time is an expiration time of a protection period of the secure data, the second time is an expiration time of a protection period of the first data, the protection period of the secure data is a time period during which the secure data is restricted from being accessed, and the protection period of the first data is a time period during which the first data is restricted from being accessed. The storage module is configured to store the first data in the first target block.

13. The apparatus of claim 12, wherein, The first data is secure data, and the obtaining module is further configured to: obtain a protection policy of the first data, the protection policy of the first data describing access restriction of the first data, and the protection policy of the first data comprising the protection period of the first data.

14. The apparatus of claim 13, wherein, The first data write instruction carries the protection policy of the first data.

15. The apparatus of any one of claims 12-14, wherein: The obtaining module is further configured to receive a second data write instruction, the second data write instruction being used to request writing of second data, the second data not being secure data. The determining module is further configured to determine a second target block, the second target block satisfying one or more of the following conditions: a time difference between an expiration time of secure data in the second target block and a current time is less than a second time threshold, and data in the second target block are all non-secure data. The storage module is configured to store the second data in the second target block.

16. The apparatus of any one of claims 12-15, wherein: The obtaining module is further configured to receive a third data write instruction, the third data write instruction being used to request updating of the first data to third data. The determining module is further configured to, in a case where the protection policy of the first data indicates that the first data is allowed to be updated, determine a third target block, the third target block satisfying one or more of the following conditions: Condition one, data in the third target block are all secure data. A second condition is that a time difference between a third time and a fourth time is not greater than the first time threshold, wherein the third time is an expiration time of a protection period of the third target block, and the fourth time is an expiration time of the protection period of the third data; The storage module is further configured to store the third data in the third target block.

17. The apparatus of claim 16, wherein, The protection policy of the third data is the protection policy of the first data, or the protection policy of the third data is carried in the third data write instruction.

18. A computing device, comprising: The computing device includes a host and a storage device connected to the host; The host is configured to send a data read instruction to the storage device; The storage device is configured to perform the method in any one of claims 1 to 11.

19. A storage device, comprising: The storage device includes a host controller and a storage medium; The host controller is configured to perform the method in any one of claims 1 to 11. The storage medium is configured to store the first data.

20. A computer program product comprising computer programs or instructions, characterized in that, The computer program or instructions, when executed by a processing device, implement the method in any one of claims 1 to 11.