Data writing method, electronic equipment and computer readable storage medium

By writing data to the kernel cache in the microkernel system and asynchronously allocating disk space, the interaction between the kernel state and the user state is optimized, solving the problem of low feedback efficiency of kernel process and improving the user experience.

CN120353379APending Publication Date: 2025-07-22ZTE CORP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411305050.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-19
Publication Date
2025-07-22

AI Technical Summary

Technical Problem

In microkernel systems, the interaction between the kernel state and the user state is complex, resulting in low feedback on the data writing results of the kernel process, which affects the user experience, especially when the small blocks of data are frequently called for writing, the experience is even worse.

Method used

After the kernel receives the data write request from the user-state process, it writes the data to the kernel cache and notifies the user-state process that the data is successfully written. At the same time, it is notified asynchronously that the user-state process allocates disk space, and optimizes the data writing process to reduce the interaction between the kernel-state and the user-state.

Benefits of technology

By optimizing the data writing process, the interaction complexity between the kernel state and the user state is reduced, the kernel's feedback efficiency for data writing results is improved, and the user experience is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120353379A_ABST
    Figure CN120353379A_ABST
Patent Text Reader

Abstract

The invention discloses a data writing method, electronic equipment and a computer readable storage medium, and belongs to the technical field of computers.The data writing method comprises the steps that a kernel receives a data writing request sent by a first user mode process; the kernel writes target data corresponding to the data writing request into a kernel cache; the kernel informs the first user mode process of successful data writing; and the kernel notifies a second user state process to allocate a disk space for the target data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of computer technology, and particularly relates to a method for writing data, an electronic device, and a computer-readable storage medium. Background Art

[0002] Compared with a macro kernel operating system, a micro kernel system can be used to implement functions such as process scheduling, memory management, and process communication. Other parts such as the Virtual File System (VFS) and network protocols can be used as services in the user space and run in the user state of the micro kernel system. Such a design can limit sensitive resource access to the kernel mode, reduce the complexity of the kernel, and improve the security and reliability of the micro kernel system.

[0003] Among them, for the micro kernel system, a related technology provides a process for writing data to a disk, which includes: a user process calls the system call write(), and after the kernel process captures the system call write(), it requests the file system to allocate disk space. After the file system successfully allocates disk space, it returns the allocation result to the kernel process. When the kernel process determines that the allocation result is successful, it writes the data corresponding to write() into the kernel cache, and finally the kernel process notifies the user process that the data writing is successful.

[0004] However, in the foregoing data writing process, there is also a problem of complex interaction between the kernel state (such as the kernel process) and the user state (such as the user process and the file system), resulting in low feedback efficiency of the kernel process for the data writing result and affecting the user experience. Summary of the Invention

[0005] The purpose of the embodiments of this application is to provide a method for writing data, an electronic device, and a computer-readable storage medium. By optimizing the data writing process, it is possible to reduce the interaction complexity between the kernel state and the user state, improve the feedback efficiency of the kernel process for the data writing result, and improve the user experience.

[0006] In a first aspect, a method for writing data is provided, including: the kernel receives a data write request sent by a first user state process; the kernel writes the target data corresponding to the data write request into the kernel cache; the kernel notifies the first user state process that the data writing is successful; the kernel notifies a second user state process to allocate disk space for the target data.

[0007] In a second aspect, an embodiment of this application provides an electronic device, including: a memory, a processor, and computer executable instructions stored on the memory and executable on the processor. When the computer executable instructions are executed by the processor, the steps of the method described in the first aspect are implemented. In a third aspect, an embodiment of the present application provides a computer-readable storage medium for storing computer-executable instructions, which, when executed by a processor, implement the steps of the method described in the first aspect. In an embodiment of the present application, when the kernel receives a data write request sent by a first user-mode process, it can write the target data corresponding to the data write request into the kernel cache, then notify the first user-mode process that the data writing is successful, and notify a second user-mode process to allocate disk space for the target data. Thus, by optimizing the data writing process, the interaction complexity between the kernel mode and the user mode can be reduced. For example, before feedback on the data writing result, the kernel mode only needs to interact with the first user-mode process, improving the feedback efficiency of the kernel for the data writing result and enhancing the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0008] To more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for description in the embodiments or the prior art. Obviously, the drawings described below are only some embodiments recorded in the present application. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.

