Commit 5efcbb85 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Niv Sardi

cleanup xfs_sb.h feature flag helpers

The various inlines in xfs_sb.h that deal with the superblock version
and fature flags were converted from macros a while ago, and this
show by the odd coding style full of useless braces and backslashes
and the avoidance of conditionals.

Clean these up to look like normal C code.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDonald Douwsma <donaldd@sgi.com>
Signed-off-by: default avatarNiv Sardi <xaiki@sgi.com>
parent df6771bd
...@@ -296,30 +296,34 @@ typedef enum { ...@@ -296,30 +296,34 @@ typedef enum {
#define XFS_SB_VERSION_NUM(sbp) ((sbp)->sb_versionnum & XFS_SB_VERSION_NUMBITS) #define XFS_SB_VERSION_NUM(sbp) ((sbp)->sb_versionnum & XFS_SB_VERSION_NUMBITS)
#ifdef __KERNEL__
static inline int xfs_sb_good_version(xfs_sb_t *sbp) static inline int xfs_sb_good_version(xfs_sb_t *sbp)
{ {
return (((sbp->sb_versionnum >= XFS_SB_VERSION_1) && \ /* We always support version 1-3 */
(sbp->sb_versionnum <= XFS_SB_VERSION_3)) || \ if (sbp->sb_versionnum >= XFS_SB_VERSION_1 &&
((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ sbp->sb_versionnum <= XFS_SB_VERSION_3)
!((sbp->sb_versionnum & ~XFS_SB_VERSION_OKREALBITS) || \ return 1;
((sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT) && \
(sbp->sb_features2 & ~XFS_SB_VERSION2_OKREALBITS))) && \ /* We support version 4 if all feature bits are supported */
(sbp->sb_shared_vn <= XFS_SB_MAX_SHARED_VN))); 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;
#ifdef __KERNEL__
if (sbp->sb_shared_vn > XFS_SB_MAX_SHARED_VN)
return 0;
#else #else
static inline int xfs_sb_good_version(xfs_sb_t *sbp) if ((sbp->sb_versionnum & XFS_SB_VERSION_SHAREDBIT) &&
{ sbp->sb_shared_vn > XFS_SB_MAX_SHARED_VN)
return (((sbp->sb_versionnum >= XFS_SB_VERSION_1) && \ return 0;
(sbp->sb_versionnum <= XFS_SB_VERSION_3)) || \ #endif
((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
!((sbp->sb_versionnum & ~XFS_SB_VERSION_OKREALBITS) || \ return 1;
((sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT) && \ }
(sbp->sb_features2 & ~XFS_SB_VERSION2_OKREALBITS))) && \
(!(sbp->sb_versionnum & XFS_SB_VERSION_SHAREDBIT) || \ return 0;
(sbp->sb_shared_vn <= XFS_SB_MAX_SHARED_VN))));
} }
#endif /* __KERNEL__ */
/* /*
* Detect a mismatched features2 field. Older kernels read/wrote * Detect a mismatched features2 field. Older kernels read/wrote
...@@ -332,123 +336,127 @@ static inline int xfs_sb_has_mismatched_features2(xfs_sb_t *sbp) ...@@ -332,123 +336,127 @@ static inline int xfs_sb_has_mismatched_features2(xfs_sb_t *sbp)
static inline unsigned xfs_sb_version_tonew(unsigned v) static inline unsigned xfs_sb_version_tonew(unsigned v)
{ {
return ((((v) == XFS_SB_VERSION_1) ? \ if (v == XFS_SB_VERSION_1)
0 : \ return XFS_SB_VERSION_4;
(((v) == XFS_SB_VERSION_2) ? \
XFS_SB_VERSION_ATTRBIT : \ if (v == XFS_SB_VERSION_2)
(XFS_SB_VERSION_ATTRBIT | XFS_SB_VERSION_NLINKBIT))) | \ return XFS_SB_VERSION_4 | XFS_SB_VERSION_ATTRBIT;
XFS_SB_VERSION_4);
return XFS_SB_VERSION_4 | XFS_SB_VERSION_ATTRBIT |
XFS_SB_VERSION_NLINKBIT;
} }
static inline unsigned xfs_sb_version_toold(unsigned v) static inline unsigned xfs_sb_version_toold(unsigned v)
{ {
return (((v) & (XFS_SB_VERSION_QUOTABIT | XFS_SB_VERSION_ALIGNBIT)) ? \ if (v & (XFS_SB_VERSION_QUOTABIT | XFS_SB_VERSION_ALIGNBIT))
0 : \ return 0;
(((v) & XFS_SB_VERSION_NLINKBIT) ? \ if (v & XFS_SB_VERSION_NLINKBIT)
XFS_SB_VERSION_3 : \ return XFS_SB_VERSION_3;
(((v) & XFS_SB_VERSION_ATTRBIT) ? \ if (v & XFS_SB_VERSION_ATTRBIT)
XFS_SB_VERSION_2 : \ return XFS_SB_VERSION_2;
XFS_SB_VERSION_1))); return XFS_SB_VERSION_1;
} }
static inline int xfs_sb_version_hasattr(xfs_sb_t *sbp) static inline int xfs_sb_version_hasattr(xfs_sb_t *sbp)
{ {
return ((sbp)->sb_versionnum == XFS_SB_VERSION_2) || \ return sbp->sb_versionnum == XFS_SB_VERSION_2 ||
((sbp)->sb_versionnum == XFS_SB_VERSION_3) || \ sbp->sb_versionnum == XFS_SB_VERSION_3 ||
((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
((sbp)->sb_versionnum & XFS_SB_VERSION_ATTRBIT)); (sbp->sb_versionnum & XFS_SB_VERSION_ATTRBIT));
} }
static inline void xfs_sb_version_addattr(xfs_sb_t *sbp) static inline void xfs_sb_version_addattr(xfs_sb_t *sbp)
{ {
(sbp)->sb_versionnum = (((sbp)->sb_versionnum == XFS_SB_VERSION_1) ? \ if (sbp->sb_versionnum == XFS_SB_VERSION_1)
XFS_SB_VERSION_2 : \ sbp->sb_versionnum = XFS_SB_VERSION_2;
((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) ? \ else if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4)
((sbp)->sb_versionnum | XFS_SB_VERSION_ATTRBIT) : \ sbp->sb_versionnum |= XFS_SB_VERSION_ATTRBIT;
(XFS_SB_VERSION_4 | XFS_SB_VERSION_ATTRBIT))); else
sbp->sb_versionnum = XFS_SB_VERSION_4 | XFS_SB_VERSION_ATTRBIT;
} }
static inline int xfs_sb_version_hasnlink(xfs_sb_t *sbp) static inline int xfs_sb_version_hasnlink(xfs_sb_t *sbp)
{ {
return ((sbp)->sb_versionnum == XFS_SB_VERSION_3) || \ return sbp->sb_versionnum == XFS_SB_VERSION_3 ||
((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
((sbp)->sb_versionnum & XFS_SB_VERSION_NLINKBIT)); (sbp->sb_versionnum & XFS_SB_VERSION_NLINKBIT));
} }
static inline void xfs_sb_version_addnlink(xfs_sb_t *sbp) static inline void xfs_sb_version_addnlink(xfs_sb_t *sbp)
{ {
(sbp)->sb_versionnum = ((sbp)->sb_versionnum <= XFS_SB_VERSION_2 ? \ if (sbp->sb_versionnum <= XFS_SB_VERSION_2)
XFS_SB_VERSION_3 : \ sbp->sb_versionnum = XFS_SB_VERSION_3;
((sbp)->sb_versionnum | XFS_SB_VERSION_NLINKBIT)); else
sbp->sb_versionnum |= XFS_SB_VERSION_NLINKBIT;
} }
static inline int xfs_sb_version_hasquota(xfs_sb_t *sbp) static inline int xfs_sb_version_hasquota(xfs_sb_t *sbp)
{ {
return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
((sbp)->sb_versionnum & XFS_SB_VERSION_QUOTABIT); (sbp->sb_versionnum & XFS_SB_VERSION_QUOTABIT);
} }
static inline void xfs_sb_version_addquota(xfs_sb_t *sbp) static inline void xfs_sb_version_addquota(xfs_sb_t *sbp)
{ {
(sbp)->sb_versionnum = \ if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4)
(XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 ? \ sbp->sb_versionnum |= XFS_SB_VERSION_QUOTABIT;
((sbp)->sb_versionnum | XFS_SB_VERSION_QUOTABIT) : \ else
(xfs_sb_version_tonew((sbp)->sb_versionnum) | \ sbp->sb_versionnum = xfs_sb_version_tonew(sbp->sb_versionnum) |
XFS_SB_VERSION_QUOTABIT)); XFS_SB_VERSION_QUOTABIT;
} }
static inline int xfs_sb_version_hasalign(xfs_sb_t *sbp) static inline int xfs_sb_version_hasalign(xfs_sb_t *sbp)
{ {
return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
((sbp)->sb_versionnum & XFS_SB_VERSION_ALIGNBIT); (sbp->sb_versionnum & XFS_SB_VERSION_ALIGNBIT);
} }
static inline int xfs_sb_version_hasdalign(xfs_sb_t *sbp) static inline int xfs_sb_version_hasdalign(xfs_sb_t *sbp)
{ {
return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
((sbp)->sb_versionnum & XFS_SB_VERSION_DALIGNBIT); (sbp->sb_versionnum & XFS_SB_VERSION_DALIGNBIT);
} }
static inline int xfs_sb_version_hasshared(xfs_sb_t *sbp) static inline int xfs_sb_version_hasshared(xfs_sb_t *sbp)
{ {
return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
((sbp)->sb_versionnum & XFS_SB_VERSION_SHAREDBIT); (sbp->sb_versionnum & XFS_SB_VERSION_SHAREDBIT);
} }
static inline int xfs_sb_version_hasdirv2(xfs_sb_t *sbp) static inline int xfs_sb_version_hasdirv2(xfs_sb_t *sbp)
{ {
return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
((sbp)->sb_versionnum & XFS_SB_VERSION_DIRV2BIT); (sbp->sb_versionnum & XFS_SB_VERSION_DIRV2BIT);
} }
static inline int xfs_sb_version_haslogv2(xfs_sb_t *sbp) static inline int xfs_sb_version_haslogv2(xfs_sb_t *sbp)
{ {
return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
((sbp)->sb_versionnum & XFS_SB_VERSION_LOGV2BIT); (sbp->sb_versionnum & XFS_SB_VERSION_LOGV2BIT);
} }
static inline int xfs_sb_version_hasextflgbit(xfs_sb_t *sbp) static inline int xfs_sb_version_hasextflgbit(xfs_sb_t *sbp)
{ {
return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
((sbp)->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT); (sbp->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT);
} }
static inline int xfs_sb_version_hassector(xfs_sb_t *sbp) static inline int xfs_sb_version_hassector(xfs_sb_t *sbp)
{ {
return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
((sbp)->sb_versionnum & XFS_SB_VERSION_SECTORBIT); (sbp->sb_versionnum & XFS_SB_VERSION_SECTORBIT);
} }
static inline int xfs_sb_version_hasasciici(xfs_sb_t *sbp) static inline int xfs_sb_version_hasasciici(xfs_sb_t *sbp)
{ {
return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
(sbp->sb_versionnum & XFS_SB_VERSION_BORGBIT); (sbp->sb_versionnum & XFS_SB_VERSION_BORGBIT);
} }
static inline int xfs_sb_version_hasmorebits(xfs_sb_t *sbp) static inline int xfs_sb_version_hasmorebits(xfs_sb_t *sbp)
{ {
return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
((sbp)->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT); (sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT);
} }
/* /*
...@@ -463,22 +471,20 @@ static inline int xfs_sb_version_hasmorebits(xfs_sb_t *sbp) ...@@ -463,22 +471,20 @@ static inline int xfs_sb_version_hasmorebits(xfs_sb_t *sbp)
static inline int xfs_sb_version_haslazysbcount(xfs_sb_t *sbp) static inline int xfs_sb_version_haslazysbcount(xfs_sb_t *sbp)
{ {
return (xfs_sb_version_hasmorebits(sbp) && \ return xfs_sb_version_hasmorebits(sbp) &&
((sbp)->sb_features2 & XFS_SB_VERSION2_LAZYSBCOUNTBIT)); (sbp->sb_features2 & XFS_SB_VERSION2_LAZYSBCOUNTBIT);
} }
static inline int xfs_sb_version_hasattr2(xfs_sb_t *sbp) static inline int xfs_sb_version_hasattr2(xfs_sb_t *sbp)
{ {
return (xfs_sb_version_hasmorebits(sbp)) && \ return xfs_sb_version_hasmorebits(sbp) &&
((sbp)->sb_features2 & XFS_SB_VERSION2_ATTR2BIT); (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(xfs_sb_t *sbp)
{ {
((sbp)->sb_versionnum = \ sbp->sb_versionnum |= XFS_SB_VERSION_MOREBITSBIT;
((sbp)->sb_versionnum | XFS_SB_VERSION_MOREBITSBIT), \ sbp->sb_features2 |= XFS_SB_VERSION2_ATTR2BIT;
((sbp)->sb_features2 = \
((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(xfs_sb_t *sbp)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment