public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] 273: don't delete everything if $SCRATCH_MNT isn't set
@ 2012-04-09 18:36 Bryan Schumaker
  2012-04-09 21:44 ` Dave Chinner
  0 siblings, 1 reply; 6+ messages in thread
From: Bryan Schumaker @ 2012-04-09 18:36 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: xfs

The cleanup function is trapped before _require_scratch() is called, and
then expands "rm -rf $SCRATCH_MNT/*" to "rm -rf /*"

Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
---
 273 |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/273 b/273
index 2965132..8889f5a 100755
--- a/273
+++ b/273
@@ -35,7 +35,11 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 _cleanup()
 {
 	cd /
-	rm -rf $SCRATCH_MNT/* $tmp.*
+	if [ ! -z $SCRATCH_DEV ] && [ ! -z $SCRATCH_MNT ];
+	then
+		rm -rf $SCRATCH_MNT
+	fi
+	rm -rf $tmp.*
 	_scratch_unmount
 }
 
-- 
1.7.10

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] 273: don't delete everything if $SCRATCH_MNT isn't set
  2012-04-09 18:36 [PATCH] 273: don't delete everything if $SCRATCH_MNT isn't set Bryan Schumaker
@ 2012-04-09 21:44 ` Dave Chinner
  2012-04-10 13:09   ` Bryan Schumaker
  2012-04-11 20:04   ` Christoph Hellwig
  0 siblings, 2 replies; 6+ messages in thread
From: Dave Chinner @ 2012-04-09 21:44 UTC (permalink / raw)
  To: Bryan Schumaker; +Cc: Christoph Hellwig, xfs

On Mon, Apr 09, 2012 at 02:36:21PM -0400, Bryan Schumaker wrote:
> The cleanup function is trapped before _require_scratch() is called, and
> then expands "rm -rf $SCRATCH_MNT/*" to "rm -rf /*"

It doesn't need to clean up the scratch device - tests need to mkfs
it first before using it, so just remove the $tmp* files. The sae
fix is needed for tests 274 and 275.

Also, it shouldn't be using "-rf" to do cleanup - "rm -f $tmp.*" is
sufficient to remove all the tmp files...

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] 273: don't delete everything if $SCRATCH_MNT isn't set
  2012-04-09 21:44 ` Dave Chinner
@ 2012-04-10 13:09   ` Bryan Schumaker
  2012-04-11  7:24     ` Lukas Czerner
  2012-04-11 20:04   ` Christoph Hellwig
  1 sibling, 1 reply; 6+ messages in thread
From: Bryan Schumaker @ 2012-04-10 13:09 UTC (permalink / raw)
  To: Dave Chinner; +Cc: Christoph Hellwig, xfs

On 04/09/12 17:44, Dave Chinner wrote:

> On Mon, Apr 09, 2012 at 02:36:21PM -0400, Bryan Schumaker wrote:
>> The cleanup function is trapped before _require_scratch() is called, and
>> then expands "rm -rf $SCRATCH_MNT/*" to "rm -rf /*"
> 
> It doesn't need to clean up the scratch device - tests need to mkfs
> it first before using it, so just remove the $tmp* files. The sae
> fix is needed for tests 274 and 275.
> 
> Also, it shouldn't be using "-rf" to do cleanup - "rm -f $tmp.*" is
> sufficient to remove all the tmp files...


Thanks for looking!  Maybe something like this?  (copying what 272 does):