[0009] Figure 1 is a flowchart of a data writing process in the related art provided by the present application.

[0010] Figure 2 is a flowchart of a method for writing data provided by an exemplary embodiment of the present application.

[0011] Figure 3 is one of the schematic diagrams of a data writing process provided by an exemplary embodiment of the present application.

[0012] Figure 4 is another schematic diagram of a data writing process provided by an exemplary embodiment of the present application.

[0013] Figure 5 is yet another schematic diagram of a data writing process provided by an exemplary embodiment of the present application.

[0014] Figure 6 is still another schematic diagram of a data writing process provided by an exemplary embodiment of the present application.

[0015] Figure 7 is a schematic diagram of the structure of an electronic device provided by an exemplary embodiment of the present application. DETAILED DESCRIPTION

[0016] To enable those skilled in the art to better understand the technical solutions in this application, the following will clearly and completely describe the technical solutions in the embodiments of this application 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 of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in this application without creative efforts shall fall within the scope of protection of this application.

[0017] The microkernel system is an operating system design used to improve the security and reliability of the operating system. Among them, the microkernel system also has the following characteristics.

[0018] 1. The microkernel system depends on hardware resources such as the underlying processor, memory, and block devices.

[0019] 2. In the microkernel system, the file system runs as a service in the user space. Among them, the file system is a method for organizing and managing files on a computer storage device.

[0020] 3. The system call of the microkernel system is an interface provided by the microkernel system to the application program for requesting microkernel system services, such as the system call write(), the system call open(), the system call remove(), etc. Among them, the system call allows users to request services from the operating system without considering the underlying details.

[0021] Among them, for the system call write(), it can write data to the disk through the file system, and its call speed is an important feature reflecting the performance of the file system service.

[0022] As Figure 1 shown, in the related art, when writing data to the disk through the system call write(), the involved data writing process usually includes: the user process calls the system call write(), the kernel process requests the file system to allocate disk space after capturing the system call write(), the file system returns the allocation result to the kernel process after successfully allocating disk space, the kernel process writes the data corresponding to write() into the kernel cache when determining that the allocation result is successful, and finally the kernel process notifies the user process that the data writing is successful.

[0023] Please refer to again Figure 1, in the aforementioned write data process provided in the related art, since one write() requires multiple conversions between the kernel mode and the user mode (such as user processes and file systems), the time consumption of process communication accounts for a large proportion in one write data process, resulting in low feedback efficiency of the kernel process for the data write result and affecting the user experience. Especially when frequently calling write() to write small chunks of data, the time consumption of process communication is more obvious and the user experience is worse.

[0024] In response to this, the embodiments of the present application provide a write data solution. By optimizing the write data process provided in the related art, it is possible to reduce the interaction complexity between the kernel mode and the user mode, improve the feedback efficiency of the kernel process for the data write result, and improve the user experience. Among them, since both the user process and the file system belong to user-mode processes, hereinafter, the user process is described as the first user-mode process and the file system is described as the second user-mode process. In addition, the kernel described hereinafter can be understood as the aforementioned kernel process.

[0025] Based on this, the technical solutions provided by the embodiments of the present application will be described in detail below with reference to the accompanying drawings through some embodiments and their application scenarios.

[0026] Figure 2 FIG. 200 shows a schematic flowchart of a method 200 for writing data provided by an embodiment of the present application. The method 200 can be executed by an electronic device, such as a terminal device or a server device. In other words, the method can be executed by software or hardware installed in the terminal device or the server device. The server includes but is not limited to: a single server, a server cluster, a cloud server, or a cloud server cluster, etc. As Figure 2 shown, the method 200 may include the following steps.

