Skip to contentSkip to conversation

Btrfs: add IO error device stats

PATCH In review Stefan Behrens 3 participants 7 messages May 25, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v5 cover Btrfs: add IO error device stats

Changes v1-v2:
- Remove restriction that BTRFS_IOC_GET_DEVICE_STATS is a privileged operation
- Cast u64 to unsigned long long for printf()

Changes v2-v3:
- Rebased on Chris' current master

Changes v3-v4:
- Add padding at end of ioctl structure

Changes v4-v5:
- The statistic members in the ioctl are now organized as an array of 64 bit values. Symbolic names for the array indexes are defined in an enum, which also defines the max value. This change makes it easier to add new statistic members in the future
- Give ins_len = -1 to btrfs_search_slot() when an item might get deleted
- Introduce a helper function for the repeated sequence stat_int() + dirty = 1 + stat_print()
- Introduce a helper function for the code that shares the bio bi_private member for two pieces of information

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.

An ioctl interface is added to get the device statistic counters. A second ioctl is added to atomically get and reset these counters.

The device statistics are written into the device tree with each transaction commit. Only modified statistics are written. When a filesystem is mounted, the device statistics for each involved device are read from the device tree and used to initialize the counters.

A patch for the btrfs-progs world will also be sent.

Stefan Behrens (3):
Btrfs: add device counters for detected IO and checksum errors
Btrfs: add ioctl to get and reset the device stats
Btrfs: read device stats on mount, write modified ones during commit

 fs/btrfs/ctree.h       |   38 ++++++
 fs/btrfs/disk-io.c     |   20 +++-
 fs/btrfs/extent_io.c   |   18 ++-
 fs/btrfs/ioctl.c       |   26 +++++
 fs/btrfs/ioctl.h       |   33 ++++++
 fs/btrfs/print-tree.c  |    3 +
 fs/btrfs/scrub.c       |   65 ++++++++---
 fs/btrfs/transaction.c |    4 +
 fs/btrfs/volumes.c     |  304 +++++++++++++++++++++++++++++++++++++++++++++++-
 fs/btrfs/volumes.h     |   52 +++++++++
 10 files changed, 539 insertions(+), 24 deletions(-)
Signature · 1 line
1.7.10.2
#1 lore raw

PATCH v5 1/3 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.

---
 fs/btrfs/disk-io.c   |   13 ++++---
 fs/btrfs/extent_io.c |   18 ++++++++--
 fs/btrfs/ioctl.h     |   19 ++++++++++
 fs/btrfs/scrub.c     |   65 +++++++++++++++++++++++++---------
 fs/btrfs/volumes.c   |   94 ++++++++++++++++++++++++++++++++++++++++++++++++--
 fs/btrfs/volumes.h   |   45 ++++++++++++++++++++++++
 6 files changed, 230 insertions(+), 24 deletions(-)
fs/btrfs/disk-io.c +9 -4
index a7ffc88..da4d33f 100644
@@ -2556,18 +2556,19 @@ recovery_tree_root:
 
 static void btrfs_end_buffer_write_sync(struct buffer_head *bh, int uptodate)
 {
-	char b[BDEVNAME_SIZE];
-
 	if (uptodate) {
 		set_buffer_uptodate(bh);
 	} else {
+		struct btrfs_device *device = (struct btrfs_device *)
+			bh->b_private;
+
 		printk_ratelimited(KERN_WARNING "lost page write due to "
-					"I/O error on %s\n",
-				       bdevname(bh->b_bdev, b));
+				   "I/O error on %s\n", device->name);
 		/* note, we dont' set_buffer_write_io_error because we have
 		 * our own ways of dealing with the IO errors
 		 */
 		clear_buffer_uptodate(bh);
+		btrfs_dev_stat_inc_and_print(device, BTRFS_DEV_STAT_WRITE_ERRS);
 	}
 	unlock_buffer(bh);
 	put_bh(bh);
@@ -2682,6 +2683,7 @@ static int write_dev_supers(struct btrfs_device *device,
 			set_buffer_uptodate(bh);
 			lock_buffer(bh);
 			bh->b_end_io = btrfs_end_buffer_write_sync;
+			bh->b_private = device;
 		}
 
 		/*
@@ -2740,6 +2742,9 @@ static int write_dev_flush(struct btrfs_device *device, int wait)
 		}
 		if (!bio_flagged(bio, BIO_UPTODATE)) {
 			ret = -EIO;
+			if (!bio_flagged(bio, BIO_EOPNOTSUPP))
+				btrfs_dev_stat_inc_and_print(device,
+					BTRFS_DEV_STAT_FLUSH_ERRS);
 		}
 
 		/* drop the reference from the wait == 0 run */
fs/btrfs/extent_io.c +16 -2
index 2fb52c2..55f72f8 100644
@@ -1923,6 +1923,7 @@ int repair_io_failure(struct btrfs_mapping_tree *map_tree, u64 start,
 	if (!test_bit(BIO_UPTODATE, &bio->bi_flags)) {
 		/* try to remap that extent elsewhere? */
 		bio_put(bio);
+		btrfs_dev_stat_inc_and_print(dev, BTRFS_DEV_STAT_WRITE_ERRS);
 		return -EIO;
 	}
 
@@ -2347,10 +2348,23 @@ static void end_bio_extent_readpage(struct bio *bio, int err)
 		if (uptodate && tree->ops && tree->ops->readpage_end_io_hook) {
 			ret = tree->ops->readpage_end_io_hook(page, start, end,
 							      state, mirror);
-			if (ret)
+			if (ret) {
+				/* no IO indicated but software detected errors
+				 * in the block, either checksum errors or
+				 * issues with the contents */
+				struct btrfs_root *root =
+					BTRFS_I(page->mapping->host)->root;
+				struct btrfs_device *device;
+
 				uptodate = 0;
-			else
+				device = btrfs_find_device_for_logical(
+						root, start, mirror);
+				if (device)
+					btrfs_dev_stat_inc_and_print(device,
+						BTRFS_DEV_STAT_CORRUPTION_ERRS);
+			} else {
 				clean_io_failure(start, page);
+			}
 		}
 
 		if (!uptodate && tree->ops && tree->ops->readpage_io_failed_hook) {
fs/btrfs/ioctl.h +19 -0
index 086e6bd..5bf05e2 100644
@@ -266,6 +266,25 @@ struct btrfs_ioctl_logical_ino_args {
 	__u64				inodes;
 };
 
+enum btrfs_dev_stat_values {
+	/* disk I/O failure stats */
+	BTRFS_DEV_STAT_WRITE_ERRS, /* EIO or EREMOTEIO from lower layers */
+	BTRFS_DEV_STAT_READ_ERRS, /* EIO or EREMOTEIO from lower layers */
+	BTRFS_DEV_STAT_FLUSH_ERRS, /* EIO or EREMOTEIO from lower layers */
+
+	/* stats for indirect indications for I/O failures */
+	BTRFS_DEV_STAT_CORRUPTION_ERRS, /* checksum error, bytenr error or
+					 * contents is illegal: this is an
+					 * indication that the block was damaged
+					 * during read or write, or written to
+					 * wrong location or read from wrong
+					 * location */
+	BTRFS_DEV_STAT_GENERATION_ERRS, /* an indication that blocks have not
+					 * been written */
+
+	BTRFS_DEV_STAT_VALUES_MAX
+};
+
 #define BTRFS_IOC_SNAP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 1, \
 				   struct btrfs_ioctl_vol_args)
 #define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, \
fs/btrfs/scrub.c +49 -16

189 lines not on this page · raw message

fs/btrfs/volumes.c +92 -2

126 lines not on this page · raw message

fs/btrfs/volumes.h +45 -0

61 lines not on this page · raw message

Signature · 1 line
1.7.10.2
#2 lore raw

PATCH v5 2/3 Btrfs: add ioctl to get and reset the device stats

In reply to Stefan Behrens

An ioctl interface is added to get the device statistic counters. A second ioctl is added to atomically get and reset these counters.

---
 fs/btrfs/ioctl.c   |   26 ++++++++++++++++++++++++++
 fs/btrfs/ioctl.h   |   14 ++++++++++++++
 fs/btrfs/volumes.c |   34 ++++++++++++++++++++++++++++++++++
 fs/btrfs/volumes.h |    3 +++
 4 files changed, 77 insertions(+)
fs/btrfs/ioctl.c +26 -0
index 14f8e1f..2f5072d 100644
@@ -3042,6 +3042,28 @@ static long btrfs_ioctl_scrub_progress(struct btrfs_root *root,
 	return ret;
 }
 
+static long btrfs_ioctl_get_dev_stats(struct btrfs_root *root,
+				      void __user *arg, int reset_after_read)
+{
+	struct btrfs_ioctl_get_dev_stats *sa;
+	int ret;
+
+	if (reset_after_read && !capable(CAP_SYS_ADMIN))
+		return -EPERM;
+
+	sa = memdup_user(arg, sizeof(*sa));
+	if (IS_ERR(sa))
+		return PTR_ERR(sa);
+
+	ret = btrfs_get_dev_stats(root, sa, reset_after_read);
+
+	if (copy_to_user(arg, sa, sizeof(*sa)))
+		ret = -EFAULT;
+
+	kfree(sa);
+	return ret;
+}
+
 static long btrfs_ioctl_ino_to_path(struct btrfs_root *root, void __user *arg)
 {
 	int ret = 0;
@@ -3424,6 +3446,10 @@ long btrfs_ioctl(struct file *file, unsigned int
 		return btrfs_ioctl_balance_ctl(root, arg);
 	case BTRFS_IOC_BALANCE_PROGRESS:
 		return btrfs_ioctl_balance_progress(root, argp);
+	case BTRFS_IOC_GET_DEV_STATS:
+		return btrfs_ioctl_get_dev_stats(root, argp, 0);
+	case BTRFS_IOC_GET_AND_RESET_DEV_STATS:
+		return btrfs_ioctl_get_dev_stats(root, argp, 1);
 	}
 
 	return -ENOTTY;
fs/btrfs/ioctl.h +14 -0
index 5bf05e2..497c530 100644
@@ -285,6 +285,16 @@ enum btrfs_dev_stat_values {
 	BTRFS_DEV_STAT_VALUES_MAX
 };
 
+struct btrfs_ioctl_get_dev_stats {
+	__u64 devid;				/* in */
+	__u64 nr_items;				/* in/out */
+
+	/* out values: */
+	__u64 values[BTRFS_DEV_STAT_VALUES_MAX];
+
+	__u64 unused[128 - 2 - BTRFS_DEV_STAT_VALUES_MAX]; /* pad to 1k */
+};
+
 #define BTRFS_IOC_SNAP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 1, \
 				   struct btrfs_ioctl_vol_args)
 #define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, \
@@ -349,5 +359,9 @@ enum btrfs_dev_stat_values {
 					struct btrfs_ioctl_ino_path_args)
 #define BTRFS_IOC_LOGICAL_INO _IOWR(BTRFS_IOCTL_MAGIC, 36, \
 					struct btrfs_ioctl_ino_path_args)
