[Ocfs2-tools-devel] [PATCH 1/1] mkfs.ocfs2: Limit the extent allocator reservation

Sunil Mushran sunil.mushran at oracle.com
Thu Sep 30 17:15:47 PDT 2010


For ultra small volumes, reserving extent allocator makes no sense.
This patch disables the allocation if the minimum size that can be
allocated is > 5% of the volume. The minimum size is calculated based
on 1 allocation group per slot.

Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com>
---
 mkfs.ocfs2/mkfs.c |    8 +++++++-
 mkfs.ocfs2/mkfs.h |    3 +++
 2 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/mkfs.ocfs2/mkfs.c b/mkfs.ocfs2/mkfs.c
index 3922638..16e2eab 100644
--- a/mkfs.ocfs2/mkfs.c
+++ b/mkfs.ocfs2/mkfs.c
@@ -1404,7 +1404,8 @@ static uint32_t cluster_size_datafiles(State *s)
 
 static uint32_t figure_extent_alloc_size(State *s)
 {
-	uint32_t cpg, numgroups;
+	uint32_t cpg;
+	int numgroups;
 	uint64_t unitsize, totalsize;
 	double curr_percent, target_percent;
 
@@ -1435,6 +1436,11 @@ static uint32_t figure_extent_alloc_size(State *s)
 		totalsize += unitsize;
 	}
 
+	if (curr_percent > MAX_EXTALLOC_RESERVE_PERCENT)
+		--numgroups;
+
+	assert(numgroups >= 0);
+
 	return cpg * numgroups;
 }
 
diff --git a/mkfs.ocfs2/mkfs.h b/mkfs.ocfs2/mkfs.h
index c3aecd6..ecbd8a0 100644
--- a/mkfs.ocfs2/mkfs.h
+++ b/mkfs.ocfs2/mkfs.h
@@ -40,6 +40,7 @@
 #include <netinet/in.h>
 #include <inttypes.h>
 #include <ctype.h>
+#include <assert.h>
 
 #include <uuid/uuid.h>
 
@@ -89,6 +90,8 @@
 
 #define CLUSTERS_MAX           (UINT32_MAX - 1)
 
+#define MAX_EXTALLOC_RESERVE_PERCENT	5
+
 enum {
 	SFI_JOURNAL,
 	SFI_CLUSTER,
-- 
1.5.6.5




More information about the Ocfs2-tools-devel mailing list