Skip to contentSkip to conversation

Define/enum conversions

PATCH In review David Sterba 4 participants 7 messages Aug 1, 2019 – Aug 2, 2019 Btrfs file system

lore
Share & tools
lore

David Sterba

author maintainer
#0 lore raw

cover Define/enum conversions

David Sterba (3):
btrfs: tree-log: convert defines to enums
btrsf: async-thread: convert defines to enums
btrfs: tree-log: use symbolic name for first replay stage

 fs/btrfs/async-thread.c |  8 +++++---
 fs/btrfs/tree-log.c     | 22 +++++++++++++---------
 2 files changed, 18 insertions(+), 12 deletions(-)
Signature · 1 line
2.22.0
author maintainer
#1 lore raw

PATCH 1/3 btrfs: tree-log: convert defines to enums

Used only for in-memory state tracking.

---
 fs/btrfs/tree-log.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
fs/btrfs/tree-log.c +12 -8
index 6c8297bcfeb7..5513e76cc336 100644
@@ -24,10 +24,12 @@
  * LOG_INODE_EXISTS means to log just enough to recreate the inode
  * during log replay
  */
-#define LOG_INODE_ALL 0
-#define LOG_INODE_EXISTS 1
-#define LOG_OTHER_INODE 2
-#define LOG_OTHER_INODE_ALL 3
+enum {
+	LOG_INODE_ALL,
+	LOG_INODE_EXISTS,
+	LOG_OTHER_INODE,
+	LOG_OTHER_INODE_ALL,
+};
 
 /*
  * directory trouble cases
@@ -81,10 +83,12 @@
  * The last stage is to deal with directories and links and extents
  * and all the other fun semantics
  */
-#define LOG_WALK_PIN_ONLY 0
-#define LOG_WALK_REPLAY_INODES 1
-#define LOG_WALK_REPLAY_DIR_INDEX 2
-#define LOG_WALK_REPLAY_ALL 3
+enum {
+	LOG_WALK_PIN_ONLY,
+	LOG_WALK_REPLAY_INODES,
+	LOG_WALK_REPLAY_DIR_INDEX,
+	LOG_WALK_REPLAY_ALL,
+};
 
 static int btrfs_log_inode(struct btrfs_trans_handle *trans,
 			   struct btrfs_root *root, struct btrfs_inode *inode,
Signature · 1 line
2.22.0
author maintainer
#2 lore raw

PATCH 2/3 btrsf: async-thread: convert defines to enums

In reply to David Sterba
---
 fs/btrfs/async-thread.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
fs/btrfs/async-thread.c +5 -3
index 122cb97c7909..2e9e13ffbd08 100644
@@ -12,9 +12,11 @@
 #include "async-thread.h"
 #include "ctree.h"
 
-#define WORK_DONE_BIT 0
-#define WORK_ORDER_DONE_BIT 1
-#define WORK_HIGH_PRIO_BIT 2
+enum {
+	WORK_DONE_BIT,
+	WORK_ORDER_DONE_BIT,
+	WORK_HIGH_PRIO_BIT,
+};
 
 #define NO_THRESHOLD (-1)
 #define DFT_THRESHOLD (32)
Signature · 1 line
2.22.0
author maintainer
#3 lore raw

PATCH 3/3 btrfs: tree-log: use symbolic name for first replay stage

In reply to David Sterba
---
 fs/btrfs/tree-log.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/tree-log.c +1 -1
index 5513e76cc336..f48c8b9b513b 100644
@@ -6237,7 +6237,7 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree)
 	struct btrfs_fs_info *fs_info = log_root_tree->fs_info;
 	struct walk_control wc = {
 		.process_func = process_one_buffer,
-		.stage = 0,
+		.stage = LOG_WALK_PIN_ONLY,
 	};
 
 	path = btrfs_alloc_path();
Signature · 1 line
2.22.0
Reviewed-by on the v1 series
#6 lore raw
In reply to David Sterba
Quoted 9 lines · David Sterba

David Sterba (3):
btrfs: tree-log: convert defines to enums
btrsf: async-thread: convert defines to enums
btrfs: tree-log: use symbolic name for first replay stage

 fs/btrfs/async-thread.c |  8 +++++---
 fs/btrfs/tree-log.c     | 22 +++++++++++++---------
 2 files changed, 18 insertions(+), 12 deletions(-)

Short and sweet, so :

Reviewed-by on v1 3/3
#4 lore raw

Re: [PATCH 3/3] btrfs: tree-log: use symbolic name for first replay stage

In reply to David Sterba

For whole series.

One nit below.

Quoted 10 lines · David Sterba
---
  fs/btrfs/tree-log.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/tree-log.c +0 -0
index 5513e76cc336..f48c8b9b513b 100644

fs/btrfs/tree-log.c int btrfs_recover_log_trees(struct btrfs_root *log_root_tree) · line 6240

Quoted 5 lines
fs/btrfs/tree-log.c +1 -1
@@ -6237,7 +6237,7 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree)
  	struct btrfs_fs_info *fs_info = log_root_tree->fs_info;
  	struct walk_control wc = {
  		.process_func = process_one_buffer,
-		.stage = 0,
+		.stage = LOG_WALK_PIN_ONLY,

Why this isn't enum?

Quoted 4 lines
fs/btrfs/tree-log.c +0 -0
  	};
 
  	path = btrfs_alloc_path();
#5 lore raw

Re: [PATCH 3/3] btrfs: tree-log: use symbolic name for first replay stage

Quoted 13 lines · Anand Jain

For whole series.

One nit below.

Quoted 5 lines · David Sterba
---
  fs/btrfs/tree-log.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines

fs/btrfs/tree-log.c int btrfs_recover_log_trees(struct btrfs_root *log_root_tree) · line 6240

Quoted 10 lines
fs/btrfs/tree-log.c +1 -1
index 5513e76cc336..f48c8b9b513b 100644
@@ -6237,7 +6237,7 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree)
  	struct btrfs_fs_info *fs_info = log_root_tree->fs_info;
  	struct walk_control wc = {
  		.process_func = process_one_buffer,
-		.stage = 0,
+		.stage = LOG_WALK_PIN_ONLY,

Why this isn't enum?

It could be, though the values of stage are used as raw int comparing it to some value (eg. replay_one_buffer and LOG_WALK_REPLAY_ALL), so that's beyond the scope of the simple conversion.