From mwm@mired.org  Wed Apr 16 03:05:02 2008
Return-Path: <mwm@mired.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 7029D106566B
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 16 Apr 2008 03:05:02 +0000 (UTC)
	(envelope-from mwm@mired.org)
Received: from mired.org (student.mired.org [66.92.153.77])
	by mx1.freebsd.org (Postfix) with ESMTP id DCFD58FC1B
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 16 Apr 2008 03:05:01 +0000 (UTC)
	(envelope-from mwm@mired.org)
Received: (qmail 8128 invoked by uid 1001); 15 Apr 2008 22:37:32 -0400
Message-Id: <20080416023732.8127.qmail@mired.org>
Date: 15 Apr 2008 22:37:32 -0400
From: Mike Meyer <mwm@mired.org>
Reply-To: Mike Meyer <mwm@mired.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: the daily_clean_disks scripts walks file systems it shouldn't
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         122811
>Category:       conf
>Synopsis:       [periodic] [patch] the daily_clean_disks scripts walks file systems it shouldn't
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    brian
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Apr 16 03:10:01 UTC 2008
>Closed-Date:    Tue Jun 23 09:52:55 UTC 2009
>Last-Modified:  Tue Jun 23 10:00:05 UTC 2009
>Originator:     Mike Meyer
>Release:        FreeBSD 7.0-STABLE amd64
>Organization:
Meyer Consulting
>Environment:
System: FreeBSD bhuda.mired.org 7.0-STABLE FreeBSD 7.0-STABLE #0: Tue Apr 8 01:24:21 EDT 2008 mwm@bhuda.mired.org:/usr/src/sys/amd64/compile/BHUDA amd64



>Description:
	The daily clean disks script tries to use the find -prune and -delete
	flags to together, which is documented (though obscurely) as not working:
	-delete is documented as implying depth-first traversal, as with -d, and
	-prune is documented as having no effect if the -d option was specified.

	This means that, while the perioud daily-clean-disks script
	tries to limit itself to locally mounted file systems and
	read-write file systems, it will actually fails to do so.

>How-To-Repeat:
	Run the clean-disks periodic on a system with non-local file 
	systems mounted, and watch it walk them.

>Fix:

	The attached patch changes adds a new knob -
	daily_clean_disks_fs_types, and individually walks file
	systems of those types if they aren't read-only.

Only in /usr/src/etc/defaults: Makefile
diff -ru /usr/src/etc/defaults/periodic.conf defaults/periodic.conf
--- /usr/src/etc/defaults/periodic.conf	2008-01-27 03:07:14.000000000 -0500
+++ defaults/periodic.conf	2008-04-15 22:27:22.758031816 -0400
@@ -40,6 +40,7 @@
 daily_clean_disks_files="[#,]* .#* a.out *.core *.CKP .emacs_[0-9]*"
 daily_clean_disks_days=3				# If older than this
 daily_clean_disks_verbose="YES"				# Mention files deleted
+daily_clean_disks_fs_types="ufs,zfs"			# File system types to clean
 
 # 110.clean-tmps
 daily_clean_tmps_enable="NO"				# Delete stuff daily
diff -ru /usr/src/etc/periodic/daily/100.clean-disks periodic/daily/100.clean-disks
--- /usr/src/etc/periodic/daily/100.clean-disks	2001-04-25 08:11:54.000000000 -0400
+++ periodic/daily/100.clean-disks	2008-04-03 16:15:55.000000000 -0400
@@ -41,7 +41,10 @@
 		    print=;;
 	    esac
 
-	    rc=$(find / \( ! -fstype local -o -fstype rdonly \) -a -prune -o \
+	    disks=$(mount -t $daily_clean_disks_fs_types \
+		     | sed -e 's/.* on //' -e 's/ *(.*//' -e '/read-only/d')
+	    echo $disks
+	    rc=$(find -x $disks \
 		\( $args \) -atime +$daily_clean_disks_days -delete $print |
 		tee /dev/stderr | wc -l)
 	    [ -z "$print" ] && rc=0
Only in /usr/src/etc/periodic/daily: Makefile
Only in /usr/src/etc/periodic/daily: type


>Release-Note:
>Audit-Trail:

From: Gavin Atkinson <gavin@FreeBSD.org>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: conf/122811
Date: Thu, 23 Apr 2009 12:21:54 +0100

 Also see conf/133070 for a different approach to solving the same issue.
 I'm not sure which approach is best.
Responsible-Changed-From-To: freebsd-bugs->brian 
Responsible-Changed-By: brian 
Responsible-Changed-When: Sat May 30 08:36:00 UTC 2009 
Responsible-Changed-Why:  
I'll fix this (and also pr 133070 which I've closed as a dup of 
this) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=122811 
State-Changed-From-To: open->patched 
State-Changed-By: brian 
State-Changed-When: Tue Jun 2 07:36:03 UTC 2009 
State-Changed-Why:  
Fixed with r193302 - I'll MFC in 3 weeks. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=122811 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: conf/122811: commit references a PR
Date: Tue,  2 Jun 2009 07:36:06 +0000 (UTC)

 Author: brian
 Date: Tue Jun  2 07:35:51 2009
 New Revision: 193302
 URL: http://svn.freebsd.org/changeset/base/193302
 
 Log:
   Rather than using both -prune (which requires directory-first tree traversal)
   and -delete (which implies depth-first traversal), avoid using -delete in
   favour of -execdir.
   
   This has a side-effect of not removing directories that contain files,
   even if we delete all of those files, but IMHO that's a better option
   than specifying all possible local filesystem types in this script.
   
   PR:		122811
   MFC after:	3 weeks
 
 Modified:
   head/etc/periodic/daily/100.clean-disks
 
 Modified: head/etc/periodic/daily/100.clean-disks
 ==============================================================================
 --- head/etc/periodic/daily/100.clean-disks	Tue Jun  2 06:55:32 2009	(r193301)
 +++ head/etc/periodic/daily/100.clean-disks	Tue Jun  2 07:35:51 2009	(r193302)
 @@ -29,7 +29,7 @@ case "$daily_clean_disks_enable" in
  	    echo ""
  	    echo "Cleaning disks:"
  	    set -f noglob
 -	    args="$args -name "`echo "$daily_clean_disks_files" |
 +	    args="-name "`echo "$daily_clean_disks_files" |
  		sed -e 's/^[ 	]*//' \
  		    -e 's/[ 	]*$//' \
  		    -e 's/[ 	][ 	]*/ -o -name /g'`
 @@ -41,9 +41,9 @@ case "$daily_clean_disks_enable" in
  		    print=;;
  	    esac
  
 -	    rc=$(find / \( ! -fstype local -o -fstype rdonly \) -a -prune -o \
 -		\( $args \) -atime +$daily_clean_disks_days -delete $print |
 -		tee /dev/stderr | wc -l)
 +	    rc=$(find / \( ! -fstype local -o -fstype rdonly \) -prune -o \
 +		\( $args \) -atime +$daily_clean_disks_days \
 +		-execdir rm -df {} \; $print | tee /dev/stderr | wc -l)
  	    [ -z "$print" ] && rc=0
  	    [ $rc -gt 1 ] && rc=1
  	    set -f glob
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: brian 
State-Changed-When: Tue Jun 23 09:52:22 UTC 2009 
State-Changed-Why:  
Merged to stable/7 - r194690 

http://www.freebsd.org/cgi/query-pr.cgi?pr=122811 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: conf/122811: commit references a PR
Date: Tue, 23 Jun 2009 09:52:47 +0000 (UTC)

 Author: brian
 Date: Tue Jun 23 09:51:38 2009
 New Revision: 194690
 URL: http://svn.freebsd.org/changeset/base/194690
 
 Log:
   MFC: r193302: Avoid using find -delete in favour of find -prune
   
   PR:		122811
 
 Modified:
   stable/7/etc/   (props changed)
   stable/7/etc/periodic/daily/100.clean-disks
 
 Modified: stable/7/etc/periodic/daily/100.clean-disks
 ==============================================================================
 --- stable/7/etc/periodic/daily/100.clean-disks	Tue Jun 23 09:50:50 2009	(r194689)
 +++ stable/7/etc/periodic/daily/100.clean-disks	Tue Jun 23 09:51:38 2009	(r194690)
 @@ -29,7 +29,7 @@ case "$daily_clean_disks_enable" in
  	    echo ""
  	    echo "Cleaning disks:"
  	    set -f noglob
 -	    args="$args -name "`echo "$daily_clean_disks_files" |
 +	    args="-name "`echo "$daily_clean_disks_files" |
  		sed -e 's/^[ 	]*//' \
  		    -e 's/[ 	]*$//' \
  		    -e 's/[ 	][ 	]*/ -o -name /g'`
 @@ -41,9 +41,9 @@ case "$daily_clean_disks_enable" in
  		    print=;;
  	    esac
  
 -	    rc=$(find / \( ! -fstype local -o -fstype rdonly \) -a -prune -o \
 -		\( $args \) -atime +$daily_clean_disks_days -delete $print |
 -		tee /dev/stderr | wc -l)
 +	    rc=$(find / \( ! -fstype local -o -fstype rdonly \) -prune -o \
 +		\( $args \) -atime +$daily_clean_disks_days \
 +		-execdir rm -df {} \; $print | tee /dev/stderr | wc -l)
  	    [ -z "$print" ] && rc=0
  	    [ $rc -gt 1 ] && rc=1
  	    set -f glob
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
>Unformatted:
