General disk command issuing method

By using a unified semantic interface and intelligent pre-inspection and risk interception mechanism, the problem of existing tools being unable to effectively monitor and send ATA commands has been solved, achieving secure and efficient disk operation management and improving user experience and operational efficiency.

CN122018823APending Publication Date: 2026-05-12JIANGSU XINSHENG INTELLIGENT TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
JIANGSU XINSHENG INTELLIGENT TECH CO LTD
Filing Date
2026-04-15
Publication Date
2026-05-12

AI Technical Summary

Technical Problem

Existing tools are unable to effectively monitor task execution progress, lack risk prevention mechanisms, and cannot send arbitrary ATA commands directly through the operating system interface, making them complex and inflexible to use.

Method used

This paper provides a general method for issuing disk commands. Through a unified semantic interface, intelligent pre-detection and risk interception, real-time status monitoring and result parsing, it enables safe and automated tasks of ATA commands that are plannable, monitorable and rollbackable.

Benefits of technology

It improves the efficiency and security of command issuance, reduces the risk of data loss and system downtime caused by accidental operations, and enhances user experience and operational efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122018823A_ABST
    Figure CN122018823A_ABST
Patent Text Reader

Abstract

The invention discloses a general disk command issuing method, and belongs to the technical field of solid state disks. The method comprises the following steps: firstly, analyzing a user instruction into ATA command operation by adopting a semantic interface; carrying out intelligent risk interception through a dual risk assessment mechanism; then, the command is packaged and issued by using an SCSI-ATA transparent transmission technology; real-time progress monitoring is realized by adopting a dual-cycle architecture of active polling and event monitoring; and finally, the original response is converted into a readable suggestion through the error code mapping library. And two execution modes of foreground synchronization and background asynchronization are supported, and multiple command types such as equipment diagnosis, performance test and secure erasure are covered. According to the method, the operation threshold is greatly reduced, and a complex hexadecimal command is replaced by semantic parameters; misoperation is effectively prevented through intelligent risk interception, and system safety is guaranteed; automation, security and visualization of disk command issuing are achieved, and the efficiency and reliability of storage device operation and maintenance are remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of solid-state drive technology, and in particular to a general disk command issuance method. Background Technology

[0002] In the development and maintenance of storage devices, it is often necessary to send specific ATA commands (such as SCT commands, SMART commands, etc.) to the disk for device diagnostics, performance testing, or firmware debugging. However, SATA disks receive ATA commands, while the operating system can only process SCSI commands. Currently, there is a lack of tools that can monitor task execution progress, prevent the issuance of risky commands, and directly send arbitrary ATA commands through the device interface provided by the operating system. Existing tools typically rely on specific hardware or drivers, or can only send a limited number of predefined commands.

[0003] Existing tools include: hdparm: Its main design goals are performance testing and power management. It has a limited command set, and its parameter parsing logic is tightly coupled to specific functions, so it does not have the ability to flexibly assemble arbitrary ATA commands.

[0004] sg_sat (belonging to the sg3_utils package): This is a set of lower-level tools, including sg_sat_identify, sg_sat_smart, etc. They are specifically designed for ATA pass-throw. Their drawbacks are: each command is implemented in a separate binary file, resulting in a fragmented command set; users need to remember a large number of tool names and parameters; and for non-standard or custom commands, users still need to manually calculate and assemble complex binary parameter blocks, making it extremely user-unfriendly.

[0005] Current tools primarily target common functions (performance, power), therefore they lack a complete ATA command set (such as complete SMART commands, flow control commands, security function commands, etc.), and their architecture is not conducive to extending these commands. Alternatively, tools like the sg_sat series adopt a "one function, one program" paradigm, resulting in a fragmented toolset, complex usage, and high learning costs. More importantly, based on in-depth analysis of the sg3_utils tool, its core deficiency lies in the fact that it is a powerful but rudimentary command set, lacking systematic support for "automation," "security," and "observability" in modern operations and maintenance scenarios. Summary of the Invention

[0006] The purpose of this invention is to overcome the shortcomings of existing technologies and provide a universal disk command issuance method. It transforms fragmented, high-risk native command operations into planned, monitorable, and rollback-enabled secure automated tasks. 1. Unified semantic interface: Provides intuitive commands such as `sg_automate sanitize --device / dev / sdX --mode full --confirm`, replacing the complex hexadecimal CDB encoding of `sg_raw`; 2. Intelligent pre-check and risk interception engine: Before executing any destructive commands (such as erase or format), it automatically checks: Is the device a system disk? Are there any unmounted partitions? Is it occupied by RAID / LVM? and forces secondary confirmation; 3. Real-time status monitoring and progress reporting: For time-consuming commands such as `sanitize` and `longself-test`, it automatically enters monitoring mode after startup, periodically polling the progress and displaying it as a progress bar / percentage, instead of blocking the terminal. 4. Enhanced Result Parsing and Suggestions: Converts the raw hexadecimal code returned by REQUEST SENSE into readable Chinese / English suggestions. For example, 0x5 0x24 0x00 is converted to "Error: Illegal request. Possible cause: Current device power or policy state does not allow this operation."

[0007] The objective of this invention is achieved through the following technical solution: a general disk command issuance method, comprising the following steps: Command reception and semantic parsing stage: Receive ATA commands input by the user, parse the commands into corresponding ATA command operations using a semantic parsing tool, and output them to the intelligent pre-detection and risk interception module; Intelligent pre-inspection and risk interception phase: The intelligent pre-inspection and risk interception module performs static and dynamic multi-dimensional risk analysis and risk assessment on the parsed ATA command operations, and decides whether to continue execution based on the risk level; Command issuance and execution mode determination stage: Input ATA command operation that has passed the risk assessment and determine the execution mode. Based on the execution mode determination result, select foreground synchronous execution or background asynchronous execution. Encapsulate the ATA command operation into a SCSI command description block through SCSI-ATA pass-through technology and issue it to the target disk device for execution through the operating system interface. Real-time status monitoring phase: The real-time status monitoring module uses a dual-loop architecture of active polling and event listening to monitor the command execution progress. Active polling queries the device status at fixed time intervals, while event listening is triggered by changes in device status and updates the progress information in real time for display. Results Analysis and Feedback Phase: Using the raw data returned by the target disk device as input, the enhanced results analysis module converts the raw error codes into readable suggestion information based on the error code mapping database, outputs the final analysis results, and provides feedback to the user.

[0008] Preferably, the ATA command uses a natural language parameter format, including device identifier, command type, and operation mode parameters.

[0009] Preferably, the risk levels are divided into emergency risk, high risk, medium risk and low risk; For urgent and risky commands, intercept and execute them directly and return a warning message; For high-risk commands, pause the process and enter interactive confirmation, requiring the user to enter confirmation parameters or confirm again; For medium and low-risk orders, proceed directly through risk assessment.

[0010] Preferably, the intelligent pre-detection and risk interception module includes a command inherent risk analysis submodule and a context risk assessment submodule; the command inherent risk analysis submodule statically assesses the command risk level based on a predefined risk database; the context risk assessment submodule dynamically detects the device status, including checking whether the target disk device is a system disk, whether there is an unmounted partition, and whether it is occupied by RAID or LVM.

[0011] Preferably, the SCSI-ATA pass-through technology encapsulates ATA commands in specific fields of the SCSI command description block through the libata library and sends them to the target disk device through the SG_IO interface of the Linux operating system.

[0012] Preferably, the device state change includes a device error event or a task completion event.

[0013] Preferably, in the command issuance and execution mode determination stage, time-consuming commands adopt a background asynchronous execution mode, return a task identifier to the user, and the user can query the task progress, success or failure result at any time through the task identifier, and the monitoring process does not block the terminal foreground task.

[0014] Preferably, in the result parsing and feedback stage, the enhanced result parsing module has a built-in error code mapping database that maps the Sense Key, additional perception code, and additional perception code qualifier returned by the device into multilingual readable suggestions.

[0015] Preferably, the multilingual readability suggestions include Chinese and English.

[0016] The beneficial effects of this invention are: 1) Through a unified semantic interface, complex hexadecimal CDB commands are converted into intuitive natural language parameters, eliminating the need for users to memorize cumbersome command formats and register values. This design allows even non-professional users to quickly get started, reducing training costs and learning time. Simultaneously, semantic commands support batch processing and automation script integration, significantly improving the efficiency and consistency of command issuance, making it particularly suitable for large-scale operation and maintenance scenarios.

[0017] 2) This invention employs a dual risk assessment mechanism (inherent command risk analysis and contextual risk assessment) to automatically identify potential risks before executing destructive commands. The system can intelligently determine the device status (e.g., whether it is a system disk, whether it is occupied, etc.) and adopt differentiated processing strategies for commands with different risk levels. This proactive risk control mechanism effectively avoids data loss or system crashes caused by misoperation, greatly improving the security of storage device management.

[0018] 3) Employing a dual-loop architecture of active polling and event listening, the system achieves full-process monitoring of time-consuming commands. Users can query the execution progress at any time via task ID, and the system intuitively displays status changes in the form of a progress bar or percentage, avoiding the problem of traditional tools blocking the terminal for extended periods and affecting other tasks. This non-blocking asynchronous execution mode significantly improves the user experience and is particularly suitable for complex operations such as sanitize and long self-test.

[0019] 4) It converts obscure hardware error codes (Sense Key, ASC, ASCQ, etc.) into readable suggestions in multiple languages, enabling users to quickly understand the cause of the problem and take appropriate measures. This intelligent error diagnosis function reduces reliance on professional technicians and lowers enterprise operation and maintenance costs. At the same time, the system records detailed operation logs and confirmation credentials, providing a complete basis for problem tracing and auditing.

[0020] 5) By transforming fragmented, high-risk operations into planable, monitorable, and secure automated tasks, this invention effectively solves the fragmentation problem inherent in traditional toolsets. Unified interface specifications and standardized operating procedures reduce configuration errors caused by human factors, improving the standardization and reliability of storage device management. Attached Figure Description

[0021] Figure 1 This is a flowchart of the method of the present invention; Figure 2 Flowchart for intelligent pre-detection and risk interception; Figure 3 Flowchart for real-time status monitoring; Figure 4 This is a flowchart for result analysis and feedback. Detailed Implementation

[0022] The technical solution of the present invention will be clearly and completely described below with reference to the embodiments. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0023] First, some terms in this invention are defined as follows: ATA: is the underlying instruction set for communication and data exchange between the host and ATA interface storage devices.

[0024] SCSI is the core instruction protocol that drives the entire enterprise-level storage and modern operating system storage stack.

[0025] CDB stands for SCSI command "command packet" or "microprogram". It is a block of binary instructions sent by the host to the SCSI device that defines specific operations.

[0026] Sense Key: A key for classifying errors or abnormal states. It indicates the nature of the error.

[0027] ASC: Additional awareness code, a specific error code under the Sense Key category. Indicates the type of error.

[0028] ASCQ: Additional Perception Code Qualifier, which further refines, limits, or supplements ASC, providing the most accurate description.

[0029] See Figures 1-4 This invention provides a technical solution: a general disk command issuance method, comprising the following steps: Command reception and semantic parsing stage: Receive ATA commands input by the user, parse the commands into corresponding ATA command operations using a semantic parsing tool, and output them to the intelligent pre-detection and risk interception module; Intelligent pre-inspection and risk interception phase: The intelligent pre-inspection and risk interception module performs static and dynamic multi-dimensional risk analysis and risk assessment on the parsed ATA command operations, and decides whether to continue execution based on the risk level; Command issuance and execution mode determination stage: Input ATA command operation that has passed the risk assessment and determine the execution mode. Based on the execution mode determination result, select foreground synchronous execution or background asynchronous execution. Encapsulate the ATA command operation into a SCSI command description block through SCSI-ATA pass-through technology and issue it to the target disk device for execution through the operating system interface. Real-time status monitoring phase: The real-time status monitoring module uses a dual-loop architecture of active polling and event listening to monitor the command execution progress. Active polling queries the device status at fixed time intervals, while event listening is triggered by changes in device status and updates the progress information in real time for display. Results Analysis and Feedback Phase: Using the raw data returned by the target disk device as input, the enhanced results analysis module converts the raw error codes into readable suggestion information based on the error code mapping database, outputs the final analysis results, and provides feedback to the user.

[0030] In this embodiment, the present invention uses CDB to convert ATA commands into SCSI commands and sends arbitrary ATA commands directly through the interface provided by the operating system.

[0031] SATA / ATA Protocol Stack: Application-layer ATA commands, driven by the operating system, are converted into FIS packets for transmission over the SATA link. The SCSI subsystem dominates in Linux, and SATA devices are typically presented as "SCSI emulation" via the libata driver.

[0032] SG_IO Interface: The Linux kernel provides the SG_IO ioctl system call, allowing user-space programs to send custom SCSI Command Description Blocks (CDBs) to block devices through the SCSI General (SG) layer. The libata driver cleverly utilizes this mechanism to support a special "ATA PASS-THROUGH (16 / 12)" SCSI command. Users can encapsulate a complete ATA command within a specific field of this SCSI command, and the libata driver will extract the ATA command and convert it into the corresponding SATA FIS packet before sending it to the hardware.

[0033] like Figure 1 As shown, after the user inputs a command, the tool generates parsed data through unified semantic parsing and sends it to the intelligent pre-detection and risk interception module. The "contextual risk assessment" and "command inherent risk analysis" modules then classify the command's risk level. Commands with urgent risks are intercepted and not executed; high-risk commands require user confirmation, and execution continues only after user confirmation; commands canceled by the user are intercepted and not executed; medium-risk and low-risk commands are directly assessed and pass the risk check, then the execution mode is determined. Foreground tasks directly display execution results and progress on the terminal; background asynchronous tasks poll the execution progress in the background and return progress and results when the user retrieves the task status, without blocking foreground task execution.

[0034] In some embodiments, the ATA command uses a natural language parameter format, including a device identifier, command type, and operation mode parameters.

[0035] In some embodiments, the risk levels are divided into emergency risk, high risk, medium risk, and low risk; For urgent and risky commands, intercept and execute them directly and return a warning message; For high-risk commands, pause the process and enter interactive confirmation, requiring the user to enter confirmation parameters or confirm again; For medium and low-risk orders, proceed directly through risk assessment.

[0036] In some embodiments, the intelligent pre-detection and risk interception module includes a command inherent risk analysis submodule and a context risk assessment submodule; the command inherent risk analysis submodule statically assesses the risk level of the command based on a predefined risk database; the context risk assessment submodule dynamically detects the device status, including checking whether the target disk device is a system disk, whether there is an unmounted partition, and whether it is occupied by RAID or LVM.

[0037] In this embodiment, as Figure 2 As shown, the intelligent pre-detection and risk interception module establishes an internal command risk database, mapping each sub-command to be issued by the tool to its inherent risk level. Risk levels are categorized as: emergency risk, high risk, medium risk, and low risk. Then, the "context risk assessment" and "command inherent risk analysis" modules further select the command's risk level before proceeding with subsequent operations. The analysis logic for command inherent risk analysis (static analysis) is shown in Table 1. Table 1

[0038] The analytical logic of contextual risk assessment (dynamic analysis) is shown in Table 2: Table 2

[0039] In some embodiments, the SCSI-ATA pass-through technology encapsulates ATA commands in specific fields of the SCSI command description block through the libata library and sends them to the target disk device through the SG_IO interface of the Linux operating system.

[0040] In some embodiments, the device state change includes a device error event or a task completion event.

[0041] In this embodiment, the core objective of the real-time status monitoring module is to transform the asynchronous and invisible operations at the tool's underlying level into tasks that are transparent, observable, and securely controllable to the user. Once a user issues and executes an asynchronous background task, a task ID will be returned to the user after the execution command is successfully issued. The task will continue to execute in the background, and the user can query the task progress, success, and failure status at any time through the ID.

[0042] The background monitoring uses a dual-loop architecture of "active polling" and "event listening," the difference between which lies in their triggering methods. "Active polling" is initiated by the monitoring program according to a fixed schedule, checking at the appointed time regardless of whether the device state has changed. "Event listening," on the other hand, is triggered by kernel or hardware events, waking up only when a critical change occurs in the device state. The monitoring process is as follows: Figure 3 As shown.

[0043] In some embodiments, during the command issuance and execution mode determination stage, time-consuming commands are executed in a background asynchronous mode, and a task identifier is returned to the user. The user can query the task progress, success or failure result at any time through the task identifier, and the monitoring process does not block the terminal foreground task.

[0044] In some embodiments, during the result parsing and feedback phase, the enhanced result parsing module has a built-in error code mapping database that maps the Sense Key, additional sense codes, and additional sense code qualifiers returned by the device into multilingual readable suggestions.

[0045] In this embodiment, the core function of the enhanced result parsing module is to act as an experienced storage expert, translating the raw, obscure hardware error codes returned by the device into clear reports that users can immediately understand and act upon. The parsing feedback process is as follows: Figure 4 As shown.

[0046] In some embodiments, the multilingual readability suggestions include Chinese and English.

