Data storage method, electronic equipment, storage medium and program product

By evaluating the attempt termination time of the storage service process in the power reserve state and adopting a gradually enhanced process termination strategy, the problem of difficulty in controlling the storage service process in the prior art is solved, ensuring the integrity of data drop-off.

CN119718592AActive Publication Date: 2025-03-28INSPUR SUZHOU INTELLIGENT TECH CO LTD

Patent Information

Application Number
CN202510222708.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-27
Publication Date
2025-03-28
Estimated Expiration
2045-02-27

AI Technical Summary

Technical Problem

The prior art is difficult to effectively control the storage service process, resulting in the inability to ensure the integrity of the data when the data falls from the disk when the power is in reserve.

Method used

By monitoring the target device to enter the power reserve state, it is evaluating whether the storage service process attempt termination time is present during the battery power supply time, and adopts a gradually enhanced process termination strategy, including the first process termination method and the second process termination method, to ensure that the storage service process is successfully terminated and data is dropped.

Benefits of technology

It realizes effective control of the storage service process, ensures that the data can be successfully dropped in power state, and enhances the integrity of the data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119718592A_ABST
    Figure CN119718592A_ABST
Patent Text Reader

Abstract

The invention discloses a data storage method, electronic equipment, a storage medium and a program product, and relates to the technical field of computers, when it is monitored that target equipment enters a standby power state, whether storage service process attempt termination time exists in battery power supply time corresponding to the standby power state or not is determined; and if the storage service process attempts to terminate, controlling the storage service process to terminate by adopting a first process termination mode with relatively low strength. And if the storage service process is not successfully terminated by using the first process termination mode and the condition of the second process termination mode is met, controlling the storage service process to terminate by adopting the second process termination mode with higher strength. And if the storage service process is successfully terminated, carrying out data disk dropping. Through a step-by-step enhanced staged process termination strategy, effective management and control of a storage service process termination process can be realized, and data integrity can be ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a method for storing data on a disk, an electronic device, a storage medium, and a program product. Background Art

[0002] The backup power state refers to the process in which the system automatically switches to the backup battery to maintain critical operations and ensure data security when the main power fails. When the power stops supplying power, the backup battery will continue to power the storage device, and the system will immediately stop the storage service process, collect cache data and cluster information that have not yet been written to the disk, and write this data to the system disk (that is, data is written to the disk) to complete persistent storage and ensure data integrity.

[0003] However, the related technology has the problem of being unable to effectively control the storage service process when storing data on disk, and it is difficult to ensure data integrity. Summary of the invention

[0004] The present application provides a method for storing data on a disk, an electronic device, a storage medium and a program product to at least solve the problem of controlling the storage service process and ensuring data integrity in the related art.

[0005] The present application provides a method for storing data on a disk, including:

[0006] In response to monitoring that the target device enters a power standby state, determining whether there is a storage service process attempt termination time within a battery power supply time corresponding to the power standby state;

[0007] If there is a storage service process attempt termination time, using the first process termination method to control the storage service process to terminate at least once within the storage service process attempt termination time;

[0008] If at least one attempt to terminate the storage service process by using the first process termination method fails and the condition for terminating the storage service process by using the second process termination method is met, the second process termination method is used to terminate the storage service process, and the strength of the second process termination method is greater than the strength of the first process termination method;

[0009] In response to determining that the storage service process is terminated successfully by using the second process termination method, data is written to the disk.

[0010] The present application also provides a data storage device, comprising:

[0011] A determination module, configured to, in response to monitoring that the target device enters a power standby state, determine whether there is a storage service process attempt termination time within a battery power supply time corresponding to the power standby state;

[0012] The first control module, if there is a storage service process attempt termination time, controls the storage service process to terminate by using a first process termination method at least once within the storage service process attempt termination time;

[0013] A second control module is used to control the storage service process to terminate by the second process termination method if at least one attempt to control the storage service process to terminate by the first process termination method fails and the condition for controlling the storage service process to terminate by the second process termination method is met, and the strength of the second process termination method is greater than the strength of the first process termination method;

[0014] The data storage module is used to store data on the disk in response to determining that the storage service process is successfully terminated by using the second process termination method.

[0015] The present application also provides an electronic device, comprising: a memory, a transceiver and a processor, wherein the memory is used to store a computer program; the transceiver is used to send and receive data under the control of the processor; and the processor is used to implement the steps of any one of the above-mentioned data storage methods when executing the computer program.

[0016] The present application also provides a computer-readable storage medium, in which a computer program is stored, wherein when the computer program is executed by a processor, the steps of any of the above-mentioned data storage methods are implemented.

[0017] The present application also provides a computer program product, including a computer program, which implements the steps of any of the above-mentioned data storage methods when executed by a processor.

[0018] Through the present application, when it is monitored that the target device enters the backup power state, it will be evaluated whether there is a storage service process attempt termination time within the battery power time. If there is a storage service process attempt time, the first process termination method with lower intensity will be used to control the termination of the storage service process. If the first process termination method fails and the conditions for controlling the termination of the storage service process using the second process termination method are met, the second process termination method with higher intensity will be used to terminate the storage service process. If the storage service process is terminated successfully, the data is written to the disk. The technical solution of the present application uses a gradually enhanced termination strategy to ensure that even if the first process termination method fails to make the storage service process unable to respond normally, the second process termination method can be used to successfully terminate the process and write data to the disk, thereby enhancing the control and management of the storage service process, thereby ensuring the integrity of the data. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0020] Figure 1 An application scenario diagram of a method for storing data on a disk provided in an embodiment of the present application;

[0021] Figure 2 A schematic diagram of a method for storing data on a disk provided in an embodiment of the present application Figure 1 ;

[0022] Figure 3 A schematic diagram of a method for storing data on a disk provided in an embodiment of the present application Figure 2 ;

[0023] Figure 4 A schematic diagram of a method for storing data on a disk provided in an embodiment of the present application Figure 3 ;

[0024] Figure 5 A schematic diagram of a data storage device provided in an embodiment of the present application;

[0025] Figure 6 A schematic diagram of the structure of another data storage device 10 provided in an embodiment of the present application;

[0026] Figure 7 A schematic diagram of the structure of the electronic device provided in this application.

[0027] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION

[0028] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0029] It should be noted that, in the description of this application, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. The terms "first", "second", etc. in this application are used to distinguish similar objects, and are not used to describe a specific order or sequence.

[0030] In the event of a main power outage, the backup battery, as a power supply unit, starts to supply power to the storage device, ensuring the continuation of critical operations and the security of data. The data drop technology in the backup power state is designed to immediately terminate the storage service process after detecting that the main power supply stops supplying power, collect cache data and cluster information that have not been dropped to the disk, and write these data to the system disk, and finally turn off the battery power and shut down. In this process, the basic service process and the storage service process work together. The storage service process is responsible for the actual storage business, while the basic service process is responsible for tasks such as monitoring the power status, pulling up and terminating the storage service process, collecting drop data, and managing battery discharge. However, if the storage service process cannot respond normally and exit due to its own problems, the basic service process will always wait for it to exit, resulting in the inability to continue the subsequent data drop and storage device power-off operations. This situation may eventually cause the storage device to be forced to shut down due to battery exhaustion, increasing the risk of data loss or damage. Therefore, the related technology has the problem of difficulty in effectively controlling the storage service process and ensuring data integrity.

[0031] In order to achieve effective control over the storage service process, when the target device is monitored to enter the standby power state, it can be evaluated whether there is a storage service process attempt termination time within the battery power supply time. If there is a storage service process attempt termination time, it means that the storage service process can be attempted to be terminated. In addition, a gradually enhanced phased process termination strategy can be used to manage the storage service process. A retry mechanism can be set to control the termination of the storage service process using a first process termination method with a lower intensity, allowing the storage service process to have the opportunity to perform necessary cleanup operations and exit normally, thereby reducing the risk of data loss. If the storage service process fails to be successfully terminated using the first process termination method and the conditions of the second process termination method are met, the second process termination method with a higher intensity is used to control the termination of the storage service process. If the storage service process is successfully terminated, the data is written to the disk to ensure that the data is correctly written to the disk. By judging the storage service process attempt termination time and adopting a phased process termination strategy, it is possible to avoid meaningless repeated attempts, improve the efficiency and success rate of storage service process termination, achieve effective management and control of the storage service process, and ensure data integrity.

[0032] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.

[0033] In combination with the specific application environment architecture or specific hardware architecture on which the execution of the data storage method depends, the specific application environment architecture or specific hardware architecture is described here. Figure 1 , Figure 1 This is an application scenario diagram of a data storage method provided in an embodiment of the present application. Figure 1 As shown, it includes a target device 101 and a battery 102. The battery 102 is used to power the target device 101 when the main power supply is interrupted, so that the target device 101 enters a backup power state, ensuring that the target device 101 can continue to operate for a period of time to support data storage. If there is a storage service process attempt termination time within the battery power supply time corresponding to the backup power state, the storage service process can be controlled to terminate by using a first process termination method with a lower intensity at least once within the storage service process attempt termination time. If the first process termination method cannot successfully terminate the storage service process and the conditions for controlling the storage service process termination by using a second process termination method are met, the second process termination method with a higher intensity can be used to control the storage service process termination. When the storage service process is successfully terminated, the data storage operation can be performed.

[0034] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0035] Figure 2 A schematic diagram of a method for storing data on a disk provided in an embodiment of the present application Figure 1 , the method is described in detail as follows:

[0036] S201: In response to monitoring that the target device enters a power standby state, determining whether there is a storage service process attempt termination time within the battery power supply time corresponding to the power standby state.

[0037] The target device refers to the storage device or system whose data integrity needs to be protected, such as a server, monitoring device, etc.

[0038] The backup power state refers to the state of switching to the backup battery power supply when the main power supply is unavailable. This state can reduce the impact of sudden power outages on the services on the target device.

[0039] Battery life refers to the length of time that a backup battery can provide power to a system. Battery life can depend on, among other things, the battery capacity and the power consumption of the target device when it is in backup mode.

[0040] The storage service process may be an application or service responsible for managing data storage services.

[0041] In this embodiment, the basic service process can create a storage service process through a system call. The basic service process can be used to monitor the power supply status of the power supply, start the storage service process, terminate the storage service process, etc. The storage service process can be used to process storage services.

[0042] Termination means causing a running program, process, or service to stop its current operation and exit.

[0043] Specifically, if there is a storage service process termination attempt time within the battery power supply time corresponding to the backup power state, it means that the current battery power supply time is sufficient and you can try to terminate the storage service process. Otherwise, it means that the battery power supply time is not sufficient and attempting to terminate the storage service process will affect the data storage process.

[0044] As an optional implementation, the following steps can be used to determine whether there is a storage service process attempt termination time within the battery power time corresponding to the backup power state: determine the battery power time and the data disk drop time; in response to the battery power time being greater than the data disk drop time, determine that there is a storage service process attempt termination time within the battery power time corresponding to the backup power state; in response to the battery power time being less than or equal to the data disk drop time, determine that there is no storage service process attempt termination time within the battery power time corresponding to the backup power state.

[0045] Data flushing time refers to the time required to write data in memory to a persistent storage medium (such as a hard disk).

[0046] In this embodiment, the voltage of the backup battery and the remaining power of the backup battery can be read to calculate the remaining capacity of the backup battery, the power consumption information of the target device can be read, and the battery power supply time can be calculated based on the power consumption information of the target device and the remaining capacity of the backup battery.

[0047] Voltage refers to the current output voltage of the battery, usually measured in volts (V).

[0048] Remaining capacity refers to the length of time the battery can continue to provide 1 mA of current under specific conditions (usually the nominal voltage), usually expressed in milliampere hours (mAh).

[0049] In order to calculate the battery life, the remaining power can be converted into the remaining capacity expressed in milliwatt-hours (mWh). The remaining capacity can be calculated as follows:

[0050]

[0051] Device power consumption refers to the energy consumed by the device per second, usually measured in watts (W). The average power consumption of the device can be regarded as the device power consumption.

[0052] The battery life can be calculated as follows:

[0053]

[0054] In this embodiment, the amount of data that needs to be written to disk and the speed at which the data is written to disk can be obtained, and the time for writing the data to disk can be calculated.

[0055] The amount of data can be expressed in bytes. The write rate refers to the speed at which data is written from memory to the storage medium. It can be expressed in bytes written per second. The data write time can be calculated as follows:

[0056]

[0057] For example, the battery power time and the data disk write time can be compared. If the battery power time is greater than the data disk write time, it means that the battery has enough power to support the completion of all data write operations. It can be determined that there is a storage service process attempt termination time within the battery power time corresponding to the backup power state, so the storage service process termination operation can be attempted. Correspondingly, if the battery power time is less than or equal to the data disk write time, it means that there is no storage service process attempt termination time within the battery power time corresponding to the backup power state, which means that even if data writing starts immediately, all operations may not be completed before the battery is exhausted, so the storage service process termination operation can be ignored.

[0058] In this embodiment, by comparing the battery power supply time and the data disk drop time, it can be determined whether there is sufficient time to attempt to terminate the storage service process in the backup power state. When the battery power supply time is greater than the data disk drop time, it means that there is sufficient time and you can try to terminate the storage service process. When the battery power supply time is less than or equal to the data disk drop time, you can give up trying to terminate the operation to prevent additional energy consumption or data risks due to invalid operations. Not only does it optimize the management logic of the storage service process, it also improves the control efficiency of the storage service process, which is conducive to ensuring data integrity.

[0059] As an optional implementation, after determining that there is no storage service process attempt termination time within the battery power supply time corresponding to the backup power state, the target device may be powered off without flushing data to disk.

[0060] When it is determined that the battery power supply time is insufficient to support data write to disk, the target device can be powered off directly without wasting time trying to terminate the storage service process or execute data write to disk. This method avoids invalid operations under low power conditions and simplifies the operation process. In addition, the direct power-off operation on the target device can also reduce the risk of unstable operation of the target device caused by delaying the power-off operation, allowing the target device to be powered off quickly and safely, ensuring the overall stability of the target device in the backup power state, and also helping to ensure data integrity.

[0061] S202: If there is a storage service process termination attempt time, the storage service process is terminated by using the first process termination method at least once within the storage service process termination attempt time.

[0062] The attempted termination time may be a time window, and the storage service process may be terminated within the attempted termination time.

[0063] In this embodiment, the first process termination method refers to a method of preferentially terminating the storage service process within the process termination attempt time. The first process termination method may be a relatively gentle process termination method.

[0064] As an optional implementation, if there is a storage service process termination attempt time, the difference between the battery power supply time and the data disk write time can be calculated, and the difference can be determined as the storage service process termination attempt time.

[0065] The difference value can represent how much time is left to try to terminate the storage service process after completing the data write operation. If the difference value is large, it means that the termination time used to try to terminate the storage service process is large; correspondingly, if the difference value is small, it means that the termination time used to try to terminate the storage service process is small.

[0066] By calculating the difference between the battery power time and the data write time, and determining the difference as the storage service process attempt termination time, this method can more accurately quantify the time available for the storage service process termination operation, thereby providing a clear time window for the storage service process termination. If the difference is large, it means that there is more time to try to terminate the storage service process, which increases the chance of successfully shutting down the storage service process and ensuring data integrity. On the contrary, if the difference is small, it means that the available time is limited, and a quick response can be made based on this to avoid data loss due to insufficient power.

[0067] S203: If the first process termination method is used to control the termination of the storage service process at least once and the conditions for using the second process termination method to control the termination of the storage service process are met, the second process termination method is used to control the termination of the storage service process, and the strength of the second process termination method is greater than the strength of the first process termination method.

[0068] Strength can be the intensity and priority of the impact on the storage service process. For example, strength can be reflected in aspects such as mandatory and captureability. For example, when the first process termination method is used to control the termination of the storage service process, a relatively mild termination signal can be used. This mild termination signal can be captured and processed, so that the storage service process can perform some cleanup operations and then exit on its own. Therefore, the first process termination method can be regarded as a request for process termination rather than a mandatory command; accordingly, when the second process termination method is used to control the termination of the storage service process, a non-ignorable termination signal can be used. Once the storage service process receives such a signal, it needs to perform the termination operation immediately, and the capture and processing of such a signal is not allowed.

[0069] Exemplarily, after the failure of controlling the termination of the storage service process using the first process termination method, a termination times threshold may be used to determine whether the condition for controlling the termination of the storage service process using the second process termination method is currently met. For example, the preset termination times threshold may be m, which means that the process of controlling the termination of the storage service process using the first process termination method may be executed at most m times. If the process of controlling the termination of the storage service process using the first process termination method has been executed m times, but the storage service process is still not terminated normally, then it may be considered that the condition for controlling the termination of the storage service process using the second process termination method is currently met.

[0070] S204: In response to determining that the storage service process is terminated successfully by using the second process termination method, data is written to disk.

[0071] Specifically, when the second process termination method is used to control the termination of the storage service process, the basic service process can use the waitpid function or the wait function to wait for the status change of the storage service process. The termination status of the storage service process can be stored in the status variable status. Macros (such as WIFSIGNALED) can be used to extract specific information from status to determine whether the storage service process is successfully terminated through the second process termination method.

[0072] Among them, macro is a preprocessing instruction, and WIFSIGNALED(status) is a macro used to check whether the child process is terminated due to receiving a signal. It parses the exit status information stored in the status variable and returns a Boolean value. For example, when the output of WIFSIGNALED(status) is a non-zero value, it means that the storage service process has been successfully controlled to terminate by the second process termination method; when the output is 0, it means that the storage service process has failed to be controlled to terminate by the second process termination method. In this embodiment, when it is determined that the storage service process is successfully controlled to terminate by the second process termination method, the data disk operation can be performed.

[0073] The method for writing device data to disk in a standby power state provided in this embodiment, after entering the standby power state, determines whether there is a storage service process attempt termination time within the battery power supply time corresponding to the standby power state. If there is no storage service process attempt termination time, the storage service process will not be controlled to terminate. This can avoid meaningless attempts and help improve the success rate of the termination operation. In addition, within the storage service process attempt termination time, a first process termination method and a second process termination method with different intensities can be used to attempt to control the storage service process to terminate, which not only avoids meaningless repeated attempts, but also can terminate the process to the maximum extent, realize effective management and control of the process termination operation, and also help ensure the integrity of the data.

[0074] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method.

[0075] Based on the above embodiments, Figure 3 The illustrated embodiment further illustrates the method for writing data to a disk of a device in a power-backup state of the present application.

[0076] Figure 3 Schematic diagram of the process of storing device data in a backup power state provided in an embodiment of the present application Figure 2 . See Figure 3 , the method may include:

[0077] S301: In response to monitoring that the target device enters a power standby state, determining whether there is a storage service process attempt termination time within the battery power supply time corresponding to the power standby state.

[0078] The execution process of S301 may refer to S201 and will not be described in detail here.

[0079] S302: If there is a storage service process termination attempt time, then the storage service process is terminated by using a first process termination method at least once within the storage service process termination attempt time.

[0080] The step of obtaining the storage service process attempt termination time can be referred to in S202 and will not be repeated here.

[0081] S303: Divide the storage service process termination attempt time into a plurality of termination attempt time periods, and configure the termination attempt time periods as the timing time of the watchdog timer.

[0082] A watchdog timer is a monitoring mechanism implemented by software. The watchdog timer is designed to monitor the status of a specific process or service and perform predefined actions.

[0083] In this embodiment, in order to more finely control the termination of the storage service process, the storage service process termination attempt time can be equally divided into multiple smaller time periods, i.e., multiple termination attempt time periods, and the watchdog timer is continuously reset using the termination attempt time periods. For example, if the storage service process termination attempt time is 600 milliseconds, it can be divided into 6 termination attempt time periods of 100 milliseconds, and each termination attempt time period can be set as the timing time of the watchdog timer.

[0084] S304: Configure the maximum number of termination attempts according to multiple termination attempt time periods.

[0085] For example, if the storage service process termination attempt time is 600 milliseconds, it can be divided into 6 termination attempt time periods of 100 milliseconds, and the maximum termination attempt number is 6. It should be noted that the maximum termination attempt number is not limited in this embodiment.

[0086] S305: configuring an attempt termination mode flag bit, wherein the attempt termination mode flag bit is configured as the first process termination mode.

[0087] The attempt termination mode flag bit may be a flag or a state variable. The attempt termination mode flag bit may be used to indicate a mode of terminating the storage service process.

[0088] Exemplarily, when the attempted termination method mark bit is 1, it may indicate that the storage service process is terminated using the first process termination method with lower intensity; when the attempted termination method mark bit is 2, it may indicate that the storage service process is terminated using the second process termination method with higher intensity.

[0089] S306: Start the watchdog timer, and control the storage service process to terminate in the first process termination mode according to the attempted termination mode flag at the scheduled time.

[0090] As an optional implementation, controlling the termination of the storage service process using the first process termination method may include the following steps: sending a request termination signal to the storage service process through a system call, so that the storage service process captures the request termination signal and performs a termination operation.

[0091] System calls are the interface between applications and the operating system kernel. System calls allow applications in user space to request the operating system kernel to perform certain specific tasks or access hardware resources.

[0092] A request termination signal is a signal sent by the operating system or a process to another process to request the other process to terminate its operation. A request termination signal usually allows the receiving process to have a chance to perform cleanup operations (such as saving data, closing files, etc.) instead of being forced to terminate immediately.

