Skip to content

Commit 56f20f4

Browse files
lorddoskiaskdave
authored andcommitted
btrfs: Add sysfs support for metadata_uuid feature
Since the metadata_uuid is a new incompat feature it requires the respective sysfs hooks. This patch adds the 'metdata_uuid' feature to be shown if it supported by the kernel. Additionally it adds /sys/fs/btrfs/UUID/metadata_uuid attribute which allows one to read the current metadata_uuid. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 7239ff4 commit 56f20f4

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

fs/btrfs/sysfs.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ BTRFS_FEAT_ATTR_INCOMPAT(extended_iref, EXTENDED_IREF);
191191
BTRFS_FEAT_ATTR_INCOMPAT(raid56, RAID56);
192192
BTRFS_FEAT_ATTR_INCOMPAT(skinny_metadata, SKINNY_METADATA);
193193
BTRFS_FEAT_ATTR_INCOMPAT(no_holes, NO_HOLES);
194+
BTRFS_FEAT_ATTR_INCOMPAT(metadata_uuid, METADATA_UUID);
194195
BTRFS_FEAT_ATTR_COMPAT_RO(free_space_tree, FREE_SPACE_TREE);
195196

196197
static struct attribute *btrfs_supported_feature_attrs[] = {
@@ -204,6 +205,7 @@ static struct attribute *btrfs_supported_feature_attrs[] = {
204205
BTRFS_FEAT_ATTR_PTR(raid56),
205206
BTRFS_FEAT_ATTR_PTR(skinny_metadata),
206207
BTRFS_FEAT_ATTR_PTR(no_holes),
208+
BTRFS_FEAT_ATTR_PTR(metadata_uuid),
207209
BTRFS_FEAT_ATTR_PTR(free_space_tree),
208210
NULL
209211
};
@@ -505,12 +507,24 @@ static ssize_t quota_override_store(struct kobject *kobj,
505507

506508
BTRFS_ATTR_RW(, quota_override, quota_override_show, quota_override_store);
507509

510+
static ssize_t btrfs_metadata_uuid_show(struct kobject *kobj,
511+
struct kobj_attribute *a, char *buf)
512+
{
513+
struct btrfs_fs_info *fs_info = to_fs_info(kobj);
514+
515+
return snprintf(buf, PAGE_SIZE, "%pU\n",
516+
fs_info->fs_devices->metadata_uuid);
517+
}
518+
519+
BTRFS_ATTR(, metadata_uuid, btrfs_metadata_uuid_show);
520+
508521
static const struct attribute *btrfs_attrs[] = {
509522
BTRFS_ATTR_PTR(, label),
510523
BTRFS_ATTR_PTR(, nodesize),
511524
BTRFS_ATTR_PTR(, sectorsize),
512525
BTRFS_ATTR_PTR(, clone_alignment),
513526
BTRFS_ATTR_PTR(, quota_override),
527+
BTRFS_ATTR_PTR(, metadata_uuid),
514528
NULL,
515529
};
516530

0 commit comments

Comments
 (0)