[PATCH] rework readahead for congested queues
authorAndrew Morton <akpm@osdl.org>
Fri, 1 Aug 2003 03:02:32 +0000 (20:02 -0700)
committerLinus Torvalds <torvalds@home.osdl.org>
Fri, 1 Aug 2003 03:02:32 +0000 (20:02 -0700)
commit12affe8fd9c54541bd8c38ea7b193bcf254c58a0
treea445e83981594ef0f37e3089e03f08e79bdbe750
parentd49ceaba9a9b5a0797abd8fafaf014a201c44dc4
[PATCH] rework readahead for congested queues

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.
include/linux/mm.h
mm/fadvise.c
mm/filemap.c
mm/madvise.c
mm/readahead.c