[Ocfs2-tools-devel] [PATCH 5/6] ocfs2: tunefs disable discontig la.patch.

Srinivas Eeda srinivas.eeda at oracle.com
Mon May 7 16:49:09 PDT 2012


turn off discontiguous local alloc

Signed-off-by: Srinivas Eeda <srinivas.eeda at oracle.com>
---
 tunefs.ocfs2/feature_discontig_la.c |   79 +++++++++++++++++++++++++++++++++++
 1 files changed, 79 insertions(+), 0 deletions(-)

diff --git a/tunefs.ocfs2/feature_discontig_la.c b/tunefs.ocfs2/feature_discontig_la.c
index 102548d..44d7a5e 100644
--- a/tunefs.ocfs2/feature_discontig_la.c
+++ b/tunefs.ocfs2/feature_discontig_la.c
@@ -101,6 +101,85 @@ out:
 	return ret;
 }
 
+static int disable_discontig_la(ocfs2_filesys *fs, int flags)
+{
+	errcode_t ret = 0;
+	struct ocfs2_super_block *super = OCFS2_RAW_SB(fs->fs_super);
+	struct tools_progress *prog = NULL;
+	struct ocfs2_dinode *di;
+	uint64_t blkno;
+	char *buf = NULL;
+	int slot;
+
+	if (!ocfs2_supports_discontig_la(super)) {
+		verbosef(VL_APP,
+			 "Discontiguous local alloc feature is already "
+			 "disabled; nothing to disable\n");
+		goto out;
+	}
+
+	if (!tools_interact("Disable the discontiguous local alloc feature on "
+			    "device \"%s\"? ",
+			    fs->fs_devname))
+		goto out;
+
+	prog = tools_progress_start("Enable discontig local alloc",
+				    "nodiscontig-la", 4);
+	if (!prog) {
+		ret = TUNEFS_ET_NO_MEMORY;
+		tcom_err(ret, "while initializing the progress display");
+		goto out;
+	}
+
+	ret = ocfs2_malloc_block(fs->fs_io, &buf);
+	if (ret)
+		goto out;
+
+	di = (struct ocfs2_dinode *)buf;
+	/* iterate every inode_alloc first. */
+	for (slot = 0; slot < OCFS2_RAW_SB(fs->fs_super)->s_max_slots;
+	     slot++) {
+		ret = ocfs2_lookup_system_inode(fs,
+						LOCAL_ALLOC_SYSTEM_INODE,
+						slot, &blkno);
+		if (ret) {
+			tcom_err(ret, "while finding local alloc %d", slot);
+			goto out;
+		}
+
+		ret = ocfs2_read_inode(fs, blkno, buf);
+		if (ret)
+			goto out;
+
+		if (di->id1.bitmap1.i_total) {
+			tcom_err(ret, "local alloc %d is not clean, run "
+				 "fsck.ocfs2 to clean the file system", slot);
+			goto out;
+		}
+
+		tools_progress_step(prog, 1);
+	}
+
+	tools_progress_step(prog, 1);
+
+	OCFS2_CLEAR_INCOMPAT_FEATURE(super,
+				     OCFS2_FEATURE_INCOMPAT_DISCONTIG_LA);
+	tunefs_block_signals();
+	ret = ocfs2_write_super(fs);
+	tunefs_unblock_signals();
+	if (ret)
+		tcom_err(ret, "while writing out the superblock");
+
+	tools_progress_step(prog, 1);
+out:
+	if (buf)
+		ocfs2_free(&buf);
+
+	if (prog)
+		tools_progress_stop(prog);
+	return ret;
+}
+
 DEFINE_TUNEFS_FEATURE_INCOMPAT(discontig_la,
 			       OCFS2_FEATURE_INCOMPAT_DISCONTIG_LA,
 			       TUNEFS_FLAG_RW | TUNEFS_FLAG_ALLOCATION |
-- 
1.5.4.3




More information about the Ocfs2-tools-devel mailing list