From patchwork Wed Apr 20 08:36:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zorro Lang X-Patchwork-Id: 12819923 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7266EC433EF for ; Wed, 20 Apr 2022 08:38:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351401AbiDTIkp (ORCPT ); Wed, 20 Apr 2022 04:40:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376766AbiDTIko (ORCPT ); Wed, 20 Apr 2022 04:40:44 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E771329C9B for ; Wed, 20 Apr 2022 01:37:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650443879; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iIdcAmi1AacA2/ltxfZkRyqpVORYvmpGlrzulm5XL/Y=; b=anALIk2/Plhb7deulzIUOTdeKQzDoKWj0NibaWOt1UiHQOTm+bFtjmdWWBgwGqwD9ZZfqO e8m2AZVUFGxqppjou4pwPLq7BVJKtYjnrXM9V+plcqSdDvTbQNakZjEVO0CeGU5bss8gXD ZIJTfJ102LYjkJBFCw4g8pIJ5yYA8zw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-187-dNep_4C8O2WnANv1p7HW_w-1; Wed, 20 Apr 2022 04:37:15 -0400 X-MC-Unique: dNep_4C8O2WnANv1p7HW_w-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 77C931857F16; Wed, 20 Apr 2022 08:37:15 +0000 (UTC) Received: from zlang-laptop.redhat.com (ovpn-12-143.pek2.redhat.com [10.72.12.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id DEC2840D1B98; Wed, 20 Apr 2022 08:37:12 +0000 (UTC) From: Zorro Lang To: fstests@vger.kernel.org Cc: linux-xfs@vger.kernel.org Subject: [PATCH 1/4] src/t_rename_overwrite: fsync to flush the rename operation result Date: Wed, 20 Apr 2022 16:36:50 +0800 Message-Id: <20220420083653.1031631-2-zlang@redhat.com> In-Reply-To: <20220420083653.1031631-1-zlang@redhat.com> References: <20220420083653.1031631-1-zlang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org The generic/035 fails on glusterfs due to glusterfs (or others like it), the file state can't be updated in time in client side, there's time delay. So call fsync to get the right file state after rename. Signed-off-by: Zorro Lang --- src/t_rename_overwrite.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/t_rename_overwrite.c b/src/t_rename_overwrite.c index c5cdd1db..8dcf8d46 100644 --- a/src/t_rename_overwrite.c +++ b/src/t_rename_overwrite.c @@ -2,6 +2,7 @@ #include #include #include +#include int main(int argc, char *argv[]) { @@ -25,6 +26,7 @@ int main(int argc, char *argv[]) res = rename(path1, path2); if (res == -1) err(1, "rename(\"%s\", \"%s\")", path1, path2); + fsync(fd); res = fstat(fd, &stbuf); if (res == -1) From patchwork Wed Apr 20 08:36:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zorro Lang X-Patchwork-Id: 12819919 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68390C433F5 for ; Wed, 20 Apr 2022 08:37:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376776AbiDTIkJ (ORCPT ); Wed, 20 Apr 2022 04:40:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376768AbiDTIkH (ORCPT ); Wed, 20 Apr 2022 04:40:07 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C792029C9B for ; Wed, 20 Apr 2022 01:37:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650443840; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=E0ZbzWLWcjCqkijOMrHebJJtfI7mS5vAY5etb8nyWnM=; b=IEIRs8aYFrkLpPXw3x9lk/3miTD6JLIi9RsdClMpEdhFIDlZmd0pAqKRpU3lD3WHYxAMyg SkigBDfHDj0sVyqjadVKZOGI8KjWxRyUcXSPAI+rDKz6N5jRLaiTK3WHoQZEEcosmyl9Yl AI+3M6BcINzjT79mqr83LY/bPvBq6kk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-544-431U5lmxNpiQxkOrAnaDbQ-1; Wed, 20 Apr 2022 04:37:19 -0400 X-MC-Unique: 431U5lmxNpiQxkOrAnaDbQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1355E8038E3; Wed, 20 Apr 2022 08:37:19 +0000 (UTC) Received: from zlang-laptop.redhat.com (ovpn-12-143.pek2.redhat.com [10.72.12.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7F24740D2969; Wed, 20 Apr 2022 08:37:17 +0000 (UTC) From: Zorro Lang To: fstests@vger.kernel.org Cc: linux-xfs@vger.kernel.org Subject: [PATCH 2/4] fstests: avoid dedupe testing blocked on large fs long time Date: Wed, 20 Apr 2022 16:36:51 +0800 Message-Id: <20220420083653.1031631-3-zlang@redhat.com> In-Reply-To: <20220420083653.1031631-1-zlang@redhat.com> References: <20220420083653.1031631-1-zlang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org When test on large fs (--large-fs), xfstests allocates a large file in SCRATCH_MNT/ at first. g/559~561 try to dedupe of extents within the same file, so they'll waste lots of time to deal with that large file. So bring in a common function named _duperemove(), which decide if allow dedupe of extents with in the same file. If specify "same" or "nosame" in the 1st argument, follow the specified option. Else use "same" by default except testing on large filesystem. Signed-off-by: Zorro Lang --- common/reflink | 39 +++++++++++++++++++++++++++++++++++++++ tests/generic/559 | 10 +++++----- tests/generic/560 | 3 +-- tests/generic/561 | 2 +- 4 files changed, 46 insertions(+), 8 deletions(-) diff --git a/common/reflink b/common/reflink index 76e9cb7d..48136650 100644 --- a/common/reflink +++ b/common/reflink @@ -488,3 +488,42 @@ _sweave_reflink_rainbow_delalloc() { _pwrite_byte 0x62 $((blksz * i)) $blksz $dfile.chk done } + +# Do De-dupe on a directory (or a file). $DUPEREMOVE_PROG is required if you +# call this function, and -d -r options are recommended. +# +# The 1st argument can be used to forcibly decide if dedupe extents with in +# the same file (better to use "same" if you run on a single file). If it's +# not set to "same" or "nosame", the function will use "same" by default +# except testing on large filesystem. +_duperemove() +{ + local dedupe_opt="" + + # Decide if allow dedupe of extents with in the same file. If specify + # "same" or "nosame", follow the specified option, else if test on + # large filesystem, "nosame" by default. + if [ "$1" = "same" ]; then + dedupe_opt="same" + shift + elif [ "$1" = "nosame" ]; then + dedupe_opt="nosame" + shift + elif [ "$LARGE_SCRATCH_DEV" = "yes" ]; then + # Don't allow dedupe of extents with in the same file if test + # on large filesystem. Due to xfstests pre-alloc a huge size + # file to take most fs free space at every test beginning if + # --large-fs option is used. + dedupe_opt="nosame" + fi + + # If above judgements set $dedupe_opt, then use this option, or "same" + # by default. + if [ -n "$dedupe_opt" ]; then + dedupe_opt="--dedupe-options=${dedupe_opt}" + else + dedupe_opt="--dedupe-options=same" + fi + + $DUPEREMOVE_PROG $dedupe_opt "$@" +} diff --git a/tests/generic/559 b/tests/generic/559 index 98ab4474..9817013f 100755 --- a/tests/generic/559 +++ b/tests/generic/559 @@ -21,18 +21,18 @@ fssize=$((2 * 1024 * 1024 * 1024)) _scratch_mkfs_sized $fssize > $seqres.full 2>&1 _scratch_mount >> $seqres.full 2>&1 +testfile="$SCRATCH_MNT/${seq}.file" # fill the fs with a big file has same contents -$XFS_IO_PROG -f -c "pwrite -S 0x55 0 $fssize" $SCRATCH_MNT/${seq}.file \ - >> $seqres.full 2>&1 -md5sum $SCRATCH_MNT/${seq}.file > ${tmp}.md5sum +$XFS_IO_PROG -f -c "pwrite -S 0x55 0 $fssize" $testfile >> $seqres.full 2>&1 +md5sum $testfile > ${tmp}.md5sum echo "= before cycle mount =" # Dedupe with 1M blocksize -$DUPEREMOVE_PROG -dr --dedupe-options=same -b 1048576 $SCRATCH_MNT/ >>$seqres.full 2>&1 +_duperemove -dr -b 1048576 $SCRATCH_MNT/ >>$seqres.full 2>&1 # Verify integrity md5sum -c --quiet ${tmp}.md5sum # Dedupe with 64k blocksize -$DUPEREMOVE_PROG -dr --dedupe-options=same -b 65536 $SCRATCH_MNT/ >>$seqres.full 2>&1 +_duperemove -dr -b 65536 $SCRATCH_MNT/ >>$seqres.full 2>&1 # Verify integrity again md5sum -c --quiet ${tmp}.md5sum diff --git a/tests/generic/560 b/tests/generic/560 index e3f28667..43b32293 100755 --- a/tests/generic/560 +++ b/tests/generic/560 @@ -35,8 +35,7 @@ function iterate_dedup_verify() $FSSTRESS_PROG $fsstress_opts -d $noisedir \ -n 200 -p $((5 * LOAD_FACTOR)) >/dev/null 2>&1 # Too many output, so only save error output - $DUPEREMOVE_PROG -dr --dedupe-options=same $dupdir \ - >/dev/null 2>$seqres.full + _duperemove same -dr $dupdir >/dev/null 2>$seqres.full md5sum -c --quiet $md5file$index src=$dest dest=$dupdir/$((index + 1)) diff --git a/tests/generic/561 b/tests/generic/561 index 44f07802..1d8109cf 100755 --- a/tests/generic/561 +++ b/tests/generic/561 @@ -67,7 +67,7 @@ for ((i = 0; i < $((2 * LOAD_FACTOR)); i++)); do # dupremove processes in an arbitrary order, which leaves the # memory in an inconsistent state long enough for the assert # to trip. - cmd="$DUPEREMOVE_PROG -dr --dedupe-options=same $testdir" + cmd="_duperemove -dr $testdir" bash -c "$cmd" >> $seqres.full 2>&1 done 2>&1 | sed -e '/Terminated/d' & dedup_pids="$! $dedup_pids" From patchwork Wed Apr 20 08:36:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zorro Lang X-Patchwork-Id: 12819920 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21553C433EF for ; Wed, 20 Apr 2022 08:37:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376775AbiDTIkN (ORCPT ); Wed, 20 Apr 2022 04:40:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376778AbiDTIkM (ORCPT ); Wed, 20 Apr 2022 04:40:12 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 37AF52A246 for ; Wed, 20 Apr 2022 01:37:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650443846; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Uh84sS/8t/iuqJUetVOeGZv2ET8jMRq4FlxqlOZfNYs=; b=cqnoL65kXsGM9xGWnDDGnAaGk4w/uGdY8CZDpZRAyOTHTeZxebM9ar2pPzZiAPYMyLh6nj na6DTenU9MFhJ+Ps9oB1QmiSh/3G+QPF/P66ItP5vPHlG9eSBl/+DMADIHnZF86/rTAR0u ggP9lW/CiAw3IFiCp11N7MZbBDAKTNU= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-439-smoeiskxNmyzuP35I9vJdw-1; Wed, 20 Apr 2022 04:37:23 -0400 X-MC-Unique: smoeiskxNmyzuP35I9vJdw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EA3A9299E744; Wed, 20 Apr 2022 08:37:22 +0000 (UTC) Received: from zlang-laptop.redhat.com (ovpn-12-143.pek2.redhat.com [10.72.12.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id 52C89404E4B1; Wed, 20 Apr 2022 08:37:21 +0000 (UTC) From: Zorro Lang To: fstests@vger.kernel.org Cc: linux-xfs@vger.kernel.org Subject: [PATCH 3/4] generic: test data corruption when blocksize < pagesize for mmaped data Date: Wed, 20 Apr 2022 16:36:52 +0800 Message-Id: <20220420083653.1031631-4-zlang@redhat.com> In-Reply-To: <20220420083653.1031631-1-zlang@redhat.com> References: <20220420083653.1031631-1-zlang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org page_mkwrite() is used by filesystems to allocate blocks under a page which is becoming writeably mmapped in some process' address space. This allows a filesystem to return a page fault if there is not enough space available, user exceeds quota or similar problem happens, rather than silently discarding data later when writepage is called. However VFS fails to call ->page_mkwrite() in all the cases where filesystems need it when blocksize < pagesize. At the moment page_mkwrite() is called, filesystem can allocate only one block for the page if i_size < page size. Otherwise it would create blocks beyond i_size which is generally undesirable. But later at writepage() time, we also need to store data at offset 4095 but we don't have block allocated for it. Signed-off-by: Zorro Lang --- tests/generic/999 | 75 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/999.out | 5 +++ 2 files changed, 80 insertions(+) create mode 100755 tests/generic/999 create mode 100644 tests/generic/999.out diff --git a/tests/generic/999 b/tests/generic/999 new file mode 100755 index 00000000..f1b65982 --- /dev/null +++ b/tests/generic/999 @@ -0,0 +1,75 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2022 Red Hat Inc. All Rights Reserved. +# +# FS QA Test 999 +# +# Regression test for linux commit 90a80202 ("data corruption when +# blocksize < pagesize for mmaped data") +# +. ./common/preamble +_begin_fstest auto quick + +# Import common functions. +. ./common/filter + +# real QA test starts here +_supported_fs generic +_require_scratch +_require_block_device $SCRATCH_DEV +_require_xfs_io_command mmap "-s " +_require_xfs_io_command mremap +_require_xfs_io_command truncate +_require_xfs_io_command mwrite + +sector_size=`_min_dio_alignment $SCRATCH_DEV` +page_size=$(get_page_size) +block_size=$((page_size/2)) +if [ $sector_size -gt $block_size ];then + _notrun "need sector size < page size" +fi + +unset MKFS_OPTIONS +# For save time, 512MiB is enough to reproduce bug +_scratch_mkfs_sized 536870912 $block_size >$seqres.full 2>&1 || _fail "mkfs failed" +_scratch_mount + +# take one block size space +$XFS_IO_PROG -f -t -c "pwrite 0 $block_size" $SCRATCH_MNT/testfile >>$seqres.full 2>&1 + +# Fill all free space, dd can keep writing until no space. Note: if the fs +# isn't be full, this test will fail. +for ((i=0; i<2; i++));do + dd if=/dev/zero of=$SCRATCH_MNT/full bs=$block_size >>$seqres.full 2>&1 + _scratch_cycle_mount +done + +# truncate 0 +# pwrite -S 0x61 0 $block_size +# mmap -rw -s $((page_size * 2)) 0 $block_size +# mwrite -S 0x61 0 1 --> page_mkwrite() for index 0 is called +# truncate $((page_size * 2)) +# mremap $((page_size * 2)) +# mwrite -S 0x61 $((page_size - 1)) 1 --> [bug] no page_mkwrite() called +# +# If there's a bug, the last step will be killed by SIGBUS, and it won't +# write a "0x61" on the disk. +# +# Note: mremap maybe failed when memory load is heavy. +$XFS_IO_PROG -f \ + -c "truncate 0" \ + -c "pwrite -S 0x61 0 $block_size" \ + -c "mmap -rw -s $((page_size * 2)) 0 $block_size" \ + -c "mwrite -S 0x61 0 1" \ + -c "truncate $((page_size * 2))" \ + -c "mremap $((page_size * 2))" \ + -c "mwrite -S 0x61 $((page_size - 1)) 1" \ + $SCRATCH_MNT/testfile | _filter_xfs_io + +# we will see 0x61 written by "mwrite -S 0x61 0 1", but we shouldn't see one +# more 0x61 by the last mwrite (except this fs isn't be full, or a bug) +od -An -c $SCRATCH_MNT/testfile + +# success, all done +status=0 +exit diff --git a/tests/generic/999.out b/tests/generic/999.out new file mode 100644 index 00000000..f1c59e83 --- /dev/null +++ b/tests/generic/999.out @@ -0,0 +1,5 @@ +QA output created by 999 + a a a a a a a a a a a a a a a a +* + \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 +* From patchwork Wed Apr 20 08:36:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zorro Lang X-Patchwork-Id: 12819921 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5582FC433EF for ; Wed, 20 Apr 2022 08:37:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376782AbiDTIkP (ORCPT ); Wed, 20 Apr 2022 04:40:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376778AbiDTIkO (ORCPT ); Wed, 20 Apr 2022 04:40:14 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 53D9329C9B for ; Wed, 20 Apr 2022 01:37:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650443848; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=v2NoSVN63TT707mkcF5bFPXcuOQ+x5KpSiqBnEzmmpo=; b=eyXIQ1Evdqbu0e3VStYCTg0kAADIQuH+80skBt5Mq8j8XJ7BorjNN1sR+OEYEB8Sz2JBcp Bb5Co8p0AucLnSNxPT3LDjnTP8oHwccSdV1I+Ea2AvREU5du1yqNNpWzrQ6hXN3K6RXBPK 3AA/jojmv8o/LxfkKFkG0Epua0d6AnA= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-216-gp_6cBH7PzyjS_neEaiiUg-1; Wed, 20 Apr 2022 04:37:27 -0400 X-MC-Unique: gp_6cBH7PzyjS_neEaiiUg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B702D1C04B5B; Wed, 20 Apr 2022 08:37:26 +0000 (UTC) Received: from zlang-laptop.redhat.com (ovpn-12-143.pek2.redhat.com [10.72.12.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1AAA640D1B98; Wed, 20 Apr 2022 08:37:24 +0000 (UTC) From: Zorro Lang To: fstests@vger.kernel.org Cc: linux-xfs@vger.kernel.org Subject: [PATCH 4/4] fstests: test xfs swapext log replay Date: Wed, 20 Apr 2022 16:36:53 +0800 Message-Id: <20220420083653.1031631-5-zlang@redhat.com> In-Reply-To: <20220420083653.1031631-1-zlang@redhat.com> References: <20220420083653.1031631-1-zlang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org If an inode had been in btree format and had a data fork owner change logged (XFS_ILOG_DOWNER), after changing the format to non-btree, will hit an ASSERT in xfs_recover_inode_owner_change() which enforces that if XFS_ILOG_[AD]OWNER is set. Signed-off-by: Zorro Lang --- Hi, 3+ years past, this test is still failed on latest upstream linux kernel, as we talked below: https://patchwork.kernel.org/project/fstests/patch/20181223141721.5318-1-zlang@redhat.com/ I think it's time to bring it back to talk again. If it's a case issue, I'll fix. If it's a bug, means this case is good to merge. Thanks, Zorro tests/xfs/999 | 58 +++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/999.out | 2 ++ 2 files changed, 60 insertions(+) create mode 100755 tests/xfs/999 create mode 100644 tests/xfs/999.out diff --git a/tests/xfs/999 b/tests/xfs/999 new file mode 100755 index 00000000..b1d58671 --- /dev/null +++ b/tests/xfs/999 @@ -0,0 +1,58 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2022 Red Hat Inc. All Rights Reserved. +# +# FS QA Test 999 +# +# If an inode had been in btree format and had a data fork owner change +# logged, after changing the format to non-btree, will hit an ASSERT or +# fs corruption. +# This case trys to cover: dc1baa715bbf ("xfs: do not log/recover swapext +# extent owner changes for deleted inodes") +# +. ./common/preamble +_begin_fstest auto quick fsr + +# Import common functions. +. ./common/filter + +# real QA test starts here +_supported_fs generic +_require_scratch +_scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs >/dev/null +. $tmp.mkfs + +_scratch_mount +localfile=$SCRATCH_MNT/fragfile + +# Try to create a file with 1024 * (3 blocks + 1 hole): +# +----------+--------+-------+----------+--------+ +# | 3 blocks | 1 hole | ... | 3 blocks | 1 hole | +# +----------+--------+-------+----------+--------+ +# +# The number of extents we can get maybe more or less than 1024, this method +# just to get a btree inode format. +filesize=$((dbsize * 1024 * 4)) +for i in `seq $filesize -$dbsize 0`; do + if [ $((i % (3 * dbsize))) -eq 0 ]; then + continue + fi + $XFS_IO_PROG -f -d -c "pwrite $i $dbsize" $localfile >> $seqres.full +done + +# Make a data fork owner change log +$XFS_FSR_PROG -v -d $localfile >> $seqres.full 2>&1 + +# Truncate the file to 0, and change the inode format to extent, then shutdown +# the fs to keep the XFS_ILOG_DOWNER flag +$XFS_IO_PROG -t -x -c "pwrite 0 $dbsize" \ + -c "fsync" \ + -c "shutdown" $localfile >> $seqres.full + +# Cycle mount, to replay the log +_scratch_cycle_mount + +echo "Silence is golden" +# success, all done +status=0 +exit diff --git a/tests/xfs/999.out b/tests/xfs/999.out new file mode 100644 index 00000000..3b276ca8 --- /dev/null +++ b/tests/xfs/999.out @@ -0,0 +1,2 @@ +QA output created by 999 +Silence is golden