Skip to contentSkip to conversation

Minor UUID cleanup

PATCH In review Nikolay Borisov 4 participants 9 messages Feb 18, 2020 – Feb 21, 2020 Btrfs file system

lore
Share & tools
lore
#0 lore raw

cover Minor UUID cleanup

Here is a short series that removes one indirect call in btrfs_uuid_tree_iterate and making uuid rescan functions private to disk-io.c since they are used only during mount.

Nikolay Borisov (3):
btrfs: Call btrfs_check_uuid_tree_entry directly in
btrfs_uuid_tree_iterate
btrfs: export btrfs_uuid_scan_kthread
btrfs: Make btrfs_check_uuid_tree private to disk-io.c

 fs/btrfs/ctree.h     |  4 +--
 fs/btrfs/disk-io.c   | 35 +++++++++++++++++++
 fs/btrfs/uuid-tree.c | 50 ++++++++++++++++++++++++---
 fs/btrfs/volumes.c   | 82 +-------------------------------------------
 fs/btrfs/volumes.h   |  2 +-
 5 files changed, 84 insertions(+), 89 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/3 btrfs: Call btrfs_check_uuid_tree_entry directly in btrfs_uuid_tree_iterate

btrfs_uuid_tree_iterate is called from only once place and its 2nd argument is always btrfs_check_uuid_tree_entry. Simplify btrfs_uuid_tree_iterate's signature by removing its 2nd argument and directly calling btrfs_check_uuid_tree_entry. Also move the latter into uuid-tree.h. No functional changes.

---
 fs/btrfs/ctree.h     |  4 +---
 fs/btrfs/uuid-tree.c | 50 ++++++++++++++++++++++++++++++++++++++++----
 fs/btrfs/volumes.c   | 47 +----------------------------------------
 3 files changed, 48 insertions(+), 53 deletions(-)
fs/btrfs/ctree.h +1 -3
index bb237d577725..ad275d06e95f 100644
@@ -2738,9 +2738,7 @@ int btrfs_uuid_tree_add(struct btrfs_trans_handle *trans, u8 *uuid, u8 type,
 			u64 subid);
 int btrfs_uuid_tree_remove(struct btrfs_trans_handle *trans, u8 *uuid, u8 type,
 			u64 subid);
-int btrfs_uuid_tree_iterate(struct btrfs_fs_info *fs_info,
-			    int (*check_func)(struct btrfs_fs_info *, u8 *, u8,
-					      u64));
+int btrfs_uuid_tree_iterate(struct btrfs_fs_info *fs_info);
 
 /* dir-item.c */
 int btrfs_check_dir_item_collision(struct btrfs_root *root, u64 dir,
fs/btrfs/uuid-tree.c +46 -4

63 lines not on this page · raw message

fs/btrfs/volumes.c +1 -46

59 lines not on this page · raw message

Signature · 1 line
2.17.1
Reviewed-by on v1 1/3
#3 lore raw

Re: [PATCH 1/3] btrfs: Call btrfs_check_uuid_tree_entry directly in btrfs_uuid_tree_iterate

In reply to Nikolay Borisov
Quoted 5 lines · Nikolay Borisov

btrfs_uuid_tree_iterate is called from only once place and its 2nd argument is always btrfs_check_uuid_tree_entry. Simplify btrfs_uuid_tree_iterate's signature by removing its 2nd argument and directly calling btrfs_check_uuid_tree_entry. Also move the latter into uuid-tree.h. No functional changes.

You forgot your signed-off-by

Thanks,

Josef

#4 lore raw

PATCH 2/3 btrfs: export btrfs_uuid_scan_kthread

In reply to Nikolay Borisov

This is preparation for the next patch that will move the rescan uuid kthread into disk-io.c. No functional changes.

---
 fs/btrfs/volumes.c | 2 +-
 fs/btrfs/volumes.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/volumes.c +1 -1
index fdc0e52542dd..0b4da3557c27 100644
@@ -4274,7 +4274,7 @@ int btrfs_cancel_balance(struct btrfs_fs_info *fs_info)
 	return 0;
 }
 
