ra_min/ra_max are not initialized, fix it.

New benchmark numbers on

        hda: ST3250820A, ATA DISK drive
        hda: max request size: 512KiB
        hda: 488397168 sectors (250059 MB) w/8192KiB Cache, CHS=30401/255/63, 
UDMA(100)

with nfs mount
        mount -o tcp,rsize=$((rsize<<10)) localhost:$EXPORT $MNT

   rsize      stock  adaptive
   ==================================
f
      8k       3.07    2.51    -18.2%
     32k       2.40    2.17     -9.6%
    128k       2.40    2.35     -2.1%
ff
      8k      12.44    6.40    -48.6%
     32k      14.62    5.46    -62.7%
    128k      15.79    5.19    -67.1%
d
      8k       2.84    2.48    -12.7%
     32k       2.53    1.99    -21.3%
    128k       2.18    2.00     -8.3%
dd
      8k       8.16    7.99     -2.1%
     32k       8.27    6.88    -16.8%
    128k       7.75    6.97    -10.1%

The 4 patterns tested are:
         f: single file read
        ff: double file parallel read
         d: single dir read
        dd: double dir parallel read

Signed-off-by: Fengguang Wu <[EMAIL PROTECTED]>
---

--- linux-2.6.19-rc6-mm1.orig/mm/readahead.c
+++ linux-2.6.19-rc6-mm1/mm/readahead.c
@@ -1616,6 +1616,10 @@ page_cache_readahead_adaptive(struct add
        unsigned long ra_max;
        int ret;
 
+       /* no read-ahead */
+       if (!ra->ra_pages)
+               return 0;
+
        if (page) {
                ClearPageReadahead(page);
 
@@ -1635,9 +1639,6 @@ page_cache_readahead_adaptive(struct add
                                                offset + LAPTOP_POLL_INTERVAL))
                                return 0;
                }
-       } else if (ra->flags & RA_FLAG_NFSD) { /* nfsd read */
-               ra_size = max_sane_readahead(req_size);
-               goto readit;
        }
 
        if (page)
@@ -1647,11 +1648,13 @@ page_cache_readahead_adaptive(struct add
 
        get_readahead_bounds(ra, &ra_min, &ra_max);
 
-       /* read-ahead disabled? */
-       if (unlikely(!ra_max || !readahead_ratio)) {
-               ra_size = max_sane_readahead(req_size);
+       /* read as is */
+       if (!readahead_ratio)
+               goto readit;
+
+       /* nfsd read */
+       if (!page && (ra->flags & RA_FLAG_NFSD))
                goto readit;
-       }
 
        /*
         * Start of file.
@@ -1698,11 +1701,11 @@ page_cache_readahead_adaptive(struct add
                return 0;
        }
 
+readit:
        /*
         * Random read.
         */
        ra_size = min(req_size, ra_max);
-readit:
        ra_size = __do_page_cache_readahead(mapping, filp, offset, ra_size, 0);
 
        ra_account(ra, RA_EVENT_RANDOM_READ, ra_size);

--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to