• Wu Fengguang's avatar
    readahead: remove sync/async readahead call dependency · 51daa88e
    Wu Fengguang authored
    The readahead call scheme is error-prone in that it expects the call sites
    to check for async readahead after doing a sync one.  I.e.
    
    			if (!page)
    				page_cache_sync_readahead();
    			page = find_get_page();
    			if (page && PageReadahead(page))
    				page_cache_async_readahead();
    
    This is because PG_readahead could be set by a sync readahead for the
    _current_ newly faulted in page, and the readahead code simply expects one
    more callback on the same page to start the async readahead.  If the
    caller fails to do so, it will miss the PG_readahead bits and never able
    to start an async readahead.
    
    Eliminate this insane constraint by piggy-backing the async part into the
    current readahead window.
    
    Now if an async readahead should be started immediately after a sync one,
    the readahead logic itself will do it.  So the following code becomes
    valid: (the 'else' in particular)
    
    			if (!page)
    				page_cache_sync_readahead();
    			else if (PageReadahead(page))
    				page_cache_async_readahead();
    
    Cc: Nick Piggin <npiggin@suse.de>
    Signed-off-by: default avatarWu Fengguang <fengguang.wu@intel.com>
    Cc: Ying Han <yinghan@google.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    51daa88e
readahead.c 14.2 KB