Disk data reading method and device

By detecting and supplementing disk data in application-level buffers, the problem of insufficient convenience of disk file reading failure is solved, and efficient and secure disk data reading is achieved, which simplifies the operation process and reduces system resource consumption.

CN119200956APending Publication Date: 2024-12-27BEIYIN FINANCIAL TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411014261.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-26
Publication Date
2024-12-27

AI Technical Summary

Technical Problem

In the prior art, when disk file reading fails, the solution is insufficient, and users need to understand the hard disk interface information or analyze complex return values, which increases labor costs and system resource consumption.

Method used

By detecting the amount of unprocessed data in the application-level buffer, the disk data reading operation is automatically performed to supplement insufficient data until the specified amount is reached, and appropriate processing is performed when the system is blocked or file errors are made, simplifying the disk data reading process .

Benefits of technology

It improves the convenience and security of disk data reading, reduces system resource usage, improves reading efficiency, and avoids complex underlying code and interface analysis operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119200956A_ABST
    Figure CN119200956A_ABST
Patent Text Reader

Abstract

The invention provides a disk data reading method and device. The method comprises the steps of obtaining a data reading request of an application program for a target file; detecting whether unprocessed data cached for the target file in an application level buffer area reaches a specified data volume, the specified data volume being a data reading amount of a single reading operation in multiple reading operations required for reading the target file; under the condition that the unprocessed data does not reach the specified data volume, executing disk data reading operation for the data reading request; and under the condition that the unprocessed data reaches the specified data volume, selecting the unprocessed data of the specified data volume from the application level buffer area and transferring the selected unprocessed data to a user buffer area, so that the application program obtains the unprocessed data of the specified data volume from the user buffer area. According to the technical scheme, the calling frequency of the disk reading operation on the system resources is reduced, and meanwhile, the efficiency of the disk reading operation is also improved.
Need to check novelty before this filing date? Find Prior Art

Description

[Technical field]

[0001] The present application relates to the technical field of data storage, and in particular to a disk data reading method and device. [Background technology]

[0002] During the operation of user processes, data often needs to be read from disk files as input for the application. At the same time, the operating system needs to store the core information of the application persistently in the disk file to support the subsequent scheduling of the application by the operating system and the state recovery behavior when the application fails. During the data reading process, the application does not read the file from beginning to end at one time, but instead reads the file by splitting it into multiple small data fragments. On this basis, during the file reading process, it is very likely that the reading will fail due to system interruption, or the EOF condition will be triggered due to the detection of the end of the file, resulting in insufficient value in the reading operation, which will affect the reliability of data reading.

[0003] In this regard, various data reading methods have been proposed in the relevant technologies to alleviate the disadvantages caused by this problem.

[0004] Among them, the inline assembly method can be used for file reading. Specifically, the metadata of the file in the file system installed on the disk can be determined based on the disk port information provided by the disk controller manufacturer, and a program that directly accesses the hardware port can be embedded in the C program to directly read the disk data into the memory, thereby avoiding the problem of disk file reading failure caused by system interruption. However, this method requires the user to fully understand the interface information published by the hard disk used in the computer system, and requires the user to be able to select a suitable port to access the disk file based on the interface information, which consumes high labor costs. In addition, this method is not sensitive to the situation where the read operation is insufficient, and it is necessary to add additional code judgment for the situation where the read operation is insufficient, and the introduction of multiple codes will increase the security risks of the system itself.

[0005] In addition, the related art also points out that the unified system call function provided by the syscall system can be used to read disk data. This system call function is implemented for all soft interrupt objects in the operating system, and is compatible with different data reading failure problems. However, the unified system call function uses a unified interface to return the return values ​​of all interrupts. The various return values ​​contain rich and varied contents. For read operations, it is necessary to analyze the cause of the data reading failure problem based on the complex return values. This process involves a lot of analysis and consumes too much system resources.

[0006] Therefore, how to deal with problems that arise during the disk file reading process more safely and effectively has become a technical problem that needs to be solved urgently. [Summary of the invention]

[0007] The embodiments of the present application provide a disk data reading method and device, aiming to solve the technical problem that the solution to the disk file reading failure problem in the related art is not convenient enough.

