Method for accessing a storage device and related products

By acquiring the storage capacity of the storage device in real time and checking for partition table anomalies, and by using different access methods and mode switching flags, the problem of access failure when the storage device switches its working mode was solved, and normal access to the storage device was achieved after the mode switch.

CN116466871BActive Publication Date: 2026-11-06CHENGDU STARBLAZE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210459306.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2022-03-30
Filing Date
2022-04-27
Publication Date
2026-11-06
Estimated Expiration
2042-04-27

AI Technical Summary

Technical Problem

In existing technologies, when a storage device switches its operating mode, the change in storage capacity causes the host to be unable to correctly obtain the partition table, resulting in access failure.

Method used

When mode switching is implemented in the storage device, the host obtains the storage capacity in real time, checks for partition table anomalies, and accesses the storage space using different access methods, including direct access using the file system, block device, partition, or logical address. Combined with mode switching flags and backup partition tables, this ensures that the storage device can be accessed normally after mode switching.

Benefits of technology

When the operating mode of the storage device is switched, the host can successfully obtain the storage capacity, avoid partition table anomalies, and ensure the continuity and reliability of data access.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116466871B_ABST
    Figure CN116466871B_ABST
Patent Text Reader

Abstract

This application relates to a method and related products for accessing a storage device. The method includes initializing the storage device and obtaining its storage capacity; in response to determining that the storage capacity of the storage device has changed, checking whether the partition table of the storage device is abnormal; and in response to detecting an abnormality in the partition table, if a correct partition table is found at a specified location in the storage space of the storage device, accessing the storage space before the specified location using a first method, and accessing the storage space after the specified location using a second method. The technical solution of this application uses different methods to access the storage space at different locations within the storage device, thereby enabling accurate and efficient acquisition of the required data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application generally relates to the field of storage technology. More specifically, this application relates to methods for accessing storage devices, and hosts and computer-readable storage media for performing the aforementioned methods. Background Technology

[0002] Figure 1A A block diagram of a solid-state storage device (SSD) is shown. The SSD 102 is coupled to a host computer to provide storage capabilities. The host computer and the SSD 102 can be coupled in various ways, including but not limited to connections via SATA (Serial Advanced Technology Attachment), SCSI (Small Computer System Interface), SAS (Serial Attached SCSI), IDE (Integrated Drive Electronics), USB (Universal Serial Bus), PCIe (Peripheral Component Interconnect Express), NVMe (NVM Express), Ethernet, Fibre Channel, and wireless communication networks. The host computer can be an information processing device capable of communicating with the storage device via the above methods, such as a personal computer, tablet computer, server, laptop computer, network switch, router, cellular phone, or personal digital assistant. Storage device 102 (hereinafter referred to as storage device) includes interface 103, control unit 104, one or more NVM chips 105 and DRAM (Dynamic Random Access Memory) 110.

[0003] The aforementioned NVM chip 105 includes common storage media such as NAND flash memory, phase-change memory, FeRAM (Ferroelectric RAM), MRAM (Magnetic Random Access Memory), and RRAM (Resistive Random Access Memory).

[0004] The aforementioned interface 103 can be adapted to exchange data with the host via methods such as SATA, IDE, USB, PCIe, NVMe, SAS, Ethernet, and Fibre Channel.

[0005] The aforementioned control unit 104 is used to control data transmission between interface 103, NVM chip 105, and DRAM 110, and also for memory management, host logical address to flash physical address mapping, erase leveling, bad block management, etc. Control unit 104 can be implemented in various ways, including software, hardware, firmware, or combinations thereof. For example, control unit 104 can be in the form of an FPGA (Field-programmable gate array), ASIC (Application Specific Integrated Circuit), or a combination thereof. Control unit 104 may also include a processor or controller, in which software executes to manipulate the hardware of control unit 104 to process I / O (Input / Output) commands. Control unit 104 can also be coupled to DRAM 110 and can access data in DRAM 110. FTL tables and / or cached I / O command data can be stored in DRAM.

[0006] The control unit 104 includes a flash interface controller (or media interface controller, flash channel controller), which is coupled to the NVM chip 105. The flash interface controller issues commands to the NVM chip 105 in accordance with the interface protocol of the NVM chip 105 to operate the NVM chip 105, and receives the command execution results output from the NVM chip 105. Known NVM chip interface protocols include "Toggle", "ONFI", etc.

[0007] In storage device 102, an FTL (Flash Translation Layer) is used to maintain the mapping information from logical addresses (LBAs) to physical addresses. Logical addresses constitute the storage address space of the solid-state storage device as perceived by upper-layer software such as the operating system. Physical addresses are the addresses used to access the physical storage units of the solid-state storage device. In related technologies, address mapping can also be implemented using intermediate address formats. For example, a logical address can be mapped to an intermediate address, and then the intermediate address can be further mapped to a physical address. The table structure that stores the mapping information from logical addresses to physical addresses is called the FTL table. The FTL table is important metadata in the storage device. The entries in the FTL table record the address mapping relationships in the storage device, in units of data pages.

[0008] For some storage devices, the File Transfer Table (FTL) is provided by the host coupled to the storage device. The host's memory stores the FTL table, and the host's CPU executes the FTL software. In other cases, a storage management unit positioned between the host and the storage device provides the FTL. In these situations, the read / write commands received by the storage device indicate the physical address.

[0009] Commands provided by the host to the storage device may access the logical addresses corresponding to one or more entries in the FTL table. The control unit may also modify the format of commands received from interface 103 (e.g., split commands according to the size of the logical address space corresponding to the FTL entry) and process the modified commands. For clarity, this document describes the example of a read / write command received by the storage device accessing a single FTL entry.

[0010] Figure 1B This diagram illustrates a logical address space in the prior art. In the prior art, the logical address space is the storage address space provided by the storage device, and the host can use elements (logical addresses) in the logical address space to access the storage device. Generally, the size of the logical address (LBA) space that the host can access is the same as the size of the LBA space provided by the storage device. For the logical address space, the storage device manages the mapping between logical addresses and physical addresses through an FTL table.

[0011] Figure 1C A diagram illustrating host access to storage devices is shown. Figure 1C In this process, the host sends an I / O command (read / write command) to the storage device. The I / O command indicates the logical address (LBA address) to be accessed. The storage device translates the LBA address into a physical block address (PBA) based on the FTL table managed in the control unit. Then, the control unit accesses the NVM chip based on the PBA address.

[0012] With the continuous improvement of data storage technology, all kinds of data are stored in storage devices, such as user data, operating system data, application data, or data required for restoring the host to factory settings. In order to improve data security, some data should not be seen by users (such as data required for restoring the host to factory settings). This data can be hidden in the storage device. Hidden storage of data means that users or applications on the host side cannot see or access this data. Summary of the Invention

[0013] The data hidden in existing technologies is typically hidden from host applications but visible to the host operating system. If the operating system is compromised or misused, the hidden data is at risk of being tampered with or deleted. To improve the security of this hidden data, related technologies hide it from both host applications and the operating system. Normally, the host cannot access or modify the hidden data through applications or the operating system. Access is only possible when the data is needed, such as when the host needs to perform a factory reset. For example, the host can access the data hidden in the storage device to perform the reset.

[0014] Storage devices can be configured with different operating modes to meet various needs. For example, a storage device normally operates in hidden mode, while it switches to normal mode when data in hidden storage needs to be accessed. Furthermore, the storage capacity set in normal and hidden modes differs, with normal mode typically having a larger capacity than hidden mode. To access data in hidden storage or parts of hidden data, the storage device can switch between hidden and normal modes. Because different operating modes correspond to different storage capacities, the storage capacity obtained by the host from the storage device will change when switching between hidden and normal modes.

[0015] When a host accesses or writes data to a storage device, it needs to perform corresponding operations based on the partition table stored in the storage space of the storage device. This partition table is typically stored at the beginning and / or end of the storage space on the storage device. When the storage device switches from normal mode to hidden mode or vice versa, the storage capacity changes. When the host needs to access or write data to the storage device, it will not be able to find the partition table at the beginning or end of the storage space, resulting in access or data writing failure. Therefore, this application aims to enable the storage device to switch between hidden mode and normal mode, so that the host can still successfully access the storage device even when the storage capacity changes.

[0016] In order to successfully obtain the required data (e.g., data visible to the host or data hidden from the host), the solution provided in this application requires the host to determine whether the storage capacity of the storage device has changed after obtaining the storage capacity of the storage device, and to check whether the partition table of the storage device is normal when the storage capacity changes. Based on the specific situation of the partition table abnormality, different access methods are used to access the storage space of the storage device, so as to successfully obtain the required data from the storage device.

[0017] Furthermore, in the solution provided in this application embodiment, for the storage space portion that the host can access in both hidden mode and normal mode, the existing file system of the storage space portion can be used for access; while for the storage space portion that the host can only access in normal mode, the host cannot directly use the existing file system for access, but can use the created block device, partition or directly use the logical address of the portion to access it, thereby meeting the data access requirements when the storage capacity changes.

[0018] Furthermore, in the solution provided in this application embodiment, when the working mode of the storage device is switched from normal mode to hidden mode, the partition table backed up in hidden mode can be written back to a specified location and the header of the storage address space of the storage device, thereby avoiding partition table abnormalities caused by the change in the working mode of the storage device.

[0019] Furthermore, in existing technologies, the operating system is configured to trigger the initialization of the storage device and obtain its storage capacity during host startup, but this operation cannot be triggered at other times. In other words, during host operation, if the storage device's operating mode changes, causing a change in storage capacity, the host cannot detect this change and may still access the storage device based on the previous capacity. Since a change in storage capacity can cause partition table anomalies, leading to host access failures, this application's solution aims to ensure that the host can obtain the changed storage capacity in real time. The solution further allows for the registration of commands to adjust the storage device's operating mode, thus adjusting the timing of storage capacity acquisition. This allows the host to send an Identify command to the storage device at any time as needed to obtain its storage capacity.

[0020] Furthermore, the solution provided in this application embodiment can also be combined with a mode switching flag to differentiate and handle partition table errors. Specifically, if the correct partition table can be found at the specified location and the mode switching flag can be found, it indicates that the partition table error is caused by the storage device changing its operating mode. The host does not need to process this, and the partition table error can be ignored to avoid further processing by the host that could cause the storage device to malfunction. If the correct partition table is not found at the specified location or the mode switching flag is not found, it indicates a fault. In this case, an error is reported so that subsequent maintenance can be performed in a timely manner.

[0021] According to a first aspect of this application, a first method for accessing a storage device is provided, comprising: initializing the storage device and obtaining the storage capacity of the storage device; in response to determining that the storage capacity of the storage device has changed, checking whether the partition table of the storage device is abnormal; and in response to detecting that the partition table of the storage device is abnormal, if a correct partition table is found at a specified location in the storage space of the storage device, accessing the storage space before the specified location using a first method, and accessing the storage space after the specified location using a second method.

[0022] According to the first method for accessing a storage device according to the first aspect of this application, a second method for accessing a storage device according to the first aspect of this application is provided, wherein accessing storage space prior to the specified location using a first method includes: accessing the storage space prior to the specified location using a file system already existing in the storage space prior to the specified location.

[0023] According to the first method for accessing a storage device according to the first aspect of this application, a third method for accessing a storage device according to the first aspect of this application is provided, wherein accessing storage space after the specified location using a second method includes: creating a block device for the storage space after the specified location and accessing it according to the block device; or creating a partition for the storage space after the specified location and accessing it according to the partition; or directly accessing it according to the logical address of the storage space after the specified location.

[0024] According to the third method for accessing a storage device according to the first aspect of this application, a fourth method for accessing a storage device according to the first aspect of this application is provided, comprising creating a block device for storage space following the specified location and accessing the block device, including: creating the block device using the storage space following the specified location; mounting the block device to a specified path of a file system; and accessing the storage space following the specified location according to the specified path.

[0025] According to the third method for accessing a storage device according to the first aspect of this application, a fifth method for accessing a storage device according to the first aspect of this application is provided, comprising creating a partition of storage space following the specified location and accessing it according to the partition, including: updating the partition table of the storage device to create a partition corresponding to the storage space following the specified location; and accessing the storage space following the specified location from the partition.

[0026] According to one of the first to fifth methods for accessing a storage device according to the first aspect of this application, a sixth method for accessing a storage device according to the first aspect of this application is provided, further comprising: backing up a partition table at a designated location in the storage space before updating the partition table of the storage device; and writing the backed-up partition table back to the designated location in response to detecting that the operating mode of the storage device has switched to a hidden mode.

[0027] According to the sixth method for accessing a storage device according to the first aspect of this application, a seventh method for accessing a storage device according to the first aspect of this application is provided, further comprising: restoring an updated partition table in the storage device using a backup partition table.

[0028] According to the seventh method for accessing a storage device according to the first aspect of this application, an eighth method for accessing a storage device according to the first aspect of this application is provided, wherein restoring an updated partition table in the storage device using a backed-up partition table includes: writing the backed-up partition table back to the specified location and the header of the storage address space of the storage device.

[0029] According to one of the first to eighth methods for accessing a storage device according to the first aspect of this application, a ninth method for accessing a storage device according to the first aspect of this application is provided, further comprising: issuing a command to the storage device to trigger it to adjust its operating mode, wherein the command includes a mode switching command or a Set Feature command defined by the NVMe protocol.

[0030] According to the ninth method for accessing a storage device according to the first aspect of this application, a tenth method for accessing a storage device according to the first aspect of this application is provided, which, before issuing a command to the storage device to trigger its adjustment of its operating mode, further includes: registering the mode switching command to associate the mode switching command with an Identify command.

[0031] According to the tenth method for accessing a storage device according to the first aspect of this application, an eleventh method for accessing a storage device according to the first aspect of this application is provided, further comprising: in response to issuing the registered mode switching command to the storage device, sending the Identify command to the storage device to obtain the storage capacity of the storage device.

[0032] According to one of the ninth to eleventh methods for accessing a storage device according to the first aspect of this application, a twelfth method for accessing a storage device according to the first aspect of this application is provided, further comprising: recording a mode switching flag in response to issuing the mode switching command.

[0033] According to the twelfth method for accessing a storage device according to the first aspect of this application, a thirteenth method for accessing a storage device according to the first aspect of this application is provided, further comprising: in response to detecting a partition table anomaly of the storage device, if a correct partition table is found at a specified location in the storage space of the storage device and the mode switching flag is found, then ignoring the partition table anomaly error; or in response to detecting a partition table anomaly of the storage device, if a correct partition table is not found at a specified location in the storage space of the storage device, or the mode switching flag is not found, then reporting an error.

[0034] According to the twelfth method for accessing a storage device according to the first aspect of this application, a fourteenth method for accessing a storage device according to the first aspect of this application is provided, further comprising: determining a storage address space range of the storage device based on the storage capacity of the storage device; and, in response to issuing an IO command to the storage device, if the address of the storage space accessed after the specified location in the IO command exceeds the storage address space range of the storage device, refusing to issue the IO command to the storage device.

[0035] According to one of the twelfth to fourteenth methods for accessing a storage device according to the first aspect of this application, a fifteenth method for accessing a storage device according to the first aspect of this application is provided, further comprising: deleting the mode switching flag.

[0036] According to a second aspect of this application, a host is provided that implements one of the first to fifteenth methods for accessing a storage device according to the first aspect of this application.

[0037] According to a third aspect of this application, a computer-readable storage medium is provided, wherein when the program instructions are executed by a processor, one of the first to fifteenth methods for accessing a storage device according to the first aspect of this application is implemented. Attached Figure Description

[0038] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this application. For those skilled in the art, other drawings can be obtained based on these drawings.

[0039] Figure 1A A block diagram of a solid-state storage device is shown. Figure 1B A schematic diagram of the logical address space in the prior art is shown; Figure 1C This diagram illustrates a host accessing a storage device. Figure 1D This illustration shows a schematic diagram of the LBA space presented to the host by the hidden mode storage device provided in an embodiment of this application; Figure 2A This illustration shows a schematic diagram of the storage space visible to the host in hidden mode, as provided in an embodiment of this application. Figure 2B This illustration shows a schematic diagram of the storage space visible to a host in normal mode, as provided in an embodiment of this application. Figure 3 A flowchart illustrating a method for accessing a storage device provided in an embodiment of this application is shown. Figure 4 A flowchart illustrating another method for accessing a storage device provided in an embodiment of this application is shown; and Figure 5 A schematic diagram of the logical address space of the storage device provided in the embodiments of this application is shown. Detailed Implementation

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

[0041] To enhance the security of hidden storage data, the data stored in the storage device is hidden from host applications and the operating system. Under normal circumstances, the host cannot access or modify the hidden storage data through applications or the operating system; the host can only access the hidden storage data when needed. Therefore, in practical applications, storage devices can be configured with multiple operating modes, including at least hidden mode and normal mode. In hidden mode, the storage device provides a portion, not all, of its logical address space to the host, so the host only knows a portion of the storage device's logical address space. Furthermore, if the host attempts to access a portion of the logical address space that exists in the storage device but is not provided to the host, the storage device will reject such access requests and report an error.

[0042] Normal mode is a working mode that contrasts with the aforementioned hidden mode. Normal mode refers to a working mode where part or all of the hidden logical address space is visible to the host. That is, in the solution provided in this application embodiment, the size of the portion of the storage device's logical space known to the host dynamically changes depending on the storage device's mode. Optionally, in normal mode, the entire logical address space hidden in the hidden mode is provided to the host. In this case, the logical address space provided by the storage device to the host is the same as or smaller than the logical address space maintained internally by the storage device. Understandably, in some implementations, the portion of the hidden logical address space maintained by the storage device in the hidden mode is not visible to the host in either normal or hidden mode.

