On Fri, Oct 26, 2012 at 03:03:12PM +0800, Ni zhan Chen wrote:On 10/26/2012 02:58 PM, Fengguang Wu wrote:The original behavior is '/= 4' on each error.Hi Fengguang,static void shrink_readahead_size_eio(struct file *filp,Yes immediately disabling readahead may hurt IO performance, the
struct file_ra_state *ra)
{
- ra->ra_pages /= 4;
+ spin_lock(&filp->f_lock);
+ filp->f_mode |= FMODE_RANDOM;
+ spin_unlock(&filp->f_lock);
As the example in comment above this function, the read maybe still
sequential, and it will waste IO bandwith if modify to FMODE_RANDOM
directly.
original '/ 4' may perform better when there are only 1-3 IO errors
encountered.
Why the number should be 1-3?
After 1 errors, readahead size will be shrinked by 1/4
After 2 errors, readahead size will be shrinked by 1/16
After 3 errors, readahead size will be shrinked by 1/64
After 4 errors, readahead size will be effectively 0 (disabled)
Thanks,
Fengguang