Commit 5138ac67 authored by Coly Li's avatar Coly Li Committed by Jens Axboe

bcache: fix misleading error message in bch_count_io_errors()

Bcache only does recoverable I/O for read operations by calling
cached_dev_read_error(). For write opertions there is no I/O recovery for
failed requests.

But in bch_count_io_errors() no matter read or write I/Os, before errors
counter reaches io error limit, pr_err() always prints "IO error on %,
recoverying". For write requests this information is misleading, because
there is no I/O recovery at all.

This patch adds a parameter 'is_read' to bch_count_io_errors(), and only
prints "recovering" by pr_err() when the bio direction is READ.
Signed-off-by: default avatarColy Li <colyli@suse.de>
Reviewed-by: default avatarMichael Lyle <mlyle@lyle.org>
Reviewed-by: default avatarTang Junhui <tang.junhui@zte.com.cn>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 2831231d
...@@ -862,7 +862,7 @@ static inline void wake_up_allocators(struct cache_set *c) ...@@ -862,7 +862,7 @@ static inline void wake_up_allocators(struct cache_set *c)
/* Forward declarations */ /* Forward declarations */
void bch_count_io_errors(struct cache *, blk_status_t, const char *); void bch_count_io_errors(struct cache *, blk_status_t, int, const char *);
void bch_bbio_count_io_errors(struct cache_set *, struct bio *, void bch_bbio_count_io_errors(struct cache_set *, struct bio *,
blk_status_t, const char *); blk_status_t, const char *);
void bch_bbio_endio(struct cache_set *, struct bio *, blk_status_t, void bch_bbio_endio(struct cache_set *, struct bio *, blk_status_t,
......
...@@ -51,7 +51,10 @@ void bch_submit_bbio(struct bio *bio, struct cache_set *c, ...@@ -51,7 +51,10 @@ void bch_submit_bbio(struct bio *bio, struct cache_set *c,
/* IO errors */ /* IO errors */
void bch_count_io_errors(struct cache *ca, blk_status_t error, const char *m) void bch_count_io_errors(struct cache *ca,
blk_status_t error,
int is_read,
const char *m)
{ {
/* /*
* The halflife of an error is: * The halflife of an error is:
...@@ -94,8 +97,9 @@ void bch_count_io_errors(struct cache *ca, blk_status_t error, const char *m) ...@@ -94,8 +97,9 @@ void bch_count_io_errors(struct cache *ca, blk_status_t error, const char *m)
errors >>= IO_ERROR_SHIFT; errors >>= IO_ERROR_SHIFT;
if (errors < ca->set->error_limit) if (errors < ca->set->error_limit)
pr_err("%s: IO error on %s, recovering", pr_err("%s: IO error on %s%s",
bdevname(ca->bdev, buf), m); bdevname(ca->bdev, buf), m,
is_read ? ", recovering." : ".");
else else
bch_cache_set_error(ca->set, bch_cache_set_error(ca->set,
"%s: too many IO errors %s", "%s: too many IO errors %s",
...@@ -108,6 +112,7 @@ void bch_bbio_count_io_errors(struct cache_set *c, struct bio *bio, ...@@ -108,6 +112,7 @@ void bch_bbio_count_io_errors(struct cache_set *c, struct bio *bio,
{ {
struct bbio *b = container_of(bio, struct bbio, bio); struct bbio *b = container_of(bio, struct bbio, bio);
struct cache *ca = PTR_CACHE(c, &b->key, 0); struct cache *ca = PTR_CACHE(c, &b->key, 0);
int is_read = (bio_data_dir(bio) == READ ? 1 : 0);
unsigned threshold = op_is_write(bio_op(bio)) unsigned threshold = op_is_write(bio_op(bio))
? c->congested_write_threshold_us ? c->congested_write_threshold_us
...@@ -129,7 +134,7 @@ void bch_bbio_count_io_errors(struct cache_set *c, struct bio *bio, ...@@ -129,7 +134,7 @@ void bch_bbio_count_io_errors(struct cache_set *c, struct bio *bio,
atomic_inc(&c->congested); atomic_inc(&c->congested);
} }
bch_count_io_errors(ca, error, m); bch_count_io_errors(ca, error, is_read, m);
} }
void bch_bbio_endio(struct cache_set *c, struct bio *bio, void bch_bbio_endio(struct cache_set *c, struct bio *bio,
......
...@@ -274,7 +274,9 @@ static void write_super_endio(struct bio *bio) ...@@ -274,7 +274,9 @@ static void write_super_endio(struct bio *bio)
{ {
struct cache *ca = bio->bi_private; struct cache *ca = bio->bi_private;
bch_count_io_errors(ca, bio->bi_status, "writing superblock"); /* is_read = 0 */
bch_count_io_errors(ca, bio->bi_status, 0,
"writing superblock");
closure_put(&ca->set->sb_write); closure_put(&ca->set->sb_write);
} }
......
...@@ -244,8 +244,10 @@ static void read_dirty_endio(struct bio *bio) ...@@ -244,8 +244,10 @@ static void read_dirty_endio(struct bio *bio)
struct keybuf_key *w = bio->bi_private; struct keybuf_key *w = bio->bi_private;
struct dirty_io *io = w->private; struct dirty_io *io = w->private;
/* is_read = 1 */
bch_count_io_errors(PTR_CACHE(io->dc->disk.c, &w->key, 0), bch_count_io_errors(PTR_CACHE(io->dc->disk.c, &w->key, 0),
bio->bi_status, "reading dirty data from cache"); bio->bi_status, 1,
"reading dirty data from cache");
dirty_endio(bio); dirty_endio(bio);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment