摘要 |
The present invention discloses a method and an apparatus for accessing a file, where the method includes: receiving, by a file system, a file access request from an application layer; acquiring metadata of a file if the file access request is to acquire content of the file according to a query condition, where the metadata of the file includes index information of the file, and the query condition is used to select content of the file with respect to the index information of the file; determining, according to the index information of the file, content that is of the file and that meets the query condition; and acquiring, by using a magnetic disk IO controller, all content that is of the file and that meets the query condition, so that the application layer accesses the file. According to the foregoing manner, in the present invention, multiple times of page faults and multiple times of magnetic disk IO that occur in one query can be avoided, and memory usage is reduced by means of filtering out a part of data. |