summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/sysfs.c
diff options
context:
space:
mode:
authorDennis Zhou <dennis@kernel.org>2019-12-13 16:22:21 -0800
committerDavid Sterba <dsterba@suse.com>2020-01-20 16:40:59 +0100
commit5dc7c10b87474c98116d3438739743cd77263e9f (patch)
tree3636b859f5228c8df8d777b2b5a4ec9559510978 /fs/btrfs/sysfs.c
parentdfb79ddb130e0a239e3e90aaf5f5b908555f52bb (diff)
downloadlinux-5dc7c10b87474c98116d3438739743cd77263e9f.tar.bz2
btrfs: keep track of discardable_bytes for async discard
Keep track of this metric so that we can understand how ahead or behind we are in discarding rate. This uses the same accounting method as discardable_extents, deltas between previous/current values and propagating them up. Signed-off-by: Dennis Zhou <dennis@kernel.org> Reviewed-by: David Sterba <dsterba@suse.com> [ update changelog ] Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/sysfs.c')
-rw-r--r--fs/btrfs/sysfs.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 0ac122c67065..ce1da3fcd6c9 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -344,6 +344,17 @@ static const struct attribute_group btrfs_static_feature_attr_group = {
*/
#define discard_to_fs_info(_kobj) to_fs_info((_kobj)->parent->parent)
+static ssize_t btrfs_discardable_bytes_show(struct kobject *kobj,
+ struct kobj_attribute *a,
+ char *buf)
+{
+ struct btrfs_fs_info *fs_info = discard_to_fs_info(kobj);
+
+ return snprintf(buf, PAGE_SIZE, "%lld\n",
+ atomic64_read(&fs_info->discard_ctl.discardable_bytes));
+}
+BTRFS_ATTR(discard, discardable_bytes, btrfs_discardable_bytes_show);
+
static ssize_t btrfs_discardable_extents_show(struct kobject *kobj,
struct kobj_attribute *a,
char *buf)
@@ -356,6 +367,7 @@ static ssize_t btrfs_discardable_extents_show(struct kobject *kobj,
BTRFS_ATTR(discard, discardable_extents, btrfs_discardable_extents_show);
static const struct attribute *discard_debug_attrs[] = {
+ BTRFS_ATTR_PTR(discard, discardable_bytes),
BTRFS_ATTR_PTR(discard, discardable_extents),
NULL,
};