linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] btrfs-progs: introduce btrfs_register_all_device()
@ 2014-10-15  0:51 Anand Jain
  2014-10-15  0:51 ` [PATCH 2/2] btrfs-progs: optimize btrfs_scan_lblkid() for multiple calls Anand Jain
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Anand Jain @ 2014-10-15  0:51 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba, clm

This function is to register all devices found after scanning
the system. Before we had this functionality with in the
btrfs_scan_lblkid(), however scanning and registering are two
different distinct operation its better keep them separate.
Also we want to optimize btrfs_scan_lblkid and avoid multiple
system scans unless needed. As of now device scan uses this function.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 utils.h   |  1 +
 volumes.c | 25 +++++++++++++++++++++++++
 volumes.h |  1 +
 3 files changed, 27 insertions(+)

diff --git a/utils.h b/utils.h
index 3f7b388..237cf64 100644
--- a/utils.h
+++ b/utils.h
@@ -162,5 +162,6 @@ static inline u64 btrfs_min_dev_size(u32 leafsize)
 	return 2 * (BTRFS_MKFS_SYSTEM_GROUP_SIZE +
 		    btrfs_min_global_blk_rsv_size(leafsize));
 }
+int btrfs_register_one_device(char *fname);
 
 #endif
diff --git a/volumes.c b/volumes.c
index 266a474..c8057c8 100644
--- a/volumes.c
+++ b/volumes.c
@@ -30,6 +30,7 @@
 #include "print-tree.h"
 #include "volumes.h"
 #include "math.h"
+#include "utils.h"
 
 struct stripe {
 	struct btrfs_device *dev;
@@ -1533,6 +1534,30 @@ btrfs_find_device_by_devid(struct btrfs_fs_devices *fs_devices,
 	return NULL;
 }
 
+/*
+ * Register all devices in the fs_uuid list created in the user
+ * space. Ensure btrfs_scan_lblkid() is called before this func.
+ */
+int btrfs_register_all_devices(void)
+{
+	int err;
+	struct btrfs_fs_devices *fs_devices;
+	struct btrfs_device *device;
+
+	list_for_each_entry(fs_devices, &fs_uuids, list) {
+		list_for_each_entry(device, &fs_devices->devices, dev_list) {
+			if (strlen(device->name) != 0) {
+				err = btrfs_register_one_device(device->name);
+				if (err < 0)
+					return err;
+				if (err > 0)
+					return -err;
+			}
+		}
+	}
+	return 0;
+}
+
 int btrfs_chunk_readonly(struct btrfs_root *root, u64 chunk_offset)
 {
 	struct cache_extent *ce;
diff --git a/volumes.h b/volumes.h
index 447dd4b..ccba34b 100644
--- a/volumes.h
+++ b/volumes.h
@@ -195,4 +195,5 @@ int write_raid56_with_parity(struct btrfs_fs_info *info,
 			     struct extent_buffer *eb,
 			     struct btrfs_multi_bio *multi,
 			     u64 stripe_len, u64 *raid_map);
+int btrfs_register_all_devices(void);
 #endif
-- 
2.0.0.153.g79dcccc


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2014-11-28  9:33 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-15  0:51 [PATCH 1/2] btrfs-progs: introduce btrfs_register_all_device() Anand Jain
2014-10-15  0:51 ` [PATCH 2/2] btrfs-progs: optimize btrfs_scan_lblkid() for multiple calls Anand Jain
2014-10-23  6:30   ` [PATCH 2/2 v2] " Anand Jain
2014-10-30 14:18     ` David Sterba
2014-10-31  1:38       ` Anand Jain
2014-10-31  3:19   ` [PATCH 2/2 v3] " Anand Jain
2014-10-30 14:33 ` [PATCH 1/2] btrfs-progs: introduce btrfs_register_all_device() David Sterba
2014-10-31  2:28   ` Anand Jain
2014-10-31  4:11 ` [PATCH 1/2 v4] " Anand Jain
2014-10-31  4:11   ` [PATCH 2/2 v4] btrfs-progs: optimize btrfs_scan_lblkid() for multiple calls Anand Jain
2014-10-31  9:08     ` Karel Zak
2014-10-31 11:04       ` Anand Jain
2014-11-11 11:47         ` Karel Zak
2014-11-14 16:51           ` David Sterba
2014-11-28  9:33             ` Karel Zak

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).