From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de ([195.135.220.15]:43368 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726795AbeIQWYT (ORCPT ); Mon, 17 Sep 2018 18:24:19 -0400 Date: Mon, 17 Sep 2018 18:56:04 +0200 From: Jan Kara To: Richard Guy Briggs Cc: Jan Kara , Paul Moore , Al Viro , linux-audit@redhat.com, linux-fsdevel@vger.kernel.org, Amir Goldstein Subject: Re: [PATCH 12/11 TESTSUITE] audit_testsuite: Add stress test for tree watches Message-ID: <20180917165604.GD10257@quack2.suse.cz> References: <20180904160632.21210-1-jack@suse.cz> <20180904160632.21210-13-jack@suse.cz> <20180914182104.roqwfh6dqln5ur7o@madcap2.tricolour.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180914182104.roqwfh6dqln5ur7o@madcap2.tricolour.ca> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Fri 14-09-18 14:21:04, Richard Guy Briggs wrote: > On 2018-09-04 18:06, Jan Kara wrote: > > Add stress test for stressing audit tree watches by adding and deleting > > rules while events are generated and watched filesystems are mounted and > > unmounted in parallel. > > A couple of minor comments below, but otherwise looks reasonable to me. > Reviewed-by: Richard Guy Briggs > > I assume you've tested this with more than $dirs = 4 and sleep(60)? I've tested it to run for longer time (couple hours) but I don't think I've tested more directories. I can try that out. > > +sub umount_all { > > + my($dir,$dirs,$ignore_fail) = @_; > > + > > + for (my $i=0; $i < $dirs; $i++) { > > + while (system("umount $dir/leaf$i >& /dev/null") > 0 && > > + $ignore_fail == 0) { > > + # Nothing - loop until umount succeeds > > + } > > + } > > Shouldn't this set of tmpfs be unmounted after the bind mounts that > follow, in reverse order to the way they were mounted? The order does not really matter. Once bind mount is created, it is independent entity from the original mount (well, except for possible mount inheritance) so you can unmount them in arbitrary order. > > +# create temp directory > > +my $dir = tempdir( TEMPLATE => '/tmp/audit-testsuite-XXXX', CLEANUP => 1 ); > > + > > +# create stdout/stderr sinks > > +( my $fh_out, my $stdout ) = tempfile( > > + TEMPLATE => '/tmp/audit-testsuite-out-XXXX', > > + UNLINK => 1 > > +); > > +( my $fh_err, my $stderr ) = tempfile( > > + TEMPLATE => '/tmp/audit-testsuite-err-XXXX', > > + UNLINK => 1 > > +); > > + > > +### > > +# tests > > + > > +my $dirs = 4; > > + > > +# setup directory hierarchy > > +for (my $i=0; $i < $dirs; $i++) { > > + mkdir $dir."/dir".$i; > > + for (my $j=0; $j < $dirs; $j++) { > > + mkdir $dir."/dir".$i."/subdir".$j; > > + } > > +} > > +mkdir "$dir/mnt"; > > +for (my $i=0; $i < $dirs; $i++) { > > + mkdir "$dir/mnt/mnt$i"; > > + mkdir "$dir/leaf$i"; > > +} > > + > > +my $stat_pid = fork(); > > + > > +if ($stat_pid == 0) { > > + run_stat($dir, $dirs); > > + # Never reached > > + exit; > > +} > > + > > +my $mount_pid = fork(); > > + > > +if ($mount_pid == 0) { > > + run_mount($dir, $dirs); > > + # Never reached > > + exit; > > +} > > + > > +my $key = key_gen(); > > + > > +my $audit_pid = fork(); > > + > > +if ($audit_pid == 0) { > > + run_mark_audit($dir, $dirs, $key); > > + # Never reached > > + exit; > > +} > > + > > +# Sleep for a minute to let stress test run... > > +sleep(60); > > +ok(1); > > + > > +### > > +# cleanup > > + > > +kill('KILL', $stat_pid, $mount_pid, $audit_pid); > > +# Wait for children to terminate > > +waitpid($stat_pid, 0); > > +waitpid($mount_pid, 0); > > +waitpid($audit_pid, 0); > > +system("auditctl -D >& /dev/null"); > > +umount_all($dir, $dirs, 1); > > Should all the subdirectories in the temp directory be deleted, or are > they all cleaned up recursively by the tempdir command? The CLEANUP / UNLINK parameters to tempdir() and tempfile() functions should make sure everything is removed on exit (including possible subdirs). Honza -- Jan Kara SUSE Labs, CR