From: Jens Axboe Expose the blockdev's VM readahead in /sys/block/hda/queue/read_ahead_kbytes This duplicates `blockdev --setra', but we're trying to get away from ioctls. It would be nice to have a readahead-setting mechanism which also allows, say, NFS to be tuned. But there is no common exposure point for backing_dev_infos. One option might be per-superblock: mount -o remount,read_ahead_kbytes=64 but the generic remount code also has no visibility of the backing_dev, so it would need a new super_block operation. One which doesn't accidentally modify default_backing_dev_info. --- 25-akpm/drivers/block/ll_rw_blk.c | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+) diff -puN drivers/block/ll_rw_blk.c~expose-backing-dev-max-read-ahead drivers/block/ll_rw_blk.c --- 25/drivers/block/ll_rw_blk.c~expose-backing-dev-max-read-ahead 2004-05-12 21:02:36.114055736 -0700 +++ 25-akpm/drivers/block/ll_rw_blk.c 2004-05-12 21:02:36.120054824 -0700 @@ -2998,14 +2998,41 @@ queue_requests_store(struct request_queu return ret; } +static ssize_t queue_ra_show(struct request_queue *q, char *page) +{ + int ra_kb = q->backing_dev_info.ra_pages << (PAGE_CACHE_SHIFT - 10); + + return queue_var_show(ra_kb, (page)); +} + +static ssize_t +queue_ra_store(struct request_queue *q, const char *page, size_t count) +{ + unsigned long ra_kb; + ssize_t ret = queue_var_store(&ra_kb, page, count); + + if (ra_kb > (q->max_sectors >> 1)) + ra_kb = (q->max_sectors >> 1); + + q->backing_dev_info.ra_pages = ra_kb >> (PAGE_CACHE_SHIFT - 10); + return ret; +} + static struct queue_sysfs_entry queue_requests_entry = { .attr = {.name = "nr_requests", .mode = S_IRUGO | S_IWUSR }, .show = queue_requests_show, .store = queue_requests_store, }; +static struct queue_sysfs_entry queue_ra_entry = { + .attr = {.name = "read_ahead_kb", .mode = S_IRUGO | S_IWUSR }, + .show = queue_ra_show, + .store = queue_ra_store, +}; + static struct attribute *default_attrs[] = { &queue_requests_entry.attr, + &queue_ra_entry.attr, NULL, }; _