Disable look-ahead for loop file.
Loopback files normally contain filesystems, in which case there are already
proper look-aheads in the upper layer, more look-aheads on the loopback file
only ruins the read-ahead hit rate.
Signed-off-by: Wu Fengguang <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
--- linux-2.6.19-rc5-mm2.orig/drivers/block/loop.c
+++ linux-2.6.19-rc5-mm2/drivers/block/loop.c
@@ -755,6 +755,12 @@ static int loop_set_fd(struct loop_devic
mapping = file->f_mapping;
inode = mapping->host;
+ /* Instruct the readahead code to skip look-ahead on loop file.
+ * The upper layer should already do proper look-ahead,
+ * one more look-ahead here only ruins the cache hit rate.
+ */
+ file->f_ra.flags |= RA_FLAG_LOOP;
+
if (!(file->f_mode & FMODE_WRITE))
lo_flags |= LO_FLAGS_READ_ONLY;
--- linux-2.6.19-rc5-mm2.orig/include/linux/fs.h
+++ linux-2.6.19-rc5-mm2/include/linux/fs.h
@@ -741,6 +741,7 @@ struct file_ra_state {
#define RA_FLAG_MISS (1UL<<31) /* a cache miss occured against this file */
#define RA_FLAG_INCACHE (1UL<<30) /* file is already in cache */
#define RA_FLAG_MMAP (1UL<<29) /* mmap page access */
+#define RA_FLAG_LOOP (1UL<<28) /* loopback file */
struct file {
/*
--- linux-2.6.19-rc5-mm2.orig/mm/readahead.c
+++ linux-2.6.19-rc5-mm2/mm/readahead.c
@@ -985,6 +985,10 @@ static int ra_submit(struct file_ra_stat
ra->lookahead_index = eof;
}
+ /* Disable look-ahead for loopback file. */
+ if (ra->flags & RA_FLAG_LOOP)
+ ra->lookahead_index = ra->readahead_index;
+
/* Take down the current read-ahead aging value. */
ra->age = nr_scanned_pages_node(numa_node_id());
--
-
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/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]