[Ocfs2-tools-devel] [PATCH] mkfs: adjust cluster size calculation

Mark Fasheh mark.fasheh at oracle.com
Tue Sep 4 11:01:06 PDT 2007


Mkfs.ocfs2 currently picks cluster sizes that are too large for most file
systems, espcially for those with mixed use where smaller sized files are
common. Change the default heuristics so that we pick the smallest cluster
size which will cover the entire device. Other fs type switches (such as
-Tdatafiles) are unchanged - so formatting with very large cluster sizes is
still easy.

Signed-off-by: Mark Fasheh <mark.fasheh at oracle.com>
---
 mkfs.ocfs2/mkfs.c |   11 ++++-------
 mkfs.ocfs2/mkfs.h |    1 +
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/mkfs.ocfs2/mkfs.c b/mkfs.ocfs2/mkfs.c
index 818736c..785c68b 100644
--- a/mkfs.ocfs2/mkfs.c
+++ b/mkfs.ocfs2/mkfs.c
@@ -1207,21 +1207,18 @@ static uint64_t figure_journal_size(uint64_t size, State *s)
 
 static uint32_t cluster_size_default(State *s)
 {
-	uint32_t volume_size, cluster_size, cluster_size_bits, need;
+	uint32_t cluster_size, cluster_size_bits;
+	uint64_t volume_size;
 
 	for (cluster_size = OCFS2_MIN_CLUSTERSIZE;
-	     cluster_size < AUTO_CLUSTERSIZE;
+	     cluster_size < OCFS2_MAX_CLUSTERSIZE;
 	     cluster_size <<= 1) {
 		cluster_size_bits = get_bits(s, cluster_size);
 
 		volume_size =
 			s->volume_size_in_bytes >> cluster_size_bits;
 
-		need = (volume_size + 7) >> 3;
-		need = ((need + cluster_size - 1) >>
-			cluster_size_bits) << cluster_size_bits;
-
-		if (need <= BITMAP_AUTO_MAX) 
+		if (volume_size <= CLUSTERS_MAX)
 			break;
 	}
 
diff --git a/mkfs.ocfs2/mkfs.h b/mkfs.ocfs2/mkfs.h
index 6db83e9..262c43d 100644
--- a/mkfs.ocfs2/mkfs.h
+++ b/mkfs.ocfs2/mkfs.h
@@ -94,6 +94,7 @@
 
 #define AUTO_CLUSTERSIZE       65536
 
+#define CLUSTERS_MAX           (UINT32_MAX - 1)
 
 enum {
 	SFI_JOURNAL,
-- 
1.5.2.2




More information about the Ocfs2-tools-devel mailing list