[0043] For ease of understanding and explanation, the embodiments of this application introduce the concepts of host-visible logical address space and logical address space. The logical address space (LBA space) is the storage address space provided by the storage device, and the host uses logical addresses, which are elements of this logical address space, to access the storage device. Since the storage device can switch between normal mode and hidden mode, in hidden mode, the storage device hides a portion of its logical address space from the host. Furthermore, the embodiments of this application introduce the concepts of host-visible logical address space (host-visible LBA space) and hidden logical address space (hidden LBA space) based on the logical address space. The host-visible logical address space is the storage address space within the logical address space that the storage device reports to the host and is accessed by the host as a block device, while the hidden LBA space is the storage address space within the logical address space in hidden mode that the storage device does not report to the host and cannot be accessed by the host as a block device.

[0044] Figure 1D This illustration shows a schematic diagram of the LBA space presented to the host by the hidden mode storage device provided in an embodiment of this application. For example... Figure 1D As shown, the LBA space includes a host-visible LBA space and a hidden LBA space, where the host-visible LBA space is part or all of the storage address space of the LBA space. For example, the host-visible logical address space provided in this embodiment is a dynamically variable storage address space. When the storage device is in normal mode, the application and / or operating system on the host can see or access the hidden LBA space. At this time, the host-visible logical address space is the entire logical address space, and its size is the same as the size of the logical address space. When the storage device is in hidden mode, the hidden LBA space is an "LBA space" that is not visible or accessible to the application and / or operating system on the host. At this time, the host-visible logical address space is a portion of the logical address space, and its size is smaller than the logical address space.

[0045] The following combination Figure 2A and Figure 2B This section explains how the host obtains storage space information from the storage device under different operating modes.

[0046] Figure 2A This illustration shows a schematic diagram of a host obtaining storage space information of a storage device in a hidden mode, as provided in an embodiment of this application. Figure 2A As shown, when the host initializes the storage device, such as during startup, it can obtain storage space information of the storage device, such as the storage capacity provided by the storage device and the starting address of the hidden storage space. For example, when a storage device is delivered to a customer, it can be in hidden mode. This means that part of the storage device's LBA space is visible to the host (called the host-visible LBA space), which is the LBA space accessible in the host's I / O commands to the storage device. Another part is invisible to the host (called the hidden LBA space), which is the LBA space that the host cannot access or that the host application, operating system, or file system is unaware of.

[0047] For example, see Figure 2AThe storage device has an LBA (Logical Address Space) size of 356GB. The size of the LBA visible to the host and the size of the hidden LBA can be set during the storage device manufacturing stage. For example, the host-visible LBA might be 256GB, and the host-hidden LBA might be 100GB. The host-hidden LBA is located after the host-visible LBA, meaning it exists within the logical address space maintained by the storage device. The logical address range of the host-visible LBA is 0-256GB, and the logical address range of the host-hidden LBA is 256GB-356GB. The host-visible LBA can store user data / operating system / applications, while the host-hidden LBA can store data needed for a factory reset. In hidden mode, the storage device's storage capacity is set based on the host-visible LBA size; in this case, the storage device's storage capacity is set to 256GB. When the host initializes the storage device, it obtains the storage space information of the storage device. For example, the host can obtain the storage capacity of the storage device as 256GB and / or the starting address of the hidden LBA space as LBA=256GB. When the host obtains the storage capacity of the storage device as 256GB, the host knows that its accessible logical address space is 0-256GB. The host operating system, applications, or disk manager can access the data in the range of 0-256GB in the logical address space of the storage device. However, the host operating system, applications, or disk manager cannot access the data in the range of 256GB-356GB in the logical address space of the storage device. Therefore, in hidden mode, the logical address space of the storage device from 256GB to 356GB is invisible to the host operating system, applications, or disk manager.

[0048] Figure 2B This illustration shows a schematic diagram of a host obtaining storage space information of a storage device in normal mode, as provided in an embodiment of this application. Figure 2B The normal mode mentioned in the text is relative to Figure 2AIn hidden mode, the host cannot access the hidden LBA space. In normal mode, the storage device sets its storage capacity based on both the visible LBA space and the hidden LBA space; for example, the storage device might be set to 356GB. When the host initializes the storage device and obtains its storage space information (e.g., the host knows the storage capacity is 356GB), it understands that the accessible logical address space is 0-356GB. The host operating system, applications, or disk manager can then access data within this range. Therefore, in normal mode, the host can access not only the visible LBA space but also the hidden LBA space. In other words, in normal mode, the host can access the entire LBA space of the storage device.

[0049] Additionally, metadata (such as partition tables) in some storage systems is recorded at the beginning and end of the storage space provided by the storage device. For example, in hidden mode, if the storage device provides a storage capacity of 256GB, the metadata will be stored at the end of the 256GB space. From the above... Figure 2A and Figure 2B It can be seen that the storage capacity of a storage device changes under different operating modes. When the storage device mode is switched (from hidden mode to normal mode), the LBA space of the storage device changes from 256GB to 356GB. During the host's access to the storage device, due to the increased storage capacity, the original metadata is no longer present at the end of the changed storage space. After the operating system recognizes the storage device size as 356GB, it attempts to retrieve metadata (such as the partition table) from the end of the LBA space (around 356GB), but the retrieval fails, indicating an anomaly in the storage device's partition table. Since this failure to retrieve metadata is caused by switching the storage device's operating mode, this application aims to minimize the problem of host access failure due to metadata retrieval failure caused by storage device operating mode switching. Therefore, this application provides the following solution for accessing the storage device.

