Skip to content

Commit fc3d532

Browse files
boryaskdave
authored andcommitted
btrfs: btrfs_log_dev_io_error() on all bio errors
As far as I can tell, we never intentionally constrained ourselves to these status codes, and it is misleading and surprising to lack the bdev error logging when we get a different error code from the block layer. This can lead to jumping to a wrong conclusion like "this system didn't see any bio failures but aborted with EIO". For example on nvme devices, I observe many failures coming back as BLK_STS_MEDIUM. It is apparent that the nvme driver returns a variety of BLK_STS_* status values in nvme_error_status(). So handle the known expected errors and make some noise on the rest which we expect won't really happen. Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Anand Jain <asj@kernel.org> Signed-off-by: Boris Burkov <boris@bur.io> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 3cd181c commit fc3d532

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

fs/btrfs/bio.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Copyright (C) 2022 Christoph Hellwig.
55
*/
66

7+
#include <linux/blk_types.h>
78
#include <linux/bio.h>
89
#include "bio.h"
910
#include "ctree.h"
@@ -350,11 +351,18 @@ static void btrfs_check_read_bio(struct btrfs_bio *bbio, struct btrfs_device *de
350351

351352
static void btrfs_log_dev_io_error(const struct bio *bio, struct btrfs_device *dev)
352353
{
354+
blk_status_t sts = bio->bi_status;
355+
353356
if (!dev || !dev->bdev)
354357
return;
355-
if (bio->bi_status != BLK_STS_IOERR && bio->bi_status != BLK_STS_TARGET)
358+
if (unlikely(sts == BLK_STS_OK))
356359
return;
357-
360+
if (unlikely(sts != BLK_STS_IOERR && sts != BLK_STS_TARGET &&
361+
sts != BLK_STS_MEDIUM && sts != BLK_STS_PROTECTION)) {
362+
btrfs_warn_rl(dev->fs_info, "bdev %s unexpected block io error: %d",
363+
btrfs_dev_name(dev), sts);
364+
return;
365+
}
358366
if (btrfs_op(bio) == BTRFS_MAP_WRITE)
359367
btrfs_dev_stat_inc_and_print(dev, BTRFS_DEV_STAT_WRITE_ERRS);
360368
else if (!(bio->bi_opf & REQ_RAHEAD))

0 commit comments

Comments
 (0)