diff options
Diffstat (limited to 'fs/btrfs/volumes.h')
-rw-r--r-- | fs/btrfs/volumes.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index bb6b03f97aaa..3406a88ca83e 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,11 @@ 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_valid; | ||
113 | int dev_stats_dirty; /* counters need to be written to disk */ | ||
114 | atomic_t dev_stat_values[BTRFS_DEV_STAT_VALUES_MAX]; | ||
109 | }; | 115 | }; |
110 | 116 | ||
111 | struct btrfs_fs_devices { | 117 | struct btrfs_fs_devices { |
@@ -281,4 +287,50 @@ int btrfs_cancel_balance(struct btrfs_fs_info *fs_info); | |||
281 | int btrfs_chunk_readonly(struct btrfs_root *root, u64 chunk_offset); | 287 | int btrfs_chunk_readonly(struct btrfs_root *root, u64 chunk_offset); |
282 | int find_free_dev_extent(struct btrfs_device *device, u64 num_bytes, | 288 | int find_free_dev_extent(struct btrfs_device *device, u64 num_bytes, |
283 | u64 *start, u64 *max_avail); | 289 | u64 *start, u64 *max_avail); |
290 | struct btrfs_device *btrfs_find_device_for_logical(struct btrfs_root *root, | ||
291 | u64 logical, int mirror_num); | ||
292 | void btrfs_dev_stat_print_on_error(struct btrfs_device *device); | ||
293 | void btrfs_dev_stat_inc_and_print(struct btrfs_device *dev, int index); | ||
294 | int btrfs_get_dev_stats(struct btrfs_root *root, | ||
295 | struct btrfs_ioctl_get_dev_stats *stats, | ||
296 | int reset_after_read); | ||
297 | int btrfs_init_dev_stats(struct btrfs_fs_info *fs_info); | ||
298 | int btrfs_run_dev_stats(struct btrfs_trans_handle *trans, | ||
299 | struct btrfs_fs_info *fs_info); | ||
300 | |||
301 | static inline void btrfs_dev_stat_inc(struct btrfs_device *dev, | ||
302 | int index) | ||
303 | { | ||
304 | atomic_inc(dev->dev_stat_values + index); | ||
305 | dev->dev_stats_dirty = 1; | ||
306 | } | ||
307 | |||
308 | static inline int btrfs_dev_stat_read(struct btrfs_device *dev, | ||
309 | int index) | ||
310 | { | ||
311 | return atomic_read(dev->dev_stat_values + index); | ||
312 | } | ||
313 | |||
314 | static inline int btrfs_dev_stat_read_and_reset(struct btrfs_device *dev, | ||
315 | int index) | ||
316 | { | ||
317 | int ret; | ||
318 | |||
319 | ret = atomic_xchg(dev->dev_stat_values + index, 0); | ||
320 | dev->dev_stats_dirty = 1; | ||
321 | return ret; | ||
322 | } | ||
323 | |||
324 | static inline void btrfs_dev_stat_set(struct btrfs_device *dev, | ||
325 | int index, unsigned long val) | ||
326 | { | ||
327 | atomic_set(dev->dev_stat_values + index, val); | ||
328 | dev->dev_stats_dirty = 1; | ||
329 | } | ||
330 | |||
331 | static inline void btrfs_dev_stat_reset(struct btrfs_device *dev, | ||
332 | int index) | ||
333 | { | ||
334 | btrfs_dev_stat_set(dev, index, 0); | ||
335 | } | ||
284 | #endif | 336 | #endif |