[0008] In a first aspect, an embodiment of the present application provides a method for reading disk data, comprising:

[0009] Get the data reading request of the application for the target file;

[0010] Detecting whether the unprocessed data cached for the target file in the application-level buffer reaches a specified data amount, wherein the specified data amount refers to a data read amount of a single read operation among multiple read operations required to read the target file;

[0011] In a case where the unprocessed data does not reach the specified data amount, performing a disk data read operation for the data read request, wherein the disk data read operation is used to read a portion of the target file other than the unprocessed data from a disk;

[0012] When the unprocessed data reaches the specified data amount, the unprocessed data of the specified data amount is selected in the application-level buffer and transferred to the user buffer, so that the application obtains the unprocessed data of the specified data amount in the user buffer.

[0013] In one embodiment of the present application, optionally, before obtaining the data reading request of the application program for the target file, the method further includes:

[0014] The application-level buffer is established in the user-mode address space where the user process is located, wherein:

[0015] A counter for counting unprocessed data in the application-level buffer is set for the application-level buffer, and an address pointer for indicating a disk access position where the unprocessed data is located is set for the application-level buffer.

[0016] In one embodiment of the present application, optionally, after selecting the specified amount of unprocessed data in the application-level buffer to be transferred to the user buffer, the method further includes:

[0017] The counter and the address pointer of the application-level buffer are updated.

[0018] In one embodiment of the present application, optionally, after performing a disk data read operation for the data read request, the method further includes:

[0019] Obtaining the return result of executing the disk data reading operation;

[0020] If the returned result is that the disk data is read successfully, the process returns to the step of detecting whether the unprocessed data cached for the target file in the application-level buffer reaches the specified data amount, and stops the disk data reading operation until the unprocessed data reaches the specified data amount.

[0021] In one embodiment of the present application, optionally, the method further includes:

[0022] If the returned result is that the disk data read fails due to system congestion, the step of executing the disk data read operation for the data read request is returned until the disk data read succeeds or the number of executions of the disk data read operation reaches a preset upper limit.

[0023] In one embodiment of the present application, optionally, the method further includes:

[0024] If the returned result is that the disk data reading fails due to a disk file error, the disk data reading process is terminated and data reading failure information is returned to the application.

[0025] In one embodiment of the present application, optionally, the method further includes:

[0026] If the returned result is that the disk data reading fails due to a disk file error, detecting whether there is replacement data having the same data characteristics as the read target of the disk data reading operation in the disk targeted by the data reading request, wherein the data characteristics include data body, data content and data confidence;

[0027] If the replacement data exists in the disk, the replacement data and preset replacement prompt information are returned to the application.

[0028] In a second aspect, an embodiment of the present application provides a disk data reading device, comprising:

[0029] A data read request acquisition unit, used to acquire a data read request from an application program for a target file;

[0030] a data volume detection unit, configured to detect whether the unprocessed data cached for the target file in the application-level buffer has reached a specified data volume, wherein the specified data volume refers to a data read volume of a single read operation among multiple read operations required to read the target file;

[0031] A first processing unit is configured to, if the unprocessed data does not reach the specified data amount, perform a disk data reading operation for the data reading request, wherein the disk data reading operation is used to read a portion of the target file other than the unprocessed data from the disk;

[0032] The second processing unit is used for selecting the unprocessed data of the specified data amount in the application-level buffer and transferring it to the user buffer when the unprocessed data reaches the specified data amount, so that the application can obtain the unprocessed data of the specified data amount in the user buffer.

[0033] In one embodiment of the present application, optionally, the device further includes:

[0034] An application-level buffer establishment unit is used to establish the application-level buffer in the user-mode address space where the user process is located before obtaining a data read request from an application program for a target file, wherein a counter for counting unprocessed data in the application-level buffer is set for the application-level buffer, and an address pointer for indicating a disk access location where the unprocessed data is located is set for the application-level buffer.

[0035] In one embodiment of the present application, optionally, the device further includes:

[0036] The information updating unit is used to update the counter and the address pointer of the application-level buffer after selecting the specified amount of unprocessed data in the application-level buffer to be transferred to the user buffer.

[0037] In one embodiment of the present application, optionally, the device further includes:

[0038] A return result obtaining unit, used for obtaining a return result of executing the disk data reading operation after executing the disk data reading operation for the data reading request;

[0039] The first execution unit is used to return to the step of detecting whether the unprocessed data cached for the target file in the application-level buffer reaches a specified data amount if the returned result is that the disk data is read successfully, and stop the disk data reading operation until the unprocessed data reaches the specified data amount.

[0040] In one embodiment of the present application, optionally, the device further includes:

[0041] The second execution unit is used to return to the step of executing the disk data reading operation for the data reading request if the returned result is that the disk data reading fails due to system congestion, until the disk data is read successfully or the number of times the disk data reading operation is executed reaches a preset upper limit.

[0042] In one embodiment of the present application, optionally, the device further includes:

[0043] The third execution unit is used to terminate the disk data reading process and return data reading failure information to the application if the returned result is that the disk data reading fails due to a disk file error.

[0044] In one embodiment of the present application, optionally, the device further includes:

[0045] The fourth execution unit is used to detect whether there is replacement data with the same data characteristics as the read target of the disk data read operation in the disk targeted by the data read request, if the returned result is that the disk data read fails due to a disk file error, wherein the data characteristics include data body, data content and data confidence; if the replacement data exists in the disk, return the replacement data and preset replacement prompt information to the application.

[0046] In a third aspect, an embodiment of the present application provides a computer device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are configured to execute the method described in the first aspect above.

[0047] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are used to execute the method described in the first aspect above.

[0048] The above technical solution aims at the technical problem that the solution to the problem of disk file reading failure in the related art is not convenient enough. When the application has a reading demand for the target file on the disk, for the single segment reading in the multiple segment readings of the target file, the application-level buffer is respectively judged whether the reading content is sufficient. In other words, it is judged whether the single segment reading can be carried out smoothly. And when the reading content of the single segment reading is insufficient, the disk reading can be automatically started to supplement the reading content of the single segment reading, so as to fully ensure the smooth progress of the process of the application reading the disk data. Compared with the prior art, this method does not require a large amount of additional underlying code, nor does it require the user to understand the interface information released by the hard disk or analyze the return value and other complicated operations, which greatly simplifies the process of smooth disk data reading, improves the convenience of data reading while improving the security of data reading. In addition, the single segment reading and the disk data supplementary reading operation involved in the process are relatively simple, occupying only a small amount of system resources, thereby reducing the occupation of system resources by the disk reading operation, and also improving the efficiency of the disk reading operation.

Brief Description of the Drawings

[0049] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0050] Figure 1 A flowchart of a disk data reading method according to an embodiment of the present application is shown;

[0051] Figure 2 A flow chart of a disk data reading method according to another embodiment of the present application is shown;

[0052] Figure 3 A block diagram of a computer device according to an embodiment of the present application is shown;

[0053] Figure 4 A block diagram of a computer device according to another embodiment of the present application is shown. [Specific implementation method]

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

[0055] Figure 1 A flow chart of a disk data reading method according to an embodiment of the present application is shown.

[0056] like Figure 1 As shown, a disk data reading method according to an embodiment of the present application includes:

[0057] Step 102: Obtain a data read request from an application program for a target file.

[0058] During the running of user processes, data often needs to be read from disk files as input for the application. At the same time, the operating system needs to store the core information of the application persistently in disk files to support the subsequent scheduling of the application by the operating system and the state recovery behavior when the application fails. In all the above situations, the application needs to read files from the disk.

[0059] Among them, the target file refers to the file located on the disk that has an effect on the application, including but not limited to the files required to call for the basic operation of the application, the files required to call for the application to perform internal functions, the files required for the system to schedule the application, the files required to recover the application when an error occurs, and any other files associated with the application.

[0060] Therefore, when an application has a demand for a target file in a disk, the application generates a data read request for the target file, and calls a function of reading disk data in the system through the data read request.

