From patchwork Thu Nov 7 02:59:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 11231691 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 A401C1575 for ; Thu, 7 Nov 2019 03:00:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 756D521882 for ; Thu, 7 Nov 2019 03:00:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mykernel.net header.i=cgxu519@mykernel.net header.b="NL8nN3f1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732732AbfKGDAm (ORCPT ); Wed, 6 Nov 2019 22:00:42 -0500 Received: from sender3-of-o52.zoho.com.cn ([124.251.121.247]:21904 "EHLO sender2.zoho.com.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727665AbfKGDAm (ORCPT ); Wed, 6 Nov 2019 22:00:42 -0500 ARC-Seal: i=1; a=rsa-sha256; t=1573095620; cv=none; d=zoho.com.cn; s=zohoarc; b=oLBWPv5/bnrH0bxS1NaKU257OYOxYiJJpr4PqX5ILcRoIXrIYepQM64G8TGdOKMNlZzI6KbGAIsaqsd9Wdw4KUuZyTkZO9Ly7EmPbHrO0/PC38oW6/Ne0Z9VTnSvQquU/AWoSPLfbSyadPDXbPUNwjscQactmfNVq2wGsToiScQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com.cn; s=zohoarc; t=1573095620; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=ZBWUJo2lnACLBGedWhqkmr+4WQ6Cd+EYougQkyojCRU=; b=EF4paURJm/xwFI1PRC7uEJ7B+mC7HyX6VKgVRD0UUnUhGd0tzURLTENphN2tFhKDai+Pg4Fg4nG/7EsHXUq5zMrLeR3PNn+wQpe9sSNRLZDp7rnYc3zKZpAS58hL7MrAQpMx6FPD6OIHjkcHX3Al9d8w+kB7kiB4gOYDZ7FRCUw= 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=1573095620; s=zohomail; d=mykernel.net; i=cgxu519@mykernel.net; h=From:To:Cc:Message-ID:Subject:Date:MIME-Version:Content-Transfer-Encoding:Content-Type; l=7397; bh=ZBWUJo2lnACLBGedWhqkmr+4WQ6Cd+EYougQkyojCRU=; b=NL8nN3f1JB10QiercHEMNhXQ77c+Pi3eEj58hgj86MPklVyxh3JV5UbsKsYbosVi OFJUsZT3csPtR5bG6W9QnUqm1j2aFQeKYV8tBZuB+Sw8Advxz3nkhghgpxTIH5WO/zM 1m/2RqZohARY/DSiwT/8bFoNEYt6WeA/TenL9Bl4= Received: from localhost.localdomain (218.18.229.179 [218.18.229.179]) by mx.zoho.com.cn with SMTPS id 1573095617141825.4514740246625; Thu, 7 Nov 2019 11:00:17 +0800 (CST) From: Chengguang Xu To: fstests@vger.kernel.org, linux-unionfs@vger.kernel.org Cc: guaneryu@gmail.com, amir73il@gmail.com, miklos@szeredi.hu, Chengguang Xu Message-ID: <20191107025941.24605-1-cgxu519@mykernel.net> Subject: [PATCH v4] overlay/066: adjust test file size && add more test patterns Date: Thu, 7 Nov 2019 10:59:41 +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 Making many small holes in 10M test file seems not very helpful for test coverage and it takes too much time on creating test files. In order to improve test speed we adjust test file size to (10 * iosize) for iosize aligned hole files and meanwhile add more test patterns for small random holes and small empty file. Reviewed-by: Amir Goldstein Signed-off-by: Chengguang Xu --- v1->v2: - Check result in one diff command. - Print more information(file layout) to full log when test failed. - Truncate test file name. v2->v3: - Print diff result to golden output. - Record xfs_io command to full log. - Set initial pos and max_pos using calculation for random hole file. v3->v4: - Fix var name typo(max_hole -> max_pos). tests/overlay/066 | 120 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 83 insertions(+), 37 deletions(-) diff --git a/tests/overlay/066 b/tests/overlay/066 index 285a5aff..deeec74f 100755 --- a/tests/overlay/066 +++ b/tests/overlay/066 @@ -40,90 +40,136 @@ _require_scratch # Remove all files from previous tests _scratch_mkfs -# We have totally 14 test files in this test. +# We have totally 16 test files in this test. # The detail as below: -# 1 empty file(10M) + 2^0(K)..2^11(K) hole size files(each 10M) + 1 random hole size file(100M). +# 1 small empty file 4K +# 1 big empty file 4M +# 1 small random hole file 10M +# 1 big random hole file 100M +# +# 12 files with variant iosize aligned holes. +# 2^0(K)..2^11(K) hole size files(file size = 10 * iosize) # # Considering both upper and lower fs will fill zero when copy-up # hole area in the file, this test at least requires double disk # space of the sum of above test files' size. -_require_fs_space $OVL_BASE_SCRATCH_MNT $(((10*1024*13 + 100*1024*1) * 2)) +_require_fs_space $OVL_BASE_SCRATCH_MNT $((((4) + (4096) + (10 * 1024) \ + + (100 * 1024) + (10 * (1 + 2048) * 12 / 2)) * 2)) + +do_cmd() +{ + echo $@ >>$seqres.full + eval $@ >>$seqres.full +} lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER testfile="copyup_sparse_test" -# Create a completely empty hole file(10M). -file_size=10240 -$XFS_IO_PROG -fc "truncate ${file_size}K" "${lowerdir}/${testfile}_empty_holefile" \ - >>$seqres.full +# Create a small completely empty hole file(4K). +file_size=4 +do_cmd $XFS_IO_PROG -fc "\"truncate ${file_size}K\"" \ + "${lowerdir}/${testfile}_empty_small" -# Create 2^0(K)..2^11(K) hole size test files(each 10M). +# Create a big completely empty hole file(4M). +file_size=4096 +do_cmd $XFS_IO_PROG -fc "\"truncate ${file_size}K\"" \ + "${lowerdir}/${testfile}_empty_big" + +# Create 2^0(K)..2^11(K) hole size test files(file size = 10 * iosize). # # The pattern is like below, both hole and data are equal to # iosize except last hole. # # |-- hole --|-- data --| ... |-- data --|-- hole --| -iosize=1 +min_iosize=1 max_iosize=2048 -file_size=10240 -max_pos=`expr $file_size - $max_iosize` +iosize=$min_iosize while [ $iosize -le $max_iosize ]; do + file_size=$(($iosize * 10)) + max_pos=$(($file_size - $iosize)) pos=$iosize - $XFS_IO_PROG -fc "truncate ${file_size}K" \ - "${lowerdir}/${testfile}_iosize${iosize}K_holefile" >>$seqres.full + do_cmd $XFS_IO_PROG -fc "\"truncate ${file_size}K\"" \ + "${lowerdir}/${testfile}_iosize${iosize}K" + echo -e "\niosize=${iosize}K hole test write scenarios ---\n" >>$seqres.full while [ $pos -lt $max_pos ]; do - $XFS_IO_PROG -fc "pwrite ${pos}K ${iosize}K" \ - "${lowerdir}/${testfile}_iosize${iosize}K_holefile" >>$seqres.full - pos=`expr $pos + $iosize + $iosize` + do_cmd $XFS_IO_PROG -fc "\"pwrite ${pos}K ${iosize}K\"" \ + "${lowerdir}/${testfile}_iosize${iosize}K" + pos=$(($pos + $iosize * 2)) done - iosize=`expr $iosize + $iosize` + iosize=$(($iosize * 2)) +done +echo >>$seqres.full + +# Create test file with many random small holes(hole size is between 4K and 512K), +# total file size is 10M. + +file_size=10240 +min_hole=4 +max_hole=512 +pos=$min_hole +max_pos=$(($file_size - 2*$max_hole)) + +do_cmd $XFS_IO_PROG -fc "\"truncate ${file_size}K\"" \ + "${lowerdir}/${testfile}_random_small" + +echo -e "\nSmall random hole test write scenarios ---\n" >>$seqres.full +while [ $pos -le $max_pos ]; do + iosize=$(($RANDOM % ($max_hole - $min_hole) + $min_hole)) + do_cmd $XFS_IO_PROG -fc "\"pwrite ${pos}K ${iosize}K\"" \ + "${lowerdir}/${testfile}_random_small" + pos=$(($pos + $iosize * 2)) done +echo >>$seqres.full + # Create test file with many random holes(hole size is between 1M and 5M), # total file size is 100M. -pos=2048 -max_pos=81920 file_size=102400 min_hole=1024 max_hole=5120 +pos=$min_hole +max_pos=$(($file_size - 2*$max_hole)) -$XFS_IO_PROG -fc "truncate ${file_size}K" "${lowerdir}/${testfile}_random_holefile" \ - >>$seqres.full +do_cmd $XFS_IO_PROG -fc "\"truncate ${file_size}K\"" \ + "${lowerdir}/${testfile}_random_big" +echo -e "\nBig random hole test write scenarios ---\n" >>$seqres.full while [ $pos -le $max_pos ]; do iosize=$(($RANDOM % ($max_hole - $min_hole) + $min_hole)) - $XFS_IO_PROG -fc "pwrite ${pos}K ${iosize}K" \ - "${lowerdir}/${testfile}_random_holefile" >>$seqres.full - pos=`expr $pos + $iosize + $iosize` + do_cmd $XFS_IO_PROG -fc "\"pwrite ${pos}K ${iosize}K\"" \ + "${lowerdir}/${testfile}_random_big" + pos=$(($pos + $iosize * 2)) done +echo >>$seqres.full _scratch_mount # Open the test files, no errors are expected. +echo -e "\nDoing copy-up...\n" >>$seqres.full for f in $SCRATCH_MNT/*; do - $XFS_IO_PROG -c "open" $f >>$seqres.full + do_cmd $XFS_IO_PROG -c "open" $f done echo "Silence is golden" # Check all copy-up files in upper layer. -iosize=1 -while [ $iosize -le 2048 ]; do - diff "${lowerdir}/${testfile}_iosize${iosize}K_holefile" \ - "${upperdir}/${testfile}_iosize${iosize}K_holefile" >>$seqres.full ||\ - echo "${upperdir}/${testfile}_iosize${iosize}K_holefile" copy up failed! - iosize=`expr $iosize + $iosize` -done - -diff "${lowerdir}/${testfile}_empty_holefile" "${upperdir}/${testfile}_empty_holefile" \ - >>$seqres.full || echo "${upperdir}/${testfile}_empty_holefile" copy up failed! -diff "${lowerdir}/${testfile}_random_holefile" "${upperdir}/${testfile}_random_holefile" \ - >>$seqres.full || echo "${upperdir}/${testfile}_random_holefile" copy up failed! +diff -qr ${upperdir} ${lowerdir} | tee -a $seqres.full +if [ $? -ne 0 ]; then + echo "Copy-up failed!!!" + + echo "\n----------------------------------------" >>$seqres.full + echo -e "The layout of files in lowerdir\n" >>$seqres.full + do_cmd $FILEFRAG_PROG -k -e $lowerdir/* + echo "\n----------------------------------------" >>$seqres.full + echo -e "The layer of files in upperdir\n" >>$seqres.full + do_cmd $FILEFRAG_PROG -k -e $upperdir/* + +fi # success, all done status=0