Skip to contentSkip to conversation

xfs: Keep sb_bad_features2 consistent with sb_features2

PATCH In review Jan Kara 2 participants 4 messages Dec 17, 2014 – Dec 23, 2014 XFS filesystem

lore
Share & tools
lore

Jan Kara

author
#0 lore raw

PATCH 1/1 xfs: Keep sb_bad_features2 consistent with sb_features2

Currently when we modify sb_features2, we store the same value also in sb_bad_features2. However in most places we forget to mark field sb_bad_features2 for logging and thus it can happen that a change to it is lost. This results in an inconsistent sb_features2 and sb_bad_features2 fields e.g. after xfstests test xfs/187.

Fix the problem by changing XFS_SB_FEATURES2 to actually mean both sb_features2 and sb_bad_features2 fields since this is always what we want to log. This isn't ideal because the fact that XFS_SB_FEATURES2 means two fields could cause some problem in future however the code is hopefully less error prone that it is now.

---
 fs/xfs/libxfs/xfs_format.h | 10 +++++-----
 fs/xfs/xfs_mount.c         |  5 ++---
 2 files changed, 7 insertions(+), 8 deletions(-)
fs/xfs/libxfs/xfs_format.h +5 -5
index fbd6da263571..476273287aaf 100644
@@ -304,8 +304,8 @@ typedef enum {
 #define XFS_SB_ICOUNT		XFS_SB_MVAL(ICOUNT)
 #define XFS_SB_IFREE		XFS_SB_MVAL(IFREE)
 #define XFS_SB_FDBLOCKS		XFS_SB_MVAL(FDBLOCKS)
-#define XFS_SB_FEATURES2	XFS_SB_MVAL(FEATURES2)
-#define XFS_SB_BAD_FEATURES2	XFS_SB_MVAL(BAD_FEATURES2)
+#define XFS_SB_FEATURES2	(XFS_SB_MVAL(FEATURES2) | \
+				 XFS_SB_MVAL(BAD_FEATURES2))
 #define XFS_SB_FEATURES_COMPAT	XFS_SB_MVAL(FEATURES_COMPAT)
 #define XFS_SB_FEATURES_RO_COMPAT XFS_SB_MVAL(FEATURES_RO_COMPAT)
 #define XFS_SB_FEATURES_INCOMPAT XFS_SB_MVAL(FEATURES_INCOMPAT)
@@ -319,9 +319,9 @@ typedef enum {
 	 XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO | XFS_SB_GQUOTINO | \
 	 XFS_SB_QFLAGS | XFS_SB_SHARED_VN | XFS_SB_UNIT | XFS_SB_WIDTH | \
 	 XFS_SB_ICOUNT | XFS_SB_IFREE | XFS_SB_FDBLOCKS | XFS_SB_FEATURES2 | \
-	 XFS_SB_BAD_FEATURES2 | XFS_SB_FEATURES_COMPAT | \
-	 XFS_SB_FEATURES_RO_COMPAT | XFS_SB_FEATURES_INCOMPAT | \
-	 XFS_SB_FEATURES_LOG_INCOMPAT | XFS_SB_PQUOTINO)
+	 XFS_SB_FEATURES_COMPAT | XFS_SB_FEATURES_RO_COMPAT | \
+	 XFS_SB_FEATURES_INCOMPAT | XFS_SB_FEATURES_LOG_INCOMPAT | \
+	 XFS_SB_PQUOTINO)
 
 
 /*
fs/xfs/xfs_mount.c +2 -3
index d3d38836f87f..71d2c97cf58a 100644
@@ -678,7 +678,7 @@ xfs_mountfs(
 		xfs_warn(mp, "correcting sb_features alignment problem");
 		sbp->sb_features2 |= sbp->sb_bad_features2;
 		sbp->sb_bad_features2 = sbp->sb_features2;
-		mp->m_update_flags |= XFS_SB_FEATURES2 | XFS_SB_BAD_FEATURES2;
+		mp->m_update_flags |= XFS_SB_FEATURES2;
 
 		/*
 		 * Re-check for ATTR2 in case it was found in bad_features2
@@ -1436,8 +1436,7 @@ xfs_mount_log_sb(
 	int		error;
 
 	ASSERT(fields & (XFS_SB_UNIT | XFS_SB_WIDTH | XFS_SB_UUID |
-			 XFS_SB_FEATURES2 | XFS_SB_BAD_FEATURES2 |
-			 XFS_SB_VERSIONNUM));
+			 XFS_SB_FEATURES2 | XFS_SB_VERSIONNUM));
 
 	tp = xfs_trans_alloc(mp, XFS_TRANS_SB_UNIT);
 	error = xfs_trans_reserve(tp, &M_RES(mp)->tr_sb, 0, 0);
Signature · 6 lines
1.8.4.5

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#1 lore raw
Quoted 11 lines · Jan Kara

Currently when we modify sb_features2, we store the same value also in sb_bad_features2. However in most places we forget to mark field sb_bad_features2 for logging and thus it can happen that a change to it is lost. This results in an inconsistent sb_features2 and sb_bad_features2 fields e.g. after xfstests test xfs/187.

Fix the problem by changing XFS_SB_FEATURES2 to actually mean both sb_features2 and sb_bad_features2 fields since this is always what we want to log. This isn't ideal because the fact that XFS_SB_FEATURES2 means two fields could cause some problem in future however the code is hopefully less error prone that it is now.

Actually, I have patches that fix this differently that I'm planning to push for the 3.20 cycle. They get rid of the "update random SB fields" problem altogether simply by logging and updating the entire SB every time.

http://oss.sgi.com/archives/xfs/2014-09/msg00448.html

Quoted 11 lines
---
 fs/xfs/libxfs/xfs_format.h | 10 +++++-----
 fs/xfs/xfs_mount.c         |  5 ++---
 2 files changed, 7 insertions(+), 8 deletions(-)
fs/xfs/libxfs/xfs_format.h +0 -0
index fbd6da263571..476273287aaf 100644

fs/xfs/libxfs/xfs_format.h typedef enum { · line 308

Quoted 7 lines
fs/xfs/libxfs/xfs_format.h +2 -2
@@ -304,8 +304,8 @@ typedef enum {
 #define XFS_SB_ICOUNT		XFS_SB_MVAL(ICOUNT)
 #define XFS_SB_IFREE		XFS_SB_MVAL(IFREE)
 #define XFS_SB_FDBLOCKS		XFS_SB_MVAL(FDBLOCKS)
-#define XFS_SB_FEATURES2	XFS_SB_MVAL(FEATURES2)
-#define XFS_SB_BAD_FEATURES2	XFS_SB_MVAL(BAD_FEATURES2)
+#define XFS_SB_FEATURES2	(XFS_SB_MVAL(FEATURES2) | \
+				 XFS_SB_MVAL(BAD_FEATURES2))

That doesn't guarantee that both fields are updated together, just that the'll get logged and written together. The code still has to ensure both fields are updated beforehand. I have a patch to address this as well, and will post them soon.

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
author
#2 lore raw
Quoted 13 lines · Dave Chinner
Quoted 11 lines · Jan Kara

Currently when we modify sb_features2, we store the same value also in sb_bad_features2. However in most places we forget to mark field sb_bad_features2 for logging and thus it can happen that a change to it is lost. This results in an inconsistent sb_features2 and sb_bad_features2 fields e.g. after xfstests test xfs/187.

Fix the problem by changing XFS_SB_FEATURES2 to actually mean both sb_features2 and sb_bad_features2 fields since this is always what we want to log. This isn't ideal because the fact that XFS_SB_FEATURES2 means two fields could cause some problem in future however the code is hopefully less error prone that it is now.

Quoted 6 lines

Actually, I have patches that fix this differently that I'm planning to push for the 3.20 cycle. They get rid of the "update random SB fields" problem altogether simply by logging and updating the entire SB every time.

http://oss.sgi.com/archives/xfs/2014-09/msg00448.html

OK, thanks for info.

Honza

Quoted 31 lines
Quoted 12 lines
---
 fs/xfs/libxfs/xfs_format.h | 10 +++++-----
 fs/xfs/xfs_mount.c         |  5 ++---
 2 files changed, 7 insertions(+), 8 deletions(-)
fs/xfs/libxfs/xfs_format.h +0 -0
index fbd6da263571..476273287aaf 100644

fs/xfs/libxfs/xfs_format.h typedef enum { · line 308

Quoted 7 lines
fs/xfs/libxfs/xfs_format.h +2 -2
@@ -304,8 +304,8 @@ typedef enum {
 #define XFS_SB_ICOUNT		XFS_SB_MVAL(ICOUNT)
 #define XFS_SB_IFREE		XFS_SB_MVAL(IFREE)
 #define XFS_SB_FDBLOCKS		XFS_SB_MVAL(FDBLOCKS)
-#define XFS_SB_FEATURES2	XFS_SB_MVAL(FEATURES2)
-#define XFS_SB_BAD_FEATURES2	XFS_SB_MVAL(BAD_FEATURES2)
+#define XFS_SB_FEATURES2	(XFS_SB_MVAL(FEATURES2) | \
+				 XFS_SB_MVAL(BAD_FEATURES2))

That doesn't guarantee that both fields are updated together, just that the'll get logged and written together. The code still has to ensure both fields are updated beforehand. I have a patch to address this as well, and will post them soon.

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
Signature · 7 lines
Jan Kara <[email protected]>
SUSE Labs, CR

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#3 lore raw
Quoted 14 lines · Jan Kara
Quoted 13 lines · Dave Chinner
Quoted 11 lines · Jan Kara

Currently when we modify sb_features2, we store the same value also in sb_bad_features2. However in most places we forget to mark field sb_bad_features2 for logging and thus it can happen that a change to it is lost. This results in an inconsistent sb_features2 and sb_bad_features2 fields e.g. after xfstests test xfs/187.

Fix the problem by changing XFS_SB_FEATURES2 to actually mean both sb_features2 and sb_bad_features2 fields since this is always what we want to log. This isn't ideal because the fact that XFS_SB_FEATURES2 means two fields could cause some problem in future however the code is hopefully less error prone that it is now.

Quoted 7 lines
Quoted 6 lines

Actually, I have patches that fix this differently that I'm planning to push for the 3.20 cycle. They get rid of the "update random SB fields" problem altogether simply by logging and updating the entire SB every time.

http://oss.sgi.com/archives/xfs/2014-09/msg00448.html

OK, thanks for info.

FWIW, I'll pull the fixes you have posted and rebase the rework I have on top of them. That way we have fixes that can be backported easily without pulling the entire rework in the commit history.

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

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