From patchwork Wed Mar 14 20:11:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 10284375 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D0BAB60386 for ; Thu, 15 Mar 2018 12:25:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFE8E2897F for ; Thu, 15 Mar 2018 12:25:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B43F0289F3; Thu, 15 Mar 2018 12:25:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.9 required=2.0 tests=BAYES_00, DATE_IN_PAST_12_24, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D3C812897F for ; Thu, 15 Mar 2018 12:25:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751456AbeCOMZs (ORCPT ); Thu, 15 Mar 2018 08:25:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:57586 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750731AbeCOMZp (ORCPT ); Thu, 15 Mar 2018 08:25:45 -0400 Received: from debian3.lan (bl12-226-64.dsl.telepac.pt [85.245.226.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 464C8204EF for ; Thu, 15 Mar 2018 12:25:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 464C8204EF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=fdmanana@kernel.org From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH 2/2 v3] Btrfs-progs: add fsck test for filesystem with shared prealloc extents Date: Wed, 14 Mar 2018 20:11:18 +0000 Message-Id: <20180314201118.12451-1-fdmanana@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180313184713.30223-1-fdmanana@kernel.org> References: <20180313184713.30223-1-fdmanana@kernel.org> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Filipe Manana Verify that a filesystem check operation (fsck) does not report the following scenario as an error: An extent is shared between two inodes, as a result of clone/reflink operation, and for one of the inodes, lets call it inode A, the extent is referenced through a file extent item as a prealloc extent, while for the other inode, call it inode B, the extent is referenced through a regular file extent item, that is, it was written to. The goal of this test is to make sure a filesystem check operation will not report "odd csum items" errors for the prealloc extent at inode A, because this scenario is valid since the extent was written through inode B and therefore it is expected to have checksum items in the filesystem's checksum btree for that shared extent. Such scenario can be created with the following steps for example: mkfs.btrfs -f /dev/sdb mount /dev/sdb /mnt touch /mnt/foo xfs_io -c "falloc 0 256K" /mnt/foo sync xfs_io -c "pwrite -S 0xab 0 256K" /mnt/foo touch /mnt/bar xfs_io -c "reflink /mnt/foo 0 0 256K" /mnt/bar xfs_io -c "fsync" /mnt/bar mount /dev/sdb /mnt umount /mnt This scenario is fixed by the following patch for the filesystem checker: "Btrfs-progs: check, fix false error reports for shared prealloc extents" Signed-off-by: Filipe Manana Reviewed-by: Qu Wenruo --- V3: No changes. V2: No changes, only added Qu's reviewed-by tag. .../reflinked-prealloc-extents.img.xz | Bin 0 -> 3244 bytes .../030-reflinked-prealloc-extents/test.sh | 42 +++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 tests/fsck-tests/030-reflinked-prealloc-extents/reflinked-prealloc-extents.img.xz create mode 100755 tests/fsck-tests/030-reflinked-prealloc-extents/test.sh diff --git a/tests/fsck-tests/030-reflinked-prealloc-extents/reflinked-prealloc-extents.img.xz b/tests/fsck-tests/030-reflinked-prealloc-extents/reflinked-prealloc-extents.img.xz new file mode 100644 index 0000000000000000000000000000000000000000..8adf0071328806fa6981f6ef225084e517d1bc3e GIT binary patch literal 3244 zcmV;d3{&&{H+ooF000E$*0e?f03iV!0000G&sfanlm85CT>wRyj;C3^v%$$4d1wo3 zjjaF1$3n~+-*XiD+@YGxDtdHe$qq4$Wo>7O_CGnuIn8OLnT=x4IGVZ-w??mVmRMZ7 z5Ay+V;mHSAoDkyM-tpo^bS;x+v}A`sNQY^&CEysS!9&~{eDz@XZKXO?8OF)IjGm%( zDUT1JIsHjj>>}y5qdSJT79-V@5Qr*LP$DwA@XNl^>?ShU!y!KD38l^=LE*nzF2}qs zeB4zmhwleI8r9LN(p#cQeLEqdB4_Wgl7Qx-M>xaL`0TU`9k;qs6+KP*H>U4>=}6F*5_MhCaIzBlfo8uAWSd+hP%WEflaqMvG9Yi+k#=?=X1;)RqEp2fES1y0!CcOxHBNudB4H&Ibwd~ zg^Q=pEd>6f!;l~S^outD;V9&&z4zdU@RLa{&{9spkk|mHXS%NxkxrGeraxy^{Cx+( z$hvBW&sc#`Zhts1td;TLkX1RsNg`CWT*I)*I@mk(hGjz?_yyPd-M$ua7B`xni7MSs zWyl`7wxZ%$wBM$&J&KIc2)P<1(dhx?%fv+}{l<|u?L$$QGeT(rUdBI{pRI`}U)a7Fj|kXDbn-0nezRe zyo)Z$_6XM$t$LFEKukadE#&l-4l*)^!)pQ&8mYw_kMjNgxd*nQI${ow>pAWyg-&V7 zeY~@@vvyi{r6BFgsls*62dIJ6pHyrL+V9bwi^Y3AmVbJ-rj~|0%3qm%C-loCfyP>s z$_FFfC0=|&kxq!1xk(2zP?u6Z!@qsjy-cb?f8VO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m}qFweC&J>2lA zz)zLztUzz8+xjs4vKTGtziG?4_!{L8QLiD59#aYO9*$)ZFa;jOO2JwKYkd-kOVQI; zM{e<1!HQg4+0Hg@>Xqpf?S057lpn_3=Q*31|3jqcYeRZ6oCA*rIHb4n9bHL=aZS?v zvrOjS^s&Pojj4!3PjKdLh8=5AL)}GE_8FUOoL)ydGOEw#8T^B}n)nXror4+_n)>Z2*|b&r zQ4u*Sk<0g^s2t7tye&Xdg8 zG2HN`QJka}O}{dIqcp84O#rE32dAf5zHVN^@n8B&66QNP!JVEEuM%12AX~oRPIcGs zV=ps`>|WP1cQu?kUL<77wB&hGzYt`M0=lV#So{@_Iygr{o5Fn9|9HMk+a=FmqKk8_QB99ArRuR7>#!y%L9G!{j6!ncOTk_*3awa zkN;`~%$XI@o0Ahz7)ZNo_ z2c`k7Oh;fsno7uR0!pBEg5BgjohMu8?^TN11DabusTj ze)_pSN^Ba6Wp^2aiQUvs2r>?R1ocR&>Q=DkRQbI>pgveJcmHt~_=uIcP3k7)2^GDc zN537UWwtmza_!k~6snP|;niI(9;M^(9c^6$;QOu}{65*q*%Fd|N&ck?tRCcNBmAhX z2F3n;IubrupC)EJ-_;I9Z+}0XRSRX-ats!dr@lFlB;jzLrz2nNCO!9`9{vD7cva-# e`Wb})0f-rZs2TvH_gU7l#Ao{g000001X)^Ms5!_0 literal 0 HcmV?d00001 diff --git a/tests/fsck-tests/030-reflinked-prealloc-extents/test.sh b/tests/fsck-tests/030-reflinked-prealloc-extents/test.sh new file mode 100755 index 00000000..63f692bc --- /dev/null +++ b/tests/fsck-tests/030-reflinked-prealloc-extents/test.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# +# Verify that a filesystem check operation (fsck) does not report the following +# scenario as an error: +# +# An extent is shared between two inodes, as a result of clone/reflink operation, +# and for one of the inodes, lets call it inode A, the extent is referenced +# through a file extent item as a prealloc extent, while for the other inode, +# call it inode B, the extent is referenced through a regular file extent item, +# that is, it was written to. The goal of this test is to make sure a filesystem +# check operation will not report "odd csum items" errors for the prealloc +# extent at inode A, because this scenario is valid since the extent was written +# through inode B and therefore it is expected to have checksum items in the +# filesystem's checksum btree for that shared extent. +# +# Such scenario can be created with the following steps for example: +# +# mkfs.btrfs -f /dev/sdb +# mount /dev/sdb /mnt +# +# touch /mnt/foo +# xfs_io -c "falloc 0 256K" /mnt/foo +# sync +# +# xfs_io -c "pwrite -S 0xab 0 256K" /mnt/foo +# touch /mnt/bar +# xfs_io -c "reflink /mnt/foo 0 0 256K" /mnt/bar +# xfs_io -c "fsync" /mnt/bar +# +# +# mount /dev/sdb /mnt +# umount /mnt + +source "$TEST_TOP/common" + +check_prereq btrfs + +check_image() { + run_check "$TOP/btrfs" check "$1" +} + +check_all_images