[0050] Figure 3 A flowchart illustrating a method 300 for accessing a storage device according to an embodiment of this application is shown. Figure 3As shown, in step S301, the storage device can be initialized and its storage capacity can be obtained. In one implementation, the host can obtain the storage capacity by querying the storage device (the specific process for obtaining the storage capacity is described below). Therefore, the host can determine the storage capacity of the storage device based on the LBA address range visible to the host. By obtaining the storage capacity, it is possible to determine whether the storage device should switch its operating mode.

[0051] In step S302, in response to determining that the storage capacity of the storage device has changed, the partition table of the storage device can be further checked for abnormalities. For example, the partition table can be detected from the tail region of the LBA space visible to the host provided by the storage device. If the partition table cannot be found, it indicates an abnormality. For example, the change in storage capacity mentioned here refers to a change in the storage capacity obtained during the current initialization of the storage device compared to the storage capacity obtained during the previous initialization. As another example, the host typically initializes the storage device during the host startup phase.

[0052] In step S303, in response to detecting an anomaly in the partition table of the storage device, if the correct partition table is found at a specified location in the storage space of the storage device, the storage space before the specified location is accessed using a first method, and the storage space after the specified location is accessed using a second method. It can be understood that the specified location in this invention can be understood as the tail region of the LBA space provided by the storage device in hidden mode, which is visible to the host. Therefore, the storage space before the specified location is visible to the host, while the storage space after the specified location is visible to the host in normal mode but hidden from the host in hidden mode. For example, Figure 2A and Figure 2B In this context, the LBA space size of the storage device is 356GB. The LBA space visible to the host is 256GB (0~256GB), and the hidden LBA space is 100GB (256GB~356GB). The specified location can be understood as the 256GB partition location, with the storage space before the specified location being 0~256GB, and the storage space after the specified location being 256GB~356GB.

[0053] According to an embodiment of this application, when an anomaly in the storage device partition table is detected, it indicates that the partition table cannot be found in the tail region of the LBA space visible to the host provided by the storage device in the current operating mode. However, the correct partition table can be found at the aforementioned specified location. This indicates that the storage capacity obtained by the host from the storage device has increased, and the increased storage capacity is due to the storage device switching from hidden mode to normal mode. Furthermore, because the storage capacity of the storage device has increased, especially the logical address space corresponding to the specified location, it cannot be accessed using the same access method as the logical address space corresponding to the preceding location, such as the file system method.

[0054] As an example, accessing storage space prior to a specified location can be achieved by using an existing file system within that storage space. As described earlier, this storage space is always visible to the host; that is, the host's file system records information about this storage space. Therefore, existing file systems can be used directly for access.

[0055] For example, accessing the storage space after a specified location can take many forms. As described above, the storage space after this specified location is hidden from the host in hidden mode, but visible to the host in normal mode. Therefore, the host's file system does not record information about the storage space after this specified location, and cannot directly access this portion of the storage space using the file system.

[0056] As one implementation, a block device can be created for the storage space following the specified location, and access can be made using this block device. Specifically, the block device can be created using the aforementioned storage space following the specified location. Then, the block device is mounted to a specified path in the file system, and the storage space following the specified location is accessed based on that specified path.

[0057] As another implementation, partitions can be created for the storage space beyond the specified location, and access can be made based on these partitions. Specifically, the partition table of the storage device can be updated to create partitions corresponding to the storage space beyond the specified location, allowing access to the storage space beyond the specified location from these partitions. When the storage device switches from hidden mode to normal mode, the storage capacity provided by the storage device increases. When creating partitions for the storage space beyond the specified location and accessing the storage space beyond the specified location based on these partitions, the existing partition table needs to be updated to obtain an updated partition table. The updated partition table can access the increased storage space.

[0058] As another implementation method, the storage space can also be accessed directly based on the logical address of the location following the specified location. For example, the logical address range corresponding to the storage space following the specified location is 256GB-356GB. Therefore, subsequent access can be performed directly using the corresponding logical address.

[0059] As an example, further, before updating the partition table of the storage device, the partition table can be backed up at a specified location in the storage space. This backup can then be written back to the specified location when the storage device's operating mode is detected to have switched to hidden mode. This ensures that when the storage device switches back to hidden mode, the host can find the partition table in hidden mode and access the storage device based on the partition table in hidden mode.

[0060] As an example, further, the updated partition table in the storage device can be restored using the backup partition table. Specifically, the backup partition table can be written back to a specified location and the header of the storage device's storage address space. This ensures that the storage device can function normally after switching from normal mode to hidden mode.

[0061] As an example, further, in order to control the storage device to switch operating modes, the host can also issue a command to the storage device to trigger it to adjust its operating mode. In one implementation, this command may include a mode switching command. This mode switching command is a custom command, not a command defined by a protocol. However, the format of the mode switching command conforms to a protocol (such as the NVMe protocol). For example, the mode switching command includes a "command code" and optionally "command parameters." The command code has a specified value to indicate that the current command is a mode switching command. The host specifies the content of the mode switching command or the parameter value. For example, the mode switching command provided by the host to the storage device only includes the command code (without specifying command parameters). The storage device identifies the received command as a mode switching command based on the command code and changes the current mode of the storage device; for example, if the storage device is currently in hidden mode, it changes to normal mode in response to receiving the mode switching command; and / or if the storage device is currently in normal mode, it changes to hidden mode in response to receiving the mode switching command. In yet another example, the mode switching command provided by the host to the storage device includes both a command code and command parameters. The storage device identifies the received command as a mode switching command based on the command code, and then determines the mode to be entered based on the command parameters. For example, a command parameter of 0 indicates a switch from hidden mode to normal mode, while a command parameter of 1 indicates a switch from normal mode to hidden mode.

[0062] The host defines the content of the mode switching command to instruct the storage device to perform a working mode switching operation after receiving the mode switching command, or to configure the parameters of the mode switching command. For example, the host instructs the storage device to perform a working mode switching operation after receiving the mode switching command by setting the value of the command parameter in the mode switching command.

