• Tang Junhui's avatar
    bcache: return attach error when no cache set exist · 7f4fc93d
    Tang Junhui authored
    I attach a back-end device to a cache set, and the cache set is not
    registered yet, this back-end device did not attach successfully, and no
    error returned:
    [root]# echo 87859280-fec6-4bcc-20df7ca8f86b > /sys/block/sde/bcache/attach
    [root]#
    
    In sysfs_attach(), the return value "v" is initialized to "size" in
    the beginning, and if no cache set exist in bch_cache_sets, the "v" value
    would not change any more, and return to sysfs, sysfs regard it as success
    since the "size" is a positive number.
    
    This patch fixes this issue by assigning "v" with "-ENOENT" in the
    initialization.
    Signed-off-by: default avatarTang Junhui <tang.junhui@zte.com.cn>
    Reviewed-by: default avatarMichael Lyle <mlyle@lyle.org>
    Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
    7f4fc93d
sysfs.c 22.9 KB