+#define BTRFS_IOC_GET_DEV_STATS _IOWR(BTRFS_IOCTL_MAGIC, 52, \
+				      struct btrfs_ioctl_get_dev_stats)
+#define BTRFS_IOC_GET_AND_RESET_DEV_STATS _IOWR(BTRFS_IOCTL_MAGIC, 53, \
+					struct btrfs_ioctl_get_dev_stats)
 
 #endif
fs/btrfs/volumes.c +34 -0
index 05e05fb..b9138b7 100644
@@ -4673,3 +4673,37 @@ void btrfs_dev_stat_print_on_error(struct btrfs_device *dev)
 			   btrfs_dev_stat_read(dev,
 					       BTRFS_DEV_STAT_GENERATION_ERRS));
 }
+
+int btrfs_get_dev_stats(struct btrfs_root *root,
+			struct btrfs_ioctl_get_dev_stats *stats,
+			int reset_after_read)
+{
+	struct btrfs_device *dev;
+	struct btrfs_fs_devices *fs_devices = root->fs_info->fs_devices;
+	int i;
+
+	mutex_lock(&fs_devices->device_list_mutex);
+	dev = btrfs_find_device(root, stats->devid, NULL, NULL);
+	mutex_unlock(&fs_devices->device_list_mutex);
+
+	if (!dev) {
+		printk(KERN_WARNING
+		       "btrfs: get dev_stats failed, device not found\n");
+		return -ENODEV;
+	} else if (reset_after_read) {
+		for (i = 0; i < BTRFS_DEV_STAT_VALUES_MAX; i++) {
+			if (stats->nr_items > i)
+				stats->values[i] =
+					btrfs_dev_stat_read_and_reset(dev, i);
+			else
+				btrfs_dev_stat_reset(dev, i);
+		}
+	} else {
+		for (i = 0; i < BTRFS_DEV_STAT_VALUES_MAX; i++)
+			if (stats->nr_items > i)
+				stats->values[i] = btrfs_dev_stat_read(dev, i);
+	}
+	if (stats->nr_items > BTRFS_DEV_STAT_VALUES_MAX)
+		stats->nr_items = BTRFS_DEV_STAT_VALUES_MAX;
+	return 0;
+}
fs/btrfs/volumes.h +3 -0
index 193b283..6798f86 100644
@@ -290,6 +290,9 @@ struct btrfs_device *btrfs_find_device_for_logical(struct btrfs_root *root,
 						   u64 logical, int mirror_num);
 void btrfs_dev_stat_print_on_error(struct btrfs_device *device);
 void btrfs_dev_stat_inc_and_print(struct btrfs_device *dev, int index);
