]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
btrfs: export more from FS_INFO to sysfs
authorDavid Sterba <dsterba@suse.cz>
Wed, 7 May 2014 16:17:16 +0000 (18:17 +0200)
committerChris Mason <clm@fb.com>
Tue, 10 Jun 2014 00:20:28 +0000 (17:20 -0700)
Similar to the FS_INFO updates, export the basic filesystem info through
sysfs: node size, sector size and clone alignment.

Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/sysfs.c

index c5eb2143dc66760d088161e8b201de3effc342c6..ba2a645dee07fce231158c2fa1d227a2ce607d7b 100644 (file)
@@ -396,8 +396,48 @@ static ssize_t btrfs_label_store(struct kobject *kobj,
 }
 BTRFS_ATTR_RW(label, 0644, btrfs_label_show, btrfs_label_store);
 
+static ssize_t btrfs_no_store(struct kobject *kobj,
+                                struct kobj_attribute *a,
+                                const char *buf, size_t len)
+{
+       return -EPERM;
+}
+
+static ssize_t btrfs_nodesize_show(struct kobject *kobj,
+                               struct kobj_attribute *a, char *buf)
+{
+       struct btrfs_fs_info *fs_info = to_fs_info(kobj);
+
+       return snprintf(buf, PAGE_SIZE, "%u\n", fs_info->super_copy->nodesize);
+}
+
+BTRFS_ATTR_RW(nodesize, 0444, btrfs_nodesize_show, btrfs_no_store);
+
+static ssize_t btrfs_sectorsize_show(struct kobject *kobj,
+                               struct kobj_attribute *a, char *buf)
+{
+       struct btrfs_fs_info *fs_info = to_fs_info(kobj);
+
+       return snprintf(buf, PAGE_SIZE, "%u\n", fs_info->super_copy->sectorsize);
+}
+
+BTRFS_ATTR_RW(sectorsize, 0444, btrfs_sectorsize_show, btrfs_no_store);
+
+static ssize_t btrfs_clone_alignment_show(struct kobject *kobj,
+                               struct kobj_attribute *a, char *buf)
+{
+       struct btrfs_fs_info *fs_info = to_fs_info(kobj);
+
+       return snprintf(buf, PAGE_SIZE, "%u\n", fs_info->super_copy->sectorsize);
+}
+
+BTRFS_ATTR_RW(clone_alignment, 0444, btrfs_clone_alignment_show, btrfs_no_store);
+
 static struct attribute *btrfs_attrs[] = {
        BTRFS_ATTR_PTR(label),
+       BTRFS_ATTR_PTR(nodesize),
+       BTRFS_ATTR_PTR(sectorsize),
+       BTRFS_ATTR_PTR(clone_alignment),
        NULL,
 };