Data Disk Landing Method, Electronic Device, Storage Medium and Program Product

By evaluating the battery power supply time in the power reserve state and adopting a gradually enhanced process termination strategy, the storage service process control problem is solved, data integrity is ensured, and the efficiency and success rate of storage service process termination are improved.

CN119718592BActive Publication Date: 2025-07-01INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

The prior art is difficult to effectively control the storage service process in the power reserve state, resulting in difficult to ensure data integrity.

Method used

By monitoring the target device to enter the power reserve state, assess whether the storage service process attempt termination time is available during the battery power supply time, adopt a gradually enhanced phased process termination strategy, first use the lower-strength first process termination method, and if it fails, use the higher-strength second process termination method to ultimately ensure that the storage service process successfully terminates and data is dropped.

Benefits of technology

It realizes effective management and control of storage service processes, ensures data integrity, and avoids meaningless repeated attempts and potential data loss or corruption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119718592B_ABST
    Figure CN119718592B_ABST
Patent Text Reader

Abstract

The present application discloses a data disk dropping method, an electronic device, a storage medium, and a program product, which relate to the field of computer technologies. When it is detected that a target device enters the backup power supply state, it is determined whether there is a storage service process attempt termination time within the battery power supply time corresponding to the backup power supply state. If there is a storage service process attempt termination time, the storage service process is controlled to terminate by using a first process termination method with a lower intensity. If the storage service process fails to be terminated successfully by using the first process termination method and the conditions for the second process termination method are met, a second process termination method with a higher intensity is used to control the storage service process to terminate. If the storage service process is terminated successfully, data is dropped to the disk. Through a gradually enhanced phased process termination strategy, effective management and control of the storage service process termination process can be achieved, and it is also beneficial to ensure the integrity of data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

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

[0003] However, when dropping data in related technologies, there is a problem that it is impossible to effectively control the storage service process and it is difficult to ensure data integrity. Summary of the Invention

[0004] This application provides a data disk dropping method, 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 related technologies.

[0005] This application provides a data disk dropping method, including:

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

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

[0008] If at least once controlling the termination of the storage service process by using the first process termination method fails and meets the condition for controlling the termination of the storage service process by using a second process termination method, then control the termination of the storage service process by using the second process termination method, and the intensity of the second process termination method is greater than that of the first process termination method;

[0009] Responding to determining that controlling the termination of the storage service process by using the second process termination method is successful, then perform data disk dropping.

[0010] This application also provides a data disk dropping device, including:

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

[0012] The first control module, if it has the attempt termination time of the storage service process, controls the termination of the storage service process at least once within the attempt termination time of the storage service process by using the first process termination method;

[0013] The second control module is configured to, if the attempt to terminate the storage service process by using the first process termination method fails at least once and the condition for controlling the termination of the storage service process by using the second process termination method is satisfied, control the termination of the storage service process by using the second process termination method, and the intensity of the second process termination method is greater than that of the first process termination method;

[0014] The data disk write module is configured to perform data disk write in response to determining that the control of the termination of the storage service process by using the second process termination method is successful.

[0015] This application also provides an electronic device, including: a memory, a transceiver, and a processor. The memory is used to store a computer program; the transceiver is used to transmit and receive data under the control of the processor; the processor is used to implement the steps of any one of the above data disk write methods when executing the computer program.

[0016] This application also provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of any one of the above data disk write methods are implemented.

[0017] This application also provides a computer program product, including a computer program. When the computer program is executed by a processor, the steps of any one of the above data disk write methods are implemented.

[0018] Through this application, when it is monitored that the target device enters the backup power supply state, it will evaluate whether there is an attempt termination time of the storage service process within the battery power supply time. If there is an attempt termination time of the storage service process, the first process termination method with a lower intensity will be used to control the termination of the storage service process. If the first process termination method fails and the condition for controlling the termination of the storage service process by using the second process termination method is satisfied, the second process termination method with a higher intensity will be used to terminate the storage service process. If the termination of the storage service process is successful, data disk write will be performed. The technical solution of this application uses a gradually enhanced termination strategy to ensure that even if the storage service process cannot respond normally when the first process termination method is used, the process can be successfully terminated by the second process termination method and data disk write can be performed, enhancing the control and management of the storage service process, and thus ensuring the integrity of data. Description of the Drawings

[0019] The accompanying drawings here are incorporated into the specification and form a part of this specification, showing embodiments consistent with this application, and are used together with the specification to explain the principles of this application.

[0020] Figure 1 It is an application scenario diagram of a data disk dropping method provided for an embodiment of this application;

[0021] Figure 2 It is a flowchart of a data disk dropping method provided for an embodiment of this application Figure 1 ;

[0022] Figure 3 It is a flowchart of a data disk dropping method provided for an embodiment of this application Figure 2 ;

[0023] Figure 4 It is a flowchart of a data disk dropping method provided for an embodiment of this application Figure 3 ;

[0024] Figure 5 It is a schematic diagram of a data disk dropping device provided for an embodiment of this application;

[0025] Figure 6 It is a schematic diagram of the structure of another data disk dropping device 10 provided for an embodiment of this application;

[0026] Figure 7 It is a schematic diagram of the structure of an electronic device provided for this application.

[0027] Through the above accompanying drawings, specific embodiments of this application have been shown, and there will be more detailed descriptions later. These accompanying drawings and textual descriptions are not intended to limit the scope of the concept of this application in any way, but to illustrate the concept of this application to those skilled in the art by referring to specific embodiments. Specific Embodiments

[0028] Next, the technical solutions in the embodiments of this application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of this application. Obviously, the described embodiments are only a part of the embodiments of this application, rather than all the embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without making creative efforts belong to 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 not only includes those elements, but also includes other elements not expressly 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, rather than to describe a specific order or sequence.

[0030] In the event of a main power interruption, the backup battery, as the power supply unit, starts to supply power to the storage device to ensure the continuous progress of critical operations and data security. The data disk-down technology in the backup power supply state aims to detect that the main power supply has stopped supplying power, immediately terminate the storage service process, collect the cached data and cluster information that have not been disked down, write this data to the system disk, and finally turn off the battery power supply and shut down the machine. In this process, the basic service process and the storage service process work together. The storage service process is responsible for the actual storage operations, while the basic service process is responsible for tasks such as monitoring the power status, starting and terminating the storage service process, collecting disk-down data, and managing battery discharge. However, if the storage service process fails to respond properly and exits due to its own problems, the basic service process will keep waiting for it to exit, resulting in the inability to continue subsequent data disk-down and storage device power-off operations. This situation may ultimately lead to the forced shutdown of the storage device due to the depletion of the battery power, increasing the risk of data loss or damage. Therefore, the related technology has the problem of being difficult to effectively control the storage service process and ensure data integrity.

[0031] To achieve effective control of the storage service process, when it is detected that the target device enters the backup power supply state, it can be evaluated whether there is a storage service process attempt termination time within the battery power supply time. If there is indeed a storage service process attempt termination time, it means that the storage service process can be attempted to be terminated. In addition, a phased process termination strategy with gradually increasing strength can be adopted to manage the storage service process. A retry mechanism can be set up 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, reducing the risk of data loss. If the first process termination method fails to successfully terminate the storage service process and meets the conditions of the second process termination method, then a 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 terminated successfully, data disk-down is performed 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 terminating the storage service process, achieve effective management and control of the storage service process, and also help ensure data integrity.

[0032] To enable those skilled in the art of this technical field to better understand the solution of this application, the following further details the application in conjunction with the accompanying drawings and specific embodiments.

[0033] Combined with the specific application environment architecture or specific hardware architecture on which the execution of the data disk writing method depends, the specific application environment architecture or specific hardware architecture is described herein. Please refer to Figure 1 , Figure 1 which is an application scenario diagram of a data disk writing method provided by an embodiment of this application. As Figure 1 shown, it includes a target device 101 and a battery 102. The battery 102 is used to supply power to the target device 101 when the main power supply is interrupted, enabling the target device 101 to enter the backup power supply state, ensuring that the target device 101 can continue to operate for a period of time to support data disk writing. If there is a storage service process attempt termination time within the battery power supply time corresponding to the backup power supply state, the storage service process can be controlled to terminate at least once within the storage service process attempt termination time by using a first process termination method with a lower intensity. If the first process termination method fails to successfully terminate the storage service process and meets the conditions for using a second process termination method to control the storage service process to terminate, the storage service process can be controlled to terminate by using a second process termination method with a higher intensity. After the storage service process is successfully terminated, a data disk writing operation can be executed.

[0034] The following uses specific embodiments to detail the technical solution of this application and how the technical solution of this application solves the above technical problems. These several specific embodiments below can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The following will describe the embodiments of this application in conjunction with the accompanying drawings.

[0035] Figure 2 which is a flowchart of a data disk writing method provided by an embodiment of this application Figure 1 , and details the method as follows:

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

[0037] The target device refers to a storage device or system that needs to protect the integrity of its data, such as a server, a monitoring device, etc.

[0038] The backup power supply state refers to the state of switching to 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] The battery power supply time refers to the length of time that the backup battery can supply power to the system. The battery power supply time can depend on the battery capacity and the power consumption of the target device when operating in the backup power state, etc.

[0040] The storage service process can be an application program 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. Among them, 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., and the storage service process can be used to process storage services.

[0042] Termination means that a running program, process, or service stops its current operation and exits.

[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 relatively sufficient, and the storage service process can be attempted to be terminated. Otherwise, it means that the battery power supply time is not sufficient, and if the storage service process is attempted to be terminated, it will affect the process of data being written to disk.

[0044] As an alternative implementation, the following steps can be used to determine whether there is a storage service process termination attempt time within the battery power supply time corresponding to the backup power state: determine the battery power supply time and the data write-to-disk time; in response to the battery power supply time being greater than the data write-to-disk time, determine that there is a storage service process termination attempt 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 write-to-disk time, determine that there is no storage service process termination attempt time within the battery power supply time corresponding to the backup power state.

[0045] The data write-to-disk time refers to the time required to write the data in the 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, the remaining capacity of the backup battery can be calculated, 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 voltage value currently output by the battery, usually measured in volts (V).

[0048] The remaining power is the length of time that the battery can continuously supply a current of 1 milliampere under specific conditions (usually at 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 attempt termination 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 attempt termination 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, there may still be cases where SIGKILL fails to terminate a 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", 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 due to the parent process not reclaiming its resources, it still exists in the process table. Zombie processes do not respond to any signals, including SIGKILL, because they have ended, but just have not been cleaned up.

[0107] To avoid the situation where SIGKILL fails to terminate a 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 write time. Correspondingly, the timing time of the watchdog timer can also be configured as multiple time periods evenly divided by the data disk write time, that is, the termination attempt time periods. When the watchdog timer is triggered again, it means that the storage service process cannot be terminated by the second process termination method either. At this time, the battery power supply time cannot meet the need for data disk write. Therefore, meaningless retry terminations can be stopped.

[0108] S309: In response to determining that the second process termination method for controlling the termination of the storage service process fails, power off the target device without performing data disk write.

[0109] It can be understood that when the second process termination method with a higher usage intensity fails to successfully terminate the storage service process, it means that the battery power supply time cannot meet the need for data disk write. No more attempt terminations are performed, and the target device is directly powered off. This can avoid wasting resources and meaningless attempt terminations, and is also conducive to protecting the integrity of data, 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 also provides a computer program product. The computer program product includes a computer program, and when the computer program is executed by a processor, the steps in any of the above-described embodiments of the data disk writing method 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 stores a computer program, and when the computer program is executed by a processor, the steps in any of the above-described embodiments of the data disk writing method are implemented.

[0158] Those skilled in the art can further realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of each example have been generally described according to their functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Skilled professionals can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present application.

[0159] The above has introduced in detail a data disk writing method, an electronic device, a storage medium, and a program product provided by the present application. Specific examples are used herein to elaborate on the principle and implementation manner of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application. It should be noted that for those of ordinary skill in the art in the technical field, without departing from the principle of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the protection scope of the claims of the present application.

Claims

1. A method for storing data on a disk, characterized in that: include: Obtaining first identification information of a basic service process and storing the first identification information; wherein the first identification information is a thread ID of the basic service process; the basic service process creates a storage service process; 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, the storage service process attempt termination time is divided into multiple attempt termination time periods, and the attempt termination time period is configured as the timing time of the watchdog timer; the maximum number of attempted termination times is configured according to the multiple attempt termination time periods; the attempt termination mode flag is configured, and the attempt termination mode flag is configured as the first process termination mode; The storage service process is terminated by using the first process termination method at least once within the storage service process termination attempt time; if the storage service process is successfully terminated by using the first process termination method, the first identification information is cleared and the data is written to the disk; If at least once the first process termination method is used to control the termination of the storage service process, it fails and the condition for using the second process termination method to control the termination of the storage service process is 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; wherein, the condition for the second process termination method to control the termination of the storage service process is that the attempted termination method flag is the second process termination method; In response to determining that the storage service process is successfully terminated by using the second process termination method, data is written to the disk; If there is no storage service process attempt termination time, the power-off operation is performed directly without data being 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 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.

4. The method according to claim 1, 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.

5. The method according to claim 4, 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.

6. 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.

7. 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.

8. 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.

9. 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 8 when executing the computer program.

10. 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 8.

11. 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 8 are implemented.

Citation Information

Patent Citations

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

    CN112136292A

  • Log storage method and device

    CN113721746A