All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] xfs: sanitise supberlock feature bit support
@ 2014-05-06  3:55 Dave Chinner
  2014-05-06  3:55 ` [PATCH 1/5] xfs: make superblock version checks reflect reality Dave Chinner
                   ` (4 more replies)
  0 siblings, 5 replies; 18+ messages in thread
From: Dave Chinner @ 2014-05-06  3:55 UTC (permalink / raw)
  To: xfs

Hi folks,

This patchset is a followup to the original feature bit cleanup
patch I sent here:

http://oss.sgi.com/archives/xfs/2014-03/msg00101.html

It basically removes all the old cruft that we inherited from Irix
(such as tests and conversion to/from v1-3 superblocks) that we've
never supported on Linux.  On Linux, we've ony ever supported V2
directories, and so anything that doesn't know about V2 directories
is simply going to be rejected at mount time. Hence we don't need
all the code to handle versions older than this.

Nor do we care about Irix bootloader feature bit masks (the SASH
feature bits) or about things that were never implemented like
shared readonly superblock support. Hence we can remove a fairly
large chunk of complexity out of the feature bit testing if we
only test for things that we can support.

Further, we should really always use to v2 inodes these days
on v4 superblock filesystems. We've been setting the NLINK feature
bit by default at mkfs time since 2007, so no we make the kernel set
it by default at mount time, too. This means that we always convert
v1 inodes to v2 inodes, and so reduce the number of different code
paths we need to test and support.

Thoughts, comments?

Cheers,

Dave.

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 1/5] xfs: make superblock version checks reflect reality
  2014-05-06  3:55 [PATCH 0/5] xfs: sanitise supberlock feature bit support Dave Chinner
@ 2014-05-06  3:55 ` Dave Chinner
  2014-05-06  8:29   ` Christoph Hellwig
  2014-05-06  3:55 ` [PATCH 2/5] xfs: keep sb_bad_features2 the same a sb_features2 Dave Chinner
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 18+ messages in thread
From: Dave Chinner @ 2014-05-06  3:55 UTC (permalink / raw)
  To: xfs

From: Dave Chinner <dchinner@redhat.com>

We only support filesystems that have v2 directory support, and than
means all the checking and handling of superblock versions prior to
this support being added is completely unnecessary overhead.

Strip out all the version 1-3 support, sanitise the good version
checking to reflect the supported versions, update all the feature
supported functions and clean up all the support bit definitions to
reflect the fact that we no longer care about Irix bootloader flag
regions for v4 feature bits. Also, convert the return values to
boolean types and remove typedefs from function declarations to
clean up calling conventions, too.

Because the feature bit checking is all inline code, this relatively
small cleanup has a noticable impact on code size:

   text    data     bss     dec     hex filename
 785195  100867     616  886678   d8796 fs/xfs/xfs.o.orig
 783595  100867     616  885078   d8156 fs/xfs/xfs.o.patched

i.e. it reduces it by 1600 bytes.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 fs/xfs/xfs_sb.h | 215 ++++++++++++++++++++------------------------------------
 1 file changed, 77 insertions(+), 138 deletions(-)

diff --git a/fs/xfs/xfs_sb.h b/fs/xfs/xfs_sb.h
index 950d1ea..85f0146 100644
--- a/fs/xfs/xfs_sb.h
+++ b/fs/xfs/xfs_sb.h
@@ -36,8 +36,6 @@ struct xfs_trans;
 #define	XFS_SB_VERSION_5	5		/* CRC enabled filesystem */
 #define	XFS_SB_VERSION_NUMBITS		0x000f
 #define	XFS_SB_VERSION_ALLFBITS		0xfff0
-#define	XFS_SB_VERSION_SASHFBITS	0xf000
-#define	XFS_SB_VERSION_REALFBITS	0x0ff0
 #define	XFS_SB_VERSION_ATTRBIT		0x0010
 #define	XFS_SB_VERSION_NLINKBIT		0x0020
 #define	XFS_SB_VERSION_QUOTABIT		0x0040
@@ -50,24 +48,14 @@ struct xfs_trans;
 #define	XFS_SB_VERSION_DIRV2BIT		0x2000
 #define	XFS_SB_VERSION_BORGBIT		0x4000	/* ASCII only case-insens. */
 #define	XFS_SB_VERSION_MOREBITSBIT	0x8000
-#define	XFS_SB_VERSION_OKSASHFBITS	\
-	(XFS_SB_VERSION_EXTFLGBIT | \
-	 XFS_SB_VERSION_DIRV2BIT | \
-	 XFS_SB_VERSION_BORGBIT)
-#define	XFS_SB_VERSION_OKREALFBITS	\
-	(XFS_SB_VERSION_ATTRBIT | \
-	 XFS_SB_VERSION_NLINKBIT | \
-	 XFS_SB_VERSION_QUOTABIT | \
-	 XFS_SB_VERSION_ALIGNBIT | \
-	 XFS_SB_VERSION_DALIGNBIT | \
-	 XFS_SB_VERSION_SHAREDBIT | \
-	 XFS_SB_VERSION_LOGV2BIT | \
-	 XFS_SB_VERSION_SECTORBIT | \
-	 XFS_SB_VERSION_MOREBITSBIT)
-#define	XFS_SB_VERSION_OKREALBITS	\
-	(XFS_SB_VERSION_NUMBITS | \
-	 XFS_SB_VERSION_OKREALFBITS | \
-	 XFS_SB_VERSION_OKSASHFBITS)
+
+/*
+ * Supported feature bit list is just all bits in the versionnum field because
+ * we've used them all up and understand them all.
+ */
+#define	XFS_SB_VERSION_OKBITS		\
+	(XFS_SB_VERSION_NUMBITS		| \
+	 XFS_SB_VERSION_ALLFBITS)
 
 /*
  * There are two words to hold XFS "feature" bits: the original
@@ -76,7 +64,6 @@ struct xfs_trans;
  *
  * These defines represent bits in sb_features2.
  */
-#define XFS_SB_VERSION2_REALFBITS	0x00ffffff	/* Mask: features */
 #define XFS_SB_VERSION2_RESERVED1BIT	0x00000001
 #define XFS_SB_VERSION2_LAZYSBCOUNTBIT	0x00000002	/* Superblk counters */
 #define XFS_SB_VERSION2_RESERVED4BIT	0x00000004
@@ -86,16 +73,11 @@ struct xfs_trans;
 #define XFS_SB_VERSION2_CRCBIT		0x00000100	/* metadata CRCs */
 #define XFS_SB_VERSION2_FTYPE		0x00000200	/* inode type in dir */
 
-#define	XFS_SB_VERSION2_OKREALFBITS	\
+#define	XFS_SB_VERSION2_OKBITS		\
 	(XFS_SB_VERSION2_LAZYSBCOUNTBIT	| \
 	 XFS_SB_VERSION2_ATTR2BIT	| \
 	 XFS_SB_VERSION2_PROJID32BIT	| \
 	 XFS_SB_VERSION2_FTYPE)
-#define	XFS_SB_VERSION2_OKSASHFBITS	\
-	(0)
-#define XFS_SB_VERSION2_OKREALBITS	\
-	(XFS_SB_VERSION2_OKREALFBITS |	\
-	 XFS_SB_VERSION2_OKSASHFBITS )
 
 /*
  * Superblock - in core version.  Must match the ondisk version below.
@@ -345,167 +327,124 @@ typedef enum {
 
 #define	XFS_SB_VERSION_NUM(sbp)	((sbp)->sb_versionnum & XFS_SB_VERSION_NUMBITS)
 
-static inline int xfs_sb_good_version(xfs_sb_t *sbp)
+/*
+ * The first XFS version we support is a v4 superblock with V2 directories.
+ */
+static inline bool xfs_sb_good_v4_features(struct xfs_sb *sbp)
 {
-	/* We always support version 1-3 */
-	if (sbp->sb_versionnum >= XFS_SB_VERSION_1 &&
-	    sbp->sb_versionnum <= XFS_SB_VERSION_3)
-		return 1;
+	if (!(sbp->sb_versionnum & XFS_SB_VERSION_DIRV2BIT))
+		return false;
 
-	/* We support version 4 if all feature bits are supported */
-	if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) {
-		if ((sbp->sb_versionnum & ~XFS_SB_VERSION_OKREALBITS) ||
-		    ((sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT) &&
-		     (sbp->sb_features2 & ~XFS_SB_VERSION2_OKREALBITS)))
-			return 0;
+	/* check for unknown features in the fs */
+	if ((sbp->sb_versionnum & ~XFS_SB_VERSION_OKBITS) ||
+	    ((sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT) &&
+	     (sbp->sb_features2 & ~XFS_SB_VERSION2_OKBITS)))
+		return false;
 
-		if (sbp->sb_shared_vn > XFS_SB_MAX_SHARED_VN)
-			return 0;
-		return 1;
-	}
-	if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5)
-		return 1;
+	/* We don't support shared superblocks - nobody knows what it is */
+	if (sbp->sb_versionnum & XFS_SB_VERSION_SHAREDBIT)
+		return false;
 
-	return 0;
+	return true;
+}
+
+static inline bool xfs_sb_good_version(struct xfs_sb *sbp)
+{
+	if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5)
+		return true;
+	if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4)
+		return xfs_sb_good_v4_features(sbp);
+	return false;
 }
 
 /*
  * 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_mismatched_features2(xfs_sb_t *sbp)
+static inline bool xfs_sb_has_mismatched_features2(struct xfs_sb *sbp)
 {
-	return (sbp->sb_bad_features2 != sbp->sb_features2);
+	return sbp->sb_bad_features2 != sbp->sb_features2;
 }
 
-static inline unsigned xfs_sb_version_tonew(unsigned v)
+static inline bool xfs_sb_version_hasattr(struct xfs_sb *sbp)
 {
-	if (v == XFS_SB_VERSION_1)
-		return XFS_SB_VERSION_4;
-
-	if (v == XFS_SB_VERSION_2)
-		return XFS_SB_VERSION_4 | XFS_SB_VERSION_ATTRBIT;
-
-	return XFS_SB_VERSION_4 | XFS_SB_VERSION_ATTRBIT |
-		XFS_SB_VERSION_NLINKBIT;
+	return (sbp->sb_versionnum & XFS_SB_VERSION_ATTRBIT);
 }
 
-static inline unsigned xfs_sb_version_toold(unsigned v)
+static inline void xfs_sb_version_addattr(struct xfs_sb *sbp)
 {
-	if (v & (XFS_SB_VERSION_QUOTABIT | XFS_SB_VERSION_ALIGNBIT))
-		return 0;
-	if (v & XFS_SB_VERSION_NLINKBIT)
-		return XFS_SB_VERSION_3;
-	if (v & XFS_SB_VERSION_ATTRBIT)
-		return XFS_SB_VERSION_2;
-	return XFS_SB_VERSION_1;
+	sbp->sb_versionnum |= XFS_SB_VERSION_ATTRBIT;
 }
 
-static inline int xfs_sb_version_hasattr(xfs_sb_t *sbp)
+static inline bool xfs_sb_version_hasnlink(struct xfs_sb *sbp)
 {
-	return sbp->sb_versionnum == XFS_SB_VERSION_2 ||
-		sbp->sb_versionnum == XFS_SB_VERSION_3 ||
-		(XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4 &&
-		 (sbp->sb_versionnum & XFS_SB_VERSION_ATTRBIT));
+	return (sbp->sb_versionnum & XFS_SB_VERSION_NLINKBIT);
 }
 
-static inline void xfs_sb_version_addattr(xfs_sb_t *sbp)
+static inline void xfs_sb_version_addnlink(struct xfs_sb *sbp)
 {
-	if (sbp->sb_versionnum == XFS_SB_VERSION_1)
-		sbp->sb_versionnum = XFS_SB_VERSION_2;
-	else if (XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4)
-		sbp->sb_versionnum |= XFS_SB_VERSION_ATTRBIT;
-	else
-		sbp->sb_versionnum = XFS_SB_VERSION_4 | XFS_SB_VERSION_ATTRBIT;
+	sbp->sb_versionnum |= XFS_SB_VERSION_NLINKBIT;
 }
 
-static inline int xfs_sb_version_hasnlink(xfs_sb_t *sbp)
+static inline bool xfs_sb_version_hasquota(struct xfs_sb *sbp)
 {
-	return sbp->sb_versionnum == XFS_SB_VERSION_3 ||
-		 (XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4 &&
-		  (sbp->sb_versionnum & XFS_SB_VERSION_NLINKBIT));
+	return (sbp->sb_versionnum & XFS_SB_VERSION_QUOTABIT);
 }
 
-static inline void xfs_sb_version_addnlink(xfs_sb_t *sbp)
+static inline void xfs_sb_version_addquota(struct xfs_sb *sbp)
 {
-	if (sbp->sb_versionnum <= XFS_SB_VERSION_2)
-		sbp->sb_versionnum = XFS_SB_VERSION_3;
-	else
-		sbp->sb_versionnum |= XFS_SB_VERSION_NLINKBIT;
+	sbp->sb_versionnum |= XFS_SB_VERSION_QUOTABIT;
 }
 
-static inline int xfs_sb_version_hasquota(xfs_sb_t *sbp)
+static inline bool xfs_sb_version_hasalign(struct xfs_sb *sbp)
 {
-	return XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4 &&
-		(sbp->sb_versionnum & XFS_SB_VERSION_QUOTABIT);
-}
-
-static inline void xfs_sb_version_addquota(xfs_sb_t *sbp)
-{
-	if (XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4)
-		sbp->sb_versionnum |= XFS_SB_VERSION_QUOTABIT;
-	else
-		sbp->sb_versionnum = xfs_sb_version_tonew(sbp->sb_versionnum) |
-					XFS_SB_VERSION_QUOTABIT;
-}
-
-static inline int xfs_sb_version_hasalign(xfs_sb_t *sbp)
-{
-	return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) ||
-	       (XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4 &&
+	return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 ||
 		(sbp->sb_versionnum & XFS_SB_VERSION_ALIGNBIT));
 }
 
-static inline int xfs_sb_version_hasdalign(xfs_sb_t *sbp)
+static inline bool xfs_sb_version_hasdalign(struct xfs_sb *sbp)
 {
-	return XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4 &&
-		(sbp->sb_versionnum & XFS_SB_VERSION_DALIGNBIT);
+	return (sbp->sb_versionnum & XFS_SB_VERSION_DALIGNBIT);
 }
 
-static inline int xfs_sb_version_hasshared(xfs_sb_t *sbp)
+static inline bool xfs_sb_version_hasshared(struct xfs_sb *sbp)
 {
 	return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
 		(sbp->sb_versionnum & XFS_SB_VERSION_SHAREDBIT);
 }
 
-static inline int xfs_sb_version_hasdirv2(xfs_sb_t *sbp)
+static inline bool xfs_sb_version_hasdirv2(struct xfs_sb *sbp)
 {
-	return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) ||
-	       (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
-		(sbp->sb_versionnum & XFS_SB_VERSION_DIRV2BIT));
+	return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 ||
+	       (sbp->sb_versionnum & XFS_SB_VERSION_DIRV2BIT);
 }
 
-static inline int xfs_sb_version_haslogv2(xfs_sb_t *sbp)
+static inline bool xfs_sb_version_haslogv2(struct xfs_sb *sbp)
 {
-	return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) ||
-	       (XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4 &&
-		(sbp->sb_versionnum & XFS_SB_VERSION_LOGV2BIT));
+	return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 ||
+	       (sbp->sb_versionnum & XFS_SB_VERSION_LOGV2BIT);
 }
 
-static inline int xfs_sb_version_hasextflgbit(xfs_sb_t *sbp)
+static inline bool xfs_sb_version_hasextflgbit(struct xfs_sb *sbp)
 {
-	return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) ||
-	       (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
-		(sbp->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT));
+	return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 ||
+	       (sbp->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT);
 }
 
-static inline int xfs_sb_version_hassector(xfs_sb_t *sbp)
+static inline bool xfs_sb_version_hassector(struct xfs_sb *sbp)
 {
-	return XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4 &&
-		(sbp->sb_versionnum & XFS_SB_VERSION_SECTORBIT);
+	return (sbp->sb_versionnum & XFS_SB_VERSION_SECTORBIT);
 }
 
-static inline int xfs_sb_version_hasasciici(xfs_sb_t *sbp)
+static inline bool xfs_sb_version_hasasciici(struct xfs_sb *sbp)
 {
-	return XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4 &&
-		(sbp->sb_versionnum & XFS_SB_VERSION_BORGBIT);
+	return (sbp->sb_versionnum & XFS_SB_VERSION_BORGBIT);
 }
 
-static inline int xfs_sb_version_hasmorebits(xfs_sb_t *sbp)
+static inline bool xfs_sb_version_hasmorebits(struct xfs_sb *sbp)
 {
-	return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) ||
-	       (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
-		(sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT));
+	return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 ||
+	       (sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT);
 }
 
 /*
@@ -513,46 +452,46 @@ static inline int xfs_sb_version_hasmorebits(xfs_sb_t *sbp)
  *
  * For example, for a bit defined as XFS_SB_VERSION2_FUNBIT, has a macro:
  *
- * SB_VERSION_HASFUNBIT(xfs_sb_t *sbp)
+ * SB_VERSION_HASFUNBIT(struct xfs_sb *sbp)
  *	((xfs_sb_version_hasmorebits(sbp) &&
  *	 ((sbp)->sb_features2 & XFS_SB_VERSION2_FUNBIT)
  */
 
-static inline int xfs_sb_version_haslazysbcount(xfs_sb_t *sbp)
+static inline bool xfs_sb_version_haslazysbcount(struct xfs_sb *sbp)
 {
 	return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) ||
 	       (xfs_sb_version_hasmorebits(sbp) &&
 		(sbp->sb_features2 & XFS_SB_VERSION2_LAZYSBCOUNTBIT));
 }
 
-static inline int xfs_sb_version_hasattr2(xfs_sb_t *sbp)
+static inline bool xfs_sb_version_hasattr2(struct xfs_sb *sbp)
 {
 	return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) ||
 	       (xfs_sb_version_hasmorebits(sbp) &&
 		(sbp->sb_features2 & XFS_SB_VERSION2_ATTR2BIT));
 }
 
-static inline void xfs_sb_version_addattr2(xfs_sb_t *sbp)
+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;
 }
 
-static inline void xfs_sb_version_removeattr2(xfs_sb_t *sbp)
+static inline void xfs_sb_version_removeattr2(struct xfs_sb *sbp)
 {
 	sbp->sb_features2 &= ~XFS_SB_VERSION2_ATTR2BIT;
 	if (!sbp->sb_features2)
 		sbp->sb_versionnum &= ~XFS_SB_VERSION_MOREBITSBIT;
 }
 
-static inline int xfs_sb_version_hasprojid32bit(xfs_sb_t *sbp)
+static inline bool xfs_sb_version_hasprojid32bit(struct xfs_sb *sbp)
 {
 	return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) ||
 	       (xfs_sb_version_hasmorebits(sbp) &&
 		(sbp->sb_features2 & XFS_SB_VERSION2_PROJID32BIT));
 }
 
-static inline void xfs_sb_version_addprojid32bit(xfs_sb_t *sbp)
+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;
@@ -625,12 +564,12 @@ xfs_sb_has_incompat_log_feature(
 /*
  * V5 superblock specific feature checks
  */
-static inline int xfs_sb_version_hascrc(xfs_sb_t *sbp)
+static inline int xfs_sb_version_hascrc(struct xfs_sb *sbp)
 {
 	return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5;
 }
 
-static inline int xfs_sb_version_has_pquotino(xfs_sb_t *sbp)
+static inline int xfs_sb_version_has_pquotino(struct xfs_sb *sbp)
 {
 	return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5;
 }
-- 
1.9.0

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 2/5] xfs: keep sb_bad_features2 the same a sb_features2
  2014-05-06  3:55 [PATCH 0/5] xfs: sanitise supberlock feature bit support Dave Chinner
  2014-05-06  3:55 ` [PATCH 1/5] xfs: make superblock version checks reflect reality Dave Chinner