[0093] In this embodiment, a request termination signal (SIGTERM) can be sent to the storage service process through the kill system call to request it to terminate its operation. A signal processing function corresponding to the SIGTERM signal is defined in the storage service process, and the function contains necessary cleanup operations and calls to the exit function (exit()); this signal processing function is registered when the storage service process is started, so that when the storage service process receives the SIGTERM signal, the signal processing function will be called to perform the corresponding termination operation and complete the termination of the process. Sending a request termination signal to the storage service process through a system call can ensure data integrity and target device stability while trying to terminate the storage service process in a gentle manner, which is conducive to ensuring data integrity. S307: In response to the failure to control the termination of the storage service process using the first process termination method, the watchdog timer is started again, and the storage service process is controlled to terminate using the first process termination method according to the attempted termination method flag at the timed time, until the first process termination method is used to control the storage service process to terminate successfully in a termination attempt before the maximum number of attempted terminations, or the first process termination method is used to control the storage service process to terminate unsuccessfully in the second-to-last attempt.

[0094] In the present embodiment, the storage service process is created by the basic service process through the fork system call, and therefore, the process identifier (process, PID) of the storage service process can be obtained. The basic service process can use the waitpid function to wait for the termination of the storage service process, and can judge whether the storage service process has been terminated normally based on the return information of the waitpid function. Exemplarily, if the return value of waitpid is consistent with the process identifier of the storage service process, it can be identified that the storage service process has been terminated normally. Otherwise, it represents that the storage identification service process has not terminated normally. In other words, the first process termination method is used to control the failure of the storage service process to terminate.

[0095] The fork system call is used to create a new process. The process that calls the fork system call is the parent process, and the newly created process is called the child process.

[0096] Specifically, for example, the storage service process termination attempt time is 300 milliseconds, which can be divided into three 100-millisecond termination attempt time periods. The maximum number of termination attempts is 3, and the interval time of the watchdog timer is 100 milliseconds. The current time is obtained as T0, and the first termination attempt is made at T0, a termination request signal SIGTERM is sent, and the wait is 100 milliseconds; if the first termination attempt fails, the watchdog timer is set to T0+100 milliseconds, and a second termination attempt is made at this moment, a termination request signal SIGTERM is sent, and the wait is 100 milliseconds. If the second termination attempt still fails, the watchdog timer needs to be set to T0+200 milliseconds. So far, it is explained that the first process termination method is used to control the termination of the storage service process and still fails at the second-to-last attempt. If the first or second attempt to terminate the storage service process is successful, there is no need to perform subsequent attempts.

[0097] As an optional implementation, if the first process termination method is used to control the termination of the storage service process and fails at the second-to-last attempt, the following steps may be performed: the attempted termination method flag is updated to the second process termination method. The conditions for controlling the termination of the storage service process by the second process termination method include: the attempted termination method flag is the second process termination method.

[0098] In order to achieve effective control over process termination, in this embodiment, if the penultimate attempt to control the termination of the storage service process using the first process termination method still fails, a more coercive measure can be tried, namely, using the second process termination method to control the termination of the storage service process.

[0099] Whether the conditions for using the second process termination method are met can be determined based on the termination method flag. For example, when the first process termination method is used to control the storage service process to terminate and fails at least once, and the termination method flag is also updated to the second process termination method, it can be considered that the conditions for using the second process termination method to control the storage service process are met.

[0100] By combining the termination mode flag to determine whether the conditions for using the second process termination mode to control the storage service process are met, the judgment logic can be simplified and the inconsistency caused by different judgment conditions can be avoided. In addition, if more process termination modes need to be introduced or the existing process termination policy needs to be adjusted, only the definition of the termination mode flag and the corresponding processing logic need to be updated, which is also conducive to quickly adapting to new demand changes.

[0101] S308: If the first process termination method is used to control the termination of the storage service process at least once and the conditions for using the second process termination method to control the termination of the storage service process are met, the second process termination method is used to control the termination of the storage service process, and the strength of the second process termination method is greater than the strength of the first process termination method.

[0102] As an optional implementation, controlling the termination of the storage service process using the second process termination method may include the following steps: sending a forced termination signal to the storage service process through a system call, so that the operating system performs a forced termination operation on the storage service process according to the forced termination signal.

[0103] A forced termination signal is a signal that cannot be caught, ignored, or processed. A forced termination signal requires the operating system to terminate the process immediately.

[0104] In this embodiment, a forced termination signal (SIGKILL) may be sent to the storage service process through a kill system call. Once the operating system receives the SIGKILL signal, the storage service process will be terminated immediately.

[0105] By introducing a stronger second process termination method, further protection is provided for the termination of the storage service process. When the first process termination method fails to control the termination of the storage service process, the operating system can directly terminate the storage service process by sending a forced termination signal, avoiding resource occupation or potential risks caused by the failure of the storage service process to exit normally. A well-defined storage service process termination strategy is formed to achieve effective management and control of the storage service process, which is also conducive to ensuring data integrity.

[0106] It should be noted that although SIGKILL is a forced termination signal, in some cases, there may still be situations where SIGKILL cannot terminate the process. For example, when a process is executing certain system calls (such as I / O operations, file system operations, etc.), it may enter a state called "uninterruptible blocking state, where the process cannot be interrupted by any signal, including SIGKILL, until it returns from the current system call; or some processes may have ended, but because the parent process has not reclaimed its resources, it still exists in the process table. Zombie processes will not respond to any signals, including SIGKILL, because they have ended, but have not been cleaned up yet.

[0107] In order to avoid the situation where SIGKILL cannot terminate the process, in this embodiment, when the number of termination attempts reaches the maximum number of termination attempts, the storage service process is terminated by sending a forced termination signal, and the watchdog timer is updated. It should be noted that, in this embodiment, the storage service process termination attempt time can also be set to the data disk drop time, and accordingly, the timing time of the watchdog timer can also be configured as a plurality of time periods evenly divided by the data disk drop time, i.e., the termination attempt time period. When the watchdog timer is triggered again, it means that the storage service process cannot be terminated by the second process termination method. At this time, the battery power supply time cannot meet the need for data drop, so meaningless retry termination is no longer required.

[0108] S309: In response to determining that the storage service process termination control using the second process termination method fails, the target device is powered off without writing data to the disk.

[0109] It is understandable that when the second process termination method with higher usage intensity cannot successfully terminate the storage service process, it means that the battery power supply time cannot meet the needs of data storage. No more termination attempts will be made, and the target device will be powered off directly. This can avoid waste of resources and meaningless attempts to terminate operations, and is also beneficial to protecting data integrity, making the entire termination and power-off process more efficient and controllable.

[0110] The method for dropping device data to disk in the standby power state provided in this embodiment realizes more refined and flexible control of the storage service process by dividing the storage service process termination attempt time into multiple termination attempt time periods, and using the termination attempt time period as the timing basis of the watchdog timer. A gradually enhanced storage service process termination strategy is adopted, starting with the first process termination method with lower intensity. If the storage service process fails to be terminated using the first process termination method for the second to last time, the termination attempt method flag is updated to support continued attempts using the second process termination method with higher intensity, ensuring that effective measures can be taken to complete the process termination even in the case of difficult termination. When it is found that the process cannot be successfully terminated even using the second process termination method, the power-off operation can be directly performed on the target device without dropping data to disk, thereby avoiding the risk of additional data damage or loss caused by repeated attempts. This method not only improves the overall efficiency of the termination operation, but also effectively guarantees the consistency and integrity of the data.

[0111] Based on the above embodiments, Figure 4 The illustrated embodiment further illustrates the method for writing data to a disk of a device in a power-backup state of the present application.

[0112] Figure 4 Schematic diagram of the process of storing device data in a backup power state provided in an embodiment of the present application Figure 3 . See Figure 4 , the method may include:

[0113] S401: Acquire first identification information of a basic service process, and store the first identification information.

[0114] The first identification information may be a thread ID of the basic service process. The thread ID may be used to identify a specific execution flow and accurately identify a specific basic service process.

[0115] S402: The basic service process creates a storage service process.

[0116] The storage service process can be created by the basic service process using the system call fork() and run as a daemon process. A daemon process is a background service process that can be used to perform periodic tasks or wait for certain events to occur. In this embodiment, the storage service process can continue to run until it is terminated by an external signal (such as a request termination signal or a forced termination signal).

[0117] S403: In response to monitoring that the target device enters a power standby state, determining whether there is a storage service process attempt termination time within the battery power supply time corresponding to the power standby state.

[0118] The execution process of S403 may refer to S201 and will not be described in detail here.

[0119] S404: If there is a storage service process termination attempt time, the storage service process is controlled to terminate by using the first process termination method at least once within the storage service process termination attempt time.

[0120] The execution process of S404 may refer to S202 and will not be described in detail here.

[0121] S405: If the first process termination method is used to control the termination of the storage service process at least once and the conditions for using the second process termination method to control the termination of the storage service process are met, the second process termination method is used to control the termination of the storage service process, and the strength of the second process termination method is greater than the strength of the first process termination method.

[0122] The execution process of S405 may refer to S203 and will not be described in detail here.

[0123] S406: If the storage service process is terminated successfully by using the first process termination method, the first identification information is cleared.

[0124] For example, in this embodiment, when the storage service process captures the request termination signal corresponding to the first process termination mode and processes it normally, it can call the exit function to exit. The operating system can send a child process notification signal (SIGCHLD) to notify the basic service process of the state change of the storage service process. After confirming that the storage service process has been successfully terminated, the basic service process can clear the stored first identification information.

[0125] S407: In response to determining that the first identification information has been cleared, write the data to the disk.

[0126] It is understandable that, in this embodiment, the first identification information being cleared may indicate that the storage service process has been successfully terminated by the first process termination method. Therefore, in response to determining that the first identification information has been cleared, it may indicate that the storage service process has been successfully terminated, and the data may be written to the disk.

[0127] Figure 5 This is a schematic diagram of a device data storage device in a standby power state provided in an embodiment of the present application. Figure 5 In this embodiment, the device for writing data to disk in the power-backup state may be composed of a process monitoring module, a watchdog module, a battery power supply module and a data writing module.

[0128] Specifically, the process monitoring module can create a storage service process and use the waiting function to obtain the state change of the storage service process. When the power is interrupted, the target device is in a standby power state, the battery power module can power the target device, and send a power-off signal to the watchdog module. The watchdog module can obtain the battery power supply time and the data disk drop time from the battery power module and the data disk drop module respectively, and start the watchdog timer. The process monitoring module will try to control the storage service process to terminate according to the first process termination method and the second process termination method. During the attempt, the waiting function can obtain the status of the storage service process to determine whether it is successfully terminated. If the storage service process cannot be successfully terminated using the first termination method and the second termination method, the watchdog module will notify the battery power module to power off the target device and no longer drop the data to the disk; if the storage service process is successfully terminated, the process monitoring module can notify the data disk drop module to perform the data disk drop operation, and the data disk drop module will notify the battery power module to power off the target device after completing the data disk drop.

