/* 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 *,
                              blk_status_t, const char *);
 void bch_bbio_endio(struct cache_set *, struct bio *, blk_status_t,
 
 
 /* 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:
                errors >>= IO_ERROR_SHIFT;
 
                if (errors < ca->set->error_limit)
-                       pr_err("%s: IO error on %s, recovering",
-                              bdevname(ca->bdev, buf), m);
+                       pr_err("%s: IO error on %s%s",
+                              bdevname(ca->bdev, buf), m,
+                              is_read ? ", recovering." : ".");
                else
                        bch_cache_set_error(ca->set,
                                            "%s: too many IO errors %s",
 {
        struct bbio *b = container_of(bio, struct bbio, bio);
        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))
                ? c->congested_write_threshold_us
                        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,
 
 {
        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);
 }
 
 
        struct keybuf_key *w = bio->bi_private;
        struct dirty_io *io = w->private;
 
+       /* is_read = 1 */
        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);
 }