* [PATCH 1/6] Btrfs: rename btrfs_sysfs_add_one to btrfs_sysfs_add_mounted
2015-07-08 7:32 [PATCH 0/6] sysfs-part2 Add seed device representation on the sysfs Anand Jain
@ 2015-07-08 7:32 ` Anand Jain
2015-07-08 7:32 ` [PATCH 2/6] Btrfs: rename btrfs_sysfs_remove_one to btrfs_sysfs_remove_mounted Anand Jain
` (5 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Anand Jain @ 2015-07-08 7:32 UTC (permalink / raw)
To: linux-btrfs, dsterba
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
fs/btrfs/ctree.h | 2 +-
fs/btrfs/disk-io.c | 2 +-
fs/btrfs/sysfs.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 80a9aef..b6b2226 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -4007,7 +4007,7 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
/* sysfs.c */
int btrfs_init_sysfs(void);
void btrfs_exit_sysfs(void);
-int btrfs_sysfs_add_one(struct btrfs_fs_info *fs_info);
+int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info);
void btrfs_sysfs_remove_one(struct btrfs_fs_info *fs_info);
/* xattr.c */
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index b977fc8..552dcbe 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -2888,7 +2888,7 @@ retry_root_backup:
goto fail_fsdev_sysfs;
}
- ret = btrfs_sysfs_add_one(fs_info);
+ ret = btrfs_sysfs_add_mounted(fs_info);
if (ret) {
pr_err("BTRFS: failed to init sysfs interface: %d\n", ret);
goto fail_fsdev_sysfs;
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 603b0cc..cabf840 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -736,7 +736,7 @@ int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs,
return error;
}
-int btrfs_sysfs_add_one(struct btrfs_fs_info *fs_info)
+int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info)
{
int error;
struct btrfs_fs_devices *fs_devs = fs_info->fs_devices;
--
2.4.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/6] Btrfs: rename btrfs_sysfs_remove_one to btrfs_sysfs_remove_mounted
2015-07-08 7:32 [PATCH 0/6] sysfs-part2 Add seed device representation on the sysfs Anand Jain
2015-07-08 7:32 ` [PATCH 1/6] Btrfs: rename btrfs_sysfs_add_one to btrfs_sysfs_add_mounted Anand Jain
@ 2015-07-08 7:32 ` Anand Jain
2015-07-08 7:32 ` [PATCH 3/6] Btrfs: rename btrfs_kobj_add_device to btrfs_sysfs_add_device_link Anand Jain
` (4 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Anand Jain @ 2015-07-08 7:32 UTC (permalink / raw)
To: linux-btrfs, dsterba
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
fs/btrfs/ctree.h | 2 +-
fs/btrfs/disk-io.c | 4 ++--
fs/btrfs/sysfs.c | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index b6b2226..eed1127 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -4008,7 +4008,7 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
int btrfs_init_sysfs(void);
void btrfs_exit_sysfs(void);
int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info);
-void btrfs_sysfs_remove_one(struct btrfs_fs_info *fs_info);
+void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info);
/* xattr.c */
ssize_t btrfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 552dcbe..4eaa554 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3067,7 +3067,7 @@ fail_cleaner:
filemap_write_and_wait(fs_info->btree_inode->i_mapping);
fail_sysfs:
- btrfs_sysfs_remove_one(fs_info);
+ btrfs_sysfs_remove_mounted(fs_info);
fail_fsdev_sysfs:
btrfs_sysfs_remove_fsid(fs_info->fs_devices);
@@ -3748,7 +3748,7 @@ void close_ctree(struct btrfs_root *root)
percpu_counter_sum(&fs_info->delalloc_bytes));
}
- btrfs_sysfs_remove_one(fs_info);
+ btrfs_sysfs_remove_mounted(fs_info);
btrfs_sysfs_remove_fsid(fs_info->fs_devices);
btrfs_free_fs_roots(fs_info);
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index cabf840..095a302 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -545,7 +545,7 @@ void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs)
}
}
-void btrfs_sysfs_remove_one(struct btrfs_fs_info *fs_info)
+void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info)
{
btrfs_reset_fs_info_ptr(fs_info);
@@ -776,7 +776,7 @@ int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info)
return 0;
failure:
- btrfs_sysfs_remove_one(fs_info);
+ btrfs_sysfs_remove_mounted(fs_info);
return error;
}
--
2.4.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/6] Btrfs: rename btrfs_kobj_add_device to btrfs_sysfs_add_device_link
2015-07-08 7:32 [PATCH 0/6] sysfs-part2 Add seed device representation on the sysfs Anand Jain
2015-07-08 7:32 ` [PATCH 1/6] Btrfs: rename btrfs_sysfs_add_one to btrfs_sysfs_add_mounted Anand Jain
2015-07-08 7:32 ` [PATCH 2/6] Btrfs: rename btrfs_sysfs_remove_one to btrfs_sysfs_remove_mounted Anand Jain
@ 2015-07-08 7:32 ` Anand Jain
2015-07-08 7:32 ` [PATCH 4/6] Btrfs: rename btrfs_kobj_rm_device to btrfs_sysfs_rm_device_link Anand Jain
` (3 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Anand Jain @ 2015-07-08 7:32 UTC (permalink / raw)
To: linux-btrfs, dsterba
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
fs/btrfs/dev-replace.c | 2 +-
fs/btrfs/sysfs.c | 4 ++--
fs/btrfs/sysfs.h | 2 +-
fs/btrfs/volumes.c | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index 862fbc2..f7c390b 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -376,7 +376,7 @@ int btrfs_dev_replace_start(struct btrfs_root *root,
WARN_ON(!tgt_device);
dev_replace->tgtdev = tgt_device;
- ret = btrfs_kobj_add_device(tgt_device->fs_devices, tgt_device);
+ ret = btrfs_sysfs_add_device_link(tgt_device->fs_devices, tgt_device);
if (ret)
btrfs_error(root->fs_info, ret, "kobj add dev failed");
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 095a302..df67f6b 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -683,7 +683,7 @@ int btrfs_sysfs_add_device(struct btrfs_fs_devices *fs_devs)
return 0;
}
-int btrfs_kobj_add_device(struct btrfs_fs_devices *fs_devices,
+int btrfs_sysfs_add_device_link(struct btrfs_fs_devices *fs_devices,
struct btrfs_device *one_device)
{
int error = 0;
@@ -744,7 +744,7 @@ int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info)
btrfs_set_fs_info_ptr(fs_info);
- error = btrfs_kobj_add_device(fs_devs, NULL);
+ error = btrfs_sysfs_add_device_link(fs_devs, NULL);
if (error)
return error;
diff --git a/fs/btrfs/sysfs.h b/fs/btrfs/sysfs.h
index 6392527..6529680 100644
--- a/fs/btrfs/sysfs.h
+++ b/fs/btrfs/sysfs.h
@@ -82,7 +82,7 @@ char *btrfs_printable_features(enum btrfs_feature_set set, u64 flags);
extern const char * const btrfs_feature_set_names[3];
extern struct kobj_type space_info_ktype;
extern struct kobj_type btrfs_raid_ktype;
-int btrfs_kobj_add_device(struct btrfs_fs_devices *fs_devices,
+int btrfs_sysfs_add_device_link(struct btrfs_fs_devices *fs_devices,
struct btrfs_device *one_device);
int btrfs_kobj_rm_device(struct btrfs_fs_devices *fs_devices,
struct btrfs_device *one_device);
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 8396699..cc1c8de 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2295,7 +2295,7 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
tmp + 1);
/* add sysfs device entry */
- btrfs_kobj_add_device(root->fs_info->fs_devices, device);
+ btrfs_sysfs_add_device_link(root->fs_info->fs_devices, device);
/*
* we've got more storage, clear any full flags on the space
--
2.4.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 4/6] Btrfs: rename btrfs_kobj_rm_device to btrfs_sysfs_rm_device_link
2015-07-08 7:32 [PATCH 0/6] sysfs-part2 Add seed device representation on the sysfs Anand Jain
` (2 preceding siblings ...)
2015-07-08 7:32 ` [PATCH 3/6] Btrfs: rename btrfs_kobj_add_device to btrfs_sysfs_add_device_link Anand Jain
@ 2015-07-08 7:32 ` Anand Jain
2015-07-08 7:32 ` [PATCH 5/6] Btrfs: rename super_kobj to fsid_kobj Anand Jain
` (2 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Anand Jain @ 2015-07-08 7:32 UTC (permalink / raw)
To: linux-btrfs, dsterba
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
fs/btrfs/dev-replace.c | 2 +-
fs/btrfs/sysfs.c | 6 +++---
fs/btrfs/sysfs.h | 2 +-
fs/btrfs/volumes.c | 6 +++---
4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index f7c390b..31e0145 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -587,7 +587,7 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
mutex_unlock(&uuid_mutex);
/* replace the sysfs entry */
- btrfs_kobj_rm_device(fs_info->fs_devices, src_device);
+ btrfs_sysfs_rm_device_link(fs_info->fs_devices, src_device);
btrfs_rm_dev_replace_free_srcdev(fs_info, src_device);
/* write back the superblocks */
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index df67f6b..52319d1 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -557,7 +557,7 @@ void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info)
addrm_unknown_feature_attrs(fs_info, false);
sysfs_remove_group(&fs_info->fs_devices->super_kobj, &btrfs_feature_attr_group);
sysfs_remove_files(&fs_info->fs_devices->super_kobj, btrfs_attrs);
- btrfs_kobj_rm_device(fs_info->fs_devices, NULL);
+ btrfs_sysfs_rm_device_link(fs_info->fs_devices, NULL);
}
const char * const btrfs_feature_set_names[3] = {
@@ -637,7 +637,7 @@ static void init_feature_attrs(void)
/* when one_device is NULL, it removes all device links */
-int btrfs_kobj_rm_device(struct btrfs_fs_devices *fs_devices,
+int btrfs_sysfs_rm_device_link(struct btrfs_fs_devices *fs_devices,
struct btrfs_device *one_device)
{
struct hd_struct *disk;
@@ -750,7 +750,7 @@ int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info)
error = sysfs_create_files(super_kobj, btrfs_attrs);
if (error) {
- btrfs_kobj_rm_device(fs_devs, NULL);
+ btrfs_sysfs_rm_device_link(fs_devs, NULL);
return error;
}
diff --git a/fs/btrfs/sysfs.h b/fs/btrfs/sysfs.h
index 6529680..9c09522 100644
--- a/fs/btrfs/sysfs.h
+++ b/fs/btrfs/sysfs.h
@@ -84,7 +84,7 @@ extern struct kobj_type space_info_ktype;
extern struct kobj_type btrfs_raid_ktype;
int btrfs_sysfs_add_device_link(struct btrfs_fs_devices *fs_devices,
struct btrfs_device *one_device);
-int btrfs_kobj_rm_device(struct btrfs_fs_devices *fs_devices,
+int btrfs_sysfs_rm_device_link(struct btrfs_fs_devices *fs_devices,
struct btrfs_device *one_device);
int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs,
struct kobject *parent);
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index cc1c8de..6483da1 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1787,7 +1787,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
if (device->bdev) {
device->fs_devices->open_devices--;
/* remove sysfs entry */
- btrfs_kobj_rm_device(root->fs_info->fs_devices, device);
+ btrfs_sysfs_rm_device_link(root->fs_info->fs_devices, device);
}
call_rcu(&device->rcu, free_device);
@@ -1957,7 +1957,7 @@ void btrfs_destroy_dev_replace_tgtdev(struct btrfs_fs_info *fs_info,
WARN_ON(!tgtdev);
mutex_lock(&fs_info->fs_devices->device_list_mutex);
- btrfs_kobj_rm_device(fs_info->fs_devices, tgtdev);
+ btrfs_sysfs_rm_device_link(fs_info->fs_devices, tgtdev);
if (tgtdev->bdev) {
btrfs_scratch_superblock(tgtdev);
@@ -2374,7 +2374,7 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
error_trans:
btrfs_end_transaction(trans, root);
rcu_string_free(device->name);
- btrfs_kobj_rm_device(root->fs_info->fs_devices, device);
+ btrfs_sysfs_rm_device_link(root->fs_info->fs_devices, device);
kfree(device);
error:
blkdev_put(bdev, FMODE_EXCL);
--
2.4.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 5/6] Btrfs: rename super_kobj to fsid_kobj
2015-07-08 7:32 [PATCH 0/6] sysfs-part2 Add seed device representation on the sysfs Anand Jain
` (3 preceding siblings ...)
2015-07-08 7:32 ` [PATCH 4/6] Btrfs: rename btrfs_kobj_rm_device to btrfs_sysfs_rm_device_link Anand Jain
@ 2015-07-08 7:32 ` Anand Jain
2015-07-08 7:32 ` [PATCH 6/6] Btrfs: sysfs: support seed devices in the sysfs layout Anand Jain
2015-08-05 17:29 ` [PATCH 0/6] sysfs-part2 Add seed device representation on the sysfs David Sterba
6 siblings, 0 replies; 10+ messages in thread
From: Anand Jain @ 2015-07-08 7:32 UTC (permalink / raw)
To: linux-btrfs, dsterba
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
fs/btrfs/sysfs.c | 36 ++++++++++++++++++------------------
fs/btrfs/volumes.c | 2 +-
fs/btrfs/volumes.h | 2 +-
3 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 52319d1..e0ac859 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -437,24 +437,24 @@ static const struct attribute *btrfs_attrs[] = {
NULL,
};
-static void btrfs_release_super_kobj(struct kobject *kobj)
+static void btrfs_release_fsid_kobj(struct kobject *kobj)
{
struct btrfs_fs_devices *fs_devs = to_fs_devs(kobj);
- memset(&fs_devs->super_kobj, 0, sizeof(struct kobject));
+ memset(&fs_devs->fsid_kobj, 0, sizeof(struct kobject));
complete(&fs_devs->kobj_unregister);
}
static struct kobj_type btrfs_ktype = {
.sysfs_ops = &kobj_sysfs_ops,
- .release = btrfs_release_super_kobj,
+ .release = btrfs_release_fsid_kobj,
};
static inline struct btrfs_fs_devices *to_fs_devs(struct kobject *kobj)
{
if (kobj->ktype != &btrfs_ktype)
return NULL;
- return container_of(kobj, struct btrfs_fs_devices, super_kobj);
+ return container_of(kobj, struct btrfs_fs_devices, fsid_kobj);
}
static inline struct btrfs_fs_info *to_fs_info(struct kobject *kobj)
@@ -502,12 +502,12 @@ static int addrm_unknown_feature_attrs(struct btrfs_fs_info *fs_info, bool add)
attrs[0] = &fa->kobj_attr.attr;
if (add) {
int ret;
- ret = sysfs_merge_group(&fs_info->fs_devices->super_kobj,
+ ret = sysfs_merge_group(&fs_info->fs_devices->fsid_kobj,
&agroup);
if (ret)
return ret;
} else
- sysfs_unmerge_group(&fs_info->fs_devices->super_kobj,
+ sysfs_unmerge_group(&fs_info->fs_devices->fsid_kobj,
&agroup);
}
@@ -523,9 +523,9 @@ static void __btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs)
fs_devs->device_dir_kobj = NULL;
}
- if (fs_devs->super_kobj.state_initialized) {
- kobject_del(&fs_devs->super_kobj);
- kobject_put(&fs_devs->super_kobj);
+ if (fs_devs->fsid_kobj.state_initialized) {
+ kobject_del(&fs_devs->fsid_kobj);
+ kobject_put(&fs_devs->fsid_kobj);
wait_for_completion(&fs_devs->kobj_unregister);
}
}
@@ -555,8 +555,8 @@ void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info)
kobject_put(fs_info->space_info_kobj);
}
addrm_unknown_feature_attrs(fs_info, false);
- sysfs_remove_group(&fs_info->fs_devices->super_kobj, &btrfs_feature_attr_group);
- sysfs_remove_files(&fs_info->fs_devices->super_kobj, btrfs_attrs);
+ sysfs_remove_group(&fs_info->fs_devices->fsid_kobj, &btrfs_feature_attr_group);
+ sysfs_remove_files(&fs_info->fs_devices->fsid_kobj, btrfs_attrs);
btrfs_sysfs_rm_device_link(fs_info->fs_devices, NULL);
}
@@ -675,7 +675,7 @@ int btrfs_sysfs_add_device(struct btrfs_fs_devices *fs_devs)
{
if (!fs_devs->device_dir_kobj)
fs_devs->device_dir_kobj = kobject_create_and_add("devices",
- &fs_devs->super_kobj);
+ &fs_devs->fsid_kobj);
if (!fs_devs->device_dir_kobj)
return -ENOMEM;
@@ -730,8 +730,8 @@ int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs,
int error;
init_completion(&fs_devs->kobj_unregister);
- fs_devs->super_kobj.kset = btrfs_kset;
- error = kobject_init_and_add(&fs_devs->super_kobj,
+ fs_devs->fsid_kobj.kset = btrfs_kset;
+ error = kobject_init_and_add(&fs_devs->fsid_kobj,
&btrfs_ktype, parent, "%pU", fs_devs->fsid);
return error;
}
@@ -740,7 +740,7 @@ int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info)
{
int error;
struct btrfs_fs_devices *fs_devs = fs_info->fs_devices;
- struct kobject *super_kobj = &fs_devs->super_kobj;
+ struct kobject *fsid_kobj = &fs_devs->fsid_kobj;
btrfs_set_fs_info_ptr(fs_info);
@@ -748,13 +748,13 @@ int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info)
if (error)
return error;
- error = sysfs_create_files(super_kobj, btrfs_attrs);
+ error = sysfs_create_files(fsid_kobj, btrfs_attrs);
if (error) {
btrfs_sysfs_rm_device_link(fs_devs, NULL);
return error;
}
- error = sysfs_create_group(super_kobj,
+ error = sysfs_create_group(fsid_kobj,
&btrfs_feature_attr_group);
if (error)
goto failure;
@@ -764,7 +764,7 @@ int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info)
goto failure;
fs_info->space_info_kobj = kobject_create_and_add("allocation",
- super_kobj);
+ fsid_kobj);
if (!fs_info->space_info_kobj) {
error = -ENOMEM;
goto failure;
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 6483da1..90340d0 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2336,7 +2336,7 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
*/
snprintf(fsid_buf, BTRFS_UUID_UNPARSED_SIZE, "%pU",
root->fs_info->fsid);
- if (kobject_rename(&root->fs_info->fs_devices->super_kobj,
+ if (kobject_rename(&root->fs_info->fs_devices->fsid_kobj,
fsid_buf))
pr_warn("BTRFS: sysfs: failed to create fsid for sprout\n");
}
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
index 210a643..865d853 100644
--- a/fs/btrfs/volumes.h
+++ b/fs/btrfs/volumes.h
@@ -256,7 +256,7 @@ struct btrfs_fs_devices {
struct btrfs_fs_info *fs_info;
/* sysfs kobjects */
- struct kobject super_kobj;
+ struct kobject fsid_kobj;
struct kobject *device_dir_kobj;
struct completion kobj_unregister;
};
--
2.4.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 6/6] Btrfs: sysfs: support seed devices in the sysfs layout
2015-07-08 7:32 [PATCH 0/6] sysfs-part2 Add seed device representation on the sysfs Anand Jain
` (4 preceding siblings ...)
2015-07-08 7:32 ` [PATCH 5/6] Btrfs: rename super_kobj to fsid_kobj Anand Jain
@ 2015-07-08 7:32 ` Anand Jain
2015-08-05 17:29 ` [PATCH 0/6] sysfs-part2 Add seed device representation on the sysfs David Sterba
6 siblings, 0 replies; 10+ messages in thread
From: Anand Jain @ 2015-07-08 7:32 UTC (permalink / raw)
To: linux-btrfs, dsterba
This adds an enhancement to show the seed fsid and its devices
on the btrfs sysfs.
The way sprouting handles fs_devices:
clone seed fs_devices and add to the fs_uuids
mem copy seed fs_devices and assign to fs_devices->seed (move dev_list)
evacuate seed fs_devices contents to hold sprout fs devices contents
So to be inline with this fs_devices changes during seeding,
represent seed fsid under the sprout fsid, this is achieved
by using the kobject_move()
The end result will be,
/sys/fs/btrfs/sprout-fsid/seed/level-1-seed-fsid/seed/(if)level-2-seed-fsid
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
fs/btrfs/dev-replace.c | 7 ++-
fs/btrfs/disk-io.c | 6 +-
fs/btrfs/sysfs.c | 150 +++++++++++++++++++++++++++++++++++++++++++------
fs/btrfs/sysfs.h | 12 ++--
fs/btrfs/volumes.c | 26 ++++-----
fs/btrfs/volumes.h | 1 +
6 files changed, 160 insertions(+), 42 deletions(-)
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index 31e0145..d0c9562 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -376,7 +376,7 @@ int btrfs_dev_replace_start(struct btrfs_root *root,
WARN_ON(!tgt_device);
dev_replace->tgtdev = tgt_device;
- ret = btrfs_sysfs_add_device_link(tgt_device->fs_devices, tgt_device);
+ ret = btrfs_sysfs_add_device_link(tgt_device->fs_devices, tgt_device, 0);
if (ret)
btrfs_error(root->fs_info, ret, "kobj add dev failed");
@@ -587,7 +587,10 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
mutex_unlock(&uuid_mutex);
/* replace the sysfs entry */
- btrfs_sysfs_rm_device_link(fs_info->fs_devices, src_device);
+ btrfs_sysfs_rm_device_link(fs_info->fs_devices, src_device, 0);
+ if (src_device->fs_devices->seeding &&
+ !src_device->fs_devices->num_devices)
+ btrfs_sysfs_remove_fsid(src_device->fs_devices);
btrfs_rm_dev_replace_free_srcdev(fs_info, src_device);
/* write back the superblocks */
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 4eaa554..b3c9870 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -2876,13 +2876,13 @@ retry_root_backup:
btrfs_close_extra_devices(fs_devices, 1);
- ret = btrfs_sysfs_add_fsid(fs_devices, NULL);
- if (ret) {
+ ret = btrfs_sysfs_add_fsid(fs_devices, NULL, 1);
+ if (ret && ret != -EEXIST) {
pr_err("BTRFS: failed to init sysfs fsid interface: %d\n", ret);
goto fail_block_groups;
}
- ret = btrfs_sysfs_add_device(fs_devices);
+ ret = btrfs_sysfs_add_device(fs_devices, 1);
if (ret) {
pr_err("BTRFS: failed to init sysfs device interface: %d\n", ret);
goto fail_fsdev_sysfs;
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index e0ac859..3a45462 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -517,6 +517,11 @@ static int addrm_unknown_feature_attrs(struct btrfs_fs_info *fs_info, bool add)
static void __btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs)
{
+ if (fs_devs->seed) {
+ __btrfs_sysfs_remove_fsid(fs_devs->seed);
+ btrfs_sysfs_rm_seed_dir(fs_devs);
+ }
+
if (fs_devs->device_dir_kobj) {
kobject_del(fs_devs->device_dir_kobj);
kobject_put(fs_devs->device_dir_kobj);
@@ -557,7 +562,7 @@ void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info)
addrm_unknown_feature_attrs(fs_info, false);
sysfs_remove_group(&fs_info->fs_devices->fsid_kobj, &btrfs_feature_attr_group);
sysfs_remove_files(&fs_info->fs_devices->fsid_kobj, btrfs_attrs);
- btrfs_sysfs_rm_device_link(fs_info->fs_devices, NULL);
+ btrfs_sysfs_rm_device_link(fs_info->fs_devices, NULL, 1);
}
const char * const btrfs_feature_set_names[3] = {
@@ -638,7 +643,7 @@ static void init_feature_attrs(void)
/* when one_device is NULL, it removes all device links */
int btrfs_sysfs_rm_device_link(struct btrfs_fs_devices *fs_devices,
- struct btrfs_device *one_device)
+ struct btrfs_device *one_device, int follow_seed)
{
struct hd_struct *disk;
struct kobject *disk_kobj;
@@ -668,27 +673,38 @@ int btrfs_sysfs_rm_device_link(struct btrfs_fs_devices *fs_devices,
disk_kobj->name);
}
+ if (follow_seed && fs_devices->seed)
+ btrfs_sysfs_rm_device_link(fs_devices->seed, NULL, follow_seed);
+
return 0;
}
-int btrfs_sysfs_add_device(struct btrfs_fs_devices *fs_devs)
+int btrfs_sysfs_add_device(struct btrfs_fs_devices *fs_devs, int follow_seed)
{
- if (!fs_devs->device_dir_kobj)
- fs_devs->device_dir_kobj = kobject_create_and_add("devices",
- &fs_devs->fsid_kobj);
+ while (fs_devs) {
+ if (!fs_devs->device_dir_kobj)
+ fs_devs->device_dir_kobj = kobject_create_and_add(
+ "devices", &fs_devs->fsid_kobj);
- if (!fs_devs->device_dir_kobj)
- return -ENOMEM;
+ if (!fs_devs->device_dir_kobj)
+ return -ENOMEM;
+
+ if (!follow_seed)
+ return 0;
+
+ fs_devs = fs_devs->seed;
+ }
return 0;
}
int btrfs_sysfs_add_device_link(struct btrfs_fs_devices *fs_devices,
- struct btrfs_device *one_device)
+ struct btrfs_device *one_device, int follow_seed)
{
int error = 0;
struct btrfs_device *dev;
+again:
list_for_each_entry(dev, &fs_devices->devices, dev_list) {
struct hd_struct *disk;
struct kobject *disk_kobj;
@@ -708,9 +724,37 @@ int btrfs_sysfs_add_device_link(struct btrfs_fs_devices *fs_devices,
break;
}
+ if (follow_seed && fs_devices->seed) {
+ fs_devices = fs_devices->seed;
+ goto again;
+ }
+
return error;
}
+void btrfs_sysfs_rm_seed_dir(struct btrfs_fs_devices *fs_devs)
+{
+ if (fs_devs->seed_dir_kobj) {
+ kobject_del(fs_devs->seed_dir_kobj);
+ kobject_put(fs_devs->seed_dir_kobj);
+ fs_devs->seed_dir_kobj = NULL;
+ }
+}
+
+int btrfs_sysfs_add_seed_dir(struct btrfs_fs_devices *fs_devs)
+{
+ if (!fs_devs->seed_dir_kobj)
+ fs_devs->seed_dir_kobj = kobject_create_and_add(
+ "seed", &fs_devs->fsid_kobj);
+
+ if (!fs_devs->seed_dir_kobj)
+ return -ENOMEM;
+
+ BUG_ON(!fs_devs->seed_dir_kobj->state_initialized);
+
+ return 0;
+}
+
/* /sys/fs/btrfs/ entry */
static struct kset *btrfs_kset;
@@ -725,15 +769,29 @@ u64 btrfs_debugfs_test;
* And parent can be specified for seed device
*/
int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs,
- struct kobject *parent)
+ struct kobject *parent, int follow_seed)
{
- int error;
+ int error = 0;
- init_completion(&fs_devs->kobj_unregister);
- fs_devs->fsid_kobj.kset = btrfs_kset;
- error = kobject_init_and_add(&fs_devs->fsid_kobj,
- &btrfs_ktype, parent, "%pU", fs_devs->fsid);
- return error;
+add_seed:
+ if (!fs_devs->fsid_kobj.state_initialized) {
+ init_completion(&fs_devs->kobj_unregister);
+ fs_devs->fsid_kobj.kset = btrfs_kset;
+ error = kobject_init_and_add(&fs_devs->fsid_kobj,
+ &btrfs_ktype, parent, "%pU", fs_devs->fsid);
+ } else {
+ error = -EEXIST;
+ }
+
+ if (!follow_seed || !fs_devs->seed)
+ return error;
+
+ btrfs_sysfs_add_seed_dir(fs_devs);
+
+ parent = fs_devs->seed_dir_kobj;
+ fs_devs = fs_devs->seed;
+
+ goto add_seed;
}
int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info)
@@ -744,13 +802,13 @@ int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info)
btrfs_set_fs_info_ptr(fs_info);
- error = btrfs_sysfs_add_device_link(fs_devs, NULL);
+ error = btrfs_sysfs_add_device_link(fs_devs, NULL, 1);
if (error)
return error;
error = sysfs_create_files(fsid_kobj, btrfs_attrs);
if (error) {
- btrfs_sysfs_rm_device_link(fs_devs, NULL);
+ btrfs_sysfs_rm_device_link(fs_devs, NULL, 0);
return error;
}
@@ -826,3 +884,59 @@ void btrfs_exit_sysfs(void)
debugfs_remove_recursive(btrfs_debugfs_root_dentry);
}
+void btrfs_sysfs_prepare_sprout_reset(void)
+{
+ /* close call would anyway cleanup */
+}
+
+void btrfs_sysfs_prepare_sprout(struct btrfs_fs_devices *fs_devices,
+ struct btrfs_fs_devices *seed_devices)
+{
+ char fsid_buf[BTRFS_UUID_UNPARSED_SIZE];
+
+ /*
+ * Sprouting has changed fsid of the mounted root,
+ * so rename the fsid on the sysfs
+ */
+ snprintf(fsid_buf, BTRFS_UUID_UNPARSED_SIZE, "%pU", fs_devices->fsid);
+ if (kobject_rename(&fs_devices->fsid_kobj, fsid_buf)) {
+ pr_warn("Btrfs: sysfs: kobject rename failed\n");
+ }
+
+ /*
+ * Create the seed fsid inside the sprout fsid
+ * but should not create devices dir, instead
+ * move it from the original fs_devices
+ */
+ memset(&seed_devices->fsid_kobj, 0, sizeof(struct kobject));
+ seed_devices->device_dir_kobj = NULL;
+ memset(&seed_devices->kobj_unregister, 0,
+ sizeof(struct completion));
+ seed_devices->seed_dir_kobj = NULL;
+
+ if (!fs_devices->seed_dir_kobj)
+ btrfs_sysfs_add_seed_dir(fs_devices);
+
+ btrfs_sysfs_add_fsid(seed_devices, fs_devices->seed_dir_kobj, 0);
+
+ if (kobject_move(fs_devices->device_dir_kobj,
+ &seed_devices->fsid_kobj))
+ pr_warn("Btrfs: sysfs: dev kobject move failed\n");
+
+ seed_devices->device_dir_kobj = fs_devices->device_dir_kobj;
+ fs_devices->device_dir_kobj = NULL;
+ btrfs_sysfs_add_device(fs_devices, 0);
+
+ /*
+ * the kobj dev and devices attribute will be created
+ * in the main function as part of the init_new_device
+ * If this is a nested seed, that is if there is seed's
+ * seed device then move that one level deep.
+ */
+ if (seed_devices->seed) {
+ btrfs_sysfs_add_seed_dir(seed_devices);
+ if (kobject_move(&seed_devices->seed->fsid_kobj,
+ seed_devices->seed_dir_kobj))
+ pr_warn("Btrfs: sysfs: kobject move failed\n");
+ }
+}
diff --git a/fs/btrfs/sysfs.h b/fs/btrfs/sysfs.h
index 9c09522..5ace289 100644
--- a/fs/btrfs/sysfs.h
+++ b/fs/btrfs/sysfs.h
@@ -83,11 +83,15 @@ extern const char * const btrfs_feature_set_names[3];
extern struct kobj_type space_info_ktype;
extern struct kobj_type btrfs_raid_ktype;
int btrfs_sysfs_add_device_link(struct btrfs_fs_devices *fs_devices,
- struct btrfs_device *one_device);
+ struct btrfs_device *one_device, int follow_seed);
int btrfs_sysfs_rm_device_link(struct btrfs_fs_devices *fs_devices,
- struct btrfs_device *one_device);
+ struct btrfs_device *one_device, int follow_seed);
int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs,
- struct kobject *parent);
-int btrfs_sysfs_add_device(struct btrfs_fs_devices *fs_devs);
+ struct kobject *parent, int follow_seed);
void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs);
+int btrfs_sysfs_add_device(struct btrfs_fs_devices *fs_devs, int follow_seed);
+int btrfs_sysfs_add_seed_dir(struct btrfs_fs_devices *fs_devs);
+void btrfs_sysfs_rm_seed_dir(struct btrfs_fs_devices *fs_devs);
+void btrfs_sysfs_prepare_sprout(struct btrfs_fs_devices *fs_devices,
+ struct btrfs_fs_devices *seed_devices);
#endif /* _BTRFS_SYSFS_H_ */
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 90340d0..47ec58c 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -27,6 +27,7 @@
#include <linux/kthread.h>
#include <linux/raid/pq.h>
#include <linux/semaphore.h>
+#include <linux/kobject.h>
#include <asm/div64.h>
#include "ctree.h"
#include "extent_map.h"
@@ -1787,7 +1788,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
if (device->bdev) {
device->fs_devices->open_devices--;
/* remove sysfs entry */
- btrfs_sysfs_rm_device_link(root->fs_info->fs_devices, device);
+ btrfs_sysfs_rm_device_link(root->fs_info->fs_devices, device, 0);
}
call_rcu(&device->rcu, free_device);
@@ -1957,7 +1958,7 @@ void btrfs_destroy_dev_replace_tgtdev(struct btrfs_fs_info *fs_info,
WARN_ON(!tgtdev);
mutex_lock(&fs_info->fs_devices->device_list_mutex);
- btrfs_sysfs_rm_device_link(fs_info->fs_devices, tgtdev);
+ btrfs_sysfs_rm_device_link(fs_info->fs_devices, tgtdev, 0);
if (tgtdev->bdev) {
btrfs_scratch_superblock(tgtdev);
@@ -2087,6 +2088,9 @@ static int btrfs_prepare_sprout(struct btrfs_root *root)
fs_devices->open_devices = 0;
fs_devices->missing_devices = 0;
fs_devices->rotating = 0;
+ if (fs_devices->seed)
+ seed_devices->seed = fs_devices->seed;
+
fs_devices->seed = seed_devices;
generate_random_uuid(fs_devices->fsid);
@@ -2098,6 +2102,8 @@ static int btrfs_prepare_sprout(struct btrfs_root *root)
~BTRFS_SUPER_FLAG_SEEDING;
btrfs_set_super_flags(disk_super, super_flags);
+ btrfs_sysfs_prepare_sprout(fs_devices, seed_devices);
+
return 0;
}
@@ -2295,7 +2301,7 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
tmp + 1);
/* add sysfs device entry */
- btrfs_sysfs_add_device_link(root->fs_info->fs_devices, device);
+ btrfs_sysfs_add_device_link(root->fs_info->fs_devices, device, 0);
/*
* we've got more storage, clear any full flags on the space
@@ -2323,22 +2329,11 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
}
if (seeding_dev) {
- char fsid_buf[BTRFS_UUID_UNPARSED_SIZE];
-
ret = btrfs_finish_sprout(trans, root);
if (ret) {
btrfs_abort_transaction(trans, root, ret);
goto error_trans;
}
-
- /* Sprouting would change fsid of the mounted root,
- * so rename the fsid on the sysfs
- */
- snprintf(fsid_buf, BTRFS_UUID_UNPARSED_SIZE, "%pU",
- root->fs_info->fsid);
- if (kobject_rename(&root->fs_info->fs_devices->fsid_kobj,
- fsid_buf))
- pr_warn("BTRFS: sysfs: failed to create fsid for sprout\n");
}
root->fs_info->num_tolerated_disk_barrier_failures =
@@ -2374,7 +2369,7 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
error_trans:
btrfs_end_transaction(trans, root);
rcu_string_free(device->name);
- btrfs_sysfs_rm_device_link(root->fs_info->fs_devices, device);
+ btrfs_sysfs_rm_device_link(root->fs_info->fs_devices, device, 0);
kfree(device);
error:
blkdev_put(bdev, FMODE_EXCL);
@@ -6286,6 +6281,7 @@ static struct btrfs_fs_devices *open_seed_devices(struct btrfs_root *root,
fs_devices->seed = root->fs_info->fs_devices->seed;
root->fs_info->fs_devices->seed = fs_devices;
+
out:
return fs_devices;
}
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
index 865d853..664e2cf2 100644
--- a/fs/btrfs/volumes.h
+++ b/fs/btrfs/volumes.h
@@ -246,6 +246,7 @@ struct btrfs_fs_devices {
struct btrfs_fs_devices *seed;
int seeding;
+ struct kobject *seed_dir_kobj;
int opened;
--
2.4.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 0/6] sysfs-part2 Add seed device representation on the sysfs
2015-07-08 7:32 [PATCH 0/6] sysfs-part2 Add seed device representation on the sysfs Anand Jain
` (5 preceding siblings ...)
2015-07-08 7:32 ` [PATCH 6/6] Btrfs: sysfs: support seed devices in the sysfs layout Anand Jain
@ 2015-08-05 17:29 ` David Sterba
2015-08-05 21:51 ` Anand Jain
6 siblings, 1 reply; 10+ messages in thread
From: David Sterba @ 2015-08-05 17:29 UTC (permalink / raw)
To: Anand Jain; +Cc: linux-btrfs, dsterba
On Wed, Jul 08, 2015 at 03:32:48PM +0800, Anand Jain wrote:
> This patch adds the support to show seed device on the btrfs sysfs.
> This is a revamped version of the previously single patch 6/6, and plus
> incorporates David suggestion to add seed fsid under the 'seed' kobject.
>
> Since this adds new patches and to bring in seed kobject it needed
> quite a lot of revamp I am resetting the patch set version to 1.
>
> Anand Jain (6):
> Btrfs: rename btrfs_sysfs_add_one to btrfs_sysfs_add_mounted
> Btrfs: rename btrfs_sysfs_remove_one to btrfs_sysfs_remove_mounted
> Btrfs: rename btrfs_kobj_add_device to btrfs_sysfs_add_device_link
> Btrfs: rename btrfs_kobj_rm_device to btrfs_sysfs_rm_device_link
> Btrfs: rename super_kobj to fsid_kobj
> Btrfs: sysfs: support seed devices in the sysfs layout
Sorry for late reply, the patches look good. I'm going to prepare a
branch for pull into 4.3. Thanks.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/6] sysfs-part2 Add seed device representation on the sysfs
2015-08-05 17:29 ` [PATCH 0/6] sysfs-part2 Add seed device representation on the sysfs David Sterba
@ 2015-08-05 21:51 ` Anand Jain
2015-08-06 12:31 ` David Sterba
0 siblings, 1 reply; 10+ messages in thread
From: Anand Jain @ 2015-08-05 21:51 UTC (permalink / raw)
To: dsterba, linux-btrfs, dsterba
Hi David,
Thanks. more below.
On 08/06/2015 01:29 AM, David Sterba wrote:
> On Wed, Jul 08, 2015 at 03:32:48PM +0800, Anand Jain wrote:
>> This patch adds the support to show seed device on the btrfs sysfs.
>> This is a revamped version of the previously single patch 6/6, and plus
>> incorporates David suggestion to add seed fsid under the 'seed' kobject.
>>
>> Since this adds new patches and to bring in seed kobject it needed
>> quite a lot of revamp I am resetting the patch set version to 1.
>>
>> Anand Jain (6):
>> Btrfs: rename btrfs_sysfs_add_one to btrfs_sysfs_add_mounted
>> Btrfs: rename btrfs_sysfs_remove_one to btrfs_sysfs_remove_mounted
>> Btrfs: rename btrfs_kobj_add_device to btrfs_sysfs_add_device_link
>> Btrfs: rename btrfs_kobj_rm_device to btrfs_sysfs_rm_device_link
>> Btrfs: rename super_kobj to fsid_kobj
these can go in.
>> Btrfs: sysfs: support seed devices in the sysfs layout
>
> Sorry for late reply, the patches look good. I'm going to prepare a
> branch for pull into 4.3. Thanks.
I suggested if this can wait.
on the 2nd thought, I am preparing to conduct a survey to know most
preferred sysfs layout for btrfs.
mainly between
one, less invasive overlays on the existing layout (current method).
the other, separates FS and Volume attributes (old method).
sorry that I am going back a bit, but i think its worth as these API
are forever.
thanks, Anand
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/6] sysfs-part2 Add seed device representation on the sysfs
2015-08-05 21:51 ` Anand Jain
@ 2015-08-06 12:31 ` David Sterba
0 siblings, 0 replies; 10+ messages in thread
From: David Sterba @ 2015-08-06 12:31 UTC (permalink / raw)
To: Anand Jain; +Cc: dsterba, linux-btrfs
On Thu, Aug 06, 2015 at 05:51:16AM +0800, Anand Jain wrote:
...
> these can go in.
>
> >> Btrfs: sysfs: support seed devices in the sysfs layout
> >
> > Sorry for late reply, the patches look good. I'm going to prepare a
> > branch for pull into 4.3. Thanks.
>
> I suggested if this can wait.
> on the 2nd thought, I am preparing to conduct a survey to know most
> preferred sysfs layout for btrfs.
> mainly between
> one, less invasive overlays on the existing layout (current method).
> the other, separates FS and Volume attributes (old method).
>
> sorry that I am going back a bit, but i think its worth as these API
> are forever.
Understood.
^ permalink raw reply [flat|nested] 10+ messages in thread