From: "Darrick J. Wong" <djwong@kernel.org>
To: sandeen@sandeen.net, djwong@kernel.org
Cc: Dave Chinner <dchinner@redhat.com>, linux-xfs@vger.kernel.org
Subject: [PATCH 25/43] xfs: convert mount flags to features
Date: Mon, 13 Sep 2021 19:42:16 -0700 [thread overview]
Message-ID: <163158733660.1604118.8914008454755284421.stgit@magnolia> (raw)
In-Reply-To: <163158719952.1604118.14415288328687941574.stgit@magnolia>
From: Dave Chinner <dchinner@redhat.com>
Source kernel commit: 0560f31a09e523090d1ab2bfe21c69d028c2bdf2
Replace m_flags feature checks with xfs_has_<feature>() calls and
rework the setup code to set flags in m_features.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
include/xfs_mount.h | 11 +++++++++++
libxfs/xfs_attr.c | 4 ++--
libxfs/xfs_attr_leaf.c | 41 +++++++++++++++++++++++------------------
libxfs/xfs_bmap.c | 4 ++--
libxfs/xfs_ialloc.c | 10 ++++------
5 files changed, 42 insertions(+), 28 deletions(-)
diff --git a/include/xfs_mount.h b/include/xfs_mount.h
index 351ceaef..aed31404 100644
--- a/include/xfs_mount.h
+++ b/include/xfs_mount.h
@@ -194,6 +194,17 @@ __XFS_HAS_FEAT(inobtcounts, INOBTCNT)
__XFS_HAS_FEAT(bigtime, BIGTIME)
__XFS_HAS_FEAT(needsrepair, NEEDSREPAIR)
+/* Kernel mount features that we don't support */
+#define __XFS_UNSUPP_FEAT(name) \
+static inline bool xfs_has_ ## name (struct xfs_mount *mp) \
+{ \
+ return false; \
+}
+__XFS_UNSUPP_FEAT(wsync)
+__XFS_UNSUPP_FEAT(noattr2)
+__XFS_UNSUPP_FEAT(ikeep)
+__XFS_UNSUPP_FEAT(swalloc)
+
#define LIBXFS_MOUNT_DEBUGGER 0x0001
#define LIBXFS_MOUNT_32BITINODES 0x0002
#define LIBXFS_MOUNT_32BITINOOPT 0x0004
diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c
index 07b19652..3a712e36 100644
--- a/libxfs/xfs_attr.c
+++ b/libxfs/xfs_attr.c
@@ -224,7 +224,7 @@ xfs_attr_try_sf_addname(
if (!error && !(args->op_flags & XFS_DA_OP_NOTIME))
xfs_trans_ichgtime(args->trans, dp, XFS_ICHGTIME_CHG);
- if (dp->i_mount->m_flags & XFS_MOUNT_WSYNC)
+ if (xfs_has_wsync(dp->i_mount))
xfs_trans_set_sync(args->trans);
return error;
@@ -808,7 +808,7 @@ xfs_attr_set(
* If this is a synchronous mount, make sure that the
* transaction goes to disk before returning to the user.
*/
- if (mp->m_flags & XFS_MOUNT_WSYNC)
+ if (xfs_has_wsync(mp))
xfs_trans_set_sync(args->trans);
if (!(args->op_flags & XFS_DA_OP_NOTIME))
diff --git a/libxfs/xfs_attr_leaf.c b/libxfs/xfs_attr_leaf.c
index 3fff838e..308fc0f7 100644
--- a/libxfs/xfs_attr_leaf.c
+++ b/libxfs/xfs_attr_leaf.c
@@ -565,7 +565,7 @@ xfs_attr_shortform_bytesfit(
* literal area, but for the old format we are done if there is no
* space in the fixed attribute fork.
*/
- if (!(mp->m_flags & XFS_MOUNT_ATTR2))
+ if (!xfs_has_attr2(mp))
return 0;
dsize = dp->i_df.if_bytes;
@@ -618,21 +618,27 @@ xfs_attr_shortform_bytesfit(
}
/*
- * Switch on the ATTR2 superblock bit (implies also FEATURES2)
+ * Switch on the ATTR2 superblock bit (implies also FEATURES2) unless:
+ * - noattr2 mount option is set,
+ * - on-disk version bit says it is already set, or
+ * - the attr2 mount option is not set to enable automatic upgrade from attr1.
*/
STATIC void
-xfs_sbversion_add_attr2(xfs_mount_t *mp, xfs_trans_t *tp)
+xfs_sbversion_add_attr2(
+ struct xfs_mount *mp,
+ struct xfs_trans *tp)
{
- if ((mp->m_flags & XFS_MOUNT_ATTR2) &&
- !(xfs_has_attr2(mp))) {
- spin_lock(&mp->m_sb_lock);
- if (!xfs_has_attr2(mp)) {
- xfs_add_attr2(mp);
- spin_unlock(&mp->m_sb_lock);
- xfs_log_sb(tp);
- } else
- spin_unlock(&mp->m_sb_lock);
- }
+ if (xfs_has_noattr2(mp))
+ return;
+ if (mp->m_sb.sb_features2 & XFS_SB_VERSION2_ATTR2BIT)
+ return;
+ if (!xfs_has_attr2(mp))
+ return;
+
+ spin_lock(&mp->m_sb_lock);
+ xfs_add_attr2(mp);
+ spin_unlock(&mp->m_sb_lock);
+ xfs_log_sb(tp);
}
/*
@@ -807,8 +813,7 @@ xfs_attr_sf_removename(
* Fix up the start offset of the attribute fork
*/
totsize -= size;
- if (totsize == sizeof(xfs_attr_sf_hdr_t) &&
- (mp->m_flags & XFS_MOUNT_ATTR2) &&
+ if (totsize == sizeof(xfs_attr_sf_hdr_t) && xfs_has_attr2(mp) &&
(dp->i_df.if_format != XFS_DINODE_FMT_BTREE) &&
!(args->op_flags & XFS_DA_OP_ADDNAME)) {
xfs_attr_fork_remove(dp, args->trans);
@@ -818,7 +823,7 @@ xfs_attr_sf_removename(
ASSERT(dp->i_forkoff);
ASSERT(totsize > sizeof(xfs_attr_sf_hdr_t) ||
(args->op_flags & XFS_DA_OP_ADDNAME) ||
- !(mp->m_flags & XFS_MOUNT_ATTR2) ||
+ !xfs_has_attr2(mp) ||
dp->i_df.if_format == XFS_DINODE_FMT_BTREE);
xfs_trans_log_inode(args->trans, dp,
XFS_ILOG_CORE | XFS_ILOG_ADATA);
@@ -994,7 +999,7 @@ xfs_attr_shortform_allfit(
bytes += xfs_attr_sf_entsize_byname(name_loc->namelen,
be16_to_cpu(name_loc->valuelen));
}
- if ((dp->i_mount->m_flags & XFS_MOUNT_ATTR2) &&
+ if (xfs_has_attr2(dp->i_mount) &&
(dp->i_df.if_format != XFS_DINODE_FMT_BTREE) &&
(bytes == sizeof(struct xfs_attr_sf_hdr)))
return -1;
@@ -1119,7 +1124,7 @@ xfs_attr3_leaf_to_shortform(
goto out;
if (forkoff == -1) {
- ASSERT(dp->i_mount->m_flags & XFS_MOUNT_ATTR2);
+ ASSERT(xfs_has_attr2(dp->i_mount));
ASSERT(dp->i_df.if_format != XFS_DINODE_FMT_BTREE);
xfs_attr_fork_remove(dp, args->trans);
goto out;
diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c
index db9e8566..bea9340a 100644
--- a/libxfs/xfs_bmap.c
+++ b/libxfs/xfs_bmap.c
@@ -1040,7 +1040,7 @@ xfs_bmap_set_attrforkoff(
ip->i_forkoff = xfs_attr_shortform_bytesfit(ip, size);
if (!ip->i_forkoff)
ip->i_forkoff = default_size;
- else if ((ip->i_mount->m_flags & XFS_MOUNT_ATTR2) && version)
+ else if (xfs_has_attr2(ip->i_mount) && version)
*version = 2;
break;
default:
@@ -3415,7 +3415,7 @@ xfs_bmap_compute_alignments(
int stripe_align = 0;
/* stripe alignment for allocation is determined by mount parameters */
- if (mp->m_swidth && (mp->m_flags & XFS_MOUNT_SWALLOC))
+ if (mp->m_swidth && xfs_has_swalloc(mp))
stripe_align = mp->m_swidth;
else if (mp->m_dalign)
stripe_align = mp->m_dalign;
diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c
index 567f9996..4075ff5a 100644
--- a/libxfs/xfs_ialloc.c
+++ b/libxfs/xfs_ialloc.c
@@ -707,7 +707,7 @@ xfs_ialloc_ag_alloc(
*/
isaligned = 0;
if (igeo->ialloc_align) {
- ASSERT(!(args.mp->m_flags & XFS_MOUNT_NOALIGN));
+ ASSERT(!xfs_has_noalign(args.mp));
args.alignment = args.mp->m_dalign;
isaligned = 1;
} else
@@ -1948,8 +1948,7 @@ xfs_difree_inobt(
* remove the chunk if the block size is large enough for multiple inode
* chunks (that might not be free).
*/
- if (!(mp->m_flags & XFS_MOUNT_IKEEP) &&
- rec.ir_free == XFS_INOBT_ALL_FREE &&
+ if (!xfs_has_ikeep(mp) && rec.ir_free == XFS_INOBT_ALL_FREE &&
mp->m_sb.sb_inopblock <= XFS_INODES_PER_CHUNK) {
struct xfs_perag *pag = agbp->b_pag;
@@ -2093,9 +2092,8 @@ xfs_difree_finobt(
* enough for multiple chunks. Leave the finobt record to remain in sync
* with the inobt.
*/
- if (rec.ir_free == XFS_INOBT_ALL_FREE &&
- mp->m_sb.sb_inopblock <= XFS_INODES_PER_CHUNK &&
- !(mp->m_flags & XFS_MOUNT_IKEEP)) {
+ if (!xfs_has_ikeep(mp) && rec.ir_free == XFS_INOBT_ALL_FREE &&
+ mp->m_sb.sb_inopblock <= XFS_INODES_PER_CHUNK) {
error = xfs_btree_delete(cur, &i);
if (error)
goto error;
next prev parent reply other threads:[~2021-09-14 2:42 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-14 2:39 [PATCHSET 00/43] xfs: sync libxfs with 5.15 Darrick J. Wong
2021-09-14 2:40 ` [PATCH 01/43] xfs_{copy,db,logprint,repair}: pass xfs_mount pointers instead of xfs_sb pointers Darrick J. Wong
2021-09-14 2:40 ` [PATCH 02/43] xfs: remove support for disabling quota accounting on a mounted file system Darrick J. Wong
2021-09-14 2:40 ` [PATCH 03/43] xfs: remove the active vs running quota differentiation Darrick J. Wong
2021-09-14 2:40 ` [PATCH 04/43] xfs: replace kmem_alloc_large() with kvmalloc() Darrick J. Wong
2021-09-14 2:40 ` [PATCH 05/43] xfs: allow setting and clearing of log incompat feature flags Darrick J. Wong
2021-09-14 2:40 ` [PATCH 06/43] xfs: add attr state machine tracepoints Darrick J. Wong
2021-09-14 2:40 ` [PATCH 07/43] xfs: Rename __xfs_attr_rmtval_remove Darrick J. Wong
2021-09-14 2:40 ` [PATCH 08/43] xfs: make xfs_rtalloc_query_range input parameters const Darrick J. Wong
2021-09-14 2:40 ` [PATCH 09/43] xfs: make the key parameters to all btree key comparison functions const Darrick J. Wong
2021-09-14 2:40 ` [PATCH 10/43] xfs: make the key parameters to all btree query range " Darrick J. Wong
2021-09-14 2:41 ` [PATCH 11/43] xfs: make the record pointer passed to query_range " Darrick J. Wong
2021-09-14 2:41 ` [PATCH 12/43] xfs: mark the record passed into btree init_key functions as const Darrick J. Wong
2021-09-14 2:41 ` [PATCH 13/43] xfs: make the keys and records passed to btree inorder functions const Darrick J. Wong
2021-09-14 2:41 ` [PATCH 14/43] xfs: mark the record passed into xchk_btree functions as const Darrick J. Wong
2021-09-14 2:41 ` [PATCH 15/43] xfs: make the pointer passed to btree set_root functions const Darrick J. Wong
2021-09-14 2:41 ` [PATCH 16/43] xfs: make the start pointer passed to btree alloc_block " Darrick J. Wong
2021-09-14 2:41 ` [PATCH 17/43] xfs: make the start pointer passed to btree update_lastrec " Darrick J. Wong
2021-09-14 2:41 ` [PATCH 18/43] xfs: constify btree function parameters that are not modified Darrick J. Wong
2021-09-14 2:41 ` [PATCH 19/43] xfs: resolve fork names in trace output Darrick J. Wong
2021-09-14 2:41 ` [PATCH 20/43] xfs: sb verifier doesn't handle uncached sb buffer Darrick J. Wong
2021-09-14 2:41 ` [PATCH 21/43] xfs: rename xfs_has_attr() Darrick J. Wong
2021-09-14 2:42 ` [PATCH 22/43] xfs: rework attr2 feature and mount options Darrick J. Wong
2021-09-14 2:42 ` [PATCH 23/43] xfs: reflect sb features in xfs_mount Darrick J. Wong
2021-09-14 2:42 ` [PATCH 24/43] xfs: replace xfs_sb_version checks with feature flag checks Darrick J. Wong
2021-09-14 2:42 ` Darrick J. Wong [this message]
2021-09-14 2:42 ` [PATCH 26/43] xfs: convert remaining mount flags to state flags Darrick J. Wong
2021-09-14 2:42 ` [PATCH 27/43] xfs: replace XFS_FORCED_SHUTDOWN with xfs_is_shutdown Darrick J. Wong
2021-09-14 2:42 ` [PATCH 28/43] xfs: convert xfs_fs_geometry to use mount feature checks Darrick J. Wong
2021-09-14 2:42 ` [PATCH 29/43] xfs: open code sb verifier " Darrick J. Wong
2021-09-14 2:42 ` [PATCH 30/43] xfs: convert xfs_sb_version_has checks to use mount features Darrick J. Wong
2021-09-14 2:42 ` [PATCH 31/43] libxlog: replace xfs_sb_version checks with feature flag checks Darrick J. Wong
2021-09-14 2:42 ` [PATCH 32/43] libxfs: " Darrick J. Wong
2021-09-14 2:43 ` [PATCH 33/43] xfs_{copy,db,logprint,repair}: " Darrick J. Wong
2021-09-14 2:43 ` [PATCH 34/43] xfs: remove unused xfs_sb_version_has wrappers Darrick J. Wong
2021-09-14 2:43 ` [PATCH 35/43] xfs: introduce xfs_sb_is_v5 helper Darrick J. Wong
2021-09-14 2:43 ` [PATCH 36/43] xfs: kill xfs_sb_version_has_v3inode() Darrick J. Wong
2021-09-14 2:43 ` [PATCH 37/43] libxfs: use opstate flags and functions for libxfs mount options Darrick J. Wong
2021-09-14 2:43 ` [PATCH 38/43] libxfs: remove pointless *XFS_MOUNT* flags Darrick J. Wong
2021-09-14 2:43 ` [PATCH 39/43] libxfs: always initialize internal buffer map Darrick J. Wong
2021-09-14 2:43 ` [PATCH 40/43] libxfs: replace XFS_BUF_SET_ADDR with a function Darrick J. Wong
2021-09-14 2:43 ` [PATCH 41/43] xfs: introduce xfs_buf_daddr() Darrick J. Wong
2021-09-14 2:43 ` [PATCH 42/43] xfs: convert bp->b_bn references to xfs_buf_daddr() Darrick J. Wong
2021-09-14 2:43 ` [PATCH 43/43] libxfs: rename buffer cache index variable b_bn Darrick J. Wong
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=163158733660.1604118.8914008454755284421.stgit@magnolia \
--to=djwong@kernel.org \
--cc=dchinner@redhat.com \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@sandeen.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).