Method and electronic device for accessing data
Various embodiments of the present disclosure generally relate to a method and an electronic device for reading data. Specifically, the method comprises receiving a request for reading the target data, and in response to the request, searching for the target data by searching a data index generated in a cache for reading data. The method further comprises in response to the target data being found, providing the target data. A corresponding system, device and computer program product are also provided.
1. A method for reading target data, comprising:
receiving a request, at a mapping logic unit (MLU), for reading the target data in a cache;
searching for the target data by searching a data index generated in the cache for reading data, wherein the MLU is configured to receive a result of the searching for the target data, wherein in response to the target data being unfound in the cache for reading data, sending a mapping for read (MFR) request from the MLU to an application program interface of a common block device file system (CBFS API), wherein in response to receiving the MFR request, sending a read request from the CBFS API to a persistent file data cache (PFDC), wherein in response to receiving the read request at the PFDC, searching for the target data in a HASH structure in the PFDC and returning a result of the searching to the CBFS API; and
upon finding the target data, providing the target data to the MLU to complete a read operation.
2. The method according to claim 1 , further comprising: updating the data index in the cache for reading data.
3. The method according to claim 2 , wherein the updating the data index in the cache for reading data comprises:
in response to data being written to the cache for reading data, generating an index entry for the written data; and
updating the data index using the index entry.
4. The method according to claim 3 , wherein the generating an index entry for the written data comprises:
in response to the written data being renamed, generating the index entry based on a file system identifier, an index node identifier and an offset.
5. The method according to claim 2 , wherein the updating the data index in the cache for reading data comprises:
in response to the target data being stored in a persistent storage device, storing the target data in the cache for reading data;
in response to the target data being stored in the cache for reading data, generating an index entry for the target data; and
updating the data index using the index entry.
6. The method according to claim 1 , wherein the searching for the target data further comprises:
in response to the target data being unfound in the cache for reading data, searching the cache for writing data.
7. The method according to claim 6 , wherein the searching for the target data further comprises:
in response to the target data being unfound in the cache for writing data, searching a persistent storage device.
8. An electronic device, comprising:
a processor;
a memory coupled to the processor and storing instructions to be executed by the processor, the instructions, when executed by the processor, causing the electronic device to perform actions including:
receiving a request, at a mapping logic unit (MLU), for reading a target data in a cache;
searching for the target data by searching a data index generated in the cache for reading data, wherein the MLU is configured to receive a result of the searching for the target data, wherein in response to the target data being unfound in the cache for reading data, sending a mapping for read (MFR) request from the MLU to an application program interface of a common block device file system (CBFS API), wherein in response to receiving the MFR request, sending a read request from the CBFS API to a persistent file data cache (PFDC), wherein in response to receiving the read request at the PFDC, searching for the target data in a HASH structure in the PFDC and returning a result of the searching to the CBFS API; and
upon finding the target data, providing the target data to the MLU to complete a read operation.
9. The electronic device according to claim 8 , wherein the actions further includes:
updating the data index in the cache for reading data.
10. The electronic device according to claim 8 , wherein the updating the data index in the cache for reading data comprises:
in response to data being written to the cache for reading data, generating an index entry for the written data; and
updating the data index using the index entry.
11. The electronic device according to claim 10 , wherein the generating an index entry for the written data comprises:
in response to the written data being renamed, generating the index entry based on a file system identifier, an index node identifier and an offset.
12. The electronic device according to claim 9 , wherein the updating the data index in the cache for reading data comprises:
in response to the target data being stored in a persistent storage device, storing the target data in the cache for reading data; in response to the target data being stored in the cache for reading data, generating an index entry for the target data; and updating the data index using the index entry.
13. The electronic device according to claim 8 , wherein the searching for the target data further comprises:
in response to the target data being unfound in the cache for reading data, searching the cache for writing data.
14. The electronic device according to claim 13 , wherein the searching for the target data further comprises:
in response to the target data being unfound in the cache for writing data, searching a persistent storage device.
15. A computer program product for reading target data, the computer program product comprising:
a non-transitory computer readable medium encoded with computer-executable program code, the code configured to enable the execution of:
receiving a request, at a mapping logic unit (MLU), for reading the target data in a cache;
searching for the target data by searching a data index generated in the cache for reading data, wherein the MLU is configured to receive a result of the searching for the target data, wherein in response to the target data being unfound in the cache for reading data, sending a mapping for read (MFR) request from the MLU to an application program interface of a common block device file system (CBFS API), wherein in response to receiving the MFR request, sending a read request from the CBFS API to a persistent file data cache (PFDC), wherein in response to receiving the read request at the PFDC, searching for the target data in a HASH structure in the PFDC and returning a result of the searching to the CBFS API; and
upon finding the target data, providing the target data to the MLU to complete a read operation.
16. The computer program product of claim 15 , wherein the code is further configured to enable the execution of:
updating the data index in the cache for reading data.
17. The computer program product of claim 16 , wherein the updating the data index in the cache for reading data comprises:
in response to data being written to the cache for reading data, generating an index entry for the written data; and updating the data index using the index entry.
18. The computer program product of claim 17 , wherein the generating an index entry for the written data comprises:
in response to the written data being renamed, generating the index entry based on a file system identifier, an index node identifier and an offset.
19. The computer program product of claim 16 , wherein the updating the data index in the cache for reading data comprises:
in response to the target data being stored in a persistent storage device, storing the target data in the cache for reading data;
in response to the target data being stored in the cache for reading data, generating an index entry for the target data; and
updating the data index using the index entry.
20. The computer program product of claim 15 , wherein the searching for the target data further comprises:
in response to the target data being unfound in the cache for reading data, searching the cache for writing data.