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

Sunil Mushran sunil.mushran at oracle.com
Thu Sep 27 17:14:25 PDT 2007


From: Mark Fasheh <mark.fasheh at oracle.com>

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>
Signed-off-by: Sunil Mushran <sunil.mushran 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 e6f6469..cd7c1ab 100644
--- a/mkfs.ocfs2/mkfs.c
+++ b/mkfs.ocfs2/mkfs.c
@@ -940,21 +940,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 b6ccc60..e08945a 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.5




More information about the Ocfs2-tools-devel mailing list