diff mbox series

[1/3] xfs: add debug knobs to control btree bulk load slack factors

Message ID 157063979364.2914891.5142110960507331172.stgit@magnolia (mailing list archive)
State Superseded
Headers show
Series xfs: prepare repair for bulk loading | expand

Commit Message

Darrick J. Wong Oct. 9, 2019, 4:49 p.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

Add some debug knobs so that we can control the leaf and node block
slack when rebuilding btrees.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/xfs_globals.c |    6 ++++++
 fs/xfs/xfs_sysctl.h  |    2 ++
 fs/xfs/xfs_sysfs.c   |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 62 insertions(+)

Comments

Brian Foster Oct. 25, 2019, 2:19 p.m. UTC | #1
On Wed, Oct 09, 2019 at 09:49:53AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Add some debug knobs so that we can control the leaf and node block
> slack when rebuilding btrees.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  fs/xfs/xfs_globals.c |    6 ++++++
>  fs/xfs/xfs_sysctl.h  |    2 ++
>  fs/xfs/xfs_sysfs.c   |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 62 insertions(+)
> 
> 
> diff --git a/fs/xfs/xfs_globals.c b/fs/xfs/xfs_globals.c
> index fa55ab8b8d80..8f67027c144b 100644
> --- a/fs/xfs/xfs_globals.c
> +++ b/fs/xfs/xfs_globals.c
> @@ -43,4 +43,10 @@ struct xfs_globals xfs_globals = {
>  #ifdef DEBUG
>  	.pwork_threads		=	-1,	/* automatic thread detection */
>  #endif
> +
> +	/* Bulk load new btree leaf blocks to 75% full. */
> +	.bload_leaf_slack	=	-1,
> +
> +	/* Bulk load new btree node blocks to 75% full. */
> +	.bload_node_slack	=	-1,

What are the units for these fields? Seems reasonable outside of that,
though I'd probably reorder it to after the related code such that this
patch also includes whatever bits that actually use the fields.

Brian

>  };
> diff --git a/fs/xfs/xfs_sysctl.h b/fs/xfs/xfs_sysctl.h
> index 8abf4640f1d5..aecccceee4ca 100644
> --- a/fs/xfs/xfs_sysctl.h
> +++ b/fs/xfs/xfs_sysctl.h
> @@ -85,6 +85,8 @@ struct xfs_globals {
>  #ifdef DEBUG
>  	int	pwork_threads;		/* parallel workqueue threads */
>  #endif
> +	int	bload_leaf_slack;	/* btree bulk load leaf slack */
> +	int	bload_node_slack;	/* btree bulk load node slack */
>  	int	log_recovery_delay;	/* log recovery delay (secs) */
>  	int	mount_delay;		/* mount setup delay (secs) */
>  	bool	bug_on_assert;		/* BUG() the kernel on assert failure */
> diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c
> index f1bc88f4367c..673ad21a9585 100644
> --- a/fs/xfs/xfs_sysfs.c
> +++ b/fs/xfs/xfs_sysfs.c
> @@ -228,6 +228,58 @@ pwork_threads_show(
>  XFS_SYSFS_ATTR_RW(pwork_threads);
>  #endif /* DEBUG */
>  
> +STATIC ssize_t
> +bload_leaf_slack_store(
> +	struct kobject	*kobject,
> +	const char	*buf,
> +	size_t		count)
> +{
> +	int		ret;
> +	int		val;
> +
> +	ret = kstrtoint(buf, 0, &val);
> +	if (ret)
> +		return ret;
> +
> +	xfs_globals.bload_leaf_slack = val;
> +	return count;
> +}
> +
> +STATIC ssize_t
> +bload_leaf_slack_show(
> +	struct kobject	*kobject,
> +	char		*buf)
> +{
> +	return snprintf(buf, PAGE_SIZE, "%d\n", xfs_globals.bload_leaf_slack);
> +}
> +XFS_SYSFS_ATTR_RW(bload_leaf_slack);
> +
> +STATIC ssize_t
> +bload_node_slack_store(
> +	struct kobject	*kobject,
> +	const char	*buf,
> +	size_t		count)
> +{
> +	int		ret;
> +	int		val;
> +
> +	ret = kstrtoint(buf, 0, &val);
> +	if (ret)
> +		return ret;
> +
> +	xfs_globals.bload_node_slack = val;
> +	return count;
> +}
> +
> +STATIC ssize_t
> +bload_node_slack_show(
> +	struct kobject	*kobject,
> +	char		*buf)
> +{
> +	return snprintf(buf, PAGE_SIZE, "%d\n", xfs_globals.bload_node_slack);
> +}
> +XFS_SYSFS_ATTR_RW(bload_node_slack);
> +
>  static struct attribute *xfs_dbg_attrs[] = {
>  	ATTR_LIST(bug_on_assert),
>  	ATTR_LIST(log_recovery_delay),
> @@ -236,6 +288,8 @@ static struct attribute *xfs_dbg_attrs[] = {
>  #ifdef DEBUG
>  	ATTR_LIST(pwork_threads),
>  #endif
> +	ATTR_LIST(bload_leaf_slack),
> +	ATTR_LIST(bload_node_slack),
>  	NULL,
>  };
>  
>
Darrick J. Wong Oct. 25, 2019, 4:39 p.m. UTC | #2
On Fri, Oct 25, 2019 at 10:19:47AM -0400, Brian Foster wrote:
> On Wed, Oct 09, 2019 at 09:49:53AM -0700, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> > 
> > Add some debug knobs so that we can control the leaf and node block
> > slack when rebuilding btrees.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >  fs/xfs/xfs_globals.c |    6 ++++++
> >  fs/xfs/xfs_sysctl.h  |    2 ++
> >  fs/xfs/xfs_sysfs.c   |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++
> >  3 files changed, 62 insertions(+)
> > 
> > 
> > diff --git a/fs/xfs/xfs_globals.c b/fs/xfs/xfs_globals.c
> > index fa55ab8b8d80..8f67027c144b 100644
> > --- a/fs/xfs/xfs_globals.c
> > +++ b/fs/xfs/xfs_globals.c
> > @@ -43,4 +43,10 @@ struct xfs_globals xfs_globals = {
> >  #ifdef DEBUG
> >  	.pwork_threads		=	-1,	/* automatic thread detection */
> >  #endif
> > +
> > +	/* Bulk load new btree leaf blocks to 75% full. */
> > +	.bload_leaf_slack	=	-1,
> > +
> > +	/* Bulk load new btree node blocks to 75% full. */
> > +	.bload_node_slack	=	-1,
> 
> What are the units for these fields?

Records (or key/ptr pairs).

> Seems reasonable outside of that, though I'd probably reorder it to
> after the related code such that this patch also includes whatever
> bits that actually use the fields.

It's the next patch.  Will reorder.

Thanks for reviewing!  I totally replied to these in reverse redro! :)

--D

> Brian
> 
> >  };
> > diff --git a/fs/xfs/xfs_sysctl.h b/fs/xfs/xfs_sysctl.h
> > index 8abf4640f1d5..aecccceee4ca 100644
> > --- a/fs/xfs/xfs_sysctl.h
> > +++ b/fs/xfs/xfs_sysctl.h
> > @@ -85,6 +85,8 @@ struct xfs_globals {
> >  #ifdef DEBUG
> >  	int	pwork_threads;		/* parallel workqueue threads */
> >  #endif
> > +	int	bload_leaf_slack;	/* btree bulk load leaf slack */
> > +	int	bload_node_slack;	/* btree bulk load node slack */
> >  	int	log_recovery_delay;	/* log recovery delay (secs) */
> >  	int	mount_delay;		/* mount setup delay (secs) */
> >  	bool	bug_on_assert;		/* BUG() the kernel on assert failure */
> > diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c
> > index f1bc88f4367c..673ad21a9585 100644
> > --- a/fs/xfs/xfs_sysfs.c
> > +++ b/fs/xfs/xfs_sysfs.c
> > @@ -228,6 +228,58 @@ pwork_threads_show(
> >  XFS_SYSFS_ATTR_RW(pwork_threads);
> >  #endif /* DEBUG */
> >  
> > +STATIC ssize_t
> > +bload_leaf_slack_store(
> > +	struct kobject	*kobject,
> > +	const char	*buf,
> > +	size_t		count)
> > +{
> > +	int		ret;
> > +	int		val;
> > +
> > +	ret = kstrtoint(buf, 0, &val);
> > +	if (ret)
> > +		return ret;
> > +
> > +	xfs_globals.bload_leaf_slack = val;
> > +	return count;
> > +}
> > +
> > +STATIC ssize_t
> > +bload_leaf_slack_show(
> > +	struct kobject	*kobject,
> > +	char		*buf)
> > +{
> > +	return snprintf(buf, PAGE_SIZE, "%d\n", xfs_globals.bload_leaf_slack);
> > +}
> > +XFS_SYSFS_ATTR_RW(bload_leaf_slack);
> > +
> > +STATIC ssize_t
> > +bload_node_slack_store(
> > +	struct kobject	*kobject,
> > +	const char	*buf,
> > +	size_t		count)
> > +{
> > +	int		ret;
> > +	int		val;
> > +
> > +	ret = kstrtoint(buf, 0, &val);
> > +	if (ret)
> > +		return ret;
> > +
> > +	xfs_globals.bload_node_slack = val;
> > +	return count;
> > +}
> > +
> > +STATIC ssize_t
> > +bload_node_slack_show(
> > +	struct kobject	*kobject,
> > +	char		*buf)
> > +{
> > +	return snprintf(buf, PAGE_SIZE, "%d\n", xfs_globals.bload_node_slack);
> > +}
> > +XFS_SYSFS_ATTR_RW(bload_node_slack);
> > +
> >  static struct attribute *xfs_dbg_attrs[] = {
> >  	ATTR_LIST(bug_on_assert),
> >  	ATTR_LIST(log_recovery_delay),
> > @@ -236,6 +288,8 @@ static struct attribute *xfs_dbg_attrs[] = {
> >  #ifdef DEBUG
> >  	ATTR_LIST(pwork_threads),
> >  #endif
> > +	ATTR_LIST(bload_leaf_slack),
> > +	ATTR_LIST(bload_node_slack),
> >  	NULL,
> >  };
> >  
> > 
>
diff mbox series

Patch

diff --git a/fs/xfs/xfs_globals.c b/fs/xfs/xfs_globals.c
index fa55ab8b8d80..8f67027c144b 100644
--- a/fs/xfs/xfs_globals.c
+++ b/fs/xfs/xfs_globals.c
@@ -43,4 +43,10 @@  struct xfs_globals xfs_globals = {
 #ifdef DEBUG
 	.pwork_threads		=	-1,	/* automatic thread detection */
 #endif
+
+	/* Bulk load new btree leaf blocks to 75% full. */
+	.bload_leaf_slack	=	-1,
+
+	/* Bulk load new btree node blocks to 75% full. */
+	.bload_node_slack	=	-1,
 };
diff --git a/fs/xfs/xfs_sysctl.h b/fs/xfs/xfs_sysctl.h
index 8abf4640f1d5..aecccceee4ca 100644
--- a/fs/xfs/xfs_sysctl.h
+++ b/fs/xfs/xfs_sysctl.h
@@ -85,6 +85,8 @@  struct xfs_globals {
 #ifdef DEBUG
 	int	pwork_threads;		/* parallel workqueue threads */
 #endif
+	int	bload_leaf_slack;	/* btree bulk load leaf slack */
+	int	bload_node_slack;	/* btree bulk load node slack */
 	int	log_recovery_delay;	/* log recovery delay (secs) */
 	int	mount_delay;		/* mount setup delay (secs) */
 	bool	bug_on_assert;		/* BUG() the kernel on assert failure */
diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c
index f1bc88f4367c..673ad21a9585 100644
--- a/fs/xfs/xfs_sysfs.c
+++ b/fs/xfs/xfs_sysfs.c
@@ -228,6 +228,58 @@  pwork_threads_show(
 XFS_SYSFS_ATTR_RW(pwork_threads);
 #endif /* DEBUG */
 
+STATIC ssize_t
+bload_leaf_slack_store(
+	struct kobject	*kobject,
+	const char	*buf,
+	size_t		count)
+{
+	int		ret;
+	int		val;
+
+	ret = kstrtoint(buf, 0, &val);
+	if (ret)
+		return ret;
+
+	xfs_globals.bload_leaf_slack = val;
+	return count;
+}
+
+STATIC ssize_t
+bload_leaf_slack_show(
+	struct kobject	*kobject,
+	char		*buf)
+{
+	return snprintf(buf, PAGE_SIZE, "%d\n", xfs_globals.bload_leaf_slack);
+}
+XFS_SYSFS_ATTR_RW(bload_leaf_slack);
+
+STATIC ssize_t
+bload_node_slack_store(
+	struct kobject	*kobject,
+	const char	*buf,
+	size_t		count)
+{
+	int		ret;
+	int		val;
+
+	ret = kstrtoint(buf, 0, &val);
+	if (ret)
+		return ret;
+
+	xfs_globals.bload_node_slack = val;
+	return count;
+}
+
+STATIC ssize_t
+bload_node_slack_show(
+	struct kobject	*kobject,
+	char		*buf)
+{
+	return snprintf(buf, PAGE_SIZE, "%d\n", xfs_globals.bload_node_slack);
+}
+XFS_SYSFS_ATTR_RW(bload_node_slack);
+
 static struct attribute *xfs_dbg_attrs[] = {
 	ATTR_LIST(bug_on_assert),
 	ATTR_LIST(log_recovery_delay),
@@ -236,6 +288,8 @@  static struct attribute *xfs_dbg_attrs[] = {
 #ifdef DEBUG
 	ATTR_LIST(pwork_threads),
 #endif
+	ATTR_LIST(bload_leaf_slack),
+	ATTR_LIST(bload_node_slack),
 	NULL,
 };