From patchwork Tue Apr 14 02:31:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 11486543 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 65B1314B4 for ; Tue, 14 Apr 2020 02:32:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1D7FB2075E for ; Tue, 14 Apr 2020 02:32:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mykernel.net header.i=cgxu519@mykernel.net header.b="dZM81xq4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404125AbgDNCcA (ORCPT ); Mon, 13 Apr 2020 22:32:00 -0400 Received: from sender2-of-o52.zoho.com.cn ([163.53.93.247]:21111 "EHLO sender2-of-o52.zoho.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728787AbgDNCb7 (ORCPT ); Mon, 13 Apr 2020 22:31:59 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1586831494; cv=none; d=zoho.com.cn; s=zohoarc; b=mGx8ZWJFLudppO+rLehFTuK9/bOek4n0erhz1z9vTPmxe2rO+F22pvojq/KBeRSmG4CfFsJTzRRaYGxw95V9xxCsWRqbT24sAxOxOMrYubZIguuedSK5GT/G7bWQsjhBUA3IKcfQ9xqzdKAqF52vDnRTzRusZYQPKsaZNhXmPZk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com.cn; s=zohoarc; t=1586831494; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=jmJ3DZa3AzQqDsTyJxHEVcDXa7r2+k89362b/f+DFgU=; b=U/SXurY7w9iGRP3WydMEMJmKmLmSwIb9NpaO+mQVHJZwnVXR8e26Nubal7IEAPw6vojJE3dbN92vWoh8FHXEC7mCEe+i8dBkmscPGVtGbgm5da3c1c1aOGG5aeT27yqaNNlY7pemsp/nXucsU27RRmLU1BccgpZ++qOGdwxyzY0= 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=1586831494; 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=jmJ3DZa3AzQqDsTyJxHEVcDXa7r2+k89362b/f+DFgU=; b=dZM81xq4Z9hWs+/snzO5whajekWyQc84MkPhV0s9C8Vg8xwupcTgbXJd7jhpjdmo DKeDZRv3XOlrMcWPosW/iRCn5H5YIuI+3sVha+NI+neYS2MdcOnB7TdxfN0oOwaybnw A0FZVOHF8xmK21aZQ4YEL9RovYC8GjvevvkzVlJs= Received: from localhost.localdomain (218.18.229.179 [218.18.229.179]) by mx.zoho.com.cn with SMTPS id 1586831491350315.98897441673193; Tue, 14 Apr 2020 10:31:31 +0800 (CST) From: Chengguang Xu To: guaneryu@gmail.com Cc: fstests@vger.kernel.org, linux-unionfs@vger.kernel.org, miklos@szeredi.hu, amir73il@gmail.com, Chengguang Xu Message-ID: <20200414023105.28261-1-cgxu519@mykernel.net> Subject: [PATCH v2] overlay/072: test for whiteout inode sharing Date: Tue, 14 Apr 2020 10:31:05 +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. common/module | 9 +++ tests/overlay/072 | 148 ++++++++++++++++++++++++++++++++++++++++++ tests/overlay/072.out | 2 + tests/overlay/group | 1 + 4 files changed, 160 insertions(+) create mode 100755 tests/overlay/072 create mode 100644 tests/overlay/072.out diff --git a/common/module b/common/module index 39e4e793..148e8c8f 100644 --- a/common/module +++ b/common/module @@ -81,3 +81,12 @@ _get_fs_module_param() { cat /sys/module/${FSTYP}/parameters/${1} 2>/dev/null } + # Set the value of a filesystem module parameter + # at /sys/module/$FSTYP/parameters/$PARAM + # + # Usage example: + # _set_fs_module_param param value + _set_fs_module_param() +{ + echo ${2} > /sys/module/${FSTYP}/parameters/${1} 2>/dev/null +} diff --git a/tests/overlay/072 b/tests/overlay/072 new file mode 100755 index 00000000..e1244394 --- /dev/null +++ b/tests/overlay/072 @@ -0,0 +1,148 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2020 Chengguang Xu . +# All Rights Reserved. +# +# FS QA Test 072 +# +# This is a test for whiteout inode sharing feature. +# +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.* + _set_fs_module_param $param_name $orig_param_value +} + +# 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_test +_require_scratch + +param_name="whiteout_link_max" + +# Check overlayfs module param(whiteout_link_max) +check_whiteout_link_max() +{ + orig_param_value=`_get_fs_module_param ${param_name}` + if [ -z ${orig_param_value} ]; then + _notrun "${FSTYP} does not support whiteout inode sharing" + fi +} + +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 -s' ' ${1}` + do + touch $lowerdir/file${name} 1>&2 2>/dev/null + done +} + +# Delete all copy-uped files in upperdir. +make_whiteout_files() +{ + rm -f $SCRATCH_MNT/* 1>&2 2>/dev/null +} + +# Check link count of whiteout files. +# Arguments: +# $1: Testing file number +# $2: Expected link count +check_whiteout_files() +{ + for name in `seq -s' ' ${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: Maximum link count +# $2: Testing file number +# $3: Expected link count +run_test_case() +{ + _scratch_mkfs + _set_fs_module_param $param_name ${1} + make_lower_files ${2} + _scratch_mount + make_whiteout_files + check_whiteout_files ${2} ${3} + _scratch_unmount +} + +check_whiteout_link_max + +# Case1: +# Setting whiteout_link_max=0 means whiteout files will not +# share inode, each whiteout file will have it's own inode. + +link_max=0 +file_count=10 +link_count=1 +run_test_case $link_max $file_count $link_count + +# Case2: +# Setting whiteout_link_max=0 means whiteout files will not +# share inode, each whiteout file will have it's own inode. + +link_max=1 +file_count=10 +link_count=1 +run_test_case $link_max $file_count $link_count + +# Case3: +# Setting whiteout_link_max>2 means whiteout files will share +# inode and link count could up to whiteout_link_max. + +link_max=2 +file_count=10 +link_count=2 +run_test_case $link_max $file_count $link_count + +# Case4: +# Setting whiteout_link_max>2 means whiteout files will share +# inode and link count could up to whiteout_link_max. + +link_max=10 +file_count=20 +link_count=10 +run_test_case $link_max $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