diff options
-rw-r--r-- | include/linux/fs.h | 4 | ||||
-rw-r--r-- | mm/filemap.c | 7 | ||||
-rw-r--r-- | mm/readahead.c | 30 |
3 files changed, 21 insertions, 20 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h index 0949e243b8b9..55a74ffa7e3b 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -696,13 +696,13 @@ struct file_ra_state { | |||
696 | unsigned long size; | 696 | unsigned long size; |
697 | unsigned long flags; /* ra flags RA_FLAG_xxx*/ | 697 | unsigned long flags; /* ra flags RA_FLAG_xxx*/ |
698 | unsigned long cache_hit; /* cache hit count*/ | 698 | unsigned long cache_hit; /* cache hit count*/ |
699 | unsigned long prev_page; /* Cache last read() position */ | 699 | unsigned long prev_index; /* Cache last read() position */ |
700 | unsigned long ahead_start; /* Ahead window */ | 700 | unsigned long ahead_start; /* Ahead window */ |
701 | unsigned long ahead_size; | 701 | unsigned long ahead_size; |
702 | unsigned long ra_pages; /* Maximum readahead window */ | 702 | unsigned long ra_pages; /* Maximum readahead window */ |
703 | unsigned long mmap_hit; /* Cache hit stat for mmap accesses */ | 703 | unsigned long mmap_hit; /* Cache hit stat for mmap accesses */ |
704 | unsigned long mmap_miss; /* Cache miss stat for mmap accesses */ | 704 | unsigned long mmap_miss; /* Cache miss stat for mmap accesses */ |
705 | unsigned int offset; /* Offset where last read() ended in a page */ | 705 | unsigned int prev_offset; /* Offset where last read() ended in a page */ |
706 | }; | 706 | }; |
707 | #define RA_FLAG_MISS 0x01 /* a cache miss occured against this file */ | 707 | #define RA_FLAG_MISS 0x01 /* a cache miss occured against this file */ |
708 | #define RA_FLAG_INCACHE 0x02 /* file is already in cache */ | 708 | #define RA_FLAG_INCACHE 0x02 /* file is already in cache */ |
diff --git a/mm/filemap.c b/mm/filemap.c index 07f5b77114a3..5631d6b2a62d 100644 --- a/mm/filemap.c +++ b/mm/filemap.c | |||
@@ -877,8 +877,8 @@ void do_generic_mapping_read(struct address_space *mapping, | |||
877 | cached_page = NULL; | 877 | cached_page = NULL; |
878 | index = *ppos >> PAGE_CACHE_SHIFT; | 878 | index = *ppos >> PAGE_CACHE_SHIFT; |
879 | next_index = index; | 879 | next_index = index; |
880 | prev_index = ra.prev_page; | 880 | prev_index = ra.prev_index; |
881 | prev_offset = ra.offset; | 881 | prev_offset = ra.prev_offset; |
882 | last_index = (*ppos + desc->count + PAGE_CACHE_SIZE-1) >> PAGE_CACHE_SHIFT; | 882 | last_index = (*ppos + desc->count + PAGE_CACHE_SIZE-1) >> PAGE_CACHE_SHIFT; |
883 | offset = *ppos & ~PAGE_CACHE_MASK; | 883 | offset = *ppos & ~PAGE_CACHE_MASK; |
884 | 884 | ||
@@ -947,7 +947,8 @@ page_ok: | |||
947 | offset += ret; | 947 | offset += ret; |
948 | index += offset >> PAGE_CACHE_SHIFT; | 948 | index += offset >> PAGE_CACHE_SHIFT; |
949 | offset &= ~PAGE_CACHE_MASK; | 949 | offset &= ~PAGE_CACHE_MASK; |
950 | prev_offset = ra.offset = offset; | 950 | prev_offset = offset; |
951 | ra.prev_offset = offset; | ||
951 | 952 | ||
952 | page_cache_release(page); | 953 | page_cache_release(page); |
953 | if (ret == nr && desc->count) | 954 | if (ret == nr && desc->count) |
diff --git a/mm/readahead.c b/mm/readahead.c index 0a6fed9d365c..9861e883fe57 100644 --- a/mm/readahead.c +++ b/mm/readahead.c | |||
@@ -37,7 +37,7 @@ void | |||
37 | file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping) | 37 | file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping) |
38 | { | 38 | { |
39 | ra->ra_pages = mapping->backing_dev_info->ra_pages; | 39 | ra->ra_pages = mapping->backing_dev_info->ra_pages; |
40 | ra->prev_page = -1; | 40 | ra->prev_index = -1; |
41 | } | 41 | } |
42 | EXPORT_SYMBOL_GPL(file_ra_state_init); | 42 | EXPORT_SYMBOL_GPL(file_ra_state_init); |
43 | 43 | ||
@@ -202,19 +202,19 @@ out: | |||
202 | * size: Number of pages in that read | 202 | * size: Number of pages in that read |
203 | * Together, these form the "current window". | 203 | * Together, these form the "current window". |
204 | * Together, start and size represent the `readahead window'. | 204 | * Together, start and size represent the `readahead window'. |
205 | * prev_page: The page which the readahead algorithm most-recently inspected. | 205 | * prev_index: The page which the readahead algorithm most-recently inspected. |
206 | * It is mainly used to detect sequential file reading. | 206 | * It is mainly used to detect sequential file reading. |
207 | * If page_cache_readahead sees that it is again being called for | 207 | * If page_cache_readahead sees that it is again being called for |
208 | * a page which it just looked at, it can return immediately without | 208 | * a page which it just looked at, it can return immediately without |
209 | * making any state changes. | 209 | * making any state changes. |
210 | * offset: Offset in the prev_page where the last read ended - used for | 210 | * offset: Offset in the prev_index where the last read ended - used for |
211 | * detection of sequential file reading. | 211 | * detection of sequential file reading. |
212 | * ahead_start, | 212 | * ahead_start, |
213 | * ahead_size: Together, these form the "ahead window". | 213 | * ahead_size: Together, these form the "ahead window". |
214 | * ra_pages: The externally controlled max readahead for this fd. | 214 | * ra_pages: The externally controlled max readahead for this fd. |
215 | * | 215 | * |
216 | * When readahead is in the off state (size == 0), readahead is disabled. | 216 | * When readahead is in the off state (size == 0), readahead is disabled. |
217 | * In this state, prev_page is used to detect the resumption of sequential I/O. | 217 | * In this state, prev_index is used to detect the resumption of sequential I/O. |
218 | * | 218 | * |
219 | * The readahead code manages two windows - the "current" and the "ahead" | 219 | * The readahead code manages two windows - the "current" and the "ahead" |
220 | * windows. The intent is that while the application is walking the pages | 220 | * windows. The intent is that while the application is walking the pages |
@@ -417,7 +417,7 @@ static int make_ahead_window(struct address_space *mapping, struct file *filp, | |||
417 | ra->ahead_size = get_next_ra_size(ra); | 417 | ra->ahead_size = get_next_ra_size(ra); |
418 | ra->ahead_start = ra->start + ra->size; | 418 | ra->ahead_start = ra->start + ra->size; |
419 | 419 | ||
420 | block = force || (ra->prev_page >= ra->ahead_start); | 420 | block = force || (ra->prev_index >= ra->ahead_start); |
421 | ret = blockable_page_cache_readahead(mapping, filp, | 421 | ret = blockable_page_cache_readahead(mapping, filp, |
422 | ra->ahead_start, ra->ahead_size, ra, block); | 422 | ra->ahead_start, ra->ahead_size, ra, block); |
423 | 423 | ||
@@ -469,13 +469,13 @@ page_cache_readahead(struct address_space *mapping, struct file_ra_state *ra, | |||
469 | * We avoid doing extra work and bogusly perturbing the readahead | 469 | * We avoid doing extra work and bogusly perturbing the readahead |
470 | * window expansion logic. | 470 | * window expansion logic. |
471 | */ | 471 | */ |
472 | if (offset == ra->prev_page && --req_size) | 472 | if (offset == ra->prev_index && --req_size) |
473 | ++offset; | 473 | ++offset; |
474 | 474 | ||
475 | /* Note that prev_page == -1 if it is a first read */ | 475 | /* Note that prev_index == -1 if it is a first read */ |
476 | sequential = (offset == ra->prev_page + 1); | 476 | sequential = (offset == ra->prev_index + 1); |
477 | ra->prev_page = offset; | 477 | ra->prev_index = offset; |
478 | ra->offset = 0; | 478 | ra->prev_offset = 0; |
479 | 479 | ||
480 | max = get_max_readahead(ra); | 480 | max = get_max_readahead(ra); |
481 | newsize = min(req_size, max); | 481 | newsize = min(req_size, max); |
@@ -484,7 +484,7 @@ page_cache_readahead(struct address_space *mapping, struct file_ra_state *ra, | |||
484 | if (newsize == 0 || (ra->flags & RA_FLAG_INCACHE)) | 484 | if (newsize == 0 || (ra->flags & RA_FLAG_INCACHE)) |
485 | goto out; | 485 | goto out; |
486 | 486 | ||
487 | ra->prev_page += newsize - 1; | 487 | ra->prev_index += newsize - 1; |
488 | 488 | ||
489 | /* | 489 | /* |
490 | * Special case - first read at start of file. We'll assume it's | 490 | * Special case - first read at start of file. We'll assume it's |
@@ -540,18 +540,18 @@ page_cache_readahead(struct address_space *mapping, struct file_ra_state *ra, | |||
540 | * we get called back on the first page of the ahead window which | 540 | * we get called back on the first page of the ahead window which |
541 | * will allow us to submit more IO. | 541 | * will allow us to submit more IO. |
542 | */ | 542 | */ |
543 | if (ra->prev_page >= ra->ahead_start) { | 543 | if (ra->prev_index >= ra->ahead_start) { |
544 | ra->start = ra->ahead_start; | 544 | ra->start = ra->ahead_start; |
545 | ra->size = ra->ahead_size; | 545 | ra->size = ra->ahead_size; |
546 | make_ahead_window(mapping, filp, ra, 0); | 546 | make_ahead_window(mapping, filp, ra, 0); |
547 | recheck: | 547 | recheck: |
548 | /* prev_page shouldn't overrun the ahead window */ | 548 | /* prev_index shouldn't overrun the ahead window */ |
549 | ra->prev_page = min(ra->prev_page, | 549 | ra->prev_index = min(ra->prev_index, |
550 | ra->ahead_start + ra->ahead_size - 1); | 550 | ra->ahead_start + ra->ahead_size - 1); |
551 | } | 551 | } |
552 | 552 | ||
553 | out: | 553 | out: |
554 | return ra->prev_page + 1; | 554 | return ra->prev_index + 1; |
555 | } | 555 | } |
556 | EXPORT_SYMBOL_GPL(page_cache_readahead); | 556 | EXPORT_SYMBOL_GPL(page_cache_readahead); |
557 | 557 | ||