Mmfilemapc

int add_to_page_cache(struct page *page, struct address_space *mapping, pgoff_t offset, gfp_t gfp_mask)

error = radix_tree_insert(&mapping->page_tree, offset, page);

page_cache_get(page); SetPageLocked(page); page->mapping = mapping; page->index = offset; mapping->nrpages++;

return error;

The index in the page cache and the pointer to the address space of the page are held in the corresponding elements of struct page (mapping and index). Finally, the address space page count (nrpages) is incremented by 1 because there is now one more page in the cache.

An alternative function named add_to_page_cache_lru with identical prototype is also available. This first invokes add_to_page_cache to add a page to the address space-specific page cache before also adding the page to the system's LRU cache using the lru_cache_add function.

Continue reading here: Mmfilemapc

Was this article helpful?

0 0