File granularity data reading method and device, electronic equipment and medium

By judging the integrity measurement of the page cache before reading the file, the reading result is fed back only after N data blocks pass the measurement, which solves the time-consuming problem of the IMA mechanism and realizes fast and secure file reading.

CN115033928BActive Publication Date: 2025-10-17ZEBRED NETWORK TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210764736.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-01
Publication Date
2025-10-17
Estimated Expiration
2042-07-01

AI Technical Summary

Technical Problem

When the existing IMA mechanism measures the integrity of large read-only files, it takes a lot of time to calculate the data digests of all data blocks of the file, which affects the startup speed or application startup.

Method used

By obtaining read requests, it determines whether the page cache of each data block in the file exists and meets the integrity measurement. The read result is fed back only after N data blocks have passed the integrity measurement, reducing the amount of calculation and improving efficiency.

Benefits of technology

It improves the security and efficiency of file reading, ensures the integrity of file metadata, and enhances user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115033928B_ABST
    Figure CN115033928B_ABST
Patent Text Reader

Abstract

The application provides a file granularity data reading method and device, electronic equipment and medium. The method comprises: obtaining a reading request, the reading request being used to indicate reading N data blocks in a file; wherein the file comprises M data blocks, N is less than M, M and N are positive integers; for each data block in the N data blocks, it is judged whether there is a page cache of the data block, if there is, after obtaining a measurement mark of the page cache as an update mark, it is determined that the page cache meets the integrity measurement; wherein the update mark is used to indicate that the page cache passes the integrity measurement; after it is determined that the page caches corresponding to the N data blocks all meet the integrity measurement, a reading result is fed back based on the page cache. The method provided by the application improves the security of file reading and the efficiency of integrity checking during reading, thereby being beneficial to improving user experience.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to computer system security technology, in particular to a file granularity data reading method and device, electronic equipment and medium. BACKGROUND

[0002] On a vehicle-mounted or mobile device, key data and configuration files are saved in a system partition. If the integrity of the system partition is destroyed, the system service performance may be out of control, so it is necessary to measure the integrity of the system partition.

[0003] The existing integrity measurement mechanisms are dm-verity and IMA. Among them, dm-verity can check all physical blocks in the entire partition to determine the integrity of the entire partition. This mechanism cannot determine exactly where the data is tampered with, and has a serious time consumption problem. IMA supports file granularity integrity measurement, and a file includes multiple data blocks. When opening a file, all data blocks of the file are read and a digest is calculated. By comparing the calculated digest with the preset digest, it is determined whether the file is complete. The above-mentioned file is a read-only file during device operation.

[0004] For the IMA mechanism, when measuring the integrity of a larger file that is read-only during operation, calculating the data digest of all data blocks of the file will obviously consume time, resulting in a decline in file IO performance. For application scenarios sensitive to booting and application startup speed, using the IMA mechanism can easily lead to a decline in key performance indicators. SUMMARY

[0005] The present application provides a file granularity data reading method, device, electronic equipment and medium, which can manage and maintain the problematic battery in a timely and accurate manner.

[0006] In one aspect, the present application provides a file granularity data reading method, which comprises:

[0007] Obtaining a read request, the read request being used to indicate reading N data blocks in a file; wherein the file includes M data blocks, the N is less than the M, and the M and the N are positive integers;

[0008] For each data block in the N data blocks, it is determined whether there is a page cache of the data block. If there is, after obtaining a measurement mark of the page cache as an update mark, it is determined that the page cache satisfies the integrity measurement; wherein the update mark is used to indicate that the page cache passes the integrity measurement.

[0009] After it is determined that the page caches corresponding to the N data blocks all satisfy the integrity measurement, a read result is fed back based on the page caches.

[0010] In another possible implementation manner, the method further includes:

[0011] if the page cache of the data block does not exist, reading content corresponding to the data block from a disk to obtain the page cache;

[0012] performing integrity measurement on the page cache to obtain an integrity measurement result;

[0013] according to the integrity measurement result, setting a measurement flag, and waking up a thread for obtaining the measurement flag to determine whether to feed back a reading result based on the page cache;

[0014] wherein if the page cache passes the integrity measurement, the measurement flag is set as an update flag; and if the page cache does not pass the integrity measurement, the measurement flag is set as an error flag.