diff --git a/273 b/273
index 2965132..4641e9d 100755
--- a/273
+++ b/273
@@ -30,14 +30,7 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=0	# success is the default!
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
-_cleanup()
-{
-	cd /
-	rm -rf $SCRATCH_MNT/* $tmp.*
-	_scratch_unmount
-}
+trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
 
 . ./common.rc
 . ./common.filter
@@ -138,7 +131,18 @@ umount $SCRATCH_DEV 2>/dev/null
 _scratch_mkfs_sized $((2 * 1024 * 1024 * 1024)) >>$seq.full 2>&1
 _scratch_mount
 
-_do_workload
+if ! _do_workload; then
+	echo "workout failed"
+	_scratch_unmount
+	status=1
+	exit
+fi
+
+if ! _scratch_unmount; then
+	echo "failed to umount"
+	status=1
+	exit
+fi
 
 _check_scratch_fs
 status=$?
-- 
1.7.10

- Bryan

> 
> Cheers,
> 
> Dave.


_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] 273: don't delete everything if $SCRATCH_MNT isn't set
  2012-04-10 13:09   ` Bryan Schumaker
@ 2012-04-11  7:24     ` Lukas Czerner
  0 siblings, 0 replies; 6+ messages in thread
From: Lukas Czerner @ 2012-04-11  7:24 UTC (permalink / raw)
  To: Bryan Schumaker; +Cc: Christoph Hellwig, xfs

On Tue, 10 Apr 2012, Bryan Schumaker wrote:

> On 04/09/12 17:44, Dave Chinner wrote:
> 
> > On Mon, Apr 09, 2012 at 02:36:21PM -0400, Bryan Schumaker wrote:
> >> The cleanup function is trapped before _require_scratch() is called, and
> >> then expands "rm -rf $SCRATCH_MNT/*" to "rm -rf /*"
> > 
> > It doesn't need to clean up the scratch device - tests need to mkfs
> > it first before using it, so just remove the $tmp* files. The sae
> > fix is needed for tests 274 and 275.
> > 
> > Also, it shouldn't be using "-rf" to do cleanup - "rm -f $tmp.*" is
> > sufficient to remove all the tmp files...
> 
> 
> Thanks for looking!  Maybe something like this?  (copying what 272 does):

This is actually not needed at all. Simply removing the 'rm -rf
$SCRATCH_MNT/*' line should be good enough :).

There is no need to remove anything from SCRATCH_DEV on cleanup, as
well as prior to actual testing.

And Dave is right, there are more tests like this which has to be fixed.

> 
> diff --git a/273 b/273
> index 2965132..4641e9d 100755
> --- a/273
> +++ b/273
> @@ -30,14 +30,7 @@ echo "QA output created by $seq"
>  here=`pwd`
>  tmp=/tmp/$$
>  status=0	# success is the default!
> -trap "_cleanup; exit \$status" 0 1 2 3 15
> -
> -_cleanup()
> -{
> -	cd /
> -	rm -rf $SCRATCH_MNT/* $tmp.*
> -	_scratch_unmount
> -}
> +trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
>  
>  . ./common.rc
>  . ./common.filter
> @@ -138,7 +131,18 @@ umount $SCRATCH_DEV 2>/dev/null
>  _scratch_mkfs_sized $((2 * 1024 * 1024 * 1024)) >>$seq.full 2>&1
>  _scratch_mount
>  
> -_do_workload
> +if ! _do_workload; then
> +	echo "workout failed"
> +	_scratch_unmount
> +	status=1
> +	exit
> +fi
> +
> +if ! _scratch_unmount; then
> +	echo "failed to umount"
> +	status=1
> +	exit
> +fi
>  
>  _check_scratch_fs
>  status=$?
> 

-- 

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] 273: don't delete everything if $SCRATCH_MNT isn't set
  2012-04-09 21:44 ` Dave Chinner
  2012-04-10 13:09   ` Bryan Schumaker
@ 2012-04-11 20:04   ` Christoph Hellwig
  2012-04-11 20:10     ` Bryan Schumaker
  1 sibling, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2012-04-11 20:04 UTC (permalink / raw)
  To: Dave Chinner; +Cc: Christoph Hellwig, xfs, Bryan Schumaker

On Tue, Apr 10, 2012 at 07:44:45AM +1000, Dave Chinner wrote:
> On Mon, Apr 09, 2012 at 02:36:21PM -0400, Bryan Schumaker wrote:
> > The cleanup function is trapped before _require_scratch() is called, and
> > then expands "rm -rf $SCRATCH_MNT/*" to "rm -rf /*"
> 
> It doesn't need to clean up the scratch device - tests need to mkfs
> it first before using it, so just remove the $tmp* files. The sae
> fix is needed for tests 274 and 275.

Given his address I assume Bryan might test on NFS, which has funky
semantics for the scratch device.

Is that true Bryan?  I really need to dive back into how we handle NFS
in this respect to have a good judgement on this patch.

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] 273: don't delete everything if $SCRATCH_MNT isn't set
  2012-04-11 20:04   ` Christoph Hellwig
@ 2012-04-11 20:10     ` Bryan Schumaker
  0 siblings, 0 replies; 6+ messages in thread
From: Bryan Schumaker @ 2012-04-11 20:10 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: xfs

On 04/11/12 16:04, Christoph Hellwig wrote:

> On Tue, Apr 10, 2012 at 07:44:45AM +1000, Dave Chinner wrote:
>> On Mon, Apr 09, 2012 at 02:36:21PM -0400, Bryan Schumaker wrote:
>>> The cleanup function is trapped before _require_scratch() is called, and
>>> then expands "rm -rf $SCRATCH_MNT/*" to "rm -rf /*"
>>
>> It doesn't need to clean up the scratch device - tests need to mkfs
>> it first before using it, so just remove the $tmp* files. The sae
>> fix is needed for tests 274 and 275.
> 
> Given his address I assume Bryan might test on NFS, which has funky
> semantics for the scratch device.
> 
> Is that true Bryan?  I really need to dive back into how we handle NFS
> in this respect to have a good judgement on this patch.
> 


Yeah, I'm testing on NFS (I guess the netapp address is a bit of a giveaway...).  I don't think this test runs on NFS, but if the scratch variables are unset then it'll still delete the root directory of the NFS client.

- Bryan

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-04-11 20:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-09 18:36 [PATCH] 273: don't delete everything if $SCRATCH_MNT isn't set Bryan Schumaker
2012-04-09 21:44 ` Dave Chinner
2012-04-10 13:09   ` Bryan Schumaker
2012-04-11  7:24     ` Lukas Czerner
2012-04-11 20:04   ` Christoph Hellwig
2012-04-11 20:10     ` Bryan Schumaker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox