]> git.ipfire.org Git - thirdparty/linux.git/blobdiff - fs/btrfs/sysfs.c
btrfs: add and use helpers for reading and writing fs_info->generation
[thirdparty/linux.git] / fs / btrfs / sysfs.c
index b1d1ac25237b7ae82b1fe963e4dd31481a2908e6..21ab8b9b62ce1f5c56dd6b6d579354ede9b516fe 100644 (file)
@@ -291,12 +291,15 @@ BTRFS_FEAT_ATTR_INCOMPAT(metadata_uuid, METADATA_UUID);
 BTRFS_FEAT_ATTR_COMPAT_RO(free_space_tree, FREE_SPACE_TREE);
 BTRFS_FEAT_ATTR_COMPAT_RO(block_group_tree, BLOCK_GROUP_TREE);
 BTRFS_FEAT_ATTR_INCOMPAT(raid1c34, RAID1C34);
+BTRFS_FEAT_ATTR_INCOMPAT(simple_quota, SIMPLE_QUOTA);
 #ifdef CONFIG_BLK_DEV_ZONED
 BTRFS_FEAT_ATTR_INCOMPAT(zoned, ZONED);
 #endif
 #ifdef CONFIG_BTRFS_DEBUG
 /* Remove once support for extent tree v2 is feature complete */
 BTRFS_FEAT_ATTR_INCOMPAT(extent_tree_v2, EXTENT_TREE_V2);
+/* Remove once support for raid stripe tree is feature complete. */
+BTRFS_FEAT_ATTR_INCOMPAT(raid_stripe_tree, RAID_STRIPE_TREE);
 #endif
 #ifdef CONFIG_FS_VERITY
 BTRFS_FEAT_ATTR_COMPAT_RO(verity, VERITY);
@@ -322,11 +325,13 @@ static struct attribute *btrfs_supported_feature_attrs[] = {
        BTRFS_FEAT_ATTR_PTR(free_space_tree),
        BTRFS_FEAT_ATTR_PTR(raid1c34),
        BTRFS_FEAT_ATTR_PTR(block_group_tree),
+       BTRFS_FEAT_ATTR_PTR(simple_quota),
 #ifdef CONFIG_BLK_DEV_ZONED
        BTRFS_FEAT_ATTR_PTR(zoned),
 #endif
 #ifdef CONFIG_BTRFS_DEBUG
        BTRFS_FEAT_ATTR_PTR(extent_tree_v2),
+       BTRFS_FEAT_ATTR_PTR(raid_stripe_tree),
 #endif
 #ifdef CONFIG_FS_VERITY
        BTRFS_FEAT_ATTR_PTR(verity),
@@ -1196,7 +1201,7 @@ static ssize_t btrfs_generation_show(struct kobject *kobj,
 {
        struct btrfs_fs_info *fs_info = to_fs_info(kobj);
 
-       return sysfs_emit(buf, "%llu\n", fs_info->generation);
+       return sysfs_emit(buf, "%llu\n", btrfs_get_fs_generation(fs_info));
 }
 BTRFS_ATTR(, generation, btrfs_generation_show);
 
@@ -2086,6 +2091,33 @@ static ssize_t qgroup_enabled_show(struct kobject *qgroups_kobj,
 }
 BTRFS_ATTR(qgroups, enabled, qgroup_enabled_show);
 
+static ssize_t qgroup_mode_show(struct kobject *qgroups_kobj,
+                               struct kobj_attribute *a,
+                               char *buf)
+{
+       struct btrfs_fs_info *fs_info = to_fs_info(qgroups_kobj->parent);
+       ssize_t ret = 0;
+
+       spin_lock(&fs_info->qgroup_lock);
+       ASSERT(btrfs_qgroup_enabled(fs_info));
+       switch (btrfs_qgroup_mode(fs_info)) {
+       case BTRFS_QGROUP_MODE_FULL:
+               ret = sysfs_emit(buf, "qgroup\n");
+               break;
+       case BTRFS_QGROUP_MODE_SIMPLE:
+               ret = sysfs_emit(buf, "squota\n");
+               break;
+       default:
+               btrfs_warn(fs_info, "unexpected qgroup mode %d\n",
+                          btrfs_qgroup_mode(fs_info));
+               break;
+       }
+       spin_unlock(&fs_info->qgroup_lock);
+
+       return ret;
+}
+BTRFS_ATTR(qgroups, mode, qgroup_mode_show);
+
 static ssize_t qgroup_inconsistent_show(struct kobject *qgroups_kobj,
                                        struct kobj_attribute *a,
                                        char *buf)
@@ -2148,6 +2180,7 @@ static struct attribute *qgroups_attrs[] = {
        BTRFS_ATTR_PTR(qgroups, enabled),
        BTRFS_ATTR_PTR(qgroups, inconsistent),
        BTRFS_ATTR_PTR(qgroups, drop_subtree_threshold),
+       BTRFS_ATTR_PTR(qgroups, mode),
        NULL
 };
 ATTRIBUTE_GROUPS(qgroups);