diff options
author | Stefan Behrens <sbehrens@giantdisaster.de> | 2012-05-25 10:06:09 -0400 |
---|---|---|
committer | Josef Bacik <josef@redhat.com> | 2012-05-30 10:23:40 -0400 |
commit | c11d2c236cc260b36ef644700fbe99bcc7e7da33 (patch) | |
tree | e240721e0b6e5784177ac39bc299db4063b93c72 /fs/btrfs/ioctl.c | |
parent | 442a4f6308e694e0fa6025708bd5e4e424bbf51c (diff) |
Btrfs: add ioctl to get and reset the device stats
An ioctl interface is added to get the device statistic counters.
A second ioctl is added to atomically get and reset these counters.
Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
Diffstat (limited to 'fs/btrfs/ioctl.c')
-rw-r--r-- | fs/btrfs/ioctl.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 15baf9456300..0f8c354c4c76 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c | |||
@@ -3046,6 +3046,28 @@ static long btrfs_ioctl_scrub_progress(struct btrfs_root *root, | |||
3046 | return ret; | 3046 | return ret; |
3047 | } | 3047 | } |
3048 | 3048 | ||
3049 | static long btrfs_ioctl_get_dev_stats(struct btrfs_root *root, | ||
3050 | void __user *arg, int reset_after_read) | ||
3051 | { | ||
3052 | struct btrfs_ioctl_get_dev_stats *sa; | ||
3053 | int ret; | ||
3054 | |||
3055 | if (reset_after_read && !capable(CAP_SYS_ADMIN)) | ||
3056 | return -EPERM; | ||
3057 | |||
3058 | sa = memdup_user(arg, sizeof(*sa)); | ||
3059 | if (IS_ERR(sa)) | ||
3060 | return PTR_ERR(sa); | ||
3061 | |||
3062 | ret = btrfs_get_dev_stats(root, sa, reset_after_read); | ||
3063 | |||
3064 | if (copy_to_user(arg, sa, sizeof(*sa))) | ||
3065 | ret = -EFAULT; | ||
3066 | |||
3067 | kfree(sa); | ||
3068 | return ret; | ||
3069 | } | ||
3070 | |||
3049 | static long btrfs_ioctl_ino_to_path(struct btrfs_root *root, void __user *arg) | 3071 | static long btrfs_ioctl_ino_to_path(struct btrfs_root *root, void __user *arg) |
3050 | { | 3072 | { |
3051 | int ret = 0; | 3073 | int ret = 0; |
@@ -3434,6 +3456,10 @@ long btrfs_ioctl(struct file *file, unsigned int | |||
3434 | return btrfs_ioctl_balance_ctl(root, arg); | 3456 | return btrfs_ioctl_balance_ctl(root, arg); |
3435 | case BTRFS_IOC_BALANCE_PROGRESS: | 3457 | case BTRFS_IOC_BALANCE_PROGRESS: |
3436 | return btrfs_ioctl_balance_progress(root, argp); | 3458 | return btrfs_ioctl_balance_progress(root, argp); |
3459 | case BTRFS_IOC_GET_DEV_STATS: | ||
3460 | return btrfs_ioctl_get_dev_stats(root, argp, 0); | ||
3461 | case BTRFS_IOC_GET_AND_RESET_DEV_STATS: | ||
3462 | return btrfs_ioctl_get_dev_stats(root, argp, 1); | ||
3437 | } | 3463 | } |
3438 | 3464 | ||
3439 | return -ENOTTY; | 3465 | return -ENOTTY; |