Samstag, 17. Juli 2010

linux kernel buffer cache and page cache

linux kernel buffer cache and page cache

秋水軒尺牘 (1) : 與王滄亭 ( 別後思慕自述近況 )

《秋水軒尺牘》 許葭村著, 宋晶如釋 香港 , 廣智書局 , 1960

(1) 與王滄亭 ( 別後思慕自述近況)

與王滄亭 ( 別後思慕自述近況 )
    
  弟向獲締交於季方。因得聞元方之賢。思一見為快。昨於會城邂逅遇之。覺大兄之才華器宇。更有勝於所聞者。正恨相見之晚。不期越宿分襟。又恨相違之速矣。

別後初四月抵津門。初十日詣平舒。月未一圓。地經兩易。風塵僕僕。無非芸人之田。自憐亦堪自笑。此值同人歸里。館中惟我獨居。加以清磬紅魚。直是修行古剎。而西風黃葉。洄溯時殷。雙鯉之頒。定不我棄。

尊體復元否。嫁務紛勞。諸宜珍攝。因風寄意。不盡所懷。

quoted from professional linux kernel architecture by Wolfgang Mauerer, page 974.

1. The buffer cache is used not only as an add-on to the page cache, butalso as an independent cache for objects
that are NOT handled in pages but in blocks.

2. The data structures for BOTH types of cahce-- the independent buffer cache and the elements used to support the page cache --are the SAME.
The principal elements of the buffer cache are the buffer heads, see struct buffer_head.



http://lxr.linux.no/#linux+v2.6.34.1/include/linux/buffer_head.h#L61

52/*
53 * Historically, a buffer_head was used to map a single block
54 * within a page, and of course as the unit of I/O through the
55 * filesystem and block layers. Nowadays the basic I/O unit
56 * is the bio, and buffer_heads are used for extracting block
57 * mappings (via a get_block_t call), for tracking state within
58 * a page (via a page_mapping) and for wrapping bio submission
59 * for backward compatibility reasons (e.g. submit_bh).
60 */
61struct buffer_head {
62 unsigned long b_state; /* buffer state bitmap (see above) */
63 struct buffer_head *b_this_page;/* circular list of page's buffers */
64 struct page *b_page; /* the page this bh is mapped to */
65
66 sector_t b_blocknr; /* start block number */
67 size_t b_size; /* size of mapping */
68 char *b_data; /* pointer to data within the page */
69
70 struct block_device *b_bdev;
71 bh_end_io_t *b_end_io; /* I/O completion */
72 void *b_private; /* reserved for b_end_io */
73 struct list_head b_assoc_buffers; /* associated with another mapping */
74 struct address_space *b_assoc_map; /* mapping this buffer is
75 associated with */
76 atomic_t b_count; /* users using this buffer_head */
77};

Keine Kommentare: