@@ -373,6 +373,8 @@ bool btrfs_exclop_start(struct btrfs_fs_info *fs_info, int type)
void btrfs_exclop_finish(struct btrfs_fs_info *fs_info)
{
atomic_set(&fs_info->exclusive_operation, BTRFS_EXCLOP_NONE);
+ sysfs_notify(&fs_info->fs_devices->fsid_kobj, NULL,
+ "exclusive_operation");
}
/*
@@ -808,6 +808,30 @@ static ssize_t btrfs_checksum_show(struct kobject *kobj,
BTRFS_ATTR(, checksum, btrfs_checksum_show);
+static ssize_t btrfs_exclusive_operation_show(struct kobject *kobj,
+ struct kobj_attribute *a, char *buf)
+{
+ struct btrfs_fs_info *fs_info = to_fs_info(kobj);
+ switch (atomic_read(&fs_info->exclusive_operation)) {
+ case BTRFS_EXCLOP_NONE:
+ return scnprintf(buf, PAGE_SIZE, "none\n");
+ case BTRFS_EXCLOP_BALANCE:
+ return scnprintf(buf, PAGE_SIZE, "balance\n");
+ case BTRFS_EXCLOP_DEV_ADD:
+ return scnprintf(buf, PAGE_SIZE, "device add\n");
+ case BTRFS_EXCLOP_DEV_REPLACE:
+ return scnprintf(buf, PAGE_SIZE, "device replace\n");
+ case BTRFS_EXCLOP_DEV_REMOVE:
+ return scnprintf(buf, PAGE_SIZE, "device remove\n");
+ case BTRFS_EXCLOP_SWAP_ACTIVATE:
+ return scnprintf(buf, PAGE_SIZE, "swap activate\n");
+ case BTRFS_EXCLOP_RESIZE:
+ return scnprintf(buf, PAGE_SIZE, "resize\n");
+ }
+ return 0;
+}
+BTRFS_ATTR(, exclusive_operation, btrfs_exclusive_operation_show);
+
static const struct attribute *btrfs_attrs[] = {
BTRFS_ATTR_PTR(, label),
BTRFS_ATTR_PTR(, nodesize),
@@ -816,6 +840,7 @@ static const struct attribute *btrfs_attrs[] = {
BTRFS_ATTR_PTR(, quota_override),
BTRFS_ATTR_PTR(, metadata_uuid),
BTRFS_ATTR_PTR(, checksum),
+ BTRFS_ATTR_PTR(, exclusive_operation),
NULL,
};