[0063] When the host defines the content of the mode switching command, the storage device switches its current operating mode according to the command. For example, in response to receiving the mode switching command in normal mode, the storage device switches from normal mode to hidden mode; or in response to receiving the mode switching command in hidden mode, the storage device switches from hidden mode to normal mode. When the host configures the command parameters of the mode switching command, the storage device switches its operating mode according to the value of the command parameters. For example, the host configures the command parameters of the mode switching command based on the current operating mode of the storage device. For instance, if the current operating mode of the storage device is hidden mode, and the command parameter is configured to 0 to control the storage device to switch to normal mode, the storage device switches to normal mode according to the command parameter value; if the current operating mode of the storage device is normal mode, and the command parameter is configured to 1 to control the storage device to switch to hidden mode, the storage device switches to hidden mode according to the command parameter value.

[0064] As an example, the specific format of the host-defined mode switching command can also include a command code and two or more command parameters to implement more functions.

[0065] In one implementation, a mode switching command, carrying different command parameters, instructs the storage device to: set to hidden mode, set to normal mode, and set the size of the hidden LBA space. The functions of setting to hidden mode and normal mode are suitable for use during storage device operation, while the function of setting the size of the hidden LBA space is suitable for use during storage device manufacturing to provide users with a storage device having a specified size of hidden space. When the mode switching command instructs the user to set the size of the hidden LBA space, further command parameters describe the value of the hidden LBA space size.

[0066] Furthermore, a command parameter of the mode switching command indicates the length of data to be transmitted in the current command, to meet the requirements of the host and storage device. The host and / or storage device determine whether the processing of the current command is complete by recognizing the length of data to be transmitted in the command parameter. Since the mode switching command does not require data transmission between the host and storage device, this command parameter is set to 0 in the mode switching command.

[0067] Similarly, another command parameter of the mode switching command is used to indicate the length of the metadata to be transmitted by the current command. In the embodiments according to this application, this command parameter is also set to 0 in the mode switching command.

[0068] When the mode switching command instructs the setting of the hidden LBA space size, it also indicates, for example, whether to initialize the hidden LBA space, whether the hidden LBA space needs to be aligned to 4KB, through one or more command parameters.

[0069] As another implementation, the aforementioned command that triggers the storage device to adjust its operating mode can also be the Set Feature command defined by the NVMe protocol. The NVMe protocol's Set Feature command can set various different "features" through command parameters. For a specific storage device, some "features" are not supported, so when it receives a Set Feature command for such a feature, it does not need to process it. Thus, the Set Feature command indicating such a feature can be used as a mode switching command, without the need to add a new command.

[0070] For example, "LBA Range Type" is one of the features that the Set Feature command can indicate, but some current storage devices do not support this feature. Therefore, the Set Feature command with the "LBA Range Type" command parameter is used as the mode switching command according to embodiments of this application. For this purpose, in addition to carrying the "LBA Range Type" command parameter, the Set Feature command also carries one or more command parameters to instruct the storage device to: set to hidden mode, set to normal mode, and set the size of the hidden LBA space. Furthermore, when the mode switching command instructs the setting of the hidden LBA space size, one or more command parameters also indicate, for example, whether to initialize the hidden LBA space, whether the hidden LBA space needs 4KB alignment, etc. Specifically, the "Data Structure Entry" field of the Set Feature command with the "LBA Range Type" command parameter is used to describe one or more parameters used for the mode switching command.

[0071] In another example, the Set Feature command indicates two logical address ranges: LBA0~LAB100 and LBA200~LBA300. This application embodiment, based on the existing NVMe protocol's definition that the Set Feature command can indicate one or more logical address ranges, further sets the one or more logical address ranges indicated by the Set Feature command to be either host-accessible or host-inaccessible, thereby enabling the hiding or display of a portion of the storage device's logical address space from the host. Furthermore, the operating mode of the storage device and the storage capacity can be set according to the one or more logical address ranges indicated by the Set Feature command. For example, these one or more logical address ranges can be set by the user using the Set Feature command. Understandably, in some implementations, the user can also directly set the Set Feature command defined by the NVMe protocol, so that the Set Feature command instructs the storage device to switch modes; that is, after receiving the Set Feature command, the storage device enters or exits hidden mode according to the switching mode indicated by the Set Feature command.

[0072] For example, when retrieving the storage capacity of a storage device, for storage devices conforming to the NVMe protocol, the host can send an Identify command to the storage device and obtain the storage capacity from the command's response. In existing technology, the host triggers the initialization of the storage device and retrieves its storage capacity during startup, but typically does not actively trigger this operation at other times. That is, during host operation, when the storage device's operating mode changes, causing a change in storage capacity, the host's components, including the operating system and file system, are unaware of the change and continue to access the storage device based on the previous capacity. Since a change in storage capacity can cause partition table anomalies, leading to access failures or the host being unable to use the increased storage space due to a lack of awareness of the increased capacity, a further approach can be taken. To ensure that the host can retrieve the changed storage capacity in real time, for example, the mode-switching command can be registered before issuing it, associating it with a specified command (e.g., the Identify command). Registration is a function provided by the host's operating system or the storage device driver. By registering, the mode switching command is associated with the specified command. After the host issues a mode switching command, the operating system or storage device driver will automatically issue the registered specified command to the storage device. This adjusts the timing of the Identify command, so that after sending the registered mode switching command to the storage device, the host can send the Identify command to the storage device at any time as needed to obtain its storage capacity.

[0073] The Identify command can specify various command parameters. As an example, when the storage device does not support "NameSpace," an Identify command specifying the "NameSpace" parameter is used to obtain the storage capacity of the storage device, or further obtain additional information related to the hidden LBA space. Thus, the storage device's processing of Identify commands with other command parameters is not changed, ensuring the storage device meets the requirements for NVMe protocol compatibility. According to embodiments of this application, when the storage device processes an Identify command specifying the "NameSpace" parameter, information about the hidden logical address space is added to the result of the Identify command. Optionally, since the storage device does not support "NameSpace," the NSID of "NameSpace" is set to, for example, NS0 in an Identify command specifying the "NameSpace" parameter.