[0015] In another possible implementation manner, the performing integrity measurement on the page cache to obtain an integrity measurement result includes:

[0016] obtaining a current hash value of the page cache;

[0017] determining whether the current hash value is consistent with a pre-stored hash value;

[0018] if the current hash value is consistent with the pre-stored hash value, determining that the page cache passes the integrity measurement,

[0019] if the current hash value is not consistent with the pre-stored hash value, determining that the page cache does not pass the integrity measurement.

[0020] In another possible implementation manner, the reading request includes an offset and a length of each data block in the N data blocks in the memory, and the determining whether the page cache of the data block exists includes:

[0021] based on the offset and the length of the data block, searching for content corresponding to the data block in the memory;

[0022] if the content corresponding to the data block is found, determining that the page cache exists.

[0023] In another possible implementation manner, before the reading request is obtained, the method further includes:

[0024] when detecting an opening request of the file, obtaining pre-stored metadata information of the file;

[0025] based on current metadata information of the file and the pre-stored metadata information, determining whether to open the file in response to the opening request.

[0026] In another possible implementation manner, before the read request is acquired, the method further includes:

[0027] When the opening request of the file is detected, pre-stored metadata information of the file is acquired;

[0028] Based on the current metadata information of the file and the pre-stored metadata information, it is determined whether to open the file in response to the opening request.

[0029] In another possible implementation manner, the opening request includes the current metadata information, and the current metadata information includes a file type, an offset and a length of each data block, and an access path of each data block.

[0030] In another aspect, the present application provides a file-granularity data reading device, comprising a first acquisition module, a judgment module and a feedback module, wherein,

[0031] The first acquisition module is configured to acquire a read request, and the read request is configured to indicate reading N data blocks in a file; wherein the file comprises M data blocks, the N is less than the M, and the M and the N are positive integers;

[0032] The judgment module is configured to determine, for each data block in the N data blocks, whether there is a page cache of the data block, and if there is, to determine that the page cache meets the integrity measurement after acquiring a measurement marker of the page cache as an update marker; wherein the update marker is configured to indicate that the page cache passes the integrity measurement.

[0033] The feedback module is configured to feed back a reading result based on the page cache after determining that the page caches corresponding to the N data blocks all meet the integrity measurement.

[0034] In another possible implementation manner, the device further comprises a reading module, a measurement module and a first determination module, wherein,

[0035] The reading module is configured to read content corresponding to the data block from a disk to obtain the page cache when the page cache of the data block does not exist.

[0036] The measurement module is configured to perform integrity measurement on the page cache to obtain an integrity measurement result.

[0037] The first determination module is configured to set a measurement marker according to the integrity measurement result, and to wake up a thread for acquiring the measurement marker, so as to determine whether to feed back a reading result based on the page cache.

[0038] If the page cache passes the integrity measurement, the measurement mark is set as an update mark; if the page cache fails the integrity measurement, the measurement mark is set as an error mark.

[0039] In another possible implementation manner, the measurement module is specifically used for:

[0040] obtaining a current hash value of the page cache;

[0041] determining whether the current hash value is consistent with a pre-stored hash value;

[0042] if the current hash value is consistent with the pre-stored hash value, determining that the page cache passes the integrity measurement,

[0043] if the current hash value is not consistent with the pre-stored hash value, determining that the page cache fails the integrity measurement.

[0044] In another possible implementation manner, the determination module is specifically used for:

[0045] finding, based on the offset and the length of the data block, the content corresponding to the data block in the memory;

[0046] if the content corresponding to the data block is found, determining that the page cache exists.

[0047] In another possible implementation manner, the apparatus further includes a second obtaining module and a second determining module, wherein,

[0048] the second obtaining module is configured to obtain pre-stored metadata information of the file when detecting an opening request of the file;

[0049] the second determining module is configured to determine, based on current metadata information of the file and the pre-stored metadata information, whether to open the file in response to the opening request.

[0050] In another possible implementation manner, the second determining module is specifically used for:

[0051] if the current metadata information is consistent with the pre-stored metadata information, opening the file;

[0052] if the current metadata information is not consistent with the pre-stored metadata information, rejecting the opening request.

