Processing method and device

By transferring valid data from the storage area to the storage area of ​​the baseboard management controller and writing the data back, the problem of task obstruction caused by insufficient storage space is solved, thereby improving the startup efficiency and user experience of electronic devices.

CN121785538APending Publication Date: 2026-04-03LENOVO (BEIJING) LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-25
Publication Date
2026-04-03

AI Technical Summary

Technical Problem

In electronic devices, when there is insufficient remaining space in the storage area, frequent data transfer and erasure operations can hinder tasks, such as causing startup delays or interruptions.

Method used

The valid data in the first storage area storing boot program data is transferred to the second storage area deployed to the baseboard management controller. When insufficient remaining space is detected, the first storage area is erased, and then the data in the second storage area is written back to the first storage area.

Benefits of technology

This reduces frequent read and write operations to the memory, avoids task disruptions, and improves the user experience of electronic devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121785538A_ABST
    Figure CN121785538A_ABST
Patent Text Reader

Abstract

The invention discloses a processing method and device, and the method comprises the steps: transferring effective data in a first storage region to a second storage region under the condition that the remaining storage space of the first storage region is detected to be smaller than or equal to a target threshold value; erasing the first storage area; writing back the data in the second storage area to the first storage area; wherein the first storage area is used for storing data corresponding to a bootstrap program; the bootstrap program is used for booting an operating system of the electronic equipment to start; the second storage area is a storage area deployed to a substrate management controller in the electronic equipment.
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 processing method and apparatus. Background Technology

[0002] In electronic devices, when the remaining space in the storage area storing Unified Extensible Firmware Interface (UEFI) data is insufficient, it is necessary to transfer the valid data in the storage area to a backup area allocated in the flash memory, erase the storage area first, and then transfer the valid data in the backup area back to the storage area.

[0003] However, this frequent reading and writing to flash memory can disrupt the tasks currently being performed by the electronic device, such as delays in the device's startup or interruptions to its tasks. Summary of the Invention

[0004] In view of the above, this application provides a processing method and apparatus, as follows:

[0005] A processing method includes:

[0006] If the remaining storage space in the first storage area is less than or equal to the target threshold, the valid data in the first storage area will be transferred to the second storage area.

[0007] Erase the first storage area;

[0008] Write the data in the second storage area back to the first storage area;

[0009] The first storage area is used to store data corresponding to the boot program; the boot program is used to boot the operating system of the electronic device; the second storage area is the storage area deployed to the baseboard management controller in the electronic device.

[0010] Optionally, the above method may further include:

[0011] When the electronic device is in the startup phase corresponding to the bootloader, in response to the first write request of the bootloader, it is detected whether the remaining storage space of the first storage area is less than or equal to the target threshold.

[0012] Optionally, in the above method, if the remaining storage space in the first storage region is detected to be less than or equal to the target threshold, the method further includes:

[0013] Write the first data to the second storage area; the first data is: the data that the bootloader needs to write to the first storage area in response to the first write request.

[0014] Optionally, the above method may further include:

[0015] In response to the start command of the electronic device, it is detected whether the remaining storage space in the first storage area is less than or equal to the target threshold.

[0016] Optionally, after transferring valid data from the first storage area to the second storage area and before erasing the first storage area, the method further includes:

[0017] Adjust the access address of the first storage area to point to the storage address of the valid data in the second storage area;

[0018] The method further includes, after writing the data from the second storage area back to the first storage area:

[0019] Restore the access address of the first storage area.

[0020] Optionally, the above method may involve writing data from the second storage area back to the first storage area, including at least one of the following:

[0021] Write the valid data in the second storage area back to the first storage area;

[0022] Write the first data in the second storage area back to the first storage area;

[0023] Write the second data in the second storage area back to the first storage area;

[0024] Wherein, the first data is: the data written by the bootloader to the second storage area in response to the first write request when the remaining storage space is less than or equal to the target threshold;

[0025] The second data is: data written by the operating system to the second storage area in response to a second write request when the remaining storage space is less than or equal to the target threshold.

[0026] A processing method includes:

[0027] When the electronic device is in the running stage corresponding to the operating system, in response to the second write request, it is detected whether the remaining storage space of the first storage area is greater than the target threshold; the second write request is used to request the writing of the second data corresponding to the boot program to the first storage area.

[0028] If the remaining storage space in the first storage area is less than or equal to the target threshold, the second data is written to the second storage area.

[0029] If the remaining storage space in the first storage area is greater than the target threshold, the second data is written into the first storage area;

[0030] The second storage area is the storage area deployed to the baseboard management controller in the electronic device; the first storage area is used to store the data corresponding to the boot program; the boot program is used to boot the operating system.

[0031] Furthermore, the bootloader is also configured to transfer valid data in the first storage area to the second storage area when the remaining storage space in the first storage area is less than or equal to a target threshold, and to write the valid data in the second storage area and the second data back to the first storage area after erasing the first storage area.

[0032] Optionally, the above method may further include:

[0033] In response to a read request, data matching the read request is read from the second storage area;

[0034] If no data matching the read request is found in the second storage area, the data matching the read request is read in the first storage area.

[0035] A processing apparatus, comprising:

[0036] The data transfer unit is used to transfer valid data in the first storage area to the second storage area when the remaining storage space in the first storage area is less than or equal to the target threshold.

[0037] A storage erasure unit is used to erase the first storage area;

[0038] A data write-back unit is used to write data from the second storage area back to the first storage area;

