diff options
author | Coly Li <colyli@suse.de> | 2020-08-15 12:37:19 +0800 |
---|---|---|
committer | Coly Li <colyli@suse.de> | 2020-08-15 12:37:19 +0800 |
commit | 78ba4e4981265a8f43497a5c9898abb3d85dfd2a (patch) | |
tree | 348451fe3580f244244032b286d21e5dadc23269 | |
parent | da275f71e25c285fb9bea8b548f5639e8908f85b (diff) | |
download | bcache-patches-78ba4e4981265a8f43497a5c9898abb3d85dfd2a.tar.gz |
for-test:
- update remove-multiple-cache-devices/single-cache-in-cache-set/
- remove already merged or dropped patches
24 files changed, 82 insertions, 659 deletions
diff --git a/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/0000-cover-letter.patch b/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/0000-cover-letter.patch index 8fec3cf..8b05636 100644 --- a/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/0000-cover-letter.patch +++ b/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/0000-cover-letter.patch @@ -1,13 +1,42 @@ From 3821a8cd1196fdf155605f0747b1a9d4bf6d8cff Mon Sep 17 00:00:00 2001 From: Coly Li <colyli@suse.de> Date: Sat, 15 Aug 2020 00:55:48 +0800 -Subject: [PATCH 00/14] *** SUBJECT HERE *** +Subject: [PATCH 00/14] bcache: remove multiple caches code framework -*** BLURB HERE *** +The multiple caches code framework in bcache is to store multiple +copies of the cached data among multiple caches of the cache set. +Current code framework just does simple data write to each cache without +any extra condition handling (e.g. device failure, slow devices). This +code framework is not and will never be completed. Considering people +may use md raid1 for same similar data duplication purpose, the multiple +caches framework is useless dead code indeed. + +Due to the multiple caches code framework, bcache has two data structure +struct cache and struct cache_set to manage the cache device. Indeed +since bcache was merged into mainline kernel in Linux v3.10, a cache set +only has one cache, the unnecessary two level abstraction makes extra +effort to maintain redundant information between struct cache and struct +cache set, for examaple the in-memmory super block struct cache_sb. + +This is the first wave effort to remove multiple caches framework and +make the code and data structure relation to be more clear. This series +explicitly make each cache set only have single cache, and remove the +embedded partial super block in struct cache_set and directly reference +cache's in-memory super block, finally move struct cache_sb from +include/uapi/linux/bcache.h to drivers/md/bcache/bcache.h since it isn't +part of uapi anymore. + +The patch set is just compiling passed, I post this series early for +your review and comments. More fixes after testing will follow up soon. + +Thanks in advance. + +Coly Li +---- Coly Li (14): bcache: remove 'int n' from parameter list of bch_bucket_alloc_set() - bcache: explictly make cache_set only have single cache + bcache: explicitly make cache_set only have single cache bcache: remove for_each_cache() bcache: add set_uuid in struct cache_set bcache: only use block_bytes() on struct cache diff --git a/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/0001-bcache-remove-int-n-from-parameter-list-of-bch_bucke.patch b/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/v1-0001-bcache-remove-int-n-from-parameter-list-of-bch_bu.patch index 9685be9..d55c183 100644 --- a/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/0001-bcache-remove-int-n-from-parameter-list-of-bch_bucke.patch +++ b/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/v1-0001-bcache-remove-int-n-from-parameter-list-of-bch_bu.patch @@ -1,7 +1,7 @@ -From d10dd49dc5c8f45bfb3e2dff9a14c36b314360ed Mon Sep 17 00:00:00 2001 +From 9260c7e003b7652c9a8208fa479ff4c5d72a6737 Mon Sep 17 00:00:00 2001 From: Coly Li <colyli@suse.de> Date: Fri, 14 Aug 2020 00:07:05 +0800 -Subject: [PATCH 01/14] bcache: remove 'int n' from parameter list of +Subject: [PATCH v1 01/14] bcache: remove 'int n' from parameter list of bch_bucket_alloc_set() The parameter 'int n' from bch_bucket_alloc_set() is not cleared diff --git a/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/0002-bcache-explictly-make-cache_set-only-have-single-cac.patch b/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/v1-0002-bcache-explicitly-make-cache_set-only-have-single.patch index 66ebff3..89c492c 100644 --- a/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/0002-bcache-explictly-make-cache_set-only-have-single-cac.patch +++ b/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/v1-0002-bcache-explicitly-make-cache_set-only-have-single.patch @@ -1,7 +1,8 @@ -From e250a7b1b72a05d3a8f085ae26101a6330c559ba Mon Sep 17 00:00:00 2001 +From da9ff41f507337ce4797935e8ba9b70da361d59d Mon Sep 17 00:00:00 2001 From: Coly Li <colyli@suse.de> Date: Fri, 14 Aug 2020 00:30:59 +0800 -Subject: [PATCH 02/14] bcache: explictly make cache_set only have single cache +Subject: [PATCH v1 02/14] bcache: explicitly make cache_set only have single + cache Currently although the bcache code has a framework for multiple caches in a cache set, but indeed the multiple caches never completed and users diff --git a/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/0003-bcache-remove-for_each_cache.patch b/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/v1-0003-bcache-remove-for_each_cache.patch index 5eef482..2968637 100644 --- a/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/0003-bcache-remove-for_each_cache.patch +++ b/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/v1-0003-bcache-remove-for_each_cache.patch @@ -1,7 +1,7 @@ -From 2a2cc128cca72b9d0784968f264c31e435b558f5 Mon Sep 17 00:00:00 2001 +From 50516df3a606a49a170bb14e26ed595aff4c84d0 Mon Sep 17 00:00:00 2001 From: Coly Li <colyli@suse.de> Date: Fri, 14 Aug 2020 01:26:09 +0800 -Subject: [PATCH 03/14] bcache: remove for_each_cache() +Subject: [PATCH v1 03/14] bcache: remove for_each_cache() Since now each cache_set explicitly has single cache, for_each_cache() is unnecessary. This patch removes this macro, and update all locations @@ -14,8 +14,8 @@ Signed-off-by: Coly Li <colyli@suse.de> drivers/md/bcache/btree.c | 103 +++++++--------- drivers/md/bcache/journal.c | 229 ++++++++++++++++------------------- drivers/md/bcache/movinggc.c | 58 +++++---- - drivers/md/bcache/super.c | 114 +++++++---------- - 6 files changed, 236 insertions(+), 294 deletions(-) + drivers/md/bcache/super.c | 115 ++++++++---------- + 6 files changed, 237 insertions(+), 294 deletions(-) diff --git a/drivers/md/bcache/alloc.c b/drivers/md/bcache/alloc.c index 3385f6add6df..1b8310992dd0 100644 @@ -657,7 +657,7 @@ index 5872d6470470..b9c3d27ec093 100644 c->moving_gc_keys.last_scanned = ZERO_KEY; diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c -index e9ccfa17beb8..2521be9380d6 100644 +index e9ccfa17beb8..91883d5c4b62 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -343,8 +343,9 @@ static void bcache_write_super_unlock(struct closure *cl) @@ -836,11 +836,11 @@ index e9ccfa17beb8..2521be9380d6 100644 goto err; } else { - pr_notice("invalidating existing data\n"); -+ unsigned int j; - +- - for_each_cache(ca, c, i) { - unsigned int j; -- ++ unsigned int j; + - ca->sb.keys = clamp_t(int, ca->sb.nbuckets >> 7, - 2, SB_JOURNAL_BUCKETS); + pr_notice("invalidating existing data\n"); @@ -869,7 +869,7 @@ index e9ccfa17beb8..2521be9380d6 100644 mutex_unlock(&c->bucket_lock); err = "cannot allocate new UUID bucket"; -@@ -2467,13 +2447,13 @@ static bool bch_is_open_backing(struct block_device *bdev) +@@ -2467,13 +2447,14 @@ static bool bch_is_open_backing(struct block_device *bdev) static bool bch_is_open_cache(struct block_device *bdev) { struct cache_set *c, *tc; @@ -882,6 +882,7 @@ index e9ccfa17beb8..2521be9380d6 100644 - return true; + list_for_each_entry_safe(c, tc, &bch_cache_sets, list) { + struct cache *ca = c->cache; ++ + if (ca->bdev == bdev) + return true; + } diff --git a/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/0004-bcache-add-set_uuid-in-struct-cache_set.patch b/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/v1-0004-bcache-add-set_uuid-in-struct-cache_set.patch index 2cc2238..a735c3d 100644 --- a/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/0004-bcache-add-set_uuid-in-struct-cache_set.patch +++ b/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/v1-0004-bcache-add-set_uuid-in-struct-cache_set.patch @@ -1,11 +1,11 @@ -From 3a40d904a9fd6946284c9b4ec157e9cbe0ac751e Mon Sep 17 00:00:00 2001 +From 5f709f50fb5302b446ab136dd4673a68051b9299 Mon Sep 17 00:00:00 2001 From: Coly Li <colyli@suse.de> Date: Fri, 14 Aug 2020 20:12:07 +0800 -Subject: [PATCH 04/14] bcache: add set_uuid in struct cache_set +Subject: [PATCH v1 04/14] bcache: add set_uuid in struct cache_set This patch adds a separated set_uuid[16] in struct cache_set, to store -the uuid of the cache set. This is the preparation to remove the embeded -struct cache_sb from struct cache_set. +the uuid of the cache set. This is the preparation to remove the +embedded struct cache_sb from struct cache_set. Signed-off-by: Coly Li <colyli@suse.de> --- @@ -41,7 +41,7 @@ index 336f43910383..0ccc1b0baa42 100644 &cache_set_debug_ops); } diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c -index 2521be9380d6..77f5673adbbc 100644 +index 91883d5c4b62..90a419ad6445 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -1189,8 +1189,8 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c, @@ -136,7 +136,7 @@ index 2521be9380d6..77f5673adbbc 100644 c->sb.flags = ca->sb.flags; c->sb.seq = ca->sb.seq; pr_debug("set version = %llu\n", c->sb.version); -@@ -2697,7 +2697,7 @@ static ssize_t bch_pending_bdevs_cleanup(struct kobject *k, +@@ -2698,7 +2698,7 @@ static ssize_t bch_pending_bdevs_cleanup(struct kobject *k, list_for_each_entry_safe(pdev, tpdev, &pending_devs, list) { list_for_each_entry_safe(c, tc, &bch_cache_sets, list) { char *pdev_set_uuid = pdev->dc->sb.set_uuid; diff --git a/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/0005-bcache-only-use-block_bytes-on-struct-cache.patch b/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/v1-0005-bcache-only-use-block_bytes-on-struct-cache.patch index ab4564b..b814ca7 100644 --- a/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/0005-bcache-only-use-block_bytes-on-struct-cache.patch +++ b/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/v1-0005-bcache-only-use-block_bytes-on-struct-cache.patch @@ -1,7 +1,7 @@ -From 33d50b1efdde6a712ea58356de757085fdf3fb97 Mon Sep 17 00:00:00 2001 +From 178fa57c56550568bf0d4140d8dc689cc6c11682 Mon Sep 17 00:00:00 2001 From: Coly Li <colyli@suse.de> Date: Fri, 14 Aug 2020 21:25:58 +0800 -Subject: [PATCH 05/14] bcache: only use block_bytes() on struct cache +Subject: [PATCH v1 05/14] bcache: only use block_bytes() on struct cache Because struct cache_set and struct cache both have struct cache_sb, therefore macro block_bytes() can be used on both of them. When removing @@ -227,7 +227,7 @@ index c7cadaafa947..02408fdbf5bb 100644 return __bch_keylist_realloc(l, u64s); diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c -index 77f5673adbbc..5636648902e3 100644 +index 90a419ad6445..36a538c2e960 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -1528,7 +1528,7 @@ static int flash_dev_run(struct cache_set *c, struct uuid_entry *u) diff --git a/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/0006-bcache-remove-useless-alloc_bucket_pages.patch b/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/v1-0006-bcache-remove-useless-alloc_bucket_pages.patch index ec0fcbe..2057ff6 100644 --- a/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/0006-bcache-remove-useless-alloc_bucket_pages.patch +++ b/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/v1-0006-bcache-remove-useless-alloc_bucket_pages.patch @@ -1,7 +1,7 @@ -From f6600e5eb379e70ec360f241b8e475081be5d00d Mon Sep 17 00:00:00 2001 +From 811f8198f1d5337729bbd855bf0e381e60eeeca3 Mon Sep 17 00:00:00 2001 From: Coly Li <colyli@suse.de> Date: Fri, 14 Aug 2020 21:28:23 +0800 -Subject: [PATCH 06/14] bcache: remove useless alloc_bucket_pages() +Subject: [PATCH v1 06/14] bcache: remove useless alloc_bucket_pages() Now no one uses alloc_bucket_pages() anymore, remove it from bcache.h. @@ -11,7 +11,7 @@ Signed-off-by: Coly Li <colyli@suse.de> 1 file changed, 3 deletions(-) diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c -index 5636648902e3..748b08ab4f11 100644 +index 36a538c2e960..28257f11d835 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -1832,9 +1832,6 @@ void bch_cache_set_unregister(struct cache_set *c) diff --git a/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/0007-bcache-remove-useless-bucket_pages.patch b/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/v1-0007-bcache-remove-useless-bucket_pages.patch index a6f7cbe..b7b40a9 100644 --- a/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/0007-bcache-remove-useless-bucket_pages.patch +++ b/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/v1-0007-bcache-remove-useless-bucket_pages.patch @@ -1,7 +1,7 @@ -From 003f48b7181ba8502b496953d888d958acecaa7d Mon Sep 17 00:00:00 2001 +From a34562e8f936f77d726fcd94746a467db5f2bf04 Mon Sep 17 00:00:00 2001 From: Coly Li <colyli@suse.de> Date: Fri, 14 Aug 2020 21:15:28 +0800 -Subject: [PATCH 07/14] bcache: remove useless bucket_pages() +Subject: [PATCH v1 07/14] bcache: remove useless bucket_pages() It seems alloc_bucket_pages() is the only user of bucket_pages(). Considering alloc_bucket_pages() is removed from bcache code, it is safe diff --git a/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/0008-bcache-only-use-bucket_bytes-on-struct-cache.patch b/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/v1-0008-bcache-only-use-bucket_bytes-on-struct-cache.patch index 474ba05..225cd5e 100644 --- a/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/0008-bcache-only-use-bucket_bytes-on-struct-cache.patch +++ b/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/v1-0008-bcache-only-use-bucket_bytes-on-struct-cache.patch @@ -1,7 +1,7 @@ -From a82c66c4838aeb8843a79c341fedcd071a7cc19c Mon Sep 17 00:00:00 2001 +From 964012dfcb5e4ae91630c5d92b51cfba698dc41d Mon Sep 17 00:00:00 2001 From: Coly Li <colyli@suse.de> Date: Fri, 14 Aug 2020 21:20:48 +0800 -Subject: [PATCH 08/14] bcache: only use bucket_bytes() on struct cache +Subject: [PATCH v1 08/14] bcache: only use bucket_bytes() on struct cache Because struct cache_set and struct cache both have struct cache_sb, macro bucket_bytes() currently are used on both of them. When removing diff --git a/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/0009-bcache-avoid-data-copy-between-cache_set-sb-and-cach.patch b/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/v1-0009-bcache-avoid-data-copy-between-cache_set-sb-and-c.patch index c916c5f..f0f0dcc 100644 --- a/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/0009-bcache-avoid-data-copy-between-cache_set-sb-and-cach.patch +++ b/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/v1-0009-bcache-avoid-data-copy-between-cache_set-sb-and-c.patch @@ -1,7 +1,7 @@ -From f0536de0e64929dfd0012937218ffce243d63313 Mon Sep 17 00:00:00 2001 +From 78c5a3367fe79f81efa030ef2cb2fc171009fc14 Mon Sep 17 00:00:00 2001 From: Coly Li <colyli@suse.de> Date: Fri, 14 Aug 2020 23:18:45 +0800 -Subject: [PATCH 09/14] bcache: avoid data copy between cache_set->sb and +Subject: [PATCH v1 09/14] bcache: avoid data copy between cache_set->sb and cache->sb struct cache_sb embedded in struct cache_set is only partial used and @@ -21,7 +21,7 @@ Signed-off-by: Coly Li <colyli@suse.de> 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c -index 748b08ab4f11..05c5a7e867bb 100644 +index 28257f11d835..20de004ab2ef 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -350,16 +350,10 @@ void bcache_write_super(struct cache_set *c) diff --git a/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/0010-bcache-don-t-check-seq-numbers-in-register_cache_set.patch b/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/v1-0010-bcache-don-t-check-seq-numbers-in-register_cache_.patch index eca2d72..a00c7ad 100644 --- a/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/0010-bcache-don-t-check-seq-numbers-in-register_cache_set.patch +++ b/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/v1-0010-bcache-don-t-check-seq-numbers-in-register_cache_.patch @@ -1,7 +1,8 @@ -From d9374567ee4b1e541a4492c4164acc75139824c3 Mon Sep 17 00:00:00 2001 +From 754956b7956b6c08c1d8e3eab0a2bda29e220115 Mon Sep 17 00:00:00 2001 From: Coly Li <colyli@suse.de> Date: Fri, 14 Aug 2020 23:28:26 +0800 -Subject: [PATCH 10/14] bcache: don't check seq numbers in register_cache_set() +Subject: [PATCH v1 10/14] bcache: don't check seq numbers in + register_cache_set() In order to update the partial super block of cache set, the seq numbers of cache and cache set are checked in register_cache_set(). If cache's @@ -21,7 +22,7 @@ Signed-off-by: Coly Li <colyli@suse.de> 1 file changed, 15 deletions(-) diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c -index 05c5a7e867bb..4ba713d0d9b0 100644 +index 20de004ab2ef..cdc1ebee5044 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -2160,21 +2160,6 @@ static const char *register_cache_set(struct cache *ca) diff --git a/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/0011-bcache-remove-can_attach_cache.patch b/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/v1-0011-bcache-remove-can_attach_cache.patch index 534bd35..fac8321 100644 --- a/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/0011-bcache-remove-can_attach_cache.patch +++ b/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/v1-0011-bcache-remove-can_attach_cache.patch @@ -1,7 +1,7 @@ -From 5b2afd6c546f00c7debacfadbeb994450c03ae20 Mon Sep 17 00:00:00 2001 +From aeb61b8c57e542123d0082054e6a65f10848a6f1 Mon Sep 17 00:00:00 2001 From: Coly Li <colyli@suse.de> Date: Fri, 14 Aug 2020 23:36:56 +0800 -Subject: [PATCH 11/14] bcache: remove can_attach_cache() +Subject: [PATCH v1 11/14] bcache: remove can_attach_cache() After removing the embedded struct cache_sb from struct cache_set, cache set will directly reference the in-memory super block of struct cache. @@ -17,7 +17,7 @@ Signed-off-by: Coly Li <colyli@suse.de> 1 file changed, 10 deletions(-) diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c -index 4ba713d0d9b0..a2bba78d78e6 100644 +index cdc1ebee5044..80cfb9dfe93e 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -2112,13 +2112,6 @@ static int run_cache_set(struct cache_set *c) diff --git a/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/0012-bcache-check-and-set-sync-status-on-cache-s-in-memor.patch b/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/v1-0012-bcache-check-and-set-sync-status-on-cache-s-in-me.patch index ea5c2c2..96bc7c8 100644 --- a/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/0012-bcache-check-and-set-sync-status-on-cache-s-in-memor.patch +++ b/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/v1-0012-bcache-check-and-set-sync-status-on-cache-s-in-me.patch @@ -1,8 +1,8 @@ -From e099c198deb5d1f2d57e2cd6f29005848260e639 Mon Sep 17 00:00:00 2001 +From 9cbec8384422a47b76db64bfe880e1224893c193 Mon Sep 17 00:00:00 2001 From: Coly Li <colyli@suse.de> Date: Fri, 14 Aug 2020 23:53:52 +0800 -Subject: [PATCH 12/14] bcache: check and set sync status on cache's in-memory - super block +Subject: [PATCH v1 12/14] bcache: check and set sync status on cache's + in-memory super block Currently the cache's sync status is checked and set on cache set's in- memory partial super block. After removing the embedded struct cache_sb @@ -49,7 +49,7 @@ index ccd5de0ab0fe..e2810668ede3 100644 w = journal_wait_for_write(c, bch_keylist_nkeys(keys)); diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c -index a2bba78d78e6..68563ee92393 100644 +index 80cfb9dfe93e..6b94b396f9e9 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -1954,7 +1954,7 @@ static int run_cache_set(struct cache_set *c) diff --git a/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/0013-bcache-remove-embedded-struct-cache_sb-from-struct-c.patch b/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/v1-0013-bcache-remove-embedded-struct-cache_sb-from-struc.patch index b31995b..693f0d0 100644 --- a/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/0013-bcache-remove-embedded-struct-cache_sb-from-struct-c.patch +++ b/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/v1-0013-bcache-remove-embedded-struct-cache_sb-from-struc.patch @@ -1,7 +1,7 @@ -From a2d4d81f595e1dd4d35e34823778a31d57b745f8 Mon Sep 17 00:00:00 2001 +From ae87df3f4f9278077ba811bd6ddc4389edd807dd Mon Sep 17 00:00:00 2001 From: Coly Li <colyli@suse.de> Date: Sat, 15 Aug 2020 00:20:00 +0800 -Subject: [PATCH 13/14] bcache: remove embedded struct cache_sb from struct +Subject: [PATCH v1 13/14] bcache: remove embedded struct cache_sb from struct cache_set Since bcache code was merged into mainline kerrnel, each cache set only @@ -312,7 +312,7 @@ index 02408fdbf5bb..37e9cf8dbfc1 100644 goto skip; } diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c -index 68563ee92393..698a0de9170f 100644 +index 6b94b396f9e9..e03676e1b370 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -471,7 +471,7 @@ static int __uuid_write(struct cache_set *c) diff --git a/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/0014-bcache-move-struct-cache_sb-out-of-uapi-bcache.h.patch b/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/v1-0014-bcache-move-struct-cache_sb-out-of-uapi-bcache.h.patch index 7a9e853..f2597c4 100644 --- a/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/0014-bcache-move-struct-cache_sb-out-of-uapi-bcache.h.patch +++ b/for-test/remove-multiple-cache-devices/single-cache-in-cache-set/v1-0014-bcache-move-struct-cache_sb-out-of-uapi-bcache.h.patch @@ -1,7 +1,7 @@ -From 3821a8cd1196fdf155605f0747b1a9d4bf6d8cff Mon Sep 17 00:00:00 2001 +From df40e8c0d6f09a9d6216e7ba3bb100b4d8ac8634 Mon Sep 17 00:00:00 2001 From: Coly Li <colyli@suse.de> Date: Sat, 15 Aug 2020 00:49:17 +0800 -Subject: [PATCH 14/14] bcache: move struct cache_sb out of uapi bcache.h +Subject: [PATCH v1 14/14] bcache: move struct cache_sb out of uapi bcache.h struct cache_sb does not exactly map to cache_sb_disk, it is only for in-memory super block and dosn't belong to uapi bcache.h. diff --git a/for-test/zoned_device/block-changes/v1/0001-block-change-REQ_OP_ZONE_RESET-from-6-to-13.patch b/for-test/zoned_device/block-changes/v1/0001-block-change-REQ_OP_ZONE_RESET-from-6-to-13.patch deleted file mode 100644 index 72a0cc1..0000000 --- a/for-test/zoned_device/block-changes/v1/0001-block-change-REQ_OP_ZONE_RESET-from-6-to-13.patch +++ /dev/null @@ -1,67 +0,0 @@ -From 6d23e843fa6bef7854e2189e19967361b5bc5991 Mon Sep 17 00:00:00 2001 -From: Coly Li <colyli@suse.de> -Date: Fri, 15 May 2020 19:59:04 +0800 -Subject: [PATCH 1/4] block: change REQ_OP_ZONE_RESET from 6 to 13 - -For a zoned device, e.g. host managed SMR hard drive, REQ_OP_ZONE_RESET -is to reset the LBA of a zone's write pointer back to the start LBA of -this zone. After the write point is reset, all previously stored data -in this zone is invalid and unaccessible anymore. Therefore, this op -code changes on disk data, belongs to a WRITE request op code. - -Current REQ_OP_ZONE_RESET is defined as number 6, but the convention of -the op code is, READ requests are even numbers, and WRITE requests are -odd numbers. See how op_is_write defined, - -397 static inline bool op_is_write(unsigned int op) -398 { -399 return (op & 1); -400 } - -When create bcache device on top of the zoned SMR drive, bcache driver -has to handle the REQ_OP_ZONE_RESET bio by invalidate all cached data -belongs to the LBA range of the restting zone. A wrong op code value -will make the this zone management bio goes into bcache' read requests -code path and causes undefined result. - -This patch changes REQ_OP_ZONE_RESET value from 6 to 13, the new odd -number will make bcache driver handle this zone management bio properly -in write requests code path. - -Fixes: 87374179c535 ("block: add a proper block layer data direction encoding") -Signed-off-by: Coly Li <colyli@suse.de> -Cc: Christoph Hellwig <hch@lst.de> -Cc: Damien Le Moal <damien.lemoal@wdc.com> -Cc: Hannes Reinecke <hare@suse.de> -Cc: Jens Axboe <axboe@fb.com> -Cc: Johannes Thumshirn <johannes.thumshirn@wdc.com> -Cc: Shaun Tancheff <shaun.tancheff@seagate.com> ---- - include/linux/blk_types.h | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h -index 31eb92876be7..8f7bc15a6de3 100644 ---- a/include/linux/blk_types.h -+++ b/include/linux/blk_types.h -@@ -282,8 +282,6 @@ enum req_opf { - REQ_OP_DISCARD = 3, - /* securely erase sectors */ - REQ_OP_SECURE_ERASE = 5, -- /* reset a zone write pointer */ -- REQ_OP_ZONE_RESET = 6, - /* write the same sector many times */ - REQ_OP_WRITE_SAME = 7, - /* reset all the zone present on the device */ -@@ -296,6 +294,8 @@ enum req_opf { - REQ_OP_ZONE_CLOSE = 11, - /* Transition a zone to full */ - REQ_OP_ZONE_FINISH = 12, -+ /* reset a zone write pointer */ -+ REQ_OP_ZONE_RESET = 13, - - /* SCSI passthrough using struct scsi_request */ - REQ_OP_SCSI_IN = 32, --- -2.25.0 - diff --git a/for-test/zoned_device/block-changes/v1/0002-block-block-change-REQ_OP_ZONE_RESET_ALL-from-8-to-1.patch b/for-test/zoned_device/block-changes/v1/0002-block-block-change-REQ_OP_ZONE_RESET_ALL-from-8-to-1.patch deleted file mode 100644 index ade3f82..0000000 --- a/for-test/zoned_device/block-changes/v1/0002-block-block-change-REQ_OP_ZONE_RESET_ALL-from-8-to-1.patch +++ /dev/null @@ -1,67 +0,0 @@ -From 1fa544f465eb82bbf5aafc1a9f7218d959315b64 Mon Sep 17 00:00:00 2001 -From: Coly Li <colyli@suse.de> -Date: Fri, 15 May 2020 20:35:36 +0800 -Subject: [PATCH 2/4] block: block: change REQ_OP_ZONE_RESET_ALL from 8 to 15 - -For a zoned device, e.g. host managed SMR hard drive, the request op -REQ_OP_ZONE_RESET_ALL is to reset LBA of all zones' writer pointers to -the start LBA of the zone they belong to. After all the write pointers -are reset, all previously stored data is invalid and unaccessible. -Therefore this op code changes on-disk data, belongs to WRITE request -op code. - -Similar to the problem of REQ_OP_ZONE_RESET, REQ_OP_ZONE_RESET_ALL is -even number 8, it means bios with REQ_OP_ZONE_RESET_ALL in bio->bi_opf -will be treated as READ request by op_is_write(). - -Same problem will happen when bcache device is created on top of zoned -device like host managed SMR hard drive, bcache driver should invalid -all cached data for the REQ_OP_ZONE_RESET_ALL request, but this zone -management bio is mistakenly treated as READ request and go into bcache -read code path, which will cause undefined behavior. - -This patch changes REQ_OP_ZONE_RESET_ALL value from 8 to 15, this new -odd number will make bcache driver handle this zone management bio in -write request code path properly. - -Fixes: e84e8f066395 ("block: add req op to reset all zones and flag") -Signed-off-by: Coly Li <colyli@suse.de> -Cc: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> -Cc: Damien Le Moal <damien.lemoal@wdc.com> -Cc: Hannes Reinecke <hare@suse.com> -Cc: Jens Axboe <axboe@kernel.dk> -Cc: Johannes Thumshirn <johannes.thumshirn@wdc.com> -Cc: Keith Busch <kbusch@kernel.org> ---- -Changelog: -v2: Fix typo for REQ_OP_ZONE_RESET_ALL. -v1: initial version. - - include/linux/blk_types.h | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h -index 8f7bc15a6de3..618032fa1b29 100644 ---- a/include/linux/blk_types.h -+++ b/include/linux/blk_types.h -@@ -284,8 +284,6 @@ enum req_opf { - REQ_OP_SECURE_ERASE = 5, - /* write the same sector many times */ - REQ_OP_WRITE_SAME = 7, -- /* reset all the zone present on the device */ -- REQ_OP_ZONE_RESET_ALL = 8, - /* write the zero filled sector many times */ - REQ_OP_WRITE_ZEROES = 9, - /* Open a zone */ -@@ -296,6 +294,8 @@ enum req_opf { - REQ_OP_ZONE_FINISH = 12, - /* reset a zone write pointer */ - REQ_OP_ZONE_RESET = 13, -+ /* reset all the zone present on the device */ -+ REQ_OP_ZONE_RESET_ALL = 15, - - /* SCSI passthrough using struct scsi_request */ - REQ_OP_SCSI_IN = 32, --- -2.25.0 - diff --git a/for-test/zoned_device/block-changes/v1/0003-block-remove-queue_is_mq-restriction-from-blk_revali.patch b/for-test/zoned_device/block-changes/v1/0003-block-remove-queue_is_mq-restriction-from-blk_revali.patch deleted file mode 100644 index 779e079..0000000 --- a/for-test/zoned_device/block-changes/v1/0003-block-remove-queue_is_mq-restriction-from-blk_revali.patch +++ /dev/null @@ -1,55 +0,0 @@ -From 3874617e24c2a7d7925590318496a567a69e6ad6 Mon Sep 17 00:00:00 2001 -From: Coly Li <colyli@suse.de> -Date: Thu, 14 May 2020 14:32:31 +0800 -Subject: [PATCH 3/4] block: remove queue_is_mq restriction from - blk_revalidate_disk_zones() - -The bcache driver is bio based and NOT request based multiqueued driver, -if a zoned SMR hard drive is used as backing device of a bcache device, -calling blk_revalidate_disk_zones() for the bcache device will fail due -to the following check in blk_revalidate_disk_zones(), -478 if (WARN_ON_ONCE(!queue_is_mq(q))) -479 return -EIO; - -Now bcache is able to export the zoned information from the underlying -zoned SMR drives and format zonefs on top of a bcache device, the -resitriction that a zoned device should be multiqueued is unnecessary -for now. - -Although in commit ae58954d8734c ("block: don't handle bio based drivers -in blk_revalidate_disk_zones") it is said that bio based drivers should -not call blk_revalidate_disk_zones() and just manually update their own -q->nr_zones, but this is inaccurate. The bio based drivers also need to -set their zone size and initialize bitmaps for cnv and seq zones, it is -necessary to call blk_revalidate_disk_zones() for bio based drivers. - -This patch removes the above queue_is_mq() restriction to permit -bcache driver calls blk_revalidate_disk_zones() for bcache device zoned -information initialization. - -Fixes: ae58954d8734c ("block: don't handle bio based drivers in blk_revalidate_disk_zones") -Signed-off-by: Coly Li <colyli@suse.de> -Cc: Christoph Hellwig <hch@lst.de> -Cc: Damien Le Moal <damien.lemoal@wdc.com> -Cc: Hannes Reinecke <hare@suse.com> -Cc: Jens Axboe <axboe@kernel.dk> ---- - block/blk-zoned.c | 2 -- - 1 file changed, 2 deletions(-) - -diff --git a/block/blk-zoned.c b/block/blk-zoned.c -index f87956e0dcaf..1e0708c68267 100644 ---- a/block/blk-zoned.c -+++ b/block/blk-zoned.c -@@ -475,8 +475,6 @@ int blk_revalidate_disk_zones(struct gendisk *disk) - - if (WARN_ON_ONCE(!blk_queue_is_zoned(q))) - return -EIO; -- if (WARN_ON_ONCE(!queue_is_mq(q))) -- return -EIO; - - /* - * Ensure that all memory allocations in this context are done as if --- -2.25.0 - diff --git a/for-test/zoned_device/block-changes/v1/0004-block-set-bi_size-to-REQ_OP_ZONE_RESET-bio.patch b/for-test/zoned_device/block-changes/v1/0004-block-set-bi_size-to-REQ_OP_ZONE_RESET-bio.patch deleted file mode 100644 index b1e9a6f..0000000 --- a/for-test/zoned_device/block-changes/v1/0004-block-set-bi_size-to-REQ_OP_ZONE_RESET-bio.patch +++ /dev/null @@ -1,96 +0,0 @@ -From f42cca05e81256e720d922f9290ac32e536f9d1f Mon Sep 17 00:00:00 2001 -From: Coly Li <colyli@suse.de> -Date: Thu, 14 May 2020 19:29:29 +0800 -Subject: [PATCH 4/4] block: set bi_size to REQ_OP_ZONE_RESET bio - -Now for zoned device, zone management ioctl commands are converted into -zone management bios and handled by blkdev_zone_mgmt(). There are 4 zone -management bios are handled, their op code is, -- REQ_OP_ZONE_RESET - Reset the zone's writer pointer and empty all previously stored data. -- REQ_OP_ZONE_OPEN - Open the zones in the specified sector range, no influence on data. -- REQ_OP_ZONE_CLOSE - Close the zones in the specified sector range, no influence on data. -- REQ_OP_ZONE_FINISH - Mark the zone as full, no influence on data. -All the zone management bios has 0 byte size, a.k.a their bi_size is 0. - -Exept for REQ_OP_ZONE_RESET request, zero length bio works fine for -other zone management bio, before the zoned device e.g. host managed SMR -hard drive can be created as a bcache device. - -When a bcache device (virtual block device to forward bios like md raid -drivers) can be created on top of the zoned device, and a fast SSD is -attached as a cache device, bcache driver may cache the frequent random -READ requests on fast SSD to accelerate hot data READ performance. - -When bcache driver receives a zone management bio for REQ_OP_ZONE_RESET -op, while forwarding the request to underlying zoned device e.g. host -managed SMR hard drive, it should also invalidate all cached data from -SSD for the resetting zone. Otherwise bcache will continue provide the -outdated cached data to READ request and cause potential data storage -inconsistency and corruption. - -In order to invalidate outdated data from SSD for the reset zone, bcache -needs to know not only the start LBA but also the range length of the -resetting zone. Otherwise, bcache won't be able to accurately invalidate -the outdated cached data. - -Is it possible to simply set the bi_size inside bcache driver? The -answer is NO. Although every REQ_OP_ZONE_RESET bio has exact length as -zone size or q->limits.chunk_sectors, it is possible that some other -layer stacking block driver (in the future) exists between bcache driver -and blkdev_zone_mgmt() where the zone management bio is made. - -The best location to set bi_size is where the zone management bio is -composed in blkdev_zone_mgmt(), then no matter how this bio is split -before bcache driver receives it, bcache driver can always correctly -invalidate the resetting range. - -This patch sets the bi_size of REQ_OP_ZONE_RESET bio for each resetting -zone. Here REQ_OP_ZONE_RESET_ALL is special whose bi_size should be set -as capacity of whole drive size, then bcache can invalidate all cached -data from SSD for the zoned backing device. - -With this change, now bcache code can handle REQ_OP_ZONE_RESET bio in -the way very similar to REQ_OP_DISCARD bio with very little change. - -Signed-off-by: Coly Li <colyli@suse.de> -Cc: Ajay Joshi <ajay.joshi@wdc.com> -Cc: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> -Cc: Christoph Hellwig <hch@lst.de> -Cc: Damien Le Moal <damien.lemoal@wdc.com> -Cc: Hannes Reinecke <hare@suse.de> -Cc: Johannes Thumshirn <johannes.thumshirn@wdc.com> ---- -Changelog: -v2: fix typo for REQ_OP_ZONE_RESET_ALL. -v1: initial version. - - block/blk-zoned.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/block/blk-zoned.c b/block/blk-zoned.c -index 1e0708c68267..01d91314399b 100644 ---- a/block/blk-zoned.c -+++ b/block/blk-zoned.c -@@ -227,11 +227,15 @@ int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op, - if (op == REQ_OP_ZONE_RESET && - blkdev_allow_reset_all_zones(bdev, sector, nr_sectors)) { - bio->bi_opf = REQ_OP_ZONE_RESET_ALL; -+ bio->bi_iter.bi_sector = sector; -+ bio->bi_iter.bi_size = nr_sectors; - break; - } - - bio->bi_opf = op | REQ_SYNC; - bio->bi_iter.bi_sector = sector; -+ if (op == REQ_OP_ZONE_RESET) -+ bio->bi_iter.bi_size = zone_sectors; - sector += zone_sectors; - - /* This may take a while, so be nice to others */ --- -2.25.0 - diff --git a/for-test/zoned_device/block-changes/v2-0000-cover-letter.patch b/for-test/zoned_device/block-changes/v2-0000-cover-letter.patch deleted file mode 100644 index eba5ed1..0000000 --- a/for-test/zoned_device/block-changes/v2-0000-cover-letter.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 115059f01f8196873184a167e3f8bcb59c7fccaa Mon Sep 17 00:00:00 2001 -From: Coly Li <colyli@suse.de> -Date: Sat, 16 May 2020 11:47:28 +0800 -Subject: [RFC PATCH v2 0/4] block layer change necessary for bcache zoned device support - -Hi folks, - -Recently I am working on supprt bcache to be created on zoned devices -e.g. host managed SMR hard drives, then frequent random READ I/Os on -these SMR drives can be accelerated. - -To make the bcache code work correctly, there are some small but maybe -important changes of block layer code are necessary. - -Thanks for the review comments from Keith Busch, I fix the typo and post -the v2 series for your review and comments. - -Thank you all in advance. - -Coly Li ---- - -Coly Li (4): - block: change REQ_OP_ZONE_RESET from 6 to 13 - block: block: change REQ_OP_ZONE_RESET_ALL from 8 to 15 - block: remove queue_is_mq restriction from blk_revalidate_disk_zones() - block: set bi_size to REQ_OP_ZONE_RESET bio - - block/blk-zoned.c | 6 ++++-- - include/linux/blk_types.h | 8 ++++---- - 2 files changed, 8 insertions(+), 6 deletions(-) - --- -2.25.0 - diff --git a/for-test/zoned_device/block-changes/v2-0001-block-change-REQ_OP_ZONE_RESET-from-6-to-13.patch b/for-test/zoned_device/block-changes/v2-0001-block-change-REQ_OP_ZONE_RESET-from-6-to-13.patch deleted file mode 100644 index f442926..0000000 --- a/for-test/zoned_device/block-changes/v2-0001-block-change-REQ_OP_ZONE_RESET-from-6-to-13.patch +++ /dev/null @@ -1,68 +0,0 @@ -From dc7fda1eeb396a0c3ead3fe136b43398db3ad5eb Mon Sep 17 00:00:00 2001 -From: Coly Li <colyli@suse.de> -Date: Fri, 15 May 2020 19:59:04 +0800 -Subject: [RFC PATCH v2 1/4] block: change REQ_OP_ZONE_RESET from 6 to 13 - -For a zoned device, e.g. host managed SMR hard drive, REQ_OP_ZONE_RESET -is to reset the LBA of a zone's write pointer back to the start LBA of -this zone. After the write point is reset, all previously stored data -in this zone is invalid and unaccessible anymore. Therefore, this op -code changes on disk data, belongs to a WRITE request op code. - -Current REQ_OP_ZONE_RESET is defined as number 6, but the convention of -the op code is, READ requests are even numbers, and WRITE requests are -odd numbers. See how op_is_write defined, - -397 static inline bool op_is_write(unsigned int op) -398 { -399 return (op & 1); -400 } - -When create bcache device on top of the zoned SMR drive, bcache driver -has to handle the REQ_OP_ZONE_RESET bio by invalidate all cached data -belongs to the LBA range of the restting zone. A wrong op code value -will make the this zone management bio goes into bcache' read requests -code path and causes undefined result. - -This patch changes REQ_OP_ZONE_RESET value from 6 to 13, the new odd -number will make bcache driver handle this zone management bio properly -in write requests code path. - -Fixes: 87374179c535 ("block: add a proper block layer data direction encoding") -Signed-off-by: Coly Li <colyli@suse.de> -Cc: Christoph Hellwig <hch@lst.de> -Cc: Damien Le Moal <damien.lemoal@wdc.com> -Cc: Hannes Reinecke <hare@suse.de> -Cc: Jens Axboe <axboe@fb.com> -Cc: Johannes Thumshirn <johannes.thumshirn@wdc.com> -Cc: Keith Busch <kbusch@kernel.org> -Cc: Shaun Tancheff <shaun.tancheff@seagate.com> ---- - include/linux/blk_types.h | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h -index 31eb92876be7..8f7bc15a6de3 100644 ---- a/include/linux/blk_types.h -+++ b/include/linux/blk_types.h -@@ -282,8 +282,6 @@ enum req_opf { - REQ_OP_DISCARD = 3, - /* securely erase sectors */ - REQ_OP_SECURE_ERASE = 5, -- /* reset a zone write pointer */ -- REQ_OP_ZONE_RESET = 6, - /* write the same sector many times */ - REQ_OP_WRITE_SAME = 7, - /* reset all the zone present on the device */ -@@ -296,6 +294,8 @@ enum req_opf { - REQ_OP_ZONE_CLOSE = 11, - /* Transition a zone to full */ - REQ_OP_ZONE_FINISH = 12, -+ /* reset a zone write pointer */ -+ REQ_OP_ZONE_RESET = 13, - - /* SCSI passthrough using struct scsi_request */ - REQ_OP_SCSI_IN = 32, --- -2.25.0 - diff --git a/for-test/zoned_device/block-changes/v2-0002-block-block-change-REQ_OP_ZONE_RESET_ALL-from-8-t.patch b/for-test/zoned_device/block-changes/v2-0002-block-block-change-REQ_OP_ZONE_RESET_ALL-from-8-t.patch deleted file mode 100644 index 7108b1f..0000000 --- a/for-test/zoned_device/block-changes/v2-0002-block-block-change-REQ_OP_ZONE_RESET_ALL-from-8-t.patch +++ /dev/null @@ -1,68 +0,0 @@ -From daf6a675e06f18e3fab89fb3803dbc7ed1f2d8fa Mon Sep 17 00:00:00 2001 -From: Coly Li <colyli@suse.de> -Date: Fri, 15 May 2020 20:35:36 +0800 -Subject: [RFC PATCH v2 2/4] block: block: change REQ_OP_ZONE_RESET_ALL from 8 - to 15 - -For a zoned device, e.g. host managed SMR hard drive, the request op -REQ_OP_ZONE_RESET_ALL is to reset LBA of all zones' writer pointers to -the start LBA of the zone they belong to. After all the write pointers -are reset, all previously stored data is invalid and unaccessible. -Therefore this op code changes on-disk data, belongs to WRITE request -op code. - -Similar to the problem of REQ_OP_ZONE_RESET, REQ_OP_ZONE_RESET_ALL is -even number 8, it means bios with REQ_OP_ZONE_RESET_ALL in bio->bi_opf -will be treated as READ request by op_is_write(). - -Same problem will happen when bcache device is created on top of zoned -device like host managed SMR hard drive, bcache driver should invalid -all cached data for the REQ_OP_ZONE_RESET_ALL request, but this zone -management bio is mistakenly treated as READ request and go into bcache -read code path, which will cause undefined behavior. - -This patch changes REQ_OP_ZONE_RESET_ALL value from 8 to 15, this new -odd number will make bcache driver handle this zone management bio in -write request code path properly. - -Fixes: e84e8f066395 ("block: add req op to reset all zones and flag") -Signed-off-by: Coly Li <colyli@suse.de> -Cc: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> -Cc: Damien Le Moal <damien.lemoal@wdc.com> -Cc: Hannes Reinecke <hare@suse.com> -Cc: Jens Axboe <axboe@kernel.dk> -Cc: Johannes Thumshirn <johannes.thumshirn@wdc.com> -Cc: Keith Busch <kbusch@kernel.org> ---- -Changelog: -v2: fix typo for REQ_OP_ZONE_RESET_ALL. -v1: initial version. - - include/linux/blk_types.h | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h -index 8f7bc15a6de3..618032fa1b29 100644 ---- a/include/linux/blk_types.h -+++ b/include/linux/blk_types.h -@@ -284,8 +284,6 @@ enum req_opf { - REQ_OP_SECURE_ERASE = 5, - /* write the same sector many times */ - REQ_OP_WRITE_SAME = 7, -- /* reset all the zone present on the device */ -- REQ_OP_ZONE_RESET_ALL = 8, - /* write the zero filled sector many times */ - REQ_OP_WRITE_ZEROES = 9, - /* Open a zone */ -@@ -296,6 +294,8 @@ enum req_opf { - REQ_OP_ZONE_FINISH = 12, - /* reset a zone write pointer */ - REQ_OP_ZONE_RESET = 13, -+ /* reset all the zone present on the device */ -+ REQ_OP_ZONE_RESET_ALL = 15, - - /* SCSI passthrough using struct scsi_request */ - REQ_OP_SCSI_IN = 32, --- -2.25.0 - diff --git a/for-test/zoned_device/block-changes/v2-0003-block-remove-queue_is_mq-restriction-from-blk_rev.patch b/for-test/zoned_device/block-changes/v2-0003-block-remove-queue_is_mq-restriction-from-blk_rev.patch deleted file mode 100644 index b015d36..0000000 --- a/for-test/zoned_device/block-changes/v2-0003-block-remove-queue_is_mq-restriction-from-blk_rev.patch +++ /dev/null @@ -1,56 +0,0 @@ -From 7450e5a45f3c5cb44c44c47324f6051c271c58d9 Mon Sep 17 00:00:00 2001 -From: Coly Li <colyli@suse.de> -Date: Thu, 14 May 2020 14:32:31 +0800 -Subject: [RFC PATCH v2 3/4] block: remove queue_is_mq restriction from - blk_revalidate_disk_zones() - -The bcache driver is bio based and NOT request based multiqueued driver, -if a zoned SMR hard drive is used as backing device of a bcache device, -calling blk_revalidate_disk_zones() for the bcache device will fail due -to the following check in blk_revalidate_disk_zones(), -478 if (WARN_ON_ONCE(!queue_is_mq(q))) -479 return -EIO; - -Now bcache is able to export the zoned information from the underlying -zoned SMR drives and format zonefs on top of a bcache device, the -resitriction that a zoned device should be multiqueued is unnecessary -for now. - -Although in commit ae58954d8734c ("block: don't handle bio based drivers -in blk_revalidate_disk_zones") it is said that bio based drivers should -not call blk_revalidate_disk_zones() and just manually update their own -q->nr_zones, but this is inaccurate. The bio based drivers also need to -set their zone size and initialize bitmaps for cnv and seq zones, it is -necessary to call blk_revalidate_disk_zones() for bio based drivers. - -This patch removes the above queue_is_mq() restriction to permit -bcache driver calls blk_revalidate_disk_zones() for bcache device zoned -information initialization. - -Fixes: ae58954d8734c ("block: don't handle bio based drivers in blk_revalidate_disk_zones") -Signed-off-by: Coly Li <colyli@suse.de> -Cc: Christoph Hellwig <hch@lst.de> -Cc: Damien Le Moal <damien.lemoal@wdc.com> -Cc: Hannes Reinecke <hare@suse.com> -Cc: Jens Axboe <axboe@kernel.dk> -Cc: Keith Busch <kbusch@kernel.org> ---- - block/blk-zoned.c | 2 -- - 1 file changed, 2 deletions(-) - -diff --git a/block/blk-zoned.c b/block/blk-zoned.c -index f87956e0dcaf..1e0708c68267 100644 ---- a/block/blk-zoned.c -+++ b/block/blk-zoned.c -@@ -475,8 +475,6 @@ int blk_revalidate_disk_zones(struct gendisk *disk) - - if (WARN_ON_ONCE(!blk_queue_is_zoned(q))) - return -EIO; -- if (WARN_ON_ONCE(!queue_is_mq(q))) -- return -EIO; - - /* - * Ensure that all memory allocations in this context are done as if --- -2.25.0 - diff --git a/for-test/zoned_device/block-changes/v2-0004-block-set-bi_size-to-REQ_OP_ZONE_RESET-bio.patch b/for-test/zoned_device/block-changes/v2-0004-block-set-bi_size-to-REQ_OP_ZONE_RESET-bio.patch deleted file mode 100644 index cb07641..0000000 --- a/for-test/zoned_device/block-changes/v2-0004-block-set-bi_size-to-REQ_OP_ZONE_RESET-bio.patch +++ /dev/null @@ -1,97 +0,0 @@ -From 115059f01f8196873184a167e3f8bcb59c7fccaa Mon Sep 17 00:00:00 2001 -From: Coly Li <colyli@suse.de> -Date: Thu, 14 May 2020 19:29:29 +0800 -Subject: [RFC PATCH v2 4/4] block: set bi_size to REQ_OP_ZONE_RESET bio - -Now for zoned device, zone management ioctl commands are converted into -zone management bios and handled by blkdev_zone_mgmt(). There are 4 zone -management bios are handled, their op code is, -- REQ_OP_ZONE_RESET - Reset the zone's writer pointer and empty all previously stored data. -- REQ_OP_ZONE_OPEN - Open the zones in the specified sector range, no influence on data. -- REQ_OP_ZONE_CLOSE - Close the zones in the specified sector range, no influence on data. -- REQ_OP_ZONE_FINISH - Mark the zone as full, no influence on data. -All the zone management bios has 0 byte size, a.k.a their bi_size is 0. - -Exept for REQ_OP_ZONE_RESET request, zero length bio works fine for -other zone management bio, before the zoned device e.g. host managed SMR -hard drive can be created as a bcache device. - -When a bcache device (virtual block device to forward bios like md raid -drivers) can be created on top of the zoned device, and a fast SSD is -attached as a cache device, bcache driver may cache the frequent random -READ requests on fast SSD to accelerate hot data READ performance. - -When bcache driver receives a zone management bio for REQ_OP_ZONE_RESET -op, while forwarding the request to underlying zoned device e.g. host -managed SMR hard drive, it should also invalidate all cached data from -SSD for the resetting zone. Otherwise bcache will continue provide the -outdated cached data to READ request and cause potential data storage -inconsistency and corruption. - -In order to invalidate outdated data from SSD for the reset zone, bcache -needs to know not only the start LBA but also the range length of the -resetting zone. Otherwise, bcache won't be able to accurately invalidate -the outdated cached data. - -Is it possible to simply set the bi_size inside bcache driver? The -answer is NO. Although every REQ_OP_ZONE_RESET bio has exact length as -zone size or q->limits.chunk_sectors, it is possible that some other -layer stacking block driver (in the future) exists between bcache driver -and blkdev_zone_mgmt() where the zone management bio is made. - -The best location to set bi_size is where the zone management bio is -composed in blkdev_zone_mgmt(), then no matter how this bio is split -before bcache driver receives it, bcache driver can always correctly -invalidate the resetting range. - -This patch sets the bi_size of REQ_OP_ZONE_RESET bio for each resetting -zone. Here REQ_OP_ZONE_RESET_ALL is special whose bi_size should be set -as capacity of whole drive size, then bcache can invalidate all cached -data from SSD for the zoned backing device. - -With this change, now bcache code can handle REQ_OP_ZONE_RESET bio in -the way very similar to REQ_OP_DISCARD bio with very little change. - -Signed-off-by: Coly Li <colyli@suse.de> -Cc: Ajay Joshi <ajay.joshi@wdc.com> -Cc: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> -Cc: Christoph Hellwig <hch@lst.de> -Cc: Damien Le Moal <damien.lemoal@wdc.com> -Cc: Hannes Reinecke <hare@suse.de> -Cc: Johannes Thumshirn <johannes.thumshirn@wdc.com> -Cc: Keith Busch <kbusch@kernel.org> ---- -Changelog: -v2: fix typo for REQ_OP_ZONE_RESET_ALL. -v1: initial version. - - block/blk-zoned.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/block/blk-zoned.c b/block/blk-zoned.c -index 1e0708c68267..01d91314399b 100644 ---- a/block/blk-zoned.c -+++ b/block/blk-zoned.c -@@ -227,11 +227,15 @@ int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op, - if (op == REQ_OP_ZONE_RESET && - blkdev_allow_reset_all_zones(bdev, sector, nr_sectors)) { - bio->bi_opf = REQ_OP_ZONE_RESET_ALL; -+ bio->bi_iter.bi_sector = sector; -+ bio->bi_iter.bi_size = nr_sectors; - break; - } - - bio->bi_opf = op | REQ_SYNC; - bio->bi_iter.bi_sector = sector; -+ if (op == REQ_OP_ZONE_RESET) -+ bio->bi_iter.bi_size = zone_sectors; - sector += zone_sectors; - - /* This may take a while, so be nice to others */ --- -2.25.0 - |