--- lustre/llite/rw.c 2010-12-06 23:51:34.166551406 -0800 +++ lustre/llite/rw.c.orig 2010-12-06 23:49:47.154543746 -0800 @@ -1128,7 +1128,8 @@ static void ll_ra_stats_inc_sbi(struct l * ll_ra_count_get at the exactly same time. All of them will get a zero ra * window, although the global window is 100M. -jay */ -static unsigned long ll_ra_count_get(struct ll_sb_info *sbi, unsigned long len) +static unsigned long ll_ra_count_get(struct ll_sb_info *sbi, struct ra_io_arg *ria, + unsigned long len) { struct ll_ra_info *ra = &sbi->ll_ra_info; unsigned long ret = 0; @@ -1142,7 +1143,7 @@ static unsigned long ll_ra_count_get(str ret = min(ra->ra_max_pages - atomic_read(&ra->ra_cur_pages), len); if ((int)ret < min((unsigned long)PTLRPC_MAX_BRW_PAGES, len)) GOTO(out, ret = 0); - + if (atomic_add_return(ret, &ra->ra_cur_pages) > ra->ra_max_pages) { atomic_sub(ret, &ra->ra_cur_pages); ret = 0; @@ -1835,7 +1836,7 @@ static int ll_readahead(struct ll_readah if (len == 0) RETURN(0); - reserved = ll_ra_count_get(ll_i2sbi(inode), len); + reserved = ll_ra_count_get(ll_i2sbi(inode), ria, len); if (reserved < len) ll_ra_stats_inc(mapping, RA_STAT_MAX_IN_FLIGHT);