From: Brian Foster <bfoster@redhat.com>
To: Dave Chinner <david@fromorbit.com>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH 3/3] xfs: sanitise sb_bad_features2 handling
Date: Thu, 8 Jan 2015 09:36:40 -0500 [thread overview]
Message-ID: <20150108143640.GC33789@bfoster.bfoster> (raw)
In-Reply-To: <1420667465-7453-4-git-send-email-david@fromorbit.com>
On Thu, Jan 08, 2015 at 08:51:05AM +1100, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
>
> We currently have to ensure that every time we update sb_features2
> that we update sb_bad_features2. Now that we log and format the
> superblock in it's entirety we actually don't have to care because
> we can simply update the sb_bad_features2 when we format it into the
> buffer. This removes the need for anything but the mount and
> superblock formatting code to care about sb_bad_features2, and
> hence removes the possibility that we forget to update bad_features2
> when necessary in the future.
>
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> ---
Reviewed-by: Brian Foster <bfoster@redhat.com>
> fs/xfs/libxfs/xfs_format.h | 14 +++++++-------
> fs/xfs/libxfs/xfs_sb.c | 8 +++++++-
> fs/xfs/xfs_mount.c | 23 +++++++++++------------
> 3 files changed, 25 insertions(+), 20 deletions(-)
>
> diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h
> index 4762732..8eb7189 100644
> --- a/fs/xfs/libxfs/xfs_format.h
> +++ b/fs/xfs/libxfs/xfs_format.h
> @@ -151,10 +151,13 @@ typedef struct xfs_sb {
> __uint32_t sb_features2; /* additional feature bits */
>
> /*
> - * bad features2 field as a result of failing to pad the sb
> - * structure to 64 bits. Some machines will be using this field
> - * for features2 bits. Easiest just to mark it bad and not use
> - * it for anything else.
> + * bad features2 field as a result of failing to pad the sb structure to
> + * 64 bits. Some machines will be using this field for features2 bits.
> + * Easiest just to mark it bad and not use it for anything else.
> + *
> + * This is not kept up to date in memory; it is always overwritten by
> + * the value in sb_features2 when formatting the incore superblock to
> + * the disk buffer.
> */
> __uint32_t sb_bad_features2;
>
> @@ -453,13 +456,11 @@ static inline void xfs_sb_version_addattr2(struct xfs_sb *sbp)
> {
> sbp->sb_versionnum |= XFS_SB_VERSION_MOREBITSBIT;
> sbp->sb_features2 |= XFS_SB_VERSION2_ATTR2BIT;
> - sbp->sb_bad_features2 |= XFS_SB_VERSION2_ATTR2BIT;
> }
>
> static inline void xfs_sb_version_removeattr2(struct xfs_sb *sbp)
> {
> sbp->sb_features2 &= ~XFS_SB_VERSION2_ATTR2BIT;
> - sbp->sb_bad_features2 &= ~XFS_SB_VERSION2_ATTR2BIT;
> if (!sbp->sb_features2)
> sbp->sb_versionnum &= ~XFS_SB_VERSION_MOREBITSBIT;
> }
> @@ -475,7 +476,6 @@ static inline void xfs_sb_version_addprojid32bit(struct xfs_sb *sbp)
> {
> sbp->sb_versionnum |= XFS_SB_VERSION_MOREBITSBIT;
> sbp->sb_features2 |= XFS_SB_VERSION2_PROJID32BIT;
> - sbp->sb_bad_features2 |= XFS_SB_VERSION2_PROJID32BIT;
> }
>
> /*
> diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c
> index 6ee3af6..b440839 100644
> --- a/fs/xfs/libxfs/xfs_sb.c
> +++ b/fs/xfs/libxfs/xfs_sb.c
> @@ -488,7 +488,6 @@ xfs_sb_to_disk(
> to->sb_fdblocks = cpu_to_be64(from->sb_fdblocks);
> to->sb_frextents = cpu_to_be64(from->sb_frextents);
>
> -
> to->sb_flags = from->sb_flags;
> to->sb_shared_vn = from->sb_shared_vn;
> to->sb_inoalignmt = cpu_to_be32(from->sb_inoalignmt);
> @@ -498,6 +497,13 @@ xfs_sb_to_disk(
> to->sb_logsectlog = from->sb_logsectlog;
> to->sb_logsectsize = cpu_to_be16(from->sb_logsectsize);
> to->sb_logsunit = cpu_to_be32(from->sb_logsunit);
> +
> + /*
> + * We need to ensure that bad_features2 always matches features2.
> + * Hence we enforce that here rather than having to remember to do it
> + * everywhere else that updates features2.
> + */
> + from->sb_bad_features2 = from->sb_features2;
> to->sb_features2 = cpu_to_be32(from->sb_features2);
> to->sb_bad_features2 = cpu_to_be32(from->sb_bad_features2);
>
> diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
> index 5ef9aa2..4fa80e6 100644
> --- a/fs/xfs/xfs_mount.c
> +++ b/fs/xfs/xfs_mount.c
> @@ -640,25 +640,24 @@ xfs_mountfs(
> xfs_sb_mount_common(mp, sbp);
>
> /*
> - * 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.
> + * 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.
> *
> * 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 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. The
> + * superblock writeback code ensures the new sb_features2 is copied to
> + * sb_bad_features2 before it is logged or written to disk.
> */
> if (xfs_sb_has_mismatched_features2(sbp)) {
> 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_sb = true;
>
> /*
> --
> 2.0.0
>
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
prev parent reply other threads:[~2015-01-08 14:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-07 21:51 [PATCH 0/3 v3] xfs: simplify superblock logging Dave Chinner
2015-01-07 21:51 ` [PATCH 1/3] xfs: remove bitfield based superblock updates Dave Chinner
2015-01-09 20:35 ` Brian Foster
2015-01-09 23:36 ` Dave Chinner
2015-01-07 21:51 ` [PATCH 2/3] xfs: consolidate superblock logging functions Dave Chinner
2015-01-08 14:36 ` Brian Foster
2015-01-08 23:20 ` Dave Chinner
2015-01-07 21:51 ` [PATCH 3/3] xfs: sanitise sb_bad_features2 handling Dave Chinner
2015-01-08 14:36 ` Brian Foster [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150108143640.GC33789@bfoster.bfoster \
--to=bfoster@redhat.com \
--cc=david@fromorbit.com \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.