lkml.org 
[lkml]   [2017]   [Dec]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH 5/5] blkcg: Add cgroup file to configure blkcg::blkg_aio_max_nr
From
Date
Add a file to configure per-cgroup maximum number of available
aio requests.

Allow write the values, which are less then currently allocated
numbers of requests.

Show numbers of currently allocated and maximum available requests.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
block/blk-cgroup.c | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 9cc6e9574946..dc5600ef4523 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -981,12 +981,52 @@ static int blkcg_print_stat(struct seq_file *sf, void *v)
return 0;
}

+#ifdef CONFIG_AIO
+static int blkcg_write_aio_max_nr(struct cgroup_subsys_state *css,
+ struct cftype *cftype, u64 val)
+{
+ struct blkcg *blkg = css_to_blkcg(css);
+ int ret = 0;
+
+ percpu_down_read(&cgroup_threadgroup_rwsem);
+ spin_lock(&aio_nr_lock);
+ if (val >= blkg->blkg_aio_nr)
+ blkg->blkg_aio_max_nr = val;
+ else
+ ret = -EBUSY;
+ spin_unlock(&aio_nr_lock);
+ percpu_up_read(&cgroup_threadgroup_rwsem);
+ return ret;
+}
+
+static int blkcg_show_aio_nrs(struct seq_file *sf, void *v)
+{
+ struct blkcg *blkg = css_to_blkcg(seq_css(sf));
+ unsigned long max_nr, nr;
+
+ spin_lock(&aio_nr_lock);
+ max_nr = blkg->blkg_aio_max_nr;
+ nr = blkg->blkg_aio_nr;
+ spin_unlock(&aio_nr_lock);
+
+ seq_printf(sf, "used=%lu, max=%lu\n", nr, max_nr);
+ return 0;
+}
+#endif /* CONFIG_AIO */
+
static struct cftype blkcg_files[] = {
{
.name = "stat",
.flags = CFTYPE_NOT_ON_ROOT,
.seq_show = blkcg_print_stat,
},
+#ifdef CONFIG_AIO
+ {
+ .name = "aio_nr",
+ .write_u64 = blkcg_write_aio_max_nr,
+ .seq_show = blkcg_show_aio_nrs,
+ },
+#endif
{ } /* terminate */
};

\
 
 \ /
  Last update: 2017-12-04 17:14    [W:0.140 / U:1.440 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site