[0027] S210, the kernel receives a data write request sent by the first user-mode process.

[0028] Wherein, the data write request may be but is not limited to the system call write() captured or obtained by the kernel.

[0029] S220, the kernel writes the target data corresponding to the data write request into the kernel cache.

[0030] S230, the kernel notifies the first user-mode process that the data writing is successful.

[0031] S240, the kernel notifies the second user-mode process to allocate disk space for the target data.

[0032] Exemplarily, please refer to Figure 3 , assuming that the data write request is the system call write(), then, relative to Figure 1In the data writing process provided in the related art shown, in this embodiment, after the kernel captures the system call write(), it directly writes the target data corresponding to write() into the kernel cache, and then notifies the first user-mode process that the data writing is successful, thus completing the feedback of the data writing result of one write(). Therefore, compared with the related art, the interaction mode between the kernel mode and the user mode is optimized in the embodiment of the present application. For example, the "second user-mode process allocating disk space" during the write() process is migrated to background processing, saving the time for "the kernel communicating with the second user-mode process" and "the second user-mode process allocating disk space", so that the kernel mode only needs to interact with the first user-mode process to perform the feedback of the data writing result, effectively reducing the interaction complexity between the kernel mode and the user mode, improving the feedback efficiency of the kernel for the data writing result, and enhancing the user experience.

[0033] For example, please refer to Figure 1 and Figure 3 . Through the optimization of the data writing process, the embodiment of the present application can effectively reduce the time consumption of one write(), improve the feedback efficiency of the kernel for the data writing result, and enhance the user experience.

[0034] In one embodiment, the execution order of "the kernel notifying the first user-mode process that the data writing is successful" in S230 and "the kernel notifying the second user-mode process to allocate disk space for the target data" in S240 can be the same. That is, in this embodiment, the kernel requests the second user-mode process to allocate disk space for the target data while notifying the first user-mode process that the data writing is successful. Thus, while effectively improving the feedback efficiency of the kernel for the data writing result, it can also achieve the timely application for disk space, ensuring the writing efficiency when subsequent data is written from the kernel cache to the disk.

[0035] Alternatively, the execution order of "the kernel notifying the second user-mode process to allocate disk space for the target data" in S240 is as Figure 3 shown, after "the kernel notifying the first user-mode process that the data writing is successful" in S230. That is, in this embodiment, the kernel can request the second user-mode process to allocate disk space for the target data after notifying the first user-mode process that the data writing is successful, so as to effectively improve the feedback efficiency of the kernel for the data writing result and enhance the user experience.

[0036] In one embodiment, when the kernel notifies the second user-mode process to allocate disk space for the target data in S240, it may also notify the second user-mode system to mark the data blocks in the corresponding range as dirty. Alternatively, after receiving the notification from the kernel to allocate disk space, the second user-mode performs disk space allocation and marks the data blocks in the corresponding range as dirty, which is not limited here.

[0037] In one embodiment, assume that the write data process provided in the foregoing S210 - S240 is defined as an asynchronous mode, that is, the asynchronous mode includes: the kernel first writes the target data corresponding to the data write request into the kernel cache, then notifies the first user-mode process that the data writing is successful, and notifies the second user-mode process to allocate disk space for the target data. Then, as Figure 4 shown, the second user-mode process can notify the kernel to use the asynchronous mode when it determines that the first condition is met. Wherein, the first condition includes: the remaining space in the disk space is greater than the first threshold, and the second user-mode process has not had an exception or the exception has been resolved. Thus, it can be ensured that after the target data is written into the kernel cache in the asynchronous mode, the second user-mode process can allocate sufficient disk space for it to facilitate the smooth writing of the target data.

