summaryrefslogtreecommitdiff
path: root/drivers/lightnvm/pblk-sysfs.c
diff options
context:
space:
mode:
authorJavier González <jg@lightnvm.io>2017-06-26 12:57:14 +0300
committerJens Axboe <axboe@kernel.dk>2017-06-27 01:24:53 +0300
commitc2e9f5d457ad6a75516e749a3e544165766ab1ce (patch)
treec7d78f902aecf429b7b422fd0ba4d6b0c8807b9c /drivers/lightnvm/pblk-sysfs.c
parentdb7ada33cdcae7fef0a088141b1e4ab8c25fd395 (diff)
downloadlinux-c2e9f5d457ad6a75516e749a3e544165766ab1ce.tar.xz
lightnvm: pblk: expose max sec per write on sysfs
Allow to configure the number of maximum sectors per write command through sysfs. This makes it easier to tune write command sizes for different controller configurations. Signed-off-by: Javier González <javier@cnexlabs.com> Signed-off-by: Matias Bjørling <matias@cnexlabs.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/lightnvm/pblk-sysfs.c')
-rw-r--r--drivers/lightnvm/pblk-sysfs.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/drivers/lightnvm/pblk-sysfs.c b/drivers/lightnvm/pblk-sysfs.c
index 3c1a586c09a2..bf8fc6699299 100644
--- a/drivers/lightnvm/pblk-sysfs.c
+++ b/drivers/lightnvm/pblk-sysfs.c
@@ -290,6 +290,11 @@ static ssize_t pblk_sysfs_lines_info(struct pblk *pblk, char *page)
return sz;
}
+static ssize_t pblk_sysfs_get_sec_per_write(struct pblk *pblk, char *page)
+{
+ return snprintf(page, PAGE_SIZE, "%d\n", pblk->sec_per_write);
+}
+
#ifdef CONFIG_NVM_DEBUG
static ssize_t pblk_sysfs_stats_debug(struct pblk *pblk, char *page)
{
@@ -354,6 +359,29 @@ static ssize_t pblk_sysfs_gc_force(struct pblk *pblk, const char *page,
return len;
}
+static ssize_t pblk_sysfs_set_sec_per_write(struct pblk *pblk,
+ const char *page, size_t len)
+{
+ size_t c_len;
+ int sec_per_write;
+
+ c_len = strcspn(page, "\n");
+ if (c_len >= len)
+ return -EINVAL;
+
+ if (kstrtouint(page, 0, &sec_per_write))
+ return -EINVAL;
+
+ if (sec_per_write < pblk->min_write_pgs
+ || sec_per_write > pblk->max_write_pgs
+ || sec_per_write % pblk->min_write_pgs != 0)
+ return -EINVAL;
+
+ pblk_set_sec_per_write(pblk, sec_per_write);
+
+ return len;
+}
+
static struct attribute sys_write_luns = {
.name = "write_luns",
.mode = 0444,
@@ -399,6 +427,11 @@ static struct attribute sys_gc_force = {
.mode = 0200,
};
+static struct attribute sys_max_sec_per_write = {
+ .name = "max_sec_per_write",
+ .mode = 0644,
+};
+
static struct attribute sys_gc_rl_max = {
.name = "gc_rl_max",
.mode = 0200,
@@ -417,6 +450,7 @@ static struct attribute *pblk_attrs[] = {
&sys_errors_attr,
&sys_gc_state,
&sys_gc_force,
+ &sys_max_sec_per_write,
&sys_gc_rl_max,
&sys_rb_attr,
&sys_stats_ppaf_attr,
@@ -449,6 +483,8 @@ static ssize_t pblk_sysfs_show(struct kobject *kobj, struct attribute *attr,
return pblk_sysfs_lines(pblk, buf);
else if (strcmp(attr->name, "lines_info") == 0)
return pblk_sysfs_lines_info(pblk, buf);
+ else if (strcmp(attr->name, "max_sec_per_write") == 0)
+ return pblk_sysfs_get_sec_per_write(pblk, buf);
#ifdef CONFIG_NVM_DEBUG
else if (strcmp(attr->name, "stats") == 0)
return pblk_sysfs_stats_debug(pblk, buf);
@@ -465,6 +501,8 @@ static ssize_t pblk_sysfs_store(struct kobject *kobj, struct attribute *attr,
return pblk_sysfs_rate_store(pblk, buf, len);
else if (strcmp(attr->name, "gc_force") == 0)
return pblk_sysfs_gc_force(pblk, buf, len);
+ else if (strcmp(attr->name, "max_sec_per_write") == 0)
+ return pblk_sysfs_set_sec_per_write(pblk, buf, len);
return 0;
}