From patchwork Tue Dec 19 10:30:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Yang X-Patchwork-Id: 10122955 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 C6656603B5 for ; Tue, 19 Dec 2017 10:34:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B447329219 for ; Tue, 19 Dec 2017 10:34:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A90A329220; Tue, 19 Dec 2017 10:34:12 +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=ham 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 1EA9829219 for ; Tue, 19 Dec 2017 10:34:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933363AbdLSKeL (ORCPT ); Tue, 19 Dec 2017 05:34:11 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:59413 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933857AbdLSKeJ (ORCPT ); Tue, 19 Dec 2017 05:34:09 -0500 X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="31769760" Received: from localhost (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 19 Dec 2017 18:34:03 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id 8517E486A76B; Tue, 19 Dec 2017 18:34:02 +0800 (CST) Received: from RHEL7.5Alpha (10.167.220.29) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.361.1; Tue, 19 Dec 2017 18:34:05 +0800 From: xiao yang To: CC: , , , xiao yang Subject: [PATCH blktests] block/013: Add test for BLKRRPART ioctl Date: Tue, 19 Dec 2017 18:30:23 +0800 Message-ID: <1513679423-13067-1-git-send-email-yangx.jy@cn.fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <20171204182953.GA16308@vader.DHCP.thefacebook.com> References: <20171204182953.GA16308@vader.DHCP.thefacebook.com> MIME-Version: 1.0 X-Originating-IP: [10.167.220.29] X-yoursite-MailScanner-ID: 8517E486A76B.A9E9F X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: yangx.jy@cn.fujitsu.com Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If the entire block device is formatted with a filesystem and mounted, running "blockdev --rereadpt" should fail and return EBUSY instead of pass. Signed-off-by: xiao yang Reviewed-by: Johannes Thumshirn --- tests/block/013 | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/block/013.out | 3 +++ 2 files changed, 65 insertions(+) create mode 100755 tests/block/013 create mode 100644 tests/block/013.out diff --git a/tests/block/013 b/tests/block/013 new file mode 100755 index 0000000..77ae55c --- /dev/null +++ b/tests/block/013 @@ -0,0 +1,62 @@ +#!/bin/bash +# +# If the entire block device is formatted with a filesystem and +# mounted, running "blockdev --rereadpt" should fail and return +# EBUSY. On buggy kernel, it passes unexpectedly. +# +# Regression test for commit 77032ca66f86 ("Return EBUSY from +# BLKRRPART for mounted whole-dev fs"). +# +# Copyright (c) 2017 FUJITSU LIMITED. All rights reserved. +# Author: Xiao Yang +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +DESCRIPTION="test return EBUSY from BLKRRPART for mounted whole-dev" +QUICK=1 + +requires() { + _have_program mkfs.ext3 +} + +test_device() { + echo "Running ${TEST_NAME}" + + rm -f "$FULL" + mkdir "$TMPDIR/mntpoint" + + # Format + mkfs.ext3 -F "$TEST_DEV" >> "$FULL" 2>&1 + + # Mount + mount "$TEST_DEV" "$TMPDIR/mntpoint" + + # Check mounted whole-dev + local out=$(blockdev --rereadpt "$TEST_DEV" 2>&1) + echo $out | grep -q "Device or resource busy" + if [ $? -eq 0 ]; then + echo "Return EBUSY for mounted whole-dev" + else + echo "Don't return EBUSY for mounted whole-dev" + fi + + echo $out >> "$FULL" + + # Umount + umount "$TMPDIR/mntpoint" + + rm -rf "$TMPDIR/mntpoint" + + echo "Test complete" +} diff --git a/tests/block/013.out b/tests/block/013.out new file mode 100644 index 0000000..74d1d08 --- /dev/null +++ b/tests/block/013.out @@ -0,0 +1,3 @@ +Running block/013 +Return EBUSY for mounted whole-dev +Test complete