From patchwork Sat Nov 30 06:53:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zorro Lang X-Patchwork-Id: 11267861 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CB75A14B7 for ; Sat, 30 Nov 2019 06:53:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 96C682084D for ; Sat, 30 Nov 2019 06:53:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CHS8N07D" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725881AbfK3Gxl (ORCPT ); Sat, 30 Nov 2019 01:53:41 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:36402 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725783AbfK3Gxl (ORCPT ); Sat, 30 Nov 2019 01:53:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575096818; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=abmEBm+MuAPMV/Lt2KXXX2QVNefdEbVkI4GqG5WtJkY=; b=CHS8N07Dxx0HuzecDli1XceAsX82tCHZpE3Yl0NehjT727+eV40Avk/20yjUShjsbMbINB dEmy5BTaX2hLxkMqmpdYfcTEUZppP8AWDq1hc6EcJbsFwDjsdeu+6ZehI8EsjzC8hlAy8Q oEor/ndoyngPrpB2n9oybdIQ8ruGOec= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-190-BjOq5tLrP2iEauWIDjsanA-1; Sat, 30 Nov 2019 01:53:35 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 92F3BDB20; Sat, 30 Nov 2019 06:53:34 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-12-80.pek2.redhat.com [10.72.12.80]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7F9FE60BF4; Sat, 30 Nov 2019 06:53:32 +0000 (UTC) From: Zorro Lang To: fstests@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org Subject: [PATCH] generic: test mount move semantics Date: Sat, 30 Nov 2019 14:53:24 +0800 Message-Id: <20191130065324.17608-1-zlang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: BjOq5tLrP2iEauWIDjsanA-1 X-Mimecast-Spam-Score: 0 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org This's a functional test case for mount --move operation, it verifies below semantics: --------------------------------------------------------------------------- | MOVE MOUNT OPERATION | |************************************************************************** |source(A)->| shared | private | slave | unbindable | | dest(B) | | | | | | | | | | | | | v | | | | | |************************************************************************** | shared | shared | shared | shared & slave | invalid | | | | | | | |non-shared| shared | private | slave | unbindable | *************************************************************************** NOTE: moving a mount residing under a shared mount is invalid. This case uses fsstress to produce a little random load, to make sure basic operations won't break the the moved mountpoints. Signed-off-by: Zorro Lang --- Hi, It's been long time (maybe 2 years) since I finished this test case. Those cases before this one have been merged: 8a02ca3b generic: test two vfsmount no peers 101cb277 generic: test mount shared subtrees state transition 71691c26 generic: test bind mount operations 74a84259 common/rc: new functions for multi-level mount/umount operations I thought this 'mount --move' test wasn't so necessary, so I left it in my local repo long time. But now upstream fsdevel is developing new mount API, I think this case will be helpful for that (if mount util supports new mount API later). So I change it a little then send out again. Thanks, Zorro common/rc | 6 + tests/generic/586 | 182 ++++++++++++++++++++ tests/generic/586.out | 374 ++++++++++++++++++++++++++++++++++++++++++ tests/generic/group | 1 + 4 files changed, 563 insertions(+) create mode 100755 tests/generic/586 create mode 100644 tests/generic/586.out diff --git a/common/rc b/common/rc index b988e912..936cc5c5 100644 --- a/common/rc +++ b/common/rc @@ -189,6 +189,12 @@ _get_mount() _mount $scratch_opts $* if [ $? -eq 0 ]; then + # mount --move operation updates the mountpoint, so remove + # the old one and insert the new one + if [[ "$*" =~ --move|-M ]]; then + MOUNTED_POINT_STACK=`echo $MOUNTED_POINT_STACK | \ + cut -d\ -f2-` + fi MOUNTED_POINT_STACK="$mnt_point $MOUNTED_POINT_STACK" else return 1 diff --git a/tests/generic/586 b/tests/generic/586 new file mode 100755 index 00000000..170e57bc --- /dev/null +++ b/tests/generic/586 @@ -0,0 +1,182 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2019 Red Hat Inc. All Rights Reserved. +# +# FS QA Test 586 +# +# Test mount shared subtrees, verify the move semantics: +# +# --------------------------------------------------------------------------- +# | MOVE MOUNT OPERATION | +# |************************************************************************** +# |source(A)->| shared | private | slave | unbindable | +# | dest(B) | | | | | +# | | | | | | | +# | v | | | | | +# |************************************************************************** +# | shared | shared | shared | shared & slave | invalid | +# | | | | | | +# |non-shared| shared | private | slave | unbindable | +# *************************************************************************** +# NOTE: moving a mount residing under a shared mount is invalid. +# +#----------------------------------------------------------------------- +# +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* + _clear_mount_stack + # make sure there's no bug cause dentry isn't be freed + rm -rf $MNTHEAD +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here +_supported_fs generic +_supported_os Linux +_require_test +_require_scratch +_require_local_device $SCRATCH_DEV + +fs_stress() +{ + local target=$1 + + $FSSTRESS_PROG -n 50 -p 3 -d $target >/dev/null + sync +} + +# prepare some mountpoint dir +SRCHEAD=$TEST_DIR/$seq-src +DSTHEAD=$TEST_DIR/$seq-dst +rm -rf $SRCHEAD $DSTHEAD +mkdir $SRCHEAD $DSTHEAD 2>>$seqres.full +mpA=$SRCHEAD/"$$"_mpA +mpB=$SRCHEAD/"$$"_mpB +mpC=$DSTHEAD/"$$"_mpC +mpD=$DSTHEAD/"$$"_mpD + +find_mnt() +{ + echo "------" + findmnt -n -o TARGET,SOURCE $SCRATCH_DEV | \ + sed -e "s;$mpA;mpA;g" \ + -e "s;$mpB;mpB;g" \ + -e "s;$mpC;mpC;g" \ + -e "s;$mpD;mpD;g" | \ + _filter_spaces | _filter_testdir_and_scratch | sort + echo "======" +} + +start_test() +{ + local type=$1 + + _scratch_mkfs >$seqres.full 2>&1 + + _get_mount -t $FSTYP $SCRATCH_DEV $SRCHEAD + # make sure $SRCHEAD is private + $MOUNT_PROG --make-private $SRCHEAD + + _get_mount -t $FSTYP $SCRATCH_DEV $DSTHEAD + # test start with a bind, then make-shared $DSTHEAD + _get_mount --bind $DSTHEAD $DSTHEAD + $MOUNT_PROG --make-"${type}" $DSTHEAD + mkdir $mpA $mpB $mpC $mpD +} + +end_test() +{ + _clear_mount_stack + rm -rf $mpA $mpB $mpC $mpD +} + +move_run() +{ + local source=$1 + local dest=$2 + + start_test $dest + + echo "move $source to $dest" + _get_mount -t $FSTYP $SCRATCH_DEV $mpA + mkdir -p $mpA/dir 2>/dev/null + $MOUNT_PROG --make-shared $mpA + # need a peer for slave later + _get_mount --bind $mpA $mpB + $MOUNT_PROG --make-"$source" $mpB + # maybe unbindable at here + _get_mount --move $mpB $mpC 2>/dev/null + if [ $? -ne 0 ]; then + find_mnt + end_test + return 0 + fi + + # check mpC after move B to C + for m in $mpA $mpC; do + _get_mount -t $FSTYP $SCRATCH_DEV $m/dir + fs_stress $m/dir + find_mnt + _put_mount + done + + # mpC will be in different parent mount, test moving from different + # parent mount, and moving a mount residing under a shared mount is + # invalid + _get_mount --move $mpC $mpD 2>/dev/null + if [ $? -ne 0 ]; then + find_mnt + end_test + return 0 + fi + for m in $mpA $mpD; do + _get_mount -t $FSTYP $SCRATCH_DEV $m/dir + fs_stress $m/dir + find_mnt + _put_mount + done + + end_test +} + +move_test() +{ + # source dest + move_run shared shared + move_run slave shared + move_run private shared + move_run unbindable shared + + move_run shared slave + move_run slave slave + move_run private slave + move_run unbindable slave + + move_run shared private + move_run slave private + move_run private private + move_run unbindable private +} + +move_test + +# success, all done +status=0 +exit diff --git a/tests/generic/586.out b/tests/generic/586.out new file mode 100644 index 00000000..efa99942 --- /dev/null +++ b/tests/generic/586.out @@ -0,0 +1,374 @@ +QA output created by 586 +move shared to shared +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpA/dir SCRATCH_DEV +mpC SCRATCH_DEV +mpC SCRATCH_DEV +mpC/dir SCRATCH_DEV +mpC/dir SCRATCH_DEV +====== +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpA/dir SCRATCH_DEV +mpC SCRATCH_DEV +mpC SCRATCH_DEV +mpC/dir SCRATCH_DEV +mpC/dir SCRATCH_DEV +====== +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpC SCRATCH_DEV +mpC SCRATCH_DEV +====== +move slave to shared +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpA/dir SCRATCH_DEV +mpC SCRATCH_DEV +mpC SCRATCH_DEV +mpC/dir SCRATCH_DEV +mpC/dir SCRATCH_DEV +====== +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpC SCRATCH_DEV +mpC SCRATCH_DEV +mpC/dir SCRATCH_DEV +mpC/dir SCRATCH_DEV +====== +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpC SCRATCH_DEV +mpC SCRATCH_DEV +====== +move private to shared +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpA/dir SCRATCH_DEV +mpC SCRATCH_DEV +mpC SCRATCH_DEV +====== +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpC SCRATCH_DEV +mpC SCRATCH_DEV +mpC/dir SCRATCH_DEV +mpC/dir SCRATCH_DEV +====== +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpC SCRATCH_DEV +mpC SCRATCH_DEV +====== +move unbindable to shared +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpB SCRATCH_DEV +====== +move shared to slave +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpA/dir SCRATCH_DEV +mpC SCRATCH_DEV +mpC/dir SCRATCH_DEV +====== +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpA/dir SCRATCH_DEV +mpC SCRATCH_DEV +mpC/dir SCRATCH_DEV +====== +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpA/dir SCRATCH_DEV +mpD SCRATCH_DEV +mpD/dir SCRATCH_DEV +====== +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpA/dir SCRATCH_DEV +mpD SCRATCH_DEV +mpD/dir SCRATCH_DEV +====== +move slave to slave +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpA/dir SCRATCH_DEV +mpC SCRATCH_DEV +mpC/dir SCRATCH_DEV +====== +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpC SCRATCH_DEV +mpC/dir SCRATCH_DEV +====== +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpA/dir SCRATCH_DEV +mpD SCRATCH_DEV +mpD/dir SCRATCH_DEV +====== +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpD SCRATCH_DEV +mpD/dir SCRATCH_DEV +====== +move private to slave +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpA/dir SCRATCH_DEV +mpC SCRATCH_DEV +====== +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpC SCRATCH_DEV +mpC/dir SCRATCH_DEV +====== +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpA/dir SCRATCH_DEV +mpD SCRATCH_DEV +====== +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpD SCRATCH_DEV +mpD/dir SCRATCH_DEV +====== +move unbindable to slave +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpA/dir SCRATCH_DEV +mpC SCRATCH_DEV +====== +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpC SCRATCH_DEV +mpC/dir SCRATCH_DEV +====== +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpA/dir SCRATCH_DEV +mpD SCRATCH_DEV +====== +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpD SCRATCH_DEV +mpD/dir SCRATCH_DEV +====== +move shared to private +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpA/dir SCRATCH_DEV +mpC SCRATCH_DEV +mpC/dir SCRATCH_DEV +====== +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpA/dir SCRATCH_DEV +mpC SCRATCH_DEV +mpC/dir SCRATCH_DEV +====== +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpA/dir SCRATCH_DEV +mpD SCRATCH_DEV +mpD/dir SCRATCH_DEV +====== +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpA/dir SCRATCH_DEV +mpD SCRATCH_DEV +mpD/dir SCRATCH_DEV +====== +move slave to private +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpA/dir SCRATCH_DEV +mpC SCRATCH_DEV +mpC/dir SCRATCH_DEV +====== +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpC SCRATCH_DEV +mpC/dir SCRATCH_DEV +====== +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpA/dir SCRATCH_DEV +mpD SCRATCH_DEV +mpD/dir SCRATCH_DEV +====== +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpD SCRATCH_DEV +mpD/dir SCRATCH_DEV +====== +move private to private +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpA/dir SCRATCH_DEV +mpC SCRATCH_DEV +====== +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpC SCRATCH_DEV +mpC/dir SCRATCH_DEV +====== +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpA/dir SCRATCH_DEV +mpD SCRATCH_DEV +====== +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpD SCRATCH_DEV +mpD/dir SCRATCH_DEV +====== +move unbindable to private +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpA/dir SCRATCH_DEV +mpC SCRATCH_DEV +====== +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpC SCRATCH_DEV +mpC/dir SCRATCH_DEV +====== +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpA/dir SCRATCH_DEV +mpD SCRATCH_DEV +====== +------ +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-dst SCRATCH_DEV +TEST_DIR/586-src SCRATCH_DEV +mpA SCRATCH_DEV +mpD SCRATCH_DEV +mpD/dir SCRATCH_DEV +====== diff --git a/tests/generic/group b/tests/generic/group index e5d0c1da..7ceddfcd 100644 --- a/tests/generic/group +++ b/tests/generic/group @@ -588,3 +588,4 @@ 583 auto quick encrypt 584 auto quick encrypt 585 auto rename +586 auto quick mount