M.2 SSD hot-swappable processing methods, electronic devices, storage media, and software products
By determining the power identifier of the M.2 SSD and entering read-only mode to complete the write request, combined with the power identifier and LED prompts, the problem of hard drive damage and data loss during the hot-swapping process of M.2 SSDs is solved, and a safe and reliable plugging and unplugging process is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- INNOGRIT TECH CO LTD
- Filing Date
- 2025-07-24
- Publication Date
- 2026-06-30
AI Technical Summary
Existing M.2 SSDs pose a risk of hard drive damage and data loss during hot-swapping, and their reliability and security cannot be guaranteed.
By checking the power indicator of the M.2 SSD, it determines whether a hot-swapping operation is required, puts it into read-only mode to complete the old write requests, and then prompts the user to perform a hot-swapping operation. This ensures that data writing is completed before the SSD is removed, and uses the power indicator and LED indicators to tell the user which SSD needs to be removed.
It enables safe hot-swapping of M.2 SSDs without damaging the hard drive, avoiding data loss and improving the reliability and safety of the insertion and removal process.
Smart Images

Figure CN120950433B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of hot-swappable technology, and more particularly to an M.2 SSD hot-swappable processing method, electronic device, storage medium, and software product. Background Technology
[0002] In certain applications of M.2 SSDs (Solid State Disks), such as using M.2 SSDs in NVMe (non-volatile memory express) RAID (redundant arrays of independent disks) cards, there is a need for hot-swapping M.2 SSDs. That is, when using an M.2 SSD in an NVMe RAID card, there is a need to be able to remove a faulty M.2 SSD and insert a new or spare one without shutting down the system or disconnecting the power.
[0003] However, M.2 SSDs do not support hot-swapping. If an M.2 SSD is forcibly hot-swapped, the chances of hard drive damage and data loss are high. Therefore, the existing M.2 protocol itself cannot guarantee the reliability of M.2 SSD hot-swapping, which may lead to problems such as hard drive damage and data loss during M.2 SSD hot-swapping.
[0004] Therefore, how to achieve hot-swapping of M.2 SSDs more reliably and securely is one of the problems that needs to be solved. Summary of the Invention
[0005] In view of this, this disclosure proposes an M.2 SSD hot-swapping method, electronic device, storage medium, and software product, thereby enabling more reliable and secure hot-swapping of M.2 SSDs.
[0006] According to a first aspect of this disclosure, a hot-swapping method for an M.2 SSD is provided, comprising: a determination step, determining whether a hot-swapping operation of the first M.2 SSD needs to be performed based on the power identifier of the first M.2 SSD inserted into the target device; a processing step, if it is determined that a hot-swapping operation of the first M.2 SSD needs to be performed, causing the first M.2 SSD to enter a read-only mode indicating that the first M.2 SSD cannot receive new write requests from the target device, and continuing to complete write operations for old write requests already received from the target device; and a prompting step, prompting the user that a hot-swapping operation of the first M.2 SSD is currently possible.
[0007] In one possible implementation, the determination step includes: acquiring the power identifier of the first M.2 SSD in real time; determining whether the value of the currently acquired power identifier is a first value indicating that the first M.2 SSD needs to be hot-swapped; if it is determined that the value of the acquired power identifier is the first value, then it is determined that the first M.2 SSD needs to be hot-swapped.
[0008] In one possible implementation, the determination step includes: acquiring the power identifier of the first M.2 SSD in real time; determining whether the value of the currently acquired power identifier is consistent with the value of the power identifier set for the first M.2 SSD when powering on and initializing the first M.2 SSD; if the determination is inconsistent, determining that the first M.2 SSD needs to be hot-swapped.
[0009] In one possible implementation, the processing steps include: if it is determined that a hot-swapping operation is required for the first M.2 SSD, then the first M.2 SSD is put into read-only mode, and it is determined whether there is first data written to the temporary storage module in the data corresponding to the old write request; if it is determined that the first data exists, then the first data stored in the temporary storage module is written to the flash memory of the first M.2 SSD to continue to complete the write operation for the old write request, wherein the prompting step is executed after the write operation for the old write request is completed.
[0010] In one possible implementation, the prompting step includes: after completing the write operation for the old write request, causing the first M.2 SSD to enter a quasi-hot-out mode from the read-only mode and making the prompt, wherein the quasi-hot-out mode is a mode that indicates that data cannot be written to the first M.2 SSD and waits for the user to hot-out the first M.2 SSD from the target device.
[0011] In one possible implementation, the power identifier of the first M.2 SSD includes a power status bit indicating the power state of the first M.2 SSD. Accordingly, the method further includes: switching the power status bit of the power identifier of the first M.2 SSD in response to the user turning off the power switch associated with the first M.2 SSD according to the prompt.
[0012] In one possible implementation, the notification includes at least one of the following: illuminating an indicator light associated with the first M.2 SSD; causing a sound device associated with the first M.2 SSD to emit a notification sound; causing a vibration device associated with the first M.2 SSD to vibrate; notifying the user that a hot-swapping operation can be performed on the first M.2 SSD; and displaying the event that a hot-swapping operation can be performed on the first M.2 SSD to the user.
[0013] In one possible implementation, the method further includes: a generation step, in response to the power switch associated with a newly hot-inserted second M.2 SSD on the target device being turned on, generating and recording a power identifier of the second M.2 SSD based on the hard disk information of the second M.2 SSD and the power state of the second M.2 SSD, wherein the value of the power identifier of the second M.2 SSD at this time is a second value indicating that the second M.2 SSD is working normally; and then, performing the determination step for the second M.2 SSD.
[0014] In one possible implementation, the power identifier of the second M.2 SSD includes a power status bit indicating the power state of the second M.2 SSD, wherein the power status bit in the power identifier of the second M.2 SSD is switched in response to a change in the power state of the second M.2 SSD.
[0015] In one possible implementation, the target device includes an NVMe RAID card or a host.
[0016] According to a second aspect of this disclosure, an M.2 SSD hot-swapping processing apparatus is provided, comprising: a determination module, configured to determine whether a hot-swapping operation of the first M.2 SSD is required based on a power identifier of a first M.2 SSD inserted into a target device; a processing module, configured to, if the determination module determines that a hot-swapping operation of the first M.2 SSD is required, cause the first M.2 SSD to enter a read-only mode indicating that the first M.2 SSD cannot receive new write requests from the target device, and continue to complete write operations for old write requests already received from the target device; and a prompting module, configured to prompt a user that a hot-swapping operation of the first M.2 SSD is currently possible.
[0017] In one possible implementation, the determination module is configured to: acquire the power identifier of the first M.2 SSD in real time; determine whether the value of the currently acquired power identifier is a first value indicating that the first M.2 SSD needs to be hot-swapped; if the acquired power identifier is the first value, then determine that the first M.2 SSD needs to be hot-swapped.
[0018] In one possible implementation, the judgment module is configured to: acquire the power identifier of the first M.2 SSD in real time; determine whether the value of the currently acquired power identifier is consistent with the value of the power identifier set for the first M.2 SSD when powering on and initializing the first M.2 SSD; if the determination is inconsistent, then determine that the first M.2 SSD needs to be hot-swapped.
[0019] In one possible implementation, the processing module is configured to: if it is determined that a hot-swapping operation is required for the first M.2 SSD, then put the first M.2 SSD into read-only mode, and determine whether there is first data written to the temporary storage module in the data corresponding to the old write request; if it is determined that the first data exists, then write the first data stored in the temporary storage module to the flash memory of the first M.2 SSD to continue to complete the write operation for the old write request, wherein, after completing the write operation for the old write request, the prompting module prompts the user that a hot-swapping operation for the first M.2 SSD is currently possible.
[0020] In one possible implementation, the prompting module is configured to: after completing the write operation for the old write request, cause the first M.2 SSD to enter a quasi-hot-out mode from the read-only mode and make the prompt, wherein the quasi-hot-out mode indicates that data cannot be written to the first M.2 SSD and waits for the user to hot-out the first M.2 SSD from the target device.
[0021] In one possible implementation, the power identifier of the first M.2 SSD includes a power status bit indicating the power state of the first M.2 SSD. Accordingly, the processing module is further configured to: switch the power status bit of the power identifier of the first M.2 SSD in response to the user turning off the power switch associated with the first M.2 SSD according to the prompt.
[0022] In one possible implementation, the notification includes at least one of the following: illuminating an indicator light associated with the first M.2 SSD; causing a sound device associated with the first M.2 SSD to emit a notification sound; causing a vibration device associated with the first M.2 SSD to vibrate; notifying the user that a hot-swapping operation can be performed on the first M.2 SSD; and displaying the event that a hot-swapping operation can be performed on the first M.2 SSD to the user.
[0023] In one possible implementation, the above apparatus further includes: a generation module, configured to, in response to the power switch associated with a newly hot-inserted second M.2 SSD on the target device being turned on, generate and record a power identifier of the second M.2 SSD based on the hard disk information of the second M.2 SSD and the power state of the second M.2 SSD, wherein the value of the power identifier of the second M.2 SSD at this time is a second value indicating that the second M.2 SSD is operating normally; then, a determination module performs the above determination for the second M.2 SSD.
[0024] In one possible implementation, the power identifier of the second M.2 SSD includes a power status bit indicating the power state of the second M.2 SSD, wherein the power status bit in the power identifier of the second M.2 SSD is switched in response to a change in the power state of the second M.2 SSD.
[0025] According to a third aspect of this disclosure, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method described above.
[0026] According to a fourth aspect of this disclosure, a non-volatile computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the steps of the above-described method.
[0027] According to a fifth aspect of this disclosure, a computer program product is provided, including a computer program or a non-volatile computer-readable storage medium carrying the computer program, wherein the computer program, when executed by a processor, implements the steps of the above-described method.
[0028] The M.2 SSD hot-swapping method, electronic device, storage medium, and software product disclosed herein determine whether a hot-swapping requirement exists for the M.2 SSD inserted on the target device based on the power identifier of the M.2 SSD. If a hot-swapping requirement exists, the M.2 SSD enters a read-only mode, indicating that it cannot receive new write requests from the target device. This allows the M.2 SSD to continue writing to older write requests already received from the target device. The user is then prompted that a hot-swapping operation is now possible. Therefore, compared to forcibly hot-swapping an M.2 SSD inserted on the target device, this disclosure allows the user to know which M.2 SSD needs to be hot-swapped based on the prompt, and to turn off the power to that M.2 SSD and hot-swap it from the target device. This avoids damage to the hard drive during the M.2 SSD hot-swapping process and ensures a smooth hot-swapping experience. The SSD has already completed the write operation for the old write request, which avoids data loss during the hot-swapping of the M.2 SSD, thus enabling more reliable and secure hot-swapping of the M.2 SSD.
[0029] Other features and aspects of this disclosure will become clear from the following detailed description of exemplary embodiments with reference to the accompanying drawings. Attached Figure Description
[0030] The accompanying drawings, which are included in and form part of this specification, illustrate exemplary embodiments, features, and aspects of this disclosure together with the specification and serve to explain the principles of this disclosure.
[0031] Figure 1 A flowchart illustrating an M.2 SSD hot-swap processing method according to an embodiment of the present disclosure is shown.
[0032] Figure 2 A schematic diagram illustrating the hot-stripping process of an M.2 SSD according to an embodiment of the present disclosure is shown.
[0033] Figure 3 A schematic diagram illustrating the determination steps of an M.2 SSD hot-swap processing method according to an embodiment of the present disclosure.
[0034] Figure 4 A schematic diagram illustrating the determination steps of an M.2 SSD hot-swap processing method according to an embodiment of the present disclosure.
[0035] Figure 5 A flowchart illustrating an M.2 SSD hot-swap processing method according to an embodiment of the present disclosure is shown.
[0036] Figure 6A schematic diagram of a hot-insertion process for an M.2 SSD according to an embodiment of the present disclosure is shown.
[0037] Figure 7 A block diagram of an M.2 SSD hot-swap processing apparatus 700 according to an embodiment of the present disclosure is shown. Detailed Implementation
[0038] Various exemplary embodiments, features, and aspects of this disclosure will now be described in detail with reference to the accompanying drawings. The same reference numerals in the drawings denote elements that have the same or similar functions. Although various aspects of the embodiments are shown in the drawings, they are not necessarily drawn to scale unless specifically indicated otherwise.
[0039] As used herein, the terms “comprising,” “including,” “having,” or variations thereof are open-ended and include one or more of the stated features, integrals, elements, steps, components, or functions, but do not exclude the presence or addition of one or more other features, integrals, elements, steps, components, functions, or groups thereof.
[0040] When an element is referred to as “connected,” “coupled,” “responding,” or a variation thereof relative to another element, it may be directly connected, coupled, or responding to another element, or there may be an intermediate element present.
[0041] Although the terms first, second, third, etc., may be used herein to describe various elements / operations, these elements / operations should not be limited by these terms. These terms are only used to distinguish one element / operation from another. Therefore, without departing from the teachings of the inventive concept, a first element / operation in some embodiments may be referred to as a second element / operation in other embodiments.
[0042] The term “exemplary” as used herein means “serving as an example, embodiment, or illustration.” Any embodiment illustrated herein as “exemplary” is not necessarily to be construed as superior to or better than other embodiments.
[0043] Furthermore, to better illustrate this disclosure, numerous specific details are set forth in the following detailed description. Those skilled in the art will understand that this disclosure can be practiced without certain specific details. In some instances, methods, means, components, and circuits well known to those skilled in the art have not been described in detail in order to highlight the main points of this disclosure.
[0044] Figure 1A flowchart illustrating an M.2 SSD hot-plugging method according to an embodiment of this disclosure is shown. It should be understood that hot-plugging, or hot-plugging while the system is powered on, allows users to remove and replace damaged components such as hard drives, power supplies, or expansion cards without shutting down the system or disconnecting the power, thereby improving the system's ability to recover from disasters, its scalability, and its flexibility. In this embodiment, the user can remove the damaged or replacement M.2 SSD and replace it with a new one without shutting down the system or disconnecting the power; that is, replacing the M.2 SSD while ensuring the system remains powered on. In one possible implementation, this method is executed by a disk management program.
[0045] like Figure 1 As shown, the method may include the following steps:
[0046] In step S110 (determination step), based on the power identifier of the first M.2 SSD inserted on the target device, it is determined whether the first M.2 SSD needs to be hot-swapped.
[0047] In this embodiment, the target device may include, but is not limited to, an NVMe RAID card or a host. The following description uses an NVMe RAID card as an example to illustrate the solution of this embodiment. This solution is also applicable to a host; therefore, the solution for a host as the target device will not be described in detail here.
[0048] A RAID card is a card that provides RAID functionality. The first M.2 SSD refers to any M.2 SSD inserted into the RAID card. The power identifier (or power code) indicates whether the M.2 SSD requires hot-plugging. When an M.2 SSD is inserted into the RAID card, it undergoes power-on initialization. During this initialization, a corresponding power identifier is set for the M.2 SSD. This initial value is called the power identifier's initial value. For example, the initial value might be "0001," indicating normal operation of the M.2 SSD. The power identifier can also include the code "0010," indicating a hot-plugging requirement. When the application sends a command to the M.2 SSD to perform a hot-plug operation, the power identifier changes from the initial value "0001" to "0010." Each M.2 SSD inserted into the RAID card is assigned a different power identifier; in other words, each M.2 SSD inserted into the RAID card has a unique power identifier.
[0049] It should be noted that any information that can indicate whether the M.2 SSD inserted on the RAID card needs to be hot-swapped can be used as the power identifier in this embodiment. Therefore, this embodiment does not limit the specific information and / or format of the power identifier.
[0050] In this embodiment, the power identifier of each M.2 SSD inserted into the NVMe RAID card can be monitored in real time, and the need for hot-swapping of the M.2 SSD can be determined based on whether the power identifier changes, thus determining whether the system / administrator plans to hot-swap the M.2 SSD. Specifically, if the power identifier of an inserted M.2 SSD changes, it can be determined that a hot-swapping operation is required for that M.2 SSD, meaning that the M.2 SSD has a hot-swapping requirement, and then step S120 can be executed. If the power identifier of an inserted M.2 SSD does not change, it can be determined that a hot-swapping operation is not required for that M.2 SSD, meaning that the M.2 SSD does not have a hot-swapping requirement, and in this case, step S110 can be re-executed.
[0051] In one possible implementation, such as Figure 3 As shown, step S110 may include:
[0052] In step S111, the power identifier of the first M.2 SSD is obtained in real time.
[0053] In step S112, it is determined whether the value of the currently obtained power identifier is a first value, such as "0010", indicating that the first M.2 SSD needs to be hot-swapped.
[0054] In step S113, if it is determined that the value of the obtained power identifier is the first value, it is determined that the first M.2 SSD needs to be hot-swapped.
[0055] In this embodiment, the power identifier value of each M.2 SSD inserted on the RAID card can be monitored in real time to see if it is the first value, and the M.2 SSD with the power identifier value of the first value is identified as an M.2 SSD that needs to be hot-swapped.
[0056] In one possible implementation, such as Figure 4 As shown, step S110 may include:
[0057] In step S114, the power identifier of the first M.2 SSD is obtained in real time.
[0058] In step S115, it is determined whether the value of the currently obtained power identifier is consistent with the value of the power identifier set for the first M.2 SSD when the first M.2 SSD is powered on and initialized, such as "0001".
[0059] In step S116, if the inconsistency is determined, it is determined that the first M.2 SSD needs to be hot-swapped.
[0060] In this embodiment, it is possible to monitor in real time whether the power identifier value of each M.2 SSD inserted on the RAID card is consistent with the initial value of the power identifier of that M.2 SSD, and to determine the M.2 SSD whose power identifier value is inconsistent with its initial value as an M.2 SSD that needs to be hot-swapped.
[0061] It should be noted that any method that can determine whether an M.2 SSD needs to be hot-swapped based on the power identifier of the M.2 SSD inserted on the RAID card can be used to implement step S110. In other words, this disclosure does not limit how to determine whether an M.2 SSD needs to be hot-swapped based on the power identifier of the M.2 SSD inserted on the RAID card. The above is just an example. Those skilled in the art can also use any other suitable method to determine whether an M.2 SSD needs to be hot-swapped based on the power identifier of the M.2 SSD inserted on the RAID card.
[0062] In one possible implementation, the power identifier of the first M.2 SSD includes a power status bit indicating the power state of the first M.2 SSD. Accordingly, the method further includes: switching the power status bit of the power identifier of the first M.2 SSD in response to the user turning off the power switch associated with the first M.2 SSD according to the prompt.
[0063] In this embodiment, considering that the power switch associated with the newly hot-inserted M.2 SSD on the RAID card changes from off to on, the power state of the M.2 SSD changes from off to on. Similarly, the power switch associated with the M.2 SSD hot-removed from the RAID card changes from on to off, and the power state of the M.2 SSD changes from on to off. Therefore, the power state of the M.2 SSD changes accordingly whether it is hot-inserted or hot-removed. Thus, the power identifier of each M.2 SSD includes a power status bit. Once the power state of an M.2 SSD changes, the power status bit of that M.2 SSD changes, and correspondingly, the power identifier of that M.2 SSD also changes. In this way, it is possible to determine whether there is a need to hot-remove the M.2 SSD inserted into the RAID card based on the power identifier including the power status bit.
[0064] In step S120 (processing step), the first M.2 SSD is put into read-only mode, which indicates that the first M.2 SSD cannot receive new write requests from the target device, and the write operation for the old write requests that have already been received from the target device continues.
[0065] In this embodiment, for an M.2 SSD that requires hot-swapping, the operating mode of the M.2 SSD is switched to read-only mode, which only allows data reading from the M.2 SSD and prevents new data writing (i.e., no new data can be written to the M.2 SSD). However, for old data corresponding to old write requests received before the M.2 SSD switched to read-only mode that has not yet been processed—that is, old data that has been sent to the M.2 SSD but has not yet been processed—the writing process needs to continue on the M.2 SSD that is already in read-only mode. This avoids data loss during the hot-swapping of the M.2 SSD.
[0066] In one possible implementation, step S120 includes: if it is determined that a hot-swapping operation needs to be performed on the first M.2 SSD, then the first M.2 SSD is put into read-only mode, and it is determined whether there is first data written to the temporary storage module in the data corresponding to the old write request; if it is determined that the first data exists, then the first data stored in the temporary storage module is written to the flash memory of the first M.2 SSD to continue to complete the write operation for the old write request.
[0067] In this embodiment, if the SSD is configured with a cache module for temporarily caching data, this cache module can be directly used as the cache. Thus, after the SSD controller receives a write request, it first writes the data corresponding to the write request to the cache module configured in the SSD, and then writes the data from the cache module to the SSD's non-volatile memory, such as NAND flash memory. The cache module configured in the SSD can be volatile memory; the data cached by the cache module is lost after power is turned off, such as DRAM, RAM, or SRAM. For example, a separate DRAM chip can be mounted on the SSD's PCB board to temporarily store the data corresponding to the write request. NAND flash memory is a non-volatile storage technology, meaning it can retain data even after power is turned off.
[0068] Therefore, for the first M.2 SSD configured with a caching module, the data corresponding to old write requests received before the first M.2 SSD switches to read-only mode is first cached in the caching module and then written from the caching module to the flash memory of the first M.2 SSD. However, when the first M.2 SSD switches to read-only mode, the data cached by the caching module may not all be written to the flash memory of the first M.2 SSD; that is, the caching module may still cache data (i.e., the aforementioned first data). If the first M.2 SSD is hot-swapped while the caching module still caches data, the data cached by the caching module will be lost and the data in the first M.2 SSD will be corrupted.
[0069] Therefore, it is determined whether the cache module of the first M.2 SSD still caches data. If it is determined to be yes, the data is first written to the flash memory of the first M.2 SSD. After all the data cached by the cache module of the first M.2 SSD is written to the flash memory of the first M.2 SSD, the following step S130 is executed.
[0070] If the SSD is not configured with a cache module for temporary data caching, HMB (Host Memory Buffer) technology can be used. This involves borrowing host memory as a cache via the PCIe interface, essentially sharing host memory using HMB. When the SSD controller receives a write request, it first writes the corresponding data to the host memory, and then writes the data from the host memory to the SSD's NAND flash memory. The host memory can be volatile memory; data cached in the host memory is lost upon power failure, such as DRAM, SRAM, cache, and their derivatives.
[0071] Therefore, for the first M.2 SSD that shares host content without a caching module, the data corresponding to old write requests received by the first M.2 SSD before switching to read-only mode is first cached in host memory and then written from host memory to the flash memory of the first M.2 SSD. However, when the first M.2 SSD switches to read-only mode, the data cached in host memory may not all be written to the flash memory of the first M.2 SSD; that is, the host memory may still cache data (i.e., the aforementioned first data). If the first M.2 SSD is hot-swapped while the host memory still caches data, the data in the first M.2 SSD will be corrupted.
[0072] To this end, it is determined whether the host memory still caches the data corresponding to the old write request received by the first M.2 SSD. If it is determined to be yes, the data is first written to the flash memory of the first M.2 SSD. After all the data corresponding to the old write request received by the first M.2 SSD cached in the host memory is written to the flash memory of the first M.2 SSD, the following step S130 is executed.
[0073] Of course, if the SSD is not configured with a caching module for temporary data storage, other suitable caching methods can be used to cache the data corresponding to write requests, and then the cached data can be written to the SSD's NAND flash memory. The implementation principle of this caching method is similar to that of caching methods using HMB technology to share host memory, and will not be elaborated upon here.
[0074] It should be understood that the aforementioned temporary storage module may include, but is not limited to, the cache module configured on the SSD, the host memory shared by the HMB technology for the SSD without a cache module, or the cache module corresponding to other caching technologies for the SSD without a cache module. This embodiment does not limit the specific implementation method of the temporary storage module.
[0075] After completing step S120, the following step S130 is executed.
[0076] In step S130 (processing step), the user is prompted that the first M.2 SSD can be hot-swapped.
[0077] In this embodiment, after the M.2 SSD that needs to be hot-swapped has been switched to read-only mode and the write operation for the old write request has been completed, a prompt can be given to inform the user which M.2 SSD needs to be hot-swapped.
[0078] In one possible implementation, the notification includes at least one of the following: illuminating an indicator light associated with the first M.2 SSD; causing a sound device associated with the first M.2 SSD to emit a notification sound; causing a vibration device associated with the first M.2 SSD to vibrate; notifying the user that a hot-swapping operation can be performed on the first M.2 SSD; and displaying the event that a hot-swapping operation can be performed on the first M.2 SSD to the user.
[0079] In this embodiment, the methods of providing prompts may include, but are not limited to, lighting up LED indicator lights, making sound devices emit prompt sounds, making buzzers vibrate, issuing notifications, sending events, etc.
[0080] In this design, when the indicator light is illuminated, the power identifier of the M.2 SSD is associated with a specific power indicator LED and power switch on that M.2 SSD. This way, by illuminating the LED associated with the M.2 SSD that needs to be hot-swapped, the user can identify which M.2 SSD needs to be hot-swapped and disconnect the power switch associated with that M.2 SSD before hot-swapping it. Thus, the power identifier of the M.2 SSD, in conjunction with the LED indicator and power switch, enables asynchronous and safe insertion and removal of the M.2 SSD, minimizing the risk of hard drive damage and data loss during hot-swapping and ensuring safer and more reliable M.2 SSD hot-swapping.
[0081] It should be understood that any method that can prompt the user which M.2 SSD needs to be hot-swapped can be used to implement step S130. Therefore, this embodiment does not limit the specific method of prompting.
[0082] In one possible implementation, step S130 includes: after completing the write operation for the old write request, causing the first M.2 SSD to enter a quasi-hot-out mode from the read-only mode and providing the prompt, wherein the quasi-hot-out mode indicates that data cannot be written to the first M.2 SSD and waits for the user to hot-out the first M.2 SSD from the NVMe RAID card.
[0083] In this embodiment, after step S120 is executed, the working mode of the M.2 SSD is switched to quasi-hot-swap mode, and the above prompt is given.
[0084] Therefore, this embodiment determines whether a hot-swapping requirement exists for the M.2 SSD inserted into the NVMe RAID card based on the power identifier of that M.2 SSD. If a hot-swapping requirement exists, the M.2 SSD enters read-only mode, indicating that it cannot receive new write requests from the NVMe RAID card. This allows the M.2 SSD to continue writing to older write requests already received from the NVMe RAID card, and the user is prompted that a hot-swapping operation is now possible. Therefore, compared to forcibly hot-swapping the M.2 SSD inserted into the NVMe RAID card, this embodiment allows the user to know which M.2 SSD needs to be hot-swapped based on the prompt, and to turn off the power to that M.2 SSD and hot-swap it from the NVMe RAID card. This avoids damage to the hard drive during the hot-swapping process and ensures a smooth process. The SSD has already completed the write operation for the old write request, which avoids data loss during the hot-swapping of the M.2 SSD, thus enabling more reliable and secure hot-swapping of the M.2 SSD.
[0085] For ease of understanding, the following is combined with Figure 2 The following describes in detail the hot-stripping process of the M.2 SSD in this embodiment. Figure 2 As shown, the NVMe RAID card has three M.2 SSDs inserted: 201, 202, and 203. Taking M.2 SSD 203 as an example, we will explain the process of hot-swapping any M.2 SSD inserted into the NVMe RAID card.
[0086] The hard drive management program monitors whether the power identifier of the M.2 SSD 203 changes. If a change is detected, it determines that there is a need to hot-plug the M.2 SSD 203 out of the system, and the system / administrator plans to hot-plug the M.2 SSD 203.
[0087] The disk management program puts the M.2 SSD 203 into read-only mode and allows it to continue writing to older write requests already received from the NVMe RAID card. Then, the program switches the M.2 SSD 203 from read-only mode to a near-hot-unplug mode, alerting the user that it needs to be hot-unplugged. For example, the program might illuminate the associated hot-unplug LED to indicate this. The near-hot-unplug mode prevents further writing to the M.2 SSD and waits for the user to unplug it.
[0088] Next, the user can pinpoint the M.2 SSD that needs hot-swapping based on the illuminated LED indicator. The user can then press the power switch associated with the M.2 SSD 203 to completely disconnect its power. Finally, the user removes the M.2 SSD 203 from the RAID card.
[0089] Therefore, compared to forcibly hot-swapping the M.2 SSD 203 from the RAID card without disconnecting its power, this embodiment disconnects the power to the M.2 SSD 203 before hot-swapping it from the RAID card. This avoids potential hard drive damage during the hot-swapping process. Furthermore, compared to not putting the M.2 SSD 203 into read-only mode and not allowing it to continue writing to older write requests already received from the NVMe RAID card, this embodiment puts the M.2 SSD 203 into read-only mode and allows it to continue writing to older write requests already received from the NVMe RAID card before hot-swapping it from the RAID card. This also avoids data loss during the hot-swapping process.
[0090] Figure 5 A flowchart illustrating a hot-swapping method for an M.2 SSD according to an embodiment of the present disclosure is shown. In one possible implementation, the method is executed by an internal program of the M.2 SSD, such as firmware. Figure 5 As shown, the method may include the following steps:
[0091] In step S510, it is determined whether there is a newly hot-inserted second M.2 SSD with its power switch turned on.
[0092] In this embodiment, the second M.2 SSD refers to any newly hot-inserted M.2 SSD on the RAID card. During the operation of the user system or the storage system using the M.2 SSD itself, the user can hot-insert a new M.2 SSD into the system. It should be understood that when the user hot-inserts a new M.2 SSD into the system, the M.2 SSD is in a power-off state, and the system cannot detect the insertion of the M.2 SSD. However, in response to the user pressing the power switch associated with the M.2 SSD, even if the power switch associated with the M.2 SSD switches from off to on, the system can detect the insertion of the M.2 SSD and then execute the following step S520.
[0093] In step S520, a power identifier for the second M.2 SSD is generated based on the hard disk information of the second M.2 SSD and the power state of the second M.2 SSD.
[0094] In this embodiment, a power-on initialization process can be performed on a newly hot-inserted M.2 SSD. This power-on initialization process includes generating a power identifier for the M.2 SSD based on its hard disk information and power status.
[0095] As explained above, when a new M.2 SSD is inserted into the system, a power-on initialization process is performed on that M.2 SSD to generate a power identifier based on the M.2 SSD itself. The generation method may include, but is not limited to: the firmware of the M.2 SSD generating a set of codes based on the internal hard drive information of the M.2 SSD when it is powered on. This code serves as the initial code for the power identifier (representing normal operation). The power identifier value of the M.2 SSD at this time is a second value indicating its normal operation; it should be understood that the second value corresponds to the initial value mentioned above.
[0096] In step S530, the power identifier of the second M.2 SSD is recorded.
[0097] In this embodiment, the power identifier set for the newly hot-inserted M.2 SSD is recorded.
[0098] Therefore, for each newly hot-inserted M.2 SSD, an initial value of the power identifier of that M.2 SSD is set and recorded so that the M.2 SSD can be monitored in real time based on the initial value to see if there is a need to hot-plug it.
[0099] In one possible implementation, after step S530, for the second M.2 SSD, the following can be executed: Figure 1The method shown is to monitor in real time whether the second M.2 SSD needs to be hot-plugged.
[0100] In this embodiment, the procedure can be performed for each newly hot-inserted M.2 SSD. Figure 1 The method shown can avoid data loss and hard drive damage during the hot-swapping of the M.2 SSD.
[0101] In one possible implementation, the power identifier of the second M.2 SSD includes a power status bit indicating the power state of the second M.2 SSD, wherein the power status bit in the power identifier of the second M.2 SSD is switched in response to a change in the power state of the second M.2 SSD.
[0102] For ease of understanding, the following is combined with Figure 6 The hot-swapping process of the M.2 SSD in this embodiment will be described in detail below. Figure 6 As shown, two M.2 SSDs, 601 and 602, were inserted into the NVMe RAID card. Taking the user's newly inserted M.2 SSD 603 as an example, the process of hot-inserting any M.2 SSD into the NVMe RAID card is explained.
[0103] During the operation of the user system or the storage system using the SSD itself, the user hot-inserts a new M.2 SSD 603 into the system. That is, the user hot-inserts a new M.2 SSD 603 into the system without requiring the host or system to lose power. When the user hot-inserts the new M.2 SSD 603, the M.2 SSD 603 is in a power-off state, and the system cannot detect the hot-insertion. Then, the user presses the power switch associated with the M.2 SSD 603, and in response, power-on initialization processing is performed on the M.2 SSD 603.
[0104] In this embodiment, power-on initialization may include, but is not limited to: generating a power identifier for the M.2 SSD 603, recording the generated power identifier, setting the LED indicator associated with the M.2 SSD 603 to an off state, setting the beeper associated with the M.2 SSD 603 to a non-vibration state, recording the insertion and removal log corresponding to the M.2 SSD 603, and sending an event notification indicating that a new hot-inserted M.2 SSD 603 has been inserted.
[0105] Next, during power-on initialization, the power identifier of the M.2 SSD 603 is set, and the system begins detecting changes in the power identifier of the M.2 SSD 603, i.e., executing... Figure 1 The steps shown.
[0106] In this embodiment, the internal program of the M.2 SSD 603 detects the hard disk information of the M.2 SSD 603, and generates a unique power identifier for the M.2 SSD 603 based on the hard disk information and the power state (conduction state) of the M.2 SSD 603, which is not shared with other M.2 SSDs; when the power state of the M.2 SSD 603 changes, the internal program of the M.2 SSD 603 switches the power state bit in the power identifier of the M.2 SSD 603.
[0107] After the M.2 SSD 603 completes power-on initialization, the user system or storage system checks for newly hot-inserted M.2 SSDs.
[0108] According to this embodiment, when a new M.2 SSD is hot-plugged into a user system or storage system, a power identifier for the M.2 SSD is set, and the association between the power identifier, LED indicator, and power switch is recorded. When the inserted M.2 SSD is removed from the system, the power identifier of the M.2 SSD is monitored to determine whether it needs to be hot-plugged. The power identifier of the M.2 SSD and its association are used to determine the corresponding LED indicator to prompt the user that the M.2 SSD needs to be hot-plugged. In response to the prompt, the user can disconnect the corresponding power switch and then hot-plug the M.2 SSD.
[0109] Figure 7 A block diagram of an M.2 SSD hot-swap processing apparatus 700 according to an embodiment of the present disclosure is shown. Figure 7 As shown, the device 700 may include a judgment module 710, a processing module 720, and a prompting module 730. The judgment module 710 determines whether a hot-swapping operation is required for the first M.2 SSD based on the power identifier of the first M.2 SSD inserted into the target device. The processing module 720 is connected to the judgment module 710 and, if the judgment module 710 determines that a hot-swapping operation is required for the first M.2 SSD, causes the first M.2 SSD to enter a read-only mode, indicating that the first M.2 SSD cannot receive new write requests from the target device, and continues to complete write operations for old write requests already received from the target device. The prompting module 730 is connected to the processing module 720 and is used to prompt the user that a hot-swapping operation for the first M.2 SSD is currently possible.
[0110] In one possible implementation, the determination module 710 is configured to: acquire the power identifier of the first M.2 SSD in real time; determine whether the value of the currently acquired power identifier is a first value indicating that the first M.2 SSD needs to be hot-swapped; if the value of the acquired power identifier is the first value, then determine that the first M.2 SSD needs to be hot-swapped.
[0111] In one possible implementation, the judgment module 710 is configured to: acquire the power identifier of the first M.2 SSD in real time; determine whether the value of the currently acquired power identifier is consistent with the value of the power identifier set for the first M.2 SSD when powering on and initializing the first M.2 SSD; if it is determined that they are inconsistent, it is determined that the first M.2 SSD needs to be hot-swapped.
[0112] In one possible implementation, the processing module 720 is configured to: if it is determined that a hot-swapping operation is required for the first M.2 SSD, then put the first M.2 SSD into read-only mode, and determine whether there is first data written to the temporary storage module in the data corresponding to the old write request; if it is determined that the first data exists, then write the first data stored in the temporary storage module to the flash memory of the first M.2 SSD to continue to complete the write operation for the old write request, wherein, after completing the write operation for the old write request, the prompting module 730 prompts the user that a hot-swapping operation for the first M.2 SSD is currently possible.
[0113] In one possible implementation, the prompting module 730 is configured to: after completing the write operation for the old write request, cause the first M.2 SSD to enter a quasi-hot-out mode from the read-only mode and make the prompt, wherein the quasi-hot-out mode is a mode that indicates that data cannot be written to the first M.2 SSD and waits for the user to hot-out the first M.2 SSD from the target device.
[0114] In one possible implementation, the power identifier of the first M.2 SSD includes a power status bit indicating the power state of the first M.2 SSD. Accordingly, the processing module 720 is further configured to switch the power status bit of the power identifier of the first M.2 SSD in response to the user turning off the power switch associated with the first M.2 SSD according to the prompt.
[0115] In one possible implementation, the notification includes at least one of the following: illuminating an indicator light associated with the first M.2 SSD; causing a sound device associated with the first M.2 SSD to emit a notification sound; causing a vibration device associated with the first M.2 SSD to vibrate; notifying the user that a hot-swapping operation can be performed on the first M.2 SSD; and displaying the event that a hot-swapping operation can be performed on the first M.2 SSD to the user.
[0116] In one possible implementation, the above-described device 700 further includes: a generation module 740, configured to, in response to the power switch associated with a newly hot-inserted second M.2 SSD being turned on on the target device, generate and record a power identifier of the second M.2 SSD based on the hard disk information and power state of the second M.2 SSD, wherein the value of the power identifier of the second M.2 SSD at this time is a second value indicating that the second M.2 SSD is operating normally; then, a determination module 710 performs the above-described determination for the second M.2 SSD.
[0117] In one possible implementation, the power identifier of the second M.2 SSD includes a power status bit indicating the power state of the second M.2 SSD, wherein the power status bit in the power identifier of the second M.2 SSD is switched in response to a change in the power state of the second M.2 SSD.
[0118] In some embodiments, the functions or modules of the apparatus provided in this disclosure can be used to perform the methods described in the above method embodiments. The specific implementation can be referred to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.
[0119] This disclosure also provides an electronic device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the above-described method.
[0120] This disclosure also provides a non-volatile computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the above-described method.
[0121] This disclosure also provides a computer program product, including a computer program or a non-volatile computer-readable storage medium carrying the computer program, wherein the computer program, when executed by a processor, implements the steps of the above method.
[0122] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of an instruction containing one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the blocks may occur in a different order than those shown in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0123] The various embodiments of this disclosure have been described above. These descriptions are exemplary and not exhaustive, nor are they limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is chosen to best explain the principles, practical application, or technical improvements to the embodiments in the market, or to enable others skilled in the art to understand the embodiments disclosed herein.
Claims
1. A method for hot-swapping an M.2 SSD, characterized in that, include: The determination step involves determining whether a hot-swapping operation is required for the first M.2 SSD based on the power identifier of the first M.2 SSD inserted into the target device. The processing steps are as follows: if it is determined that a hot-swapping operation is required for the first M.2 SSD, the first M.2 SSD is put into a read-only mode, which indicates that the first M.2 SSD cannot receive new write requests from the target device, and the write operation for the old write requests that have already been received from the target device is continued. The prompts the user with information indicating that the first M.2 SSD can now be hot-swapped. The determination step includes: Obtain the power identifier of the first M.2 SSD in real time; Determine whether the currently acquired power identifier value is a first value indicating that the first M.2 SSD needs to be hot-swapped; If the obtained power identifier value is determined to be the first value, then it is determined that the first M.2 SSD needs to be hot-swapped.
2. The method according to claim 1, characterized in that, The processing steps include: If it is determined that a hot-swapping operation is required for the first M.2 SSD, the first M.2 SSD is put into read-only mode, and it is determined whether the data corresponding to the old write request contains the first data that has been written to the temporary storage module. If it is determined that the first data exists, the first data stored in the temporary storage module is written to the flash memory of the first M.2 SSD to continue the write operation for the old write request. The prompting step is executed after the write operation for the old write request has been completed.
3. The method according to claim 1, characterized in that, The prompting steps include: After completing the write operation for the old write request, the first M.2 SSD is switched from read-only mode to quasi-hot-out mode, and the prompt is given. The quasi-hot-out mode indicates that data cannot be written to the first M.2 SSD and the user is waiting to hot-out the first M.2 SSD from the target device.
4. The method according to claim 1, characterized in that, The power identifier of the first M.2 SSD includes a power status bit indicating the power state of the first M.2 SSD, and correspondingly, the method further includes: In response to the user disconnecting the power switch associated with the first M.2 SSD according to the prompt, the power status bit of the power identifier of the first M.2 SSD is switched.
5. The method according to claim 1, characterized in that, The prompt includes at least one of the following: Turn on the indicator light associated with the first M.2 SSD; The audio device associated with the first M.2 SSD will emit a notification sound; To cause the vibration device associated with the first M.2 SSD to vibrate; Notify the user that the first M.2 SSD can be hot-swapped. The event that allows the user to hot-plug the first M.2 SSD is displayed.
6. The method according to any one of claims 1 to 5, characterized in that, Also includes: In the generation step, in response to the power switch associated with the newly hot-inserted second M.2 SSD on the target device being turned on, a power identifier of the second M.2 SSD is generated and recorded based on the hard drive information and power status of the second M.2 SSD. The value of the power identifier of the second M.2 SSD at this time is a second value indicating that the second M.2 SSD is working normally. Then, the determination step is performed for the second M.2 SSD.
7. The method according to claim 6, characterized in that, The power identifier of the second M.2 SSD includes a power status bit indicating the power state of the second M.2 SSD, wherein the power status bit in the power identifier of the second M.2 SSD is switched in response to a change in the power state of the second M.2 SSD.
8. The method according to any one of claims 1 to 5, characterized in that, The target device includes an NVMe RAID card or a host.
9. A method for hot-swapping an M.2 SSD, characterized in that, include: The determination step involves determining whether a hot-swapping operation is required for the first M.2 SSD based on the power identifier of the first M.2 SSD inserted into the target device. The processing steps are as follows: if it is determined that a hot-swapping operation is required for the first M.2 SSD, the first M.2 SSD is put into a read-only mode, which indicates that the first M.2 SSD cannot receive new write requests from the target device, and the write operation for the old write requests that have already been received from the target device is continued. The prompts the user with information indicating that the first M.2 SSD can now be hot-swapped. The determination step includes: Obtain the power identifier of the first M.2 SSD in real time; Determine whether the value of the currently obtained power identifier is consistent with the value of the power identifier set for the first M.2 SSD when powering on and initializing the first M.2 SSD; If an inconsistency is detected, it is determined that the first M.2 SSD needs to be hot-swapped.
10. The method according to claim 9, characterized in that, The processing steps include: If it is determined that a hot-swapping operation is required for the first M.2 SSD, the first M.2 SSD is put into read-only mode, and it is determined whether the data corresponding to the old write request contains the first data that has been written to the temporary storage module. If it is determined that the first data exists, the first data stored in the temporary storage module is written to the flash memory of the first M.2 SSD to continue the write operation for the old write request. The prompting step is executed after the write operation for the old write request has been completed.
11. The method according to claim 9, characterized in that, The prompting steps include: After completing the write operation for the old write request, the first M.2 SSD is switched from read-only mode to quasi-hot-out mode, and the prompt is given. The quasi-hot-out mode indicates that data cannot be written to the first M.2 SSD and the user is waiting to hot-out the first M.2 SSD from the target device.
12. The method according to claim 9, characterized in that, The power identifier of the first M.2 SSD includes a power status bit indicating the power state of the first M.2 SSD, and correspondingly, the method further includes: In response to the user disconnecting the power switch associated with the first M.2 SSD according to the prompt, the power status bit of the power identifier of the first M.2 SSD is switched.
13. The method according to claim 9, characterized in that, The prompt includes at least one of the following: Turn on the indicator light associated with the first M.2 SSD; The audio device associated with the first M.2 SSD will emit a notification sound; To cause the vibration device associated with the first M.2 SSD to vibrate; Notify the user that the first M.2 SSD can be hot-swapped. The event that allows the user to hot-plug the first M.2 SSD is displayed.
14. The method according to any one of claims 9 to 13, characterized in that, Also includes: In the generation step, in response to the power switch associated with the newly hot-inserted second M.2 SSD on the target device being turned on, a power identifier of the second M.2 SSD is generated and recorded based on the hard drive information and power status of the second M.2 SSD. The value of the power identifier of the second M.2 SSD at this time is a second value indicating that the second M.2 SSD is working normally. Then, the determination step is performed for the second M.2 SSD.
15. The method according to claim 14, characterized in that, The power identifier of the second M.2 SSD includes a power status bit indicating the power state of the second M.2 SSD, wherein the power status bit in the power identifier of the second M.2 SSD is switched in response to a change in the power state of the second M.2 SSD.
16. The method according to any one of claims 9 to 13, characterized in that, The target device includes an NVMe RAID card or a host.
17. An electronic device comprising a memory, a processor, and a computer program stored in the memory, characterized in that, The processor executes the computer program to implement the steps of the method according to any one of claims 1 to 16.
18. A non-volatile computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 16.
19. A computer program product comprising a computer program, or a non-volatile computer-readable storage medium carrying a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 16.