• Coly Li's avatar
    bcache: use sysfs_strtoul_bool() to set bit-field variables · f5c0b95d
    Coly Li authored
    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: default avatarColy Li <colyli@suse.de>
    Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
    f5c0b95d
sysfs.c 26.6 KB