]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
bcache: account size of buckets used in uuid write to ca->meta_sectors_written
authorShenghui Wang <shhuiw@foxmail.com>
Mon, 8 Oct 2018 12:41:07 +0000 (20:41 +0800)
committerJens Axboe <axboe@kernel.dk>
Mon, 8 Oct 2018 14:19:37 +0000 (08:19 -0600)
UUIDs are considered as metadata. __uuid_write should add the number
of buckets (in sectors) written to disk to ca->meta_sectors_written.
Currently only 1 bucket is used in uuid write.

Steps to test:
1) create a fresh backing device and a fresh cache device separately.
   The backing device didn't attach to any cache set.
2) cd /sys/block/<cache device>/bcache
   cat metadata_written      // record the output value
   cat bucket_size
3) attach the backing device to cache set
4) cat metadata_written
   The output value is almost the same as the value in step 2
   before the change.
   After the change, the value is bigger about 1 bucket size.

Signed-off-by: Shenghui Wang <shhuiw@foxmail.com>
Reviewed-by: Tang Junhui <tang.junhui.linux@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/md/bcache/super.c

index 30ba9aeb5ee8345ac192e34e51e67beae2127950..5fd1466b34e479b6eae00b3c43ef2d6f829984ff 100644 (file)
@@ -418,6 +418,7 @@ static int __uuid_write(struct cache_set *c)
 {
        BKEY_PADDED(key) k;
        struct closure cl;
+       struct cache *ca;
 
        closure_init_stack(&cl);
        lockdep_assert_held(&bch_register_lock);
@@ -429,6 +430,10 @@ static int __uuid_write(struct cache_set *c)
        uuid_io(c, REQ_OP_WRITE, 0, &k.key, &cl);
        closure_sync(&cl);
 
+       /* Only one bucket used for uuid write */
+       ca = PTR_CACHE(c, &k.key, 0);
+       atomic_long_add(ca->sb.bucket_size, &ca->meta_sectors_written);
+
        bkey_copy(&c->uuid_bucket, &k.key);
        bkey_put(c, &k.key);
        return 0;