[0038] In one embodiment, there can be multiple ways to determine the remaining space in the disk space. In one implementation, the second user-mode process can determine the remaining space in the disk space after each disk space allocation. For example, the second user-mode process can allocate disk space according to the received first notification, and determine the remaining space in the disk space after the disk space allocation is completed. Wherein, the first notification is for the kernel to apply for disk space. In another implementation, please refer to Figure 5 , if the first user-mode process frequently calls write(), and the rate at which the second user-mode process allocates disk space is lower than the receiving rate of the second notification (for the kernel to apply for disk space from the second user-mode process), it will cause the second user-mode process to not be able to allocate disk space in a timely manner for the received second notification, resulting in the second notification being backlogged and cached in the message processing process or message pool of the second user-mode process. In this regard, in the embodiments of the present application, when determining the remaining space in the disk space, before allocating disk space for at least one backlogged second notification, the second user-mode process can first perform a quick preprocessing on the backlogged second notifications to calculate the total disk space to be applied for by all the backlogged second notifications, and then determine the remaining space in the disk space according to the difference between the current remaining space in the disk space and the total disk space to be applied for by the at least one second notification. Thus, the accuracy of the determination result of the remaining space in the disk space can be ensured.

[0039] For example, assume that the current remaining space in the disk space is S, and there are 3 unprocessed second notifications backlogged in the message pool of the second user-mode process, such as M1, M2, and M3. Among them, the disk space to be applied for by M1 is N1, the disk space to be applied for by M2 is N2, and the disk space to be applied for by M3 is N3. Then, the second user-mode process can determine the remaining space of the disk space as: (S - (N1 + N2 + N3)), that is, when the second user-mode process determines whether the remaining space of the disk space is greater than the first threshold, it can determine whether (S - (N1 + N2 + N3)) is greater than the first threshold.

[0040] In this embodiment, through the method for determining the remaining space in the disk space provided in the foregoing implementation manner, it is also possible to avoid the error that the second user-mode process cannot allocate disk space for it due to the total disk space to be applied for by the backlogged or cached second notifications being greater than the remaining space of the disk space. Especially for the write data process in the asynchronous mode, since the error that the second user-mode process cannot allocate disk space for the backlogged second notifications cannot be returned to the kernel and cannot be returned to the first user-mode process, it will also cause the problem that the return value of the data write result does not match the actual situation.

[0041] In one embodiment, the design of the foregoing first threshold can refer to the total disk capacity, the upper limit of device memory, and the Inter-Process Communication (IPC) speed, etc. For example, in this embodiment, the first threshold can be, but is not limited to, 200 Mb to 500 Mb.

[0042] In one embodiment, the size of the remaining space in the disk space is not only related to the data write request, but also can be as Figure 5 shown, related to at least one of the file creation operation, the file truncation operation, and the file deletion operation. That is to say, similar to the data write operation corresponding to the foregoing data write request, the execution of at least one of the file creation operation, the file truncation operation, and the file deletion operation will also cause the remaining space of the disk space to change. Therefore, when determining the remaining space of the disk space, the file creation operation, the file truncation operation, and the file deletion operation can also be considered to improve the accuracy of the determination result of the remaining space of the disk space.

[0043] Among them, the file creation operation can be implemented through system calls such as open(), the file truncation operation can be implemented through system calls such as truncate(), and the file deletion operation can be implemented through system calls such as remove().

[0044] In one embodiment, when no exception occurs or the exception is resolved for the aforementioned second user-mode process, the occurrence of an exception for the second user-mode process described in this application may include at least one of the following 11)-14).

[0045] 11) The remaining space in the disk space is less than a third threshold, that is, the remaining space in the disk space is insufficient.

[0046] Wherein, if the exception that occurs to the second user-mode process is that the remaining space in the disk space is less than the third threshold, then when the remaining space in the disk space is not less than the third threshold, it can be determined that no exception occurs or the exception is resolved for the second user-mode process.

