aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColy Li <colyli@suse.de>2018-02-06 00:04:07 +0800
committerColy Li <colyli@suse.de>2018-02-06 00:04:07 +0800
commitefff8da279e868e6a9d9c96afdd2fca5c31bbdba (patch)
tree1608a7cce6514fa9cff17627efd6d6bbf6957375
parentdcc1da5ab0d2ea18f2f5e5dd769047fcc9c0bb43 (diff)
downloadbcache-patches-efff8da279e868e6a9d9c96afdd2fca5c31bbdba.tar.gz
for-next: update v5 patch set
-rw-r--r--for-next/v5-0000-cover-letter.patch15
-rw-r--r--for-next/v5-0001-bcache-set-writeback_rate_update_seconds-in-range.patch4
-rw-r--r--for-next/v5-0002-bcache-fix-cached_dev-count-usage-for-bch_cache_s.patch4
-rw-r--r--for-next/v5-0003-bcache-quit-dc-writeback_thread-when-BCACHE_DEV_D.patch8
-rw-r--r--for-next/v5-0004-bcache-stop-dc-writeback_rate_update-properly.patch4
-rw-r--r--for-next/v5-0005-bcache-add-CACHE_SET_IO_DISABLE-to-struct-cache_s.patch4
-rw-r--r--for-next/v5-0006-bcache-add-stop_when_cache_set_failed-option-to-b.patch (renamed from for-next/v5-0011-bcache-add-stop_when_cache_set_failed-option-to-b.patch)98
-rw-r--r--for-next/v5-0006-bcache-stop-all-attached-bcache-devices-for-a-ret.patch67
-rw-r--r--for-next/v5-0007-bcache-fix-inaccurate-io-state-for-detached-bcach.patch4
-rw-r--r--for-next/v5-0008-bcache-add-backing_request_endio-for-bi_end_io-of.patch8
-rw-r--r--for-next/v5-0009-bcache-add-io_disable-to-struct-cached_dev.patch50
-rw-r--r--for-next/v5-0010-bcache-stop-bcache-device-when-backing-device-is-.patch24
12 files changed, 116 insertions, 174 deletions
diff --git a/for-next/v5-0000-cover-letter.patch b/for-next/v5-0000-cover-letter.patch
index de57fc5..0f5a650 100644
--- a/for-next/v5-0000-cover-letter.patch
+++ b/for-next/v5-0000-cover-letter.patch
@@ -1,7 +1,7 @@
From e8f72263c0f4f20b85f42a617fa4998115f797af Mon Sep 17 00:00:00 2001
From: Coly Li <colyli@suse.de>
Date: Mon, 5 Feb 2018 18:26:45 +0800
-Subject: [PATCH v5 00/11] bcache: device failure handling improvement
+Subject: [PATCH v5 00/10] bcache: device failure handling improvement
Hi maintainers and folks,
@@ -30,20 +30,23 @@ are not in v5 patch set any more.
In v5 patch set add a new patch "bcache: add stop_when_cache_set_failed
option to backing device", which provides "auto"/"always" options to
-configure whether or not to stop bcache device for a broken cache cset.
+configure whether or not to stop bcache device for a broken cache set. The
+patch "bcache: stop all attached bcache devices for a retired cache set"
+from v4 patch set is replaced by the above new added patch.
Most of the patches are reviewed by Hannes Reinecke and Junhui Tang. There
are still severl patches need to be reviewed,
-- [PATCH v5 03/11] bcache: quit dc->writeback_thread when
+- [PATCH v5 03/10] bcache: quit dc->writeback_thread when
BCACHE_DEV_DETACHING is set
-- [PATCH v5 11/11] bcache: add stop_when_cache_set_failed option to
+- [PATCH v5 06/10] bcache: add stop_when_cache_set_failed option to
backing device
Any comment, question and review are warmly welcome. Thanks in advance.
Changelog:
-v5: add [PATCH v5 11/11] bcache: add stop_when_cache_set_failed option to
- backing device.
+v5: replace patch "bcache: stop all attached bcache devices for a retired
+ cache set" from v4 patch set by "bcache: add stop_when_cache_set_failed
+ option to backing device" from v5 patch set.
fix issues from v4 patch set.
improve kernel message format, remove redundant prefix string.
v4: add per-cached_dev option stop_attached_devs_on_fail to avoid stopping
diff --git a/for-next/v5-0001-bcache-set-writeback_rate_update_seconds-in-range.patch b/for-next/v5-0001-bcache-set-writeback_rate_update_seconds-in-range.patch
index d218724..4a6c147 100644
--- a/for-next/v5-0001-bcache-set-writeback_rate_update_seconds-in-range.patch
+++ b/for-next/v5-0001-bcache-set-writeback_rate_update_seconds-in-range.patch
@@ -1,7 +1,7 @@
-From 31fa907c6f962fc229c4364ac08b239f7bf5384d Mon Sep 17 00:00:00 2001
+From 71066c410c4f50bb1803a634dff17fd0ecb90860 Mon Sep 17 00:00:00 2001
From: Coly Li <colyli@suse.de>
Date: Sat, 13 Jan 2018 15:11:03 +0800
-Subject: [PATCH v5 01/11] bcache: set writeback_rate_update_seconds in range
+Subject: [PATCH v5 01/10] bcache: set writeback_rate_update_seconds in range
[1, 60] seconds
dc->writeback_rate_update_seconds can be set via sysfs and its value can
diff --git a/for-next/v5-0002-bcache-fix-cached_dev-count-usage-for-bch_cache_s.patch b/for-next/v5-0002-bcache-fix-cached_dev-count-usage-for-bch_cache_s.patch
index 1c09d03..1ff898a 100644
--- a/for-next/v5-0002-bcache-fix-cached_dev-count-usage-for-bch_cache_s.patch
+++ b/for-next/v5-0002-bcache-fix-cached_dev-count-usage-for-bch_cache_s.patch
@@ -1,7 +1,7 @@
-From c88508fc06f1d3d2241104d5e3b7b5e0045d24c0 Mon Sep 17 00:00:00 2001
+From 8d90ae56c8b859dbd3b4360c8e011f5fee7b3540 Mon Sep 17 00:00:00 2001
From: Coly Li <colyli@suse.de>
Date: Mon, 8 Jan 2018 23:05:58 +0800
-Subject: [PATCH v5 02/11] bcache: fix cached_dev->count usage for
+Subject: [PATCH v5 02/10] bcache: fix cached_dev->count usage for
bch_cache_set_error()
When bcache metadata I/O fails, bcache will call bch_cache_set_error()
diff --git a/for-next/v5-0003-bcache-quit-dc-writeback_thread-when-BCACHE_DEV_D.patch b/for-next/v5-0003-bcache-quit-dc-writeback_thread-when-BCACHE_DEV_D.patch
index d9aa14d..cd0b2e6 100644
--- a/for-next/v5-0003-bcache-quit-dc-writeback_thread-when-BCACHE_DEV_D.patch
+++ b/for-next/v5-0003-bcache-quit-dc-writeback_thread-when-BCACHE_DEV_D.patch
@@ -1,7 +1,7 @@
-From ad362b22f19cca3073dfe9290529ea5ff63c8b4b Mon Sep 17 00:00:00 2001
+From 26562d0421bf1fa18492e4089fead5b1f97616e2 Mon Sep 17 00:00:00 2001
From: Coly Li <colyli@suse.de>
Date: Sun, 14 Jan 2018 21:41:57 +0800
-Subject: [PATCH v5 03/11] bcache: quit dc->writeback_thread when
+Subject: [PATCH v5 03/10] bcache: quit dc->writeback_thread when
BCACHE_DEV_DETACHING is set
In patch "bcache: fix cached_dev->count usage for bch_cache_set_error()",
@@ -66,12 +66,12 @@ thread goes to sleep in mistake while it should continue to run.
thread. Therefore the condition check will correctly be false, and
continue writeback code without sleeping.
2.2 condition "!dc->writeback_running)"
- dc->writeback_running can be changed via sysfs file, every time it is
+ dc->writeback_running can be changed via sysfs file, every time it is
modified, a following bch_writeback_queue() is alwasy called. So the
change is always observed on the CPU core of writeback thread. If
dc->writeback_running is changed from 0 to 1 on other CPU core, this
condition check will observe the modification and allow writeback
- thread to continue to run without sleeping.
+ thread to continue to run without sleeping.
Now we can see, even without a locking protection, multiple conditions
check is safe here, no deadlock or process hang up will happen.
diff --git a/for-next/v5-0004-bcache-stop-dc-writeback_rate_update-properly.patch b/for-next/v5-0004-bcache-stop-dc-writeback_rate_update-properly.patch
index 83524b8..909a381 100644
--- a/for-next/v5-0004-bcache-stop-dc-writeback_rate_update-properly.patch
+++ b/for-next/v5-0004-bcache-stop-dc-writeback_rate_update-properly.patch
@@ -1,7 +1,7 @@
-From f4ce0fb52b341b89a5302daa4a0c2ce716281867 Mon Sep 17 00:00:00 2001
+From 0661a1f418c8efe59d19f952218c2faca0044275 Mon Sep 17 00:00:00 2001
From: Coly Li <colyli@suse.de>
Date: Sat, 13 Jan 2018 15:48:39 +0800
-Subject: [PATCH v5 04/11] bcache: stop dc->writeback_rate_update properly
+Subject: [PATCH v5 04/10] bcache: stop dc->writeback_rate_update properly
struct delayed_work writeback_rate_update in struct cache_dev is a delayed
worker to call function update_writeback_rate() in period (the interval is
diff --git a/for-next/v5-0005-bcache-add-CACHE_SET_IO_DISABLE-to-struct-cache_s.patch b/for-next/v5-0005-bcache-add-CACHE_SET_IO_DISABLE-to-struct-cache_s.patch
index 57afe27..7444b9a 100644
--- a/for-next/v5-0005-bcache-add-CACHE_SET_IO_DISABLE-to-struct-cache_s.patch
+++ b/for-next/v5-0005-bcache-add-CACHE_SET_IO_DISABLE-to-struct-cache_s.patch
@@ -1,7 +1,7 @@
-From 805fefa99ced3d184d69c65449eb3e24104346b9 Mon Sep 17 00:00:00 2001
+From f9371b6b9d66ff73942770360cce17a72ca7625a Mon Sep 17 00:00:00 2001
From: Coly Li <colyli@suse.de>
Date: Sun, 14 Jan 2018 22:15:00 +0800
-Subject: [PATCH v5 05/11] bcache: add CACHE_SET_IO_DISABLE to struct cache_set
+Subject: [PATCH v5 05/10] bcache: add CACHE_SET_IO_DISABLE to struct cache_set
flags
When too many I/Os failed on cache device, bch_cache_set_error() is called
diff --git a/for-next/v5-0011-bcache-add-stop_when_cache_set_failed-option-to-b.patch b/for-next/v5-0006-bcache-add-stop_when_cache_set_failed-option-to-b.patch
index c782476..53f932c 100644
--- a/for-next/v5-0011-bcache-add-stop_when_cache_set_failed-option-to-b.patch
+++ b/for-next/v5-0006-bcache-add-stop_when_cache_set_failed-option-to-b.patch
@@ -1,15 +1,28 @@
-From e8f72263c0f4f20b85f42a617fa4998115f797af Mon Sep 17 00:00:00 2001
+From fc5aa1aa4157619dc56f794419405b64a31a1312 Mon Sep 17 00:00:00 2001
From: Coly Li <colyli@suse.de>
-Date: Mon, 5 Feb 2018 10:43:18 +0800
-Subject: [PATCH v5 11/11] bcache: add stop_when_cache_set_failed option to
+Date: Mon, 5 Feb 2018 23:44:28 +0800
+Subject: [PATCH v5 06/10] bcache: add stop_when_cache_set_failed option to
backing device
-Current bcache failure handling code will stop all attached bcache devices
-when the cache set is broken or disconnected. This might not be desired
-behavior, example bcache deployed for an email service. In such workload,
-if cache device is broken but no dirty data lost, keep the bcache device
-alive and permit email service continue to access data might be a better
-solution for the cache device failure.
+When there are too many I/O errors on cache device, current bcache code
+will retire the whole cache set, and detach all bcache devices. But the
+detached bcache devices are not stopped, which is problematic when bcache
+is in writeback mode.
+
+If the retired cache set has dirty data of backing devices, continue
+writing to bcache device will write to backing device directly. If the
+LBA of write request has a dirty version cached on cache device, next time
+when the cache device is re-registered and backing device re-attached to
+it again, the stale dirty data on cache device will be written to backing
+device, and overwrite latest directly written data. This situation causes
+a quite data corruption.
+
+But we cannot simply stop all attached bcache devices when the cache set is
+broken or disconnected. For example, use bcache to accelerate performance
+of an email service. In such workload, if cache device is broken but no
+dirty data lost, keep the bcache device alive and permit email service
+continue to access user data might be a better solution for the cache
+device failure.
Nix <nix@esperi.org.uk> points out the issue and provides the above example
to explain why it might be necessary to not stop bcache device for broken
@@ -35,13 +48,13 @@ Cc: Michael Lyle <mlyle@lyle.org>
Cc: Junhui Tang <tang.junhui@zte.com.cn>
Cc: Hannes Reinecke <hare@suse.com>
---
- drivers/md/bcache/bcache.h | 8 +++++
- drivers/md/bcache/super.c | 90 ++++++++++++++++++++++++++++++++++++----------
- drivers/md/bcache/sysfs.c | 17 +++++++++
- 3 files changed, 97 insertions(+), 18 deletions(-)
+ drivers/md/bcache/bcache.h | 9 +++++
+ drivers/md/bcache/super.c | 82 ++++++++++++++++++++++++++++++++++++++++------
+ drivers/md/bcache/sysfs.c | 17 ++++++++++
+ 3 files changed, 98 insertions(+), 10 deletions(-)
diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h
-index 1c749352172d..59e675304b7e 100644
+index 7917b3820dd5..263164490833 100644
--- a/drivers/md/bcache/bcache.h
+++ b/drivers/md/bcache/bcache.h
@@ -287,6 +287,12 @@ struct io {
@@ -57,15 +70,16 @@ index 1c749352172d..59e675304b7e 100644
struct cached_dev {
struct list_head list;
struct bcache_device disk;
-@@ -382,6 +388,7 @@ struct cached_dev {
+@@ -379,6 +385,8 @@ struct cached_dev {
+ unsigned writeback_rate_i_term_inverse;
unsigned writeback_rate_p_term_inverse;
unsigned writeback_rate_minimum;
-
++
+ enum stop_on_faliure stop_when_cache_set_failed;
- #define DEFAULT_CACHED_DEV_ERROR_LIMIT 64
- atomic_t io_errors;
- unsigned error_limit;
-@@ -933,6 +940,7 @@ void bch_write_bdev_super(struct cached_dev *, struct closure *);
+ };
+
+ enum alloc_reserve {
+@@ -924,6 +932,7 @@ void bch_write_bdev_super(struct cached_dev *, struct closure *);
extern struct workqueue_struct *bcache_wq;
extern const char * const bch_cache_modes[];
@@ -74,7 +88,7 @@ index 1c749352172d..59e675304b7e 100644
extern struct list_head bch_cache_sets;
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
-index de0f5fb9bde2..d2999f1e6ae2 100644
+index f8b0d1196c12..e335433bdfb7 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -47,6 +47,14 @@ const char * const bch_cache_modes[] = {
@@ -92,16 +106,17 @@ index de0f5fb9bde2..d2999f1e6ae2 100644
static struct kobject *bcache_kobj;
struct mutex bch_register_lock;
LIST_HEAD(bch_cache_sets);
-@@ -1246,6 +1254,8 @@ static int cached_dev_init(struct cached_dev *dc, unsigned block_size)
- atomic_set(&dc->io_errors, 0);
- dc->io_disable = false;
- dc->error_limit = DEFAULT_CACHED_DEV_ERROR_LIMIT;
+@@ -1187,6 +1195,9 @@ static int cached_dev_init(struct cached_dev *dc, unsigned block_size)
+ max(dc->disk.disk->queue->backing_dev_info->ra_pages,
+ q->backing_dev_info->ra_pages);
+
+ /* default to auto */
+ dc->stop_when_cache_set_failed = BCH_CACHED_DEV_STOP_ATUO;
-
++
bch_cached_dev_request_init(dc);
bch_cached_dev_writeback_init(dc);
-@@ -1541,33 +1551,77 @@ static void cache_set_flush(struct closure *cl)
+ return 0;
+@@ -1463,25 +1474,76 @@ static void cache_set_flush(struct closure *cl)
closure_return(cl);
}
@@ -112,25 +127,24 @@ index de0f5fb9bde2..d2999f1e6ae2 100644
+ * value and whether the broken cache has dirty data:
+ *
+ * dc->stop_when_cache_set_failed dc->has_dirty stop bcache device
-+ * BCH_CACHED_STOP_ATUO 0 NO
-+ * BCH_CACHED_STOP_ATUO 1 YES
-+ * BCH_CACHED_DEV_STOP_ALWAYS 0 YES
-+ * BCH_CACHED_DEV_STOP_ALWAYS 1 YES
++ * BCH_CACHED_STOP_ATUO 0 NO
++ * BCH_CACHED_STOP_ATUO 1 YES
++ * BCH_CACHED_DEV_STOP_ALWAYS 0 YES
++ * BCH_CACHED_DEV_STOP_ALWAYS 1 YES
+ *
+ * The expected behavior is, if stop_when_cache_set_failed is configured to
+ * "auto" via sysfs interface, the bcache device will not be stopped if the
+ * backing device is clean on the broken cache device.
+ */
+static void conditional_stop_bcache_device(struct cache_set *c,
-+ struct bcache_device *d,
-+ struct cached_dev *dc)
++ struct bcache_device *d,
++ struct cached_dev *dc)
+{
+ if (dc->stop_when_cache_set_failed == BCH_CACHED_DEV_STOP_ALWAYS) {
+ pr_warn("stop_when_cache_set_failed of %s is \"always\", stop"
+ " it for failed cache set %pU.",
+ d->disk->disk_name, c->sb.set_uuid);
+ bcache_device_stop(d);
-+ return;
+ } else if (atomic_read(&dc->has_dirty)) {
+ /*
+ * dc->stop_when_cache_set_failed == BCH_CACHED_STOP_ATUO
@@ -140,7 +154,7 @@ index de0f5fb9bde2..d2999f1e6ae2 100644
+ "cache is dirty, stop it to avoid potential data "
+ "corruption.",
+ d->disk->disk_name);
-+ bcache_device_stop(d);
++ bcache_device_stop(d);
+ } else {
+ /*
+ * dc->stop_when_cache_set_failed == BCH_CACHED_STOP_ATUO
@@ -168,14 +182,6 @@ index de0f5fb9bde2..d2999f1e6ae2 100644
- dc = container_of(c->devices[i],
- struct cached_dev, disk);
- bch_cached_dev_detach(dc);
-- /*
-- * If we come here by too many I/O errors,
-- * bcache device should be stopped too, to
-- * keep data consistency on cache and
-- * backing devices.
-- */
-- if (test_bit(CACHE_SET_IO_DISABLE, &c->flags))
-- bcache_device_stop(c->devices[i]);
- } else {
- bcache_device_stop(c->devices[i]);
- }
@@ -198,7 +204,7 @@ index de0f5fb9bde2..d2999f1e6ae2 100644
mutex_unlock(&bch_register_lock);
diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c
-index ac3adf2dcf6c..e88fdcc549cd 100644
+index cf973c07c856..91d859a54575 100644
--- a/drivers/md/bcache/sysfs.c
+++ b/drivers/md/bcache/sysfs.c
@@ -78,6 +78,7 @@ rw_attribute(congested_write_threshold_us);
@@ -222,7 +228,7 @@ index ac3adf2dcf6c..e88fdcc549cd 100644
sysfs_printf(data_csum, "%i", dc->disk.data_csum);
var_printf(verify, "%i");
var_printf(bypass_torture_test, "%i");
-@@ -257,6 +264,15 @@ STORE(__cached_dev)
+@@ -247,6 +254,15 @@ STORE(__cached_dev)
}
}
@@ -238,7 +244,7 @@ index ac3adf2dcf6c..e88fdcc549cd 100644
if (attr == &sysfs_label) {
if (size > SB_LABEL_SIZE)
return -EINVAL;
-@@ -333,6 +349,7 @@ static struct attribute *bch_cached_dev_files[] = {
+@@ -323,6 +339,7 @@ static struct attribute *bch_cached_dev_files[] = {
&sysfs_data_csum,
#endif
&sysfs_cache_mode,
diff --git a/for-next/v5-0006-bcache-stop-all-attached-bcache-devices-for-a-ret.patch b/for-next/v5-0006-bcache-stop-all-attached-bcache-devices-for-a-ret.patch
deleted file mode 100644
index 7cea41c..0000000
--- a/for-next/v5-0006-bcache-stop-all-attached-bcache-devices-for-a-ret.patch
+++ /dev/null
@@ -1,67 +0,0 @@
-From e741114d13958a91559cd8c376cf704cb2180370 Mon Sep 17 00:00:00 2001
-From: Coly Li <colyli@suse.de>
-Date: Wed, 10 Jan 2018 00:26:32 +0800
-Subject: [PATCH v5 06/11] bcache: stop all attached bcache devices for a
- retired cache set
-
-When there are too many I/O errors on cache device, current bcache code
-will retire the whole cache set, and detach all bcache devices. But the
-detached bcache devices are not stopped, which is problematic when bcache
-is in writeback mode.
-
-If the retired cache set has dirty data of backing devices, continue
-writing to bcache device will write to backing device directly. If the
-LBA of write request has a dirty version cached on cache device, next time
-when the cache device is re-registered and backing device re-attached to
-it again, the stale dirty data on cache device will be written to backing
-device, and overwrite latest directly written data. This situation causes
-a quite data corruption.
-
-This patch checkes whether cache_set->io_disable is true in
-__cache_set_unregister(). If cache_set->io_disable is true, it means cache
-set is unregistering by too many I/O errors, then all attached bcache
-devices will be stopped as well. If cache_set->io_disable is not true, it
-means __cache_set_unregister() is triggered by writing 1 to sysfs file
-/sys/fs/bcache/<UUID>/bcache/stop. This is an exception because users do
-it explicitly, this patch keeps existing behavior and does not stop any
-bcache device.
-
-Even the failed cache device has no dirty data, stopping bcache device is
-still a desired behavior by many Ceph and data base users. Then their
-application will report I/O errors due to disappeared bcache device, and
-operation people will know the cache device is broken or disconnected.
-
-Changelog:
-v2: add reviewed-by from Hannes.
-v1: initial version for review.
-
-Signed-off-by: Coly Li <colyli@suse.de>
-Reviewed-by: Hannes Reinecke <hare@suse.com>
-Cc: Junhui Tang <tang.junhui@zte.com.cn>
-Cc: Michael Lyle <mlyle@lyle.org>
----
- drivers/md/bcache/super.c | 8 ++++++++
- 1 file changed, 8 insertions(+)
-
-diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
-index f8b0d1196c12..41ef438e7b40 100644
---- a/drivers/md/bcache/super.c
-+++ b/drivers/md/bcache/super.c
-@@ -1478,6 +1478,14 @@ static void __cache_set_unregister(struct closure *cl)
- dc = container_of(c->devices[i],
- struct cached_dev, disk);
- bch_cached_dev_detach(dc);
-+ /*
-+ * If we come here by too many I/O errors,
-+ * bcache device should be stopped too, to
-+ * keep data consistency on cache and
-+ * backing devices.
-+ */
-+ if (test_bit(CACHE_SET_IO_DISABLE, &c->flags))
-+ bcache_device_stop(c->devices[i]);
- } else {
- bcache_device_stop(c->devices[i]);
- }
---
-2.16.1
-
diff --git a/for-next/v5-0007-bcache-fix-inaccurate-io-state-for-detached-bcach.patch b/for-next/v5-0007-bcache-fix-inaccurate-io-state-for-detached-bcach.patch
index 419c2c7..79707be 100644
--- a/for-next/v5-0007-bcache-fix-inaccurate-io-state-for-detached-bcach.patch
+++ b/for-next/v5-0007-bcache-fix-inaccurate-io-state-for-detached-bcach.patch
@@ -1,7 +1,7 @@
-From d6f9f789096d2c3473314fa10ea1166683399ac8 Mon Sep 17 00:00:00 2001
+From 64c41825d56a1a0a7f7b468606a08bf6a86c21ba Mon Sep 17 00:00:00 2001
From: Tang Junhui <tang.junhui@zte.com.cn>
Date: Tue, 9 Jan 2018 10:27:11 +0800
-Subject: [PATCH v5 07/11] bcache: fix inaccurate io state for detached bcache
+Subject: [PATCH v5 07/10] bcache: fix inaccurate io state for detached bcache
devices
When we run IO in a detached device, and run iostat to shows IO status,
diff --git a/for-next/v5-0008-bcache-add-backing_request_endio-for-bi_end_io-of.patch b/for-next/v5-0008-bcache-add-backing_request_endio-for-bi_end_io-of.patch
index 4cddd78..18f7651 100644
--- a/for-next/v5-0008-bcache-add-backing_request_endio-for-bi_end_io-of.patch
+++ b/for-next/v5-0008-bcache-add-backing_request_endio-for-bi_end_io-of.patch
@@ -1,7 +1,7 @@
-From e76beb2960de33506c0f6e177d43f8a8cfafee30 Mon Sep 17 00:00:00 2001
+From 38cfbb08de26e4e16d9f87307f132f4c7572e7bf Mon Sep 17 00:00:00 2001
From: Coly Li <colyli@suse.de>
Date: Wed, 10 Jan 2018 21:01:48 +0800
-Subject: [PATCH v5 08/11] bcache: add backing_request_endio() for bi_end_io of
+Subject: [PATCH v5 08/10] bcache: add backing_request_endio() for bi_end_io of
attached backing device I/O
In order to catch I/O error of backing device, a separate bi_end_io
@@ -227,10 +227,10 @@ index e09c5ae745be..9c6dda3b0068 100644
return BLK_QC_T_NONE;
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
-index 41ef438e7b40..082faaf2ee2f 100644
+index e335433bdfb7..4f1a14b99415 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
-@@ -265,6 +265,7 @@ void bch_write_bdev_super(struct cached_dev *dc, struct closure *parent)
+@@ -273,6 +273,7 @@ void bch_write_bdev_super(struct cached_dev *dc, struct closure *parent)
bio->bi_private = dc;
closure_get(cl);
diff --git a/for-next/v5-0009-bcache-add-io_disable-to-struct-cached_dev.patch b/for-next/v5-0009-bcache-add-io_disable-to-struct-cached_dev.patch
index 9a63f8d..2ff139d 100644
--- a/for-next/v5-0009-bcache-add-io_disable-to-struct-cached_dev.patch
+++ b/for-next/v5-0009-bcache-add-io_disable-to-struct-cached_dev.patch
@@ -1,7 +1,7 @@
-From fff4f5d3d40952ddba1649fd7a5ce0d025b0b3cc Mon Sep 17 00:00:00 2001
+From 677f078827ce5ebde0a4aad6dfc0dc269433d622 Mon Sep 17 00:00:00 2001
From: Coly Li <colyli@suse.de>
-Date: Wed, 10 Jan 2018 21:33:45 +0800
-Subject: [PATCH v5 09/11] bcache: add io_disable to struct cached_dev
+Date: Mon, 5 Feb 2018 23:49:47 +0800
+Subject: [PATCH v5 09/10] bcache: add io_disable to struct cached_dev
If a bcache device is configured to writeback mode, current code does not
handle write I/O errors on backing devices properly.
@@ -34,18 +34,18 @@ Reviewed-by: Hannes Reinecke <hare@suse.com>
Cc: Michael Lyle <mlyle@lyle.org>
Cc: Junhui Tang <tang.junhui@zte.com.cn>
---
- drivers/md/bcache/bcache.h | 7 +++++++
+ drivers/md/bcache/bcache.h | 6 ++++++
drivers/md/bcache/io.c | 14 ++++++++++++++
drivers/md/bcache/request.c | 14 ++++++++++++--
- drivers/md/bcache/super.c | 22 ++++++++++++++++++++++
+ drivers/md/bcache/super.c | 23 ++++++++++++++++++++++-
drivers/md/bcache/sysfs.c | 15 ++++++++++++++-
- 5 files changed, 69 insertions(+), 3 deletions(-)
+ 5 files changed, 68 insertions(+), 4 deletions(-)
diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h
-index 7917b3820dd5..822ec75bb78c 100644
+index 263164490833..c59ce168bd82 100644
--- a/drivers/md/bcache/bcache.h
+++ b/drivers/md/bcache/bcache.h
-@@ -360,6 +360,7 @@ struct cached_dev {
+@@ -366,6 +366,7 @@ struct cached_dev {
unsigned sequential_cutoff;
unsigned readahead;
@@ -53,18 +53,17 @@ index 7917b3820dd5..822ec75bb78c 100644
unsigned verify:1;
unsigned bypass_torture_test:1;
-@@ -379,6 +380,10 @@ struct cached_dev {
- unsigned writeback_rate_i_term_inverse;
- unsigned writeback_rate_p_term_inverse;
+@@ -387,6 +388,9 @@ struct cached_dev {
unsigned writeback_rate_minimum;
-+
-+#define DEFAULT_CACHED_DEV_ERROR_LIMIT 64
+
+ enum stop_on_faliure stop_when_cache_set_failed;
++#define DEFAULT_CACHED_DEV_ERROR_LIMIT 64
+ atomic_t io_errors;
+ unsigned error_limit;
};
enum alloc_reserve {
-@@ -888,6 +893,7 @@ static inline void closure_bio_submit(struct cache_set *c,
+@@ -896,6 +900,7 @@ static inline void closure_bio_submit(struct cache_set *c,
/* Forward declarations */
@@ -72,7 +71,7 @@ index 7917b3820dd5..822ec75bb78c 100644
void bch_count_io_errors(struct cache *, blk_status_t, int, const char *);
void bch_bbio_count_io_errors(struct cache_set *, struct bio *,
blk_status_t, const char *);
-@@ -915,6 +921,7 @@ int bch_bucket_alloc_set(struct cache_set *, unsigned,
+@@ -923,6 +928,7 @@ int bch_bucket_alloc_set(struct cache_set *, unsigned,
struct bkey *, int, bool);
bool bch_alloc_sectors(struct cache_set *, struct bkey *, unsigned,
unsigned, unsigned, bool);
@@ -153,21 +152,22 @@ index 9c6dda3b0068..03245e6980a6 100644
bio_endio(bio);
return BLK_QC_T_NONE;
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
-index 082faaf2ee2f..91a08cdd55bd 100644
+index 4f1a14b99415..40b07d980a20 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
-@@ -1188,6 +1188,10 @@ static int cached_dev_init(struct cached_dev *dc, unsigned block_size)
+@@ -1196,7 +1196,10 @@ static int cached_dev_init(struct cached_dev *dc, unsigned block_size)
max(dc->disk.disk->queue->backing_dev_info->ra_pages,
q->backing_dev_info->ra_pages);
+- /* default to auto */
+ atomic_set(&dc->io_errors, 0);
+ dc->io_disable = false;
+ dc->error_limit = DEFAULT_CACHED_DEV_ERROR_LIMIT;
-+
++ /* default to "auto" */
+ dc->stop_when_cache_set_failed = BCH_CACHED_DEV_STOP_ATUO;
+
bch_cached_dev_request_init(dc);
- bch_cached_dev_writeback_init(dc);
- return 0;
-@@ -1339,6 +1343,24 @@ int bch_flash_dev_create(struct cache_set *c, uint64_t size)
+@@ -1350,6 +1353,24 @@ int bch_flash_dev_create(struct cache_set *c, uint64_t size)
return flash_dev_run(c, u);
}
@@ -193,10 +193,10 @@ index 082faaf2ee2f..91a08cdd55bd 100644
__printf(2, 3)
diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c
-index cf973c07c856..ac3adf2dcf6c 100644
+index 91d859a54575..e88fdcc549cd 100644
--- a/drivers/md/bcache/sysfs.c
+++ b/drivers/md/bcache/sysfs.c
-@@ -134,7 +134,9 @@ SHOW(__bch_cached_dev)
+@@ -141,7 +141,9 @@ SHOW(__bch_cached_dev)
var_print(writeback_delay);
var_print(writeback_percent);
sysfs_hprint(writeback_rate, dc->writeback_rate.rate << 9);
@@ -207,7 +207,7 @@ index cf973c07c856..ac3adf2dcf6c 100644
var_print(writeback_rate_update_seconds);
var_print(writeback_rate_i_term_inverse);
var_print(writeback_rate_p_term_inverse);
-@@ -225,6 +227,14 @@ STORE(__cached_dev)
+@@ -232,6 +234,14 @@ STORE(__cached_dev)
d_strtoul(writeback_rate_i_term_inverse);
d_strtoul_nonzero(writeback_rate_p_term_inverse);
@@ -222,7 +222,7 @@ index cf973c07c856..ac3adf2dcf6c 100644
d_strtoi_h(sequential_cutoff);
d_strtoi_h(readahead);
-@@ -332,6 +342,9 @@ static struct attribute *bch_cached_dev_files[] = {
+@@ -349,6 +359,9 @@ static struct attribute *bch_cached_dev_files[] = {
&sysfs_writeback_rate_i_term_inverse,
&sysfs_writeback_rate_p_term_inverse,
&sysfs_writeback_rate_debug,
diff --git a/for-next/v5-0010-bcache-stop-bcache-device-when-backing-device-is-.patch b/for-next/v5-0010-bcache-stop-bcache-device-when-backing-device-is-.patch
index d03b24e..5ebd851 100644
--- a/for-next/v5-0010-bcache-stop-bcache-device-when-backing-device-is-.patch
+++ b/for-next/v5-0010-bcache-stop-bcache-device-when-backing-device-is-.patch
@@ -1,7 +1,7 @@
-From 7d8d5a020e69671723932da30a1800eed91d3bcd Mon Sep 17 00:00:00 2001
+From 88e4b7378283d942fe281f1b246be4a427a88511 Mon Sep 17 00:00:00 2001
From: Coly Li <colyli@suse.de>
-Date: Sat, 13 Jan 2018 17:31:44 +0800
-Subject: [PATCH v5 10/11] bcache: stop bcache device when backing device is
+Date: Mon, 5 Feb 2018 23:52:40 +0800
+Subject: [PATCH v5 10/10] bcache: stop bcache device when backing device is
offline
Currently bcache does not handle backing device failure, if backing
@@ -41,10 +41,10 @@ Cc: Junhui Tang <tang.junhui@zte.com.cn>
2 files changed, 57 insertions(+)
diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h
-index 822ec75bb78c..1c749352172d 100644
+index c59ce168bd82..aa83dd0f682f 100644
--- a/drivers/md/bcache/bcache.h
+++ b/drivers/md/bcache/bcache.h
-@@ -338,6 +338,7 @@ struct cached_dev {
+@@ -344,6 +344,7 @@ struct cached_dev {
struct keybuf writeback_keys;
@@ -52,8 +52,8 @@ index 822ec75bb78c..1c749352172d 100644
/*
* Order the write-half of writeback operations strongly in dispatch
* order. (Maintain LBA order; don't allow reads completing out of
-@@ -384,6 +385,7 @@ struct cached_dev {
- #define DEFAULT_CACHED_DEV_ERROR_LIMIT 64
+@@ -391,6 +392,7 @@ struct cached_dev {
+ #define DEFAULT_CACHED_DEV_ERROR_LIMIT 64
atomic_t io_errors;
unsigned error_limit;
+ unsigned offline_seconds;
@@ -61,10 +61,10 @@ index 822ec75bb78c..1c749352172d 100644
enum alloc_reserve {
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
-index 91a08cdd55bd..de0f5fb9bde2 100644
+index 40b07d980a20..6d672329efce 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
-@@ -646,6 +646,11 @@ static int ioctl_dev(struct block_device *b, fmode_t mode,
+@@ -654,6 +654,11 @@ static int ioctl_dev(struct block_device *b, fmode_t mode,
unsigned int cmd, unsigned long arg)
{
struct bcache_device *d = b->bd_disk->private_data;
@@ -76,7 +76,7 @@ index 91a08cdd55bd..de0f5fb9bde2 100644
return d->ioctl(d, mode, cmd, arg);
}
-@@ -856,6 +861,45 @@ static void calc_cached_dev_sectors(struct cache_set *c)
+@@ -864,6 +869,45 @@ static void calc_cached_dev_sectors(struct cache_set *c)
c->cached_dev_sectors = sectors;
}
@@ -122,7 +122,7 @@ index 91a08cdd55bd..de0f5fb9bde2 100644
void bch_cached_dev_run(struct cached_dev *dc)
{
struct bcache_device *d = &dc->disk;
-@@ -898,6 +942,15 @@ void bch_cached_dev_run(struct cached_dev *dc)
+@@ -906,6 +950,15 @@ void bch_cached_dev_run(struct cached_dev *dc)
if (sysfs_create_link(&d->kobj, &disk_to_dev(d->disk)->kobj, "dev") ||
sysfs_create_link(&disk_to_dev(d->disk)->kobj, &d->kobj, "bcache"))
pr_debug("error creating sysfs link");
@@ -138,7 +138,7 @@ index 91a08cdd55bd..de0f5fb9bde2 100644
}
/*
-@@ -1118,6 +1171,8 @@ static void cached_dev_free(struct closure *cl)
+@@ -1126,6 +1179,8 @@ static void cached_dev_free(struct closure *cl)
kthread_stop(dc->writeback_thread);
if (dc->writeback_write_wq)
destroy_workqueue(dc->writeback_write_wq);