[0039] The first storage area is used to store data corresponding to the boot program; the boot program is used to boot the operating system of the electronic device; the second storage area is the storage area deployed to the baseboard management controller in the electronic device.

[0040] A processing apparatus, comprising:

[0041] The remaining detection unit is used to detect whether the remaining storage space of the first storage area is greater than a target threshold in response to a second write request when the electronic device is in the running stage corresponding to the operating system; the second write request is used to request the writing of the second data corresponding to the boot program to the first storage area;

[0042] A data writing unit is configured to write the second data into a second storage area when the remaining storage space in the first storage area is less than or equal to the target threshold; and to write the second data into the first storage area when the remaining storage space in the first storage area is greater than the target threshold.

[0043] The second storage area is the storage area deployed to the baseboard management controller in the electronic device; the first storage area is used to store the data corresponding to the boot program; the boot program is used to boot the operating system.

[0044] Furthermore, the bootloader is also configured to transfer valid data in the first storage area to the second storage area when the remaining storage space in the first storage area is less than or equal to a target threshold, and to write the valid data in the second storage area and the second data back to the first storage area after erasing the first storage area. Attached Figure Description

[0045] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0046] Figure 1 A flowchart illustrating a processing method provided in an embodiment of this application;

[0047] Figure 2 Another flowchart of a processing method provided in an embodiment of this application;

[0048] Figure 3 Another flowchart of a processing method provided in an embodiment of this application;

[0049] Figure 4 A flowchart illustrating a processing method provided in an embodiment of this application;

[0050] Figure 5 A flowchart illustrating another processing method provided in this application embodiment;

[0051] Figure 6 A partial flowchart of another processing method provided in an embodiment of this application;

[0052] Figure 7 This is a schematic diagram of the structure of a processing device provided in an embodiment of this application;

[0053] Figure 8 This is another schematic diagram of a processing device provided in an embodiment of this application;

[0054] Figure 9 This is a schematic diagram of another processing device provided in an embodiment of this application;

[0055] Figure 10 Another schematic diagram of a processing apparatus provided in an embodiment of this application;

[0056] Figure 11 This is a flowchart illustrating the implementation of a recycling mechanism during the server startup phase in a scenario applicable to this application;

[0057] Figure 12 This is a flowchart illustrating the process of the operating system writing data to NVRAM in a server-based scenario applicable to this application.

[0058] Figure 13 This is a flowchart illustrating the process of the operating system reading data from NVRAM in a server-based scenario applicable to this application.

[0059] Figure 14 This is a flowchart illustrating the execution of a recycling mechanism during the server startup phase in the scenario where this application applies to servers;

[0060] Figure 15 This is a flowchart illustrating the recovery and recycling mechanism in the server scenario applicable to this application. Detailed Implementation

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

[0062] refer to Figure 1The diagram shown illustrates a processing method provided in this application embodiment. This method is applicable to electronic devices with a first storage area and a second storage area. The first storage area stores data corresponding to a bootloader, which is used to boot the operating system of the electronic device. For example, the bootloader can be UEFI. The first storage area is a non-volatile random access memory (NVRAM) partitioned for UEFI within the flash memory. The second storage area is a storage area deployed to the Baseboard Management Controller (BMC) in the electronic device, such as the shared memory space of the BMC. Based on this, the first storage area serves as the primary data area for UEFI, and the second storage area serves as the backup data area for UEFI. The technical solution in this embodiment is mainly used to improve the user experience of the electronic device.

[0063] Specifically, the method in this embodiment may include the following steps:

[0064] Step 101: Detect whether the remaining storage space of the first storage area is less than or equal to the target threshold. If the remaining storage space of the first storage area is less than or equal to the target threshold, proceed to step 102. If the remaining storage space of the first storage area is greater than the target threshold, continue to proceed to step 101.

[0065] The target threshold can be set according to business needs. The target threshold can be a percentage value, such as 10%; or the target threshold can be a storage quantity value, such as 10M.

[0066] It should be noted that step 101 is executed during the boot phase corresponding to the bootloader of the electronic device. For example, when the electronic device boots up and is in the boot phase corresponding to UEFI, step 101 is executed to reclaim the first storage area.

[0067] In one implementation, step 101 can directly read the remaining storage space of the first storage area and determine the relationship between the remaining storage space and the target threshold in order to detect whether the remaining storage space of the first storage area is less than or equal to the target threshold.

[0068] Step 102: Transfer the valid data in the first storage area to the second storage area.

[0069] In the first storage area, besides valid data corresponding to boot programs such as UEFI, there is also other invalid data, such as data corresponding to invalid UEFI programs. In this embodiment, when transferring data to the second storage area, only the valid data in the first storage area needs to be transferred, thus avoiding the loss of valid data.

[0070] Step 103: Erase the first storage area.

[0071] In this case, the valid data in the first storage area has been transferred to the second storage area. Therefore, erasing the first storage area will not cause data loss, and erasing the first storage area will also make all the storage space in the first storage area available.

[0072] Step 104: Write the data in the second storage area back to the first storage area.

[0073] It should be noted that the data to be written back to the second storage area from the first storage area must include at least the valid data in the first storage area before the first storage area was erased.

[0074] Furthermore, after step 104, the data in the second storage area can be deleted to facilitate the next recycling process.

[0075] It should be noted that during the execution of the above process, the electronic device may malfunction, such as a power outage, causing the recycling process to be interrupted. In this case, the recycling process can be restarted in this embodiment. Specifically, it can be done as follows: first, determine whether the second storage area contains valid data from the first storage area. If the second storage area contains valid data from the first storage area, it means that steps 101 and 102 have been completed. At this time, steps 103 and 104 can be executed directly. If the second storage area does not contain valid data from the first storage area, then steps 101, 102, 103, and 104 can be executed again.

[0076] As can be seen from the above technical solutions, in the processing method provided by the embodiments of this application, when it is detected that the remaining storage space of the first storage area used to store the data corresponding to the boot program is less than or equal to the target threshold, the valid data in the first storage area is first transferred to the second storage area deployed to the baseboard management controller, and then the first storage area is erased. After that, the data in the second storage area can be written back to the second storage area. It can be seen that in this embodiment, the storage area in the memory where the first storage area is located is not used as the backup storage area. Instead, the storage area of ​​the baseboard management controller is used as the backup second storage area. When the first storage area is reclaimed, data read and write are performed between the first storage area and the second storage area. It is not necessary to frequently read and write in the memory where the first storage area is located. This can reduce the read and write frequency of the memory where the first storage area is located, and thus will not cause the task currently being executed by the electronic device to be blocked. This improves the task execution status of the electronic device when the first storage area is reclaimed, thereby improving the user's experience of using the electronic device.

[0077] In one implementation, this embodiment may further include the following steps, such as... Figure 2 As shown:

[0078] Step 105: When the electronic device is in the boot phase corresponding to the boot program, monitor whether there is a first write request from the boot program. In response to the first write request from the boot program, execute step 101. Otherwise, continue to execute step 105 until the boot program finishes booting and the operating system starts.

[0079] The first write request is used to request the writing of corresponding data to the first storage area.

[0080] For example, during the UEFI startup phase, when UEFI needs to write the first data to the first storage area, it first checks whether the remaining storage space of the first storage area is less than or equal to the target threshold. If so, the recycling process from steps 102 to 104 is executed. If the remaining storage space of the first storage area is greater than the target threshold, the first data corresponding to the first write request is written to the first storage area, and the remaining storage space of the first storage area is checked again to see if it is less than or equal to the target threshold. If so, the recycling process from steps 102 to 104 is executed. Otherwise, the recycling process is not required until UEFI startup is complete, allowing the operating system to start.

[0081] Based on the above implementation, if in step 101 the remaining storage space of the first storage region is detected to be less than or equal to the target threshold, the following steps can also be performed, such as... Figure 3 As shown:

[0082] Step 106: Write the first data to the second storage area.

[0083] The first data is: the data that the bootloader needs to write to the first storage area in response to the first write request, such as the setting parameters of a certain setting item that UEFI needs to write.

[0084] Based on this, when writing data from the second storage area back to the first storage area in step 104, in addition to writing back the valid data from the first storage area before it was erased, the first data written in the second storage area is also written back to the first storage area.

[0085] For example, during the UEFI startup phase, when the UEFI needs to write the first data to the first storage area, it first checks whether the remaining storage space in the first storage area is less than or equal to a target threshold. If so, the first data is written to the second storage area, and the valid data in the first storage area is transferred to the second storage area. After erasing the first storage area, the data in the second storage area is written back to the first storage area. If the remaining storage space in the first storage area is greater than the target threshold, the first data is written to the first storage area. Since the remaining storage space in the first storage area is sufficient, a reclamation process is not required.

[0086] As can be seen, in this embodiment, the process of reclaiming the storage area can be executed when the bootloader has a write request, without affecting the operation of the bootloader, and therefore without affecting the startup of the operating system in the electronic device, thereby improving the user experience of the electronic device.

[0087] In one implementation, step 101 in this embodiment can be executed when the electronic device starts up, that is, in response to the start command of the electronic device, step 101 is executed to detect whether the remaining storage space of the first storage area is less than or equal to the target threshold.

[0088] For example, when an electronic device is powered on or restarted, it enters the boot phase of a boot program such as UEFI. In response to the boot command of the electronic device, such as a power-on command or a restart command, it checks whether the remaining storage space in the first storage area is less than or equal to the target threshold. If so, the recycling process from step 102 to step 104 is executed; otherwise, the recycling process is not executed.

[0089] As can be seen, in this embodiment, the process of reclaiming the storage area can be executed when the electronic device starts up, without affecting the operation of the boot program, and therefore without affecting the startup of the operating system in the electronic device, thereby improving the user experience of the electronic device.

[0090] In one implementation, after step 102 and before step 103, the following processing may also be performed, such as... Figure 4 As shown:

[0091] Step 107: Adjust the access address of the first storage area to point to the storage address of the valid data in the second storage area.

[0092] Accordingly, after step 104, the following processing can also be performed:

[0093] Step 108: Restore the access address of the first storage area.

[0094] In this embodiment, after transferring valid data from the first storage area to the second storage area, the access address of the first storage area is first adjusted to point to the storage address of the valid data in the second storage area, and then the first storage area is erased. This allows access to the valid data transferred to the second storage area according to the storage address of the second storage area, thus ensuring that access to the valid data is not affected. After writing the data from the second storage area back to the first storage area, the access address of the first storage area is restored, allowing access to the bootloader data to continue in the first storage area without affecting access to the valid data.

[0095] In one implementation, step 104, when writing data from the second storage area back to the first storage area, may include at least one of the following:

[0096] Write the valid data in the second storage area back to the first storage area;

