btrfs: add persistent scrub lifetime and session counters
cover btrfs: add persistent scrub lifetime and session counters
From: Torstein Eide <[email protected]>
btrfs currently exposes scrub progress only via ioctl which returns a snapshot of a running scrub and nothing once it finishes. There is no persistent record of what previous scrubs found and no sysfs interface for monitoring.
This series adds per-device scrub statistics that survive across unmounts and are exposed via sysfs. A new on-disk item (BTRFS_SCRUB_STATS_OBJECTID, BTRFS_PERSISTENT_ITEM_KEY, devid) stores 14 __le64 lifetime counters per device in the device tree, following the same dirty-counter/flush-at-commit pattern as btrfs_dev_stats.
Each device gains an in-memory session snapshot (reset at scrub start, populated at scrub end) for the most recent run.
The sysfs layout under /sys/fs/btrfs/<UUID>/ and devinfo/<devid>/:
scrub/lifetime/<counter> accumulated totals across all runs scrub/session/<counter> snapshot of the most recent run scrub/session/status idle | running | finished | canceled
scrub/session/duration_seconds
scrub/reset write "1" to zero lifetime counters
plan is explaned her: https://github.com/kdave/btrfs-progs/issues/1108
tested with xfstests.
## Result
Bellow is table with results of a destrutive test, with two passes, one dd per devices, scrub repeat.
| FILE | Total | Device 1 | Device 2 | | | Lifetime | Session | Lifetime | Session | Lifetime | Session | |-----------------------|------------|------------|------------|------------|------------|------------| | corrected_errors | 28736 | 13120 | 15616 | 0 | 13120 | 13120 | | csum_discards | 0 | 0 | 0 | 0 | 0 | 0 | | csum_errors | 28736 | 13120 | 15616 | 0 | 13120 | 13120 | | data_bytes_scrubbed | 6174015488 | 3087007744 | 3087007744 | 1543503872 | 3087007744 | 1543503872 | | data_extents_scrubbed | 94208 | 47104 | 47104 | 23552 | 47104 | 23552 | | duration_seconds | | 1 | | 1 | | 1 | | last_physical | | | | 2147483648 | | 2126643200 | | malloc_errors | 0 | 0 | 0 | 0 | 0 | 0 | | no_csum | 0 | 0 | 0 | 0 | 0 | 0 | | read_errors | 0 | 0 | 0 | 0 | 0 | 0 | | status | | finished | | finished | | finished | | super_errors | 0 | 0 | 0 | 0 | 0 | 0 | | t_end | | 1776595754 | | 1776595754 | | 1776595754 | | tree_bytes_scrubbed | 6946816 | 3473408 | 3473408 | 1736704 | 3473408 | 1736704 | | tree_extents_scrubbed | 424 | 212 | 212 | 106 | 212 | 106 | | t_start | | 1776595753 | | 1776595753 | | 1776595753 | | uncorrectable_errors | 0 | 0 | 0 | 0 | 0 | 0 | | unverified_errors | 0 | 0 | 0 | 0 | 0 | 0 | | verify_errors | 0 | 0 | 0 | 0 | 0 | 0 |
Torstein Eide (5):
btrfs: uapi: introduce on-disk scrub stats item
btrfs: add in-memory scrub lifetime and session fields
btrfs: persist scrub lifetime stats to the device tree
btrfs: hook scrub session tracking into 'btrfs_scrub_dev()'
btrfs: expose scrub lifetime and session counters via sysfs
fs/btrfs/disk-io.c | 6 + fs/btrfs/fs.h | 5 + fs/btrfs/scrub.c | 16 + fs/btrfs/sysfs.c | 586 ++++++++++++++++++++++++++++++++ fs/btrfs/sysfs.h | 3 + fs/btrfs/transaction.c | 3 + fs/btrfs/volumes.c | 239 ++++++++++++- fs/btrfs/volumes.h | 79 +++++ include/uapi/linux/btrfs_tree.h | 34 ++ 9 files changed, 969 insertions(+), 2 deletions(-)
Signature · 1 line
2.48.1
PATCH 1/5 btrfs: uapi: introduce on-disk scrub stats item
From: Torstein Eide <[email protected]>
Add a new persistent item type for per-device scrub lifetime counters:
Key: (BTRFS_SCRUB_STATS_OBJECTID, BTRFS_PERSISTENT_ITEM_KEY, devid)
The item payload is struct btrfs_scrub_stats_item, an array of __le64 values indexed by BTRFS_SCRUB_STAT_* constants (data/tree extents and bytes scrubbed, read/checksum/verify/malloc errors, etc.).
The array is designed to grow at the end; existing index values are fixed and must not be renumbered. New entries should be appended and the item_size check in the reader handles shorter on-disk items from older kernels gracefully.
--- include/uapi/linux/btrfs_tree.h | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
include/uapi/linux/btrfs_tree.h +34 -0
@@ -82,6 +82,9 @@/* device stats in the device tree */ #define BTRFS_DEV_STATS_OBJECTID 0ULL +/* per-device scrub lifetime stats in the device tree */ +#define BTRFS_SCRUB_STATS_OBJECTID 1ULL +/* for storing balance parameters in the root tree */ #define BTRFS_BALANCE_OBJECTID -4ULL
@@ -1139,6 +1142,37 @@ struct btrfs_dev_stats_item {__le64 values[BTRFS_DEV_STAT_VALUES_MAX ]; } __attribute__ ((__packed__)); +/* +* Scrub lifetime error counters, stored per device in the device tree. +* Key: (BTRFS_SCRUB_STATS_OBJECTID, BTRFS_PERSISTENT_ITEM_KEY, devid) +* +* Index values are defined by enum btrfs_scrub_stat_index in btrfs_tree.h +* (kernel-internal, not exposed via ioctl). +*/ +#define BTRFS_SCRUB_STAT_DATA_EXTENTS_SCRUBBED 0 +#define BTRFS_SCRUB_STAT_TREE_EXTENTS_SCRUBBED 1 +#define BTRFS_SCRUB_STAT_DATA_BYTES_SCRUBBED 2 +#define BTRFS_SCRUB_STAT_TREE_BYTES_SCRUBBED 3 +#define BTRFS_SCRUB_STAT_READ_ERRORS 4 +#define BTRFS_SCRUB_STAT_CSUM_ERRORS 5 +#define BTRFS_SCRUB_STAT_VERIFY_ERRORS 6 +#define BTRFS_SCRUB_STAT_NO_CSUM 7 +#define BTRFS_SCRUB_STAT_CSUM_DISCARDS 8 +#define BTRFS_SCRUB_STAT_SUPER_ERRORS 9 +#define BTRFS_SCRUB_STAT_MALLOC_ERRORS 10 +#define BTRFS_SCRUB_STAT_UNCORRECTABLE_ERRORS 11 +#define BTRFS_SCRUB_STAT_CORRECTED_ERRORS 12 +#define BTRFS_SCRUB_STAT_UNVERIFIED_ERRORS 13 +#define BTRFS_SCRUB_STAT_VALUES_MAX 14 + +struct btrfs_scrub_stats_item { +/* +* Grow at the end for future enhancements; keep existing values +* unchanged. Index values defined by BTRFS_SCRUB_STAT_* above. +*/ +__le64 values[BTRFS_SCRUB_STAT_VALUES_MAX ]; +} __attribute__ ((__packed__ )); +#define BTRFS_DEV_REPLACE_ITEM_CONT_READING_FROM_SRCDEV_MODE_ALWAYS 0#define BTRFS_DEV_REPLACE_ITEM_CONT_READING_FROM_SRCDEV_MODE_AVOID 1
Signature · 1 line
2.48.1
PATCH 2/5 btrfs: add in-memory scrub lifetime and session fields
In reply to Torstein EideFrom: Torstein Eide <[email protected]>
Extend struct btrfs_device with two counter arrays and session metadata:
scrub_stat_values[] - lifetime totals, persisted across mounts via
the new BTRFS_SCRUB_STATS_OBJECTID tree item. Protected by an atomic dirty counter (scrub_stats_ccnt) and flushed at transaction commit by btrfs_run_scrub_stats().
scrub_session_values[] - per-run counters reset when a new scrub
starts; never written to disk.
scrub_session_{t_start,t_end,last_physical,status} - timing and
progress metadata for the current or most recent scrub session on this device.
Add matching kobject pointers (scrub_kobj, scrub_lifetime_kobj, scrub_session_kobj) to both struct btrfs_device and struct btrfs_fs_info for the sysfs hierarchy added in a later patch.
Add BTRFS_SCRUB_STATUS_* constants and the inline read/write helpers btrfs_scrub_stat_{read,add,set}() and btrfs_scrub_session_read(). The add/set helpers include an smp_mb__before_atomic() to order stat updates before the dirty-counter increment, pairing with the smp_rmb() in btrfs_run_scrub_stats().
--- fs/btrfs/fs.h | 5 +++ fs/btrfs/volumes.h | 79 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+)
fs/btrfs/fs.h +5 -0
@@ -714,6 +714,11 @@ struct btrfs_fs_info {struct kobject *qgroups_kobj;struct kobject *discard_kobj; +/* For /sys/fs/btrfs/<UUID>/scrub/{lifetime,session}/ */ +struct kobject *scrub_kobj; +struct kobject *scrub_lifetime_kobj; +struct kobject *scrub_session_kobj; +/* Track the number of blocks (sectors) read by the filesystem. */ struct percpu_counter stats_read_blocks;
fs/btrfs/volumes.h +79 -0
97 lines not on this page · raw message
Signature · 1 line
2.48.1
PATCH 3/5 btrfs: persist scrub lifetime stats to the device tree
In reply to Torstein EideFrom: Torstein Eide <[email protected]>
Load and save per-device scrub lifetime counters using the on-disk item introduced in the previous patch.
btrfs_init_scrub_stats() - called from open_ctree() after device stats
are initialised. Reads each device's BTRFS_SCRUB_STATS_OBJECTID item into the in-memory atomic arrays. Devices with no item yet start with all counters at zero. Items shorter than the current struct (from an older kernel) are handled by zero-filling the missing tail entries.
update_scrub_stat_item() / btrfs_run_scrub_stats() - mirrors the
existing btrfs_run_dev_stats() pattern. Called from commit_cowonly_roots() after btrfs_run_dev_stats(). Iterates over all devices; for each device whose scrub_stats_ccnt dirty counter is non-zero it writes the current atomic values back to the tree item, creating or replacing the item as needed.
btrfs_update_scrub_stats() - called from btrfs_scrub_dev() on
completion (or cancellation). Copies the final btrfs_scrub_progress counters into both the session arrays and the lifetime totals, records t_end and last_physical, and sets the session status.
--- fs/btrfs/disk-io.c | 6 ++ fs/btrfs/transaction.c | 3 + fs/btrfs/volumes.c | 239 ++++++++++++++++++++++++++++++++++++++++- 3 files changed, 246 insertions(+), 2 deletions(-)
fs/btrfs/disk-io.c +6 -0
@@ -3545,6 +3545,12 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device goto fail_block_groups; } + ret =btrfs_init_scrub_stats (fs_info); +if (ret) { +btrfs_err (fs_info,"failed to init scrub_stats: %d" , ret); + goto fail_block_groups; + } + ret =btrfs_init_dev_replace (fs_info);if (ret) {btrfs_err (fs_info,"failed to init dev_replace: %d" , ret);
fs/btrfs/transaction.c +3 -0
@@ -1375,6 +1375,9 @@ static noinline int commit_cowonly_roots(struct btrfs_trans_handle *trans)return ret; ret =btrfs_run_dev_stats (trans); +if (ret) +return ret; + ret =btrfs_run_scrub_stats (trans);if (ret)return ret; ret =btrfs_run_dev_replace (trans);
fs/btrfs/volumes.c +239 -2
265 lines not on this page · raw message
Signature · 1 line
2.48.1
PATCH 4/5 btrfs: hook scrub session tracking into btrfs_scrub_dev()
In reply to Torstein EideFrom: Torstein Eide <[email protected]>
At the start of a scrub (excluding device replace runs):
- zero all per-device scrub_session_values[] counters
- set scrub_session_last_physical to the start offset
- record scrub_session_t_start (wall-clock seconds)
- set scrub_session_status to BTRFS_SCRUB_STATUS_RUNNING
At the end of a scrub, call btrfs_update_scrub_stats() which copies the final btrfs_scrub_progress counters into the session and lifetime arrays, stamps t_end, and sets the status to FINISHED or CANCELED depending on the return value.
Device replace runs are excluded because their progress is tracked separately and their statistics should not pollute the device's own scrub history.
--- fs/btrfs/scrub.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
fs/btrfs/scrub.c +16 -0
@@ -6,6 +6,7 @@#include <linux/blkdev.h> #include <linux/ratelimit.h> #include <linux/sched/mm.h> +#include <linux/timekeeping.h> #include "ctree.h" #include "discard.h" #include "volumes.h"
@@ -3152,6 +3153,18 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start, dev->scrub_ctx = sctx;mutex_unlock (&fs_info->fs_devices->device_list_mutex); +if (!is_dev_replace) { +int i; + +/* Reset session counters for this new scrub run */ +for (i =0 ; i <BTRFS_SCRUB_STAT_VALUES_MAX ; i++) +atomic64_set (&dev->scrub_session_values[i],0 ); + dev->scrub_session_last_physical = start; + dev->scrub_session_t_start =ktime_get_real_seconds (); + dev->scrub_session_t_end =0 ; +atomic_set (&dev->scrub_session_status,BTRFS_SCRUB_STATUS_RUNNING ); + } +/* * checking @scrub_pause_req here, we can avoid * race between committing transaction and scrubbing.
@@ -3207,6 +3220,9 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,if (progress)memcpy (progress, &sctx->stat,sizeof (*progress)); +if (!is_dev_replace) +btrfs_update_scrub_stats (dev, &sctx->stat, ret); +if (!is_dev_replace)btrfs_info (fs_info,"scrub: %s on devid %llu with status: %d" , ret ?"not finished" :"finished" , devid, ret);
Signature · 1 line
2.48.1
PATCH 5/5 btrfs: expose scrub lifetime and session counters via sysfs
In reply to Torstein EideFrom: Torstein Eide <[email protected]>
Create two sysfs sub-hierarchies under each filesystem UUID and under each devinfo/<devid>/ entry:
/sys/fs/btrfs/<UUID>/scrub/
reset (write "1" to zero all devices' lifetime
counters and mark them dirty)
lifetime/ filesystem-wide sums of per-device lifetime
data_extents_scrubbed counters (one file per stat index)
tree_extents_scrubbed
... (14 counters total)
session/ filesystem-wide view of the most recent run
data_extents_scrubbed (summed across devices for counters,
... earliest t_start / latest t_end for time)
status idle | running | finished | canceled
t_start / t_end Unix timestamps (seconds)
duration_seconds computed on read; live while running
/sys/fs/btrfs/<UUID>/devinfo/<devid>/scrub/
reset (per-device reset)
lifetime/ per-device lifetime counters
session/ per-device session counters + metadata last_physical byte offset where the last run stopped
The attribute arrays are declared as 'const struct attribute *[]' so they are compatible with sysfs_create_files() / sysfs_remove_files(). Forward declarations are placed before btrfs_sysfs_remove_mounted() and btrfs_sysfs_remove_device() which reference them before their definitions.
--- fs/btrfs/sysfs.c | 586 +++++++++++++++++++++++++++++++++++++++++++++++ fs/btrfs/sysfs.h | 3 + 2 files changed, 589 insertions(+)
fs/btrfs/sysfs.c +586 -0
@@ -11,6 +11,7 @@#include <linux/bug.h> #include <linux/list.h> #include <linux/string_choices.h> +#include <linux/timekeeping.h> #include "messages.h" #include "ctree.h" #include "discard.h"
@@ -1707,6 +1708,14 @@ static void btrfs_sysfs_remove_fs_devices(struct btrfs_fs_devices *fs_devices) } } +/* Forward declarations for scrub sysfs attribute arrays defined later. */ +static const struct attribute *scrub_attrs[]; +static const struct attribute *scrub_lifetime_attrs[]; +static const struct attribute *scrub_session_attrs[]; +static const struct attribute *devid_scrub_attrs[]; +static const struct attribute *devid_scrub_lifetime_attrs[]; +static const struct attribute *devid_scrub_session_attrs[]; +void btrfs_sysfs_remove_mounted (struct btrfs_fs_info *fs_info) {struct kobject *fsid_kobj = &fs_info->fs_devices->fsid_kobj;
@@ -1723,6 +1732,21 @@ void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info)kobject_del (fs_info->discard_kobj);kobject_put (fs_info->discard_kobj); } +if (fs_info->scrub_session_kobj) { +sysfs_remove_files (fs_info->scrub_session_kobj, scrub_session_attrs); +kobject_del (fs_info->scrub_session_kobj); +kobject_put (fs_info->scrub_session_kobj); + } +if (fs_info->scrub_lifetime_kobj) { +sysfs_remove_files (fs_info->scrub_lifetime_kobj, scrub_lifetime_attrs); +kobject_del (fs_info->scrub_lifetime_kobj); +kobject_put (fs_info->scrub_lifetime_kobj); + } +if (fs_info->scrub_kobj) { +sysfs_remove_files (fs_info->scrub_kobj, scrub_attrs); +kobject_del (fs_info->scrub_kobj); +kobject_put (fs_info->scrub_kobj); + }#ifdef CONFIG_BTRFS_DEBUG if (fs_info->debug_kobj) {sysfs_remove_files (fs_info->debug_kobj, btrfs_debug_mount_attrs);
@@ -1970,6 +1994,28 @@ void btrfs_sysfs_remove_device(struct btrfs_device *device)if (device->bdev)sysfs_remove_link (devices_kobj,bdev_kobj (device->bdev)->name); +/* Tear down devinfo/<devid>/scrub/ hierarchy (children before parent) */ +if (device->scrub_session_kobj) { +sysfs_remove_files (device->scrub_session_kobj, + devid_scrub_session_attrs); +kobject_del (device->scrub_session_kobj); +kobject_put (device->scrub_session_kobj); + device->scrub_session_kobj =NULL ; + } +if (device->scrub_lifetime_kobj) { +sysfs_remove_files (device->scrub_lifetime_kobj, + devid_scrub_lifetime_attrs); +kobject_del (device->scrub_lifetime_kobj); +kobject_put (device->scrub_lifetime_kobj); + device->scrub_lifetime_kobj =NULL ; + } +if (device->scrub_kobj) { +sysfs_remove_files (device->scrub_kobj, devid_scrub_attrs); +kobject_del (device->scrub_kobj); +kobject_put (device->scrub_kobj); + device->scrub_kobj =NULL ; + } +if (device->devid_kobj.state_initialized) {kobject_del (&device->devid_kobj);kobject_put (&device->devid_kobj);
@@ -2099,6 +2145,482 @@ static ssize_t btrfs_devinfo_error_stats_show(struct kobject *kobj, }BTRFS_ATTR (devid, error_stats, btrfs_devinfo_error_stats_show); +/* ---------- scrub/lifetime/ and scrub/session/ sysfs attributes ---------- */ + +/* +* Return the btrfs_device owning a kobject that lives two levels below +* devid_kobj, i.e. kobj->parent is scrub_kobj, kobj->parent->parent is +* devid_kobj. +*/ +static struct btrfs_device *kobj_to_scrub_device (struct kobject *kobj) +{ + return container_of(kobj->parent->parent, struct btrfs_device, devid_kobj); +} + +/* +* Return the btrfs_fs_info owning a kobject that lives two levels below +* fsid_kobj, i.e. kobj->parent is fs_info->scrub_kobj, +* kobj->parent->parent is &fs_devs->fsid_kobj. +*/ +static struct btrfs_fs_info *kobj_to_scrub_fs_info (struct kobject *kobj) +{ +struct btrfs_fs_devices *fs_devs = + container_of(kobj->parent->parent, struct btrfs_fs_devices, fsid_kobj); +return fs_devs->fs_info; +} + +/* +* Per-device scrub/lifetime/ attributes. +* Each show function reads an atomic64 from btrfs_device::scrub_stat_values[]. +*/ +#define DEV_SCRUB_LIFETIME_ATTR (_name, _idx) \ +static ssize_t btrfs_devid_scrub_lifetime_##_name##_show( \ + struct kobject *kobj, struct kobj_attribute *a, char *buf) \ +{ \ + struct btrfs_device *dev = kobj_to_scrub_device(kobj); \ + return sysfs_emit(buf, "%llu\n", btrfs_scrub_stat_read(dev, _idx)); \ +} \ +BTRFS_ATTR(devid_scrub_lifetime, _name, \ + btrfs_devid_scrub_lifetime_##_name##_show) + +DEV_SCRUB_LIFETIME_ATTR (data_extents_scrubbed,BTRFS_SCRUB_STAT_DATA_EXTENTS_SCRUBBED ); +DEV_SCRUB_LIFETIME_ATTR (tree_extents_scrubbed,BTRFS_SCRUB_STAT_TREE_EXTENTS_SCRUBBED ); +DEV_SCRUB_LIFETIME_ATTR (data_bytes_scrubbed,BTRFS_SCRUB_STAT_DATA_BYTES_SCRUBBED ); +DEV_SCRUB_LIFETIME_ATTR (tree_bytes_scrubbed,BTRFS_SCRUB_STAT_TREE_BYTES_SCRUBBED ); +DEV_SCRUB_LIFETIME_ATTR (read_errors,BTRFS_SCRUB_STAT_READ_ERRORS ); +DEV_SCRUB_LIFETIME_ATTR (csum_errors,BTRFS_SCRUB_STAT_CSUM_ERRORS ); +DEV_SCRUB_LIFETIME_ATTR (verify_errors,BTRFS_SCRUB_STAT_VERIFY_ERRORS ); +DEV_SCRUB_LIFETIME_ATTR (no_csum,BTRFS_SCRUB_STAT_NO_CSUM ); +DEV_SCRUB_LIFETIME_ATTR (csum_discards,BTRFS_SCRUB_STAT_CSUM_DISCARDS ); +DEV_SCRUB_LIFETIME_ATTR (super_errors,BTRFS_SCRUB_STAT_SUPER_ERRORS ); +DEV_SCRUB_LIFETIME_ATTR (malloc_errors,BTRFS_SCRUB_STAT_MALLOC_ERRORS ); +DEV_SCRUB_LIFETIME_ATTR (uncorrectable_errors,BTRFS_SCRUB_STAT_UNCORRECTABLE_ERRORS ); +DEV_SCRUB_LIFETIME_ATTR (corrected_errors,BTRFS_SCRUB_STAT_CORRECTED_ERRORS ); +DEV_SCRUB_LIFETIME_ATTR (unverified_errors,BTRFS_SCRUB_STAT_UNVERIFIED_ERRORS ); + +static const struct attribute *devid_scrub_lifetime_attrs[] = { +BTRFS_ATTR_PTR (devid_scrub_lifetime, data_extents_scrubbed), +BTRFS_ATTR_PTR (devid_scrub_lifetime, tree_extents_scrubbed), +BTRFS_ATTR_PTR (devid_scrub_lifetime, data_bytes_scrubbed), +BTRFS_ATTR_PTR (devid_scrub_lifetime, tree_bytes_scrubbed), +BTRFS_ATTR_PTR (devid_scrub_lifetime, read_errors), +BTRFS_ATTR_PTR (devid_scrub_lifetime, csum_errors), +BTRFS_ATTR_PTR (devid_scrub_lifetime, verify_errors), +BTRFS_ATTR_PTR (devid_scrub_lifetime, no_csum), +BTRFS_ATTR_PTR (devid_scrub_lifetime, csum_discards), +BTRFS_ATTR_PTR (devid_scrub_lifetime, super_errors), +BTRFS_ATTR_PTR (devid_scrub_lifetime, malloc_errors), +BTRFS_ATTR_PTR (devid_scrub_lifetime, uncorrectable_errors), +BTRFS_ATTR_PTR (devid_scrub_lifetime, corrected_errors), +BTRFS_ATTR_PTR (devid_scrub_lifetime, unverified_errors), +NULL +}; + +/* +* Per-device scrub/session/ attributes. +*/ +#define DEV_SCRUB_SESSION_ATTR (_name, _idx) \ +static ssize_t btrfs_devid_scrub_session_##_name##_show( \ + struct kobject *kobj, struct kobj_attribute *a, char *buf) \ +{ \ + struct btrfs_device *dev = kobj_to_scrub_device(kobj); \ + return sysfs_emit(buf, "%llu\n", btrfs_scrub_session_read(dev, _idx)); \ +} \ +BTRFS_ATTR(devid_scrub_session, _name, \ + btrfs_devid_scrub_session_##_name##_show) + +DEV_SCRUB_SESSION_ATTR (data_extents_scrubbed,BTRFS_SCRUB_STAT_DATA_EXTENTS_SCRUBBED ); +DEV_SCRUB_SESSION_ATTR (tree_extents_scrubbed,BTRFS_SCRUB_STAT_TREE_EXTENTS_SCRUBBED ); +DEV_SCRUB_SESSION_ATTR (data_bytes_scrubbed,BTRFS_SCRUB_STAT_DATA_BYTES_SCRUBBED ); +DEV_SCRUB_SESSION_ATTR (tree_bytes_scrubbed,BTRFS_SCRUB_STAT_TREE_BYTES_SCRUBBED ); +DEV_SCRUB_SESSION_ATTR (read_errors,BTRFS_SCRUB_STAT_READ_ERRORS ); +DEV_SCRUB_SESSION_ATTR (csum_errors,BTRFS_SCRUB_STAT_CSUM_ERRORS ); +DEV_SCRUB_SESSION_ATTR (verify_errors,BTRFS_SCRUB_STAT_VERIFY_ERRORS ); +DEV_SCRUB_SESSION_ATTR (no_csum,BTRFS_SCRUB_STAT_NO_CSUM ); +DEV_SCRUB_SESSION_ATTR (csum_discards,BTRFS_SCRUB_STAT_CSUM_DISCARDS ); +DEV_SCRUB_SESSION_ATTR (super_errors,BTRFS_SCRUB_STAT_SUPER_ERRORS ); +DEV_SCRUB_SESSION_ATTR (malloc_errors,BTRFS_SCRUB_STAT_MALLOC_ERRORS ); +DEV_SCRUB_SESSION_ATTR (uncorrectable_errors,BTRFS_SCRUB_STAT_UNCORRECTABLE_ERRORS ); +DEV_SCRUB_SESSION_ATTR (corrected_errors,BTRFS_SCRUB_STAT_CORRECTED_ERRORS ); +DEV_SCRUB_SESSION_ATTR (unverified_errors,BTRFS_SCRUB_STAT_UNVERIFIED_ERRORS ); + +static ssize_t btrfs_devid_scrub_session_last_physical_show ( +struct kobject *kobj,struct kobj_attribute *a,char *buf) +{ +struct btrfs_device *dev =kobj_to_scrub_device (kobj); + +return sysfs_emit (buf,"%llu\n" ,READ_ONCE (dev->scrub_session_last_physical)); +} +BTRFS_ATTR (devid_scrub_session, last_physical, + btrfs_devid_scrub_session_last_physical_show); + +static ssize_t btrfs_devid_scrub_session_t_start_show ( +struct kobject *kobj,struct kobj_attribute *a,char *buf) +{ +struct btrfs_device *dev =kobj_to_scrub_device (kobj); + +return sysfs_emit (buf,"%llu\n" ,READ_ONCE (dev->scrub_session_t_start)); +} +BTRFS_ATTR (devid_scrub_session, t_start, btrfs_devid_scrub_session_t_start_show); + +static ssize_t btrfs_devid_scrub_session_t_end_show ( +struct kobject *kobj,struct kobj_attribute *a,char *buf) +{ +struct btrfs_device *dev =kobj_to_scrub_device (kobj); + +return sysfs_emit (buf,"%llu\n" ,READ_ONCE (dev->scrub_session_t_end)); +} +BTRFS_ATTR (devid_scrub_session, t_end, btrfs_devid_scrub_session_t_end_show); + +static ssize_t btrfs_devid_scrub_session_duration_seconds_show ( +struct kobject *kobj,struct kobj_attribute *a,char *buf) +{ +struct btrfs_device *dev =kobj_to_scrub_device (kobj); +u64 t_start =READ_ONCE (dev->scrub_session_t_start); +u64 t_end =READ_ONCE (dev->scrub_session_t_end); +u64 dur; + +if (t_start ==0 ) + dur =0 ; +else if (t_end !=0 ) + dur = t_end - t_start; +else + dur = (u64 )ktime_get_real_seconds () - t_start; +return sysfs_emit (buf,"%llu\n" , dur); +} +BTRFS_ATTR (devid_scrub_session, duration_seconds, + btrfs_devid_scrub_session_duration_seconds_show); + +static const char *const btrfs_scrub_status_strings[] = { + [BTRFS_SCRUB_STATUS_IDLE ] ="idle" , + [BTRFS_SCRUB_STATUS_RUNNING ] ="running" , + [BTRFS_SCRUB_STATUS_FINISHED ] ="finished" , + [BTRFS_SCRUB_STATUS_CANCELED ] ="canceled" , +}; + +static ssize_t btrfs_devid_scrub_session_status_show ( +struct kobject *kobj,struct kobj_attribute *a,char *buf) +{ +struct btrfs_device *dev =kobj_to_scrub_device (kobj); +int status =atomic_read (&dev->scrub_session_status); + +if (status <0 || status >=ARRAY_SIZE (btrfs_scrub_status_strings)) +return sysfs_emit (buf,"unknown\n" ); +return sysfs_emit (buf,"%s\n" , btrfs_scrub_status_strings[status]); +} +BTRFS_ATTR (devid_scrub_session, status, btrfs_devid_scrub_session_status_show); + +static const struct attribute *devid_scrub_session_attrs[] = { +BTRFS_ATTR_PTR (devid_scrub_session, data_extents_scrubbed), +BTRFS_ATTR_PTR (devid_scrub_session, tree_extents_scrubbed), +BTRFS_ATTR_PTR (devid_scrub_session, data_bytes_scrubbed), +BTRFS_ATTR_PTR (devid_scrub_session, tree_bytes_scrubbed), +BTRFS_ATTR_PTR (devid_scrub_session, read_errors), +BTRFS_ATTR_PTR (devid_scrub_session, csum_errors), +BTRFS_ATTR_PTR (devid_scrub_session, verify_errors), +BTRFS_ATTR_PTR (devid_scrub_session, no_csum), +BTRFS_ATTR_PTR (devid_scrub_session, csum_discards), +BTRFS_ATTR_PTR (devid_scrub_session, super_errors), +BTRFS_ATTR_PTR (devid_scrub_session, malloc_errors), +BTRFS_ATTR_PTR (devid_scrub_session, uncorrectable_errors), +BTRFS_ATTR_PTR (devid_scrub_session, corrected_errors), +BTRFS_ATTR_PTR (devid_scrub_session, unverified_errors), +BTRFS_ATTR_PTR (devid_scrub_session, last_physical), +BTRFS_ATTR_PTR (devid_scrub_session, t_start), +BTRFS_ATTR_PTR (devid_scrub_session, t_end), +BTRFS_ATTR_PTR (devid_scrub_session, duration_seconds), +BTRFS_ATTR_PTR (devid_scrub_session, status), +NULL +}; + +/* +* Per-device scrub/reset (write-only): "echo 1 > reset" zeroes lifetime +* counters and marks them dirty for the next transaction commit. +*/ +static ssize_t btrfs_devid_scrub_reset_store (struct kobject *kobj, +struct kobj_attribute *a,const char *buf,size_t len) +{ +struct btrfs_device *dev; +unsigned long val; +int i; + +if (kstrtoul (buf,10 , &val) || val !=1 ) +return -EINVAL ; + +/* kobj here is the scrub_kobj, one level below devid_kobj */ + dev = container_of(kobj->parent, struct btrfs_device, devid_kobj); + +for (i =0 ; i <BTRFS_SCRUB_STAT_VALUES_MAX ; i++) +btrfs_scrub_stat_set (dev, i,0 ); + +btrfs_info (dev->fs_info, +"scrub: lifetime stats reset for devid %llu by %s (%d)" , + dev->devid, current->comm,task_pid_nr (current)); +return len; +} +BTRFS_ATTR_W (devid_scrub, reset, btrfs_devid_scrub_reset_store); + +static const struct attribute *devid_scrub_attrs[] = { +BTRFS_ATTR_PTR (devid_scrub, reset), +NULL +}; + +/* ---------- fs-level scrub/lifetime/ and scrub/session/ attributes ---------- */ + +/* +* Filesystem-level lifetime counters: sum of all device lifetime counters. +*/ +#define FS_SCRUB_LIFETIME_ATTR (_name, _idx) \ +static ssize_t btrfs_scrub_lifetime_##_name##_show( \ + struct kobject *kobj, struct kobj_attribute *a, char *buf) \ +{ \ + struct btrfs_fs_info *fs_info = kobj_to_scrub_fs_info(kobj); \ + struct btrfs_fs_devices *fs_devs = fs_info->fs_devices; \ + struct btrfs_device *dev; \ + u64 total = 0; \ + \ + mutex_lock(&fs_devs->device_list_mutex); \ + list_for_each_entry(dev, &fs_devs->devices, dev_list) \ + total += btrfs_scrub_stat_read(dev, _idx); \ + mutex_unlock(&fs_devs->device_list_mutex); \ + return sysfs_emit(buf, "%llu\n", total); \ +} \ +BTRFS_ATTR(scrub_lifetime, _name, btrfs_scrub_lifetime_##_name##_show) + +FS_SCRUB_LIFETIME_ATTR (data_extents_scrubbed,BTRFS_SCRUB_STAT_DATA_EXTENTS_SCRUBBED ); +FS_SCRUB_LIFETIME_ATTR (tree_extents_scrubbed,BTRFS_SCRUB_STAT_TREE_EXTENTS_SCRUBBED ); +FS_SCRUB_LIFETIME_ATTR (data_bytes_scrubbed,BTRFS_SCRUB_STAT_DATA_BYTES_SCRUBBED ); +FS_SCRUB_LIFETIME_ATTR (tree_bytes_scrubbed,BTRFS_SCRUB_STAT_TREE_BYTES_SCRUBBED ); +FS_SCRUB_LIFETIME_ATTR (read_errors,BTRFS_SCRUB_STAT_READ_ERRORS ); +FS_SCRUB_LIFETIME_ATTR (csum_errors,BTRFS_SCRUB_STAT_CSUM_ERRORS ); +FS_SCRUB_LIFETIME_ATTR (verify_errors,BTRFS_SCRUB_STAT_VERIFY_ERRORS ); +FS_SCRUB_LIFETIME_ATTR (no_csum,BTRFS_SCRUB_STAT_NO_CSUM ); +FS_SCRUB_LIFETIME_ATTR (csum_discards,BTRFS_SCRUB_STAT_CSUM_DISCARDS ); +FS_SCRUB_LIFETIME_ATTR (super_errors,BTRFS_SCRUB_STAT_SUPER_ERRORS ); +FS_SCRUB_LIFETIME_ATTR (malloc_errors,BTRFS_SCRUB_STAT_MALLOC_ERRORS ); +FS_SCRUB_LIFETIME_ATTR (uncorrectable_errors,BTRFS_SCRUB_STAT_UNCORRECTABLE_ERRORS ); +FS_SCRUB_LIFETIME_ATTR (corrected_errors,BTRFS_SCRUB_STAT_CORRECTED_ERRORS ); +FS_SCRUB_LIFETIME_ATTR (unverified_errors,BTRFS_SCRUB_STAT_UNVERIFIED_ERRORS ); + +static const struct attribute *scrub_lifetime_attrs[] = { +BTRFS_ATTR_PTR (scrub_lifetime, data_extents_scrubbed), +BTRFS_ATTR_PTR (scrub_lifetime, tree_extents_scrubbed), +BTRFS_ATTR_PTR (scrub_lifetime, data_bytes_scrubbed), +BTRFS_ATTR_PTR (scrub_lifetime, tree_bytes_scrubbed), +BTRFS_ATTR_PTR (scrub_lifetime, read_errors), +BTRFS_ATTR_PTR (scrub_lifetime, csum_errors), +BTRFS_ATTR_PTR (scrub_lifetime, verify_errors), +BTRFS_ATTR_PTR (scrub_lifetime, no_csum), +BTRFS_ATTR_PTR (scrub_lifetime, csum_discards), +BTRFS_ATTR_PTR (scrub_lifetime, super_errors), +BTRFS_ATTR_PTR (scrub_lifetime, malloc_errors), +BTRFS_ATTR_PTR (scrub_lifetime, uncorrectable_errors), +BTRFS_ATTR_PTR (scrub_lifetime, corrected_errors), +BTRFS_ATTR_PTR (scrub_lifetime, unverified_errors), +NULL +}; + +/* +* Filesystem-level session counters: sum of per-device session values. +* Timing/status derive from per-device values. +*/ +#define FS_SCRUB_SESSION_ATTR (_name, _idx) \ +static ssize_t btrfs_scrub_session_##_name##_show( \ + struct kobject *kobj, struct kobj_attribute *a, char *buf) \ +{ \ + struct btrfs_fs_info *fs_info = kobj_to_scrub_fs_info(kobj); \ + struct btrfs_fs_devices *fs_devs = fs_info->fs_devices; \ + struct btrfs_device *dev; \ + u64 total = 0; \ + \ + mutex_lock(&fs_devs->device_list_mutex); \ + list_for_each_entry(dev, &fs_devs->devices, dev_list) \ + total += btrfs_scrub_session_read(dev, _idx); \ + mutex_unlock(&fs_devs->device_list_mutex); \ + return sysfs_emit(buf, "%llu\n", total); \ +} \ +BTRFS_ATTR(scrub_session, _name, btrfs_scrub_session_##_name##_show) + +FS_SCRUB_SESSION_ATTR (data_extents_scrubbed,BTRFS_SCRUB_STAT_DATA_EXTENTS_SCRUBBED ); +FS_SCRUB_SESSION_ATTR (tree_extents_scrubbed,BTRFS_SCRUB_STAT_TREE_EXTENTS_SCRUBBED ); +FS_SCRUB_SESSION_ATTR (data_bytes_scrubbed,BTRFS_SCRUB_STAT_DATA_BYTES_SCRUBBED ); +FS_SCRUB_SESSION_ATTR (tree_bytes_scrubbed,BTRFS_SCRUB_STAT_TREE_BYTES_SCRUBBED ); +FS_SCRUB_SESSION_ATTR (read_errors,BTRFS_SCRUB_STAT_READ_ERRORS ); +FS_SCRUB_SESSION_ATTR (csum_errors,BTRFS_SCRUB_STAT_CSUM_ERRORS ); +FS_SCRUB_SESSION_ATTR (verify_errors,BTRFS_SCRUB_STAT_VERIFY_ERRORS ); +FS_SCRUB_SESSION_ATTR (no_csum,BTRFS_SCRUB_STAT_NO_CSUM ); +FS_SCRUB_SESSION_ATTR (csum_discards,BTRFS_SCRUB_STAT_CSUM_DISCARDS ); +FS_SCRUB_SESSION_ATTR (super_errors,BTRFS_SCRUB_STAT_SUPER_ERRORS ); +FS_SCRUB_SESSION_ATTR (malloc_errors,BTRFS_SCRUB_STAT_MALLOC_ERRORS ); +FS_SCRUB_SESSION_ATTR (uncorrectable_errors,BTRFS_SCRUB_STAT_UNCORRECTABLE_ERRORS ); +FS_SCRUB_SESSION_ATTR (corrected_errors,BTRFS_SCRUB_STAT_CORRECTED_ERRORS ); +FS_SCRUB_SESSION_ATTR (unverified_errors,BTRFS_SCRUB_STAT_UNVERIFIED_ERRORS ); + +static ssize_t btrfs_scrub_session_status_show ( +struct kobject *kobj,struct kobj_attribute *a,char *buf) +{ +struct btrfs_fs_info *fs_info =kobj_to_scrub_fs_info (kobj); + +if (atomic_read (&fs_info->scrubs_running) >0 ) +return sysfs_emit (buf,"running\n" ); + +/* +* Not running: check if any device's last session finished or was +* canceled. +*/ + { +struct btrfs_fs_devices *fs_devs = fs_info->fs_devices; +struct btrfs_device *dev; +int seen_finished =0 , seen_canceled =0 ; + +mutex_lock (&fs_devs->device_list_mutex); +list_for_each_entry (dev, &fs_devs->devices, dev_list) { +int st =atomic_read (&dev->scrub_session_status); + +if (st ==BTRFS_SCRUB_STATUS_FINISHED ) + seen_finished =1 ; +else if (st ==BTRFS_SCRUB_STATUS_CANCELED ) + seen_canceled =1 ; + } +mutex_unlock (&fs_devs->device_list_mutex); + +if (seen_canceled) +return sysfs_emit (buf,"canceled\n" ); +if (seen_finished) +return sysfs_emit (buf,"finished\n" ); + } +return sysfs_emit (buf,"idle\n" ); +} +BTRFS_ATTR (scrub_session, status, btrfs_scrub_session_status_show); + +static ssize_t btrfs_scrub_session_t_start_show ( +struct kobject *kobj,struct kobj_attribute *a,char *buf) +{ +struct btrfs_fs_info *fs_info =kobj_to_scrub_fs_info (kobj); +struct btrfs_fs_devices *fs_devs = fs_info->fs_devices; +struct btrfs_device *dev; +u64 t_min =0 ; + +mutex_lock (&fs_devs->device_list_mutex); +list_for_each_entry (dev, &fs_devs->devices, dev_list) { +u64 t =READ_ONCE (dev->scrub_session_t_start); + +if (t && (!t_min || t < t_min)) + t_min = t; + } +mutex_unlock (&fs_devs->device_list_mutex); +return sysfs_emit (buf,"%llu\n" , t_min); +} +BTRFS_ATTR (scrub_session, t_start, btrfs_scrub_session_t_start_show); + +static ssize_t btrfs_scrub_session_t_end_show ( +struct kobject *kobj,struct kobj_attribute *a,char *buf) +{ +struct btrfs_fs_info *fs_info =kobj_to_scrub_fs_info (kobj); +struct btrfs_fs_devices *fs_devs = fs_info->fs_devices; +struct btrfs_device *dev; +u64 t_max =0 ; + +mutex_lock (&fs_devs->device_list_mutex); +list_for_each_entry (dev, &fs_devs->devices, dev_list) { +u64 t =READ_ONCE (dev->scrub_session_t_end); + +if (t > t_max) + t_max = t; + } +mutex_unlock (&fs_devs->device_list_mutex); +return sysfs_emit (buf,"%llu\n" , t_max); +} +BTRFS_ATTR (scrub_session, t_end, btrfs_scrub_session_t_end_show); + +static ssize_t btrfs_scrub_session_duration_seconds_show ( +struct kobject *kobj,struct kobj_attribute *a,char *buf) +{ +struct btrfs_fs_info *fs_info =kobj_to_scrub_fs_info (kobj); +struct btrfs_fs_devices *fs_devs = fs_info->fs_devices; +struct btrfs_device *dev; +u64 t_start =0 , t_end =0 , dur; + +mutex_lock (&fs_devs->device_list_mutex); +list_for_each_entry (dev, &fs_devs->devices, dev_list) { +u64 ts =READ_ONCE (dev->scrub_session_t_start); +u64 te =READ_ONCE (dev->scrub_session_t_end); + +if (ts && (!t_start || ts < t_start)) + t_start = ts; +if (te > t_end) + t_end = te; + } +mutex_unlock (&fs_devs->device_list_mutex); + +if (!t_start) + dur =0 ; +else if (t_end) + dur = t_end - t_start; +else + dur = (u64 )ktime_get_real_seconds () - t_start; +return sysfs_emit (buf,"%llu\n" , dur); +} +BTRFS_ATTR (scrub_session, duration_seconds, + btrfs_scrub_session_duration_seconds_show); + +static const struct attribute *scrub_session_attrs[] = { +BTRFS_ATTR_PTR (scrub_session, data_extents_scrubbed), +BTRFS_ATTR_PTR (scrub_session, tree_extents_scrubbed), +BTRFS_ATTR_PTR (scrub_session, data_bytes_scrubbed), +BTRFS_ATTR_PTR (scrub_session, tree_bytes_scrubbed), +BTRFS_ATTR_PTR (scrub_session, read_errors), +BTRFS_ATTR_PTR (scrub_session, csum_errors), +BTRFS_ATTR_PTR (scrub_session, verify_errors), +BTRFS_ATTR_PTR (scrub_session, no_csum), +BTRFS_ATTR_PTR (scrub_session, csum_discards), +BTRFS_ATTR_PTR (scrub_session, super_errors), +BTRFS_ATTR_PTR (scrub_session, malloc_errors), +BTRFS_ATTR_PTR (scrub_session, uncorrectable_errors), +BTRFS_ATTR_PTR (scrub_session, corrected_errors), +BTRFS_ATTR_PTR (scrub_session, unverified_errors), +BTRFS_ATTR_PTR (scrub_session, status), +BTRFS_ATTR_PTR (scrub_session, t_start), +BTRFS_ATTR_PTR (scrub_session, t_end), +BTRFS_ATTR_PTR (scrub_session, duration_seconds), +NULL +}; + +/* +* Filesystem-level scrub/reset (write-only): zeros all devices' lifetime +* counters and marks them dirty. +*/ +static ssize_t btrfs_scrub_reset_store (struct kobject *kobj, +struct kobj_attribute *a,const char *buf,size_t len) +{ +/* kobj is fs_info->scrub_kobj, parent is fsid_kobj */ +struct btrfs_fs_devices *fs_devs = + container_of(kobj->parent, struct btrfs_fs_devices, fsid_kobj); +struct btrfs_fs_info *fs_info = fs_devs->fs_info; +struct btrfs_device *dev; +unsigned long val; +int i; + +if (kstrtoul (buf,10 , &val) || val !=1 ) +return -EINVAL ; + +mutex_lock (&fs_devs->device_list_mutex); +list_for_each_entry (dev, &fs_devs->devices, dev_list) +for (i =0 ; i <BTRFS_SCRUB_STAT_VALUES_MAX ; i++) +btrfs_scrub_stat_set (dev, i,0 ); +mutex_unlock (&fs_devs->device_list_mutex); + +btrfs_info (fs_info,"scrub: all lifetime stats reset by %s (%d)" , + current->comm,task_pid_nr (current)); +return len; +} +BTRFS_ATTR_W (scrub, reset, btrfs_scrub_reset_store); + +static const struct attribute *scrub_attrs[] = { +BTRFS_ATTR_PTR (scrub, reset), +NULL +}; +/* * Information about one device. *
@@ -2169,7 +2691,41 @@ int btrfs_sysfs_add_device(struct btrfs_device *device)btrfs_warn (device->fs_info,"devinfo init for devid %llu failed: %d" , device->devid, ret); + goto out; + } + +/* Create devinfo/<devid>/scrub/ hierarchy */ + device->scrub_kobj =kobject_create_and_add ("scrub" , &device->devid_kobj); +if (!device->scrub_kobj) { + ret = -ENOMEM ; +btrfs_warn (device->fs_info, +"scrub kobj init for devid %llu failed" , + device->devid); + goto out; + } + ret =sysfs_create_files (device->scrub_kobj, devid_scrub_attrs); +if (ret) + goto out; + + device->scrub_lifetime_kobj =kobject_create_and_add ("lifetime" , + device->scrub_kobj); +if (!device->scrub_lifetime_kobj) { + ret = -ENOMEM ; + goto out; + } + ret =sysfs_create_files (device->scrub_lifetime_kobj, + devid_scrub_lifetime_attrs); +if (ret) + goto out; + + device->scrub_session_kobj =kobject_create_and_add ("session" , + device->scrub_kobj); +if (!device->scrub_session_kobj) { + ret = -ENOMEM ; + goto out; } + ret =sysfs_create_files (device->scrub_session_kobj, + devid_scrub_session_attrs); out:memalloc_nofs_restore (nofs_flag);
@@ -2346,6 +2902,36 @@ int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info)if (ret) goto failure; +/* Create /sys/fs/btrfs/<UUID>/scrub/{lifetime,session}/ hierarchy */ + fs_info->scrub_kobj =kobject_create_and_add ("scrub" , fsid_kobj); +if (!fs_info->scrub_kobj) { + ret = -ENOMEM ; + goto failure; + } + ret =sysfs_create_files (fs_info->scrub_kobj, scrub_attrs); +if (ret) + goto failure; + + fs_info->scrub_lifetime_kobj =kobject_create_and_add ("lifetime" , + fs_info->scrub_kobj); +if (!fs_info->scrub_lifetime_kobj) { + ret = -ENOMEM ; + goto failure; + } + ret =sysfs_create_files (fs_info->scrub_lifetime_kobj, scrub_lifetime_attrs); +if (ret) + goto failure; + + fs_info->scrub_session_kobj =kobject_create_and_add ("session" , + fs_info->scrub_kobj); +if (!fs_info->scrub_session_kobj) { + ret = -ENOMEM ; + goto failure; + } + ret =sysfs_create_files (fs_info->scrub_session_kobj, scrub_session_attrs); +if (ret) + goto failure; +return 0 ; failure:btrfs_sysfs_remove_mounted (fs_info);
fs/btrfs/sysfs.h +3 -0
@@ -41,6 +41,9 @@ int btrfs_sysfs_add_space_info_type(struct btrfs_space_info *space_info);void btrfs_sysfs_remove_space_info (struct btrfs_space_info *space_info);void btrfs_sysfs_update_devid (struct btrfs_device *device); +int btrfs_sysfs_add_scrub_device (struct btrfs_device *device); +void btrfs_sysfs_remove_scrub_device (struct btrfs_device *device); +int btrfs_sysfs_add_one_qgroup (struct btrfs_fs_info *fs_info,struct btrfs_qgroup *qgroup);void btrfs_sysfs_del_qgroups (struct btrfs_fs_info *fs_info);
Signature · 1 line
2.48.1