[Ocfs2-tools-commits] taoma commits r1354 - in trunk: libocfs2 tunefs.ocfs2

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Wed May 16 17:49:44 PDT 2007


Author: taoma
Date: 2007-05-16 17:49:41 -0700 (Wed, 16 May 2007)
New Revision: 1354

Modified:
   trunk/libocfs2/mkjournal.c
   trunk/tunefs.ocfs2/tunefs.c
Log:
Add shrinking journal size support in tunefs.ocfs2.

Now ocfs2_truncate can truncate a file to a specified size.
So add the mechanism of journal truncate to save the disk space. 

Signed-off-by:smushran

Modified: trunk/libocfs2/mkjournal.c
===================================================================
--- trunk/libocfs2/mkjournal.c	2007-05-10 19:49:57 UTC (rev 1353)
+++ trunk/libocfs2/mkjournal.c	2007-05-17 00:49:41 UTC (rev 1354)
@@ -301,6 +301,19 @@
 		ret = ocfs2_write_inode(fs, blkno, (char *)di);
 		if (ret)
 			goto out;
+	} else if (clusters < di->i_clusters) {
+		uint64_t new_size = clusters <<
+			   OCFS2_RAW_SB(fs->fs_super)->s_clustersize_bits;
+		ret = ocfs2_truncate(fs, blkno, new_size);
+		if (ret)
+			goto out;
+
+		ocfs2_free_cached_inode(fs, ci);
+		ret = ocfs2_read_cached_inode(fs, blkno, &ci);
+		if (ret) {
+			ci = NULL;
+			goto out;
+		}
 	}
 
 	ret = ocfs2_format_journal(fs, ci);

Modified: trunk/tunefs.ocfs2/tunefs.c
===================================================================
--- trunk/tunefs.ocfs2/tunefs.c	2007-05-10 19:49:57 UTC (rev 1353)
+++ trunk/tunefs.ocfs2/tunefs.c	2007-05-17 00:49:41 UTC (rev 1354)
@@ -976,7 +976,7 @@
 		}
 
 		di = (struct ocfs2_dinode *)buf;
-		if (num_clusters <= di->i_clusters)
+		if (num_clusters == di->i_clusters)
 			continue;
 
 		printf("Updating %s...  ", jrnl_file);
@@ -1445,17 +1445,9 @@
 		opts.jrnl_size = num_clusters <<
 				OCFS2_RAW_SB(fs->fs_super)->s_clustersize_bits;
 
-		if (opts.jrnl_size > def_jrnl_size)
+		if (opts.jrnl_size != def_jrnl_size)
 			printf("Changing journal size %"PRIu64" to %"PRIu64"\n",
 			       def_jrnl_size, opts.jrnl_size);
-		else {
-			if (!opts.num_slots) {
-				com_err(opts.progname, 0, "Journal size %"PRIu64" "
-					"has to be larger " "than %"PRIu64"",
-					opts.jrnl_size, def_jrnl_size);
-				goto unlock;
-			}
-		}
 	}
 
 	/* validate volume size */




More information about the Ocfs2-tools-commits mailing list