From patchwork Tue Nov 14 10:54:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eryu Guan X-Patchwork-Id: 10057369 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7CACD6023A for ; Tue, 14 Nov 2017 10:55:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7827E29304 for ; Tue, 14 Nov 2017 10:55:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D677293F9; Tue, 14 Nov 2017 10:55:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F368329409 for ; Tue, 14 Nov 2017 10:55:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755093AbdKNKzd (ORCPT ); Tue, 14 Nov 2017 05:55:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39272 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754554AbdKNKyy (ORCPT ); Tue, 14 Nov 2017 05:54:54 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 530162DACEE; Tue, 14 Nov 2017 10:54:54 +0000 (UTC) Received: from localhost (dhcp-12-147.nay.redhat.com [10.66.12.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id CB7F19D7CA; Tue, 14 Nov 2017 10:54:53 +0000 (UTC) From: Eryu Guan To: fstests@vger.kernel.org Cc: misono.tomohiro@jp.fujitsu.com, linux-xfs@vger.kernel.org, Eryu Guan Subject: [PATCH 3/3] fstests: filter readonly mount error messages Date: Tue, 14 Nov 2017 18:54:01 +0800 Message-Id: <20171114105401.10542-4-eguan@redhat.com> In-Reply-To: <20171114105401.10542-1-eguan@redhat.com> References: <20171114105401.10542-1-eguan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 14 Nov 2017 10:54:54 +0000 (UTC) Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP util-linux commit 6dede2f2f7c5 ("libmount: support MS_RDONLY on write-protected devices") changed the error message on read-only block device, and in the failure case printed one line message instead of two (for details please see comments in common/filter), and this change broke generic/050 and overlay/035. Fix it by adding more filter rules to _filter_ro_mount and updating associated .out files to unify the output from both old and new util-linux versions. Signed-off-by: Eryu Guan --- common/filter | 35 ++++++++++++++++++++++++++++++++++- tests/generic/050 | 2 +- tests/generic/050.out | 8 ++++---- tests/overlay/035 | 9 +++++++-- 4 files changed, 46 insertions(+), 8 deletions(-) diff --git a/common/filter b/common/filter index b1cd558ab0e1..357c4c9357c3 100644 --- a/common/filter +++ b/common/filter @@ -399,9 +399,42 @@ _filter_ending_dot() # Older mount output referred to "block device" when mounting RO devices # It's gone in newer versions +# +# And util-linux v2.30 changed the output again, e.g. +# for a successful ro mount: +# prior to v2.30: mount: is write-protected, mounting read-only +# v2.30 and later: mount: : WARNING: device write-protected, mounted read-only. +# +# a failed ro mount: +# prior to v2.30: +# mount: is write-protected, mounting read-only +# mount: cannot mount read-only +# v2.30 and later: +# mount: : cannot mount read-only. +# +# a failed rw remount: +# prior to v2.30: mount: cannot remount read-write, is write-protected +# v2.30 and later: mount: : cannot remount read-write, is write-protected. +# +# Now use _filter_ro_mount to unify all these differences across old & new +# util-linux versions. _filter_ro_mount() { sed -e "s/mount: block device/mount:/g" \ - -e "s/mount: cannot mount block device/mount: cannot mount/g" + -e "s/mount: cannot mount block device/mount: cannot mount/g" | \ + _filter_ending_dot | \ + perl -ne ' + if (/write-protected, mount.*read-only/) { + print "mount: device write-protected, mounting read-only\n"; + } elsif (/mount: .*: cannot mount.*read-only/) { + print "mount: device write-protected, mounting read-only\n"; + print "mount: cannot mount read-only\n"; + } elsif (/mount: .*: cannot remount (.*) read-write.*/) { + print "mount: cannot remount $1 read-write, is write-protected\n"; + } elsif (/(^mount: cannot mount) .* (read-only$)/) { + print "$1 $2\n"; + } else { + print "$_"; + }' } # Filter a failed mount output, util-linux changed the message several times. diff --git a/tests/generic/050 b/tests/generic/050 index 5fa28a7648e5..65fcb018ca5f 100755 --- a/tests/generic/050 +++ b/tests/generic/050 @@ -98,7 +98,7 @@ echo "mounting filesystem that needs recovery on a read-only device:" _scratch_mount 2>&1 | _filter_scratch | _filter_ro_mount echo "unmounting read-only filesystem" -_scratch_unmount 2>&1 | _filter_scratch +_scratch_unmount 2>&1 | _filter_scratch | _filter_ending_dot # # This is the way out if the underlying device really is read-only. diff --git a/tests/generic/050.out b/tests/generic/050.out index fb90f6ea5819..2187d16fa328 100644 --- a/tests/generic/050.out +++ b/tests/generic/050.out @@ -1,7 +1,7 @@ QA output created by 050 setting device read-only mounting read-only block device: -mount: SCRATCH_DEV is write-protected, mounting read-only +mount: device write-protected, mounting read-only touching file on read-only filesystem (should fail) touch: cannot touch 'SCRATCH_MNT/foo': Read-only file system unmounting read-only filesystem @@ -12,12 +12,12 @@ going down: unmounting shutdown filesystem: setting device read-only mounting filesystem that needs recovery on a read-only device: -mount: SCRATCH_DEV is write-protected, mounting read-only -mount: cannot mount SCRATCH_DEV read-only +mount: device write-protected, mounting read-only +mount: cannot mount read-only unmounting read-only filesystem umount: SCRATCH_DEV: not mounted mounting filesystem with -o norecovery on a read-only device: -mount: SCRATCH_DEV is write-protected, mounting read-only +mount: device write-protected, mounting read-only unmounting read-only filesystem setting device read-write mounting filesystem that needs recovery with -o ro: diff --git a/tests/overlay/035 b/tests/overlay/035 index 64fcd708105e..d285d44ae9df 100755 --- a/tests/overlay/035 +++ b/tests/overlay/035 @@ -45,6 +45,11 @@ _cleanup() . ./common/rc . ./common/filter +filter_mount() +{ + _filter_scratch | _filter_ro_mount +} + # remove previous $seqres.full before test rm -f $seqres.full @@ -69,7 +74,7 @@ mkdir -p $lowerdir1 $lowerdir2 $upperdir $workdir $MOUNT_PROG -t overlay -o"lowerdir=$lowerdir2:$lowerdir1" \ $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT touch $SCRATCH_MNT/foo 2>&1 | _filter_scratch -_scratch_remount rw 2>&1 | _filter_scratch +_scratch_remount rw 2>&1 | filter_mount $UMOUNT_PROG $SCRATCH_MNT # Make workdir immutable to prevent workdir re-create on mount @@ -79,7 +84,7 @@ $CHATTR_PROG +i $workdir # Verify that overlay is mounted read-only and that it cannot be remounted rw. _overlay_scratch_mount_dirs $lowerdir2 $upperdir $workdir touch $SCRATCH_MNT/bar 2>&1 | _filter_scratch -_scratch_remount rw 2>&1 | _filter_scratch +_scratch_remount rw 2>&1 | filter_mount # success, all done status=0