Commit 19e16281 authored by Dave Chinner's avatar Dave Chinner Committed by Long Li
Browse files

xfs: convert remaining mount flags to state flags

mainline inclusion
from mainline-v5.14-rc4
commit 2e973b2c
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4KIAO
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=2e973b2cd4cdb993be94cca4c33f532f1ed05316



--------------------------------

The remaining mount flags kept in m_flags are actually runtime state
flags. These change dynamically, so they really should be updated
atomically so we don't potentially lose an update due to racing
modifications.

Convert these remaining flags to be stored in m_opstate and use
atomic bitops to set and clear the flags. This also adds a couple of
simple wrappers for common state checks - read only and shutdown.

Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>

Conflicts:
	fs/xfs/xfs_mount.c
	fs/xfs/xfs_super.c

Signed-off-by: default avatarLong Li <leo.lilong@huawei.com>
parent 6cef9dda
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3116,7 +3116,7 @@ xfs_alloc_vextent(
		 * the first a.g. fails.
		 */
		if ((args->datatype & XFS_ALLOC_INITIAL_USER_DATA) &&
		    (mp->m_flags & XFS_MOUNT_32BITINODES)) {
		    xfs_is_inode32(mp)) {
			args->fsbno = XFS_AGB_TO_FSB(mp,
					((mp->m_agfrotor / rotorstep) %
					mp->m_sb.sb_agcount), 0);
+1 −1
Original line number Diff line number Diff line
@@ -181,7 +181,7 @@ xfs_validate_sb_read(
"Superblock has unknown read-only compatible features (0x%x) enabled.",
			(sbp->sb_features_ro_compat &
					XFS_SB_FEAT_RO_COMPAT_UNKNOWN));
		if (!(mp->m_flags & XFS_MOUNT_RDONLY)) {
		if (!xfs_is_readonly(mp)) {
			xfs_warn(mp,
"Attempted to mount read-only compatible filesystem read-write.");
			xfs_warn(mp,
+1 −1
Original line number Diff line number Diff line
@@ -917,7 +917,7 @@ xchk_start_reaping(
	 * Readonly filesystems do not perform inactivation or speculative
	 * preallocation, so there's no need to restart the workers.
	 */
	if (!(sc->mp->m_flags & XFS_MOUNT_RDONLY)) {
	if (!xfs_is_readonly(sc->mp)) {
		xfs_inodegc_start(sc->mp);
		xfs_blockgc_start(sc->mp);
	}
+1 −1
Original line number Diff line number Diff line
@@ -420,7 +420,7 @@ xchk_validate_inputs(
			goto out;

		error = -EROFS;
		if (mp->m_flags & XFS_MOUNT_RDONLY)
		if (xfs_is_readonly(mp))
			goto out;
	}

+1 −1
Original line number Diff line number Diff line
@@ -1220,7 +1220,7 @@ xfs_buf_ioerror_permanent(
		return true;

	/* At unmount we may treat errors differently */
	if ((mp->m_flags & XFS_MOUNT_UNMOUNTING) && mp->m_fail_unmount)
	if (xfs_is_unmounting(mp) && mp->m_fail_unmount)
		return true;

	return false;
Loading