aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/disk-io.c
diff options
context:
space:
mode:
authorStefan Behrens <sbehrens@giantdisaster.de>2012-05-25 10:06:08 -0400
committerJosef Bacik <josef@redhat.com>2012-05-30 10:23:39 -0400
commit442a4f6308e694e0fa6025708bd5e4e424bbf51c (patch)
treee782db1bcbec25283048d77871e0bed7ad04567c /fs/btrfs/disk-io.c
parentd07eb9117050c9ed3f78296ebcc06128b52693be (diff)
Btrfs: add device counters for detected IO and checksum errors
The goal is to detect when drives start to get an increased error rate, when drives should be replaced soon. Therefore statistic counters are added that count IO errors (read, write and flush). Additionally, the software detected errors like checksum errors and corrupted blocks are counted. Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r--fs/btrfs/disk-io.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 0f788c059063..46d474e74aa4 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -2557,18 +2557,19 @@ recovery_tree_root:
2557 2557
2558static void btrfs_end_buffer_write_sync(struct buffer_head *bh, int uptodate) 2558static void btrfs_end_buffer_write_sync(struct buffer_head *bh, int uptodate)
2559{ 2559{
2560 char b[BDEVNAME_SIZE];
2561
2562 if (uptodate) { 2560 if (uptodate) {
2563 set_buffer_uptodate(bh); 2561 set_buffer_uptodate(bh);
2564 } else { 2562 } else {
2563 struct btrfs_device *device = (struct btrfs_device *)
2564 bh->b_private;
2565
2565 printk_ratelimited(KERN_WARNING "lost page write due to " 2566 printk_ratelimited(KERN_WARNING "lost page write due to "
2566 "I/O error on %s\n", 2567 "I/O error on %s\n", device->name);
2567 bdevname(bh->b_bdev, b));
2568 /* note, we dont' set_buffer_write_io_error because we have 2568 /* note, we dont' set_buffer_write_io_error because we have
2569 * our own ways of dealing with the IO errors 2569 * our own ways of dealing with the IO errors
2570 */ 2570 */
2571 clear_buffer_uptodate(bh); 2571 clear_buffer_uptodate(bh);
2572 btrfs_dev_stat_inc_and_print(device, BTRFS_DEV_STAT_WRITE_ERRS);
2572 } 2573 }
2573 unlock_buffer(bh); 2574 unlock_buffer(bh);
2574 put_bh(bh); 2575 put_bh(bh);
@@ -2683,6 +2684,7 @@ static int write_dev_supers(struct btrfs_device *device,
2683 set_buffer_uptodate(bh); 2684 set_buffer_uptodate(bh);
2684 lock_buffer(bh); 2685 lock_buffer(bh);
2685 bh->b_end_io = btrfs_end_buffer_write_sync; 2686 bh->b_end_io = btrfs_end_buffer_write_sync;
2687 bh->b_private = device;
2686 } 2688 }
2687 2689
2688 /* 2690 /*
@@ -2741,6 +2743,9 @@ static int write_dev_flush(struct btrfs_device *device, int wait)
2741 } 2743 }
2742 if (!bio_flagged(bio, BIO_UPTODATE)) { 2744 if (!bio_flagged(bio, BIO_UPTODATE)) {
2743 ret = -EIO; 2745 ret = -EIO;
2746 if (!bio_flagged(bio, BIO_EOPNOTSUPP))
2747 btrfs_dev_stat_inc_and_print(device,
2748 BTRFS_DEV_STAT_FLUSH_ERRS);
2744 } 2749 }
2745 2750
2746 /* drop the reference from the wait == 0 run */ 2751 /* drop the reference from the wait == 0 run */