@ 2014-05-06  3:55 ` Dave Chinner
  2014-05-06  8:20   ` Christoph Hellwig
  2014-05-06  3:55 ` [PATCH 3/5] xfs: turn NLINK feature on by default Dave Chinner
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 18+ messages in thread
From: Dave Chinner @ 2014-05-06  3:55 UTC (permalink / raw)
  To: xfs

From: Dave Chinner <dchinner@redhat.com>

Whenever we update sb_features2, we need to update sb_bad_features2
so that they remain identical on disk. This prevents future mounts
or userspace utilities from getting confused over which features the
filesystem supports.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 fs/xfs/xfs_sb.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/xfs/xfs_sb.h b/fs/xfs/xfs_sb.h
index 85f0146..7dfa8f1 100644
--- a/fs/xfs/xfs_sb.h
+++ b/fs/xfs/xfs_sb.h
@@ -475,11 +475,13 @@ 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;
 }
-- 
1.9.0

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 3/5] xfs: turn NLINK feature on by default
  2014-05-06  3:55 [PATCH 0/5] xfs: sanitise supberlock feature bit support Dave Chinner
  2014-05-06  3:55 ` [PATCH 1/5] xfs: make superblock version checks reflect reality Dave Chinner
  2014-05-06  3:55 ` [PATCH 2/5] xfs: keep sb_bad_features2 the same a sb_features2 Dave Chinner
@ 2014-05-06  3:55 ` Dave Chinner
  2014-05-06  8:15   ` Christoph Hellwig
  2014-05-06  3:55 ` [PATCH 4/5] xfs: don't need dirv2 checks anymore Dave Chinner
  2014-05-06  3:55 ` [PATCH 5/5] xfs: remove shared supberlock feature checking Dave Chinner
  4 siblings, 1 reply; 18+ messages in thread
From: Dave Chinner @ 2014-05-06  3:55 UTC (permalink / raw)
  To: xfs

From: Dave Chinner <dchinner@redhat.com>

mkfs has turned on the XFS_SB_VERSION_NLINKBIT feature bit by
default since November 2007. It's about time we simply made the
kernel code turn it on by default and so always convert v1 inodes to
v2 inodes. This removes needless version checks and modification
when bumping link counts on inodes, and will take code out of
a few common code paths.

   text    data     bss     dec     hex filename
 783595  100867     616  885078   d8156 fs/xfs/xfs.o.orig
 783171  100867     616  884654   d7fae fs/xfs/xfs.o.patched

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 fs/xfs/xfs_fsops.c      |  4 +--
 fs/xfs/xfs_ialloc.c     |  4 +--
 fs/xfs/xfs_inode.c      | 80 +++++++++++--------------------------------------
 fs/xfs/xfs_inode.h      |  2 +-
 fs/xfs/xfs_inode_item.c | 30 +------------------
 fs/xfs/xfs_ioctl.c      |  5 ++--
 fs/xfs/xfs_mount.c      |  6 ++++
 fs/xfs/xfs_sb.h         | 10 -------
 8 files changed, 31 insertions(+), 110 deletions(-)

diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index 3445ead..2a03f2d 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -74,11 +74,9 @@ xfs_fs_geometry(
 	}
 	if (new_version >= 3) {
 		geo->version = XFS_FSOP_GEOM_VERSION;
-		geo->flags =
+		geo->flags = XFS_FSOP_GEOM_FLAGS_NLINK |
 			(xfs_sb_version_hasattr(&mp->m_sb) ?
 				XFS_FSOP_GEOM_FLAGS_ATTR : 0) |
-			(xfs_sb_version_hasnlink(&mp->m_sb) ?
-				XFS_FSOP_GEOM_FLAGS_NLINK : 0) |
 			(xfs_sb_version_hasquota(&mp->m_sb) ?
 				XFS_FSOP_GEOM_FLAGS_QUOTA : 0) |
 			(xfs_sb_version_hasalign(&mp->m_sb) ?
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c
index 6ac0c29..c89a53a 100644
--- a/fs/xfs/xfs_ialloc.c
+++ b/fs/xfs/xfs_ialloc.c
@@ -280,10 +280,8 @@ xfs_ialloc_inode_init(
 		if (tp)
 			xfs_icreate_log(tp, agno, agbno, mp->m_ialloc_inos,
 					mp->m_sb.sb_inodesize, length, gen);
-	} else if (xfs_sb_version_hasnlink(&mp->m_sb))
+	} else
 		version = 2;
-	else
-		version = 1;
 
 	for (j = 0; j < nbufs; j++) {
 		/*
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 6d6b44a..0fcfdd4 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -681,6 +681,14 @@ xfs_ialloc(
 		return error;
 	ASSERT(ip != NULL);
 
+	/*
+	 * We always convert v1 inodes to v2 now - we only support filesystems
+	 * with >= v2 inode capability, so there is no reason for ever leaving
+	 * an inode in v1 format.
+	 */
+	if (ip->i_d.di_version == 1)
+		ip->i_d.di_version = 2;
+
 	ip->i_d.di_mode = mode;
 	ip->i_d.di_onlink = 0;
 	ip->i_d.di_nlink = nlink;
@@ -690,27 +698,6 @@ xfs_ialloc(
 	xfs_set_projid(ip, prid);
 	memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
 
-	/*
-	 * If the superblock version is up to where we support new format
-	 * inodes and this is currently an old format inode, then change
-	 * the inode version number now.  This way we only do the conversion
-	 * here rather than here and in the flush/logging code.
-	 */
-	if (xfs_sb_version_hasnlink(&mp->m_sb) &&
-	    ip->i_d.di_version == 1) {
-		ip->i_d.di_version = 2;
-		/*
-		 * We've already zeroed the old link count, the projid field,
-		 * and the pad field.
-		 */
-	}
-
-	/*
-	 * Project ids won't be stored on disk if we are using a version 1 inode.
-	 */
-	if ((prid != 0) && (ip->i_d.di_version == 1))
-		xfs_bump_ino_vers2(tp, ip);
-
 	if (pip && XFS_INHERIT_GID(pip)) {
 		ip->i_d.di_gid = pip->i_d.di_gid;
 		if ((pip->i_d.di_mode & S_ISGID) && S_ISDIR(mode)) {
@@ -1064,28 +1051,14 @@ xfs_droplink(
  */
 void
 xfs_bump_ino_vers2(
-	xfs_trans_t	*tp,
 	xfs_inode_t	*ip)
 {
-	xfs_mount_t	*mp;
-
 	ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
 	ASSERT(ip->i_d.di_version == 1);
 
 	ip->i_d.di_version = 2;
 	ip->i_d.di_onlink = 0;
 	memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
-	mp = tp->t_mountp;
-	if (!xfs_sb_version_hasnlink(&mp->m_sb)) {
-		spin_lock(&mp->m_sb_lock);
-		if (!xfs_sb_version_hasnlink(&mp->m_sb)) {
-			xfs_sb_version_addnlink(&mp->m_sb);
-			spin_unlock(&mp->m_sb_lock);
-			xfs_mod_sb(tp, XFS_SB_VERSIONNUM);
-		} else {
-			spin_unlock(&mp->m_sb_lock);
-		}
-	}
 	/* Caller must log the inode */
 }
 
@@ -1112,7 +1085,7 @@ xfs_bumplink(
 		 * system to do this, then we need to bump the superblock
 		 * version number as well.
 		 */
-		xfs_bump_ino_vers2(tp, ip);
+		xfs_bump_ino_vers2(ip);
 	}
 
 	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
@@ -3333,34 +3306,17 @@ xfs_iflush_int(
 		ip->i_d.di_flushiter = 0;
 
 	/*
-	 * If this is really an old format inode and the superblock version
-	 * has not been updated to support only new format inodes, then
-	 * convert back to the old inode format.  If the superblock version
-	 * has been updated, then make the conversion permanent.
+	 * If this is really an old format inode, convert it to a v2 format
+	 * inode to make the conversion permanent.
 	 */
-	ASSERT(ip->i_d.di_version == 1 || xfs_sb_version_hasnlink(&mp->m_sb));
 	if (ip->i_d.di_version == 1) {
-		if (!xfs_sb_version_hasnlink(&mp->m_sb)) {
-			/*
-			 * Convert it back.
-			 */
-			ASSERT(ip->i_d.di_nlink <= XFS_MAXLINK_1);
-			dip->di_onlink = cpu_to_be16(ip->i_d.di_nlink);
-		} else {
-			/*
-			 * The superblock version has already been bumped,
-			 * so just make the conversion to the new inode
-			 * format permanent.
-			 */
-			ip->i_d.di_version = 2;
-			dip->di_version = 2;
-			ip->i_d.di_onlink = 0;
-			dip->di_onlink = 0;
-			memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
-			memset(&(dip->di_pad[0]), 0,
-			      sizeof(dip->di_pad));
-			ASSERT(xfs_get_projid(ip) == 0);
-		}
+		ip->i_d.di_version = 2;
+		dip->di_version = 2;
+		ip->i_d.di_onlink = 0;
+		dip->di_onlink = 0;
+		memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
+		memset(&(dip->di_pad[0]), 0, sizeof(dip->di_pad));
+		ASSERT(xfs_get_projid(ip) == 0);
 	}
 
 	xfs_iflush_fork(ip, dip, iip, XFS_DATA_FORK);
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index 13aea54..0ae6e0d 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -377,7 +377,7 @@ int		xfs_dir_ialloc(struct xfs_trans **, struct xfs_inode *, umode_t,
 			       struct xfs_inode **, int *);
 int		xfs_droplink(struct xfs_trans *, struct xfs_inode *);
 int		xfs_bumplink(struct xfs_trans *, struct xfs_inode *);
-void		xfs_bump_ino_vers2(struct xfs_trans *, struct xfs_inode *);
+void		xfs_bump_ino_vers2(struct xfs_inode *);
 
 /* from xfs_file.c */
 int		xfs_zero_eof(struct xfs_inode *, xfs_off_t, xfs_fsize_t);
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index 686889b..dacd6c1 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -145,34 +145,6 @@ xfs_inode_item_size(
 		xfs_inode_item_attr_fork_size(iip, nvecs, nbytes);
 }
 
-/*
- * If this is a v1 format inode, then we need to log it as such.  This means
- * that we have to copy the link count from the new field to the old.  We
- * don't have to worry about the new fields, because nothing trusts them as
- * long as the old inode version number is there.
- */
-STATIC void
-xfs_inode_item_format_v1_inode(
-	struct xfs_inode	*ip)
-{
-	if (!xfs_sb_version_hasnlink(&ip->i_mount->m_sb)) {
-		/*
-		 * Convert it back.
-		 */
-		ASSERT(ip->i_d.di_nlink <= XFS_MAXLINK_1);
-		ip->i_d.di_onlink = ip->i_d.di_nlink;
-	} else {
-		/*
-		 * The superblock version has already been bumped,
-		 * so just make the conversion to the new inode
-		 * format permanent.
-		 */
-		ip->i_d.di_version = 2;
-		ip->i_d.di_onlink = 0;
-		memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
-	}
-}
-
 STATIC void
 xfs_inode_item_format_data_fork(
 	struct xfs_inode_log_item *iip,
@@ -381,7 +353,7 @@ xfs_inode_item_format(
 	xlog_finish_iovec(lv, vecp, sizeof(struct xfs_inode_log_format));
 
 	if (ip->i_d.di_version == 1)
-		xfs_inode_item_format_v1_inode(ip);
+		xfs_bump_ino_vers2(ip);
 	xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_ICORE,
 			&ip->i_d,
 			xfs_icdinode_size(ip->i_d.di_version));
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 2d8f4fd..3f55759 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -1228,7 +1228,6 @@ xfs_ioctl_setattr(
 				olddquot = xfs_qm_vop_chown(tp, ip,
 							&ip->i_pdquot, pdqp);
 			}
-			xfs_set_projid(ip, fa->fsx_projid);
 
 			/*
 			 * We may have to rev the inode as well as
@@ -1236,7 +1235,9 @@ xfs_ioctl_setattr(
 			 * exist before DINODE_VERSION_2 and SB_VERSION_NLINK.
 			 */
 			if (ip->i_d.di_version == 1)
-				xfs_bump_ino_vers2(tp, ip);
+				xfs_bump_ino_vers2(ip);
+
+			xfs_set_projid(ip, fa->fsx_projid);
 		}
 
 	}
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 944f3d9..3f09782 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -697,6 +697,12 @@ xfs_mountfs(
 			mp->m_update_flags |= XFS_SB_VERSIONNUM;
 	}
 
+	/* always use v2 inodes by default now */
+	if (!(mp->m_sb.sb_versionnum & XFS_SB_VERSION_NLINKBIT)) {
+		mp->m_sb.sb_versionnum |= XFS_SB_VERSION_NLINKBIT;
+		mp->m_update_flags |= XFS_SB_VERSIONNUM;
+	}
+
 	/*
 	 * Check if sb_agblocks is aligned at stripe boundary
 	 * If sb_agblocks is NOT aligned turn off m_dalign since
diff --git a/fs/xfs/xfs_sb.h b/fs/xfs/xfs_sb.h
index 7dfa8f1..b238a0e 100644
--- a/fs/xfs/xfs_sb.h
+++ b/fs/xfs/xfs_sb.h
@@ -376,16 +376,6 @@ static inline void xfs_sb_version_addattr(struct xfs_sb *sbp)
 	sbp->sb_versionnum |= XFS_SB_VERSION_ATTRBIT;
 }
 
-static inline bool xfs_sb_version_hasnlink(struct xfs_sb *sbp)
-{
-	return (sbp->sb_versionnum & XFS_SB_VERSION_NLINKBIT);
-}
-
-static inline void xfs_sb_version_addnlink(struct xfs_sb *sbp)
-{
-	sbp->sb_versionnum |= XFS_SB_VERSION_NLINKBIT;
-}
-
 static inline bool xfs_sb_version_hasquota(struct xfs_sb *sbp)
 {
 	return (sbp->sb_versionnum & XFS_SB_VERSION_QUOTABIT);
-- 
1.9.0

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 4/5] xfs: don't need dirv2 checks anymore
  2014-05-06  3:55 [PATCH 0/5] xfs: sanitise supberlock feature bit support Dave Chinner
                   ` (2 preceding siblings ...)
  2014-05-06  3:55 ` [PATCH 3/5] xfs: turn NLINK feature on by default Dave Chinner
@ 2014-05-06  3:55 ` Dave Chinner
  2014-05-06  8:16   ` Christoph Hellwig
  2014-05-06  3:55 ` [PATCH 5/5] xfs: remove shared supberlock feature checking Dave Chinner
  4 siblings, 1 reply; 18+ messages in thread
From: Dave Chinner @ 2014-05-06  3:55 UTC (permalink / raw)
  To: xfs

From: Dave Chinner <dchinner@redhat.com>

If the the V2 directory feature bit is not set in the superblock
feature mask the filesystem will fail the good version check.
Hence we don't need any other version checking on the dir2 feature
bit in the code as the filesystem will not mount without it set.
Remove the checking code.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 fs/xfs/xfs_dir2.c  | 2 +-
 fs/xfs/xfs_fsops.c | 3 +--
 fs/xfs/xfs_sb.c    | 9 ---------
 fs/xfs/xfs_sb.h    | 6 ------
 4 files changed, 2 insertions(+), 18 deletions(-)

diff --git a/fs/xfs/xfs_dir2.c b/fs/xfs/xfs_dir2.c
index e365c98..93fcebd 100644
--- a/fs/xfs/xfs_dir2.c
+++ b/fs/xfs/xfs_dir2.c
@@ -92,7 +92,7 @@ xfs_dir_mount(
 	int	nodehdr_size;
 
 
-	ASSERT(xfs_sb_version_hasdirv2(&mp->m_sb));
+	ASSERT(mp->m_sb.sb_versionnum & XFS_SB_VERSION_DIRV2BIT);
 	ASSERT((1 << (mp->m_sb.sb_blocklog + mp->m_sb.sb_dirblklog)) <=
 	       XFS_MAX_BLOCKSIZE);
 
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index 2a03f2d..b099799 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -75,6 +75,7 @@ xfs_fs_geometry(
 	if (new_version >= 3) {
 		geo->version = XFS_FSOP_GEOM_VERSION;
 		geo->flags = XFS_FSOP_GEOM_FLAGS_NLINK |
+			     XFS_FSOP_GEOM_FLAGS_DIRV2 |
 			(xfs_sb_version_hasattr(&mp->m_sb) ?
 				XFS_FSOP_GEOM_FLAGS_ATTR : 0) |
 			(xfs_sb_version_hasquota(&mp->m_sb) ?
@@ -87,8 +88,6 @@ xfs_fs_geometry(
 				XFS_FSOP_GEOM_FLAGS_SHARED : 0) |
 			(xfs_sb_version_hasextflgbit(&mp->m_sb) ?
 				XFS_FSOP_GEOM_FLAGS_EXTFLG : 0) |
-			(xfs_sb_version_hasdirv2(&mp->m_sb) ?
-				XFS_FSOP_GEOM_FLAGS_DIRV2 : 0) |
 			(xfs_sb_version_hassector(&mp->m_sb) ?
 				XFS_FSOP_GEOM_FLAGS_SECTOR : 0) |
 			(xfs_sb_version_hasasciici(&mp->m_sb) ?
diff --git a/fs/xfs/xfs_sb.c b/fs/xfs/xfs_sb.c
index 8baf61a..de16dd5 100644
--- a/fs/xfs/xfs_sb.c
+++ b/fs/xfs/xfs_sb.c
@@ -333,15 +333,6 @@ xfs_mount_validate_sb(
 		xfs_warn(mp, "Offline file system operation in progress!");
 		return XFS_ERROR(EFSCORRUPTED);
 	}
-
-	/*
-	 * Version 1 directory format has never worked on Linux.
-	 */
-	if (unlikely(!xfs_sb_version_hasdirv2(sbp))) {
-		xfs_warn(mp, "file system using version 1 directory format");
-		return XFS_ERROR(ENOSYS);
-	}
-
 	return 0;
 }
 
diff --git a/fs/xfs/xfs_sb.h b/fs/xfs/xfs_sb.h
index b238a0e..9aa5caa 100644
--- a/fs/xfs/xfs_sb.h
+++ b/fs/xfs/xfs_sb.h
@@ -403,12 +403,6 @@ static inline bool xfs_sb_version_hasshared(struct xfs_sb *sbp)
 		(sbp->sb_versionnum & XFS_SB_VERSION_SHAREDBIT);
 }
 
-static inline bool xfs_sb_version_hasdirv2(struct xfs_sb *sbp)
-{
-	return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 ||
-	       (sbp->sb_versionnum & XFS_SB_VERSION_DIRV2BIT);
-}
-
 static inline bool xfs_sb_version_haslogv2(struct xfs_sb *sbp)
 {
 	return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 ||
-- 
1.9.0

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 5/5] xfs: remove shared supberlock feature checking
  2014-05-06  3:55 [PATCH 0/5] xfs: sanitise supberlock feature bit support Dave Chinner
                   ` (3 preceding siblings ...)
  2014-05-06  3:55 ` [PATCH 4/5] xfs: don't need dirv2 checks anymore Dave Chinner
@ 2014-05-06  3:55 ` Dave Chinner
  2014-05-06  7:48   ` Jeff Liu
  2014-05-06  8:18   ` Christoph Hellwig
  4 siblings, 2 replies; 18+ messages in thread
From: Dave Chinner @ 2014-05-06  3:55 UTC (permalink / raw)
  To: xfs

From: Dave Chinner <dchinner@redhat.com>

We reject any filesystem that is mounted with this feature bit set,
so we don't need to check for it anywhere else. Remove the function
for checking if the feature bit is set and any code that uses it.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 fs/xfs/xfs_fsops.c |  2 --
 fs/xfs/xfs_sb.c    |  3 ++-
 fs/xfs/xfs_sb.h    | 17 ++++-------------
 3 files changed, 6 insertions(+), 16 deletions(-)

diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index b099799..97886a7 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -84,8 +84,6 @@ xfs_fs_geometry(
 				XFS_FSOP_GEOM_FLAGS_IALIGN : 0) |
 			(xfs_sb_version_hasdalign(&mp->m_sb) ?
 				XFS_FSOP_GEOM_FLAGS_DALIGN : 0) |
-			(xfs_sb_version_hasshared(&mp->m_sb) ?
-				XFS_FSOP_GEOM_FLAGS_SHARED : 0) |
 			(xfs_sb_version_hasextflgbit(&mp->m_sb) ?
 				XFS_FSOP_GEOM_FLAGS_EXTFLG : 0) |
 			(xfs_sb_version_hassector(&mp->m_sb) ?
diff --git a/fs/xfs/xfs_sb.c b/fs/xfs/xfs_sb.c
index de16dd5..c3453b1 100644
--- a/fs/xfs/xfs_sb.c
+++ b/fs/xfs/xfs_sb.c
@@ -291,7 +291,8 @@ xfs_mount_validate_sb(
 	    (sbp->sb_imax_pct > 100 /* zero sb_imax_pct is valid */)	||
 	    sbp->sb_dblocks == 0					||
 	    sbp->sb_dblocks > XFS_MAX_DBLOCKS(sbp)			||
-	    sbp->sb_dblocks < XFS_MIN_DBLOCKS(sbp))) {
+	    sbp->sb_dblocks < XFS_MIN_DBLOCKS(sbp)			||
+	    sbp->sb_shared_vn != 0)) {
 		xfs_notice(mp, "SB sanity check failed");
 		return XFS_ERROR(EFSCORRUPTED);
 	}
diff --git a/fs/xfs/xfs_sb.h b/fs/xfs/xfs_sb.h
index 9aa5caa..3fcfc2a 100644
--- a/fs/xfs/xfs_sb.h
+++ b/fs/xfs/xfs_sb.h
@@ -51,11 +51,12 @@ struct xfs_trans;
 
 /*
  * Supported feature bit list is just all bits in the versionnum field because
- * we've used them all up and understand them all.
+ * we've used them all up and understand them all. Except, of course, for the
+ * shared superblock bit, which nobody knows what it does and so is unsupported.
  */
 #define	XFS_SB_VERSION_OKBITS		\
-	(XFS_SB_VERSION_NUMBITS		| \
-	 XFS_SB_VERSION_ALLFBITS)
+	((XFS_SB_VERSION_NUMBITS | XFS_SB_VERSION_ALLFBITS) & \
+		~XFS_SB_VERSION_SHAREDBIT)
 
 /*
  * There are two words to hold XFS "feature" bits: the original
@@ -341,10 +342,6 @@ static inline bool xfs_sb_good_v4_features(struct xfs_sb *sbp)
 	     (sbp->sb_features2 & ~XFS_SB_VERSION2_OKBITS)))
 		return false;
 
-	/* We don't support shared superblocks - nobody knows what it is */
-	if (sbp->sb_versionnum & XFS_SB_VERSION_SHAREDBIT)
-		return false;
-
 	return true;
 }
 
@@ -397,12 +394,6 @@ static inline bool xfs_sb_version_hasdalign(struct xfs_sb *sbp)
 	return (sbp->sb_versionnum & XFS_SB_VERSION_DALIGNBIT);
 }
 
-static inline bool xfs_sb_version_hasshared(struct xfs_sb *sbp)
-{
-	return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
-		(sbp->sb_versionnum & XFS_SB_VERSION_SHAREDBIT);
-}
-
 static inline bool xfs_sb_version_haslogv2(struct xfs_sb *sbp)
 {
 	return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 ||
-- 
1.9.0

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH 5/5] xfs: remove shared supberlock feature checking
  2014-05-06  3:55 ` [PATCH 5/5] xfs: remove shared supberlock feature checking Dave Chinner
@ 2014-05-06  7:48   ` Jeff Liu
  2014-05-06  8:02     ` Dave Chinner
  2014-05-06  8:18   ` Christoph Hellwig
  1 sibling, 1 reply; 18+ messages in thread
From: Jeff Liu @ 2014-05-06  7:48 UTC (permalink / raw)
  To: Dave Chinner, xfs


On 05/06 2014 11:55 AM, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
> 
> We reject any filesystem that is mounted with this feature bit set,
> so we don't need to check for it anywhere else. Remove the function
> for checking if the feature bit is set and any code that uses it.
> 
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> ---
>  fs/xfs/xfs_fsops.c |  2 --
>  fs/xfs/xfs_sb.c    |  3 ++-
>  fs/xfs/xfs_sb.h    | 17 ++++-------------
>  3 files changed, 6 insertions(+), 16 deletions(-)
> 
> diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
> index b099799..97886a7 100644
> --- a/fs/xfs/xfs_fsops.c
> +++ b/fs/xfs/xfs_fsops.c
> @@ -84,8 +84,6 @@ xfs_fs_geometry(
>  				XFS_FSOP_GEOM_FLAGS_IALIGN : 0) |
>  			(xfs_sb_version_hasdalign(&mp->m_sb) ?
>  				XFS_FSOP_GEOM_FLAGS_DALIGN : 0) |
> -			(xfs_sb_version_hasshared(&mp->m_sb) ?
> -				XFS_FSOP_GEOM_FLAGS_SHARED : 0) |

Just a trivial comments, now the XFS_FSOP_GEOM_FLAGS_SHARED is useless, so
we can remove it from fs/xfs/xfs.h.

Otherwise, looks good to me.

Reviewed-by: Jie Liu <jeff.liu@oracle.com>


Cheers,
-Jeff

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 5/5] xfs: remove shared supberlock feature checking
  2014-05-06  7:48   ` Jeff Liu
@ 2014-05-06  8:02     ` Dave Chinner
  0 siblings, 0 replies; 18+ messages in thread
From: Dave Chinner @ 2014-05-06  8:02 UTC (permalink / raw)
  To: Jeff Liu; +Cc: xfs

On Tue, May 06, 2014 at 03:48:43PM +0800, Jeff Liu wrote:
> 
> On 05/06 2014 11:55 AM, Dave Chinner wrote:
> > From: Dave Chinner <dchinner@redhat.com>
> > 
> > We reject any filesystem that is mounted with this feature bit set,
> > so we don't need to check for it anywhere else. Remove the function
> > for checking if the feature bit is set and any code that uses it.
> > 
> > Signed-off-by: Dave Chinner <dchinner@redhat.com>
> > ---
> >  fs/xfs/xfs_fsops.c |  2 --
> >  fs/xfs/xfs_sb.c    |  3 ++-
> >  fs/xfs/xfs_sb.h    | 17 ++++-------------
> >  3 files changed, 6 insertions(+), 16 deletions(-)
> > 
> > diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
> > index b099799..97886a7 100644
> > --- a/fs/xfs/xfs_fsops.c
> > +++ b/fs/xfs/xfs_fsops.c
> > @@ -84,8 +84,6 @@ xfs_fs_geometry(
> >  				XFS_FSOP_GEOM_FLAGS_IALIGN : 0) |
> >  			(xfs_sb_version_hasdalign(&mp->m_sb) ?
> >  				XFS_FSOP_GEOM_FLAGS_DALIGN : 0) |
> > -			(xfs_sb_version_hasshared(&mp->m_sb) ?
> > -				XFS_FSOP_GEOM_FLAGS_SHARED : 0) |
> 
> Just a trivial comments, now the XFS_FSOP_GEOM_FLAGS_SHARED is useless, so
> we can remove it from fs/xfs/xfs.h.

That's a public API header file, so removing it could break
applications. It's OK to leave it there, I think.

> Otherwise, looks good to me.
> 
> Reviewed-by: Jie Liu <jeff.liu@oracle.com>

Thanks!

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 3/5] xfs: turn NLINK feature on by default
  2014-05-06  3:55 ` [PATCH 3/5] xfs: turn NLINK feature on by default Dave Chinner
@ 2014-05-06  8:15   ` Christoph Hellwig
  2014-05-06  9:06     ` Dave Chinner
  0 siblings, 1 reply; 18+ messages in thread
From: Christoph Hellwig @ 2014-05-06  8:15 UTC (permalink / raw)
  To: Dave Chinner; +Cc: xfs

>  
> @@ -1112,7 +1085,7 @@ xfs_bumplink(
>  		 * system to do this, then we need to bump the superblock
>  		 * version number as well.
>  		 */
> -		xfs_bump_ino_vers2(tp, ip);
> +		xfs_bump_ino_vers2(ip);

The comment here is certainly out of date now.

But I think keeping these xfs_bump_ino_vers2 calls around everywhere is
wrong to start with.  xfs_iread should make sure all inodes are version
1, that allows to kill xfs_bump_ino_vers2 entirely, and probably also
simplify xfs_ialloc a little more.  At the point we won't have to deal
with v1 inodes anywhere but in xfs_iread, and we can have a big fat
comment in that place why we even bother with the v1 inodes, because
the fact that we have the hasnlink bit but inodes might still be old
format is something we'll all have forgotten about in a few years,
and new developers will never figure out by themselves.

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 4/5] xfs: don't need dirv2 checks anymore
  2014-05-06  3:55 ` [PATCH 4/5] xfs: don't need dirv2 checks anymore Dave Chinner
@ 2014-05-06  8:16   ` Christoph Hellwig
  2014-05-06  8:45     ` Dave Chinner
  0 siblings, 1 reply; 18+ messages in thread
From: Christoph Hellwig @ 2014-05-06  8:16 UTC (permalink / raw)
  To: Dave Chinner; +Cc: xfs

> -	ASSERT(xfs_sb_version_hasdirv2(&mp->m_sb));
> +	ASSERT(mp->m_sb.sb_versionnum & XFS_SB_VERSION_DIRV2BIT);

How is this going to work for v5 filesystems?  Probably better to just
kill the assert..

Otherwise looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 5/5] xfs: remove shared supberlock feature checking
  2014-05-06  3:55 ` [PATCH 5/5] xfs: remove shared supberlock feature checking Dave Chinner
  2014-05-06  7:48   ` Jeff Liu
@ 2014-05-06  8:18   ` Christoph Hellwig
  2014-05-06  8:28     ` Dave Chinner
  1 sibling, 1 reply; 18+ messages in thread
From: Christoph Hellwig @ 2014-05-06  8:18 UTC (permalink / raw)
  To: Dave Chinner; +Cc: xfs

On Tue, May 06, 2014 at 01:55:59PM +1000, Dave Chinner wrote:
> 
> We reject any filesystem that is mounted with this feature bit set,
> so we don't need to check for it anywhere else. Remove the function
> for checking if the feature bit is set and any code that uses it.
> 
> Signed-off-by: Dave Chinner <dchinner@redhat.com>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

If someone at SGI has some spare time for a BugWorks search I'd really
love to figure out of the story behind the shared superblock feature..

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 2/5] xfs: keep sb_bad_features2 the same a sb_features2
  2014-05-06  3:55 ` [PATCH 2/5] xfs: keep sb_bad_features2 the same a sb_features2 Dave Chinner
@ 2014-05-06  8:20   ` Christoph Hellwig
  0 siblings, 0 replies; 18+ messages in thread
From: Christoph Hellwig @ 2014-05-06  8:20 UTC (permalink / raw)
  To: Dave Chinner; +Cc: xfs

On Tue, May 06, 2014 at 01:55:56PM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
> 
> Whenever we update sb_features2, we need to update sb_bad_features2
> so that they remain identical on disk. This prevents future mounts
> or userspace utilities from getting confused over which features the
> filesystem supports.
> 
> Signed-off-by: Dave Chinner <dchinner@redhat.com>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 5/5] xfs: remove shared supberlock feature checking
  2014-05-06  8:18   ` Christoph Hellwig
@ 2014-05-06  8:28     ` Dave Chinner
  0 siblings, 0 replies; 18+ messages in thread
From: Dave Chinner @ 2014-05-06  8:28 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: xfs

On Tue, May 06, 2014 at 01:18:20AM -0700, Christoph Hellwig wrote:
> On Tue, May 06, 2014 at 01:55:59PM +1000, Dave Chinner wrote:
> > 
> > We reject any filesystem that is mounted with this feature bit set,
> > so we don't need to check for it anywhere else. Remove the function
> > for checking if the feature bit is set and any code that uses it.
> > 
> > Signed-off-by: Dave Chinner <dchinner@redhat.com>
> 
> Looks good,
> 
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> 
> If someone at SGI has some spare time for a BugWorks search I'd really
> love to figure out of the story behind the shared superblock feature..

http://oss.sgi.com/cgi-bin/gitweb.cgi?p=archive/xfs-import.git;a=commitdiff;h=9ea7d56d2db84bd45183c4ab11903b97c5b9a8e9

tells us that the PV to start looking at is 522678. It's something
to do with shared read-only filesystems - I suspect the sb_shared_vn
field counts the number of read-only mounts - and my guess is it was
for Cellular Irix. i.e. SGI's aborted attempt to make a distributed
operating system that left useless crap all through the Irix 6.5
codebase...

Cheers,

Dve.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/5] xfs: make superblock version checks reflect reality
  2014-05-06  3:55 ` [PATCH 1/5] xfs: make superblock version checks reflect reality Dave Chinner
@ 2014-05-06  8:29   ` Christoph Hellwig
  2014-05-06  8:39     ` Dave Chinner
  0 siblings, 1 reply; 18+ messages in thread
From: Christoph Hellwig @ 2014-05-06  8:29 UTC (permalink / raw)
  To: Dave Chinner; +Cc: xfs

> +/*
> + * The first XFS version we support is a v4 superblock with V2 directories.
> + */
> +static inline bool xfs_sb_good_v4_features(struct xfs_sb *sbp)
>  {
> +	if (!(sbp->sb_versionnum & XFS_SB_VERSION_DIRV2BIT))
> +		return false;
>  
> +	/* check for unknown features in the fs */
> +	if ((sbp->sb_versionnum & ~XFS_SB_VERSION_OKBITS) ||

Given that sb_versionnum is a __uint16_t and XFS_SB_VERSION_OKBITS is
0xffff this will never evaluate to false and a sane compiler should warn
about it.  How about remove this check and XFS_SB_VERSION_OKBITS?

The various has_ macros are a bit confusing to me, as some explicitly
check for 5 superblocks, and some assume the caller handles them in
some way, but I think this is something we can leave for later cleanups.

>   * For example, for a bit defined as XFS_SB_VERSION2_FUNBIT, has a macro:
>   *
> - * SB_VERSION_HASFUNBIT(xfs_sb_t *sbp)
> + * SB_VERSION_HASFUNBIT(struct xfs_sb *sbp)

>   *	((xfs_sb_version_hasmorebits(sbp) &&
>   *	 ((sbp)->sb_features2 & XFS_SB_VERSION2_FUNBIT)
>   */

This should be updated to the lowe case convention inlines we've used
for a long time.  Or just removed as new features should go into v5
superblocks..

Modulo these minor bits:

Reviewed-by: Christoph Hellwig <hch@lst.de>

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/5] xfs: make superblock version checks reflect reality
  2014-05-06  8:29   ` Christoph Hellwig
@ 2014-05-06  8:39     ` Dave Chinner
  0 siblings, 0 replies; 18+ messages in thread
From: Dave Chinner @ 2014-05-06  8:39 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: xfs

On Tue, May 06, 2014 at 01:29:48AM -0700, Christoph Hellwig wrote:
> > +/*
> > + * The first XFS version we support is a v4 superblock with V2 directories.
> > + */
> > +static inline bool xfs_sb_good_v4_features(struct xfs_sb *sbp)
> >  {
> > +	if (!(sbp->sb_versionnum & XFS_SB_VERSION_DIRV2BIT))
> > +		return false;
> >  
> > +	/* check for unknown features in the fs */
> > +	if ((sbp->sb_versionnum & ~XFS_SB_VERSION_OKBITS) ||
> 
> Given that sb_versionnum is a __uint16_t and XFS_SB_VERSION_OKBITS is
> 0xffff this will never evaluate to false and a sane compiler should warn
> about it.  How about remove this check and XFS_SB_VERSION_OKBITS?

It gets changed later to this:

#define XFS_SB_VERSION_OKBITS           \
        ((XFS_SB_VERSION_NUMBITS | XFS_SB_VERSION_ALLFBITS) & \
		~XFS_SB_VERSION_SHAREDBIT)

So we don't ever consider the shared bit valid. IOWs, it's not
0xffff ;)

> The various has_ macros are a bit confusing to me, as some explicitly
> check for 5 superblocks, and some assume the caller handles them in
> some way, but I think this is something we can leave for later cleanups.
> 
> >   * For example, for a bit defined as XFS_SB_VERSION2_FUNBIT, has a macro:
> >   *
> > - * SB_VERSION_HASFUNBIT(xfs_sb_t *sbp)
> > + * SB_VERSION_HASFUNBIT(struct xfs_sb *sbp)
> 
> >   *	((xfs_sb_version_hasmorebits(sbp) &&
> >   *	 ((sbp)->sb_features2 & XFS_SB_VERSION2_FUNBIT)
> >   */
> 
> This should be updated to the lowe case convention inlines we've used
> for a long time.  Or just removed as new features should go into v5
> superblocks..

I'll update it.

> Modulo these minor bits:
> 
> Reviewed-by: Christoph Hellwig <hch@lst.de>

Thanks!

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 4/5] xfs: don't need dirv2 checks anymore
  2014-05-06  8:16   ` Christoph Hellwig
@ 2014-05-06  8:45     ` Dave Chinner
  0 siblings, 0 replies; 18+ messages in thread
From: Dave Chinner @ 2014-05-06  8:45 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: xfs

On Tue, May 06, 2014 at 01:16:52AM -0700, Christoph Hellwig wrote:
> > -	ASSERT(xfs_sb_version_hasdirv2(&mp->m_sb));
> > +	ASSERT(mp->m_sb.sb_versionnum & XFS_SB_VERSION_DIRV2BIT);
> 
> How is this going to work for v5 filesystems?  Probably better to just
> kill the assert..

mkfs still sets the sb_features bitmask for all the supported v4
features it uses by default on v5 superblocks. There are some
feature bits in the v4 mask that are optional for v5 superblocks,
too (e.g. case insensitivity, sunit/swidth alignment), so we won't
ever stop setting the XFS_SB_VERSION_DIRV2BIT on v5 superblocks...

> Otherwise looks good,
> 
> Reviewed-by: Christoph Hellwig <hch@lst.de>

Thanks!

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 3/5] xfs: turn NLINK feature on by default
  2014-05-06  8:15   ` Christoph Hellwig
@ 2014-05-06  9:06     ` Dave Chinner
  0 siblings, 0 replies; 18+ messages in thread
From: Dave Chinner @ 2014-05-06  9:06 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: xfs

On Tue, May 06, 2014 at 01:15:18AM -0700, Christoph Hellwig wrote:
> >  
> > @@ -1112,7 +1085,7 @@ xfs_bumplink(
> >  		 * system to do this, then we need to bump the superblock
> >  		 * version number as well.
> >  		 */
> > -		xfs_bump_ino_vers2(tp, ip);
> > +		xfs_bump_ino_vers2(ip);
> 
> The comment here is certainly out of date now.
> 
> But I think keeping these xfs_bump_ino_vers2 calls around everywhere is
> wrong to start with.  xfs_iread should make sure all inodes are version
> 1, that allows to kill xfs_bump_ino_vers2 entirely, and probably also
> simplify xfs_ialloc a little more.  At the point we won't have to deal
> with v1 inodes anywhere but in xfs_iread, and we can have a big fat
> comment in that place why we even bother with the v1 inodes, because
> the fact that we have the hasnlink bit but inodes might still be old
> format is something we'll all have forgotten about in a few years,
> and new developers will never figure out by themselves.

OK, I'll look at reworking it aong those lines.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 5/5] xfs: remove shared supberlock feature checking
  2014-05-16 23:00 [PATCH 0/5 V2] xfs: sanitise superblock feature bit support Dave Chinner
@ 2014-05-16 23:00 ` Dave Chinner
  0 siblings, 0 replies; 18+ messages in thread
From: Dave Chinner @ 2014-05-16 23:00 UTC (permalink / raw)
  To: xfs

From: Dave Chinner <dchinner@redhat.com>

We reject any filesystem that is mounted with this feature bit set,
so we don't need to check for it anywhere else. Remove the function
for checking if the feature bit is set and any code that uses it.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jie Liu <jeff.liu@oracle.com>
---
 fs/xfs/xfs_fsops.c |  2 --
 fs/xfs/xfs_sb.c    |  3 ++-
 fs/xfs/xfs_sb.h    | 17 ++++-------------
 3 files changed, 6 insertions(+), 16 deletions(-)

diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index b099799..97886a7 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -84,8 +84,6 @@ xfs_fs_geometry(
 				XFS_FSOP_GEOM_FLAGS_IALIGN : 0) |
 			(xfs_sb_version_hasdalign(&mp->m_sb) ?
 				XFS_FSOP_GEOM_FLAGS_DALIGN : 0) |
-			(xfs_sb_version_hasshared(&mp->m_sb) ?
-				XFS_FSOP_GEOM_FLAGS_SHARED : 0) |
 			(xfs_sb_version_hasextflgbit(&mp->m_sb) ?
 				XFS_FSOP_GEOM_FLAGS_EXTFLG : 0) |
 			(xfs_sb_version_hassector(&mp->m_sb) ?
diff --git a/fs/xfs/xfs_sb.c b/fs/xfs/xfs_sb.c
index de16dd5..c3453b1 100644
--- a/fs/xfs/xfs_sb.c
+++ b/fs/xfs/xfs_sb.c
@@ -291,7 +291,8 @@ xfs_mount_validate_sb(
 	    (sbp->sb_imax_pct > 100 /* zero sb_imax_pct is valid */)	||
 	    sbp->sb_dblocks == 0					||
 	    sbp->sb_dblocks > XFS_MAX_DBLOCKS(sbp)			||
-	    sbp->sb_dblocks < XFS_MIN_DBLOCKS(sbp))) {
+	    sbp->sb_dblocks < XFS_MIN_DBLOCKS(sbp)			||
+	    sbp->sb_shared_vn != 0)) {
 		xfs_notice(mp, "SB sanity check failed");
 		return XFS_ERROR(EFSCORRUPTED);
 	}
diff --git a/fs/xfs/xfs_sb.h b/fs/xfs/xfs_sb.h
index 2344825..c43c2d6 100644
--- a/fs/xfs/xfs_sb.h
+++ b/fs/xfs/xfs_sb.h
@@ -51,11 +51,12 @@ struct xfs_trans;
 
 /*
  * Supported feature bit list is just all bits in the versionnum field because
- * we've used them all up and understand them all.
+ * we've used them all up and understand them all. Except, of course, for the
+ * shared superblock bit, which nobody knows what it does and so is unsupported.
  */
 #define	XFS_SB_VERSION_OKBITS		\
-	(XFS_SB_VERSION_NUMBITS		| \
-	 XFS_SB_VERSION_ALLFBITS)
+	((XFS_SB_VERSION_NUMBITS | XFS_SB_VERSION_ALLFBITS) & \
+		~XFS_SB_VERSION_SHAREDBIT)
 
 /*
  * There are two words to hold XFS "feature" bits: the original
@@ -341,10 +342,6 @@ static inline bool xfs_sb_good_v4_features(struct xfs_sb *sbp)
 	     (sbp->sb_features2 & ~XFS_SB_VERSION2_OKBITS)))
 		return false;
 
-	/* We don't support shared superblocks - nobody knows what it is */
-	if (sbp->sb_versionnum & XFS_SB_VERSION_SHAREDBIT)
-		return false;
-
 	return true;
 }
 
@@ -397,12 +394,6 @@ static inline bool xfs_sb_version_hasdalign(struct xfs_sb *sbp)
 	return (sbp->sb_versionnum & XFS_SB_VERSION_DALIGNBIT);
 }
 
-static inline bool xfs_sb_version_hasshared(struct xfs_sb *sbp)
-{
-	return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
-		(sbp->sb_versionnum & XFS_SB_VERSION_SHAREDBIT);
-}
-
 static inline bool xfs_sb_version_haslogv2(struct xfs_sb *sbp)
 {
 	return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 ||
-- 
1.9.0

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2014-05-16 23:01 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-06  3:55 [PATCH 0/5] xfs: sanitise supberlock feature bit support Dave Chinner
2014-05-06  3:55 ` [PATCH 1/5] xfs: make superblock version checks reflect reality Dave Chinner
2014-05-06  8:29   ` Christoph Hellwig
2014-05-06  8:39     ` Dave Chinner
2014-05-06  3:55 ` [PATCH 2/5] xfs: keep sb_bad_features2 the same a sb_features2 Dave Chinner
2014-05-06  8:20   ` Christoph Hellwig
2014-05-06  3:55 ` [PATCH 3/5] xfs: turn NLINK feature on by default Dave Chinner
2014-05-06  8:15   ` Christoph Hellwig
2014-05-06  9:06     ` Dave Chinner
2014-05-06  3:55 ` [PATCH 4/5] xfs: don't need dirv2 checks anymore Dave Chinner
2014-05-06  8:16   ` Christoph Hellwig
2014-05-06  8:45     ` Dave Chinner
2014-05-06  3:55 ` [PATCH 5/5] xfs: remove shared supberlock feature checking Dave Chinner
2014-05-06  7:48   ` Jeff Liu
2014-05-06  8:02     ` Dave Chinner
2014-05-06  8:18   ` Christoph Hellwig
2014-05-06  8:28     ` Dave Chinner
2014-05-16 23:00 [PATCH 0/5 V2] xfs: sanitise superblock feature bit support Dave Chinner
2014-05-16 23:00 ` [PATCH 5/5] xfs: remove shared supberlock feature checking Dave Chinner

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.