Skip to contentSkip to conversation

xfs_db: modify bad_features2 when modifying features2

PATCH In review Eric Sandeen 2 participants 4 messages Dec 1, 2009 – Dec 2, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs_db: modify bad_features2 when modifying features2

The "attr1" command in xfs_db, for example, only modifies the features2 field; when mounted, the kernel will find a mismatch between features2 and bad_features2, and attr2 gets turned back on.

I think the simplest fix is to modify do_version to modify both fields, but not if there is an existing mismatch that should be investigated first.

---

db/sb.c +8 -1
index 7c61b15..961a939 100644
@@ -556,6 +556,12 @@ do_version(xfs_agnumber_t agno, __uint16_t version, __uint32_t features)
 	if (!get_sb(agno, &tsb))
 		return 0;
 
+	if (xfs_sb_has_mismatched_features2(&tsb)) {
+		dbprintf(_("Superblock has mismatched features2 fields, "
+			   "skipping modification\n"));
+		return 0;
+	}
+
 	if ((version & XFS_SB_VERSION_LOGV2BIT) &&
 					!xfs_sb_version_haslogv2(&tsb)) {
 		tsb.sb_logsunit = 1;
@@ -564,7 +570,8 @@ do_version(xfs_agnumber_t agno, __uint16_t version, __uint32_t features)
 
 	tsb.sb_versionnum = version;
 	tsb.sb_features2 = features;
-	fields |= XFS_SB_VERSIONNUM | XFS_SB_FEATURES2;
+	tsb.sb_bad_features2 = features;
+	fields |= XFS_SB_VERSIONNUM | XFS_SB_FEATURES2 | XFS_SB_BAD_FEATURES2;
 	libxfs_sb_to_disk(iocur_top->data, &tsb, fields);
 	write_cur();
 	return 1;

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#1 lore raw

db/sb.c do_version(xfs_agnumber_t agno, __uint16_t version, __uint32_t features) · line 563

Quoted 5 lines · Eric Sandeen
db/sb.c +5 -0
+	if (xfs_sb_has_mismatched_features2(&tsb)) {
+		dbprintf(_("Superblock has mismatched features2 fields, "
+			   "skipping modification\n"));
+		return 0;
+	}

However I'm not sure if this one is an all that good idea. It'll make all version updates fail if we have a mismatched features2. That way people can't use xfs_db to fix it up which seems odd.

To me just printing the warning but not aborting would be the best way to inform the user about it.

db/sb.c do_version(xfs_agnumber_t agno, __uint16_t version, __uint32_t features) · line 574

Quoted 11 lines
db/sb.c +3 -1
+
 	if ((version & XFS_SB_VERSION_LOGV2BIT) &&
 					!xfs_sb_version_haslogv2(&tsb)) {
 		tsb.sb_logsunit = 1;
@@ -564,7 +570,8 @@ do_version(xfs_agnumber_t agno, __uint16_t version, __uint32_t features)
 
 	tsb.sb_versionnum = version;
 	tsb.sb_features2 = features;
-	fields |= XFS_SB_VERSIONNUM | XFS_SB_FEATURES2;
+	tsb.sb_bad_features2 = features;
+	fields |= XFS_SB_VERSIONNUM | XFS_SB_FEATURES2 | XFS_SB_BAD_FEATURES2;

This one looks good to me.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#2 lore raw
Quoted 11 lines · Christoph Hellwig

db/sb.c do_version(xfs_agnumber_t agno, __uint16_t version, __uint32_t features) · line 563

Quoted 5 lines · Eric Sandeen
db/sb.c +5 -0
+	if (xfs_sb_has_mismatched_features2(&tsb)) {
+		dbprintf(_("Superblock has mismatched features2 fields, "
+			   "skipping modification\n"));
+		return 0;
+	}

However I'm not sure if this one is an all that good idea. It'll make all version updates fail if we have a mismatched features2. That way people can't use xfs_db to fix it up which seems odd.

Quoted 2 lines

To me just printing the warning but not aborting would be the best way to inform the user about it.

hm yeah I suppose so.

I wonder if we should catch it somehow on the feature-set shortcuts like "attr1" but allow it for explicit value sets ...

?

-Eric

Quoted 7 lines
Quoted 7 lines
db/sb.c +1 -0
+
 	if ((version & XFS_SB_VERSION_LOGV2BIT) &&
 					!xfs_sb_version_haslogv2(&tsb)) {
 		tsb.sb_logsunit = 1;
@@ -564,7 +570,8 @@ do_version(xfs_agnumber_t agno, __uint16_t version, __uint32_t features)
 
Quoted 8 lines

db/sb.c do_version(xfs_agnumber_t agno, __uint16_t version, __uint32_t features) · line 574

Quoted 5 lines
db/sb.c +2 -1
 	tsb.sb_versionnum = version;
 	tsb.sb_features2 = features;
-	fields |= XFS_SB_VERSIONNUM | XFS_SB_FEATURES2;
+	tsb.sb_bad_features2 = features;
+	fields |= XFS_SB_VERSIONNUM | XFS_SB_FEATURES2 | XFS_SB_BAD_FEATURES2;

This one looks good to me.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#3 lore raw
Quoted 11 lines · Eric Sandeen
Quoted 10 lines · Christoph Hellwig

db/sb.c do_version(xfs_agnumber_t agno, __uint16_t version, __uint32_t features) · line 563

Quoted 5 lines · Eric Sandeen
db/sb.c +5 -0
+	if (xfs_sb_has_mismatched_features2(&tsb)) {
+		dbprintf(_("Superblock has mismatched features2 fields, "
+			   "skipping modification\n"));
+		return 0;
+	}

However I'm not sure if this one is an all that good idea. It'll make all version updates fail if we have a mismatched features2. That way people can't use xfs_db to fix it up which seems odd.

Quoted 7 lines
Quoted 2 lines

To me just printing the warning but not aborting would be the best way to inform the user about it.

hm yeah I suppose so.

I wonder if we should catch it somehow on the feature-set shortcuts like "attr1" but allow it for explicit value sets ...

actually:

"version" prints version
"version <featurename>" adds that feature
"version <value> <value>" prints the names for the values but doesn't change anything

... so you can still modify mismatched values by writing to the superblocks directly although that's a little tedious. But that shouldn't really happen too often.

I'm just wary of automatically overwriting the mismatch w/o errors... it seems like some intervention might be necessary.

Or, since the kernel does this already (fixes up mismatches) maybe we should just put the same algorithms into xfs_db but that's getting tricky. :)

Maybe for a later date ...

-Eric

Quoted 18 lines

?

-Eric

Quoted 6 lines
Quoted 6 lines
db/sb.c +1 -0
+
 	if ((version & XFS_SB_VERSION_LOGV2BIT) &&
 					!xfs_sb_version_haslogv2(&tsb)) {
 		tsb.sb_logsunit = 1;
@@ -564,7 +570,8 @@ do_version(xfs_agnumber_t agno, __uint16_t version, __uint32_t features)
 
Quoted 7 lines

db/sb.c do_version(xfs_agnumber_t agno, __uint16_t version, __uint32_t features) · line 574

Quoted 5 lines
db/sb.c +2 -1
 	tsb.sb_versionnum = version;
 	tsb.sb_features2 = features;
-	fields |= XFS_SB_VERSIONNUM | XFS_SB_FEATURES2;
+	tsb.sb_bad_features2 = features;
+	fields |= XFS_SB_VERSIONNUM | XFS_SB_FEATURES2 | XFS_SB_BAD_FEATURES2;

This one looks good to me.

Quoted 5 lines

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs