aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorAndrew Morton <akpm@osdl.org>2005-11-07 03:59:28 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-07 10:53:37 -0500
commit7361f4d8ca65d23a18ba009b4484612183332c2f (patch)
tree7e3dcf22f7d191bcbeb78eb633ae067a76163124 /mm
parentbf8f972d3a1daf969cf44f64cc36d53bfd76441f (diff)
[PATCH] readahead commentary
Add a few comments surrounding the generic readahead API. Also convert some ulongs into pgoff_t: the identifier for PAGE_CACHE_SIZE offsets into pagecache. Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/readahead.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/mm/readahead.c b/mm/readahead.c
index d0b50034e245..72e7adbb87c7 100644
--- a/mm/readahead.c
+++ b/mm/readahead.c
@@ -254,7 +254,7 @@ out:
254 */ 254 */
255static int 255static int
256__do_page_cache_readahead(struct address_space *mapping, struct file *filp, 256__do_page_cache_readahead(struct address_space *mapping, struct file *filp,
257 unsigned long offset, unsigned long nr_to_read) 257 pgoff_t offset, unsigned long nr_to_read)
258{ 258{
259 struct inode *inode = mapping->host; 259 struct inode *inode = mapping->host;
260 struct page *page; 260 struct page *page;
@@ -274,7 +274,7 @@ __do_page_cache_readahead(struct address_space *mapping, struct file *filp,
274 */ 274 */
275 read_lock_irq(&mapping->tree_lock); 275 read_lock_irq(&mapping->tree_lock);
276 for (page_idx = 0; page_idx < nr_to_read; page_idx++) { 276 for (page_idx = 0; page_idx < nr_to_read; page_idx++) {
277 unsigned long page_offset = offset + page_idx; 277 pgoff_t page_offset = offset + page_idx;
278 278
279 if (page_offset > end_index) 279 if (page_offset > end_index)
280 break; 280 break;
@@ -311,7 +311,7 @@ out:
311 * memory at once. 311 * memory at once.
312 */ 312 */
313int force_page_cache_readahead(struct address_space *mapping, struct file *filp, 313int force_page_cache_readahead(struct address_space *mapping, struct file *filp,
314 unsigned long offset, unsigned long nr_to_read) 314 pgoff_t offset, unsigned long nr_to_read)
315{ 315{
316 int ret = 0; 316 int ret = 0;
317 317
@@ -368,7 +368,7 @@ static inline int check_ra_success(struct file_ra_state *ra,
368 * request queues. 368 * request queues.
369 */ 369 */
370int do_page_cache_readahead(struct address_space *mapping, struct file *filp, 370int do_page_cache_readahead(struct address_space *mapping, struct file *filp,
371 unsigned long offset, unsigned long nr_to_read) 371 pgoff_t offset, unsigned long nr_to_read)
372{ 372{
373 if (bdi_read_congested(mapping->backing_dev_info)) 373 if (bdi_read_congested(mapping->backing_dev_info))
374 return -1; 374 return -1;
@@ -385,7 +385,7 @@ int do_page_cache_readahead(struct address_space *mapping, struct file *filp,
385 */ 385 */
386static int 386static int
387blockable_page_cache_readahead(struct address_space *mapping, struct file *filp, 387blockable_page_cache_readahead(struct address_space *mapping, struct file *filp,
388 unsigned long offset, unsigned long nr_to_read, 388 pgoff_t offset, unsigned long nr_to_read,
389 struct file_ra_state *ra, int block) 389 struct file_ra_state *ra, int block)
390{ 390{
391 int actual; 391 int actual;
@@ -430,14 +430,27 @@ static int make_ahead_window(struct address_space *mapping, struct file *filp,
430 return ret; 430 return ret;
431} 431}
432 432
433/* 433/**
434 * page_cache_readahead is the main function. If performs the adaptive 434 * page_cache_readahead - generic adaptive readahead
435 * @mapping: address_space which holds the pagecache and I/O vectors
436 * @ra: file_ra_state which holds the readahead state
437 * @filp: passed on to ->readpage() and ->readpages()
438 * @offset: start offset into @mapping, in PAGE_CACHE_SIZE units
439 * @req_size: hint: total size of the read which the caller is performing in
440 * PAGE_CACHE_SIZE units
441 *
442 * page_cache_readahead() is the main function. If performs the adaptive
435 * readahead window size management and submits the readahead I/O. 443 * readahead window size management and submits the readahead I/O.
444 *
445 * Note that @filp is purely used for passing on to the ->readpage[s]()
446 * handler: it may refer to a different file from @mapping (so we may not use
447 * @filp->f_mapping or @filp->f_dentry->d_inode here).
448 * Also, @ra may not be equal to &@filp->f_ra.
449 *
436 */ 450 */
437unsigned long 451unsigned long
438page_cache_readahead(struct address_space *mapping, struct file_ra_state *ra, 452page_cache_readahead(struct address_space *mapping, struct file_ra_state *ra,
439 struct file *filp, unsigned long offset, 453 struct file *filp, pgoff_t offset, unsigned long req_size)
440 unsigned long req_size)
441{ 454{
442 unsigned long max, newsize; 455 unsigned long max, newsize;
443 int sequential; 456 int sequential;