Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Boris Burkov and committed by
David Sterba
fc3d5328 3cd181cc

+10 -2
+10 -2
fs/btrfs/bio.c
··· 4 4 * Copyright (C) 2022 Christoph Hellwig. 5 5 */ 6 6 7 + #include <linux/blk_types.h> 7 8 #include <linux/bio.h> 8 9 #include "bio.h" 9 10 #include "ctree.h" ··· 351 350 352 351 static void btrfs_log_dev_io_error(const struct bio *bio, struct btrfs_device *dev) 353 352 { 353 + blk_status_t sts = bio->bi_status; 354 + 354 355 if (!dev || !dev->bdev) 355 356 return; 356 - if (bio->bi_status != BLK_STS_IOERR && bio->bi_status != BLK_STS_TARGET) 357 + if (unlikely(sts == BLK_STS_OK)) 357 358 return; 358 - 359 + if (unlikely(sts != BLK_STS_IOERR && sts != BLK_STS_TARGET && 360 + sts != BLK_STS_MEDIUM && sts != BLK_STS_PROTECTION)) { 361 + btrfs_warn_rl(dev->fs_info, "bdev %s unexpected block io error: %d", 362 + btrfs_dev_name(dev), sts); 363 + return; 364 + } 359 365 if (btrfs_op(bio) == BTRFS_MAP_WRITE) 360 366 btrfs_dev_stat_inc_and_print(dev, BTRFS_DEV_STAT_WRITE_ERRS); 361 367 else if (!(bio->bi_opf & REQ_RAHEAD))