* [PATCH] combined features2 fixup patches (updating/rewriting what was sent in other threads)
@ 2008-03-31 3:03 Eric Sandeen
2008-04-02 0:29 ` David Chinner
0 siblings, 1 reply; 3+ messages in thread
From: Eric Sandeen @ 2008-03-31 3:03 UTC (permalink / raw)
To: xfs-oss
Ensure "both" features2 slots are consistent, and set mp attr2 flag.
Since older kernels may look in the sb_bad_features2 slot for
flags, rather than zeroing it out on fixup, we should make it
equal to the sb_features2 value.
Also, if the ATTR2 flag was not found prior to features2
fixup, it was not set in the mount flags, so re-check after the
fixup so that the current session will use the feature.
Also fix up the comments to reflect these changes.
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
---
Index: linux-2.6-xfs/fs/xfs/xfs_mount.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/xfs_mount.c
+++ linux-2.6-xfs/fs/xfs/xfs_mount.c
@@ -967,22 +967,26 @@ xfs_mountfs(
xfs_mount_common(mp, sbp);
/*
- * Check for a bad features2 field alignment. This happened on
- * some platforms due to xfs_sb_t not being 64bit size aligned
- * when sb_features was added and hence the compiler put it in
- * the wrong place.
+ * Check for a mismatched features2 values. Older kernels
+ * read & wrote into the wrong sb offset for sb_features2
+ * on some platforms due to xfs_sb_t not being 64bit size aligned
+ * when sb_features2 was added, which made older superblock
+ * reading/writing routines swap it as a 64-bit value.
*
- * If we detect a bad field, we or the set bits into the existing
- * features2 field in case it has already been modified and we
- * don't want to lose any features. Zero the bad one and mark
- * the two fields as needing updates once the transaction subsystem
- * is online.
+ * For backwards compatibility, we make both slots equal.
+ *
+ * If we detect a mismatched field, we OR the set bits into the
+ * existing features2 field in case it has already been modified; we
+ * don't want to lose any features. We then update the bad location
+ * with the ORed value so that older kernels will see any features2
+ * flags, and mark the two fields as needing updates once the
+ * transaction subsystem is online.
*/
- if (xfs_sb_has_bad_features2(sbp)) {
+ if (xfs_sb_has_mismatched_features2(sbp)) {
cmn_err(CE_WARN,
"XFS: correcting sb_features alignment problem");
sbp->sb_features2 |= sbp->sb_bad_features2;
- sbp->sb_bad_features2 = 0;
+ sbp->sb_bad_features2 = sbp->sb_features2;
update_flags |= XFS_SB_FEATURES2 | XFS_SB_BAD_FEATURES2;
}
@@ -1181,6 +1185,12 @@ xfs_mountfs(
xfs_mount_log_sb(mp, update_flags);
/*
+ * Re-check for ATTR2 in case it was found in bad_features2 slot.
+ */
+ if (xfs_sb_version_hasattr2(&mp->m_sb))
+ mp->m_flags |= XFS_MOUNT_ATTR2;
+
+ /*
* Initialise the XFS quota management subsystem for this mount
*/
error = XFS_QM_INIT(mp, "amount, "aflags);
@@ -1890,7 +1900,8 @@ xfs_uuid_unmount(
/*
* Used to log changes to the superblock unit and width fields which could
- * be altered by the mount options. Only the first superblock is updated.
+ * be altered by the mount options, as well as any potential sb_features2
+ * fixup. Only the first superblock is updated.
*/
STATIC void
xfs_mount_log_sb(
Index: linux-2.6-xfs/fs/xfs/xfs_sb.h
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/xfs_sb.h
+++ linux-2.6-xfs/fs/xfs/xfs_sb.h
@@ -320,11 +320,12 @@ static inline int xfs_sb_good_version(xf
#endif /* __KERNEL__ */
/*
- * Detect a bad features2 field
+ * Detect a mismatched features2 field. Older kernels read/wrote
+ * this into the wrong slot, so to be safe we keep them in sync.
*/
-static inline int xfs_sb_has_bad_features2(xfs_sb_t *sbp)
+static inline int xfs_sb_has_mismatched_features2(xfs_sb_t *sbp)
{
- return (sbp->sb_bad_features2 != 0);
+ return (sbp->sb_bad_features2 != sbp->sb_features2);
}
static inline unsigned xfs_sb_version_tonew(unsigned v)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] combined features2 fixup patches (updating/rewriting what was sent in other threads)
2008-03-31 3:03 [PATCH] combined features2 fixup patches (updating/rewriting what was sent in other threads) Eric Sandeen
@ 2008-04-02 0:29 ` David Chinner
2008-04-03 1:06 ` [PATCH V2] " Eric Sandeen
0 siblings, 1 reply; 3+ messages in thread
From: David Chinner @ 2008-04-02 0:29 UTC (permalink / raw)
To: Eric Sandeen; +Cc: xfs-oss
On Sun, Mar 30, 2008 at 10:03:08PM -0500, Eric Sandeen wrote:
> Ensure "both" features2 slots are consistent, and set mp attr2 flag.
>
> Since older kernels may look in the sb_bad_features2 slot for
> flags, rather than zeroing it out on fixup, we should make it
> equal to the sb_features2 value.
>
> Also, if the ATTR2 flag was not found prior to features2
> fixup, it was not set in the mount flags, so re-check after the
> fixup so that the current session will use the feature.
>
> Also fix up the comments to reflect these changes.
>
> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
> ---
>
> Index: linux-2.6-xfs/fs/xfs/xfs_mount.c
> ===================================================================
> --- linux-2.6-xfs.orig/fs/xfs/xfs_mount.c
> +++ linux-2.6-xfs/fs/xfs/xfs_mount.c
> @@ -967,22 +967,26 @@ xfs_mountfs(
> xfs_mount_common(mp, sbp);
>
> /*
> - * Check for a bad features2 field alignment. This happened on
> - * some platforms due to xfs_sb_t not being 64bit size aligned
> - * when sb_features was added and hence the compiler put it in
> - * the wrong place.
> + * Check for a mismatched features2 values. Older kernels
> + * read & wrote into the wrong sb offset for sb_features2
> + * on some platforms due to xfs_sb_t not being 64bit size aligned
> + * when sb_features2 was added, which made older superblock
> + * reading/writing routines swap it as a 64-bit value.
> *
> - * If we detect a bad field, we or the set bits into the existing
> - * features2 field in case it has already been modified and we
> - * don't want to lose any features. Zero the bad one and mark
> - * the two fields as needing updates once the transaction subsystem
> - * is online.
> + * For backwards compatibility, we make both slots equal.
> + *
> + * If we detect a mismatched field, we OR the set bits into the
> + * existing features2 field in case it has already been modified; we
> + * don't want to lose any features. We then update the bad location
> + * with the ORed value so that older kernels will see any features2
> + * flags, and mark the two fields as needing updates once the
> + * transaction subsystem is online.
> */
> - if (xfs_sb_has_bad_features2(sbp)) {
> + if (xfs_sb_has_mismatched_features2(sbp)) {
> cmn_err(CE_WARN,
> "XFS: correcting sb_features alignment problem");
> sbp->sb_features2 |= sbp->sb_bad_features2;
> - sbp->sb_bad_features2 = 0;
> + sbp->sb_bad_features2 = sbp->sb_features2;
> update_flags |= XFS_SB_FEATURES2 | XFS_SB_BAD_FEATURES2;
Probably should update XFS_MOUNT_ATTR2 here, not later. i.e. before
we mount he log and start recovery.
> @@ -1181,6 +1185,12 @@ xfs_mountfs(
> xfs_mount_log_sb(mp, update_flags);
>
> /*
> + * Re-check for ATTR2 in case it was found in bad_features2 slot.
> + */
> + if (xfs_sb_version_hasattr2(&mp->m_sb))
> + mp->m_flags |= XFS_MOUNT_ATTR2;
> +
Rather than here.
> /*
> - * Detect a bad features2 field
> + * Detect a mismatched features2 field. Older kernels read/wrote
> + * this into the wrong slot, so to be safe we keep them in sync.
> */
> -static inline int xfs_sb_has_bad_features2(xfs_sb_t *sbp)
> +static inline int xfs_sb_has_mismatched_features2(xfs_sb_t *sbp)
> {
> - return (sbp->sb_bad_features2 != 0);
> + return (sbp->sb_bad_features2 != sbp->sb_features2);
> }
Yep, makes sense.
Cheers,
Dave.
--
Dave Chinner
Principal Engineer
SGI Australian Software Group
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH V2] combined features2 fixup patches (updating/rewriting what was sent in other threads)
2008-04-02 0:29 ` David Chinner
@ 2008-04-03 1:06 ` Eric Sandeen
0 siblings, 0 replies; 3+ messages in thread
From: Eric Sandeen @ 2008-04-03 1:06 UTC (permalink / raw)
To: David Chinner; +Cc: xfs-oss
(Addressing Dave's review point)
Ensure "both" features2 slots are consistent, and set mp attr2 flag.
Since older kernels may look in the sb_bad_features2 slot for
flags, rather than zeroing it out on fixup, we should make it
equal to the sb_features2 value.
Also, if the ATTR2 flag was not found prior to features2
fixup, it was not set in the mount flags, so re-check after the
fixup so that the current session will use the feature.
Also fix up the comments to reflect these changes.
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
---
Index: linux-2.6-xfs/fs/xfs/xfs_mount.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/xfs_mount.c
+++ linux-2.6-xfs/fs/xfs/xfs_mount.c
@@ -967,23 +967,32 @@ xfs_mountfs(
xfs_mount_common(mp, sbp);
/*
- * Check for a bad features2 field alignment. This happened on
- * some platforms due to xfs_sb_t not being 64bit size aligned
- * when sb_features was added and hence the compiler put it in
- * the wrong place.
+ * Check for a mismatched features2 values. Older kernels
+ * read & wrote into the wrong sb offset for sb_features2
+ * on some platforms due to xfs_sb_t not being 64bit size aligned
+ * when sb_features2 was added, which made older superblock
+ * reading/writing routines swap it as a 64-bit value.
*
- * If we detect a bad field, we or the set bits into the existing
- * features2 field in case it has already been modified and we
- * don't want to lose any features. Zero the bad one and mark
- * the two fields as needing updates once the transaction subsystem
- * is online.
+ * For backwards compatibility, we make both slots equal.
+ *
+ * If we detect a mismatched field, we OR the set bits into the
+ * existing features2 field in case it has already been modified; we
+ * don't want to lose any features. We then update the bad location
+ * with the ORed value so that older kernels will see any features2
+ * flags, and mark the two fields as needing updates once the
+ * transaction subsystem is online.
*/
- if (xfs_sb_has_bad_features2(sbp)) {
+ if (xfs_sb_has_mismatched_features2(sbp)) {
cmn_err(CE_WARN,
"XFS: correcting sb_features alignment problem");
sbp->sb_features2 |= sbp->sb_bad_features2;
- sbp->sb_bad_features2 = 0;
+ sbp->sb_bad_features2 = sbp->sb_features2;
update_flags |= XFS_SB_FEATURES2 | XFS_SB_BAD_FEATURES2;
+ /*
+ * Re-check for ATTR2 from the bad_features2 slot.
+ */
+ if (xfs_sb_version_hasattr2(&mp->m_sb))
+ mp->m_flags |= XFS_MOUNT_ATTR2;
}
/*
@@ -1890,7 +1899,8 @@ xfs_uuid_unmount(
/*
* Used to log changes to the superblock unit and width fields which could
- * be altered by the mount options. Only the first superblock is updated.
+ * be altered by the mount options, as well as any potential sb_features2
+ * fixup. Only the first superblock is updated.
*/
STATIC void
xfs_mount_log_sb(
Index: linux-2.6-xfs/fs/xfs/xfs_sb.h
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/xfs_sb.h
+++ linux-2.6-xfs/fs/xfs/xfs_sb.h
@@ -320,11 +320,12 @@ static inline int xfs_sb_good_version(xf
#endif /* __KERNEL__ */
/*
- * Detect a bad features2 field
+ * Detect a mismatched features2 field. Older kernels read/wrote
+ * this into the wrong slot, so to be safe we keep them in sync.
*/
-static inline int xfs_sb_has_bad_features2(xfs_sb_t *sbp)
+static inline int xfs_sb_has_mismatched_features2(xfs_sb_t *sbp)
{
- return (sbp->sb_bad_features2 != 0);
+ return (sbp->sb_bad_features2 != sbp->sb_features2);
}
static inline unsigned xfs_sb_version_tonew(unsigned v)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-04-03 1:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-31 3:03 [PATCH] combined features2 fixup patches (updating/rewriting what was sent in other threads) Eric Sandeen
2008-04-02 0:29 ` David Chinner
2008-04-03 1:06 ` [PATCH V2] " Eric Sandeen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox