• Andrew Morton's avatar
    [PATCH] rework readahead for congested queues · 12affe8f
    Andrew Morton authored
    Since Jens changed the block layer to fail readahead if the queue has no
    requests free, a few changes suggest themselves.
    
    - It's a bit silly to go and alocate a bunch of pages, build BIOs for them,
      submit the IO only to have it fail, forcing us to free the pages again.
    
      So the patch changes do_page_cache_readahead() to peek at the queue's
      read_congested state.  If the queue is read-congested we abandon the entire
      readahead up-front without doing all that work.
    
    - If the queue is not read-congested, we go ahead and do the readahead,
      after having set PF_READAHEAD.
    
      The backing_dev_info's read-congested threshold cuts in when 7/8ths of
      the queue's requests are in flight, so it is probable that the readahead
      abandonment code in __make_request will now almost never trigger.
    
    - The above changes make do_page_cache_readahead() "unreliable", in that it
      may do nothing at all.
    
      However there are some system calls:
    
    	- fadvise(POSIX_FADV_WILLNEED)
    	- madvise(MADV_WILLNEED)
    	- sys_readahead()
    
      In which the user has an expectation that the kernel will actually
      perform the IO.
    
      So the patch creates a new "force_page_cache_readahead()" which will
      perform the IO regardless of the queue's congestion state.
    
      Arguably, this is the wrong thing to do: even though the application
      requested readahead it could be that the kernel _should_ abandon the user's
      request because the disk is so busy.
    
      I don't know.  But for now, let's keep the above syscalls behaviour
      unchanged.  It is trivial to switch back to do_page_cache_readahead()
      later.
    12affe8f
filemap.c 46.5 KB