Skip to contentSkip to conversation

btrfs/ulist: replace the magic number 128 with macro definition ULIST_SIZE_INCREMENT

PATCH In review Wang Sheng-Hui 2 participants 2 messages Mar 8, 2012 – Mar 15, 2012 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs/ulist: replace the magic number 128 with macro definition ULIST_SIZE_INCREMENT

Remove the magic number 128 in btrfs/ulist.c.
Introduce the macro definition ULIST_SIZE_INCREMENT in btrfs/ulist.h.

---
 fs/btrfs/ulist.c |    2 +-
 fs/btrfs/ulist.h |    5 +++++
 2 files changed, 6 insertions(+), 1 deletions(-)
fs/btrfs/ulist.c +1 -1
index 12f5147..b8a4506 100644
@@ -154,7 +154,7 @@ int ulist_add(struct ulist *ulist, u64 val, unsigned long aux,
 	}
 
 	if (ulist->nnodes >= ulist->nodes_alloced) {
-		u64 new_alloced = ulist->nodes_alloced + 128;
+		u64 new_alloced = ulist->nodes_alloced + ULIST_SIZE_INCREMENT;
 		struct ulist_node *new_nodes;
 		void *old = NULL;
 
fs/btrfs/ulist.h +5 -0
index 2e25dec..590e396 100644
@@ -23,6 +23,11 @@
  * number of elements statically allocated inside struct ulist
  */
 #define ULIST_SIZE 16
+/*
+ * increment as dynamically allocated elements space grows
+ */
+#define ULIST_SIZE_INCREMENT 128
+
 
 /*
  * element of the list
Signature · 1 line
1.7.1
#1 lore raw
Quoted 2 lines · Wang Sheng-Hui

Remove the magic number 128 in btrfs/ulist.c.
Introduce the macro definition ULIST_SIZE_INCREMENT in btrfs/ulist.h.

I'm using this patch without problem since you published it (compressed /home with hourly snapshot delete/creation).

Thanks a lot for your work,
Andrea