[Ocfs2-tools-devel] [PATCH 5/6] debugfs.ocfs2: Support the extended slot map.

Joel Becker joel.becker at oracle.com
Thu Dec 6 21:18:10 PST 2007


debugfs.ocfs2 uses lower-level access to read the slot map.  Add the
extended slot map calls.

Signed-off-by: Joel Becker <joel.becker at oracle.com>
---
 debugfs.ocfs2/commands.c     |    8 ++++++--
 debugfs.ocfs2/dump.c         |   19 +++++++++++++------
 debugfs.ocfs2/include/dump.h |    3 ++-
 debugfs.ocfs2/utils.c        |    4 ++++
 libocfs2/include/ocfs2.h     |    1 +
 5 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/debugfs.ocfs2/commands.c b/debugfs.ocfs2/commands.c
index 25cfe7d..7752349 100644
--- a/debugfs.ocfs2/commands.c
+++ b/debugfs.ocfs2/commands.c
@@ -1201,19 +1201,23 @@ static void do_slotmap (char **args)
 {
 	FILE *out;
 	errcode_t ret;
+        struct ocfs2_slot_map_extended *se = NULL;
         struct ocfs2_slot_map *sm = NULL;
 
 	if (check_device_open())
 		return ;
 
-	ret = ocfs2_read_slot_map(gbls.fs, &sm);
+	if (ocfs2_uses_extended_slot_map(OCFS2_RAW_SB(gbls.fs->fs_super)))
+		ret = ocfs2_read_slot_map_extended(gbls.fs, &se);
+	else
+		ret = ocfs2_read_slot_map(gbls.fs, &sm);
 	if (ret) {
 		com_err(args[0], ret, "while reading slotmap system file");
 		goto bail;
 	}
 
 	out = open_pager(gbls.interactive);
-	dump_slots (out, sm, OCFS2_RAW_SB(gbls.fs->fs_super)->s_max_slots);
+	dump_slots (out, se, sm, OCFS2_RAW_SB(gbls.fs->fs_super)->s_max_slots);
 	close_pager (out);
 
 bail:
diff --git a/debugfs.ocfs2/dump.c b/debugfs.ocfs2/dump.c
index 2f0b780..78b4a1d 100644
--- a/debugfs.ocfs2/dump.c
+++ b/debugfs.ocfs2/dump.c
@@ -605,20 +605,27 @@ void dump_jbd_unknown (FILE *out, uint64_t start, uint64_t end)
  * dump_slots()
  *
  */
-void dump_slots (FILE *out, struct ocfs2_slot_map *sm, int num_slots)
+void dump_slots (FILE *out, struct ocfs2_slot_map_extended *se,
+                 struct ocfs2_slot_map *sm, int num_slots)
 {
 	int i;
+        unsigned int node_num;
 	
 	fprintf (out, "\t%5s   %5s\n", "Slot#", "Node#");
 	
 	for (i = 0; i < num_slots; ++i) {
-		if (sm->sm_slots[i] == (uint16_t)OCFS2_INVALID_SLOT)
-			continue;
+		if (se) {
+			if (!se->se_slots[i].es_valid)
+				continue;
+			node_num = se->se_slots[i].es_node_num;
+		} else {
+			if (sm->sm_slots[i] == (uint16_t)OCFS2_INVALID_SLOT)
+				continue;
+			node_num = sm->sm_slots[i];
+		}
 
-		fprintf (out, "\t%5d   %5u\n", i, sm->sm_slots[i]);
+		fprintf (out, "\t%5d   %5u\n", i, node_num);
 	}
-
-	return ;
 }
 
 void dump_hb (FILE *out, char *buf, uint32_t len)
diff --git a/debugfs.ocfs2/include/dump.h b/debugfs.ocfs2/include/dump.h
index a094b7c..5310d36 100644
--- a/debugfs.ocfs2/include/dump.h
+++ b/debugfs.ocfs2/include/dump.h
@@ -48,7 +48,8 @@ void dump_jbd_superblock (FILE *out, journal_superblock_t *jsb);
 void dump_jbd_block (FILE *out, journal_header_t *header, uint64_t blknum);
 void dump_jbd_metadata (FILE *out, int type, char *buf, uint64_t blknum);
 void dump_jbd_unknown (FILE *out, uint64_t start, uint64_t end);
-void dump_slots (FILE *out, struct ocfs2_slot_map *sm, int num_slots);
+void dump_slots (FILE *out, struct ocfs2_slot_map_extended *se,
+                 struct ocfs2_slot_map *sm, int num_slots);
 void dump_fast_symlink (FILE *out, char *link);
 void dump_hb (FILE *out, char *buf, uint32_t len);
 void dump_inode_path (FILE *out, uint64_t blkno, char *path);
diff --git a/debugfs.ocfs2/utils.c b/debugfs.ocfs2/utils.c
index 7d91bb4..aafa5b4 100644
--- a/debugfs.ocfs2/utils.c
+++ b/debugfs.ocfs2/utils.c
@@ -42,6 +42,9 @@ void get_incompat_flag(uint32_t flag, GString *str)
 	if (flag & OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC)
 		g_string_append(str, "Sparse ");
 
+	if (flag & OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP)
+		g_string_append(str, "ExtendedSlotMap ");
+
 	if (flag & OCFS2_FEATURE_INCOMPAT_TUNEFS_INPROG) {
 		g_string_append(str, "AbortedTunefs ");
 	}
@@ -50,6 +53,7 @@ void get_incompat_flag(uint32_t flag, GString *str)
 		     OCFS2_FEATURE_INCOMPAT_RESIZE_INPROG |
 		     OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT |
 		     OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC |
+		     OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP |
 		     OCFS2_FEATURE_INCOMPAT_TUNEFS_INPROG))
 		g_string_append(str, "Unknown ");
 
diff --git a/libocfs2/include/ocfs2.h b/libocfs2/include/ocfs2.h
index 8b24318..47a1772 100644
--- a/libocfs2/include/ocfs2.h
+++ b/libocfs2/include/ocfs2.h
@@ -94,6 +94,7 @@
 #define OCFS2_FEATURE_INCOMPAT_RESIZE_INPROG_STR	"AbortedResize"
 #define OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT_STR		"Local"
 #define OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC_STR		"SparseAlloc"
+#define OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP_STR	"ExtendedSlotMap"
 #define OCFS2_FEATURE_INCOMPAT_TUNEFS_INPROG_STR	"TunefsAbort"
 #define OCFS2_FEATURE_COMPAT_BACKUP_SB_STR		"BackupSuper"
 #define OCFS2_FEATURE_RO_COMPAT_UNWRITTEN_STR		"UnwrittenExtents"
-- 
1.5.2.2




More information about the Ocfs2-tools-devel mailing list