A method and network device for detecting flash memory
Patent Information
- Application Number
- CN202611150578.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-30
- Publication Date
- 2026-10-27
AI Technical Summary
滞后性:被动检测通常在故障已经发生并对业务造成影响(如无法启动、配置丢失)后才发出告警,缺乏事前预警能力
[0015]通过上述各实施例可以看出,通过创建测试文件,并对测试文件进行写读操作,可以实现主动探测,定期对Flash进行“体检”,能在用户感知到业务问题(如配置保存失败)之前,提前发现存储介质性能下降或坏块增加的趋势。
Smart Images

Figure CN122991233A_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the field of communication technology, and in particular to a method for detecting flash memory and a network device. Background Technology
[0002] In network devices such as routers and switches, flash storage is the core carrier for storing firmware, configuration files, and runtime data. The read and write stability of flash storage directly determines the overall operational reliability of the device. If flash storage experiences faults such as bad blocks, abnormal read and write permissions, aging storage chips, or partition damage, it can lead to failures in saving device configurations, loss of business data, and abnormal system operation, thereby causing various online business failures.
[0003] Currently, Flash fault detection is mostly passive, relying on firmware verification failures during device startup, errors from routine file operations (such as saving configurations), or uncorrectable errors reported by hardware registers to trigger alarms. This approach has the following problems: Delay: Passive detection usually only issues alarms after a fault has occurred and affected business operations (such as failure to start or loss of configuration), lacking the ability to provide early warning.
[0004] Interference: To confirm whether Flash is working properly, maintenance personnel may need to manually perform file operations (such as copying and deleting) for testing. These operations may consume system resources or, in extreme cases, affect production files due to misoperation.
[0005] Incomplete: A single read or write failure may indicate different stages of Flash degradation (e.g., a write failure may occur earlier than a read failure), but existing methods often categorize them all as "storage errors," which is not conducive to accurately locating the problem.
[0006] Lack of isolation: If test operations are performed directly on business files, there is a risk of damaging critical data. Summary of the Invention
[0007] To overcome the problems existing in related technologies, this specification provides a method for testing flash memory and a network device.
[0008] According to a first aspect of the embodiments of this specification, a method for detecting a flash memory is provided, the method comprising: Create a test file in a preset storage path. The test file includes a fixed string or a timestamp. Perform write operation tests and / or read operation tests on the test file according to the preset cycle; The health status of the flash memory is determined based on the write operation test and / or read operation test.
[0009] The default storage path is the storage path for non-critical business operations.
[0010] The storage paths for non-critical business operations include storage paths that are isolated from the software, data, and configuration necessary for the normal operation of the equipment.
[0011] The test includes performing write operations on the test file, including: Write preset test data to the test file and generate write operation test results based on the results of writing the preset test data.
[0012] The test includes performing read operations on the test file, including: After writing the preset test data to the test file, the test data is read from the test file, and the read operation test result is generated based on the result of reading the test data.
[0013] The determination of the health status of the flash memory based on the write operation test and / or read operation test includes: If writing the preset test data to the test file fails, the write operation is deemed to have failed, and the first alarm is triggered. If reading test data from the test file fails, or if the read test data is inconsistent with the written test data, the read operation is deemed to have failed, and a second alarm is triggered.
[0014] The first and second alarms include SNMP Trap messages, and the corresponding events are recorded in the system log; The first alarm corresponds to an SNMP Trap message indicating a Flash write test failure, while the second alarm corresponds to an SNMP Trap message indicating a Flash read test failure.
[0015] As can be seen from the above embodiments, by creating test files and performing write and read operations on the test files, proactive detection can be achieved, and the Flash memory can be regularly "checked up." This allows for the early detection of trends in storage media performance degradation or bad block increases before users perceive business problems (such as configuration saving failures).
[0016] Meanwhile, all testing operations are performed on independent test files, completely isolated from real business data and the file system, thus avoiding the risk of business data corruption caused by the testing behavior itself.
[0017] Meanwhile, distinguishing between "read failure" and "write failure" provides maintenance personnel with more accurate fault information. For example, "write failure" may indicate an early sign that the Flash memory is nearing the end of its lifespan or that bad blocks exist, while "read failure" may mean that the data has been corrupted, which helps in taking different emergency measures.
[0018] According to a second aspect of the embodiments of this specification, a network device is provided, the network device comprising: The configuration module is used to create test files in a preset storage path. The test files include: a fixed string or a timestamp. The testing module is used to perform write operation tests and / or read operation tests on the test file according to a preset period. The analysis module is used to determine the health status of the flash memory based on the write operation test and / or read operation test.
[0019] The default storage path is the storage path for non-critical business operations; The test module is specifically used to write preset test data into the test file and generate write operation test results based on the results of writing the preset test data. After writing the preset test data to the test file, the test data is read from the test file, and the read operation test result is generated based on the result of reading the test data.
[0020] Specifically, the analysis module is used to determine that the write operation has failed and trigger the first alarm if it fails to write the preset test data to the test file. If reading test data from the test file fails, or if the read test data is inconsistent with the written test data, the read operation is deemed to have failed, and a second alarm is triggered.
[0021] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this specification. Attached Figure Description
[0022] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this specification and, together with the description, serve to explain the principles of this specification.
[0023] Figure 1 This is a schematic flowchart illustrating a method for detecting a flash memory according to an exemplary embodiment.
[0024] Figure 2 This is a schematic flowchart illustrating a method for detecting a flash memory according to an exemplary embodiment. Detailed Implementation
[0025] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this specification. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this specification as detailed in the appended claims.
[0026] The terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to be limiting of this specification. The singular forms “a,” “the,” and “the” as used in this specification and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any and all possible combinations of one or more of the associated listed items.
[0027] It should be understood that although the terms first, second, third, etc., may be used in this specification to describe various information, this information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of this specification, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to determination."
[0028] To address the issues of lag, interference, and incompleteness in existing passive flash memory fault testing methods, this disclosure provides a method for detecting flash memory, such as... Figure 1 As shown, the method includes: S101 creates a test file in a preset storage path, the test file including: a fixed string or a timestamp; S102 performs write operation tests and / or read operation tests on the test file according to a preset cycle; S103 determines the health status of the flash memory based on the write operation test and / or read operation test.
[0029] In this embodiment, the preset storage path is a storage path for non-critical business operations. For example, a storage path that is isolated from the software, data, and configuration necessary for the normal operation of the device is used as the storage path for creating test files.
[0030] The purpose is to completely isolate the testing actions from the business data operations during the subsequent testing of the test files, ensuring that the testing behavior does not affect any business functions or data security, and solving the risks that the testing operation itself may bring.
[0031] In this embodiment, performing a write operation test on the test file includes: Write pre-defined test data to the test file and generate write operation test results based on the results of writing the pre-defined test data. For example, write the current timestamp and a random number to the test file and record whether the write operation is successful or failed. If successful, the write operation is considered normal; if it fails, the write operation is considered to have failed, and the first alarm is triggered. In this embodiment, the first alarm can be a high-priority SNMP alarm, with the alarm information explicitly identifying the fault type as "Flash write test failed". Simultaneously, a Severity-level log entry is recorded in the device's syslog, containing a timestamp, fault type, and test file path.
[0032] After writing to the test file, the written test data can be read from the test file. If the read is successful and the read data matches the written test data, the read operation is considered normal. Conversely, if the read fails or the read test data does not match the written test data, the read operation is considered to have failed, and a second alarm is triggered. This second alarm can be a high-priority SNMP alarm message labeled "Flash read test failed or data verification error". Similarly, the corresponding severity level is logged in the syslog.
[0033] Based on the above method embodiments, this disclosure also provides an example, such as... Figure 2 As shown.
[0034] Initialization phase: a. Create a test file named test_flash.txt in a non-critical path of the device's Flash memory. The initial content of this file can be a fixed string or a timestamp.
[0035] b. Configure monitoring strategies, including the execution cycle of read / write tests (e.g., every 24 hours), test file paths, and associated alarm actions.
[0036] Active Probe Cycle: a. Trigger a complete Flash health detection task according to the preset cycle.
[0037] b. Write operation test: Attempt to write new test data (e.g., the current timestamp and a random number) to the test_flash.txt file. Record the result of the write operation (success or failure).
[0038] c. Read Operation Verification: Immediately after a successful write operation, read the contents of the test_flash.txt file. Compare the read contents with the test data just written to verify their consistency. Record the read operation and verification result (success or failure).
[0039] d. If both read and write operations are successful, the current probe ends and waits for the next cycle without generating any alarms or logs.
[0040] Fault diagnosis and differentiated alarms: a. Write operation failure determination: When writing data to test_flash.txt, if the system returns an error, the write operation is determined to have failed.
[0041] b. Read operation failure judgment: If the data read from test_flash.txt is inconsistent with the data verification (i.e., the content read does not match the content written), the read operation is judged as a failure.
[0042] c. Alarm Trigger: If a write operation fails, a high-priority SNMP alarm (Trap) is generated and sent, explicitly indicating the fault type as "Flash write test failed". Simultaneously, a Severity-level log entry is recorded in the device's syslog, including a timestamp, fault type, and test file path.
[0043] If a read operation fails (including verification failure), a medium-to-high priority SNMP alarm will be generated and sent, with the alarm message identified as "Flash read test failed or data verification error". Similarly, the corresponding severity level will be logged in syslog.
[0044] * The SNMP alarms can be received and displayed by the Network Management System (NMS), and the syslog can be sent to the log server for centralized analysis.
[0045] Resource isolation and security: The entire probing process is strictly limited to a dedicated test file, test_flash.txt, which is completely isolated from the operating system image, configuration files, business logs, and other data required for device operation, ensuring that the probing behavior will not interfere with or damage any critical business data.
[0046] As can be seen from the above embodiments, this embodiment, by creating test files and performing read / write operations on them, can proactively probe the flash memory and periodically perform "check-ups" on the flash. This allows for the early detection of performance degradation or increasing bad blocks before users perceive business problems (such as configuration save failures). Furthermore, all test operations are performed on independent test files, completely isolated from real business data and the file system, avoiding the risk of data corruption due to the testing itself. Additionally, distinguishing between "read failures" and "write failures" provides maintenance personnel with more accurate fault information. For example, a "write failure" may indicate an impending end of flash lifespan or the presence of bad blocks, while a "read failure" may mean data corruption, facilitating the implementation of different emergency measures.
[0047] Based on the above method embodiments, this disclosure also provides a network device, the network device comprising: The configuration module is used to create test files in a preset storage path. The test files include: a fixed string or a timestamp. The testing module is used to perform write operation tests and / or read operation tests on the test file according to a preset period. The analysis module is used to determine the health status of the flash memory based on the write operation test and / or read operation test.
[0048] The default storage path is the storage path for non-critical business operations; The test module is specifically used to write preset test data into the test file and generate write operation test results based on the results of writing the preset test data. After writing the preset test data to the test file, the test data is read from the test file, and the read operation test result is generated based on the result of reading the test data.
[0049] Specifically, the analysis module is used to determine that the write operation has failed and trigger the first alarm if it fails to write the preset test data to the test file. If reading test data from the test file fails, or if the read test data is inconsistent with the written test data, the read operation is deemed to have failed, and a second alarm is triggered.
[0050] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The device embodiments described above are merely illustrative. The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of the solution in this specification according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0051] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0052] Other embodiments of this specification will readily occur to those skilled in the art upon consideration of the specification and practice of the invention claimed herein. This specification is intended to cover any variations, uses, or adaptations that follow the general principles of this specification and include common knowledge or customary techniques in the art not claimed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this specification are indicated by the following claims.
[0053] It should be understood that this specification is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this specification is limited only by the appended claims.
[0054] The above description is merely a preferred embodiment of this specification and is not intended to limit this specification. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this specification should be included within the scope of protection of this specification.
Claims
1. A method for detecting flash memory, characterized in that, The method includes: Create a test file in a preset storage path. The test file includes a fixed string or a timestamp. Perform write operation tests and / or read operation tests on the test file according to the preset cycle; The health status of the flash memory is determined based on the write operation test and / or read operation test.
2. The method according to claim 1, characterized in that, The default storage path is the storage path for non-critical business operations.
3. The method according to claim 2, characterized in that, The storage paths for non-critical business operations include storage paths that are isolated from the software, data, and configuration necessary for the normal operation of the equipment.
4. The method according to claim 1, characterized in that, Perform write operation tests on the test file, including: Write preset test data to the test file and generate write operation test results based on the results of writing the preset test data.
5. The method according to claim 4, characterized in that, Perform read operation tests on the test file, including: After writing the preset test data to the test file, the test data is read from the test file, and the read operation test result is generated based on the result of reading the test data.
6. The method according to claim 4 or 5, characterized in that, The health status of the flash memory is determined based on the write operation test and / or read operation test, including: If writing the preset test data to the test file fails, the write operation is deemed to have failed, and the first alarm is triggered. If reading test data from the test file fails, or if the read test data is inconsistent with the written test data, the read operation is deemed to have failed, and a second alarm is triggered.
7. The method according to claim 6, characterized in that, The first and second alarms include SNMP Trap messages, and the corresponding events are recorded in the system log; The first alarm corresponds to an SNMP Trap message indicating a Flash write test failure, while the second alarm corresponds to an SNMP Trap message indicating a Flash read test failure.
8. A network device, characterized in that, The network device includes: The configuration module is used to create test files in a preset storage path. The test files include: a fixed string or a timestamp. The testing module is used to perform write operation tests and / or read operation tests on the test file according to a preset period. The analysis module is used to determine the health status of the flash memory based on the write operation test and / or read operation test.
9. The network device according to claim 8, characterized in that, The default storage path is the storage path for non-critical business operations; The test module is specifically used to write preset test data into the test file and generate write operation test results based on the results of writing the preset test data. After writing the preset test data to the test file, the test data is read from the test file, and the read operation test result is generated based on the result of reading the test data.
10. The network device according to claim 9, characterized in that, The analysis module is specifically used to determine that the write operation has failed and trigger the first alarm if it fails to write the preset test data to the test file. If reading test data from the test file fails, or if the read test data is inconsistent with the written test data, the read operation is deemed to have failed, and a second alarm is triggered.