[0047] This invention provides more intuitive and easy-to-understand commands through a unified semantic interface, replacing the need to memorize complex hexadecimal CDB commands. It transforms fragmented, high-risk native command operations into safe, automated tasks that are plannable, monitorable, and rollbackable. Users no longer need to directly manipulate hexadecimal register values; instead, they express their intent through intuitive semantic parameters and can monitor task progress in real time.

[0048] Before executing any destructive commands (such as erasure or formatting), the intelligent pre-inspection and risk interception module automatically checks whether the device is a system disk, whether there are any unmounted partitions, whether it is occupied by RAID / LVM, and forces a second confirmation. Real-time status monitoring and progress reporting: For time-consuming commands such as sanitize and long self-test, the system automatically enters monitoring mode after startup, periodically polls the progress and displays it in the form of a progress bar / percentage, instead of blocking the terminal.

[0049] The above description is merely a preferred embodiment of the present invention. It should be understood that the present invention is not limited to the forms disclosed herein and should not be construed as excluding other embodiments. It can be used in various other combinations, modifications, and environments, and can be altered within the scope of the concept described herein through the above teachings or related technologies or knowledge. Modifications and variations made by those skilled in the art that do not depart from the spirit and scope of the present invention should be within the protection scope of the appended claims.

Claims

1. A general disk command issuance method, characterized in that: Includes the following steps: Command reception and semantic parsing stage: Receive ATA commands input by the user, parse the commands into corresponding ATA command operations using a semantic parsing tool, and output them to the intelligent pre-detection and risk interception module; Intelligent pre-inspection and risk interception phase: The intelligent pre-inspection and risk interception module performs static and dynamic multi-dimensional risk analysis and risk assessment on the parsed ATA command operations, and decides whether to continue execution based on the risk level; Command issuance and execution mode determination stage: Input ATA command operation that has passed the risk assessment and determine the execution mode. Based on the execution mode determination result, select foreground synchronous execution or background asynchronous execution. Encapsulate the ATA command operation into a SCSI command description block through SCSI-ATA pass-through technology and issue it to the target disk device for execution through the operating system interface. Real-time status monitoring phase: The real-time status monitoring module uses a dual-loop architecture of active polling and event listening to monitor the command execution progress. Active polling queries the device status at fixed time intervals, while event listening is triggered by changes in device status and updates the progress information in real time for display. Results Analysis and Feedback Phase: Using the raw data returned by the target disk device as input, the enhanced results analysis module converts the raw error codes into readable suggestion information based on the error code mapping database, outputs the final analysis results, and provides feedback to the user.

2. The general disk command issuance method according to claim 1, characterized in that: The ATA commands use a natural language parameter format, including device identifier, command type, and operation mode parameters.

3. The general disk command issuance method according to claim 1, characterized in that: The risk levels are categorized as emergency risk, high risk, medium risk, and low risk. For urgent and risky commands, intercept and execute them directly and return a warning message; For high-risk commands, pause the process and enter interactive confirmation, requiring the user to enter confirmation parameters or confirm again; For medium and low-risk orders, proceed directly through risk assessment.

4. The general disk command issuance method according to claim 1, characterized in that: The intelligent pre-detection and risk interception module includes a command inherent risk analysis submodule and a context risk assessment submodule; the command inherent risk analysis submodule statically assesses the command risk level based on a predefined risk database; The context risk assessment submodule dynamically detects the device status, including checking whether the target disk device is a system disk, whether there are unmounted partitions, and whether it is occupied by RAID or LVM.

5. The general disk command issuance method according to claim 1, characterized in that: The SCSI-ATA pass-through technology encapsulates ATA commands in specific fields of the SCSI command description block through the libata library and sends them to the target disk device through the SG_IO interface of the Linux operating system.

6. The general disk command issuance method according to claim 1, characterized in that: The device status changes mentioned include device error events or task completion events.

7. The general disk command issuance method according to claim 1, characterized in that: In the command issuance and execution mode determination stage, time-consuming commands are executed in the background asynchronous mode, and a task identifier is returned to the user. The user can query the task progress, success or failure result at any time through the task identifier, and the monitoring process does not block the terminal foreground task.

8. The general disk command issuance method according to claim 1, characterized in that: In the result parsing and feedback phase, the enhanced result parsing module has a built-in error code mapping database that maps the Sense Key, additional perception code, and additional perception code qualifier returned by the device into multilingual readable suggestions.

9. The general disk command issuance method according to claim 8, characterized in that: The proposed multilingual readability includes Chinese and English.