From patchwork Thu Nov 17 02:06:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 9433387 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 3E63860469 for ; Thu, 17 Nov 2016 02:07:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25D2B291E5 for ; Thu, 17 Nov 2016 02:07:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 172A0291E9; Thu, 17 Nov 2016 02:07:49 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable 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 41882291E5 for ; Thu, 17 Nov 2016 02:07:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S941134AbcKQCHY (ORCPT ); Wed, 16 Nov 2016 21:07:24 -0500 Received: from cn.fujitsu.com ([222.73.24.84]:18724 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1754320AbcKQCHV (ORCPT ); Wed, 16 Nov 2016 21:07:21 -0500 X-IronPort-AV: E=Sophos;i="5.20,367,1444665600"; d="scan'208";a="965282" Received: from unknown (HELO cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 17 Nov 2016 10:07:04 +0800 Received: from localhost.localdomain (unknown [10.167.226.34]) by cn.fujitsu.com (Postfix) with ESMTP id 1DD3740142D3; Thu, 17 Nov 2016 10:07:03 +0800 (CST) From: Qu Wenruo To: linux-btrfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH] fstests: Introduce check for explicit SHARED extent flag reporting Date: Thu, 17 Nov 2016 10:06:48 +0800 Message-Id: <20161117020648.19685-1-quwenruo@cn.fujitsu.com> X-Mailer: git-send-email 2.10.2 MIME-Version: 1.0 X-yoursite-MailScanner-ID: 1DD3740142D3.AC0C0 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: quwenruo@cn.fujitsu.com 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 For fs support reflink, some of them (OK, btrfs again) doesn't split SHARED flag for extent fiemap reporting. For example: 0 4K 8K / File1: Extent 0 \ / \ |<- On disk Extent-->| | / | File2 / Extent: 0 Fs supports explicit SHARED extent reporting should report fiemap like: File1: 2 extents Extent 0-4K: SHARED Extent 4-8K: File2: 1 extents Extent 0-4K: SHARED Fs doesn't support explicit reporting will report fiemap like: File1: 1 extent Extent 0-8K: SHARED File2: 1 extent Extent 0-4K: SHARED Test case like generic/372 require explicit reporting will cause false alert on btrfs. Add such runtime check for that requirememt. Signed-off-by: Qu Wenruo --- common/reflink | 44 ++++++++++++++++++++++++++++++++++++++++++++ tests/generic/372 | 1 + 2 files changed, 45 insertions(+) diff --git a/common/reflink b/common/reflink index 8b34046..9ada2e8 100644 --- a/common/reflink +++ b/common/reflink @@ -78,6 +78,50 @@ _require_scratch_reflink() _scratch_unmount } +# this test requires scratch fs to report explicit SHARED flag +# e.g. +# 0 4K 8K +# / File1: Extent 0 \ +# / \ +# |<- On disk Extent-->| +# | / +# | File2 / +# Extent: 0 +# Fs supports explicit SHARED extent reporting should report fiemap like: +# File1: 2 extents +# Extent 0-4K: SHARED +# Extent 4-8K: +# File2: 1 extents +# Extent 0-4K: SHARED +# +# Fs doesn't support explicit reporting will report fiemap like: +# File1: 1 extent +# Extent 0-8K: SHARED +# File2: 1 extent +# Extent 0-4K: SHARED +_require_scratch_explicit_shared_extents() +{ + _require_scratch + _require_fiemap + _require_scratch_reflink + _require_xfs_io_command "reflink" + local nr_extents + + _scratch_mkfs > /dev/null + _scratch_mount + + _pwrite_byte 0x61 0 128k $SCRATCH_MNT/file1 + _reflink_range $SCRATCH_MNT/file1 0 $SCRATCH_MNT/file2 0 64k + + _scratch_cycle_mount + + nr_extents=$(_count_extents $SCRATCH_MNT/file1) + if [ $nr_extents -eq 1 ]; then + _notrun "Explicit SHARED flag reporting not support by filesystem type: $FSTYP" + fi + _scratch_unmount +} + # this test requires the test fs support dedupe... _require_test_dedupe() { diff --git a/tests/generic/372 b/tests/generic/372 index 31dff20..51a3eca 100755 --- a/tests/generic/372 +++ b/tests/generic/372 @@ -47,6 +47,7 @@ _supported_os Linux _supported_fs generic _require_scratch_reflink _require_fiemap +_require_scratch_explicit_shared_extents echo "Format and mount" _scratch_mkfs > $seqres.full 2>&1