From patchwork Thu Sep 1 05:06:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eryu Guan X-Patchwork-Id: 9308335 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 E7DF160865 for ; Thu, 1 Sep 2016 05:08:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D9AA429170 for ; Thu, 1 Sep 2016 05:08:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE93429190; Thu, 1 Sep 2016 05:08:01 +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 5D95C29173 for ; Thu, 1 Sep 2016 05:08:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750762AbcIAFIA (ORCPT ); Thu, 1 Sep 2016 01:08:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53096 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750750AbcIAFIA (ORCPT ); Thu, 1 Sep 2016 01:08:00 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 96AFB635C3 for ; Thu, 1 Sep 2016 05:07:52 +0000 (UTC) Received: from localhost (dhcp-13-153.nay.redhat.com [10.66.13.153]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u8157pYZ023319; Thu, 1 Sep 2016 01:07:52 -0400 From: Eryu Guan To: fstests@vger.kernel.org Cc: Eryu Guan Subject: [PATCH v3 2/2] overlay: copy-up lowerdir which has opaque xattr set Date: Thu, 1 Sep 2016 13:06:24 +0800 Message-Id: <1472706384-12262-2-git-send-email-eguan@redhat.com> In-Reply-To: <1472706384-12262-1-git-send-email-eguan@redhat.com> References: <1472706384-12262-1-git-send-email-eguan@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 01 Sep 2016 05:07:52 +0000 (UTC) Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When copying up a directory with opaque xattr set, the xattr was copied up as well, after a remount the opaque flag is honored so the copied-up directory is treated as opaque, which causes files created in the lowerdir to be hidden when using multiple lower directories. This is fixed by "ovl: don't copy up opaqueness". Signed-off-by: Eryu Guan Reviewed-by: Dave Chinner --- v3: - replace mounted device "none" by $SCRATCH_DEV v2: - use _overlay_mount_dirs helper to do the overlay mount - use _scratch_unmount instead of raw $UMOUNT_PROG - remove unused _require_attrs tests/overlay/014 | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/overlay/014.out | 3 ++ tests/overlay/group | 1 + 3 files changed, 98 insertions(+) create mode 100755 tests/overlay/014 create mode 100644 tests/overlay/014.out diff --git a/tests/overlay/014 b/tests/overlay/014 new file mode 100755 index 0000000..36d7077 --- /dev/null +++ b/tests/overlay/014 @@ -0,0 +1,94 @@ +#! /bin/bash +# FS QA Test 014 +# +# Test copy-up of lowerdir with opaque xattr set. +# +# When copying up a directory with opaque xattr set, the xattr was copied up as +# well, after a remount the opaque flag is honored so the copied-up directory +# is treated as opaque, which causes files created in the lowerdir to be hidden +# when using multiple lower directories. +# +# This is fixed by "ovl: don't copy up opaqueness". +# +#----------------------------------------------------------------------- +# Copyright (c) 2016 Red Hat Inc. All Rights Reserved. +# +# 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. +# +# This program is distributed in the hope that it would 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, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# + +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.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/attr + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here +_supported_fs overlay +_supported_os Linux +_require_test +_require_scratch + +# Remove all files from previous tests +_scratch_mkfs + +# Create multiple lowerdirs and upperdir, workdir, and testdir on lowerdir +lowerdir1=$SCRATCH_DEV/lower1 +lowerdir2=$SCRATCH_DEV/lower2 +upperdir=$SCRATCH_DEV/upper +workdir=$SCRATCH_DEV/workdir +mkdir -p $lowerdir1 $lowerdir2 $upperdir $workdir +mkdir -p $lowerdir1/testdir/d + +# mount overlay with $lowerdir2 as upperdir, and remove & recreate testdir, +# make testdir on $lowerdir2 opaque +_overlay_mount_dirs $lowerdir1 $lowerdir2 $workdir $SCRATCH_DEV $SCRATCH_MNT +rm -rf $SCRATCH_MNT/testdir +mkdir -p $SCRATCH_MNT/testdir/visibledir +_scratch_unmount + +# mount overlay again, with lowerdir1 and lowerdir2 as multiple lowerdirs, +# and create a new file in testdir, triggers copyup from lowerdir, +# copyup should not copy overlayfs private xattr +_overlay_mount_dirs "$lowerdir2:$lowerdir1" $upperdir $workdir \ + $SCRATCH_DEV $SCRATCH_MNT +touch $SCRATCH_MNT/testdir/visiblefile + +# umount and mount overlay again, buggy kernel treats the copied-up dir as +# opaque, visibledir is not seen in merged dir. +_scratch_unmount +_overlay_mount_dirs "$lowerdir2:$lowerdir1" $upperdir $workdir \ + $SCRATCH_DEV $SCRATCH_MNT +ls $SCRATCH_MNT/testdir + +# success, all done +status=0 +exit diff --git a/tests/overlay/014.out b/tests/overlay/014.out new file mode 100644 index 0000000..ec09c4d --- /dev/null +++ b/tests/overlay/014.out @@ -0,0 +1,3 @@ +QA output created by 014 +visibledir +visiblefile diff --git a/tests/overlay/group b/tests/overlay/group index 5c80566..71eaadb 100644 --- a/tests/overlay/group +++ b/tests/overlay/group @@ -16,3 +16,4 @@ 011 auto quick 012 auto quick 013 auto quick +014 auto quick copyup