Commit 7361f4d8ca65d23a18ba009b4484612183332c2f

Authored by Andrew Morton
Committed by Linus Torvalds
1 parent bf8f972d3a

[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>

Showing 2 changed files with 26 additions and 13 deletions Side-by-side Diff

... ... @@ -932,13 +932,13 @@
932 932 * turning readahead off */
933 933  
934 934 int do_page_cache_readahead(struct address_space *mapping, struct file *filp,
935   - unsigned long offset, unsigned long nr_to_read);
  935 + pgoff_t offset, unsigned long nr_to_read);
936 936 int force_page_cache_readahead(struct address_space *mapping, struct file *filp,
937   - unsigned long offset, unsigned long nr_to_read);
938   -unsigned long page_cache_readahead(struct address_space *mapping,
  937 + pgoff_t offset, unsigned long nr_to_read);
  938 +unsigned long page_cache_readahead(struct address_space *mapping,
939 939 struct file_ra_state *ra,
940 940 struct file *filp,
941   - unsigned long offset,
  941 + pgoff_t offset,
942 942 unsigned long size);
943 943 void handle_ra_miss(struct address_space *mapping,
944 944 struct file_ra_state *ra, pgoff_t offset);
... ... @@ -254,7 +254,7 @@
254 254 */
255 255 static int
256 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 259 struct inode *inode = mapping->host;
260 260 struct page *page;
... ... @@ -274,7 +274,7 @@
274 274 */
275 275 read_lock_irq(&mapping->tree_lock);
276 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 279 if (page_offset > end_index)
280 280 break;
... ... @@ -311,7 +311,7 @@
311 311 * memory at once.
312 312 */
313 313 int 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 316 int ret = 0;
317 317  
... ... @@ -368,7 +368,7 @@
368 368 * request queues.
369 369 */
370 370 int 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 373 if (bdi_read_congested(mapping->backing_dev_info))
374 374 return -1;
... ... @@ -385,7 +385,7 @@
385 385 */
386 386 static int
387 387 blockable_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 389 struct file_ra_state *ra, int block)
390 390 {
391 391 int actual;
392 392  
393 393  
... ... @@ -430,14 +430,27 @@
430 430 return ret;
431 431 }
432 432  
433   -/*
434   - * page_cache_readahead is the main function. If performs the adaptive
  433 +/**
  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 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 */
437 451 unsigned long
438 452 page_cache_readahead(struct address_space *mapping, struct file_ra_state *ra,
439   - struct file *filp, unsigned long offset,
440   - unsigned long req_size)
  453 + struct file *filp, pgoff_t offset, unsigned long req_size)
441 454 {
442 455 unsigned long max, newsize;
443 456 int sequential;