[0053] In another possible implementation manner, the opening request includes the current metadata information, and the current metadata information includes a file type, an offset and a length of each data block, and an access path of each data block.

[0054] In a third aspect, the present application provides an electronic device, including:

[0055] at least one processor and a memory;

[0056] The memory stores computer-executable instructions.

[0057] The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor executes the file-granularity data reading method according to any one of the first aspect.

[0058] In a fourth aspect, the present application provides a computer-readable storage medium, which stores computer-executable instructions, and when a processor executes the computer-executable instructions, the file-granularity data reading method according to any one of the first aspect is implemented.

[0059] The present application provides a file-granularity data reading method, device, electronic equipment and medium. Through the present application, when any file needs to be opened, the current metadata information of the file is first acquired, and the current metadata information is compared with the pre-stored metadata information to quickly determine whether the type, access path, etc. of the current file is tampered with, so as to determine the integrity of the current file metadata. Further, when it is intended to read part of the content in the file, the present method only checks one or more data blocks corresponding to the part of the content, effectively reducing the calculation amount and improving the checking efficiency, thereby facilitating the improvement of user experience.

[0060] Specifically, the specific process of reading part of the content corresponding to the current file is as follows: when the reading request is acquired, first, the N data blocks that need to be read are determined, and then it is judged whether the page cache corresponding to the N data blocks respectively exists in the memory. If it exists, after the measurement mark of the page cache is acquired as an update mark, it is determined that the page cache satisfies the integrity measurement, at this time, the reading result is fed back based on the page cache. Only after the N data blocks that need to be read all pass the integrity measurement, the target reading content is allowed to be read, thereby improving the security of file reading. BRIEF DESCRIPTION OF DRAWINGS

[0061] The accompanying drawings, which are incorporated into and form part of the specification, illustrate embodiments consistent with the present application and, together with the specification, serve to explain the principles of the present application.

[0062] Figure 1 A file-granularity data reading scenario provided for an embodiment of the present application;

[0063] Figure 2 A file-granularity data reading method flow provided for an embodiment of the present application Figure 1 ;

[0064] Figure 3A file granularity data reading method flowchart provided by an embodiment of the present application Figure 2 ;

[0065] Figure 4 A file granularity data reading method flowchart provided by an embodiment of the present application Figure 3 ;

[0066] Figure 5 A file granularity data reading device schematic diagram provided by an embodiment of the present application

[0067] Figure 6 An electronic device provided by an embodiment of the present application.

[0068] The specific embodiments of the present application have been shown through the above-mentioned drawings, and will be described in more detail hereinafter. These drawings and the written description are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION

[0069] The exemplary embodiments will be described in detail herein with reference to the attached drawings. In the following description, the same numbers are used to indicate the same or similar components. The embodiments described in the following exemplary embodiments are not meant to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of the present application as detailed in the appended claims.

[0070] Figure 1 A file granularity data reading scenario schematic diagram provided by an embodiment of the present application, the device includes a disk and a memory, wherein the disk includes at least one file, the file type can be video, audio, document, etc., each file contains data content with corresponding offset and length. When reading file content, it is read in units of 4K size data block. The memory is used to cache data content read by the user. Specifically, when reading any data block in any file to the memory, first, a 4K size memory page is established in the memory, and then the content contained in the data block is filled in the memory page to obtain the page cache corresponding to the data block. When the user needs to read the file content, the device will first determine whether the page cache corresponding to the data block including the part of the content exists in the memory, if it exists, the part of the content is directly obtained from the corresponding page cache in the memory, thereby improving the reading efficiency. When the device is running, each file contained in the device in the embodiment of the present application is a read-only file.

[0071] Specifically, as shown in FIG. 1, the device includes a disk and a memory. The disk includes at least one file, the file type can be video, audio, document, etc., each file contains data content with corresponding offset and length. When reading file content, it is read in units of 4K size data block. The memory is used to cache data content read by the user. Specifically, when reading any data block in any file to the memory, first, a 4K size memory page is established in the memory, and then the content contained in the data block is filled in the memory page to obtain the page cache corresponding to the data block. When the user needs to read the file content, the device will first determine whether the page cache corresponding to the data block including the part of the content exists in the memory, if it exists, the part of the content is directly obtained from the corresponding page cache in the memory, thereby improving the reading efficiency. When the device is running, each file contained in the device in the embodiment of the present application is a read-only file. Figure 1In the shown scenario, N files are stored in the disk, and file 1 includes seven data blocks. When a user demands to read a part of the data content in file 1, first, based on the offset and length of the part of the data content, N continuous data blocks that need to be read are determined, where N is a positive integer. In the shown scenario, the data blocks that need to be read are determined to be data blocks 5, 6, and 7 according to the offset and length of the data content that needs to be read. Figure 1 In the shown scenario, first, the page caches corresponding to data blocks 5, 6, and 7 are found in the memory according to the data blocks 5, 6, and 7 that need to be read. Figure 1 It can be seen that the page cache 15 of the fifth data block of file 1 exists in the memory, and the page caches corresponding to the sixth and seventh data blocks do not exist. Therefore, finally, the data content included in the fifth data block of file 1 can be directly read through the page cache 15, and for the contents of the sixth and seventh data blocks that do not exist in the memory, the contents of the sixth and seventh data blocks are first read from the disk to the memory, and then the data contents of the sixth and seventh data blocks are obtained based on the corresponding page caches in the memory.

[0072] When a user opens or reads file content, the device needs to verify the integrity of the file to ensure that the opened or read file is not tampered with, thereby ensuring the security of the file. The existing integrity measurement mechanism, one of which needs to verify all data blocks in the disk partition when measuring the integrity of a file, is not a file-granularity verification; the other needs to verify all data blocks included in the file.

[0073] At this time, if the number of files in the disk partition is too large or the amount of file data is too large, it is easy to cause low efficiency when opening or reading the file. Therefore, the present application proposes a file-granularity data reading method, which is used to verify the integrity of one or more data blocks when reading the one or more data blocks, to realize on-demand verification, effectively reduce the amount of calculation, and be beneficial to speeding up the efficiency of opening or reading the corresponding content, thereby being beneficial to improving the user experience.

[0074] The technical solutions of the present application and how the technical solutions of the present application solve the above technical problems will be described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes can not be described in detail in some embodiments.

[0075] Figure 2 A file-granularity data reading method flow provided for the embodiment Figure 1 . The following will be described in detail Figure 2 , one embodiment of the present application. As shown in Figure 2 , the method in the embodiment can include steps S201, S202, S203, and S204, wherein,

[0076] Step S201, a read request is acquired, the read request being used to indicate reading N data blocks in a file.

[0077] Wherein, the file includes M data blocks, N is less than M, and M and N are positive integers.

[0078] Specifically, as shown in the figure, Figure 1 File 1 includes 7 data blocks, i.e. M = 7. For file 1, the applicable cases of the present application include: the number of data blocks that the user needs to read is less than the number of all data blocks included in file 1, i.e. N < 7 is satisfied.

[0079] Step S202, for each data block in the N data blocks, it is judged whether there is a page cache of the data block, if there is, after acquiring the measurement mark of the page cache as an update mark, it is determined that the page cache satisfies the integrity measurement.

[0080] Wherein, the update mark is used to indicate that the page cache passes the integrity measurement, and the satisfaction of the integrity measurement is used to represent whether the page cache is tampered with.

[0081] Step S203, after determining that the page caches corresponding to the N data blocks all satisfy the integrity measurement, the read result is fed back based on the page caches.

[0082] Specifically, when it is determined that the current N data blocks are not tampered with, the read result is fed back based on the page caches, and the read result is used to show the data content required by the user.

[0083] The method provided in the embodiment can, for a read-only file, when the user requests to read N data blocks corresponding to a certain part of the content in the file, first judge whether there is a page cache corresponding to each of the N data blocks in the memory, if there is, judge whether the N data blocks are tampered with based on the page caches corresponding to the N data blocks respectively, and only when the page caches corresponding to the N data blocks all pass the integrity measurement, the data content included in the page caches corresponding to the N data blocks is fed back to the user.

[0084] In the above process, it is first judged whether there is a page cache corresponding to each of the N data blocks in the memory, and when the page cache exists and is not tampered with, the page cache is directly acquired from the memory, thereby improving the file reading efficiency. Meanwhile, only when the N data blocks all pass the integrity measurement, the read content is allowed to be fed back, so that when the file is read, on the one hand, the verification is performed on demand, the calculation amount and the waiting time are reduced, and on the other hand, the security of the file reading is effectively improved.

[0085] Figure 3 is a file-granularity data reading method provided by the embodiment of the present application Figure 2 , and the following will be combined with Figure 3The specific implementation process of the embodiment of the present application is described in detail. Specifically, the embodiment describes the case where the page cache of the data block does not exist in the memory and the way of integrity measurement of the page cache on the basis of the above-described embodiment.

[0086] As shown in Figure 3 The method provided by the embodiment includes the following steps: step S301, step S302, step S303 and step S304.

[0087] In step S301, if the page cache of the data block does not exist, the content corresponding to the data block is read from the disk to obtain the page cache.

[0088] Specifically, if the page cache of the data block does not exist in the memory, a new memory page is first established in the memory, and then the corresponding data block content read from the disk is filled in the corresponding memory page, thereby obtaining the page cache corresponding to each data block.

[0089] In step S302, the current hash value of the page cache is obtained.

[0090] Specifically, the current hash value of each page cache is calculated.

[0091] In step S303, it is determined whether the current hash value is consistent with the pre-stored hash value to obtain the integrity measurement result.

[0092] Specifically, if the current hash value is consistent with the pre-stored hash value, it is determined that the page cache passes the integrity measurement, and if the current hash value is not consistent with the pre-stored hash value, it is determined that the page cache does not pass the integrity measurement.

[0093] In step S304, according to the integrity measurement result, the measurement mark is set, and the thread for obtaining the measurement mark is woken up to determine whether to feed back the reading result based on the page cache.

[0094] Specifically, if the page cache passes the integrity measurement, the measurement mark is set as an update mark, and if the page cache does not pass the integrity measurement, the measurement mark is set as an error mark. When the measurement mark of the page cache is needed, the measurement mark of the page cache is obtained, and it is determined whether to feed back the reading result based on the measurement mark of the page cache.

[0095] The method provided by the embodiment comprises: after each page cache is read, performing integrity verification once, that is, performing hash calculation on the current read page cache to obtain a current hash value; and comparing the current hash value with a pre-stored hash value, wherein the pre-stored hash value is a hash value corresponding to the data block when the data block is stored. If the current hash value is consistent with the pre-stored hash value, it is indicated that the corresponding data block is not tampered with, that is, the integrity measurement result of the page cache corresponding to the data block is that the page cache of the current data block passes the integrity measurement, and at this time, an update flag is set for the current page cache to facilitate identification.

[0096] Figure 4 The method flow of the file granularity data reading provided by the embodiment of the application Figure 3 In Figure 2 and Figure 3 , the specific implementation process of the embodiment of the application is described in detail in combination with Figure 4 . Specifically, the embodiment describes the way of performing integrity measurement when opening a file and reading any data block.

[0097] As shown in Figure 4 , the method provided by the embodiment comprises the following steps: step S401, step S402, step S403, step S404, step S405, step S406, step S407, step S408, step S409, step S410 and step S411, wherein

[0098] In step S401, when detecting an opening request of a file, pre-stored metadata information of the file is obtained.

[0099] The opening request comprises current metadata information, and the current metadata information comprises a file type, offsets and lengths of each data block, and an access path of each data block.

[0100] In step S402, it is determined whether the current metadata information is consistent with the pre-stored metadata information. If yes, step S403 is performed; if no, step S404 is performed.

[0101] Specifically, the way of determining whether the current metadata information is consistent with the pre-stored metadata information is as follows: a hash value of the current metadata information is calculated to obtain a current metadata hash value. The current metadata hash value is compared with a pre-stored metadata hash value. If the current metadata hash value is consistent with the pre-stored metadata hash value, it is indicated that the current metadata information is consistent with the pre-stored metadata information, that is, the file metadata information is not tampered with, and the file can be safely opened. If the current metadata hash value is not consistent with the pre-stored metadata hash value, it is indicated that the current metadata information is not consistent with the pre-stored metadata information, that is, the file metadata information is tampered with, and at this time, there is a risk when the file is opened.