[0074] As another example, when using the Set Feature command indicating "LBA Range Type" as a mode switching command, the Get Feature command indicating "LBA Range Type" can be used accordingly to obtain the current operating mode of the storage device (normal mode or hidden mode), and optionally the size of the hidden LBA space. The Set Feature command indicating "LBA Range Type" is also registered to be associated with mode switching commands.

[0075] According to embodiments of this application, mode switching commands are indicated by custom commands or by existing commands in the standard, thereby providing new or different functions for the commands. The storage devices coupled to the host may come from different manufacturers or batches, and therefore may or may not support mode switching commands. Support is needed to assist the host in identifying whether the storage device supports mode switching commands. As another example, the effects of commands sent by the host to the storage device, such as NVMe commands or custom commands, can be reflected through a Log page. A "Log Page" is a data structure defined by the NVMe protocol that reflects the effects of the storage device processing each command. The data corresponding to each command in the "Log Page" reflects the differences in the effects of command processing between different storage devices. For example, one storage device may change its storage capacity after processing a SetFeature command indicating "LBA Range Type," while another storage device may not; or, for another example, one storage device may change its storage capacity after processing a custom mode switching command, while another storage device may not support the custom mode switching command. Therefore, the effects of commands can be obtained through the Log page, allowing identification of whether one or more storage devices connected to the host support hiding portions of the logical address space. Specifically, the host sets an identifier in the Log page for mode-switching commands to indicate their effects, and returns the relevant identifier upon receiving a GetLog Page command in the NVMe protocol (to retrieve the Log page for the corresponding mode-switching command). For example, in the data of the corresponding mode-switching command in the Log Page, the CSUPP / LBCC / NCC / NIC / CCC / CSE fields specified by the NVMe protocol are all set to 1.

[0076] Before issuing a mode switching command to a storage device, the host first queries the storage device using the Get Log age command. If it finds that the mode switching command for a certain storage device will change the storage capacity, it registers the mode switching command for that storage device in the operating system or the storage device driver accordingly, associating it with the Identify command, the Get Feature command indicating "LBARange Type", etc. If it finds that the mode switching command for a certain storage device will not change the storage capacity, it will not register the mode switching command for that storage device.

[0077] After registering the mode switching command, the host can obtain the storage capacity of the storage device by issuing commands such as Identify namespace or Get Feature after the driver captures the issuance of the mode switching command.

[0078] As an example, a mode switch flag can be recorded when the mode switch command is issued. This allows for easier identification of partition table anomalies later, confirming that the anomaly was caused by a mode switch on the storage device. This enables appropriate handling of the anomaly, such as ignoring it. Alternatively, the mode switch flag can be deleted as needed to meet different user requirements.

[0079] As an example, further, when a partition table anomaly is detected on a storage device, if the correct partition table is found at a specified location along with a mode switch marker, it can be further confirmed that the partition table anomaly is caused by a storage device mode switch, and the partition table anomaly error can be ignored. If the correct partition table or mode switch marker is not found at a specified location in the storage space of the storage device, it indicates that some storage fault may have caused the partition table anomaly. In this case, an error should be reported to facilitate timely maintenance.

[0080] In an optional implementation, during the issuance of an I / O command to a storage device in hidden mode, if the address of the storage space accessed after the specified location in the I / O command exceeds the storage address space range of the storage device, the host's storage device driver will refuse to issue the I / O command to the storage device to avoid errors and unnecessary command sending and processing, effectively saving system resources. Optionally or further, if, for some reason (e.g., virus infection), the host issues an I / O command to the hidden mode storage device to access the hidden LBA space, the storage device will also refuse to process such I / O commands and report an error to the host, such as an out-of-bounds logical address access error.

[0081] Optionally, the storage device may refuse to process erase and / or format commands to the hidden LBA space to protect the data in that space. For example, in hidden mode, the storage device refuses to process erase and / or format commands to the hidden LBA space; while in normal mode, the storage device may execute erase and / or format commands to the hidden LBA space after verifying the host's permissions, and delete the data in the hidden LBA space in response. In yet another example, after the storage device is manufactured and the required data is written to the hidden LBA space, it may never accept erase and / or format commands from the host to ensure the continued availability of the data in the hidden LBA space. Understandably, for wear leveling, data reliability, and other requirements, the control unit within the storage device may perform garbage collection on the physical address corresponding to the hidden LBA space, but ensure the validity of the data in the hidden LBA space.

[0082] Optionally, the operating mode of the storage device (hidden mode or normal mode) should not change due to power-on / off. Alternatively, a hidden mode-first approach can be adopted: storage devices in hidden mode remain in hidden mode after a restart; while storage devices in normal mode enter hidden mode after a restart, thus improving the security of the hidden LBA space. After power-on / off or restart of the storage device, information such as the size of the hidden LBA space and Log Page remains unchanged.

[0083] Figure 4 This document illustrates a flowchart of another method 400 for accessing a storage device provided in an embodiment of this application. It should be noted that method 400 can be understood as a further refinement and supplement to the various steps of method 300. Therefore, the preceding text, in conjunction with... Figure 3 The detailed descriptions in the text also apply to the following text.

[0084] like Figure 4 As shown, in step S401, the host is started. Specifically, this includes loading the host system's OS kernel, etc. In step S402, the storage device can be initialized, and its storage capacity can be obtained. For example, the host can send an Identify command or a get feature command to the storage device to obtain the storage capacity returned by the storage device. The Identify command can be sent during the host startup or restart phase, or at any time after a registered mode switching command is issued.

[0085] In step S403, the secondary GTP partition table can be checked for normality. If normal, proceed to step S404 to complete the file system startup. If abnormal, proceed to step S405.

[0086] The following combination Figure 5 The detection process for the partition table is further explained.

