Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1414208pxb; Sun, 7 Mar 2021 18:18:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJyxNIzghgU4Rkz8P4E8GwE+Qo4g6axNtKRRP3hSU0Ao5zk+6DMlzb43lIFH4vFCoeG14JOw X-Received: by 2002:a17:906:2743:: with SMTP id a3mr13068113ejd.378.1615169896833; Sun, 07 Mar 2021 18:18:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615169896; cv=none; d=google.com; s=arc-20160816; b=rer50vC+909vxWD00e3fmSgTyL/wKfrkDK0mZJA9rESzxXwe2hYTfhy9DEpUAWEcLa rmWLU8QXs/sVKIYp05gNkFJsp2YiWErvPY5Tjpr5PGLTMY6Kw5Gu920gIWO5FeW0OmvB 4mZZeZbWK6WNrkHoijo8AUbKJ5AB6wfdxT2OxKad8ALyjOieQ+t5eAwrpcnVC9SVeMzE CLQnkCdGM/ISC0xR9JEIzcwcCaMYCUjhjsNyaXnbouVMQzevNVLNCiTidA4hSJHUv1E7 fa+HUOAw7ULB2tuf7umjlfONc41Q0jjR79E5Tv/DBXY9f40ZONm0HhfR4IS4lnB0nIKr j2VQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=umK5taZ/X0it81dPCEnTLNfyFfKOJGvtMmsbBG1L+Mk=; b=oRArdPJYxJH585vGgP8uWKeO+iSFtzoghuNNLy5B7znGebyuQMQuFPpEu+yQcYAu7m EfdIey6+WyFvuP5FM78tA/kKaVLxb7t1yTys+GxcH0jfnbzhg7J6YAViu8I7m20Tev5D NBIHprC4uWhOB2uv49m4qU1eEKbR81DIcHqhyqc1a/wYrS5NgSD5xlAIBDfxOxvkEF6j S7+QgXdUF4phJaDeOfVDNCjAwm+/IvMWeGNsZD8NSw336vx5tSlkEhvyQX3heTvOJ7lI 5uKecV+5suO2TRnb0538YzqJIJFITGVR6E6kPNtvV5TgbVRAqy5N8C4KRbh0kK6dxKMM lM5w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j11si6992820edj.481.2021.03.07.18.17.46; Sun, 07 Mar 2021 18:18:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231417AbhCGPbH (ORCPT + 99 others); Sun, 7 Mar 2021 10:31:07 -0500 Received: from out20-98.mail.aliyun.com ([115.124.20.98]:56189 "EHLO out20-98.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231255AbhCGPa4 (ORCPT ); Sun, 7 Mar 2021 10:30:56 -0500 X-Alimail-AntiSpam: AC=CONTINUE;BC=0.0743673|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_system_inform|0.260236-0.00399315-0.735771;FP=0|0|0|0|0|-1|-1|-1;HT=ay29a033018047187;MF=guan@eryu.me;NM=1;PH=DS;RN=5;RT=5;SR=0;TI=SMTPD_---.JhdEwGg_1615131049; Received: from localhost(mailfrom:guan@eryu.me fp:SMTPD_---.JhdEwGg_1615131049) by smtp.aliyun-inc.com(10.147.41.143); Sun, 07 Mar 2021 23:30:50 +0800 Date: Sun, 7 Mar 2021 23:30:49 +0800 From: Eryu Guan To: Zorro Lang Cc: fstests@vger.kernel.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, sunke32@huawei.com Subject: Re: [PATCH] xfstests: rename RENAME_WHITEOUT test on fs no enough sapce Message-ID: References: <20210218071324.50413-1-zlang@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210218071324.50413-1-zlang@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Thu, Feb 18, 2021 at 03:13:24PM +0800, Zorro Lang wrote: > This's a regression test for linux 6b4b8e6b4ad8 ("ext4: fix bug for > rename with RENAME_WHITEOUT"). Rename a file with RENAME_WHITEOUT > flag might cause corruption when there's not enough space to > complete this renaming operation. > > Signed-off-by: Zorro Lang > Signed-off-by: Sun Ke > --- > > Hi, > > As the request of Sun Ke, I rewrite his test case as this patch. > The history of reviewing as below: > https://patchwork.kernel.org/project/fstests/patch/20210128061202.210074-1-sunke32@huawei.com/ > https://patchwork.kernel.org/project/fstests/patch/20210202123956.3146761-1-sunke32@huawei.com/ > > At last, I decide to create several chunks of files to do this testing, help to > get more chance to trigger ENOSPC when does rename(RENAME_WHITEOUT). > > From my testing, it can reproduce this bug on linux 5.10[1], and test passed on > linux 5.11-rc5+ [2]. And it works on XFS too. Hope to get more review from fs-devel. Thanks a lot for the revision! > > [1] > # ./check generic/623 > FSTYP -- ext4 > PLATFORM -- Linux/x86_64 ibm-xxxxxxx-xx 5.10.0-rc5+ #4 SMP Tue Jan 5 20:12:45 CST 2021 > MKFS_OPTIONS -- /dev/mapper/testvg-scratchdev > MOUNT_OPTIONS -- -o acl,user_xattr -o context=system_u:object_r:root_t:s0 /dev/mapper/testvg-scratchdev /mnt/scratch > > generic/623 _check_generic_filesystem: filesystem on /dev/mapper/testvg-scratchdev is inconsistent > (see /root/git/xfstests-zlang/results//generic/623.full for details) > - output mismatch (see /root/git/xfstests-zlang/results//generic/623.out.bad) > --- tests/generic/623.out 2021-02-18 13:26:35.953071523 +0800 > +++ /root/git/xfstests-zlang/results//generic/623.out.bad 2021-02-18 13:28:10.450733088 +0800 > @@ -1,2 +1,232 @@ > QA output created by 623 > +ls: cannot access '/mnt/scratch/srcfile3866': Structure needs cleaning > +ls: cannot access '/mnt/scratch/srcfile3867': Structure needs cleaning > +ls: cannot access '/mnt/scratch/srcfile3868': Structure needs cleaning > +ls: cannot access '/mnt/scratch/srcfile3869': Structure needs cleaning > +ls: cannot access '/mnt/scratch/srcfile3870': Structure needs cleaning > +ls: cannot access '/mnt/scratch/srcfile3871': Structure needs cleaning > ... > (Run 'diff -u /root/git/xfstests-zlang/tests/generic/623.out /root/git/xfstests-zlang/results//generic/623.out.bad' to see the entire diff) > Ran: generic/623 > Failures: generic/623 > Failed 1 of 1 tests > > [2] > # ./check generic/623 > FSTYP -- ext4 > PLATFORM -- Linux/x86_64 localhost 5.11.0-0.rc5.20210128git76c057c84d28.137.fc34.x86_64 #1 SMP Thu Jan 28 21:10:47 UTC 2021 > MKFS_OPTIONS -- /dev/mapper/testvg-scratchdev > MOUNT_OPTIONS -- -o acl,user_xattr -o context=system_u:object_r:root_t:s0 /dev/mapper/testvg-scratchdev /mnt/scratch > > generic/623 4s ... 86s > Ran: generic/623 > Passed all 1 tests > > [3] > # ./check generic/623 > FSTYP -- xfs (non-debug) > PLATFORM -- Linux/x86_64 localhost 5.11.0-0.rc5.20210128git76c057c84d28.137.fc34.x86_64 #1 SMP Thu Jan 28 21:10:47 UTC 2021 > MKFS_OPTIONS -- -f -bsize=4096 /dev/mapper/testvg-scratchdev > MOUNT_OPTIONS -- -o context=system_u:object_r:root_t:s0 /dev/mapper/testvg-scratchdev /mnt/scratch > > generic/623 86s ... 99s > Ran: generic/623 > Passed all 1 tests > > Thanks, > Zorro > > tests/generic/623 | 72 +++++++++++++++++++++++++++++++++++++++++++ > tests/generic/623.out | 2 ++ > tests/generic/group | 1 + > 3 files changed, 75 insertions(+) > create mode 100755 tests/generic/623 > create mode 100644 tests/generic/623.out > > diff --git a/tests/generic/623 b/tests/generic/623 > new file mode 100755 > index 00000000..56358ca6 > --- /dev/null > +++ b/tests/generic/623 > @@ -0,0 +1,72 @@ > +#! /bin/bash > +# SPDX-License-Identifier: GPL-2.0 > +# Copyright (c) 2021 HUAWEI. All Rights Reserved. > +# Copyright (c) 2021 Red Hat Inc. All Rights Reserved. > +# > +# FS QA Test 623 > +# > +# Test RENAME_WHITEOUT on filesystem without space to create one more inodes. > +# This is a regression test for kernel commit: > +# 6b4b8e6b4ad8 ("ext4: ext4: fix bug for rename with RENAME_WHITEOUT") > +# > +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/populate . ./common/renameat2 then ... > + > +# remove previous $seqres.full before test > +rm -f $seqres.full > + > +# real QA test starts here > +_supported_fs generic > +_require_scratch Need "_require_renameat2 whiteout" here. > + > +_scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1 > +_scratch_mount > + > +# Create several chunks of file, to help to trigger the bug easily > +CHUNKS=$((64 * 64)) Rename CHUNKS to NR_FILE? I tried 128 and could trigger the failure quickly as well, and test passwd within 5 seconds on v5.11 kernel. So I think 128 files should be fine? It's not required to be 100% reproducible, as long as the possiblity is high enough. > +for ((i=0; i + touch $SCRATCH_MNT/srcfile$i > +done > +# Try to fill the whole fs > +nr_free=$(stat -f -c '%f' $SCRATCH_MNT) > +blksz="$(_get_block_size $SCRATCH_MNT)" > +_fill_fs $((nr_free * blksz)) $SCRATCH_MNT/fill_space $blksz 0 >> $seqres.full 2>&1 > +# Use empty files to fill the rest > +for ((i=0; i<10000; i++));do > + touch $SCRATCH_MNT/fill_file$i 2>/dev/null > + # Until no more files can be created > + if [ $? -ne 0 ];then > + break > + fi > +done > +# ENOSPC is expected here > +for ((i=0; i + $here/src/renameat2 -w $SCRATCH_MNT/srcfile$i $SCRATCH_MNT/dstfile$i >> $seqres.full 2>&1 > +done > +_scratch_cycle_mount > +# Expect no errors at here > +for ((i=0; i + ls -l $SCRATCH_MNT/srcfile$i >/dev/null > +done > + > +echo "Silence is golden" > +# success, all done > +status=0 > +exit > diff --git a/tests/generic/623.out b/tests/generic/623.out > new file mode 100644 > index 00000000..6f774f19 > --- /dev/null > +++ b/tests/generic/623.out > @@ -0,0 +1,2 @@ > +QA output created by 623 > +Silence is golden > diff --git a/tests/generic/group b/tests/generic/group > index b10fdea4..72136075 100644 > --- a/tests/generic/group > +++ b/tests/generic/group > @@ -625,3 +625,4 @@ > 620 auto mount quick > 621 auto quick encrypt > 622 auto shutdown metadata atime > +623 auto rename enospc If we reduce the iterations, and test would pass quickly, we could add 'quick' group too. Thanks, Eryu > -- > 2.29.2