From patchwork Wed May 6 10:15:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 11530985 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 26C2792A for ; Wed, 6 May 2020 10:16:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DFC9620753 for ; Wed, 6 May 2020 10:16:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mykernel.net header.i=cgxu519@mykernel.net header.b="VGFH9rUu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728314AbgEFKQE (ORCPT ); Wed, 6 May 2020 06:16:04 -0400 Received: from sender2-of-o52.zoho.com.cn ([163.53.93.247]:21128 "EHLO sender2-of-o52.zoho.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726354AbgEFKQE (ORCPT ); Wed, 6 May 2020 06:16:04 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1588760140; cv=none; d=zoho.com.cn; s=zohoarc; b=mm7/+5PPpn1lWayFVZ2bxIhX2UYnTCaDjJD4RfDn0Xxk5tiZHKU7pEhbznl7HgaDl+uQaPZKoYmZQ012QVQnKj6XYxPgWL2YMqCUn5lG+he3VSRENp4Me1F77rOdcnMsw1wGQhe9ZdqsVgSw9O2FpKgEBLs461mqRTV6oWiMxgQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com.cn; s=zohoarc; t=1588760140; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=Ggml1o82k6KVm5HD6w6KjbpDYIEsphB7H0u6YgALDCo=; b=AG8SFEnn5hTbRVM27gBGSESscNOOWh4jA7ZiRWr7RiUrsqH5fVMZm4WQEDvpSZNNRwgRzMC33VY8/IK/Qm+eaFnCskQi4r7WzI9Wh5KIm61taEk7E6sTz+XQHUOAi12zt9AZFKshYG6WDolJ5zmVIFWlTvmVeoJ/MkEP6HQyGu8= ARC-Authentication-Results: i=1; mx.zoho.com.cn; dkim=pass header.i=mykernel.net; spf=pass smtp.mailfrom=cgxu519@mykernel.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1588760140; s=zohomail; d=mykernel.net; i=cgxu519@mykernel.net; h=From:To:Cc:Message-ID:Subject:Date:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=Ggml1o82k6KVm5HD6w6KjbpDYIEsphB7H0u6YgALDCo=; b=VGFH9rUu+BUVt090JwxWlhQo4nY/lqWIARbRS1bJL+4VsMd5tnQo6cui/rlrshNJ xK9iorGzMX3UGtveNGezq+o0uvcBI5MZ34iMSNf4NGgzUYgAtAMKrS4j/v7yTjAyJUf 7uBgpgqQlJzS8NIWOF4uB5kY2vfoOXLPsKIUsuQo= Received: from localhost.localdomain (218.18.229.179 [218.18.229.179]) by mx.zoho.com.cn with SMTPS id 1588760138811260.042708897837; Wed, 6 May 2020 18:15:38 +0800 (CST) From: Chengguang Xu To: guan@eryu.me, miklos@szeredi.hu, amir73il@gmail.com Cc: fstests@vger.kernel.org, linux-unionfs@vger.kernel.org, Chengguang Xu Message-ID: <20200506101528.27359-1-cgxu519@mykernel.net> Subject: [PATCH v4] overlay/072: test for whiteout inode sharing Date: Wed, 6 May 2020 18:15:28 +0800 X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-ZohoCNMailClient: External Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org This is a test for whiteout inode sharing feature. Signed-off-by: Chengguang Xu Reviewed-by: Amir Goldstein --- v1->v2: - Address Amir's comments in v1 v2->v3: - Address Amir's comments in v2 v3->v4: - Fix test case based on latest kernel patch(removed module param) https://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs.git/commit/?h=overlayfs-next&id=4e49695244661568130bfefcb6143dd1eaa3d8e7 tests/overlay/072 | 106 ++++++++++++++++++++++++++++++++++++++++++ tests/overlay/072.out | 2 + tests/overlay/group | 1 + 3 files changed, 109 insertions(+) create mode 100755 tests/overlay/072 create mode 100644 tests/overlay/072.out diff --git a/tests/overlay/072 b/tests/overlay/072 new file mode 100755 index 00000000..fc847092 --- /dev/null +++ b/tests/overlay/072 @@ -0,0 +1,106 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2020 Chengguang Xu . +# All Rights Reserved. +# +# FS QA Test 072 +# +# Test whiteout inode sharing functionality. +# +# A "whiteout" is an object that has special meaning in overlayfs. +# A whiteout on an upper layer will effectively hide a matching file +# in the lower layer, making it appear as if the file didn't exist. +# +# Whiteout inode sharing means multiple whiteout objects will share +# one inode in upper layer, without this feature every whiteout object +# will consume one inode in upper layer. + +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 + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here +_supported_fs overlay +_supported_os Linux +_require_scratch + +lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER +upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER +workdir=$OVL_BASE_SCRATCH_MNT/$OVL_WORK + +# Make some testing files in lowerdir. +# Argument: +# $1: Testing file number +make_lower_files() +{ + for name in `seq ${1}`; do + touch $lowerdir/file${name} &>/dev/null + done +} + +# Delete all copy-uped files in upperdir. +make_whiteout_files() +{ + rm -f $SCRATCH_MNT/* &>/dev/null +} + +# Check link count of whiteout files. +# Arguments: +# $1: Testing file number +# $2: Expected link count +check_whiteout_files() +{ + for name in `seq ${1}`; do + local real_count=`stat -c %h $upperdir/file${name} 2>/dev/null` + if [[ ${2} != $real_count ]]; then + echo "Expected link count is ${2} but real count is $real_count, file name is file${name}" + fi + done + local tmpfile_count=`ls $workdir/work/\#* $workdir/index/\#* 2>/dev/null |wc -l 2>/dev/null` + if [[ -n "$tmpfile_count" && $tmpfile_count > 1 ]]; then + echo "There are more than one whiteout tmpfile in work/index dir!" + ls -l $workdir/work/\#* $workdir/index/\#* 2>/dev/null + fi +} + +# Run test case with specific arguments. +# Arguments: +# $1: Testing file number +# $2: Expected link count +run_test_case() +{ + _scratch_mkfs + make_lower_files ${1} + _scratch_mount + make_whiteout_files + check_whiteout_files ${1} ${2} + _scratch_unmount +} + +#Test case +file_count=10 +link_count=11 +run_test_case $file_count $link_count + +# success, all done +echo "Silence is golden" +status=0 +exit diff --git a/tests/overlay/072.out b/tests/overlay/072.out new file mode 100644 index 00000000..590bbc6c --- /dev/null +++ b/tests/overlay/072.out @@ -0,0 +1,2 @@ +QA output created by 072 +Silence is golden diff --git a/tests/overlay/group b/tests/overlay/group index 43ad8a52..8b2276f1 100644 --- a/tests/overlay/group +++ b/tests/overlay/group @@ -74,3 +74,4 @@ 069 auto quick copyup hardlink exportfs nested nonsamefs 070 auto quick copyup redirect nested 071 auto quick copyup redirect nested nonsamefs +072 auto quick whiteout