diff mbox series

[RFC,v2,1/3] common/xfs: add a _require_xfs_shrink helper

Message ID 20210312132300.259226-2-hsiangkao@redhat.com (mailing list archive)
State Superseded
Headers show
Series xfs: testcases for shrinking free space in the last AG | expand

Commit Message

Gao Xiang March 12, 2021, 1:22 p.m. UTC
In order to detect whether the current kernel supports XFS shrinking.

Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
---
use -D1 rather than -D0 since xfs_growfs would report unchanged size
instead.

 common/xfs | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Gao Xiang March 12, 2021, 3:18 p.m. UTC | #1
Hi Zorro,

On Fri, Mar 12, 2021 at 11:25:06PM +0800, Zorro Lang wrote:
> On Fri, Mar 12, 2021 at 09:22:58PM +0800, Gao Xiang wrote:
> > In order to detect whether the current kernel supports XFS shrinking.
> > 
> > Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
> > ---
> > use -D1 rather than -D0 since xfs_growfs would report unchanged size
> > instead.
> > 
> >  common/xfs | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> > 
> > diff --git a/common/xfs b/common/xfs
> > index 2156749d..326edacc 100644
> > --- a/common/xfs
> > +++ b/common/xfs
> > @@ -432,6 +432,16 @@ _supports_xfs_scrub()
> >  	return 0
> >  }
> >  
> > +_require_xfs_shrink()
> > +{
> > +	_scratch_mkfs_xfs >/dev/null 2>&1
> > +
> > +	_scratch_mount
> > +	$XFS_GROWFS_PROG -D1 "$SCRATCH_MNT" 2>&1 | grep -q 'Invalid argument' || { \
> > +		_scratch_unmount; _notrun "kernel does not support shrinking"; }
> 	        ^^^^
> 		I think this unmount isn't necessary, due to after "_notrun" the
> 		$SCRATCH_DEV will be umounted "automatically".

I didn't dig into it more. Just follow _require_xfs_scratch_rmapbt().

If it's not necessary (assumed ./check does that), will update it in
the next version. Thanks for your suggestion.

Thanks,
Gao Xiang
Zorro Lang March 12, 2021, 3:25 p.m. UTC | #2
On Fri, Mar 12, 2021 at 09:22:58PM +0800, Gao Xiang wrote:
> In order to detect whether the current kernel supports XFS shrinking.
> 
> Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
> ---
> use -D1 rather than -D0 since xfs_growfs would report unchanged size
> instead.
> 
>  common/xfs | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/common/xfs b/common/xfs
> index 2156749d..326edacc 100644
> --- a/common/xfs
> +++ b/common/xfs
> @@ -432,6 +432,16 @@ _supports_xfs_scrub()
>  	return 0
>  }
>  
> +_require_xfs_shrink()
> +{
> +	_scratch_mkfs_xfs >/dev/null 2>&1
> +
> +	_scratch_mount
> +	$XFS_GROWFS_PROG -D1 "$SCRATCH_MNT" 2>&1 | grep -q 'Invalid argument' || { \
> +		_scratch_unmount; _notrun "kernel does not support shrinking"; }
	        ^^^^
		I think this unmount isn't necessary, due to after "_notrun" the
		$SCRATCH_DEV will be umounted "automatically".

> +	_scratch_unmount
> +}
> +
>  # run xfs_check and friends on a FS.
>  _check_xfs_filesystem()
>  {
> -- 
> 2.27.0
>
diff mbox series

Patch

diff --git a/common/xfs b/common/xfs
index 2156749d..326edacc 100644
--- a/common/xfs
+++ b/common/xfs
@@ -432,6 +432,16 @@  _supports_xfs_scrub()
 	return 0
 }
 
+_require_xfs_shrink()
+{
+	_scratch_mkfs_xfs >/dev/null 2>&1
+
+	_scratch_mount
+	$XFS_GROWFS_PROG -D1 "$SCRATCH_MNT" 2>&1 | grep -q 'Invalid argument' || { \
+		_scratch_unmount; _notrun "kernel does not support shrinking"; }
+	_scratch_unmount
+}
+
 # run xfs_check and friends on a FS.
 _check_xfs_filesystem()
 {