Skip to contentSkip to conversation

gfs2-utils: Remove references to unlinked file tag

PATCH New Andrew Price 2 participants 6 messages May 25, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 gfs2-utils: Remove references to unlinked file tag

Remove references to an obsolete unlinked tag file (or file tag).

---
 gfs2/libgfs2/libgfs2.h |    1 -
 gfs2/man/gfs2_jadd.8   |    3 ---
 gfs2/man/mkfs.gfs2.8   |    3 ---
 gfs2/mkfs/main_mkfs.c  |    5 +----
 4 files changed, 1 insertions(+), 11 deletions(-)
gfs2/libgfs2/libgfs2.h +0 -1
index e2a7e45..8ed08dd 100644
@@ -255,7 +255,6 @@ struct gfs2_sbd {
 	unsigned int bsize;	     /* The block size of the FS (in bytes) */
 	unsigned int jsize;	     /* Size of journals (in MB) */
 	unsigned int rgsize;     /* Size of resource groups (in MB) */
-	unsigned int utsize;     /* Size of unlinked tag files (in MB) */
 	unsigned int qcsize;     /* Size of quota change files (in MB) */
 
 	int debug;
gfs2/man/gfs2_jadd.8 +0 -3
index a645fb7..5453edd 100644
@@ -50,9 +50,6 @@ The number of new journals to add.
 \fB-q\fP
 Be quiet.  Don't print anything.
 .TP
-\fB-u MegaBytes\fP
-Initial size of each journal's unlinked tag file
-.TP
 \fB-V\fP
 Version. Print version information, then exit.
 .
gfs2/man/mkfs.gfs2.8 +0 -3
index 63348f8..d17e272 100644
@@ -75,9 +75,6 @@ Fsname is a unique file system name used to distinguish this GFS2 file
 system from others created (1 to 16 characters).  Lock_nolock doesn't
 use this field.
 .TP
-\fB-u\fP \fIMegaBytes\fR
-Initial size of each journal's unlinked tag file
-.TP
 \fB-V\fP
 Print program version information, then exit.
 
gfs2/mkfs/main_mkfs.c +1 -4
index 7c93621..e6b00a0 100644
@@ -109,7 +109,7 @@ static void decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)
 	sdp->orig_fssize = 0;
 
 	while (cont) {
-		optchar = getopt(argc, argv, "-b:c:DhJ:j:KOp:qr:t:u:VX");
+		optchar = getopt(argc, argv, "-b:c:DhJ:j:KOp:qr:t:VX");
 
 		switch (optchar) {
 		case 'b':
@@ -166,9 +166,6 @@ static void decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)
 			strcpy(sdp->locktable, optarg);
 			break;
 
-		case 'u':
-			break;
-
 		case 'V':
 			printf("gfs2_mkfs %s (built %s %s)\n", VERSION,
 			       __DATE__, __TIME__);
Signature · 1 line
1.7.7.6
#1 lore raw

PATCH 2/3 gfs2_edit: Fix find_mtype and support gfs1 structures

Fixes up find_mtype to really iterate over the metadata array and to choose between gfs2 and gfs1 structures.

---
 gfs2/edit/hexedit.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
gfs2/edit/hexedit.c +5 -4
index 69d1940..8311534 100644
@@ -813,14 +813,15 @@ int display_block_type(int from_restore)
 	return ret_type;
 }
 
-static const struct lgfs2_metadata *find_mtype(uint32_t mtype)
+static const struct lgfs2_metadata *find_mtype(uint32_t mtype, int gfs1)
 {
 	const struct lgfs2_metadata *m = lgfs2_metadata;
 	unsigned n = 0;
 
 	do {
-		if (m->gfs2 && m->mh_type == mtype)
-			return m;
+		if (((gfs1 && m[n].gfs1) || (!gfs1 && m[n].gfs2))
+		                         && m[n].mh_type == mtype)
+			return &m[n];
 		n++;
 	} while (n < lgfs2_metadata_size);
 
@@ -934,7 +935,7 @@ static int hexdump(uint64_t startaddr, int len)
 		}
 		print_gfs2("] ");
 		if (print_field >= 0) {
-			const struct lgfs2_metadata *m = find_mtype(get_block_type(bh));
+			const struct lgfs2_metadata *m = find_mtype(get_block_type(bh), sbd.gfs1);
 			if (m) {
 				const struct lgfs2_metafield *f;
 				unsigned n;
Signature · 1 line
1.7.7.6
#2 lore raw

PATCH 2/3 gfs2_edit: Fix find_mtype and support gfs1 structures

Quoted 16 lines · Andrew Price

Fixes up find_mtype to really iterate over the metadata array and to choose between gfs2 and gfs1 structures.

---
  gfs2/edit/hexedit.c |    9 +++++----
  1 files changed, 5 insertions(+), 4 deletions(-)
gfs2/edit/hexedit.c +0 -0
index 69d1940..8311534 100644
@@ -813,14 +813,15 @@ int display_block_type(int from_restore)
  	return ret_type;
  }
 

gfs2/edit/hexedit.c int display_block_type(int from_restore) · line 822

Quoted 10 lines
gfs2/edit/hexedit.c +2 -3
-static const struct lgfs2_metadata *find_mtype(uint32_t mtype)
+static const struct lgfs2_metadata *find_mtype(uint32_t mtype, int gfs1)
  {
  	const struct lgfs2_metadata *m = lgfs2_metadata;
  	unsigned n = 0;
 
  	do {
-		if (m->gfs2&&  m->mh_type == mtype)
-			return m;
+		if (((gfs1&&  m[n].gfs1) || (!gfs1&&  m[n].gfs2))

I'm wondering if we should represent the version metadata as flags instead of separate gfs1 and gfs2 fields and define some constants so we can do the comparison in one go, e.g.

                 if ((m[n].versions & versions) ...

Where versions is some combination of defined constants passed into the function like LGFS2_VER_1 | LGFS2_VER_2

But that has its own drawbacks I guess so I'm probably just splitting hairs. What do you think?

Andy

Quoted 14 lines
gfs2/edit/hexedit.c +3 -1
+		&&  m[n].mh_type == mtype)
+			return&m[n];
  		n++;
  	} while (n<  lgfs2_metadata_size);
 
@@ -934,7 +935,7 @@ static int hexdump(uint64_t startaddr, int len)
  		}
  		print_gfs2("] ");
  		if (print_field>= 0) {
-			const struct lgfs2_metadata *m = find_mtype(get_block_type(bh));
+			const struct lgfs2_metadata *m = find_mtype(get_block_type(bh), sbd.gfs1);
  			if (m) {
  				const struct lgfs2_metafield *f;
  				unsigned n;
#3 lore raw

PATCH 2/3 gfs2_edit: Fix find_mtype and support gfs1 structures

Hi,

Quoted 34 lines · Andrew Price
Quoted 16 lines · Andrew Price

Fixes up find_mtype to really iterate over the metadata array and to choose between gfs2 and gfs1 structures.

---
  gfs2/edit/hexedit.c |    9 +++++----
  1 files changed, 5 insertions(+), 4 deletions(-)
gfs2/edit/hexedit.c +0 -0
index 69d1940..8311534 100644
@@ -813,14 +813,15 @@ int display_block_type(int from_restore)
  	return ret_type;
  }
 

gfs2/edit/hexedit.c int display_block_type(int from_restore) · line 822

Quoted 10 lines
gfs2/edit/hexedit.c +2 -3
-static const struct lgfs2_metadata *find_mtype(uint32_t mtype)
+static const struct lgfs2_metadata *find_mtype(uint32_t mtype, int gfs1)
  {
  	const struct lgfs2_metadata *m = lgfs2_metadata;
  	unsigned n = 0;
 
  	do {
-		if (m->gfs2&&  m->mh_type == mtype)
-			return m;
+		if (((gfs1&&  m[n].gfs1) || (!gfs1&&  m[n].gfs2))

I'm wondering if we should represent the version metadata as flags instead of separate gfs1 and gfs2 fields and define some constants so we can do the comparison in one go, e.g.

                 if ((m[n].versions & versions) ...
Quoted 8 lines

Where versions is some combination of defined constants passed into the function like LGFS2_VER_1 | LGFS2_VER_2

But that has its own drawbacks I guess so I'm probably just splitting hairs. What do you think?

Andy

I think that makes sense. I don't remember now why I did that with a bitfield and not flags, but it is probably better to convert it to flags. We'll want to give them a longer name though, as everything in the library will land up with a LGFS2_ or lgfs2_ prefix in the end,

Steve.

#4 lore raw

PATCH 3/3 gfs2_edit: Clean up some magic offsets

In reply to Andrew Price

Replace some uses of magic offsets with equivalent struct member accesses.

---
 gfs2/edit/hexedit.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
gfs2/edit/hexedit.c +5 -4
index 8311534..b4e6d15 100644
@@ -838,6 +838,7 @@ static int hexdump(uint64_t startaddr, int len)
 	uint64_t l;
 	const char *lpBuffer = bh->b_data;
 	int print_field, cursor_line;
+	const uint32_t block_type = get_block_type(bh);
 
 	strcpy(edit_fmt,"%02x");
 	pointer = (unsigned char *)lpBuffer + offset;
@@ -935,7 +936,7 @@ static int hexdump(uint64_t startaddr, int len)
 		}
 		print_gfs2("] ");
 		if (print_field >= 0) {
-			const struct lgfs2_metadata *m = find_mtype(get_block_type(bh), sbd.gfs1);
+			const struct lgfs2_metadata *m = find_mtype(block_type, sbd.gfs1);
 			if (m) {
 				const struct lgfs2_metafield *f;
 				unsigned n;
@@ -951,9 +952,9 @@ static int hexdump(uint64_t startaddr, int len)
 
 		}
 		if (cursor_line) {
-			if (((*(bh->b_data + 7) == GFS2_METATYPE_IN) ||
-			   (*(bh->b_data + 7) == GFS2_METATYPE_DI &&
-			    (*(bh->b_data + 0x8b) || *(bh->b_data + 0x8a))))) {
+			if (block_type == GFS2_METATYPE_IN ||
+			    ((block_type == GFS2_METATYPE_DI) &&
+			     ((struct gfs2_dinode*)bh->b_data)->di_height)) {
 				int ptroffset = edit_row[dmode] * 16 +
 					edit_col[dmode];
 
Signature · 1 line
1.7.7.6
#5 lore raw

PATCH 3/3 gfs2_edit: Clean up some magic offsets

Hi,

Those all look ok to me,

Steve.

Quoted 42 lines · Andrew Price

Replace some uses of magic offsets with equivalent struct member accesses.

---
 gfs2/edit/hexedit.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
gfs2/edit/hexedit.c +5 -4
index 8311534..b4e6d15 100644
@@ -838,6 +838,7 @@ static int hexdump(uint64_t startaddr, int len)
 	uint64_t l;
 	const char *lpBuffer = bh->b_data;
 	int print_field, cursor_line;
+	const uint32_t block_type = get_block_type(bh);
 
 	strcpy(edit_fmt,"%02x");
 	pointer = (unsigned char *)lpBuffer + offset;
@@ -935,7 +936,7 @@ static int hexdump(uint64_t startaddr, int len)
 		}
 		print_gfs2("] ");
 		if (print_field >= 0) {
-			const struct lgfs2_metadata *m = find_mtype(get_block_type(bh), sbd.gfs1);
+			const struct lgfs2_metadata *m = find_mtype(block_type, sbd.gfs1);
 			if (m) {
 				const struct lgfs2_metafield *f;
 				unsigned n;
@@ -951,9 +952,9 @@ static int hexdump(uint64_t startaddr, int len)
 
 		}
 		if (cursor_line) {
-			if (((*(bh->b_data + 7) == GFS2_METATYPE_IN) ||
-			   (*(bh->b_data + 7) == GFS2_METATYPE_DI &&
-			    (*(bh->b_data + 0x8b) || *(bh->b_data + 0x8a))))) {
+			if (block_type == GFS2_METATYPE_IN ||
+			    ((block_type == GFS2_METATYPE_DI) &&
+			     ((struct gfs2_dinode*)bh->b_data)->di_height)) {
 				int ptroffset = edit_row[dmode] * 16 +
 					edit_col[dmode];