[0061] Step 104 , detecting whether the unprocessed data cached for the target file in the application-level buffer has reached a specified data amount.

[0062] The specified data volume refers to the data read volume of a single read operation among multiple read operations required to read the target file.

[0063] Specifically, the application does not read the file from beginning to end at one time, but rather reads the file by splitting it into multiple small-data-volume segments.

[0064] In a possible design, the amount of data read each time can be set to a specified amount of data.

[0065] In another possible design, the minimum data amount read each time may be set to a specified data amount.

[0066] In this way, if it is detected that the unprocessed data cached for the target file in the application-level buffer reaches the specified data amount, it means that the unprocessed data is sufficient for a fragment read. Conversely, if it is detected that the unprocessed data cached for the target file in the application-level buffer does not reach the specified data amount, it means that the unprocessed data is not enough for a fragment read.

[0067] Step 106: When the unprocessed data does not reach the specified data amount, perform a disk data read operation for the data read request, wherein the disk data read operation is used to read a portion of the target file other than the unprocessed data from the disk.

[0068] If the unprocessed data is not enough for a single segment read, the disk data read operation can be continued to read the portion of the target file other than the unprocessed data from the disk to make up for the amount required for a single segment read.

[0069] On this basis, optionally, after executing the disk data read operation for the data read request, it also includes: obtaining the return result of executing the disk data read operation; if the return result is that the disk data read is successful, returning to the step of detecting whether the unprocessed data cached for the target file in the application-level buffer reaches the specified data amount, and stopping the disk data read operation until the unprocessed data reaches the specified data amount.

[0070] Optionally, the difference in data volume between the unprocessed data in the application-level buffer and the specified data volume can be determined, and when performing a disk data read operation, only the data volume of the difference is read from the portion of the target file on the disk other than the unprocessed data, so that the unprocessed data in the application-level buffer is sufficient for the current single fragment read.

[0071] Optionally, the data volume read in a single segment may be set to the specified data volume. Of course, the data volume read in a single segment may also be any other data volume other than the specified data volume that meets the actual data reading requirements.

[0072] Step 108, when the unprocessed data reaches the specified data amount, select the specified data amount of unprocessed data in the application-level buffer and transfer it to the user buffer, so that the application obtains the specified data amount of unprocessed data in the user buffer.

[0073] If the unprocessed data is sufficient for a fragment read, data of the specified data size may be directly selected from the unprocessed data and transferred to the user buffer for use by the application.

[0074] In the above technical solution, when the application has a read demand for the target file on the disk, for a single segment read in the multiple segment reads of the target file, a judgment is made in the application-level buffer whether the read content is sufficient. In other words, it is judged whether the single segment read can be carried out smoothly. And when the read content of the single segment read is insufficient, the disk read can be automatically started to supplement the read content of the single segment read, fully ensuring the smooth progress of the process of the application reading the disk data. Compared with the prior art, this method does not require a large amount of additional underlying code, nor does it require the user to understand the interface information released by the hard disk or analyze the return value and other complicated operations. It greatly simplifies the process of smooth disk data reading, improves the convenience of data reading while improving the security of data reading. In addition, the single segment read and the disk data supplementary reading operation involved are relatively simple processes and only occupy a small amount of system resources. Therefore, the occupation of system resources by the disk read operation is reduced, and the efficiency of the disk read operation is also improved.

[0075] In a possible design, before step 102, the application-level buffer may be established in the user-mode address space where the user process is located, so as to facilitate the application program to temporarily store the data of the target file on the disk in the application-level buffer.

[0076] A counter for counting unprocessed data in the application-level buffer is set for the application-level buffer, and an address pointer for indicating a disk access position where the unprocessed data is located is set for the application-level buffer.

[0077] On this basis, after the specified amount of unprocessed data is selected in the application-level buffer and transferred to the user buffer, since the amount of data in the application-level buffer has changed and the data content has also changed, the counter and the address pointer of the application-level buffer can be updated. Specifically, updating the address pointer means deleting the address pointer of the data that has been transferred to the user buffer and adding the address pointer of the data newly read from the disk.

[0078] After executing the disk data read operation for the data read request in step 106, if the returned result is that the disk data read fails due to system congestion, return to the step of executing the disk data read operation for the data read request until the disk data is read successfully or the number of executions of the disk data read operation reaches a preset upper limit.

[0079] That is to say, if the disk data reading fails due to system congestion, since the system congestion is generally temporary, the disk data reading operation steps can be repeated so that the required disk data can be successfully read after the system congestion is resolved. Of course, in order to save system resources, a preset upper limit can be set as the maximum number of times the disk data reading operation can be repeatedly executed. Once the number of times the disk data reading operation is repeatedly executed reaches the preset upper limit, the disk data reading operation is stopped.

[0080] After the disk data reading operation is performed for the data reading request in step 106, if the returned result is that the disk data reading fails due to a disk file error, the disk data reading process is terminated and data reading failure information is returned to the application. In the case where the disk data reading fails due to a disk file error, since the disk file error generally cannot be automatically repaired by the system, the reading failure message can be directly returned to end the reading process.

[0081] After executing the disk data read operation for the data read request in step 106, if the returned result is that the disk data read fails due to a disk file error, it is detected whether there is replacement data with the same data characteristics as the read target of the disk data read operation in the disk targeted by the data read request; if the replacement data exists in the disk, the replacement data and preset replacement prompt information are returned to the application.

[0082] The data features include data subject, data content and data confidence, where data subject refers to the operating subject and the subject of the data, data content refers to the specific operation content corresponding to the data, and data confidence refers to the quotient of the integrity of the data and the proportion of the deviation value in the data. It can be seen that data features reflect the essential content and reliability of the data. If the data subject, data content and data confidence of two sets of data are consistent, it means that the two have sufficient reliability to be used as replacements for the same content.

[0083] On this basis, if the disk has replacement data for the read target of this disk data read operation, then in the case of failure to read the read target, the replacement data can be returned to the application-level buffer as the read result. This improves the success rate of data reading and avoids the failure of data acquisition required for a single segment read affecting the overall reading effect of the target file by the application.

[0084] Figure 2 A flow chart of a disk data reading method according to another embodiment of the present application is shown.

[0085] like Figure 2 As shown, first, a static buffer and a pointer are initialized. The static buffer mentioned here is an application-level buffer, and the pointer is an address pointer.

[0086] Next, when a request to read data from a target file on the disk is received, it is checked whether the partial data of the target file already in the static buffer is sufficient for a single segment read.

[0087] If sufficient, the data is directly read from the static buffer. Further, if the number of bytes of the read data reaches the required number of bytes in the request to read the data, the read data is returned to the application program that issued the request to read the data.

[0088] If it is not enough, read the disk data into the static buffer through the descriptor. If the read fails due to EINTR (blocking), return to the step of reading data from the static buffer to read here so that the disk data can be successfully read after the blocking ends. On the contrary, if the read fails due to non-EINTR, first determine whether some data has been read. If some data has been read into the static buffer, update the pointer and data counter in the static buffer, and enter the step of checking whether the partial data of the target file already in the static buffer is sufficient for a single fragment read. If no data is read into the static buffer, return EOF or an error to the application that requested to read the data.

[0089] In fact, there is always a need to access disk files during the running of an application. This access may be to access external data files as input, process the data in the file, or load other executable files on the disk. The length of the file accessed each time is unpredictable. Most files have a large number of bytes, which makes it impossible for the application to load all the contents of the file into the physical memory shared by the process and the operating system in one read. When the application runs, it seems to scan the entire file, but in fact it is achieved by loading a small amount of file content multiple times. When loading a file once, it is possible that the read size is not as expected. At the same time, the execution of the program may be interrupted by other system interrupts and returned as an execution error. Every time such a situation occurs, it needs to be judged to make the execution flow run more logically.

[0090] In this regard, the present application automatically processes when insufficient file values ​​are read in a file read operation, so that the read return caused by the interrupt processing in the file reading process can be logically ignored, and the read operation can continue at the correct position of the file. For situations where file data processing may require multiple reads of files with small amounts of data, the present application uses cache technology to reduce system calls, so that fewer context switches can improve the application's utilization of processor time slices.

[0091] Specifically, the present application uses a buffered file reading method, which can automatically handle insufficient read data and system interruptions using the buffer. Specifically, an application-level static buffer is used to temporarily store data, and the application-level static buffer is used as much as possible in each read operation. When the application-level static buffer is empty or the amount of data is insufficient to satisfy a single fragment read, the read operation process will re-call the Unix system read function to fill the application-level static buffer and handle possible system interruptions.

[0092] In a possible design, an embodiment of the present application includes the following steps:

[0093] Step 1: Initialize an application-level static buffer in the user-mode address space. This application-level static buffer is used as a temporary storage space for each system call data. At the same time, it is necessary to maintain the relevant address pointer and the available data counter in the cache for this application-level static buffer.

[0094] Step 2: When the application requests to read data, the application-level static buffer is first checked to determine whether there is enough unprocessed data for a single fragment read in the application-level static buffer.

[0095] Step 3: When the counter in the application-level static buffer is empty or less than the specified amount of data, call the read function in Unix to try to read more data from the disk file pointed to by the file descriptor into the application-level static buffer.

[0096] Step 4: If the read operation returns a return value indicating a failure, check whether the return value is the errno value set by the system. If so, it means that the read operation failed due to a system interrupt handler. In this case, call the read function again until the read succeeds or another error is encountered.

[0097] Step 5: Copy the data in the application-level static buffer to the buffer provided by the user, and update the pointer and counter in the application-level static buffer to maintain the state of the application-level static buffer.

[0098] In addition, when disk data is read successfully, the number of bytes actually read is returned.

[0099] It should be added that the above technical solution can be implemented based on the existing Unix I / O system read function, and its independent application-level static buffer is only used for read operations. With the support of the application-level static buffer, the number of system calls required to read data can be effectively reduced, and the utilization rate of process time slices can be improved.

[0100] The present application provides a disk data reading device, comprising:

[0101] A data read request acquisition unit, used to acquire a data read request from an application program for a target file;

[0102] a data volume detection unit, configured to detect whether the unprocessed data cached for the target file in the application-level buffer has reached a specified data volume, wherein the specified data volume refers to a data read volume of a single read operation among multiple read operations required to read the target file;

[0103] A first processing unit is configured to, if the unprocessed data does not reach the specified data amount, perform a disk data reading operation for the data reading request, wherein the disk data reading operation is used to read a portion of the target file other than the unprocessed data from the disk;

[0104] The second processing unit is used for selecting the unprocessed data of the specified data amount in the application-level buffer and transferring it to the user buffer when the unprocessed data reaches the specified data amount, so that the application can obtain the unprocessed data of the specified data amount in the user buffer.

[0105] In one embodiment of the present application, optionally, the device further includes:

[0106] An application-level buffer establishment unit is used to establish the application-level buffer in the user-mode address space where the user process is located before obtaining a data read request from an application program for a target file, wherein a counter for counting unprocessed data in the application-level buffer is set for the application-level buffer, and an address pointer for indicating a disk access location where the unprocessed data is located is set for the application-level buffer.

[0107] In one embodiment of the present application, optionally, the device further includes:

[0108] The information updating unit is used to update the counter and the address pointer of the application-level buffer after selecting the specified amount of unprocessed data in the application-level buffer to be transferred to the user buffer.

[0109] In one embodiment of the present application, optionally, the device further includes:

[0110] A return result obtaining unit, used for obtaining a return result of executing the disk data reading operation after executing the disk data reading operation for the data reading request;

[0111] The first execution unit is used to return to the step of detecting whether the unprocessed data cached for the target file in the application-level buffer reaches a specified data amount if the returned result is that the disk data is read successfully, and stop the disk data reading operation until the unprocessed data reaches the specified data amount.

[0112] In one embodiment of the present application, optionally, the device further includes:

[0113] The second execution unit is used to return to the step of executing the disk data reading operation for the data reading request if the returned result is that the disk data reading fails due to system congestion, until the disk data is read successfully or the number of times the disk data reading operation is executed reaches a preset upper limit.

[0114] In one embodiment of the present application, optionally, the device further includes:

[0115] The third execution unit is used to terminate the disk data reading process and return data reading failure information to the application if the returned result is that the disk data reading fails due to a disk file error.

[0116] In one embodiment of the present application, optionally, the device further includes:

[0117] The fourth execution unit is used to detect whether there is replacement data with the same data characteristics as the read target of the disk data read operation in the disk targeted by the data read request, if the returned result is that the disk data read fails due to a disk file error, wherein the data characteristics include data body, data content and data confidence; if the replacement data exists in the disk, return the replacement data and preset replacement prompt information to the application.

[0118] The disk data reading device uses any one of the solutions in the above embodiments, and therefore has all the above technical effects, which will not be repeated here.

[0119] In addition, in one embodiment, the present application provides a computer device, which may be a server, and its internal structure diagram may be as follows: Figure 3 As shown. The computer device includes a processor, a memory, a network interface and a database connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile and / or volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external client via a network connection. When the computer program is executed by the processor, the method described in any of the above embodiments can be implemented.

[0120] In one embodiment, the present application further provides a computer device, which may be a client, and its internal structure diagram may be as follows: Figure 4As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external server via a network connection. When the computer program is executed by the processor, the method described in any of the above embodiments can be implemented.

[0121] Any of the above-mentioned computer devices in the embodiments of the present application may exist in various forms, including but not limited to:

[0122] (1) Mobile communication devices: These devices are characterized by their mobile communication functions and their main purpose is to provide voice and data communications. These terminals include: smart phones (such as iPhone), multimedia phones, functional phones, and low-end phones.

[0123] (2) Ultra-mobile personal computer devices: These devices fall into the category of personal computers, have computing and processing capabilities, and generally also have mobile Internet access features. These terminals include: PDA, MID and UMPC devices, such as iPad.

[0124] (3) Portable entertainment devices: These devices can display and play multimedia content. They include audio and video players (such as iPods), handheld game consoles, e-books, as well as smart toys, wearable devices, and portable car navigation devices.

[0125] (4) Server: A device that provides computing services. The server consists of a processor, hard disk, memory, system bus, etc. The server is similar to a general computer architecture, but because it needs to provide highly reliable services, it has higher requirements in terms of processing power, stability, reliability, security, scalability, and manageability.

[0126] (5) Other electronic devices with data interaction functions.

[0127] In addition, an embodiment of the present application provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are used to perform the following steps:

[0128] Get the data reading request of the application for the target file;

[0129] Detecting whether the unprocessed data cached for the target file in the application-level buffer reaches a specified data amount, wherein the specified data amount refers to a data read amount of a single read operation among multiple read operations required to read the target file;

[0130] In a case where the unprocessed data does not reach the specified data amount, performing a disk data read operation for the data read request, wherein the disk data read operation is used to read a portion of the target file other than the unprocessed data from a disk;

[0131] When the unprocessed data reaches the specified data amount, the unprocessed data of the specified data amount is selected in the application-level buffer and transferred to the user buffer, so that the application obtains the unprocessed data of the specified data amount in the user buffer.

[0132] It should be noted that the above functions or steps that can be implemented by the computer-readable storage medium or computer device can refer to the relevant description in the aforementioned method embodiment. In order to avoid repetition, they will not be described one by one here.

[0133] The technical solution of the present application is described in detail above in combination with the accompanying drawings. Through the technical solution of the present application, when the application has a read demand for the target file on the disk, for a single segment read in multiple segment reads of the target file, a judgment is made in the application-level buffer whether the read content is sufficient. In other words, a judgment is made whether the single segment read can be carried out smoothly. And when the read content of the single segment read is insufficient, the disk read can be automatically started to supplement the read content of the single segment read, fully ensuring the smooth progress of the process of the application reading the disk data. Compared with the prior art, this method does not require a large amount of additional underlying code, nor does it require the user to understand the interface information released by the hard disk or analyze the return value and other complicated operations, which greatly simplifies the process of smooth disk data reading, improves the convenience of data reading while improving the security of data reading. In addition, the single segment read and the disk data supplementary reading operation involved in the process are relatively simple and only occupy a small amount of system resources, thereby reducing the occupation of system resources by the disk read operation and improving the efficiency of the disk read operation.

[0134] The word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrases "if it is determined" or "if (stated condition or event) is detected" may be interpreted as "when it is determined" or "in response to determining" or "when detecting (stated condition or event)" or "in response to detecting (stated condition or event)", depending on the context.

[0135] The terms used in the embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit the present application. The singular forms "a", "said" and "the" used in the embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings.

[0136] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0137] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0138] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0139] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.

Claims

1. A disk data reading method, characterized in that: include: Get the data reading request of the application for the target file; Detecting whether the unprocessed data cached for the target file in the application-level buffer reaches a specified data amount, wherein the specified data amount refers to a data read amount of a single read operation among multiple read operations required to read the target file; In a case where the unprocessed data does not reach the specified data amount, performing a disk data read operation for the data read request, wherein the disk data read operation is used to read a portion of the target file other than the unprocessed data from a disk; When the unprocessed data reaches the specified data amount, the unprocessed data of the specified data amount is selected in the application-level buffer and transferred to the user buffer, so that the application obtains the unprocessed data of the specified data amount in the user buffer.

2. The disk data reading method according to claim 1, characterized in that: Before obtaining the data reading request of the application program for the target file, the method further includes: The application-level buffer is established in the user-mode address space where the user process is located, wherein: A counter for counting unprocessed data in the application-level buffer is set for the application-level buffer, and an address pointer for indicating a disk access position where the unprocessed data is located is set for the application-level buffer.

3. The disk data reading method according to claim 2, characterized in that: After selecting the specified amount of unprocessed data in the application-level buffer and transferring it to the user buffer, the method further includes: The counter and the address pointer of the application-level buffer are updated.

4. The disk data reading method according to any one of claims 1 to 3, characterized in that: After performing the disk data reading operation for the data reading request, the method further includes: Obtaining the return result of executing the disk data reading operation; If the returned result is that the disk data is read successfully, the process returns to the step of detecting whether the unprocessed data cached for the target file in the application-level buffer reaches the specified data amount, and stops the disk data reading operation until the unprocessed data reaches the specified data amount.

5. The disk data reading method according to claim 4, characterized in that: Also includes: If the returned result is that the disk data read fails due to system congestion, the step of executing the disk data read operation for the data read request is returned until the disk data read succeeds or the number of executions of the disk data read operation reaches a preset upper limit.

6. The disk data reading method according to claim 4, characterized in that: Also includes: If the returned result is that the disk data reading fails due to a disk file error, the disk data reading process is terminated and data reading failure information is returned to the application.

7. The disk data reading method according to claim 4, characterized in that: Also includes: If the returned result is that the disk data reading fails due to a disk file error, detecting whether there is replacement data having the same data characteristics as the read target of the disk data reading operation in the disk targeted by the data reading request, wherein the data characteristics include data body, data content and data confidence; If the replacement data exists in the disk, the replacement data and preset replacement prompt information are returned to the application.

8. A disk data reading device, characterized in that: include: A data read request acquisition unit, used to acquire a data read request from an application program for a target file; a data volume detection unit, configured to detect whether the unprocessed data cached for the target file in the application-level buffer has reached a specified data volume, wherein the specified data volume refers to a data read volume of a single read operation among multiple read operations required to read the target file; A first processing unit is configured to, if the unprocessed data does not reach the specified data amount, perform a disk data reading operation for the data reading request, wherein the disk data reading operation is used to read a portion of the target file other than the unprocessed data from the disk; The second processing unit is used for selecting the unprocessed data of the specified data amount in the application-level buffer and transferring it to the user buffer when the unprocessed data reaches the specified data amount, so that the application can obtain the unprocessed data of the specified data amount in the user buffer.

9. A computer device, characterized in that: include: at least one processor; and, a memory communicatively coupled to the at least one processor; The memory stores instructions executable by the at least one processor, wherein the instructions are configured to execute the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: Computer executable instructions are stored, and the computer executable instructions are used to execute the method according to any one of claims 1 to 7.