diff options
author | Coly Li <colyli@suse.de> | 2017-12-09 20:41:13 +0800 |
---|---|---|
committer | Coly Li <colyli@suse.de> | 2017-12-09 20:41:13 +0800 |
commit | ed66385550447d7f3dabebfad6bc10afb70bbe61 (patch) | |
tree | cef1f64b407017be77d998eee7f36035abd56618 | |
parent | 94d8ca2cb6f7d239c88cff3750d0a48d6a689166 (diff) | |
download | bcache-patches-ed66385550447d7f3dabebfad6bc10afb70bbe61.tar.gz |
for-test: add 2 patches
0006-bcache-add-io_disable-to-struct-cached_dev.patch
0007-bcache-add-sysfs-interface-to-cached_dev-member-io_e.patch
-rw-r--r-- | for-test/0006-bcache-add-io_disable-to-struct-cached_dev.patch | 153 | ||||
-rw-r--r-- | for-test/0007-bcache-add-sysfs-interface-to-cached_dev-member-io_e.patch | 46 |
2 files changed, 199 insertions, 0 deletions
diff --git a/for-test/0006-bcache-add-io_disable-to-struct-cached_dev.patch b/for-test/0006-bcache-add-io_disable-to-struct-cached_dev.patch new file mode 100644 index 0000000..f2e4721 --- /dev/null +++ b/for-test/0006-bcache-add-io_disable-to-struct-cached_dev.patch @@ -0,0 +1,153 @@ +From 86d3756cfadf50427a42671c826eeb02b94df6d4 Mon Sep 17 00:00:00 2001 +From: Coly Li <colyli@suse.de> +Date: Sat, 9 Dec 2017 20:12:55 +0800 +Subject: [PATCH 1/2] bcache: add io_disable to struct cached_dev + +Signed-off-by: Coly Li <colyli@suse.de> +--- + drivers/md/bcache/bcache.h | 9 ++++++++- + drivers/md/bcache/io.c | 15 +++++++++++++++ + drivers/md/bcache/request.c | 5 ++++- + drivers/md/bcache/super.c | 22 ++++++++++++++++++++++ + 4 files changed, 49 insertions(+), 2 deletions(-) + +diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h +index 89526acde49a..4f12112a7489 100644 +--- a/drivers/md/bcache/bcache.h ++++ b/drivers/md/bcache/bcache.h +@@ -349,7 +349,7 @@ struct cached_dev { + /* The rest of this all shows up in sysfs */ + unsigned sequential_cutoff; + unsigned readahead; +- ++ bool io_disable; + unsigned verify:1; + unsigned bypass_torture_test:1; + +@@ -369,6 +369,11 @@ struct cached_dev { + unsigned writeback_rate_i_term_inverse; + unsigned writeback_rate_p_term_inverse; + unsigned writeback_rate_minimum; ++ ++#define DEFAULT_CACHED_DEV_ERROR_LIMIT 64 ++ atomic_t io_errors; ++ unsigned error_limit; ++ + }; + + enum alloc_reserve { +@@ -869,6 +874,7 @@ static inline void closure_bio_submit(struct cache_set *c, + + /* Forward declarations */ + ++void bch_count_backing_io_errors(struct cached_dev *dc, struct bio *bio); + void bch_count_io_errors(struct cache *, blk_status_t, const char *); + void bch_bbio_count_io_errors(struct cache_set *, struct bio *, + blk_status_t, const char *); +@@ -896,6 +902,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); ++bool bch_cached_dev_error(struct cached_dev *dc); + + __printf(2, 3) + bool bch_cache_set_error(struct cache_set *, const char *, ...); +diff --git a/drivers/md/bcache/io.c b/drivers/md/bcache/io.c +index 99d2971999d2..f6aa05c5e810 100644 +--- a/drivers/md/bcache/io.c ++++ b/drivers/md/bcache/io.c +@@ -51,6 +51,21 @@ void bch_submit_bbio(struct bio *bio, struct cache_set *c, + + /* IO errors */ + ++void bch_count_backing_io_errors(struct cached_dev *dc, struct bio *bio) ++{ ++ char buf[BDEVNAME_SIZE]; ++ unsigned errors; ++ ++ WARN_ONCE(!dc, "NULL pointer of struct cached_dev"); ++ ++ errors = atomic_add_return(1, &dc->io_errors); ++ if (errors < dc->error_limit) ++ pr_err("%s: IO error on backing device, unrecoverable", ++ bio_devname(bio, buf)); ++ else ++ bch_cached_dev_error(dc); ++} ++ + void bch_count_io_errors(struct cache *ca, blk_status_t error, const char *m) + { + /* +diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c +index 78cccfb2e107..0edb7ae37acf 100644 +--- a/drivers/md/bcache/request.c ++++ b/drivers/md/bcache/request.c +@@ -614,6 +614,8 @@ static void backing_request_endio(struct bio *bio) + + if (bio->bi_status) { + struct search *s = container_of(cl, struct search, cl); ++ struct cached_dev *dc = container_of(s->d, ++ struct cached_dev, disk); + /* + * If a bio has REQ_PREFLUSH for writeback mode, it is + * speically assembled in cached_dev_write() for a non-zero +@@ -633,6 +635,7 @@ static void backing_request_endio(struct bio *bio) + } + s->recoverable = false; + /* should count I/O error for backing device here */ ++ bch_count_backing_io_errors(dc, bio); + } + + bio_put(bio); +@@ -1034,7 +1037,7 @@ static blk_qc_t cached_dev_make_request(struct request_queue *q, + struct cached_dev *dc = container_of(d, struct cached_dev, disk); + int rw = bio_data_dir(bio); + +- if (unlikely(d->c->io_disable)) { ++ if (unlikely(d->c->io_disable || dc->io_disable)) { + bio->bi_status = BLK_STS_IOERR; + bio_endio(bio); + return BLK_QC_T_NONE; +diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c +index c6578df78122..dc9d092211c7 100644 +--- a/drivers/md/bcache/super.c ++++ b/drivers/md/bcache/super.c +@@ -1147,6 +1147,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); + ++ atomic_set(&dc->io_errors, 0); ++ dc->io_disable = false; ++ dc->error_limit = DEFAULT_CACHED_DEV_ERROR_LIMIT; ++ + bch_cached_dev_request_init(dc); + bch_cached_dev_writeback_init(dc); + return 0; +@@ -1298,6 +1302,24 @@ int bch_flash_dev_create(struct cache_set *c, uint64_t size) + return flash_dev_run(c, u); + } + ++bool bch_cached_dev_error(struct cached_dev *dc) ++{ ++ char name[BDEVNAME_SIZE]; ++ ++ if (!dc || test_bit(BCACHE_DEV_CLOSING, &dc->disk.flags)) ++ return false; ++ ++ dc->io_disable = true; ++ smp_mb(); ++ ++ printk(KERN_ERR ++ "bcache: stop %s: too many IO errors on backing device %s\n", ++ dc->disk.name, bdevname(dc->bdev, name)); ++ ++ bcache_device_stop(&dc->disk); ++ return true; ++} ++ + /* Cache set */ + + __printf(2, 3) +-- +2.13.6 + diff --git a/for-test/0007-bcache-add-sysfs-interface-to-cached_dev-member-io_e.patch b/for-test/0007-bcache-add-sysfs-interface-to-cached_dev-member-io_e.patch new file mode 100644 index 0000000..3da6731 --- /dev/null +++ b/for-test/0007-bcache-add-sysfs-interface-to-cached_dev-member-io_e.patch @@ -0,0 +1,46 @@ +From 05440ed5fc04f60c2c23830c91d814ece3879555 Mon Sep 17 00:00:00 2001 +From: Coly Li <colyli@suse.de> +Date: Sat, 9 Dec 2017 20:39:16 +0800 +Subject: [PATCH 2/2] bcache: add sysfs interface to cached_dev member + io_errors and error_limit. + +Signed-off-by: Coly Li <colyli@suse.de> +--- + drivers/md/bcache/sysfs.c | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c +index 46e8939aa314..e2f93cd6a598 100644 +--- a/drivers/md/bcache/sysfs.c ++++ b/drivers/md/bcache/sysfs.c +@@ -132,7 +132,8 @@ SHOW(__bch_cached_dev) + var_print(writeback_delay); + var_print(writeback_percent); + sysfs_hprint(writeback_rate, dc->writeback_rate.rate << 9); +- ++ sysfs_hprint(io_errors, atomic_read(&dc->io_errors)); ++ sysfs_printf(io_error_limit, "%i", dc->error_limit); + var_print(writeback_rate_update_seconds); + var_print(writeback_rate_i_term_inverse); + var_print(writeback_rate_p_term_inverse); +@@ -221,6 +222,8 @@ STORE(__cached_dev) + d_strtoul(writeback_rate_i_term_inverse); + d_strtoul_nonzero(writeback_rate_p_term_inverse); + ++ sysfs_strtoul_clamp(io_error_limit, dc->error_limit, 0, INT_MAX); ++ + d_strtoi_h(sequential_cutoff); + d_strtoi_h(readahead); + +@@ -327,6 +330,8 @@ static struct attribute *bch_cached_dev_files[] = { + &sysfs_writeback_rate_i_term_inverse, + &sysfs_writeback_rate_p_term_inverse, + &sysfs_writeback_rate_debug, ++ &sysfs_errors, ++ &sysfs_io_error_limit, + &sysfs_dirty_data, + &sysfs_stripe_size, + &sysfs_partial_stripes_expensive, +-- +2.13.6 + |