From a50376bda091b762dc2bcfdd54b386157829f84b Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Fri, 14 May 2004 20:20:03 -0700 Subject: [PATCH] [PATCH] expose backing dev max read-ahead 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. --- drivers/block/ll_rw_blk.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/block/ll_rw_blk.c b/drivers/block/ll_rw_blk.c index a7bd677b7a66f..f3c9c06656add 100644 --- a/drivers/block/ll_rw_blk.c +++ b/drivers/block/ll_rw_blk.c @@ -2997,14 +2997,41 @@ queue_requests_store(struct request_queue *q, const char *page, size_t count) 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, }; -- 2.53.0