bcache: fix incorrect sysfs output value of strip size
authorTang Junhui <tang.junhui@zte.com.cn>
Mon, 19 Mar 2018 00:36:20 +0000 (17:36 -0700)
committerJens Axboe <axboe@kernel.dk>
Mon, 19 Mar 2018 02:15:20 +0000 (20:15 -0600)
Stripe size is shown as zero when no strip in back end device:
[root@ceph132 ~]# cat /sys/block/sdd/bcache/stripe_size
0.0k

Actually it should be 1T Bytes (1 << 31 sectors), but in sysfs
interface, stripe_size was changed from sectors to bytes, and move
9 bits left, so the 32 bits variable overflows.

This patch change the variable to a 64 bits type before moving bits.

Signed-off-by: Tang Junhui <tang.junhui@zte.com.cn>
Reviewed-by: Michael Lyle <mlyle@lyle.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/md/bcache/sysfs.c

index 414129f7c49f5662ef8a1ad3b5dc3fb4b016533c..8c3fd05db87af56b49b50486e2f9b798b53eed8c 100644 (file)
@@ -181,7 +181,7 @@ SHOW(__bch_cached_dev)
        sysfs_hprint(dirty_data,
                     bcache_dev_sectors_dirty(&dc->disk) << 9);
 
-       sysfs_hprint(stripe_size,       dc->disk.stripe_size << 9);
+       sysfs_hprint(stripe_size,        ((uint64_t)dc->disk.stripe_size) << 9);
        var_printf(partial_stripes_expensive,   "%u");
 
        var_hprint(sequential_cutoff);