Skip to content

Commit df93589

Browse files
kdavemasoncl
authored andcommitted
btrfs: export more from FS_INFO to sysfs
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>
1 parent 80a773f commit df93589

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

fs/btrfs/sysfs.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,48 @@ static ssize_t btrfs_label_store(struct kobject *kobj,
396396
}
397397
BTRFS_ATTR_RW(label, 0644, btrfs_label_show, btrfs_label_store);
398398

399+
static ssize_t btrfs_no_store(struct kobject *kobj,
400+
struct kobj_attribute *a,
401+
const char *buf, size_t len)
402+
{
403+
return -EPERM;
404+
}
405+
406+
static ssize_t btrfs_nodesize_show(struct kobject *kobj,
407+
struct kobj_attribute *a, char *buf)
408+
{
409+
struct btrfs_fs_info *fs_info = to_fs_info(kobj);
410+
411+
return snprintf(buf, PAGE_SIZE, "%u\n", fs_info->super_copy->nodesize);
412+
}
413+
414+
BTRFS_ATTR_RW(nodesize, 0444, btrfs_nodesize_show, btrfs_no_store);
415+
416+
static ssize_t btrfs_sectorsize_show(struct kobject *kobj,
417+
struct kobj_attribute *a, char *buf)
418+
{
419+
struct btrfs_fs_info *fs_info = to_fs_info(kobj);
420+
421+
return snprintf(buf, PAGE_SIZE, "%u\n", fs_info->super_copy->sectorsize);
422+
}
423+
424+
BTRFS_ATTR_RW(sectorsize, 0444, btrfs_sectorsize_show, btrfs_no_store);
425+
426+
static ssize_t btrfs_clone_alignment_show(struct kobject *kobj,
427+
struct kobj_attribute *a, char *buf)
428+
{
429+
struct btrfs_fs_info *fs_info = to_fs_info(kobj);
430+
431+
return snprintf(buf, PAGE_SIZE, "%u\n", fs_info->super_copy->sectorsize);
432+
}
433+
434+
BTRFS_ATTR_RW(clone_alignment, 0444, btrfs_clone_alignment_show, btrfs_no_store);
435+
399436
static struct attribute *btrfs_attrs[] = {
400437
BTRFS_ATTR_PTR(label),
438+
BTRFS_ATTR_PTR(nodesize),
439+
BTRFS_ATTR_PTR(sectorsize),
440+
BTRFS_ATTR_PTR(clone_alignment),
401441
NULL,
402442
};
403443

0 commit comments

Comments
 (0)