[0087] Figure 5 A schematic diagram illustrating the logical address space of the storage device provided in an embodiment of this application is shown. Figure 5 As shown, the logical address space of the storage device is LBA0~LBAm, of which the logical address space visible to the host is LBA0~LBAn, while the hidden logical address space is LBAn~LBAm. The Protective MBR is the Protective Master Boot Record, and the Globally Unique Partition Table (GUID Partition Table, GPT) is divided into the Primary GPT at the head and the Secondary GPT at the tail. As mentioned earlier, when the operating mode of the storage device changes, the storage address space visible to the host changes under different operating modes (normal mode or hidden mode). For example, when the storage device mode is switched (e.g., from hidden mode to normal mode), the LBA space of the storage device becomes 356GB, and the original secondary GPT partition table is no longer present at its tail. After the operating system recognizes that the storage device size is 356GB, it will attempt to retrieve the secondary GPT partition table from the tail of the LBA space (near 356GB). At this point, the retrieval of the secondary GPT partition table fails, indicating an anomaly has been detected. In some embodiments, if retrieving the secondary GTP partition table fails, a message may be displayed indicating that the secondary GTP partition table is missing. In practical applications, users can simply ignore this message.

[0088] After detecting an anomaly in the secondary GTP partition table, return Figure 4 Next, in step S405, it can be checked whether a secondary GTP partition table exists at a specified location. As mentioned above, the specified location can be understood as the tail region of the LBA space visible to the host provided by the storage device in hidden mode. A secondary GTP partition table is stored at the specified location in hidden mode. If the secondary GTP partition table is found to exist, step S406 can be continued. If the secondary GTP partition table is not found, it indicates that the storage device may be malfunctioning.

[0089] In step S406, the presence of a mode switching flag can be detected. In some embodiments, when the host issues a command to the storage device to trigger a change in its operating mode (e.g., a mode switching command or a Set Feature command), a mode switching flag is recorded. Therefore, this mode switching flag can be used to determine whether the storage device has changed its operating mode. If the mode switching flag exists, it indicates that the storage device has switched from hidden mode to normal mode, and can access the storage space after the specified location (i.e., the logical address space hidden in hidden mode), which can be accessed specifically through step S407. If the mode switching flag does not exist, it indicates that the storage device may be malfunctioning.

[0090] In step S407, hidden data can be accessed by creating a new partition or block device, or directly by accessing the hidden data through the logical address of the storage space after the specified location. The specific access process can be found in the preceding descriptions and will not be repeated here. Thus, precise and effective access to data in different storage spaces within the storage device can be achieved through different methods, especially effective access to data in the storage space after the specified location.

[0091] This application also provides a host computer, including a processor; and a memory storing computer instructions for accessing a storage device, causing the host computer to execute... Figure 3 and Figure 4 Related solutions. Additionally, this application also provides a computer-readable storage medium that, when program instructions are executed by a processor, enables the implementation of... Figure 3 and Figure 4 Related solutions.

[0092] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application. Clearly, those skilled in the art can make various alterations and variations to this application without departing from its spirit and scope. Thus, 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 method for accessing a storage device, characterized in that, include: Initialize the storage device and obtain its storage capacity; In response to determining that the storage capacity of the storage device has changed, check whether the partition table of the storage device is abnormal; as well as In response to detecting an anomaly in the partition table of the storage device, if the correct partition table is found at a specified location in the storage space of the storage device, the storage space before the specified location is accessed using a first method, and the storage space after the specified location is accessed using a second method; wherein, the first method is a file system method; the second method is different from the first method.

2. The method according to claim 1, characterized in that, The storage space prior to accessing the specified location using the first method includes: Access the storage space prior to the specified location using the file system that already exists in the storage space prior to the specified location.

3. The method according to claim 1, characterized in that, Accessing the storage space after the specified location using the second method includes: Create a block device for the storage space following the specified location, and access it based on the block device; or Create a partition for the storage space following the specified location, and access the partition accordingly; or Access the storage space directly based on the logical address following the specified location.

4. The method according to claim 3, characterized in that, Creating a partition for the storage space following the specified location, and accessing the partition accordingly, includes: Update the partition table of the storage device to create the partition corresponding to the storage space after the specified location; and Access the storage space following the specified location from the partition.

5. The method according to claim 4, characterized in that, Also includes: Before updating the partition table of the storage device, back up the partition table at a specified location in the storage space; as well as In response to detecting that the operating mode of the storage device has switched to hidden mode, the backed-up partition table is written back to the specified location.

6. The method according to any one of claims 1 to 5, characterized in that, Before issuing a command to the storage device to trigger it to adjust its operating mode, the method further includes: In response to the command to adjust the working mode being a mode switching command, the mode switching command is registered to associate the mode switching command with the Identify command.

7. The method according to claim 6, characterized in that, Also includes: In response to issuing the mode switching command, a mode switching flag is recorded.

8. The method according to claim 7, characterized in that, Also includes: In response to detecting a partition table anomaly in the storage device, if the correct partition table is found at a specified location in the storage space of the storage device and the mode switching flag is found, then the partition table anomaly error is ignored. or In response to the detection of an anomaly in the partition table of the storage device, if the correct partition table is not found at a specified location in the storage space of the storage device, or if the mode switching flag is not found, an error is reported.

9. The method according to any one of claims 1 to 5, characterized in that, Also includes: The storage address space range of the storage device is determined based on its storage capacity. as well as In response to an I / O command to be issued to the storage device, if the address of the storage space accessed in the I / O command after the specified location exceeds the storage address space range of the storage device, the I / O command is rejected from being issued to the storage device.

10. A host computer, characterized in that, include: processor; as well as A memory storing computer instructions for accessing a storage device, which, when executed by the processor, cause the host to perform the method according to any one of claims 1-9.

Citation Information

Patent Citations

  • Partitioned namespaces in solid state drives

    CN113196226A

  • Apparatus and method for controlling booting operation of computer system

    CN1591359A