[0097] Write the first data in the second storage area back to the first storage area; the first data is: the data that the bootloader writes to the second storage area in response to the first write request when the remaining storage space is less than or equal to the target threshold;

[0098] Write the second data in the second storage area back to the first storage area; the second data is: the data written to the second storage area by the operating system in response to the second write request when the remaining storage space is less than or equal to the target threshold.

[0099] It should be noted that the second data is the data written to the second storage area by the operating system when the electronic device is in the operating system running phase.

[0100] For example, during the UEFI boot phase of an electronic device, in response to a first write request, the UEFI writes first data to the first storage area if it detects that the remaining storage space in the first storage area is greater than a target threshold. After the UEFI boot is complete, the operating system runs. In response to a second write request, the operating system writes second data to the second storage area if it detects that the remaining storage space in the first storage area is less than or equal to the target threshold. Based on this, when the electronic device restarts, the UEFI, in response to the electronic device's boot command, detects that the remaining storage space in the first storage area is less than or equal to the target threshold. At this time, it writes the valid data (including the written first data) from the first storage area to the second storage area, then erases the first storage area. Afterward, it writes the valid data (including the first data) from the second storage area and the second data written by the operating system back to the first storage area, completing the first storage area reclamation process.

[0101] For example, during the UEFI startup phase of an electronic device, in response to a first write request, if the remaining storage space in the first storage area is less than or equal to a target threshold, the UEFI writes the first data to the second storage area and executes the recycling process of the first storage area. Specifically, this includes: writing the valid data in the first storage area to the second storage area, erasing the first storage area, and then writing the valid data in the second storage area and the first data written by the UEFI back to the first storage area to complete the recycling process of the first storage area.

[0102] For example, during the UEFI boot phase of an electronic device, the UEFI responds to a first write request and, if it detects that the remaining storage space in the first storage area is greater than a target threshold, writes the first data into the first storage area. After the UEFI boot is complete, the operating system runs. Responding to a second write request, the operating system, if it detects that the remaining storage space in the first storage area is greater than the target threshold, writes the second data into the first storage area. Based on this, when the electronic device restarts, the UEFI responds to the electronic device's boot command and detects that the remaining storage space in the first storage area is less than or equal to the target threshold. At this time, it writes the valid data in the first storage area (including the first data written by the UEFI and the second data written by the operating system) to the second storage area, then erases the first storage area. Afterward, it writes the valid data in the second storage area back to the first storage area, completing the first storage area reclamation process.

[0103] refer to Figure 5 This is a flowchart illustrating the implementation of a processing method provided in an embodiment of this application. This method can be applied to electronic devices having a first storage area and a second storage area. The technical solution in this embodiment is mainly used to improve the user experience of electronic devices.

[0104] Specifically, the method in this embodiment may include the following steps:

[0105] Step 501: When the electronic device is in the running stage corresponding to the operating system, in response to the second write request, detect whether the remaining storage space of the first storage area is greater than the target threshold; if the remaining storage space of the first storage area is less than or equal to the target threshold, execute step 502. If the remaining storage space of the first storage area is greater than the target threshold, execute step 503.

[0106] The second write request is used to request the writing of the second data corresponding to the bootloader to the first storage area.

[0107] For example, the second data could be parameter data used to configure UEFI settings on the UEFI settings interface during the operating system's runtime phase.

[0108] Step 502: Write the second data into the second storage area.

[0109] Step 503: Write the second data into the first storage area.

[0110] As can be seen, in this application, when the remaining storage space in the first storage area is insufficient, the second data is directly written to the second storage area, and there will be no situation where writing is not possible due to insufficient remaining storage space in the first storage area. If the remaining storage space in the first storage area is sufficient, then the second data will continue to be written to the first storage area.

[0111] The second storage area is the storage area deployed to the baseboard management controller in the electronic device; the first storage area is used to store the data corresponding to the boot program; the boot program is used to boot the operating system.

[0112] Furthermore, the bootstrap program is also used to transfer valid data from the first storage area to the second storage area when it detects that the remaining storage space in the first storage area is less than or equal to a target threshold, and to write the valid data and the second data from the second storage area back to the first storage area after erasing the first storage area. Based on this, in this embodiment, the reclamation process for the first storage area is performed during the bootstrap program's startup phase.

[0113] As can be seen from the above technical solutions, in the processing method provided by this application embodiment, when the bootloader detects that the remaining storage space of the first storage area used to store the data corresponding to the bootloader is less than or equal to a target threshold, it first transfers the valid data in the first storage area to the second storage area deployed to the baseboard management controller, then erases the first storage area, and then writes the data in the second storage area back to the second storage area. After the bootloader completes the operating system running stage, the operating system can determine the writing area of ​​the second data according to the size of the remaining storage space in the first storage area. It can be seen that in this embodiment, the storage area in the memory where the first storage area is located is not used as the backup storage area, but the storage area of ​​the baseboard management controller is used as the backup second storage area. When the first storage area is reclaimed, data read and write are performed between the first storage area and the second storage area, without frequent read and write operations in the memory where the first storage area is located. This reduces the read and write frequency of the memory where the first storage area is located, and thus does not cause the task currently being executed by the electronic device to be blocked, thereby improving the task execution status of the electronic device when the first storage area is reclaimed, thereby improving the user's experience with the electronic device.

[0114] In one implementation, this embodiment may also include the following processing, such as... Figure 6 As shown:

[0115] Step 601: In response to the read request, the operating system reads the data matching the read request from the second storage area.

[0116] In this case, the read request is a request from the operating system to read the bootloader data. In this embodiment, if the remaining storage space in the first storage area is less than or equal to the target threshold, the system will first search for data matching the read request in the second storage area.

[0117] Step 602: Determine whether data matching the read request is read in the second storage area. If no data matching the read request is read in the second storage area, proceed to step 603.

[0118] Specifically, in this embodiment, the corresponding data can be searched in the second storage area according to the read / write request. If the data is found, it is read directly; if the data is not found, the data is searched in the first storage area.

[0119] Step 603: The operating system reads the data matching the read request from the first storage area.

[0120] As can be seen, in this embodiment, considering that data reading is most likely to be reading recently written data, the operating system can prioritize reading from the second storage area when it needs to read the boot program data. If the data matching the read request cannot be read from the second storage area, it can then search for data matching the read request in the first storage area, which can improve the data read hit rate.

[0121] refer to Figure 7 This is a schematic diagram of a processing device provided in an embodiment of this application. The processing device can be understood as a bootloader such as UEFI. Specifically, the processing device may include the following units:

[0122] The data transfer unit 701 is used to transfer valid data in the first storage area to the second storage area when the remaining storage space in the first storage area is less than or equal to a target threshold.

[0123] Storage erasure unit 702 is used to erase the first storage area;

[0124] The data write-back unit 703 is used to write data in the second storage area back to the first storage area;

[0125] The first storage area is used to store data corresponding to the boot program; the boot program is used to boot the operating system of the electronic device; the second storage area is the storage area deployed to the baseboard management controller in the electronic device.

[0126] As can be seen from the above technical solutions, in the processing apparatus provided in this application embodiment, when the bootloader detects that the remaining storage space in the first storage area used to store data corresponding to the bootloader is less than or equal to a target threshold, it first transfers the valid data in the first storage area to the second storage area deployed to the baseboard management controller, then erases the first storage area, and then writes the data in the second storage area back to the second storage area. It is evident that in this embodiment, the storage area in the memory where the first storage area is located is not used as a backup storage area; instead, the storage area of ​​the baseboard management controller is used as the backup second storage area. When reclaiming the first storage area, data reads and writes are performed between the first and second storage areas, eliminating the need for frequent reads and writes in the memory where the first storage area is located. This reduces the read and write frequency in the memory where the first storage area is located, thus preventing the current task being blocked by the electronic device. This improves the task execution status of the electronic device when reclaiming the first storage area, thereby improving the user experience of the electronic device.

[0127] In one implementation, the data transfer unit 701 is further configured to: when the electronic device is in the startup phase corresponding to the boot program, in response to the first write request of the boot program, detect whether the remaining storage space of the first storage area is less than or equal to the target threshold; based on this, when the data transfer unit 701 detects that the remaining storage space of the first storage area is less than or equal to the target threshold, transfer the valid data in the first storage area to the second storage area.

[0128] Wherein, when the data transfer unit 701 detects that the remaining storage space in the first storage area is less than or equal to the target threshold, it is further configured to: write the first data into the second storage area; the first data is: the data that the bootstrap program needs to write to the first storage area in response to the first write request.

[0129] In one implementation, the data transfer unit 701 is further configured to: in response to the start command of the electronic device, detect whether the remaining storage space of the first storage area is less than or equal to the target threshold; based on this, when the data transfer unit 701 detects that the remaining storage space of the first storage area is less than or equal to the target threshold, transfer the valid data in the first storage area to the second storage area.

[0130] In one implementation, the apparatus in this embodiment may further include the following units, such as... Figure 8 As shown:

[0131] Address adjustment unit 704 is used to: after data transfer unit 701 transfers valid data in the first storage area to the second storage area and before storage erase unit 702 erases the first storage area, adjust the access address of the first storage area to point to the storage address of the valid data in the second storage area.

[0132] The address adjustment unit 704 is further configured to restore the access address of the first storage area after the data write-back unit 703 writes the data in the second storage area back to the first storage area.

[0133] In one implementation, when the data write-back unit 703 writes data from the second storage area back to the first storage area, it includes at least one of the following:

[0134] Write the valid data in the second storage area back to the first storage area;

[0135] Write the first data in the second storage area back to the first storage area;

[0136] Write the second data in the second storage area back to the first storage area;

[0137] Wherein, the first data is: the data written by the bootloader to the second storage area in response to the first write request when the remaining storage space is less than or equal to the target threshold;

[0138] The second data is: data written by the operating system to the second storage area in response to a second write request when the remaining storage space is less than or equal to the target threshold.

[0139] It should be noted that the specific implementation of each unit in this embodiment can be referred to the corresponding content above, and will not be described in detail here.

[0140] refer to Figure 9 This is a schematic diagram of a processing device provided in an embodiment of this application. The device can be understood as an operating system. Specifically, the processing device may include the following units:

[0141] The remaining detection unit 901 is used to detect whether the remaining storage space of the first storage area is greater than a target threshold in response to a second write request when the electronic device is in the running stage corresponding to the operating system; the second write request is used to request to write the second data corresponding to the boot program to the first storage area.

[0142] The data writing unit 902 is used to write the second data into the second storage area when the remaining storage space in the first storage area is less than or equal to the target threshold; and to write the second data into the first storage area when the remaining storage space in the first storage area is greater than the target threshold.

[0143] The second storage area is the storage area deployed to the baseboard management controller in the electronic device; the first storage area is used to store the data corresponding to the boot program; the boot program is used to boot the operating system.

[0144] Furthermore, the bootloader is also configured to transfer valid data in the first storage area to the second storage area when the remaining storage space in the first storage area is less than or equal to a target threshold, and to write the valid data in the second storage area and the second data back to the first storage area after erasing the first storage area.

[0145] As can be seen from the above technical solutions, in the processing apparatus provided in this application embodiment, when the bootloader detects that the remaining storage space of the first storage area used to store the data corresponding to the bootloader is less than or equal to a target threshold, it first transfers the valid data in the first storage area to the second storage area deployed to the baseboard management controller, then erases the first storage area, and then writes the data in the second storage area back to the second storage area. After the bootloader completes the operating system running stage, the operating system can determine the writing area of ​​the second data according to the size of the remaining storage space in the first storage area. It can be seen that in this embodiment, the storage area in the memory where the first storage area is located is not used as the backup storage area, but the storage area of ​​the baseboard management controller is used as the backup second storage area. When the first storage area is reclaimed, data read and write are performed between the first storage area and the second storage area, without frequent read and write operations in the memory where the first storage area is located. This reduces the read and write frequency of the memory where the first storage area is located, and thus does not cause the currently executed task of the electronic device to be blocked, thereby improving the task execution state of the electronic device when the first storage area is reclaimed, thereby improving the user's experience of using the electronic device.

[0146] In one implementation, the apparatus in this embodiment may further include the following units, such as... Figure 10 As shown:

[0147] The data reading unit 903 is configured to, in response to a read request, read data matching the read request in the second storage area; and, if no data matching the read request is found in the second storage area, read data matching the read request in the first storage area.

[0148] It should be noted that the specific implementation of each unit in this embodiment can be referred to the corresponding content above, and will not be described in detail here.

[0149] In addition, embodiments of this application also provide an electronic device in which a bootloader and an operating system can be deployed via a memory and a processor, wherein:

[0150] When the bootloader detects that the remaining storage space in the first storage area is less than or equal to the target threshold, it transfers the valid data in the first storage area to the second storage area; erases the first storage area; and writes the data in the second storage area back to the first storage area.

[0151] The first storage area is used to store data corresponding to the boot program; the boot program is used to boot the operating system of the electronic device; the second storage area is the storage area deployed to the baseboard management controller in the electronic device.

[0152] Specifically, when the electronic device is in the startup phase corresponding to the boot program, in response to the boot program's first write request, the boot program detects whether the remaining storage space in the first storage area is less than or equal to the target threshold, and if it detects that the remaining storage space in the first storage area is less than or equal to the target threshold, it also writes the first data into the second storage area; the first data is: the data that the boot program needs to write to the first storage area in response to the first write request.

[0153] Alternatively, in response to the startup command of the electronic device, the bootloader detects whether the remaining storage space in the first storage area is less than or equal to the target threshold.

[0154] In addition, after transferring the valid data in the first storage area to the second storage area, the bootloader adjusts the access address of the first storage area to point to the storage address of the valid data in the second storage area before erasing the first storage area; and after writing the data in the second storage area back to the first storage area, it restores the access address of the first storage area.

[0155] When the bootloader writes data from the second storage area back to the first storage area, it includes at least one of the following:

[0156] Write the valid data in the second storage area back to the first storage area;

[0157] Write the first data in the second storage area back to the first storage area;

[0158] Write the second data in the second storage area back to the first storage area;

[0159] When the electronic device is in the running stage corresponding to the operating system, the operating system responds to the second write request and checks whether the remaining storage space of the first storage area is greater than the target threshold; the second write request is used to request the writing of the second data corresponding to the boot program to the first storage area; if the remaining storage space of the first storage area is less than or equal to the target threshold, the second data is written to the second storage area; if the remaining storage space of the first storage area is greater than the target threshold, the second data is written to the first storage area.

[0160] In addition, in response to a read request, the operating system reads data matching the read request from the second storage area; if no data matching the read request is found in the second storage area, the operating system reads data matching the read request from the first storage area.

[0161] Taking an electronic device as a server as an example, the technical solution of this application is illustrated below:

[0162] Firstly, in the server system architecture, the NVRAM area of ​​UEFI is used to store critical information such as firmware settings, boot configuration, and user data. This area is typically stored in flash memory. Flash memory's physical characteristics support read, erase, and write operations, but write operations can only go from 1 to 0. When the NVRAM area is insufficient, the target block needs to be erased. Erasure can restore from 0 to 1, and the erase unit is usually a fixed-size block (e.g., 4KB, 64KB). Under the current UEFI specification, when updating or deleting data in NVRAM, the new data is written to a free area in NVRAM, and the original data location is marked as invalid. After multiple iterations, the NVRAM area will generate a large amount of fragmentation, leading to insufficient available contiguous space. To address this, the UEFI NVRAM driver introduces an NVRAM space reclamation mechanism, namely NVRAM Reclaim: when creating or updating data, if the UEFI driver detects insufficient contiguous space, it will trigger a reclamation process to release contiguous available NVRAM space.

[0163] In existing technology, two NVRAM regions are partitioned on the current flash memory: one is the primary region used normally, and the other is a backup region used during the reclaim mechanism. When UEFI creates or updates data such as variables in NVRAM, it first checks the available space in the current primary NVRAM. If the remaining available space is insufficient, NVRAM reclaim is initiated. During NVRAM reclaim, all valid data is organized, written to the backup NVRAM region, and then the current primary NVRAM region is erased. The system is then booted from the backup NVRAM region, or the valid data in the backup NVRAM is written back to the primary NVRAM region before booting from the primary NVRAM region.

