Skip to content

Commit 5138ac6

Browse files
Coly Liaxboe
authored andcommitted
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: Coly Li <colyli@suse.de> Reviewed-by: Michael Lyle <mlyle@lyle.org> Reviewed-by: Tang Junhui <tang.junhui@zte.com.cn> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 2831231 commit 5138ac6

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

drivers/md/bcache/bcache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ static inline void wake_up_allocators(struct cache_set *c)
862862

863863
/* Forward declarations */
864864

865-
void bch_count_io_errors(struct cache *, blk_status_t, const char *);
865+
void bch_count_io_errors(struct cache *, blk_status_t, int, const char *);
866866
void bch_bbio_count_io_errors(struct cache_set *, struct bio *,
867867
blk_status_t, const char *);
868868
void bch_bbio_endio(struct cache_set *, struct bio *, blk_status_t,

drivers/md/bcache/io.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ void bch_submit_bbio(struct bio *bio, struct cache_set *c,
5151

5252
/* IO errors */
5353

54-
void bch_count_io_errors(struct cache *ca, blk_status_t error, const char *m)
54+
void bch_count_io_errors(struct cache *ca,
55+
blk_status_t error,
56+
int is_read,
57+
const char *m)
5558
{
5659
/*
5760
* 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)
9497
errors >>= IO_ERROR_SHIFT;
9598

9699
if (errors < ca->set->error_limit)
97-
pr_err("%s: IO error on %s, recovering",
98-
bdevname(ca->bdev, buf), m);
100+
pr_err("%s: IO error on %s%s",
101+
bdevname(ca->bdev, buf), m,
102+
is_read ? ", recovering." : ".");
99103
else
100104
bch_cache_set_error(ca->set,
101105
"%s: too many IO errors %s",
@@ -108,6 +112,7 @@ void bch_bbio_count_io_errors(struct cache_set *c, struct bio *bio,
108112
{
109113
struct bbio *b = container_of(bio, struct bbio, bio);
110114
struct cache *ca = PTR_CACHE(c, &b->key, 0);
115+
int is_read = (bio_data_dir(bio) == READ ? 1 : 0);
111116

112117
unsigned threshold = op_is_write(bio_op(bio))
113118
? c->congested_write_threshold_us
@@ -129,7 +134,7 @@ void bch_bbio_count_io_errors(struct cache_set *c, struct bio *bio,
129134
atomic_inc(&c->congested);
130135
}
131136

132-
bch_count_io_errors(ca, error, m);
137+
bch_count_io_errors(ca, error, is_read, m);
133138
}
134139

135140
void bch_bbio_endio(struct cache_set *c, struct bio *bio,

drivers/md/bcache/super.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,9 @@ static void write_super_endio(struct bio *bio)
274274
{
275275
struct cache *ca = bio->bi_private;
276276

277-
bch_count_io_errors(ca, bio->bi_status, "writing superblock");
277+
/* is_read = 0 */
278+
bch_count_io_errors(ca, bio->bi_status, 0,
279+
"writing superblock");
278280
closure_put(&ca->set->sb_write);
279281
}
280282

drivers/md/bcache/writeback.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,10 @@ static void read_dirty_endio(struct bio *bio)
244244
struct keybuf_key *w = bio->bi_private;
245245
struct dirty_io *io = w->private;
246246

247+
/* is_read = 1 */
247248
bch_count_io_errors(PTR_CACHE(io->dc->disk.c, &w->key, 0),
248-
bio->bi_status, "reading dirty data from cache");
249+
bio->bi_status, 1,
250+
"reading dirty data from cache");
249251

250252
dirty_endio(bio);
251253
}

0 commit comments

Comments
 (0)