[PATCH 5.1/10] xfs: create mount option to override metadata threads

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Darrick J. Wong <djwong@xxxxxxxxxx>

Create a mount option so that sysadmins can override the estimated
parallelism of the filesystem, which in turn controls the number of
active work items in background threads.

Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx>
---
 fs/xfs/xfs_mount.h |    3 +++
 fs/xfs/xfs_pwork.c |    5 +++++
 fs/xfs/xfs_super.c |   22 ++++++++++++++++++++++
 3 files changed, 30 insertions(+)

diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index dfa429b77ee2..884a49972789 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -209,6 +209,9 @@ typedef struct xfs_mount {
 	struct mutex		m_growlock;	/* growfs mutex */
 
 #ifdef DEBUG
+	/* Desired parallelism of threaded tasks and background workers. */
+	unsigned int		m_metadata_threads;
+
 	/*
 	 * Frequency with which errors are injected.  Replaces xfs_etest; the
 	 * value stored in here is the inverse of the frequency with which the
diff --git a/fs/xfs/xfs_pwork.c b/fs/xfs/xfs_pwork.c
index 53606397ff54..e89fb47bdfd6 100644
--- a/fs/xfs/xfs_pwork.c
+++ b/fs/xfs/xfs_pwork.c
@@ -162,6 +162,11 @@ xfs_pwork_guess_metadata_threads(
 {
 	unsigned int		threads;
 
+#ifdef DEBUG
+	if (mp->m_metadata_threads > 0)
+		return mp->m_metadata_threads;
+#endif
+
 	/*
 	 * Estimate the amount of parallelism for metadata operations from the
 	 * least capable of the two devices that handle metadata.  Cap that
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index d17fbdb2a656..2f8c512fca10 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -93,6 +93,9 @@ enum {
 	Opt_prjquota, Opt_uquota, Opt_gquota, Opt_pquota,
 	Opt_uqnoenforce, Opt_gqnoenforce, Opt_pqnoenforce, Opt_qnoenforce,
 	Opt_discard, Opt_nodiscard, Opt_dax, Opt_dax_enum,
+#ifdef DEBUG
+	Opt_metadata_threads,
+#endif
 };
 
 static const struct fs_parameter_spec xfs_fs_parameters[] = {
@@ -137,6 +140,9 @@ static const struct fs_parameter_spec xfs_fs_parameters[] = {
 	fsparam_flag("nodiscard",	Opt_nodiscard),
 	fsparam_flag("dax",		Opt_dax),
 	fsparam_enum("dax",		Opt_dax_enum, dax_param_enums),
+#ifdef DEBUG
+	fsparam_u32("metadata_threads",	Opt_metadata_threads),
+#endif
 	{}
 };
 
@@ -222,6 +228,11 @@ xfs_fs_show_options(
 	if (!(mp->m_qflags & XFS_ALL_QUOTA_ACCT))
 		seq_puts(m, ",noquota");
 
+#ifdef DEBUG
+	if (mp->m_metadata_threads > 0)
+		seq_printf(m, ",metadata_threads=%u", mp->m_metadata_threads);
+#endif
+
 	return 0;
 }
 
@@ -1291,6 +1302,12 @@ xfs_fs_parse_param(
 	case Opt_dax_enum:
 		xfs_mount_set_dax_mode(mp, result.uint_32);
 		return 0;
+#endif
+#ifdef DEBUG
+	case Opt_metadata_threads:
+		xfs_warn(mp, "%s set to %u", param->key, result.uint_32);
+		mp->m_metadata_threads = result.uint_32;
+		return 0;
 #endif
 	/* Following mount options will be removed in September 2025 */
 	case Opt_ikeep:
@@ -1831,6 +1848,11 @@ xfs_fs_reconfigure(
 			return error;
 	}
 
+#ifdef DEBUG
+	mp->m_metadata_threads = new_mp->m_metadata_threads;
+	xfs_configure_background_workqueues(mp);
+#endif
+
 	return 0;
 }
 



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux