All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Cc: dsterba@suse.cz
Subject: [PATCH 26/26] Btrfs: create sys/fs/btrfs/fsid when scanned instead of when mounted
Date: Tue, 10 Mar 2015 06:38:44 +0800	[thread overview]
Message-ID: <1425940724-7744-27-git-send-email-anand.jain@oracle.com> (raw)
In-Reply-To: <1425940724-7744-1-git-send-email-anand.jain@oracle.com>

This patch changes the life cycle of the exisiting sysfs kobjects
/sys/fs/btrfs/<fsid> and /sys/fs/btrfs/<fsid>/devices,
from that they are created and destroyed by mount and unmount event
respectively, to created and destroyed by scanned-registered and
module-unload respectively.

So that information from the btrfs_fs_devices can be added.

This does not change life cycle of any attributes from the fs_info.

The changes here are very simple, thanks to the sysfs framework
modifictions patchset which was sent before.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/disk-io.c | 3 ++-
 fs/btrfs/sysfs.c   | 7 ++++++-
 fs/btrfs/sysfs.h   | 3 ++-
 fs/btrfs/volumes.c | 6 +++++-
 4 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 4b19e41..0155ce8 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3694,7 +3694,8 @@ void close_ctree(struct btrfs_root *root)
 	}
 
 	btrfs_sysfs_remove_mounted(fs_info);
-	btrfs_sysfs_remove_fsid(fs_info->fs_devices);
+	if (fs_info->fs_devices->seed)
+		btrfs_sysfs_remove_fsid(fs_info->fs_devices->seed);
 
 	btrfs_free_fs_roots(fs_info);
 
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index e1b4f95..253e57e 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -845,6 +845,7 @@ int btrfs_init_sysfs(void)
 void btrfs_exit_sysfs(void)
 {
 	sysfs_remove_group(&btrfs_kset->kobj, &btrfs_feature_attr_group);
+	btrfs_sysfs_remove_fsid(NULL);
 	kset_unregister(btrfs_kset);
 	debugfs_remove_recursive(btrfs_debugfs_root_dentry);
 }
@@ -855,7 +856,8 @@ void btrfs_sysfs_prepare_sprout_reset(void)
 }
 
 void btrfs_sysfs_prepare_sprout(struct btrfs_fs_devices *fs_devices,
-				struct btrfs_fs_devices *seed_devices)
+				struct btrfs_fs_devices *seed_devices,
+				struct btrfs_fs_devices *old_devices)
 {
 	char fsid_buf[BTRFS_UUID_UNPARSED_SIZE];
 
@@ -898,4 +900,7 @@ void btrfs_sysfs_prepare_sprout(struct btrfs_fs_devices *fs_devices,
 					&seed_devices->super_kobj))
 			pr_warn("Btrfs: sysfs: kobject move failed\n");
 	}
+
+	btrfs_sysfs_add_fsid(old_devices, NULL, 0);
+	btrfs_sysfs_add_device(old_devices, 0);
 }
diff --git a/fs/btrfs/sysfs.h b/fs/btrfs/sysfs.h
index b23e94c..34b9864 100644
--- a/fs/btrfs/sysfs.h
+++ b/fs/btrfs/sysfs.h
@@ -79,5 +79,6 @@ int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs,
 int btrfs_sysfs_add_device(struct btrfs_fs_devices *fs_devs, int follow_seed);
 void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs);
 void btrfs_sysfs_prepare_sprout(struct btrfs_fs_devices *fs_devices,
-				struct btrfs_fs_devices *seed_devices);
+				struct btrfs_fs_devices *seed_devices,
+				struct btrfs_fs_devices *old_devices);
 #endif /* _BTRFS_SYSFS_H_ */
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index bf59224..dfb5062 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -523,6 +523,10 @@ static noinline int device_list_add(const char *path,
 		list_add(&fs_devices->list, &fs_uuids);
 
 		device = NULL;
+		if (btrfs_sysfs_add_fsid(fs_devices, NULL, 0))
+			printk(KERN_WARNING "Btrfs: sysfs add fsid failed\n");
+		if (btrfs_sysfs_add_device(fs_devices, 0))
+			printk(KERN_WARNING "Btrfs: sysfs add device failed\n");
 	} else {
 		device = __find_device(&fs_devices->devices, devid,
 				       disk_super->dev_item.uuid);
@@ -2064,7 +2068,7 @@ 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);
+	btrfs_sysfs_prepare_sprout(fs_devices, seed_devices, old_devices);
 
 	return 0;
 }