[0129] Figure 5 The specific execution process of the device data storage system in the backup power state can be referred to the above embodiment, which will not be repeated here.

[0130] Figure 6 This is a schematic diagram of the structure of another device data storage device 10 in a standby power state provided by an embodiment of the present application. Figure 6 As shown, the device for writing data to a disk of a device in a power-backup state comprises: a determination module 11 , a first control module 12 , a second control module 13 and a data writing module 14 .

[0131] The determination module 11 is used to determine whether there is a storage service process attempt termination time within the battery power supply time corresponding to the backup power state in response to monitoring that the target device enters the backup power state.

[0132] The first control module 12 is configured to control the storage service process to terminate by using a first process termination method at least once within the storage service process attempt termination time if there is a storage service process attempt termination time.

[0133] The second control module 13 is used to control the storage service process to terminate by the second process termination method if at least one of the first process termination methods fails and the conditions for controlling the storage service process to terminate by the second process termination method are met.

[0134] The strength of the second process termination method is greater than the strength of the first process termination method.

[0135] The data storage module 14 is configured to store data on the disk in response to determining that the storage service process is successfully terminated by using the second process termination method.

[0136] In one embodiment, the determination module 11 is specifically used to: determine the battery power time and the data disk write time; in response to the battery power time being greater than the data disk write time, determine that there is a storage service process attempt to terminate time within the battery power time corresponding to the backup power state; in response to the battery power time being less than or equal to the data disk write time, determine that there is no storage service process attempt to terminate time within the battery power time corresponding to the backup power state.

[0137] In one embodiment, the device for flushing data to a disk of a device in a power-backup state further includes a power-off module, and the power-off module is specifically used to: perform a power-off operation on the target device without flushing data to a disk.

[0138] In one embodiment, the determination module 11 is further used to: if there is a storage service process attempt termination time, calculate the difference between the battery power supply time and the data disk write time; and determine the difference as the storage service process attempt termination time.

[0139] In one embodiment, the device data disk write apparatus in the backup power state also includes a configuration module, which is specifically used to: use the first process termination method to control the storage service process to terminate at least once within the storage service process attempt termination time, divide the storage service process attempt termination time into multiple attempt termination time periods, and configure the attempt termination time period as the timing time of the watchdog timer; configure the maximum number of termination attempts according to the multiple attempt termination time periods; configure the attempt termination method flag bit, and the attempt termination method flag bit is configured as the first process termination method.

[0140] In one embodiment, the first control module 12 is specifically used to: start the watchdog timer, and control the storage service process to terminate by using the first process termination method according to the attempted termination method mark at the timed time; in response to the failure of controlling the storage service process to terminate by using the first process termination method, start the watchdog timer again, and control the storage service process to terminate by using the first process termination method according to the attempted termination method mark at the timed time, until the storage service process is successfully terminated by using the first process termination method in a termination attempt before the maximum number of termination attempts, or the storage service process is failed to be terminated by using the first process termination method in the second-to-last attempt.

[0141] In one embodiment, the device data storage device in the backup power state also includes an update module, which is specifically used to: if the first process termination method is used to control the termination of the storage service process fails during the second-to-last attempt, the attempt termination method mark is updated to the second process termination method.

[0142] Among them, the condition for satisfying the second process termination method to control the storage service process termination is that the attempted termination method mark is the second process termination method.

[0143] In one embodiment, the power-off module is further used to: in response to determining that the storage service process termination control using the second process termination method fails, power off the target device without writing data to the disk.

[0144] In one embodiment, the device data disk writing apparatus in the standby power state also includes a processing module, which is specifically used to: obtain first identification information of the basic service process and store the first identification information; if the storage service process is successfully terminated by controlling the first process termination method, the first identification information is cleared.

[0145] In one embodiment, the data write-to-disk module 14 is specifically configured to write the data to the disk in response to determining that the storage service process is terminated successfully by using the second process termination method or the first identification information has been cleared.

[0146] In one implementation, the first control module 12 is specifically configured to: send a request termination signal to the storage service process through a system call; and the storage service process captures the request termination signal and executes a termination operation.

[0147] In one implementation, the second control module 13 is specifically configured to: send a forced termination signal to the storage service process through a system call; and the operating system performs a forced termination operation on the storage service process.

[0148] For the description of the features in the embodiment corresponding to the device for storing data on a disk in a standby power state, please refer to the relevant description of the embodiment corresponding to the method for storing data on a disk in a standby power state, which will not be repeated here.

[0149] Figure 7 This is a schematic diagram of the structure of the electronic device provided in this application. Figure 7 As shown, the electronic device provided in this embodiment includes: at least one processor 23 and a memory 21. Optionally, the electronic device in the standby state further includes a transceiver 22. The processor 23, the memory 21 and the transceiver 22 are connected via a bus.

[0150] The specific implementation process of the processor 23 can be found in the above method embodiment, and its implementation principle and technical effect are similar, so this embodiment will not be repeated here.

[0151] In the above embodiments, it should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the method disclosed in the application may be directly implemented as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.

[0152] The memory may include a high-speed memory (Random Access Memory, RAM), and may also include a non-volatile memory (NVM), such as at least one disk storage.

