Skip to content

Commit f362374

Browse files
asjkdave
authored andcommitted
btrfs: sysfs: show temp_fsid feature
This adds sysfs objects to indicate temp_fsid feature support and its status. /sys/fs/btrfs/features/temp_fsid /sys/fs/btrfs/<UUID>/temp_fsid For example: Consider two cloned and mounted devices. $ blkid /dev/sdc[1-2] /dev/sdc1: UUID="509ad44b-ad2a-4a8a-bc8d-fe69db7220d5" .. /dev/sdc2: UUID="509ad44b-ad2a-4a8a-bc8d-fe69db7220d5" .. One gets actual fsid, and the other gets the temp_fsid when mounted. $ btrfs filesystem show -m Label: none uuid: 509ad44b-ad2a-4a8a-bc8d-fe69db7220d5 Total devices 1 FS bytes used 54.14MiB devid 1 size 300.00MiB used 144.00MiB path /dev/sdc1 Label: none uuid: 33bad74e-c91b-43a5-aef8-b3cab97ae63a Total devices 1 FS bytes used 54.14MiB devid 1 size 300.00MiB used 144.00MiB path /dev/sdc2 Their sysfs as below. $ cat /sys/fs/btrfs/features/temp_fsid 0 $ cat /sys/fs/btrfs/509ad44b-ad2a-4a8a-bc8d-fe69db7220d5/temp_fsid 0 $ cat /sys/fs/btrfs/33bad74e-c91b-43a5-aef8-b3cab97ae63a/temp_fsid 1 Signed-off-by: Anand Jain <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent ac6ea6a commit f362374

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

fs/btrfs/sysfs.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,13 @@ static ssize_t acl_show(struct kobject *kobj, struct kobj_attribute *a, char *bu
425425
}
426426
BTRFS_ATTR(static_feature, acl, acl_show);
427427

428+
static ssize_t temp_fsid_supported_show(struct kobject *kobj,
429+
struct kobj_attribute *a, char *buf)
430+
{
431+
return sysfs_emit(buf, "0\n");
432+
}
433+
BTRFS_ATTR(static_feature, temp_fsid, temp_fsid_supported_show);
434+
428435
/*
429436
* Features which only depend on kernel version.
430437
*
@@ -438,6 +445,7 @@ static struct attribute *btrfs_supported_static_feature_attrs[] = {
438445
BTRFS_ATTR_PTR(static_feature, send_stream_version),
439446
BTRFS_ATTR_PTR(static_feature, supported_rescue_options),
440447
BTRFS_ATTR_PTR(static_feature, supported_sectorsizes),
448+
BTRFS_ATTR_PTR(static_feature, temp_fsid),
441449
NULL
442450
};
443451

@@ -1205,6 +1213,15 @@ static ssize_t btrfs_generation_show(struct kobject *kobj,
12051213
}
12061214
BTRFS_ATTR(, generation, btrfs_generation_show);
12071215

1216+
static ssize_t btrfs_temp_fsid_show(struct kobject *kobj,
1217+
struct kobj_attribute *a, char *buf)
1218+
{
1219+
struct btrfs_fs_info *fs_info = to_fs_info(kobj);
1220+
1221+
return sysfs_emit(buf, "%d\n", fs_info->fs_devices->temp_fsid);
1222+
}
1223+
BTRFS_ATTR(, temp_fsid, btrfs_temp_fsid_show);
1224+
12081225
static const char * const btrfs_read_policy_name[] = { "pid" };
12091226

12101227
static ssize_t btrfs_read_policy_show(struct kobject *kobj,
@@ -1307,6 +1324,7 @@ static const struct attribute *btrfs_attrs[] = {
13071324
BTRFS_ATTR_PTR(, read_policy),
13081325
BTRFS_ATTR_PTR(, bg_reclaim_threshold),
13091326
BTRFS_ATTR_PTR(, commit_stats),
1327+
BTRFS_ATTR_PTR(, temp_fsid),
13101328
NULL,
13111329
};
13121330

0 commit comments

Comments
 (0)