[Ocfs2-tools-commits] manish commits r877 - trunk/mkfs.ocfs2

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Thu May 5 17:26:06 CDT 2005


Author: manish
Date: 2005-05-05 17:26:04 -0500 (Thu, 05 May 2005)
New Revision: 877

Modified:
   trunk/mkfs.ocfs2/mkfs.c
Log:
Have mkfs sanity check that the requested blocksize is >= hardware sector
size. Also, actually enable the blocksize hueristic, and use symbolic constants for default values.


Modified: trunk/mkfs.ocfs2/mkfs.c
===================================================================
--- trunk/mkfs.ocfs2/mkfs.c	2005-05-05 21:18:50 UTC (rev 876)
+++ trunk/mkfs.ocfs2/mkfs.c	2005-05-05 22:26:04 UTC (rev 877)
@@ -757,6 +757,8 @@
 {
 	size_t pagesize;
 	errcode_t err;
+	uint32_t blocksize;
+	int sectsize;
 	uint32_t ret;
 	struct ocfs2_cluster_group_sizes cgs;
 	uint64_t tmp;
@@ -765,35 +767,63 @@
 
 	s->pagesize_bits = get_bits(s, pagesize);
 
-	if (!s->blocksize)
-		s->blocksize = 4096;
+	err = ocfs2_get_device_sectsize(s->device_name, &sectsize);
+	if (err) {
+		com_err(s->progname, err,
+			"while getting hardware sector size of device %s",
+			s->device_name);
+		exit(1);
+	}
 
+	if (s->blocksize)
+		blocksize = s->blocksize;
+	else
+		blocksize = OCFS2_MAX_BLOCKSIZE;
+
+	if (blocksize < sectsize) {
+		com_err(s->progname, 0,
+			"the block device %s has a hardware sector size (%d) "
+			"that is larger than the selected block size (%u)",
+			s->device_name, sectsize, blocksize);
+		exit(1);
+	}
+
 	if (!s->volume_size_in_blocks) {
-		err = ocfs2_get_device_size(s->device_name, s->blocksize, &ret);
+		err = ocfs2_get_device_size(s->device_name, blocksize, &ret);
+		if (err) {
+			com_err(s->progname, err,
+				"while getting size of device %s",
+				s->device_name);
+			exit(1);
+		}
+
 		s->volume_size_in_blocks = ret;
 		if (s->specified_size_in_blocks) {
 			if (s->specified_size_in_blocks > 
 			    s->volume_size_in_blocks) {
-				printf("%"PRIu64" blocks were specified and "
-				       "this is greater than the %"PRIu64" "
-				       "blocks that make up %s.\n", 
-				       s->specified_size_in_blocks,
-				       s->volume_size_in_blocks, 
-				       s->device_name);
+				com_err(s->progname, 0,
+					"%"PRIu64" blocks were specified and "
+					"this is greater than the %"PRIu64" "
+					"blocks that make up %s.\n", 
+					s->specified_size_in_blocks,
+					s->volume_size_in_blocks, 
+					s->device_name);
 				exit(1);
 			}
 			s->volume_size_in_blocks = s->specified_size_in_blocks;
 		}
 	}
 
-	s->volume_size_in_bytes = s->volume_size_in_blocks * s->blocksize;
+	s->volume_size_in_bytes = s->volume_size_in_blocks * blocksize;
 
 	if (!s->blocksize) {
 		if (s->volume_size_in_bytes <= 1024 * 1024 * 3) {
-			s->blocksize = 512;
+			s->blocksize = OCFS2_MIN_BLOCKSIZE;
 		} else {
 			int shift = 30;
 
+			s->blocksize = OCFS2_MAX_BLOCKSIZE;
+
 			while (s->blocksize > 1024) {
 				if (s->volume_size_in_bytes >= 1U << shift)
 					break;



More information about the Ocfs2-tools-commits mailing list