+int btrfs_get_dev_stats(struct btrfs_root *root,
+			struct btrfs_ioctl_get_dev_stats *stats,
+			int reset_after_read);
 
 static inline void btrfs_dev_stat_inc(struct btrfs_device *dev,
 				      int index)
Signature · 1 line
1.7.10.2
#3 lore raw

PATCH v5 3/3 Btrfs: read device stats on mount, write modified ones during commit

In reply to Stefan Behrens

The device statistics are written into the device tree with each transaction commit. Only modified statistics are written. When a filesystem is mounted, the device statistics for each involved device are read from the device tree and used to initialize the counters.

---
 fs/btrfs/ctree.h       |   38 +++++++++++
 fs/btrfs/disk-io.c     |    7 ++
 fs/btrfs/print-tree.c  |    3 +
 fs/btrfs/transaction.c |    4 ++
 fs/btrfs/volumes.c     |  176 ++++++++++++++++++++++++++++++++++++++++++++++++
 fs/btrfs/volumes.h     |    4 ++
 6 files changed, 232 insertions(+)
fs/btrfs/ctree.h +38 -0
index ec42a24..3e5ab89 100644
@@ -823,6 +823,14 @@ struct btrfs_csum_item {
 	u8 csum;
 } __attribute__ ((__packed__));
 
+struct btrfs_dev_stats_item {
+	/*
+	 * grow this item struct at the end for future enhancements and keep
+	 * the existing values unchanged
+	 */
+	__le64 values[BTRFS_DEV_STAT_VALUES_MAX];
+} __attribute__ ((__packed__));
+
 /* different types of block groups (and chunks) */
 #define BTRFS_BLOCK_GROUP_DATA		(1ULL << 0)
 #define BTRFS_BLOCK_GROUP_SYSTEM	(1ULL << 1)
@@ -1508,6 +1516,12 @@ struct btrfs_ioctl_defrag_range_args {
 #define BTRFS_BALANCE_ITEM_KEY	248
 
 /*
+ * Persistantly stores the io stats in the device tree.
+ * One key for all stats, (0, BTRFS_DEV_STATS_KEY, devid).
+ */
+#define BTRFS_DEV_STATS_KEY	249
+
+/*
  * string items are for debugging.  They just store a short string of
  * data in the FS
  */
@@ -2415,6 +2429,30 @@ static inline u32 btrfs_file_extent_inline_item_len(struct extent_buffer *eb,
 	return btrfs_item_size(eb, e) - offset;
 }
 
+/* btrfs_dev_stats_item */
+static inline u64 btrfs_dev_stats_value(struct extent_buffer *eb,
+					struct btrfs_dev_stats_item *ptr,
+					int index)
+{
+	u64 val;
+
+	read_extent_buffer(eb, &val,
+			   offsetof(struct btrfs_dev_stats_item, values) +
+			    ((unsigned long)ptr) + (index * sizeof(u64)),
+			   sizeof(val));
+	return val;
+}
+
+static inline void btrfs_set_dev_stats_value(struct extent_buffer *eb,
+					     struct btrfs_dev_stats_item *ptr,
+					     int index, u64 val)
+{
+	write_extent_buffer(eb, &val,
+			    offsetof(struct btrfs_dev_stats_item, values) +
+			     ((unsigned long)ptr) + (index * sizeof(u64)),
+			    sizeof(val));
+}
+
 static inline struct btrfs_fs_info *btrfs_sb(struct super_block *sb)
 {
 	return sb->s_fs_info;
fs/btrfs/disk-io.c +7 -0
index da4d33f..00f541a 100644
@@ -2353,6 +2353,13 @@ retry_root_backup:
 	fs_info->generation = generation;
 	fs_info->last_trans_committed = generation;
 
+	ret = btrfs_init_dev_stats(fs_info);
+	if (ret) {
+		printk(KERN_ERR "btrfs: failed to init dev_stats: %d\n",
+		       ret);
+		goto fail_block_groups;
+	}
+
 	ret = btrfs_init_space_info(fs_info);
 	if (ret) {
 		printk(KERN_ERR "Failed to initial space info: %d\n", ret);
fs/btrfs/print-tree.c +3 -0
index f38e452..5e23684 100644
@@ -294,6 +294,9 @@ void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l)
 			       btrfs_dev_extent_chunk_offset(l, dev_extent),
 			       (unsigned long long)
 			       btrfs_dev_extent_length(l, dev_extent));
+		case BTRFS_DEV_STATS_KEY:
+			printk(KERN_INFO "\t\tdevice stats\n");
+			break;
 		};
 	}
 }