[0164] The above NVRAM recycling mechanism has the following drawbacks:

[0165] 1. Affects boot performance and excessively consumes flash memory resources: During the system boot phase, NVRAM space reclamation is performed, and frequent erasure and read / write of Flash can take hundreds of milliseconds, which seriously prolongs the server boot time. In addition, a back NVRAM area of ​​the same size is required to complete the reclaim process.

[0166] 2. Business Interruption: During operating system runtime, the recycling process is executed through the System Management Interrupt (SMI) handler. During this period, host processing is monopolized, which will cause noticeable lag in the operating system and upper-layer applications, and may even cause system crashes due to the blocking of critical tasks, seriously affecting business continuity.

[0167] 3. Reliability risks arising from functional compromises: To avoid the aforementioned operational interruptions, some UEFI solutions choose to disable the recycling function during operating system runtime. This will result in the inability to release NVRAM fragment space. When the NVRAM area becomes unwriteable due to fragmentation exhaustion, critical functions that rely on runtime updates of UEFI variables will fail, posing a serious threat to system operation and reliability.

[0168] In view of this, this application proposes an innovative method for backing up UEFI NVRAM data in the shared memory area of ​​the BMC and realizing NVRAM data reclamation. The core concept of this application is that: during the server startup phase or when the operating system is running, if the NVRAM area is full, by utilizing the BMC's out-of-band management capabilities independent of the host operating system and its read and write permissions to flash memory, the valid data of NVRAM can be sent to the BMC for backup. After the UEFI erases the NVRAM, the valid data backed up in the BMC is then written back to the UEFI NVRAM area.

[0169] Specifically, the key technical points of this application are as follows:

[0170] like Figure 11 The diagram shown is a flowchart of the recycling mechanism implemented during the server startup phase, which specifically includes:

[0171] During the server startup phase, when the Basic Input / Output System (BIOS) writes data to NVRAM (i.e., the first write request), it can determine whether there is enough space in NVRAM. If there is enough space, the data can be successfully written to NVRAM. If the NVRAM area is full, the valid data in NVRAM is backed up to a shared memory file in the BMC shared memory space. Then, the address of NVRAM is modified to point to the address where the valid data in the BMC shared memory is located. After UEFI erases the primary NVRAM area, the valid data in the BMC shared memory space is written back to the UEFI NVRAM area. Furthermore, the address of NVRAM needs to be restored. Finally, the data in the BMC shared memory space is deleted.

[0172] like Figure 12As shown, when the operating system is running, if the operating system needs to store data into the NVRAM, it determines whether the NVRAM has enough space. If it does, the data is successfully stored. If the NVRAM is full, the operating system will temporarily store the data that it wants to store into the NVRAM in a file in the shared memory space of the BMC.

[0173] like Figure 13 As shown, when the operating system is running, if the operating system needs to read data from NVRAM, it first checks if there is any data that the operating system needs to read in the files of the shared memory space of the BMC. If not, it reads from the NVRAM area. If it does, then the data can be successfully read from the shared memory space of the BMC.

[0174] like Figure 14 As shown, when the server starts up again, a reclamation mechanism is executed on the NVRAM during the server startup phase: It checks whether the operating system has written data to the BMC's shared memory space. If not, no action is taken. If so, it indicates that NVRAM space was insufficient during the previous server run. In this case, it checks whether the reclamation mechanism has already been executed, i.e., whether valid data in the NVRAM exists in the BMC's shared memory space. If not, the valid data in the NVRAM can be backed up to the BMC's shared memory space, and then the address of the NVRAM is set to the storage address of the valid data in the BMC's shared memory space before erasing the primary NVRAM area. If valid data in the NVRAM exists in the BMC's shared memory space, it means that the reclamation mechanism has been executed. In this case, after erasing the primary NVRAM area, the valid data in the BMC's shared memory space and the data written by the operating system are written together to the NVRAM area. Finally, the valid data in the BMC's shared memory space and the data written by the operating system are deleted.

[0175] Additionally, if an anomaly such as a power outage causes the recycling mechanism to be interrupted during the above-described recycling process, you can refer to... Figure 15 The process of the recovery and recycling mechanism shown (and) Figure 11 and Figure 14 The recycling mechanism shown is similar, as detailed below:

[0176] First, determine if valid NVRAM data exists in the BMC shared memory space. That is, check if there is a backup of valid NVRAM data in the BMC's shared memory space. If it does, it means there isn't enough space in the NVRAM, and the valid NVRAM data has already been written to the BMC's shared memory space. Then, further determine if the operating system has written data to the BMC's shared memory space. If so, the primary NVRAM area can be directly erased, and the backup NVRAM data from the BMC's shared memory space, along with the data written by the operating system, can be written back to the NVRAM. Then, the backup NVRAM data and the data written by the operating system in the BMC's shared memory space are deleted. If the operating system hasn't written data to the BMC's shared memory space, after erasing the primary NVRAM area, the backup NVRAM data from the BMC's shared memory space is written back to the NVRAM.

[0177] If the valid data of NVRAM is not stored in the BMC shared memory space, that is, if there is no backup of the valid data of NVRAM in the BMC shared memory space, it cannot be determined whether there is enough space in NVRAM. At this time, it is determined whether there is enough space in NVRAM. If there is enough space, then no reclamation mechanism needs to be executed. If there is not enough space, then the valid data of NVRAM must first be backed up to the BMC shared memory space, and the address of NVRAM must be modified to point to the storage address of the valid data in the BMC shared memory space. Then, the NVRAM area of ​​the primary is erased. Then, the valid data of NVRAM backed up from the BMC shared memory space is written to NVRAM.

[0178] In summary, this application has the following advantages:

[0179] 1. It completely avoids the risk of system lag, stagnation or crashes caused by recycling operations during operating system runtime, ensuring the continuity of critical business operations.

[0180] 2. Improved system boot performance: Reduced the number of read / write and erase operations on flash memory, and eliminated the need for read / write and erase operations on backup NVRAM.

[0181] 3. Improve system reliability and maintainability: By keeping the recycling mechanism enabled at all times in the operating system environment, the failure of core functions (such as online firmware updates) due to NVRAM space exhaustion is effectively avoided, thereby improving the long-term operational reliability and maintainability of the system.

[0182] 4. Saves flash memory space, eliminating the need for an additional NVRAM space of equal size for backup.

[0183] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to the method section.

[0184] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0185] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.

[0186] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A processing method, comprising: If the remaining storage space in the first storage area is less than or equal to the target threshold, the valid data in the first storage area will be transferred to the second storage area. Erase the first storage area; Write the data in the second storage area back to the first storage area; The first storage area is used to store data corresponding to the bootloader; the bootloader is used to boot the operating system of the electronic device; the second storage area is the storage area deployed to the baseboard management controller in the electronic device.

2. The method according to claim 1, further comprising: When the electronic device is in the startup phase corresponding to the bootloader, in response to the first write request of the bootloader, it is detected whether the remaining storage space of the first storage area is less than or equal to the target threshold.

3. The method according to claim 2, wherein if the remaining storage space in the first storage region is detected to be less than or equal to the target threshold, the method further comprises: Write the first data into the second storage area; The first data is: the data that the bootloader needs to write to the first storage area in response to the first write request.

4. The method according to claim 1, further comprising: In response to the start command of the electronic device, it is detected whether the remaining storage space in the first storage area is less than or equal to the target threshold.

5. The method according to claim 1, wherein after transferring valid data in the first storage area to the second storage area and before erasing the first storage area, the method further comprises: Adjust the access address of the first storage area to point to the storage address of the valid data in the second storage area; The method further includes, after writing the data from the second storage area back to the first storage area: Restore the access address of the first storage area.

6. The method of claim 1, wherein writing data in the second storage area back to the first storage area comprises at least one of the following: Write the valid data in the second storage area back to the first storage area; Write the first data in the second storage area back to the first storage area; Write the second data in the second storage area back to the first storage area; Wherein, the first data is: the data written by the bootloader to the second storage area in response to the first write request when the remaining storage space is less than or equal to the target threshold; The second data is: data written by the operating system to the second storage area in response to a second write request when the remaining storage space is less than or equal to the target threshold.

7. A processing method, comprising: When the electronic device is in the running stage corresponding to the operating system, in response to the second write request, it is detected whether the remaining storage space in the first storage area is greater than the target threshold. The second write request is used to request the writing of the second data corresponding to the bootloader to the first storage area; If the remaining storage space in the first storage area is less than or equal to the target threshold, the second data is written to the second storage area. If the remaining storage space in the first storage area is greater than the target threshold, the second data is written into the first storage area; The second storage area is the storage area deployed to the baseboard management controller in the electronic device; the first storage area is used to store the data corresponding to the boot program; the boot program is used to boot the operating system. Furthermore, the bootloader is also configured to transfer valid data in the first storage area to the second storage area when the remaining storage space in the first storage area is less than or equal to a target threshold, and to write the valid data in the second storage area and the second data back to the first storage area after erasing the first storage area.

8. The method according to claim 7, further comprising: In response to a read request, data matching the read request is read from the second storage area; If no data matching the read request is found in the second storage area, the data matching the read request is read in the first storage area.

9. A processing apparatus, comprising: The data transfer unit is used to transfer valid data in the first storage area to the second storage area when the remaining storage space in the first storage area is less than or equal to a target threshold. A storage erasure unit is used to erase the first storage area; A data write-back unit is used to write data from the second storage area back to the first storage area; The first storage area is used to store data corresponding to the bootloader; the bootloader is used to boot the operating system of the electronic device; the second storage area is the storage area deployed to the baseboard management controller in the electronic device.

10. A processing apparatus, comprising: The remaining detection unit is used to detect whether the remaining storage space of the first storage area is greater than the target threshold in response to the second write request when the electronic device is in the running stage corresponding to the operating system. The second write request is used to request the writing of the second data corresponding to the bootloader to the first storage area; A data writing unit is used to write the second data into a second storage area when the remaining storage space in the first storage area is less than or equal to the target threshold. If the remaining storage space in the first storage area is greater than the target threshold, the second data is written into the first storage area; The second storage area is the storage area deployed to the baseboard management controller in the electronic device; the first storage area is used to store the data corresponding to the boot program; the boot program is used to boot the operating system. Furthermore, the bootloader is also configured to transfer valid data in the first storage area to the second storage area when the remaining storage space in the first storage area is less than or equal to a target threshold, and to write the valid data in the second storage area and the second data back to the first storage area after erasing the first storage area.