Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 16: Page and Buffer Cache


As demonstrated when discussingstruct address_space, each address space contains a pointer to an
address_space_operationsinstance that holds the above function list:

<fs.h>
struct address_space_operations {
int (*writepage)(struct page *page, struct writeback_control *wbc);
int (*readpage)(struct file *, struct page *);
int (*sync_page)(struct page *);

/*Write back some dirty pages from this mapping. */
int (*writepages)(struct address_space *, struct writeback_control *);

/*Set a page dirty */
int (*set_page_dirty)(struct page *page);

int (*readpages)(struct file *filp, struct address_space *mapping,
struct list_head *pages, unsigned nr_pages);

/*
*ext3 requires that a successful prepare_write() call be followed
*by a commit_write() call - they must be balanced
*/
int (*prepare_write)(struct file *, struct page *, unsigned, unsigned);
int (*commit_write)(struct file *, struct page *, unsigned, unsigned);

int (*write_begin)(struct file *, struct address_space *mapping,
loff_t pos, unsigned len, unsigned flags,
struct page **pagep, void **fsdata);
int (*write_end)(struct file *, struct address_space *mapping,
loff_t pos, unsigned len, unsigned copied,
struct page *page, void *fsdata);

/*Unfortunately this kludge is needed for FIBMAP. Don’t use it */
sector_t (*bmap)(struct address_space *, sector_t);
int (*invalidatepage) (struct page *, unsigned long);
int (*releasepage) (struct page *, gfp_t);
ssize_t (*direct_IO)(int, struct kiocb *, const struct iovec *iov,
loff_t offset, unsigned long nr_segs);
struct page* (*get_xip_page)(struct address_space *, sector_t,
int);
int (*migratepage) (struct address_space *,
struct page *, struct page *);
int (*launder_page) (struct page *);
};

❑ writepageandwritepageswrite one or more pages of the address space back to the underlying
block device. This is done by delegating a corresponding request to the block layer.
The kernel makes a number of standard functions available for this purpose [block_write_
full_pageandmpage_readpage(s)]; these are typically used instead of a manual implemen-
tation. Section 16.4.4 discusses the functions of thempage_family.
❑ readpageandreadpagesread one or more consecutive pages from the backing store into a
page frame.readpageandreadpagesare likewise not usually implemented manually but are
Free download pdf