fs/btrfs/transaction.c +4 -0
index 3642225..82b03af 100644
@@ -28,6 +28,7 @@
 #include "locking.h"
 #include "tree-log.h"
 #include "inode-map.h"
+#include "volumes.h"
 
 #define BTRFS_ROOT_TRANS_TAG 0
 
@@ -758,6 +759,9 @@ static noinline int commit_cowonly_roots(struct btrfs_trans_handle *trans,
 	if (ret)
 		return ret;
 
+	ret = btrfs_run_dev_stats(trans, root->fs_info);
+	BUG_ON(ret);
+
 	while (!list_empty(&fs_info->dirty_cowonly_roots)) {
 		next = fs_info->dirty_cowonly_roots.next;
 		list_del_init(next);
fs/btrfs/volumes.c +176 -0

212 lines not on this page · raw message

fs/btrfs/volumes.h +4 -0
index 6798f86..3406a88 100644
@@ -109,6 +109,7 @@ struct btrfs_device {
 
 	/* disk I/O failure stats. For detailed description refer to
 	 * enum btrfs_dev_stat_values in ioctl.h */
+	int dev_stats_valid;
 	int dev_stats_dirty; /* counters need to be written to disk */
 	atomic_t dev_stat_values[BTRFS_DEV_STAT_VALUES_MAX];
 };
@@ -293,6 +294,9 @@ void btrfs_dev_stat_inc_and_print(struct btrfs_device *dev, int index);
 int btrfs_get_dev_stats(struct btrfs_root *root,
 			struct btrfs_ioctl_get_dev_stats *stats,
 			int reset_after_read);
+int btrfs_init_dev_stats(struct btrfs_fs_info *fs_info);
+int btrfs_run_dev_stats(struct btrfs_trans_handle *trans,
+			struct btrfs_fs_info *fs_info);
 
 static inline void btrfs_dev_stat_inc(struct btrfs_device *dev,
 				      int index)
Signature · 1 line
1.7.10.2
#4 lore raw
In reply to Stefan Behrens

Can you explain why the device error counters should be in a filesystem instead of generic block layer code?

Quoted 45 lines · Stefan Behrens

Changes v1-v2:
- Remove restriction that BTRFS_IOC_GET_DEVICE_STATS is a privileged operation
- Cast u64 to unsigned long long for printf()

Changes v2-v3:
- Rebased on Chris' current master

Changes v3-v4:
- Add padding at end of ioctl structure

Changes v4-v5:
- The statistic members in the ioctl are now organized as an array of 64 bit values. Symbolic names for the array indexes are defined in an enum, which also defines the max value. This change makes it easier to add new statistic members in the future
- Give ins_len = -1 to btrfs_search_slot() when an item might get deleted
- Introduce a helper function for the repeated sequence stat_int() + dirty = 1 + stat_print()
- Introduce a helper function for the code that shares the bio bi_private member for two pieces of information

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.

An ioctl interface is added to get the device statistic counters. A second ioctl is added to atomically get and reset these counters.

The device statistics are written into the device tree with each transaction commit. Only modified statistics are written. When a filesystem is mounted, the device statistics for each involved device are read from the device tree and used to initialize the counters.

A patch for the btrfs-progs world will also be sent.

Stefan Behrens (3):
Btrfs: add device counters for detected IO and checksum errors
Btrfs: add ioctl to get and reset the device stats
Btrfs: read device stats on mount, write modified ones during commit

Quoted 19 lines
 fs/btrfs/ctree.h       |   38 ++++++
 fs/btrfs/disk-io.c     |   20 +++-
 fs/btrfs/extent_io.c   |   18 ++-
 fs/btrfs/ioctl.c       |   26 +++++
 fs/btrfs/ioctl.h       |   33 ++++++
 fs/btrfs/print-tree.c  |    3 +
 fs/btrfs/scrub.c       |   65 ++++++++---
 fs/btrfs/transaction.c |    4 +
 fs/btrfs/volumes.c     |  304 +++++++++++++++++++++++++++++++++++++++++++++++-
 fs/btrfs/volumes.h     |   52 +++++++++
 10 files changed, 539 insertions(+), 24 deletions(-)
Signature · 6 lines
1.7.10.2

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

---end quoted text---

#5 lore raw

It would be helpful if already the generic block layer would offer device error counters. Then btrfs could read them, add own counters for its checksum detected errors, and store everything persistently in the filesystem.

The goal is to replace disks that have an increased error rate with spare disks, and the goal is to repair this degenerated RAID state quickly.

Quoted 4 lines · Christoph Hellwig

Can you explain why the device error counters should be in a filesystem instead of generic block layer code?

On Fri, May 25, 2012 at 04:06:07PM +0200, Stefan Behrens wrote:

[...]

Quoted 36 lines
Quoted 36 lines

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.

An ioctl interface is added to get the device statistic counters. A second ioctl is added to atomically get and reset these counters.

The device statistics are written into the device tree with each transaction commit. Only modified statistics are written. When a filesystem is mounted, the device statistics for each involved device are read from the device tree and used to initialize the counters.

A patch for the btrfs-progs world will also be sent.

Stefan Behrens (3):
Btrfs: add device counters for detected IO and checksum errors
Btrfs: add ioctl to get and reset the device stats
Btrfs: read device stats on mount, write modified ones during commit

  fs/btrfs/ctree.h       |   38 ++++++
  fs/btrfs/disk-io.c     |   20 +++-
  fs/btrfs/extent_io.c   |   18 ++-
  fs/btrfs/ioctl.c       |   26 +++++
  fs/btrfs/ioctl.h       |   33 ++++++
  fs/btrfs/print-tree.c  |    3 +
  fs/btrfs/scrub.c       |   65 ++++++++---
  fs/btrfs/transaction.c |    4 +
  fs/btrfs/volumes.c     |  304 +++++++++++++++++++++++++++++++++++++++++++++++-
  fs/btrfs/volumes.h     |   52 +++++++++
  10 files changed, 539 insertions(+), 24 deletions(-)

--
1.7.10.2

#6 lore raw
Quoted 5 lines · Stefan Behrens

It would be helpful if already the generic block layer would offer device error counters. Then btrfs could read them, add own counters for its checksum detected errors, and store everything persistently in the filesystem.

I take it that you not only count I/O-errors, but also corrupted blocks and errors generated by misdirected writes. These are informations that are not available to the block layer.

Quoted 51 lines

The goal is to replace disks that have an increased error rate with spare disks, and the goal is to repair this degenerated RAID state quickly.

Quoted 4 lines · Christoph Hellwig

Can you explain why the device error counters should be in a filesystem instead of generic block layer code?

On Fri, May 25, 2012 at 04:06:07PM +0200, Stefan Behrens wrote:

[...]

Quoted 35 lines
Quoted 35 lines

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.

An ioctl interface is added to get the device statistic counters. A second ioctl is added to atomically get and reset these counters.

The device statistics are written into the device tree with each transaction commit. Only modified statistics are written. When a filesystem is mounted, the device statistics for each involved device are read from the device tree and used to initialize the counters.

A patch for the btrfs-progs world will also be sent.

Stefan Behrens (3):
Btrfs: add device counters for detected IO and checksum errors
Btrfs: add ioctl to get and reset the device stats
Btrfs: read device stats on mount, write modified ones during commit

fs/btrfs/ctree.h | 38 ++++++
fs/btrfs/disk-io.c | 20 +++-
fs/btrfs/extent_io.c | 18 ++-
fs/btrfs/ioctl.c | 26 +++++
fs/btrfs/ioctl.h | 33 ++++++
fs/btrfs/print-tree.c | 3 +
fs/btrfs/scrub.c | 65 ++++++++---
fs/btrfs/transaction.c | 4 +
fs/btrfs/volumes.c | 304
+++++++++++++++++++++++++++++++++++++++++++++++-
fs/btrfs/volumes.h | 52 +++++++++

10 files changed, 539 insertions(+), 24 deletions(-)
Quoted 2 lines
Quoted 2 lines

--
1.7.10.2

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html