-static int btrfs_uuid_scan_kthread(void *data)
+int btrfs_uuid_scan_kthread(void *data)
 {
 	struct btrfs_fs_info *fs_info = data;
 	struct btrfs_root *root = fs_info->tree_root;
fs/btrfs/volumes.h +1 -0
index f01552a0785e..311d03cf99a7 100644
@@ -462,6 +462,7 @@ int btrfs_pause_balance(struct btrfs_fs_info *fs_info);
 int btrfs_cancel_balance(struct btrfs_fs_info *fs_info);
 int btrfs_create_uuid_tree(struct btrfs_fs_info *fs_info);
 int btrfs_check_uuid_tree(struct btrfs_fs_info *fs_info);
+int btrfs_uuid_scan_kthread(void *data);
 int btrfs_chunk_readonly(struct btrfs_fs_info *fs_info, u64 chunk_offset);
 int find_free_dev_extent(struct btrfs_device *device, u64 num_bytes,
 			 u64 *start, u64 *max_avail);
Signature · 1 line
2.17.1
#5 lore raw

Re: [PATCH 2/3] btrfs: export btrfs_uuid_scan_kthread

I'd squash this into the next patch

#6 lore raw

PATCH 3/3 btrfs: Make btrfs_check_uuid_tree private to disk-io.c

In reply to Nikolay Borisov

It's used only during fs mount as such it can be made private to disk-io.c file. Also use the occassion to move btrfs_uuid_rescan_kthread as btrfs_check_uuid_tree is its sole caller. No functional changes.

---
 fs/btrfs/disk-io.c | 35 +++++++++++++++++++++++++++++++++++
 fs/btrfs/volumes.c | 35 -----------------------------------
 fs/btrfs/volumes.h |  1 -
 3 files changed, 35 insertions(+), 36 deletions(-)
fs/btrfs/disk-io.c +35 -0
index 9046bf0d4868..cf60385e0dfb 100644
@@ -2836,6 +2836,41 @@ static int init_mount_fs_info(struct btrfs_fs_info *fs_info, struct super_block
 	return ret;
 }
 
+static int btrfs_uuid_rescan_kthread(void *data)
+{
+	struct btrfs_fs_info *fs_info = (struct btrfs_fs_info *)data;
+	int ret;
+
+	/*
+	 * 1st step is to iterate through the existing UUID tree and
+	 * to delete all entries that contain outdated data.
+	 * 2nd step is to add all missing entries to the UUID tree.
+	 */
+	ret = btrfs_uuid_tree_iterate(fs_info);
+	if (ret < 0) {
+		btrfs_warn(fs_info, "iterating uuid_tree failed %d", ret);
+		up(&fs_info->uuid_tree_rescan_sem);
+		return ret;
+	}
+	return btrfs_uuid_scan_kthread(data);
+}
+
+static int btrfs_check_uuid_tree(struct btrfs_fs_info *fs_info)
+{
+	struct task_struct *task;
+
+	down(&fs_info->uuid_tree_rescan_sem);
+	task = kthread_run(btrfs_uuid_rescan_kthread, fs_info, "btrfs-uuid");
+	if (IS_ERR(task)) {
+		/* fs_info->update_uuid_tree_gen remains 0 in all error case */
+		btrfs_warn(fs_info, "failed to start uuid_rescan task");
+		up(&fs_info->uuid_tree_rescan_sem);
+		return PTR_ERR(task);
+	}
+
+	return 0;
+}
+
 int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_devices,
 		      char *options)
 {
fs/btrfs/volumes.c +0 -35
index 0b4da3557c27..91618be34e6c 100644
@@ -4403,25 +4403,6 @@ int btrfs_uuid_scan_kthread(void *data)
 	return 0;
 }
 
-static int btrfs_uuid_rescan_kthread(void *data)
-{
-	struct btrfs_fs_info *fs_info = (struct btrfs_fs_info *)data;
-	int ret;
-
-	/*
-	 * 1st step is to iterate through the existing UUID tree and
-	 * to delete all entries that contain outdated data.
-	 * 2nd step is to add all missing entries to the UUID tree.
-	 */
-	ret = btrfs_uuid_tree_iterate(fs_info);
-	if (ret < 0) {
-		btrfs_warn(fs_info, "iterating uuid_tree failed %d", ret);
-		up(&fs_info->uuid_tree_rescan_sem);
-		return ret;
-	}
-	return btrfs_uuid_scan_kthread(data);
-}
-
 int btrfs_create_uuid_tree(struct btrfs_fs_info *fs_info)
 {
 	struct btrfs_trans_handle *trans;
@@ -4464,22 +4445,6 @@ int btrfs_create_uuid_tree(struct btrfs_fs_info *fs_info)
 	return 0;
 }
 
-int btrfs_check_uuid_tree(struct btrfs_fs_info *fs_info)
-{
-	struct task_struct *task;
-
-	down(&fs_info->uuid_tree_rescan_sem);
-	task = kthread_run(btrfs_uuid_rescan_kthread, fs_info, "btrfs-uuid");
-	if (IS_ERR(task)) {
-		/* fs_info->update_uuid_tree_gen remains 0 in all error case */
-		btrfs_warn(fs_info, "failed to start uuid_rescan task");
-		up(&fs_info->uuid_tree_rescan_sem);
-		return PTR_ERR(task);
-	}
-
-	return 0;
-}
-
 /*
  * shrinking a device means finding all of the device extents past
  * the new size, and then following the back refs to the chunks.
fs/btrfs/volumes.h +0 -1
index 311d03cf99a7..bb0fc7b35ba0 100644
@@ -461,7 +461,6 @@ int btrfs_recover_balance(struct btrfs_fs_info *fs_info);
 int btrfs_pause_balance(struct btrfs_fs_info *fs_info);
 int btrfs_cancel_balance(struct btrfs_fs_info *fs_info);
 int btrfs_create_uuid_tree(struct btrfs_fs_info *fs_info);
-int btrfs_check_uuid_tree(struct btrfs_fs_info *fs_info);
 int btrfs_uuid_scan_kthread(void *data);
 int btrfs_chunk_readonly(struct btrfs_fs_info *fs_info, u64 chunk_offset);
 int find_free_dev_extent(struct btrfs_device *device, u64 num_bytes,
Signature · 1 line
2.17.1
Reviewed-by on v1 3/3
#7 lore raw

Re: [PATCH 3/3] btrfs: Make btrfs_check_uuid_tree private to disk-io.c

Quoted 4 lines · Nikolay Borisov

It's used only during fs mount as such it can be made private to disk-io.c file. Also use the occassion to move btrfs_uuid_rescan_kthread as btrfs_check_uuid_tree is its sole caller. No functional changes.
---

Forgot your signed-off-by here as well. And it's "occasion".

Thanks,

Josef

#8 lore raw
In reply to Nikolay Borisov
Quoted 9 lines · Nikolay Borisov

Here is a short series that removes one indirect call in btrfs_uuid_tree_iterate and making uuid rescan functions private to disk-io.c since they are used only during mount.

Nikolay Borisov (3):
btrfs: Call btrfs_check_uuid_tree_entry directly in
btrfs_uuid_tree_iterate
btrfs: export btrfs_uuid_scan_kthread
btrfs: Make btrfs_check_uuid_tree private to disk-io.c

With the fixups applied, added to misc-next. Thanks.