aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/volumes.h
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/volumes.h
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/volumes.h')
-rw-r--r--fs/btrfs/volumes.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
index bb6b03f97aaa..193b2835e6ae 100644
--- a/fs/btrfs/volumes.h
+++ b/fs/btrfs/volumes.h
@@ -22,6 +22,7 @@
22#include <linux/bio.h> 22#include <linux/bio.h>
23#include <linux/sort.h> 23#include <linux/sort.h>
24#include "async-thread.h" 24#include "async-thread.h"
25#include "ioctl.h"
25 26
26#define BTRFS_STRIPE_LEN (64 * 1024) 27#define BTRFS_STRIPE_LEN (64 * 1024)
27 28
@@ -106,6 +107,10 @@ struct btrfs_device {
106 struct completion flush_wait; 107 struct completion flush_wait;
107 int nobarriers; 108 int nobarriers;
108 109
110 /* disk I/O failure stats. For detailed description refer to
111 * enum btrfs_dev_stat_values in ioctl.h */
112 int dev_stats_dirty; /* counters need to be written to disk */
113 atomic_t dev_stat_values[BTRFS_DEV_STAT_VALUES_MAX];
109}; 114};
110 115
111struct btrfs_fs_devices { 116struct btrfs_fs_devices {
@@ -281,4 +286,44 @@ int btrfs_cancel_balance(struct btrfs_fs_info *fs_info);
281int btrfs_chunk_readonly(struct btrfs_root *root, u64 chunk_offset); 286int btrfs_chunk_readonly(struct btrfs_root *root, u64 chunk_offset);
282int find_free_dev_extent(struct btrfs_device *device, u64 num_bytes, 287int find_free_dev_extent(struct btrfs_device *device, u64 num_bytes,
283 u64 *start, u64 *max_avail); 288 u64 *start, u64 *max_avail);
289struct btrfs_device *btrfs_find_device_for_logical(struct btrfs_root *root,
290 u64 logical, int mirror_num);
291void btrfs_dev_stat_print_on_error(struct btrfs_device *device);
292void btrfs_dev_stat_inc_and_print(struct btrfs_device *dev, int index);
293
294static inline void btrfs_dev_stat_inc(struct btrfs_device *dev,
295 int index)
296{
297 atomic_inc(dev->dev_stat_values + index);
298 dev->dev_stats_dirty = 1;
299}
300
301static inline int btrfs_dev_stat_read(struct btrfs_device *dev,
302 int index)
303{
304 return atomic_read(dev->dev_stat_values + index);
305}
306
307static inline int btrfs_dev_stat_read_and_reset(struct btrfs_device *dev,
308 int index)
309{
310 int ret;
311
312 ret = atomic_xchg(dev->dev_stat_values + index, 0);
313 dev->dev_stats_dirty = 1;
314 return ret;
315}
316
317static inline void btrfs_dev_stat_set(struct btrfs_device *dev,
318 int index, unsigned long val)
319{
320 atomic_set(dev->dev_stat_values + index, val);
321 dev->dev_stats_dirty = 1;
322}
323
324static inline void btrfs_dev_stat_reset(struct btrfs_device *dev,
325 int index)
326{
327 btrfs_dev_stat_set(dev, index, 0);
328}
284#endif 329#endif