[0047] In one embodiment, the third threshold may be less than the second threshold mentioned later. For example, in this embodiment, the third threshold may be 0, etc., and there is no limitation here.

[0048] 12) The second user-mode process cannot allocate disk space.

[0049] Wherein, if the exception that occurs to the second user-mode process is that the second user-mode process cannot allocate disk space, then when the disk space can be allocated, it can be determined that no exception occurs or the exception is resolved for the second user-mode process.

[0050] 13) The second user-mode process fails.

[0051] Wherein, if the exception that occurs to the second user-mode process is that the second user-mode process fails, then when the failure of the second user-mode process is repaired, it can be determined that no exception occurs or the exception is resolved for the second user-mode process.

[0052] 14) The disk device corresponding to the second user-mode process fails.

[0053] Wherein, if the exception that occurs to the second user-mode process is that the disk device corresponding to the second user-mode process fails, then when the failure of the disk device corresponding to the second user-mode process is repaired, it can be determined that no exception occurs or the exception is resolved for the second user-mode process.

[0054] In one embodiment, the aforementioned second user-mode process can reflect the exception content through an error code. Among them, the error code can be but is not limited to "EIO", "ENOMEM", etc.

[0055] In one embodiment, the manner in which the aforementioned second user-mode process notifies the kernel to use the asynchronous mode may include but is not limited to: dynamically notifying the kernel to use the asynchronous mode in the form of a message.

[0056] In this embodiment, the use of the asynchronous mode by the kernel may include, but is not limited to: the kernel remaining in the asynchronous mode, or the kernel switching from other modes other than the asynchronous mode to the asynchronous mode, which is not limited herein. Among them, the other modes may include, but are not limited to, the synchronous mode. In this embodiment, the synchronous mode can be understood as the write data process provided in the related art, that is, the synchronous mode includes: the kernel requests the second user-mode process to allocate disk space for the target data corresponding to the data write request, and when the second user-mode process successfully allocates the disk space and the kernel writes the target data into the kernel cache, notifies the first user-mode process that the data writing is successful.

[0057] In one embodiment, the situation where the other mode is the synchronous mode can be understood as: in this embodiment, on the basis of the write data process provided in the related art, the asynchronous mode is further added, so that the second user-mode process can control the kernel to use different write data processes according to different conditions to obtain the optimal write data performance under different conditions.

[0058] In this embodiment, as Figure 6 shown, for the use of the synchronous mode, the second user-mode process can notify the kernel to use the synchronous mode when it is determined that the second condition is met. Among them, the second condition includes at least one of the remaining space in the disk space being less than the second threshold and an exception occurring in the second user-mode process. Thus, through the setting of the second condition, when the disk space is insufficient or an exception occurs in the second user-mode process, the kernel can timely use the synchronous mode for the write data process to ensure the smooth execution of the subsequent write data process.

[0059] For example, when the kernel is in the asynchronous mode, considering that the kernel returns the data writing result to the first user-mode process after storing the target data in the kernel cache, and the second user-mode process asynchronously processes the task of allocating disk space, therefore, the target data written in the kernel cache may fill up the disk space, and the error message that the disk space is full cannot be truly returned to the first user-mode process or the user, resulting in an error in write(). In this regard, in this embodiment, by calculating the remaining space of the disk space, the second user-mode process can always sense the size of the kernel cache, and when the kernel cache is about to fill up the disk space, that is, when the remaining space in the disk space is less than the second threshold, the second user-mode process timely notifies the kernel to switch back to the synchronous mode, so that the second user-mode process can timely feedback abnormal problems such as insufficient disk space to the first user-mode process via the kernel, such as through the error code returned to the user's system call write() via the kernel, to prevent situations such as the kernel cache being written out.

[0060] In one embodiment, in addition to the kernel switching from the asynchronous mode to the synchronous mode, the aforementioned kernel using the synchronous mode may further include the kernel maintaining the synchronous mode.

[0061] In this embodiment, the method for determining the remaining space in the disk space and the situation where the second user-mode process encounters an exception may refer to the relevant descriptions in the foregoing determination of the remaining space in the disk space, and will not be elaborated herein.

[0062] In one embodiment, the design of the second threshold may refer to the total disk capacity, the upper limit of device memory, the IPC speed, etc. For example, in this embodiment, the second threshold may be 200 Mb to 500 Mb. In one embodiment, the aforementioned first threshold may be greater than the second threshold. Thus, it is possible to prevent a large number of "messages for the second user-mode process to notify the kernel of synchronous and asynchronous switching" from being generated due to frequent write and delete operations within the threshold range, wasting system resources. In this embodiment, the difference between the first threshold and the second threshold may be, but is not limited to, 40 Mb to 100 Mb.

[0063] In the technical solution provided by the embodiments of the present application, by optimizing the write data process provided in the related art, it is possible to reduce the interaction complexity between the kernel mode and the user mode. For example, before the feedback on the data write result is made, the kernel mode only needs to interact with the first user-mode process, improving the feedback efficiency of the kernel for the data write result and enhancing the user experience.

[0064] In addition, the embodiments of the present application also add an "asynchronous mode" interaction mode on the basis of the synchronous mode provided in the related art. For example, with the asynchronous mode as the main mode and the synchronous mode as the auxiliary mode, it can meet the data write requirements under different conditions and improve the flexibility of writing data.

[0065] Based on the foregoing method for writing data, for the sake of easy understanding, the implementation process thereof will be exemplarily described below with reference to examples.

[0066] Example 1 Assume that both the synchronous mode and the asynchronous mode are configured in the kernel. Then, the process for writing data provided in this embodiment may include, but is not limited to, the following steps.

[0067] (1) The second user-mode process determines the size of the remaining space in the disk space and determines whether the second user-mode process has an exception.

[0068] (2) As Figure 5As shown, when the second user-mode process determines that the remaining space in the disk space is greater than the first threshold and the second user-mode process has not encountered an exception or the exception has been resolved, the second user-mode process notifies the kernel to use the asynchronous mode, such as switching from the synchronous mode to the asynchronous mode.

[0069] Or, as Figure 6 shown, when the second user-mode process determines that the remaining space in the disk space is less than the second threshold and / or the second user-mode process encounters an exception, the second user-mode process notifies the kernel to use the synchronous mode, such as switching from the asynchronous mode to the synchronous mode.

[0070] (3) The first user-mode process uses the system call write(), and when the kernel captures write(), it performs the following operations.

[0071] Operation 1: If the kernel uses the asynchronous mode, then as Figure 5 shown, the kernel first writes the target data corresponding to write() into the kernel cache, then notifies the first user-mode process that the data has been successfully written, and finally sends a first notification to the second user-mode process to notify the second user-mode process to allocate disk space for the target data.

[0072] Operation 2: If the kernel uses the synchronous mode, then as Figure 6 shown, the kernel sends a message to the second user-mode process to request the second user-mode process to allocate disk space for the target data corresponding to write(). The second user-mode process returns the disk allocation result to the kernel. When the kernel determines that the second user-mode process has successfully allocated the disk space based on the disk allocation result, it writes the target data into the kernel cache, and then notifies the first user-mode process that the data has been successfully written; or, if the kernel determines that the second user-mode process has not successfully allocated disk space based on the disk allocation result, it indicates to the first user-mode process that the data write has failed.

[0073] (4) After the second user-mode process completes the disk space allocation described in (3) above, it performs (1)-(2) above again to determine whether a switch between the asynchronous mode and the synchronous mode is required to facilitate the execution of the data writing process during subsequent system calls to write().

[0074] In one embodiment, for the determination of the remaining space of the disk space described in the foregoing (1) or (4), if the second user-mode process determines that there is at least one second notification in the message pool when determining the remaining space of the disk space, then the second user-mode process can calculate the total disk space to be applied for by at least one second notification, and then determine the remaining space in the disk space according to the difference between the current remaining space in the disk space and the total disk space to be applied for by at least one second notification. Thereby, it is possible to avoid the problem that the second user-mode process cannot allocate disk space due to the total disk space to be applied for by this part of the second notifications in the message pool being greater than the remaining space of the disk space, ensuring the smooth progress of the subsequent data writing process.

[0075] In the foregoing data writing process provided in this Example 1, it may include, but is not limited to, those described in the foregoing (1)-(4), such as it may include more or fewer steps than the foregoing. In addition, the implementation processes described in the foregoing (1)-(4) may refer to the relevant descriptions in the foregoing Method Embodiment 200, and will not be elaborated herein.

[0076] The foregoing data writing solution provided in the embodiments of the present application can be applied to, but is not limited to, microkernel systems in fields such as automotive electronics and telecommunications equipment.

[0077] Figure 7 The schematic diagram of the hardware structure of the electronic device provided in the embodiments of the present application is shown. Referring to this figure, at the hardware level, the electronic device includes a processor, and optionally, an internal bus, a network interface, and a memory. Among them, the memory may include internal memory, such as high-speed random access memory (Random-Access Memory, RAM), and may also include non-volatile memory, such as at least one disk memory, etc. Of course, the electronic device may also include other hardware required for other services.

[0078] The processor, network interface, and memory can be interconnected through an internal bus, and this internal 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 the sake of convenience of representation, only a bidirectional arrow is used in this figure, but it does not mean that there is only one bus or one type of bus.

[0079] A memory for storing programs. Specifically, the program may include program code, and the program code includes computer operation instructions. The memory may include a memory and a non-volatile memory, and provide instructions and data to the processor.

[0080] The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a device for locating a specified user at the logical level. The processor executes the program stored in the memory and is specifically used to execute: Figure 2 The method disclosed in the illustrated embodiment implements the functions and beneficial effects of the various methods described in the foregoing method embodiments, which will not be elaborated herein.

[0081] The above as in this application Figure 2 The method disclosed in the illustrated embodiment as above can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the integrated logic circuit in the hardware of the processor or instructions in software form. The above processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. It can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The steps of the method disclosed in combination with the embodiments of this application can be directly embodied as being executed and completed by a hardware decoding processor, or executed and completed by a combination of the hardware and software modules in the decoding processor. The software module may be located in a mature storage medium in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. This storage medium is located in the memory, and the processor reads the information in the memory and combines its hardware to complete the steps of the above method.

[0082] The electronic device can also execute the various methods described in the foregoing method embodiments and implement the functions and beneficial effects of the various methods described in the foregoing method embodiments, which will not be elaborated herein.

[0083] Of course, in addition to the software implementation, the electronic device of the present application does not exclude other implementation manners, such as a logic device or a combination of software and hardware. That is to say, the execution subject of the following processing flow is not limited to each logic unit, and may also be hardware or a logic device.

[0084] An embodiment of the present application also provides a computer-readable storage medium storing one or more programs, which, when executed by an electronic device including a plurality of application programs, cause the electronic device to execute Figure 2 the methods disclosed in the illustrated embodiments and achieve the functions and beneficial effects of the methods described in the foregoing method embodiments, which will not be elaborated herein.

[0085] The computer-readable storage medium includes a read-only memory (ROM for short), a random access memory (RAM for short), a magnetic disk, an optical disc, or the like.

[0086] An embodiment of the present application also provides a computer program product including a computer program stored on a non-transitory computer-readable storage medium, the computer program including program instructions, which, when executed by a computer, implement the following process: Figure 2 the methods disclosed in the illustrated embodiments and achieve the functions and beneficial effects of the methods described in the foregoing method embodiments, which will not be elaborated herein.

