readahead: sanify file_ra_state names
Subsystems (5)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/2 readahead: split ondemand readahead interface into two functions
Split ondemand readahead interface into two functions. I think this makes it a little clearer for non-readahead experts (like Rusty).
Internally they both call ondemand_readahead(), but the page argument is changed to an obvious boolean flag.
Signed-off-by Rusty Russell <[email protected]>
Signed-off-by Fengguang Wu <[email protected]>
--- fs/ext3/dir.c | 4 - fs/ext4/dir.c | 4 - fs/splice.c | 6 +- include/linux/mm.h | 20 ++++++--- mm/filemap.c | 10 ++-- mm/readahead.c | 95 ++++++++++++++++++++++++++----------------- 6 files changed, 84 insertions(+), 55 deletions(-)
fs/ext3/dir.c +2 -2
@@ -139,10 +139,10 @@ static int ext3_readdir(struct file * fipgoff_t index = map_bh.b_blocknr >> (PAGE_CACHE_SHIFT - inode->i_blkbits);if (!ra_has_index (&filp->f_ra, index)) -page_cache_readahead_ondemand ( +page_cache_sync_readahead ( sb->s_bdev->bd_inode->i_mapping, &filp->f_ra, filp, -NULL , index,1 ); + index,1 ); filp->f_ra.prev_index = index; bh =ext3_bread (NULL , inode, blk,0 , &err); }
fs/ext4/dir.c +2 -2
@@ -138,10 +138,10 @@ static int ext4_readdir(struct file * fipgoff_t index = map_bh.b_blocknr >> (PAGE_CACHE_SHIFT - inode->i_blkbits);if (!ra_has_index (&filp->f_ra, index)) -page_cache_readahead_ondemand ( +page_cache_sync_readahead ( sb->s_bdev->bd_inode->i_mapping, &filp->f_ra, filp, -NULL , index,1 ); + index,1 ); filp->f_ra.prev_index = index; bh =ext4_bread (NULL , inode, blk,0 , &err); }
fs/splice.c +3 -3
@@ -304,8 +304,8 @@ __generic_file_splice_read(struct file ** readahead/allocate the rest. */ if (spd.nr_pages < nr_pages) -page_cache_readahead_ondemand (mapping, &in->f_ra, in, -NULL , index, req_pages - spd.nr_pages); +page_cache_sync_readahead (mapping, &in->f_ra, in, + index, req_pages - spd.nr_pages);while (spd.nr_pages < nr_pages) {/*
@@ -360,7 +360,7 @@ __generic_file_splice_read(struct file * page = pages[page_nr];if (PageReadahead (page)) -page_cache_readahead_ondemand (mapping, &in->f_ra, in, +page_cache_async_readahead (mapping, &in->f_ra, in, page, index, req_pages - page_nr);/*
include/linux/mm.h +14 -6
@@ -1146,12 +1146,20 @@ int do_page_cache_readahead(struct addre pgoff_t offset, unsigned long nr_to_read);int force_page_cache_readahead (struct address_space *mapping,struct file *filp,pgoff_t offset,unsigned long nr_to_read); -unsigned long page_cache_readahead_ondemand (struct address_space *mapping, -struct file_ra_state *ra, -struct file *filp, -struct page *page, -pgoff_t offset, -unsigned long size); + +void page_cache_sync_readahead (struct address_space *mapping, +struct file_ra_state *ra, +struct file *filp, +pgoff_t offset, +unsigned long size); + +void page_cache_async_readahead (struct address_space *mapping, +struct file_ra_state *ra, +struct file *filp, +struct page *pg, +pgoff_t offset, +unsigned long size); +unsigned long max_sane_readahead (unsigned long nr);/* Do stack extension */
mm/filemap.c +5 -5
@@ -913,15 +913,15 @@ void do_generic_mapping_read(struct addr find_page: page =find_get_page (mapping, index);if (!page) { -page_cache_readahead_ondemand (mapping, - &ra, filp, page, +page_cache_sync_readahead (mapping, + &ra, filp, index, last_index - index); page =find_get_page (mapping, index);if (unlikely (page ==NULL )) goto no_cached_page; }if (PageReadahead (page)) { -page_cache_readahead_ondemand (mapping, +page_cache_async_readahead (mapping, &ra, filp, page, index, last_index - index); }
@@ -1382,14 +1382,14 @@ retry_find:*/ if (VM_SequentialReadHint (vma)) {if (!page) { -page_cache_readahead_ondemand (mapping, ra, file, page, +page_cache_sync_readahead (mapping, ra, file, fdata->pgoff,1 ); page =find_lock_page (mapping, fdata->pgoff);if (!page) goto no_cached_page; }if (PageReadahead (page)) { -page_cache_readahead_ondemand (mapping, ra, file, page, +page_cache_async_readahead (mapping, ra, file, page, fdata->pgoff,1 ); } }
mm/readahead.c +58 -37
129 lines not on this page · raw message
--
PATCH 2/2 readahead: sanify file_ra_state names
In reply to a message not in the archiveRename some file_ra_state variables and remove some accessors.
It results in much simpler code.
Kudos to Rusty!
Signed-off-by Fengguang Wu <[email protected]>
--- include/linux/fs.h | 61 +++----------------------------------- mm/readahead.c | 68 +++++++++++++++---------------------------- 2 files changed, 31 insertions(+), 98 deletions(-)
include/linux/fs.h +6 -55
@@ -768,16 +768,12 @@ struct fown_struct {/* * Track a single file's readahead state -* -* ================#============|==================#==================| -* ^ ^ ^ ^ -* file_ra_state.la_index .ra_index .lookahead_index .readahead_index */ struct file_ra_state { -pgoff_t la_index;/* enqueue time */ -pgoff_t ra_index;/* begin offset */ -pgoff_t lookahead_index;/* time to do next readahead */ -pgoff_t readahead_index;/* end offset */ +pgoff_t start;/* where readahead started */ +unsigned long size;/* # of readahead pages */ +unsigned long async_size;/* do asynchronous readahead when +there are only # of pages ahead */ unsigned long ra_pages;/* Maximum readahead window */ unsigned long mmap_hit;/* Cache hit stat for mmap accesses */
@@ -787,59 +783,14 @@ struct file_ra_state { };/* -* Measuring read-ahead sizes. -* -* |----------- readahead size ------------>| -* ===#============|==================#=====================| -* |------- invoke interval ------>|-- lookahead size -->| -*/ -static inline unsigned long ra_readahead_size (struct file_ra_state *ra) -{ -return ra->readahead_index - ra->ra_index; -} - -static inline unsigned long ra_lookahead_size (struct file_ra_state *ra) -{ -return ra->readahead_index - ra->lookahead_index; -} - -static inline unsigned long ra_invoke_interval (struct file_ra_state *ra) -{ -return ra->lookahead_index - ra->la_index; -} - -/* * Check if @index falls in the readahead windows. */ static inline int ra_has_index (struct file_ra_state *ra,pgoff_t index) { -return (index >= ra->la_index && - index < ra->readahead_index); -} - -/* -* Where is the old read-ahead and look-ahead? -*/ -static inline void ra_set_index (struct file_ra_state *ra, -pgoff_t la_index,pgoff_t ra_index) -{ - ra->la_index = la_index; - ra->ra_index = ra_index; +return (index >= ra->start && + index < ra->start + ra->size); } -/* -* Where is the new read-ahead and look-ahead? -*/ -static inline void ra_set_size (struct file_ra_state *ra, -unsigned long ra_size,unsigned long la_size) -{ - ra->readahead_index = ra->ra_index + ra_size; - ra->lookahead_index = ra->ra_index + ra_size - la_size; -} - -unsigned long ra_submit (struct file_ra_state *ra, -struct address_space *mapping,struct file *filp); -struct file {/* * fu_list becomes invalid after file_free is called and queued via
mm/readahead.c +25 -43
129 lines not on this page · raw message
--