From patchwork Tue Dec 18 20:36:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10736267 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BC4EF13BF for ; Tue, 18 Dec 2018 20:36:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE9DE2AE19 for ; Tue, 18 Dec 2018 20:36:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A29FB2AE25; Tue, 18 Dec 2018 20:36:17 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY 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 8299E2AE19 for ; Tue, 18 Dec 2018 20:36:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727597AbeLRUgO (ORCPT ); Tue, 18 Dec 2018 15:36:14 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:54624 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727051AbeLRUgH (ORCPT ); Tue, 18 Dec 2018 15:36:07 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wBIKYSrS104574; Tue, 18 Dec 2018 20:36:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=0jcd2xCNBvZ3VzbU3nXtIzVCI/1YcgSlaroV7HijwyI=; b=efSvKfIvMNBEuKZw0b9hRncVy3eHcYxc4szJsQXfKhF5eoRsq+zZKvDJN4VEBm57Lclf ausmFoeOBoZ5TWvur8m+XidB/H1qJV8KWQXAG3Ot2JoeXKqcEdOJcCM2Byg50Nob20Gl GiHGv/73XdXEY3LgREFiJj7NUe2MNA9Sa02sqcmL3edl+/uz4R4+LuAKCd+kmjlpMk9k Hu2vFuVQA5KuYSrP34cdiIF8CiGPkHHjF/HSQ6U1YH/O7k9QQaUH0543nObhAoh01Awm oZT81GjLIpSYNNbsMwdWM0gI4x+SPlxy7yUv9GXVLZuWJOESE6FUWP/EE95MsFahTJL0 3g== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2120.oracle.com with ESMTP id 2pct8qwn03-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 18 Dec 2018 20:36:05 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id wBIKa4M2009858 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 18 Dec 2018 20:36:05 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id wBIKa4ex016067; Tue, 18 Dec 2018 20:36:04 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 18 Dec 2018 12:36:04 -0800 Subject: [PATCH 3/5] generic/050: fix ro blockdev mount of xfs with quota From: "Darrick J. Wong" To: guaneryu@gmail.com, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org Date: Tue, 18 Dec 2018 12:36:03 -0800 Message-ID: <154516536357.31115.14111308107665005322.stgit@magnolia> In-Reply-To: <154516534392.31115.7010578395334646479.stgit@magnolia> References: <154516534392.31115.7010578395334646479.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9111 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1812180170 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong In XFS, mounting with quota always require a writable device. If the block device is read only, the mount fails, which fails this test. Since this is expected, work around this by simulating the golden output when we expect a mount failure. Signed-off-by: Darrick J. Wong --- tests/generic/050 | 62 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 16 deletions(-) diff --git a/tests/generic/050 b/tests/generic/050 index 90e924db..9a327165 100755 --- a/tests/generic/050 +++ b/tests/generic/050 @@ -36,6 +36,22 @@ _require_norecovery _scratch_mkfs >/dev/null 2>&1 +filter_ro_mount() { + local arg="" + + if [ -n "$expect_mount_failure" ]; then + arg="s|mount: $SCRATCH_MNT: permission denied|mount: device write-protected, mounting read-only|g" + fi + sed -e "$arg" | _filter_ro_mount +} + +# Mounting with quota on XFS requires a writable fs, which means +# we expect to fail the ro blockdev test with with EPERM. +expect_mount_failure= +if [ "$FSTYP" = "xfs" ] && echo "$MOUNT_OPTIONS" | grep -q quota ; then + expect_mount_failure=1 +fi + # # Mark the device read-only # @@ -46,17 +62,25 @@ blockdev --setro $SCRATCH_DEV # Mount it, and make sure we can't write to it, and we can unmount it again # echo "mounting read-only block device:" -_try_scratch_mount 2>&1 | _filter_ro_mount - -echo "touching file on read-only filesystem (should fail)" -touch $SCRATCH_MNT/foo 2>&1 | _filter_scratch - -# -# Apparently this used to be broken at some point: -# http://oss.sgi.com/bugzilla/show_bug.cgi?id=807 -# -echo "unmounting read-only filesystem" -_scratch_unmount 2>&1 | _filter_scratch +_try_scratch_mount 2>&1 | filter_ro_mount +if [ "${PIPESTATUS[0]}" -eq 0 ]; then + echo "touching file on read-only filesystem (should fail)" + touch $SCRATCH_MNT/foo 2>&1 | _filter_scratch + + # + # Apparently this used to be broken at some point: + # http://oss.sgi.com/bugzilla/show_bug.cgi?id=807 + # + echo "unmounting read-only filesystem" + _scratch_unmount 2>&1 | _filter_scratch +elif [ -n "${expect_mount_failure}" ]; then + # Mount failed, so simulate EROFS instead of scribbling on root fs + echo "touching file on read-only filesystem (should fail)" + echo "touch: cannot touch 'SCRATCH_MNT/foo': Read-only file system" + echo "unmounting read-only filesystem" +else + echo "Mount failed, though it wasn't supposed to!" +fi echo "setting device read-write" blockdev --setrw $SCRATCH_DEV @@ -88,14 +112,20 @@ _scratch_unmount 2>&1 | _filter_scratch | _filter_ending_dot # # This is the way out if the underlying device really is read-only. -# Doesn't mean it's a good idea in practive, more a last resort +# Doesn't mean it's a good idea in practice, more a last resort # data recovery hack. # echo "mounting filesystem with -o norecovery on a read-only device:" -_try_scratch_mount -o norecovery 2>&1 | _filter_ro_mount - -echo "unmounting read-only filesystem" -_scratch_unmount 2>&1 | _filter_scratch +_try_scratch_mount -o norecovery 2>&1 | filter_ro_mount +if [ "${PIPESTATUS[0]}" -eq 0 ]; then + echo "unmounting read-only filesystem" + _scratch_unmount 2>&1 | _filter_scratch +elif [ -n "${expect_mount_failure}" ]; then + # Mount failed, simulate correct output + echo "unmounting read-only filesystem" +else + echo "Mount failed, though it wasn't supposed to!" +fi echo "setting device read-write" blockdev --setrw $SCRATCH_DEV