[0102] Step S403, open the file in response to the opening request.

[0103] Step S404, reject the opening request.

[0104] Step S405, acquire a read request when the file is allowed to be opened and there is a read demand, the read request being used to indicate reading N data blocks in the file.

[0105] Specifically, based on the read request, determine the N data blocks that the user needs to read.

[0106] Step S406, for the N data blocks, find the corresponding content of the data blocks in the memory based on the offset and length of the data blocks. If the corresponding content of the data blocks can be found, execute step S407, if the corresponding content of the data blocks cannot be found, execute step S408.

[0107] Step S407, determine that there is a page cache, and acquire the integrity measurement result of the page cache.

[0108] Step S408, determine that there is no page cache, read the page cache from the disk, and acquire the integrity measurement result of the page cache.

[0109] Step S409, based on the integrity measurement result, judge whether the measurement marks of each page cache are all update marks. If yes, execute step S410; if the measurement mark of the acquired page cache is an error mark, execute step S411.

[0110] Step S410, feed back the read result based on the page cache.

[0111] The read result is to allow reading the corresponding content of the file, and feed back the corresponding content of the file to the user.

[0112] Step S411, reject the read request.

[0113] The method provided in the embodiment, when the user opens the file, first determines whether the directory, access path, data type, etc. of the file are tampered based on the current metadata information, so as to reject the opening request of the user in time when the directory, access path, data type, etc. of the file are tampered, and inform the user that the file has been tampered. Only when the directory, access path, data type, etc. of the file are not tampered, the file is allowed to be opened, which guarantees the security when the file is opened.

[0114] At this time, when the user has read a part of the file content, first determine whether the page cache of the part of the content exists in the memory, and when the page cache of the part of the content exists, obtain the integrity measurement result of the corresponding page cache to verify whether the part of the content of the file is tampered. When the page cache of the part of the content does not exist, read the part of the content to the memory to obtain the page cache of the part of the content, and perform integrity measurement on the page cache of the part of the content to obtain the integrity measurement result. Finally, based on the integrity measurement result, it is determined whether to feed back the part of the content of the file to the user. Only the part of the content required by the user is determined whether it is tampered, which effectively improves the efficiency of safe reading and is beneficial to improve the experience of the user.

[0115] The above embodiment introduces a file granularity data reading method from the perspective of method flow. The following embodiment introduces a file granularity data reading device from the perspective of virtual module or virtual unit. For details, see the following embodiment.

[0116] The embodiment of the present application provides a file granularity data reading device, as shown in the figure, which comprises a first acquisition module 51, a judgment module 52 and a feedback module 53, wherein, Figure 5

[0117] The first acquisition module 51 is used for acquiring a reading request, and the reading request is used for indicating reading N data blocks in a file; wherein the file comprises M data blocks, N is less than M, M and N are positive integers;

[0118] The judgment module 52 is used for judging whether the page cache of each data block in the N data blocks exists, and if it exists, determining that the page cache satisfies the integrity measurement after obtaining the measurement mark of the page cache as an update mark; wherein the update mark is used for indicating that the page cache passes the integrity measurement;

[0119] The feedback module 53 is used for feeding back the reading result based on the page cache after determining that the page caches corresponding to the N data blocks all satisfy the integrity measurement.

[0120] Another possible implementation manner of the embodiment of the present application, the device further comprises: a reading module, a measurement module and a first determination module, wherein,

[0121] The reading module is used for reading the content corresponding to the data block from the disk to obtain the page cache when the page cache of the data block does not exist;

[0122] The measurement module is used for performing integrity measurement on the page cache to obtain an integrity measurement result.

[0123] The first determination module is used for setting the measurement mark according to the integrity measurement result, and waking up the thread for obtaining the measurement mark to determine whether to feed back the reading result based on the page cache; ​

[0124] If the page cache passes the integrity measurement, the measurement mark is set as an update mark; and if the page cache fails the integrity measurement, the measurement mark is set as an error mark.

[0125] In another possible implementation of the embodiment of the application, the measurement module is specifically configured to:

[0126] obtain a current hash value of the page cache;

[0127] determine whether the current hash value is consistent with the pre-stored hash value;

[0128] if the current hash value is consistent with the pre-stored hash value, determine that the page cache passes the integrity measurement,

[0129] if the current hash value is not consistent with the pre-stored hash value, determine that the page cache fails the integrity measurement.

[0130] In another possible implementation of the embodiment of the application, the determination module is specifically configured to:

[0131] search for the content corresponding to the data block in the memory based on the offset and the length of the data block;

[0132] if the content corresponding to the data block is found, determine that the page cache exists.

[0133] In another possible implementation of the embodiment of the application, the apparatus further includes a second obtaining module and a second determining module, wherein,

[0134] the second obtaining module is configured to obtain pre-stored metadata information of the file when detecting an opening request of the file;

[0135] the second determining module is configured to determine whether to open the file in response to the opening request based on current metadata information and the pre-stored metadata information of the file.

[0136] In another possible implementation of the embodiment of the application, the second determining module is specifically configured to:

[0137] if the current metadata information is consistent with the pre-stored metadata information, open the file;

[0138] if the current metadata information is not consistent with the pre-stored metadata information, reject the opening request.

[0139] In another possible implementation of the embodiment of the application, the opening request includes the current metadata information, and the current metadata information includes a file type, offsets and lengths of each data block, and access paths of each data block.

[0140] In the embodiments of the present application, the first obtaining module 51 and the second obtaining module can be the same obtaining module, or can be different obtaining modules. The first determining module and the second determining module can be the same determining module, or can be different determining modules, which are not limited in the embodiments of the present application.

[0141] The file granularity data reading device provided in the embodiments of the present application is suitable for the method embodiments described above, and will not be described herein.

[0142] An electronic device is provided in the embodiments of the present application, as shown in Figure 6 Figure 6 The electronic device shown in the embodiments of the present application includes a processor 61 and a memory 62. The processor 61 and the memory 62 are connected, for example, through a bus 63. Optionally, the electronic device can further include a transceiver 64. It should be noted that the transceiver 64 is not limited to one in actual application, and the structure of the electronic device does not constitute a limitation on the embodiments of the present application.

[0143] The processor 61 can be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. The processor 61 can implement or execute various exemplary logical blocks, modules and circuits described in combination with the disclosure. The processor 61 can also be a combination of computing functions, such as one or more microprocessors in combination, a combination of DSP and microprocessor, etc.

[0144] The bus 63 can include a path for transmitting information between the above-mentioned components. The bus 63 can be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. The bus 63 can be divided into an address bus 63, a data bus 63, a control bus 63, etc. For the sake of convenience, Figure 3 In the embodiments of the present application, only one thick line is used to represent the bus 63, but it does not mean that there is only one bus 63 or only one type of bus 63.

[0145] ​The memory 62 can be a ROM (Read Only Memory 62) or other type of static storage device that can store static information and instructions; a RAM (Random Access Memory 62) or other type of dynamic storage device that can store information and instructions; an EEPROM (Electrically Erasable Programmable Read Only Memory 62), a CD-ROM (Compact Disc Read Only Memory), or other optical disc storage, an optical disc storage (including a compact disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited thereto.

[0146] The memory 62 is configured to store application program codes for implementing the solutions of the present application, and the processor 61 is configured to control the execution of the application program codes. The processor 61 is configured to execute the application program codes stored in the memory 62 to implement the content shown in the foregoing method embodiments.

[0147] The electronic device includes, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (Personal Digital Assistant), a PAD (Tablet Personal Computer), a PMP (Portable Multimedia Player), a car terminal (e.g., a car navigation terminal), and the like, and a stationary terminal such as a digital TV, a desktop computer, and the like. It can also be a server or the like. Figure 6 The electronic device shown is merely an example and should not impose any limitation on the functions and use range of the embodiments of the present disclosure.

[0148] The embodiments of the present application provide a computer readable storage medium, which stores computer programs, and when the computer programs are run on a computer, the computer can execute the corresponding content in the foregoing method embodiments.

[0149] Other embodiments of the present application will be apparent to those skilled in the art from consideration of the specification and practice of the application disclosed herein. The specification and examples given are exemplary only and the true scope and spirit of the application is indicated by the claims. The specification and examples are to be regarded as illustrative only, the true scope and spirit of the application being indicated by the claims.

[0150] It is to be understood that the application is not limited to the precise construction already described above and shown in the drawings, and that various modifications and changes can be made by those skilled in the art without departing from the scope of the application. The scope of the application should only be limited by the claims appended hereto.

Claims

1. A method for reading data at file granularity, characterized in that: include: Obtaining a read request, the read request being used to instruct reading N data blocks in a file; wherein the file includes M data blocks, N is less than M, and M and N are positive integers; For each of the N data blocks, determining whether a page cache for the data block exists in a memory, and if so, obtaining a metric tag of the page cache; the metric tag is pre-set based on an integrity measurement result of the page cache; the metric tag includes an update tag and an error tag, wherein the update tag is used to indicate that the page cache passes the integrity measurement, and the error tag is used to indicate that the page cache fails the integrity measurement; After obtaining that the metric mark of the page cache is an update mark, determining that the page cache satisfies the integrity metric; After determining that the page caches corresponding to the N data blocks all meet the integrity metric, feeding back a reading result based on the page cache; If any of the page cache's metrics are marked as bad, the read request is rejected.

2. The method according to claim 1, characterized in that The method further comprises: If the page cache of the data block does not exist, reading the content corresponding to the data block from the disk to obtain the page cache; Performing integrity measurement on the page cache to obtain an integrity measurement result; Setting a measurement flag according to the integrity measurement result, and waking up a thread that obtains the measurement flag to determine whether to feed back a read result based on the page cache; If the page cache passes the integrity measurement, the measurement flag is set as an update flag; if the page cache fails the integrity measurement, the measurement flag is set as an error flag.

3. The method according to claim 2, characterized in that The performing integrity measurement on the page cache to obtain an integrity measurement result includes: Get the current hash value of the page cache; Determine whether the current hash value is consistent with the pre-stored hash value; If they are consistent, it is determined that the page cache passes the integrity measurement. If not, it is determined that the page cache fails the integrity metric.

4. The method according to claim 1, wherein The read request includes the offset and length of each data block in the memory of the N data blocks, and the determining whether there is a page cache for the data block includes: Based on the offset and length of the data block, searching for content corresponding to the data block in the memory; If the content corresponding to the data block is found, it is determined that the page cache exists.

5. The method according to claim 1, wherein Before obtaining the read request, the method further includes: When an opening request for the file is detected, obtaining pre-stored metadata information of the file; Based on the current metadata information of the file and the pre-stored metadata information, it is determined whether to open the file in response to the open request.

6. The method according to claim 5, characterized in that The determining, based on the current metadata information of the file and the pre-stored metadata information, whether to open the file in response to the open request includes: If the current metadata information is consistent with the pre-stored metadata information, opening the file; If the current metadata information is inconsistent with the pre-stored metadata information, the opening request is rejected.

7. The method according to claim 5, characterized in that The open request includes the current metadata information, and the current metadata information includes the file type, the offset and length of each data block, and the access path of each data block.

8. A data reading device with file granularity, characterized in that: include: A first acquisition module is configured to acquire a read request, wherein the read request is configured to instruct to read N data blocks in a file; wherein the file includes M data blocks, N is less than M, and M and N are positive integers; a determination module configured to determine, for each of the N data blocks, whether a page cache for the data block exists in a memory, and if so, obtain a metric tag of the page cache; the metric tag is pre-set based on an integrity measurement result of the page cache; the metric tag includes an update tag and an error tag, wherein the update tag is used to indicate that the page cache passes the integrity measurement, and the error tag is used to indicate that the page cache fails the integrity measurement; and upon obtaining that the metric tag of the page cache is the update tag, determine that the page cache satisfies the integrity measurement; A feedback module, configured to feed back a reading result based on the page cache after determining that the page caches corresponding to the N data blocks all meet the integrity metric; If any of the page cache's metrics are marked as bad, the read request is rejected.

9. An electronic device, characterized in that: include: at least one processor and memory; The memory stores computer-executable instructions; The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor executes the file-granularity data reading method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the file-granularity data reading method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Acceleration method and system for network content loading, its server and terminal

    CN101431525A

  • Data reading method, device and equipment and storage medium

    CN110764708A

  • Memory access control method and system and storage device controller

    CN111125794A