[0087] The computer-readable storage medium includes permanent and non-permanent, removable and non-removable media, which can store information by any method or technology. The information may be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette tapes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission media that can be used to store information accessible by a computing device. As defined herein, computer-readable storage media does not include transitory computer-readable media such as modulated data signals and carrier waves.

[0088] In summary, the above are only the preferred embodiments of the present application and are not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included within the protection scope of the present application.

[0089] The systems, devices, modules or units illustrated in the above embodiments may be specifically implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or any combination of these devices.

[0090] It should also be noted that the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, such that a process, method, commodity or device comprising a series of elements not only includes those elements but also other elements not expressly listed, or elements inherent to such process, method, commodity or device. Without further limitation, an element defined by the statement "comprising one..." does not exclude the existence of additional identical elements in the process, method, commodity or device comprising the said element.

[0091] Each embodiment in this specification is described in a progressive manner, and the same or similar parts among the embodiments can be referred to each other. Each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the description of the method embodiment.

Claims

1. A method for writing data, characterized in that, Including: The kernel receives a data write request sent by a first user-mode process; The kernel writes the target data corresponding to the data write request into the kernel cache; The kernel notifies the first user-mode process that the data writing is successful; The kernel notifies the second user-mode process to allocate disk space for the target data.

2. The method according to claim 1, characterized in that The method further includes: When determining that a first condition is satisfied, the second user-mode process notifies the kernel to use the asynchronous mode; Wherein, the first condition includes: the remaining space in the disk space is greater than a first threshold, and the second user-mode process has not had an exception or the exception has been resolved; The asynchronous mode includes: the kernel first writes the target data corresponding to the data write request into the kernel cache, then notifies the first user-mode process that the data writing is successful, and notifies the second user-mode process to allocate disk space for the target data.

3. The method according to any one of claims 1-2, characterized in that, The method further includes: When determining that a second condition is satisfied, the second user-mode process notifies the kernel to use the synchronous mode; Wherein, the second condition includes at least one of the following: The remaining space in the disk space is less than a second threshold; An exception occurs in the second user-mode process; The synchronous mode includes: the kernel requests the second user-mode process to allocate disk space for the target data corresponding to the data write request, and when the second user-mode process successfully allocates the disk space, the kernel writes the target data into the kernel cache and notifies the first user-mode process that the data writing is successful.

4. The method according to claim 3, wherein The first threshold is greater than the second threshold.

5. The method according to claim 2 or 3, characterized in that, The determining method for the remaining space in the disk space includes: The second user-mode process performs disk space allocation according to a first notification received, where the first notification is for the kernel to apply for the disk space; After completing the disk space allocation, the second user-mode process determines the remaining space in the disk space.

6. The method according to claim 2 or 3, characterized in that, The determining method for the remaining space in the disk space includes: When the second user-mode process determines that there is at least one second notification cached currently, it preprocesses the at least one second notification to obtain the total sum of the disk space to be applied for by the at least one second notification; The second user-mode process determines the remaining space in the disk space according to the difference between the current remaining space in the disk space and the total sum of the disk space to be applied for by the at least one second notification; Wherein, the second notification is a notification for the kernel to apply for disk space and has not been processed by the second user-mode process yet.

7. The method according to claim 2 or 3, characterized in that, The size of the remaining space in the disk space is also related to at least one of a file creation operation, a file truncation operation, and a file deletion operation.

8. The method according to claim 3, wherein An exception occurs in the second user-mode process, including at least one of the following: The remaining space in the disk space is less than a third threshold; The second user-mode process cannot allocate disk space; The second user-mode process fails; The disk device corresponding to the second user-mode process fails.

9. An electronic device, characterized in that, It includes a memory, a processor, and a computer program stored on the memory and executable on the processor. When the computer program is executed by the processor, it implements the steps of the method according to any one of claims 1-8.

10. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium. When the computer program is executed by the processor, it implements the steps of the method according to any one of claims 1-8.