struct page * lookup_swap_cache(swp_entry_t entry) {

struct page *page;

page = find_get_page(&swapper_space, entry.val); return page;

7Notice that kernel 2.6.25, which was under development when this book was written, will reshuffle the function names discussed here slightly. add_to_swap_cache will be merged into its only caller read_swap_cache_async, and will not exist anymore.

_add_to_swap_cache, however, will take its place and will be renamed to add_to_swap_cache. The callers are updated accordingly.

8Like many other swapping functions described in this chapter, the original function in the kernel sources includes a few short calls to update the key statistics of the swapping subsystem. I will not include such calls in our discussion because they essentially deal with simple manipulation of counters, which is not very interesting.

This function yields the required page by reference to a swp_entry_t instance by scanning the swapper_space address space using the familiar find_get_page function discussed in Chapter 16. As for many other address space related tasks, all the hard work is done by the radix tree implementation! Note that if the page is not found, the code returns a null pointer. The kernel must then fetch the data from the hard disk.

Continue reading here: Writing Data Back

Was this article helpful?

0 0