linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Goffredo Baroncelli <kreijack@inwind.it>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH v0 2/4] Add hook for sysfs to btrfs.
Date: Thu, 23 Aug 2012 14:13:18 +0200	[thread overview]
Message-ID: <20120823121305.12203.15916.stgit@venice.bhome> (raw)
In-Reply-To: <20120823120505.12203.11658.stgit@venice.bhome>

Add the hook in the btrfs filesystem code to supporting sysfs.
---
 fs/btrfs/volumes.c |   15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index ecaad40..e1075ab 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -36,6 +36,7 @@
 #include "async-thread.h"
 #include "check-integrity.h"
 #include "rcu-string.h"
+#include "sysfs.h"
 
 static int init_first_rw_device(struct btrfs_trans_handle *trans,
 				struct btrfs_root *root,
@@ -405,6 +406,8 @@ static noinline int device_list_add(const char *path,
 		}
 	}
 
+	btrfs_sysfs_add_device(device);
+
 	if (found_transid > fs_devices->latest_trans) {
 		fs_devices->latest_devid = devid;
 		fs_devices->latest_trans = found_transid;
@@ -458,6 +461,9 @@ static struct btrfs_fs_devices *clone_fs_devices(struct btrfs_fs_devices *orig)
 		INIT_LIST_HEAD(&device->dev_alloc_list);
 
 		list_add(&device->dev_list, &fs_devices->devices);
+		
+		btrfs_sysfs_add_device(device);
+		
 		device->fs_devices = fs_devices;
 		fs_devices->num_devices++;
 	}
@@ -576,7 +582,7 @@ static int __btrfs_close_devices(struct btrfs_fs_devices *fs_devices)
 		new_device->in_fs_metadata = 0;
 		new_device->can_discard = 0;
 		list_replace_rcu(&device->dev_list, &new_device->dev_list);
-
+		//btrfs_sysfs_remove_device(device);
 		call_rcu(&device->rcu, free_device);
 	}
 	mutex_unlock(&fs_devices->device_list_mutex);
@@ -1430,6 +1436,9 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
 
 	cur_devices = device->fs_devices;
 	mutex_lock(&root->fs_info->fs_devices->device_list_mutex);
+	
+	btrfs_sysfs_remove_device(device);
+	
 	list_del_rcu(&device->dev_list);
 
 	device->fs_devices->num_devices--;
@@ -1744,6 +1753,7 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
 	 */
 	mutex_lock(&root->fs_info->fs_devices->device_list_mutex);
 	list_add_rcu(&device->dev_list, &root->fs_info->fs_devices->devices);
+	btrfs_sysfs_add_device(device);
 	list_add(&device->dev_alloc_list,
 		 &root->fs_info->fs_devices->alloc_list);
 	root->fs_info->fs_devices->num_devices++;
@@ -4306,6 +4316,9 @@ static struct btrfs_device *add_missing_dev(struct btrfs_root *root,
 	spin_lock_init(&device->io_lock);
 	INIT_LIST_HEAD(&device->dev_alloc_list);
 	memcpy(device->uuid, dev_uuid, BTRFS_UUID_SIZE);
+	
+	btrfs_sysfs_add_device(device);
+	
 	return device;
 }
 


  parent reply	other threads:[~2012-08-23 12:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-23 12:12 [PATCH v0 0/4] BTRFS sysfs support Goffredo Baroncelli
2012-08-23 12:12 ` [PATCH v0 1/4] Add support for sysfs to btrfs Goffredo Baroncelli
2012-08-23 14:01   ` Stefan Behrens
2012-08-23 12:13 ` Goffredo Baroncelli [this message]
2012-08-23 12:13 ` [PATCH v0 3/4] Add a new Kconfig section to enable or disable the sysfs Goffredo Baroncelli
2012-08-23 12:13 ` [PATCH v0 4/4] Btrfs sysfs support documentation Goffredo Baroncelli

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=20120823121305.12203.15916.stgit@venice.bhome \
    --to=kreijack@inwind.it \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).