From: Coly Li <colyli@suse.de>
To: axboe@kernel.dk
Cc: linux-bcache@vger.kernel.org, linux-block@vger.kernel.org,
Coly Li <colyli@suse.de>
Subject: [PATCH 11/19] bcache: use sysfs_strtoul_bool() to set bit-field variables
Date: Sat, 9 Feb 2019 12:53:03 +0800 [thread overview]
Message-ID: <20190209045311.15677-12-colyli@suse.de> (raw)
In-Reply-To: <20190209045311.15677-1-colyli@suse.de>
When setting bcache parameters via sysfs, there are some variables are
defined as bit-field value. Current bcache code in sysfs.c uses either
d_strtoul() or sysfs_strtoul() to convert the input string to unsigned
integer value and set it to the corresponded bit-field value.
The problem is, the bit-field value only takes the lowest bit of the
converted value. If input is 2, the expected value (like bool value)
of the bit-field value should be 1, but indeed it is 0.
The following sysfs files for bit-field variables have such problem,
bypass_torture_test, for dc->bypass_torture_test
writeback_metadata, for dc->writeback_metadata
writeback_running, for dc->writeback_running
verify, for c->verify
key_merging_disabled, for c->key_merging_disabled
gc_always_rewrite, for c->gc_always_rewrite
btree_shrinker_disabled,for c->shrinker_disabled
copy_gc_enabled, for c->copy_gc_enabled
This patch uses sysfs_strtoul_bool() to set such bit-field variables,
then if the converted value is non-zero, the bit-field variables will
be set to 1, like setting a bool value like expensive_debug_checks.
Signed-off-by: Coly Li <colyli@suse.de>
---
drivers/md/bcache/sysfs.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c
index 96b64893f2cb..57395e23747a 100644
--- a/drivers/md/bcache/sysfs.c
+++ b/drivers/md/bcache/sysfs.c
@@ -277,9 +277,9 @@ STORE(__cached_dev)
sysfs_strtoul(data_csum, dc->disk.data_csum);
d_strtoul(verify);
- d_strtoul(bypass_torture_test);
- d_strtoul(writeback_metadata);
- d_strtoul(writeback_running);
+ sysfs_strtoul_bool(bypass_torture_test, dc->bypass_torture_test);
+ sysfs_strtoul_bool(writeback_metadata, dc->writeback_metadata);
+ sysfs_strtoul_bool(writeback_running, dc->writeback_running);
d_strtoul(writeback_delay);
sysfs_strtoul_clamp(writeback_percent, dc->writeback_percent,
@@ -816,12 +816,12 @@ STORE(__bch_cache_set)
}
sysfs_strtoul(journal_delay_ms, c->journal_delay_ms);
- sysfs_strtoul(verify, c->verify);
- sysfs_strtoul(key_merging_disabled, c->key_merging_disabled);
+ sysfs_strtoul_bool(verify, c->verify);
+ sysfs_strtoul_bool(key_merging_disabled, c->key_merging_disabled);
sysfs_strtoul(expensive_debug_checks, c->expensive_debug_checks);
- sysfs_strtoul(gc_always_rewrite, c->gc_always_rewrite);
- sysfs_strtoul(btree_shrinker_disabled, c->shrinker_disabled);
- sysfs_strtoul(copy_gc_enabled, c->copy_gc_enabled);
+ sysfs_strtoul_bool(gc_always_rewrite, c->gc_always_rewrite);
+ sysfs_strtoul_bool(btree_shrinker_disabled, c->shrinker_disabled);
+ sysfs_strtoul_bool(copy_gc_enabled, c->copy_gc_enabled);
/*
* write gc_after_writeback here may overwrite an already set
* BCH_DO_AUTO_GC, it doesn't matter because this flag will be
--
2.16.4
next prev parent reply other threads:[~2019-02-09 4:53 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-09 4:52 [PATCH 00/19] bcache patches for Linux v5.1 Coly Li
2019-02-09 4:52 ` [PATCH 01/19] bcache: never writeback a discard operation Coly Li
2019-02-09 4:52 ` [PATCH 02/19] bcache: not use hard coded memset size in bch_cache_accounting_clear() Coly Li
2019-02-09 4:52 ` [PATCH 03/19] bcache: export backing_dev_name via sysfs Coly Li
2019-02-09 4:52 ` [PATCH 04/19] bcache: export backing_dev_uuid " Coly Li
2019-02-09 4:52 ` [PATCH 05/19] bcache: fix indentation issue, remove tabs on a hunk of code Coly Li
2019-02-09 4:52 ` [PATCH 06/19] bcache: treat stale && dirty keys as bad keys Coly Li
[not found] ` <20190212132825.E476F217D9@mail.kernel.org>
2019-02-12 16:42 ` Coly Li
2019-02-09 4:52 ` [PATCH 07/19] bcache: improve sysfs_strtoul_clamp() Coly Li
2019-02-09 4:53 ` [PATCH 08/19] bcache: fix input integer overflow of congested threshold Coly Li
2019-02-09 4:53 ` [PATCH 09/19] bcache: fix input overflow to sequential_cutoff Coly Li
2019-02-09 4:53 ` [PATCH 10/19] bcache: add sysfs_strtoul_bool() for setting bit-field variables Coly Li
2019-02-09 4:53 ` Coly Li [this message]
2019-02-09 4:53 ` [PATCH 12/19] bcache: fix input overflow to writeback_delay Coly Li
2019-02-09 4:53 ` [PATCH 13/19] bcache: fix potential div-zero error of writeback_rate_i_term_inverse Coly Li
2019-02-09 4:53 ` [PATCH 14/19] bcache: fix potential div-zero error of writeback_rate_p_term_inverse Coly Li
2019-02-09 4:53 ` [PATCH 15/19] bcache: fix input overflow to writeback_rate_minimum Coly Li
2019-02-09 4:53 ` [PATCH 16/19] bcache: fix input overflow to journal_delay_ms Coly Li
2019-02-09 4:53 ` [PATCH 17/19] bcache: fix input overflow to cache set io_error_limit Coly Li
2019-02-09 4:53 ` [PATCH 18/19] bcache: fix input overflow to cache set sysfs file io_error_halflife Coly Li
2019-02-09 4:53 ` [PATCH 19/19] bcache: use (REQ_META|REQ_PRIO) to indicate bio for metadata Coly Li
[not found] ` <20190212132824.1D1502084E@mail.kernel.org>
2019-02-12 16:48 ` Coly Li
2019-02-09 14:19 ` [PATCH 00/19] bcache patches for Linux v5.1 Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190209045311.15677-12-colyli@suse.de \
--to=colyli@suse.de \
--cc=axboe@kernel.dk \
--cc=linux-bcache@vger.kernel.org \
--cc=linux-block@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).