Storage device control method and device, equipment and medium
By implementing error verification of the current storage sector and transferring data to the backup sector in the storage device, the error failure problem caused by the storage device after power outage is solved, and the stability of the system is improved.
Patent Information
- Application Number
- CN202411548592.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-31
- Publication Date
- 2025-02-28
AI Technical Summary
During the ermination process of the storage device, a sudden power outage may cause the ergonomic failure, which will cause errors in the storage sector. The system cannot verify correctly after the power supply is restored, resulting in the system being paralyzed and dead, and the stability is reduced.
A storage device control method is provided. By acquiring the current storage sector and performing error verification, if an error failure occurs, the storage location and data of the storage sector are obtained, the backup storage sector is determined, the data is written to the backup sector, and the first register is controlled to avoid an error from the fault control device.
It effectively avoids system paralysis caused by storage sector error failure, improves system stability, and ensures that the storage device can operate normally in error situations.
Smart Images

Figure CN119536638A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to, but is not limited to, the field of storage processing, and in particular to a storage device control method, device, equipment, and medium. Background Art
[0002] If a power outage occurs suddenly during the erasing and writing process of the storage device, the erasing and writing may fail, which may lead to an error in a storage sector in the storage device. When the system initializes the storage device after power is restored, if it passes through the error storage sector, it will not be able to jump due to the inability to correctly check, that is, it will read repeatedly and get stuck in the error storage sector, causing the system to crash and freeze, and reducing the stability of the system. Summary of the invention
[0003] The embodiments of the present application provide a storage device control method, device, equipment and medium, which can effectively improve the stability of the system.
[0004] In a first aspect, an embodiment of the present application provides a storage device control method, wherein the storage device comprises a high-speed storage unit, a first register, and a fault control device, wherein the first register is used to control the working state of the fault control device, the high-speed storage unit is composed of a plurality of storage sectors, and the storage sector is composed of a plurality of storage blocks, when the first register is in a closed state, the fault control device starts to work, and when the first register is in an open state, the fault control device stops working, the current storage sector is the storage sector in use in the high-speed storage unit, and the backup storage sector is the storage sector in the high-speed storage unit that is in a waiting state;
[0005] The control method comprises:
[0006] Acquire the current storage sector, and perform error checking on the current storage sector;
[0007] When an error occurs in the current storage sector, obtaining storage locations of a plurality of the storage sectors and storage data of the storage blocks in the current storage sector;
[0008] The backup storage sector is determined according to the storage position, the storage data is written into the backup storage sector, and the first register is controlled to be in an on state.
[0009] According to the storage device control method of the first aspect of the present application, there are at least the following beneficial effects: if a storage sector in the storage device has a storage error fault, the storage sector cannot be used normally, which in turn causes the system using the storage device to be paralyzed and freeze. Therefore, before reading and writing the storage sector, the current storage sector in use in the high-speed storage unit can be obtained first, and the current storage sector can be error-checked to determine whether the current storage sector has an error fault, so as to avoid continuing the read and write operation when the current storage sector has an error fault. If an error fault occurs in the current storage sector, the storage positions of multiple storage sectors and the storage data of the current storage sector are obtained, and then the backup storage sector is determined according to the storage position, the storage data is written to the backup storage sector and the first register is controlled to be in an open state, and the storage data of the current storage sector with a fault is written to the backup storage sector while avoiding the fault control device reporting an error, so as to improve the stability of the system.
[0010] According to some embodiments of the first aspect of the present application, the control method further includes:
[0011] A first storage address of the current storage sector is obtained, and the address of the backup storage unit is replaced with the first storage address.
[0012] According to some embodiments of the first aspect of the present application, when an error failure occurs in the current storage sector, obtaining storage locations of a plurality of the storage sectors and storage data of the storage blocks in the current storage sector includes:
[0013] When an error occurs in the current storage sector, storage locations of multiple storage sectors and storage data of the last valid storage block in the current storage sector are obtained.
[0014] According to some embodiments of the first aspect of the present application, determining the backup storage sector according to the storage location includes:
[0015] According to the storage position, the storage sector next to the current storage sector is determined as a backup storage sector.
[0016] According to some embodiments of the first aspect of the present application, the control method further includes:
[0017] The storage conditions of all the storage blocks in the storage sector are obtained, and when all the storage blocks are completely written, data erasing processing is performed on the storage sector.
[0018] According to some embodiments of the first aspect of the present application, the control method further includes:
[0019] The backup storage sector is set as a valid storage sector and the current storage sector is set as an invalid storage sector.
[0020] According to some embodiments of the first aspect of the present application, the control method further includes:
[0021] The number of sectors of the invalid storage sectors in the high-speed storage unit is obtained, and when the number of sectors reaches a first preset condition, the first register is controlled to be closed.
[0022] In a second aspect, an embodiment of the present application provides an operation control device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the storage device control method as described in the first aspect is implemented.
[0023] In a third aspect, an embodiment of the present application provides an electronic device, comprising an operation control device as described in the embodiment of the second aspect.
[0024] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the storage device control method as described in the embodiment of the first aspect.
[0025] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the description, claims and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The accompanying drawings are used to provide a further understanding of the technical solution of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the technical solution of the present invention and do not constitute a limitation on the technical solution of the present invention.
[0027] Figure 1 A schematic diagram of the structure of a storage device provided in an embodiment of the present application;
[0028] Figure 2 A flowchart of a storage device control method provided in an embodiment of the present application;
[0029] Figure 3 A flowchart of a storage device control method provided by another embodiment of the present application;
[0030] Figure 4 for Figure 2 Specific flow chart of step S200;
[0031] Figure 5 A flowchart of a storage device control method provided by another embodiment of the present application;
[0032] Figure 6 A flowchart of a storage device control method provided by another embodiment of the present application;
[0033] Figure 7 An operation control device is provided for an embodiment of the present application. DETAILED DESCRIPTION
[0034] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0035] It is understood that although the functional modules are divided in the device schematic diagram and the logical order is shown in the flow chart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flow chart. The terms "first", "second", etc. in the specification, claims or the above drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0036] At present, if a power outage occurs suddenly during the erasing and writing process of a storage device, the erasing and writing may fail, which may lead to an error in a storage sector in the storage device. When the system initializes the storage device after power is restored, if the error storage sector is passed, it will not be able to jump due to the inability to correctly check, that is, repeated reading, and it will be stuck in the error storage sector, causing the system to crash and deteriorate the stability of the system.
[0037] Based on this, the embodiments of the present application provide a control method, device, equipment and medium for a storage device. If a storage sector in the storage device has a storage error fault, the storage sector cannot be used normally, which in turn causes the system using the storage device to be paralyzed and freeze. Therefore, before reading and writing the storage sector, the current storage sector in use in the high-speed storage unit can be obtained first, and the current storage sector can be error-checked to determine whether the current storage sector has an error fault, so as to avoid continuing the read and write operation when the current storage sector has an error fault. If an error fault occurs in the current storage sector, the storage positions of multiple storage sectors and the storage data of the current storage sector are obtained, and then the backup storage sector is determined according to the storage position, the storage data is written to the backup storage sector and the first register is controlled to be in an open state. In the case of avoiding an error report from the fault control device, the storage data of the current storage sector with a fault is written to the backup storage sector, thereby improving the stability of the system.
[0038] The embodiments of the present application are further described below in conjunction with the accompanying drawings.
[0039] Reference Figure 1 , Figure 1 A schematic diagram of the structure of a storage device provided in an embodiment of the present application.
[0040] It can be understood that the storage device includes a high-speed storage unit, a first register and a fault control device, the high-speed storage unit is composed of a plurality of storage sectors, the storage sector is composed of a plurality of storage blocks, and the first register is used to control the working state of the fault control device. Under normal circumstances, if no error or fault occurs in all storage sectors, the first register is in an open state, and the fault control device stops working; similarly, under normal circumstances, if an error or fault occurs in any storage sector, the first register enters a closed state, the fault control device starts working, and sends an alarm signal to the device connected to the storage device.
[0041] First, refer to Figure 2 , Figure 2 A flowchart of a storage device control method provided in an embodiment of the present application, which can be applied to the above Figure 1 The control method includes but is not limited to the following steps:
[0042] Step S100, obtaining the current storage sector and performing error checking on the current storage sector;
[0043] Step S200, when an error occurs in the current storage sector, obtaining storage locations of multiple storage sectors and storage data of the current storage sector;
[0044] Step S300, determining a backup storage sector according to the storage location, writing the storage data into the backup storage sector and controlling the first register to be in an on state;
[0045] It is understandable that if any storage sector in the high-speed storage unit has a storage error fault, the storage sector may not be used normally, which may cause the system using the storage device to crash. Therefore, before erasing the storage sector, the current storage sector in the high-speed storage unit that is in use can be obtained first, wherein the current storage sector in use can be a storage sector in a read-write state, and an error check is performed on the current storage sector to determine whether the current storage sector has an error fault. If the current storage sector has an error fault, the storage location of all storage sectors and the storage data of the storage block in the current storage sector are obtained. The backup storage sector can be determined by the storage location, which is convenient for transferring the storage data to the backup storage sector. Therefore, after the backup storage sector is determined at the storage location, the storage data can be written to the backup storage sector. In addition, since the storage data of the current storage sector in the error fault has been transferred to the backup storage sector, that is, the error fault of the current storage sector can be considered to have been processed, therefore, the storage device can control the first register to always remain in the open state to avoid the fault control device entering the working state due to the closure of the first register.
[0046] Specifically, the storage device can be applied to an embedded controller. Before the system is powered off, the embedded controller will store part of the information in a high-speed storage unit. During the process of erasing the high-speed storage unit, if a sudden power failure occurs, it may cause a certain storage sector in the high-speed storage unit to fail to be erased, resulting in an error failure in a certain storage sector. When the embedded controller is powered on again, the high-speed storage unit will be initialized. During the initialization process, when passing through a storage sector with an error failure, due to the failure of the storage sector, the storage sector may be repeatedly read and cannot jump to the next storage sector normally, thereby causing the embedded controller to crash and freeze, resulting in a decrease in the stability of the system. The present application will first perform an error check on the current storage sector before erasing the current storage sector. If the current storage sector has an error failure, the storage location of all storage sectors and the storage data of the current storage sector are obtained, and then the storage data of the current storage sector is transferred to the backup storage sector to ensure that the embedded controller can normally erase the high-speed storage unit and ensure the stability of the system.
[0047] It should be noted that the backup storage sector can be the next storage sector of the current storage sector, that is, according to the storage position, the next storage sector of the current storage sector is used as the backup storage sector. For example, the high-speed storage unit includes a first storage sector, a second storage sector, a third storage sector and a fourth storage sector with consecutive addresses. If the current storage sector is the second storage sector, the third storage sector is the backup storage sector.
[0048] It should be noted that the error check on the current storage sector can be performed by accumulating the read and write time of the current storage sector. When the read and write time is greater than a preset time threshold, it can be considered that an error failure occurs in the current storage sector. In addition, other methods can be used to perform error check on the current storage sector. The present application does not make any specific limitation on the error check on the current storage sector.
[0049] It should be noted that after the storage address and the storage data are written into the backup storage sector, the backup storage sector is set as a valid storage sector and the current storage sector is set as an invalid storage sector.
[0050] Reference Figure 3 , Figure 3 A flowchart of a storage device control method provided in another embodiment of the present application includes but is not limited to the following steps:
[0051] Step S400, obtaining a first storage address of a current storage sector, and replacing the address of a backup storage unit with the first storage address.
[0052] It can be understood that after determining the backup storage sector according to the storage position, the first storage address of the current storage sector will also be obtained. The system can determine the position of the current storage sector according to the first storage address, and then erase and write the current storage sector. Therefore, while writing the stored data to the backup storage sector, the address of the backup storage sector can also be replaced with the first storage address. When the address of the backup storage sector is replaced with the first storage address, the system will directly read and write the backup storage sector when erasing according to the first storage address, thereby avoiding the system from reading and writing the current storage sector that has an error or failure, and effectively ensuring the stability of the system.
[0053] Reference Figure 4 , Figure 4 for Figure 2 The specific flow chart of step S200 includes but is not limited to the following steps:
[0054] Step S210: when an error occurs in the current storage sector, the storage locations of multiple storage sectors and the storage data of the last valid storage block in the current storage sector are obtained.
[0055] It is understandable that a storage sector includes multiple storage blocks. During the process of erasing a high-speed storage unit, if a sudden power outage occurs, it may cause a storage block in the storage sector to fail to be erased, thereby causing an error failure in the storage sector. However, since a storage sector includes multiple storage blocks, even if one of the storage blocks fails, the remaining storage blocks can still be used normally. Therefore, when an error failure occurs in the current storage sector, the storage locations of multiple storage sectors and the storage data of the last valid storage block in the current storage sector can be obtained, and then the backup storage sector is determined according to the storage location, and finally the storage data of the last valid storage block is written to the backup storage sector, wherein the last valid storage block in the current storage sector is the previous storage block of the failed storage block.
[0056] It should be noted that, when the storage data of the last valid storage block in the current storage sector is obtained, the storage address of the storage block is also obtained, and when the storage data is written into the backup storage sector, the storage address is also written.
[0057] Specifically, the backup storage sector is determined according to the storage position, and the position of each storage block in the backup storage sector is obtained, and then the backup storage block is determined, and finally the storage data of the last valid storage block in the current storage sector is written to the backup storage block, and the storage address of the backup storage block is replaced with the storage address of the last valid storage block in the current storage sector, so as to avoid the system from reading and writing the failed storage block and improve the stability of the system, wherein the backup storage block can be the first valid storage block in the backup storage sector.
[0058] It should be noted that after the storage address and the storage data are written into the backup storage block, the backup storage block is set as a valid storage block and the last valid storage block in the current storage sector is set as an invalid storage block.
[0059] Reference Figure 5 , Figure 5 A flowchart of a storage device control method provided in another embodiment of the present application includes but is not limited to the following steps:
[0060] Step S500, obtaining the storage status of all storage blocks in the storage sector, and when all storage blocks are completely written, performing data erasing processing on the storage sector.
[0061] It is understandable that the service life of the storage sector will decrease as the number of erase and write times increases. Therefore, while performing error checking on the current storage sector, the storage status of all storage blocks in the storage sector can also be obtained to determine whether each storage block has been written. If all storage blocks have been written, the storage sector is erased. By limiting the storage sector to the case where all storage blocks have been written, the storage sector is erased, which can effectively reduce the number of erase and write times of the storage sector, increase the service life of the storage device, and thus improve the stability of the system.
[0062] It should be noted that, in some embodiments, when the storage space occupied by the data stored in the storage sector reaches a preset storage threshold, the storage sector can be considered to be full, wherein the preset storage threshold can be 80% or 90%, and the specific preset storage threshold can be adjusted according to actual conditions.
[0063] Reference Figure 6 , Figure 6 A flowchart of a storage device control method provided in another embodiment of the present application includes but is not limited to the following steps:
[0064] Step S600, obtaining the number of invalid storage sectors in the high-speed storage unit, and when the number of sectors reaches a first preset condition, controlling the first register to be closed.
[0065] It is understandable that as the system is used for a long time, the number of storage sectors with error faults will gradually increase. Since the present application will mark the storage sectors with error faults as invalid storage sectors, the number of valid storage sectors will gradually increase as the system is used for a long time. When the number of invalid storage sectors in the high-speed storage unit reaches the first preset condition, it will affect the storage efficiency of the high-speed storage unit. Therefore, it is necessary to control the first register to be closed when the number of sectors reaches the first preset condition. When the first register is closed, the fault control device will enter the working state to perform fault reminders and error reports.
[0066] It should be noted that the number of sectors reaching the first preset condition may be that the ratio of the number of invalid storage sectors to the number of all storage sectors is greater than or equal to a first preset threshold, wherein the first preset threshold may be 70%, that is, when the ratio of the number of invalid storage sectors to the number of all storage sectors is greater than or equal to 70%, it is considered that the first preset condition is reached, and the specific preset first threshold may be adjusted according to actual conditions.
[0067] Second, refer to Figure 7The present application embodiment provides an operation control device 700, including a memory 710, a processor 720, and a computer program stored in the memory 710 and executable on the processor 720. The processor 720 executes the program to implement the control method of the storage device in the first aspect of the embodiment, for example, executing Figure 2 Steps S100 to S300, Figure 3 In the method step S400, Figure 4 In the method step S210, Figure 5 Method step S500 and Figure 6 Method step S600 in .
[0068] The memory 710 is a non-transitory computer-readable storage medium that can be used to store non-transitory software programs and non-transitory computer executable programs, such as the control method of the storage device in the above-mentioned embodiment of the present application. The processor 720 implements the control method of the storage device in the above-mentioned embodiment of the present application by running the non-transitory software program and instructions stored in the memory 710.
[0069] The memory 710 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required by at least one function; the data storage area may store data required to execute the control method of the storage device in the above embodiment, etc. In addition, the memory 710 may include a high-speed random access memory 710, and may also include a non-transitory memory 710, such as at least one disk storage device, a flash memory device, or other non-transitory solid-state storage device. It should be noted that the memory 710 may optionally include a memory 710 remotely arranged relative to the processor 720, and these remote memories 710 may be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0070] In the third aspect, the embodiment of the present application provides an electronic device, the electronic device includes an operation control device 700 as in the embodiment of the second aspect. If a storage error occurs in a storage sector in the storage device, the storage sector cannot be used normally, thereby causing the system using the storage device to be paralyzed and frozen. Therefore, before reading and writing the storage sector, the current storage sector in use in the high-speed storage unit can be obtained first, and the current storage sector can be error-checked to determine whether the current storage sector has an error failure, so as to avoid continuing the read and write operation when the current storage sector has an error failure. If an error occurs in the current storage sector, the storage locations of multiple storage sectors and the storage data of the current storage sector are obtained, and then the backup storage sector is determined according to the storage location, the storage data is written to the backup storage sector and the first register is controlled to be in an open state. In the case of avoiding the fault control device reporting an error, the storage data of the current storage sector with a fault is written to the backup storage sector, thereby improving the stability of the system.
[0071] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the control method of the storage device of the first aspect embodiment above, such as executing Figure 2 Steps S100 to S300, Figure 3 In the method step S400, Figure 4 In the method step S210, Figure 5 Method step S500 and Figure 6 Method step S600 in .
[0072] It will be appreciated by those skilled in the art that all or some of the steps and systems in the disclosed methods above may be implemented as software, firmware, hardware and appropriate combinations thereof. Some physical components or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor or a microprocessor, or implemented as hardware, or implemented as an integrated circuit, such as an application specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium or a non-transitory medium and a communication medium or a temporary medium. As known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information such as computer-readable instructions, data structures, program modules or other data. Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disk DVD or other optical disk storage, magnetic cassettes, magnetic tapes, disk storage or other magnetic storage devices, or any other medium that may be used to store desired information and may be accessed by a computer. Furthermore, it is well known to those skilled in the art that communication media typically embodies computer readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.
[0073] The embodiments of the present application are described in detail above in conjunction with the accompanying drawings, but the present application is not limited to the above embodiments, and various changes can be made within the knowledge scope of ordinary technicians in the technical field without departing from the purpose of the present application.
Claims
1. A storage device control method, characterized in that: The storage device comprises a high-speed storage unit, a first register and a fault control device, wherein the first register is used to control the working state of the fault control device, the high-speed storage unit is composed of a plurality of storage sectors, and the storage sector is composed of a plurality of storage blocks, the fault control device starts to work when the first register is in a closed state, and stops working when the first register is in an open state, the current storage sector is the storage sector in the high-speed storage unit in a used state, and the backup storage sector is the storage sector in the high-speed storage unit in a waiting state; The control method comprises: Acquire the current storage sector, and perform error checking on the current storage sector; When an error occurs in the current storage sector, obtaining storage locations of a plurality of the storage sectors and storage data of the storage blocks in the current storage sector; The backup storage sector is determined according to the storage position, the storage data is written into the backup storage sector, and the first register is controlled to be in an on state.
2. The storage device control method according to claim 1, characterized in that: The control method further comprises: A first storage address of the current storage sector is obtained, and the address of the backup storage unit is replaced with the first storage address.
3. The storage device control method according to claim 1, characterized in that: When an error fault occurs in the current storage sector, obtaining storage locations of a plurality of the storage sectors and storage data of the storage blocks in the current storage sector comprises: When an error failure occurs in the current storage sector, storage locations of multiple storage sectors and storage data of the last valid storage block in the current storage sector are obtained.
4. The storage device control method according to claim 1, characterized in that: The step of determining a backup storage sector according to the storage location includes: According to the storage position, the storage sector next to the current storage sector is determined as a backup storage sector.
5. The storage device control method according to claim 1, characterized in that: The control method further comprises: The storage conditions of all the storage blocks in the storage sector are obtained, and when all the storage blocks are completely written, data erasing processing is performed on the storage sector.
6. The storage device control method according to claim 1, characterized in that: The control method further comprises: The backup storage sector is set as a valid storage sector and the current storage sector is set as an invalid storage sector.
7. The storage device control method according to claim 6, characterized in that: The control method further comprises: The number of sectors of the invalid storage sectors in the high-speed storage unit is obtained, and when the number of sectors reaches a first preset condition, the first register is controlled to be closed.
8. An operation control device, characterized in that: The invention comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the storage device control method according to any one of claims 1 to 7.
9. An electronic device, characterized in that: Comprising the operation control device as claimed in claim 8.
10. A computer storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the storage device control method according to any one of claims 1 to 7.