[0153] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of this application is not limited to only one bus or one type of bus.

[0154] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above-mentioned data storage method embodiments when running.

[0155] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.

[0156] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in any of the above-mentioned data storage method embodiments are implemented.

[0157] An embodiment of the present application also provides another computer program product, including a non-volatile computer-readable storage medium, the non-volatile computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the steps in any of the above-mentioned data storage method embodiments are implemented.

[0158] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0159] The above is a detailed introduction to a data disk method, electronic device, storage medium and program product provided by the present application. This article uses specific examples to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of the present application.

Claims

1. A method for storing data on a disk, characterized in that: include: In response to monitoring that the target device enters a power standby state, determining whether there is a storage service process attempt termination time within a battery power supply time corresponding to the power standby state; If there is a storage service process attempt termination time, using the first process termination method to control the storage service process to terminate at least once within the storage service process attempt termination time; If at least one attempt to terminate the storage service process by using the first process termination method fails and the condition for terminating the storage service process by using the second process termination method is met, the second process termination method is used to terminate the storage service process, and the strength of the second process termination method is greater than the strength of the first process termination method; In response to determining that the storage service process is terminated successfully by using the second process termination method, data is written to the disk.

2. The method according to claim 1, characterized in that: The determining whether there is a storage service process attempt termination time within the battery power supply time corresponding to the backup power state includes: Determine the battery power supply time and data storage time; In response to the battery power supply time being greater than the data storage time, determining that there is a storage service process attempt termination time within the battery power supply time corresponding to the backup power state; In response to the battery power supply time being less than or equal to the data disk write time, it is determined that there is no storage service process attempt termination time within the battery power supply time corresponding to the backup power state.

3. The method according to claim 2, characterized in that After determining that there is no storage service process attempt termination time within the battery power supply time corresponding to the backup power state, the method further includes: The target device is powered off without writing data to disk.

4. The method according to claim 2, characterized in that: If the storage service process attempts to terminate the time, it also includes: Calculate the difference between the battery power supply time and the data storage time; The difference is determined as the storage service process attempt termination time.

5. The method according to claim 1, characterized in that The method further comprises: controlling the storage service process to terminate by using the first process termination method at least once within the storage service process termination attempt time. Divide the storage service process attempt termination time into a plurality of attempt termination time periods, and configure the attempt termination time periods as the timing time of the watchdog timer; configuring a maximum number of termination attempts according to the plurality of termination attempt time periods; An attempt termination mode flag is configured, wherein the attempt termination mode flag is configured as a first process termination mode.

6. The method according to claim 5, characterized in that Controlling the storage service process to terminate by using a first process termination method at least once within the storage service process termination attempt time includes: Starting a watchdog timer, and controlling the storage service process to terminate in a first process termination manner according to the attempted termination manner flag at the timing time; In response to the failure of controlling the termination of the storage service process by adopting the first process termination method, the watchdog timer is started again, and the storage service process is controlled to be terminated by adopting the first process termination method according to the attempted termination method flag at the timing time, until the storage service process is successfully terminated by adopting the first process termination method in a termination attempt before the maximum number of termination attempts, or the storage service process is failed to be terminated by adopting the first process termination method in the second-to-last attempt.

7. The method according to claim 6, characterized in that If the first process termination method is used to control the storage service process to terminate at the second to last attempt, the method further includes: Update the attempt termination mode flag to the second process termination mode; The condition for controlling the storage service process to terminate in the second process termination mode includes: The attempted termination mode flag is the second process termination mode.

8. The method according to claim 1, characterized in that: In response to determining that the use of the second process termination mode to control the storage service process to terminate fails, the method further includes: The target device is powered off without writing data to disk.

9. The method according to claim 1, characterized in that: The method further comprises: Obtaining first identification information of the basic service process and storing the first identification information; If the storage service process is successfully terminated by controlling the termination of the storage service process using the first process termination method, the first identification information is cleared.

10. The method according to claim 9, characterized in that Also includes: In response to determining that the first identification information has been cleared, the data is written to the disk.

11. The method according to claim 1, characterized in that: The adopting the first process termination mode to control the storage service process to terminate includes: A request termination signal is sent to the storage service process through a system call, so that the storage service process captures the request termination signal and performs a termination operation.

12. The method according to claim 1, characterized in that The adopting the second process termination mode to control the storage service process to terminate includes: A forced termination signal is sent to the storage service process through a system call, so that the operating system performs a forced termination operation on the storage service process according to the forced termination signal.

13. An electronic device, characterized in that: include: Memory, transceivers and processors, The memory is used to store computer programs; The transceiver is used to send and receive data under the control of the processor; The processor is used to implement the steps of the method for storing data on a disk as claimed in any one of claims 1 to 12 when executing the computer program.

14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the steps of the method for storing data on a disk as claimed in any one of claims 1 to 12.

15. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method for storing data on a disk as claimed in any one of claims 1 to 12 are implemented.

Citation Information

Patent Citations

  • Test system, method, apparatus and storage medium for storing power-down protection

    CN109086226A

  • System and method for automated shutdown and startup for a network

    CN112136292A

  • Log storage method and device

    CN113721746A

  • Server standby power function optimization method and system, terminal and storage medium

    CN114816023A

  • Test case execution method and device and server

    CN118779232A

Cited By

  • Data processing method and computer storage medium

    CN121560626A

  • A data processing method and a computer storage medium

    CN121560626B