diff mbox series

[2/2] check: optionally compress core dumps

Message ID 166500908117.887104.12652015559068296578.stgit@magnolia (mailing list archive)
State New, archived
Headers show
Series fstests: improve coredump capture and storage | expand

Commit Message

Darrick J. Wong Oct. 5, 2022, 10:31 p.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

Compress coredumps whenever desired to save space.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 README    |    1 +
 common/rc |   13 +++++++++++++
 2 files changed, 14 insertions(+)

Comments

Zorro Lang Oct. 7, 2022, 12:45 p.m. UTC | #1
On Wed, Oct 05, 2022 at 03:31:21PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> Compress coredumps whenever desired to save space.
> 
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> ---
>  README    |    1 +
>  common/rc |   13 +++++++++++++
>  2 files changed, 14 insertions(+)
> 
> 
> diff --git a/README b/README
> index 80d148be82..ec923ca564 100644
> --- a/README
> +++ b/README
> @@ -241,6 +241,7 @@ Misc:
>     this option is supported for all filesystems currently only -overlay is
>     expected to run without issues. For other filesystems additional patches
>     and fixes to the test suite might be needed.
> + - Set COMPRESS_COREDUMPS=1 to compress core dumps with gzip -9.

This patch looks good to me, just one question I'm thinking -- should this
parameter be under "Misc:" or "Tools specification:" part? If the former is
good, then:

Reviewed-by: Zorro Lang <zlang@redhat.com>


>  
>  ______________________
>  USING THE FSQA SUITE
> diff --git a/common/rc b/common/rc
> index 9750d06a9a..d3af4e07b2 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -4955,12 +4955,25 @@ _save_coredump()
>  	local core_hash="$(_md5_checksum "$path")"
>  	local out_file="$RESULT_BASE/$seqnum.core.$core_hash"
>  
> +	if [ "$COMPRESS_COREDUMPS" = "1" ]; then
> +		out_file="${out_file}.gz"
> +	fi
> +
>  	if [ -s "$out_file" ]; then
>  		rm -f "$path"
>  		return
>  	fi
>  	rm -f "$out_file"
>  
> +	if [ "$COMPRESS_COREDUMPS" = "1" ]; then
> +		if gzip -9 < "$path" > "$out_file"; then
> +			rm -f "$path"
> +		else
> +			rm -f "$out_file"
> +		fi
> +		return
> +	fi
> +
>  	mv "$path" "$out_file"
>  }
>  
>
Darrick J. Wong Oct. 7, 2022, 9:32 p.m. UTC | #2
On Fri, Oct 07, 2022 at 08:45:26PM +0800, Zorro Lang wrote:
> On Wed, Oct 05, 2022 at 03:31:21PM -0700, Darrick J. Wong wrote:
> > From: Darrick J. Wong <djwong@kernel.org>
> > 
> > Compress coredumps whenever desired to save space.
> > 
> > Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> > ---
> >  README    |    1 +
> >  common/rc |   13 +++++++++++++
> >  2 files changed, 14 insertions(+)
> > 
> > 
> > diff --git a/README b/README
> > index 80d148be82..ec923ca564 100644
> > --- a/README
> > +++ b/README
> > @@ -241,6 +241,7 @@ Misc:
> >     this option is supported for all filesystems currently only -overlay is
> >     expected to run without issues. For other filesystems additional patches
> >     and fixes to the test suite might be needed.
> > + - Set COMPRESS_COREDUMPS=1 to compress core dumps with gzip -9.
> 
> This patch looks good to me, just one question I'm thinking -- should this
> parameter be under "Misc:" or "Tools specification:" part? If the former is
> good, then:

I was thinking misc, buuut it occurs to me that perhaps we ought to let
people specify a different compression program, e.g.

COMPRESS_COREDUMPS=xz ./check generic/444

in which case this would be a tool spec thing.

I think I'll go back and rework this to do that.

--D

> Reviewed-by: Zorro Lang <zlang@redhat.com>
> 
> 
> >  
> >  ______________________
> >  USING THE FSQA SUITE
> > diff --git a/common/rc b/common/rc
> > index 9750d06a9a..d3af4e07b2 100644
> > --- a/common/rc
> > +++ b/common/rc
> > @@ -4955,12 +4955,25 @@ _save_coredump()
> >  	local core_hash="$(_md5_checksum "$path")"
> >  	local out_file="$RESULT_BASE/$seqnum.core.$core_hash"
> >  
> > +	if [ "$COMPRESS_COREDUMPS" = "1" ]; then
> > +		out_file="${out_file}.gz"
> > +	fi
> > +
> >  	if [ -s "$out_file" ]; then
> >  		rm -f "$path"
> >  		return
> >  	fi
> >  	rm -f "$out_file"
> >  
> > +	if [ "$COMPRESS_COREDUMPS" = "1" ]; then
> > +		if gzip -9 < "$path" > "$out_file"; then
> > +			rm -f "$path"
> > +		else
> > +			rm -f "$out_file"
> > +		fi
> > +		return
> > +	fi
> > +
> >  	mv "$path" "$out_file"
> >  }
> >  
> > 
>
diff mbox series

Patch

diff --git a/README b/README
index 80d148be82..ec923ca564 100644
--- a/README
+++ b/README
@@ -241,6 +241,7 @@  Misc:
    this option is supported for all filesystems currently only -overlay is
    expected to run without issues. For other filesystems additional patches
    and fixes to the test suite might be needed.
+ - Set COMPRESS_COREDUMPS=1 to compress core dumps with gzip -9.
 
 ______________________
 USING THE FSQA SUITE
diff --git a/common/rc b/common/rc
index 9750d06a9a..d3af4e07b2 100644
--- a/common/rc
+++ b/common/rc
@@ -4955,12 +4955,25 @@  _save_coredump()
 	local core_hash="$(_md5_checksum "$path")"
 	local out_file="$RESULT_BASE/$seqnum.core.$core_hash"
 
+	if [ "$COMPRESS_COREDUMPS" = "1" ]; then
+		out_file="${out_file}.gz"
+	fi
+
 	if [ -s "$out_file" ]; then
 		rm -f "$path"
 		return
 	fi
 	rm -f "$out_file"
 
+	if [ "$COMPRESS_COREDUMPS" = "1" ]; then
+		if gzip -9 < "$path" > "$out_file"; then
+			rm -f "$path"
+		else
+			rm -f "$out_file"
+		fi
+		return
+	fi
+
 	mv "$path" "$out_file"
 }