[Ocfs2-tools-devel] [PATCH 1/5] tunefs.ocfs2: Warn if not using complete device

Goldwyn Rodrigues rgoldwyn at gmail.com
Tue Jan 17 12:10:07 PST 2012


Sample test case (for a device greater than 16TB):
1. Format a device with blocksize 4k and block count < 16TB
2. resize device (-S)
Results: Device is formatted to 16TB even if the device is bigger.

The patch fails the tunefs.ocfs2 attempt and ask user to explicitly state
block-count to not use the complete device.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn at suse.de>
Signed-off-by: Michal Srb <msrb at suse.com>
---
 tunefs.ocfs2/op_resize_volume.c |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/tunefs.ocfs2/op_resize_volume.c b/tunefs.ocfs2/op_resize_volume.c
index 8541374..b16542f 100644
--- a/tunefs.ocfs2/op_resize_volume.c
+++ b/tunefs.ocfs2/op_resize_volume.c
@@ -535,10 +535,24 @@ static errcode_t check_new_size(ocfs2_filesys
*fs, uint64_t new_size,
 	}

 	device_clusters = device_blocks >> b_to_c_bits;
-	if (device_clusters > UINT32_MAX)
-		device_clusters = UINT32_MAX;
-	if (!try_clusters)
+
+	if (!try_clusters) {
+		if (device_clusters > UINT32_MAX) {
+			verbosef(VL_APP,
+				 "Clusters (%"PRIu64" is greater than "
+				 "maximum possible clusters %"PRIu32"\n",
+				 device_clusters, UINT32_MAX);
+			try_blocks = UINT32_MAX << b_to_c_bits;
+			errorf("Clusters %"PRIu64" is greater than max allowed"
+			       " %"PRIu32".\nIf you want to resize to %"PRIu64
+			       " blocks please specify %"PRIu64" as "
+			       "blocks-count.\n", device_clusters,
+				UINT32_MAX, try_blocks, try_blocks);
+			return TUNEFS_ET_INVALID_NUMBER;
+		}
 		try_clusters = device_clusters;
+	}
+
 	try_blocks = try_clusters << b_to_c_bits;

 	/* Now we're guaranteed that try_clusters is within range */
-- 
1.7.7



More information about the Ocfs2-tools-devel mailing list