aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColy Li <colyli@suse.de>2018-09-25 16:47:03 +0800
committerColy Li <colyli@suse.de>2018-09-25 16:47:03 +0800
commitf630bd4767a5b9f690745da7c49676784b0d1d0f (patch)
tree0f52130a76bb326454c19793c90341420620614c
parent2d2590857e4f299a6313e1dafaedd81a0844c849 (diff)
downloadbcache-patches-f630bd4767a5b9f690745da7c49676784b0d1d0f.tar.gz
for-next: add 0001-bcache-account-size-of-buckets-used-in-uuid-write-to.patch
-rw-r--r--for-next/0001-bcache-account-size-of-buckets-used-in-uuid-write-to.patch55
1 files changed, 55 insertions, 0 deletions
diff --git a/for-next/0001-bcache-account-size-of-buckets-used-in-uuid-write-to.patch b/for-next/0001-bcache-account-size-of-buckets-used-in-uuid-write-to.patch
new file mode 100644
index 0000000..4ddfa20
--- /dev/null
+++ b/for-next/0001-bcache-account-size-of-buckets-used-in-uuid-write-to.patch
@@ -0,0 +1,55 @@
+From 95fa937b67c5270496f8f0894c9abdf85e3cdbb1 Mon Sep 17 00:00:00 2001
+From: Shenghui Wang <shhuiw@foxmail.com>
+Date: Fri, 7 Sep 2018 18:40:40 +0800
+Subject: [PATCH] bcache: account size of buckets used in uuid write to
+ ca->meta_sectors_written
+
+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>
+---
+ drivers/md/bcache/super.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
+index 75620ab0c67b..bc6e057ad1bb 100644
+--- a/drivers/md/bcache/super.c
++++ b/drivers/md/bcache/super.c
+@@ -417,6 +417,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);
+@@ -428,6 +429,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;
+--
+2.18.0
+