-- 
2.0.0.153.g79dcccc


  parent reply	other threads:[~2015-03-09 17:11 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-09 22:38 [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added Anand Jain
2015-03-09 22:38 ` [PATCH 01/26] Btrfs: sysfs: fix, btrfs_release_super_kobj() should to clean up the kobject data Anand Jain
2015-03-09 22:38 ` [PATCH 02/26] Btrfs: sysfs: fix, fs_info kobject_unregister has init_completion() twice Anand Jain
2015-03-09 22:38 ` [PATCH 03/26] Btrfs: sysfs: fix, undo sysfs device links Anand Jain
2015-03-09 22:38 ` [PATCH 04/26] Btrfs: sysfs: fix, kobject pointer clean up needed after kobject release Anand Jain
2015-03-09 22:38 ` [PATCH 05/26] Btrfc: sysfs: fix, check if device_dir_kobj is init before destroy Anand Jain
2015-03-09 22:38 ` [PATCH 06/26] Btrfs: sysfs: reorder the kobject creations Anand Jain
2015-03-09 22:38 ` [PATCH 07/26] Btrfs: sysfs: rename __btrfs_sysfs_remove_one to btrfs_sysfs_remove_fsid Anand Jain
2015-03-09 22:38 ` [PATCH 08/26] Btrfs: sysfs: introduce function btrfs_sysfs_add_fsid() to create sysfs fsid Anand Jain
2015-03-09 22:38 ` [PATCH 09/26] Btrfs: sysfs: let default_attrs be separate from the kset Anand Jain
2015-03-09 22:38 ` [PATCH 10/26] Btrfs: sysfs: separate device kobject and its attribute creation Anand Jain
2015-03-09 22:38 ` [PATCH 11/26] Btrfs: sysfs: move super_kobj and device_dir_kobj from fs_info to btrfs_fs_devices Anand Jain
2015-03-09 22:38 ` [PATCH 12/26] Btrfs: introduce btrfs_get_fs_uuids to get fs_uuids v2 Anand Jain
2015-03-09 22:38 ` [PATCH 13/26] Btrfs: sysfs: add pointer to access fs_info from fs_devices v2 Anand Jain
2015-03-09 22:38 ` [PATCH 14/26] Btrfs: sysfs: provide framework to remove all fsid sysfs kobject v2 Anand Jain
2015-03-09 22:38 ` [PATCH 15/26] Btrfs: sysfs btrfs_kobj_add_device() pass fs_devices instead of fs_info Anand Jain
2015-03-09 22:38 ` [PATCH 16/26] Btrfs: sysfs btrfs_kobj_rm_device() " Anand Jain
2015-03-09 22:38 ` [PATCH 17/26] Btrfs: sysfs: make btrfs_sysfs_add_fsid() non static Anand Jain
2015-03-09 22:38 ` [PATCH 18/26] Btrfs: sysfs: make btrfs_sysfs_add_device() " Anand Jain
2015-03-09 22:38 ` [PATCH 19/26] Btrfs: sysfs: btrfs_sysfs_remove_fsid() make it " Anand Jain
2015-03-09 22:38 ` [PATCH 20/26] Btrfs: sysfs: separate kobject and attribute creation Anand Jain
2015-03-09 22:38 ` [PATCH 21/26] Btrfs: sysfs: add support to add parent for fsid Anand Jain
2015-03-09 22:38 ` [PATCH 22/26] Btrfs: sysfs: don't fail seeding for the sake of sysfs kobject issue v2 Anand Jain
2015-03-09 22:38 ` [PATCH 23/26] Btrfs: free the stale device Anand Jain
2015-03-09 22:38 ` [PATCH 24/26] Btrfs: sysfs: add support to show replacing target in the sysfs Anand Jain
2015-03-09 22:38 ` [PATCH 25/26] Btrfs: sysfs: support seed devices in the sysfs layout v3 Anand Jain
2015-03-19 18:55   ` David Sterba
2015-03-20  1:58     ` Anand Jain
2015-03-09 22:38 ` Anand Jain [this message]
2015-03-19 18:58 ` [PATCH 00/26 v4] provide framework so that sysfs attributs from the fs_devices can be added David Sterba
2015-03-20 10:03   ` Anand Jain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1425940724-7744-27-git-send-email-anand.jain@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.