From patchwork Thu Apr 6 13:19:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Monakhov X-Patchwork-Id: 9667271 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 6772C6021C for ; Thu, 6 Apr 2017 13:19:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7CB1A26E4E for ; Thu, 6 Apr 2017 13:19:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 71BC527165; Thu, 6 Apr 2017 13:19:29 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 D3E5626E4E for ; Thu, 6 Apr 2017 13:19:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934431AbdDFNT0 (ORCPT ); Thu, 6 Apr 2017 09:19:26 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:33751 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756093AbdDFNTU (ORCPT ); Thu, 6 Apr 2017 09:19:20 -0400 Received: by mail-lf0-f66.google.com with SMTP id r36so3644793lfi.0; Thu, 06 Apr 2017 06:19:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=AgWvvxvu6JJryfIeXGb8GsOlXGYBqmL27Y1wTQTyw1M=; b=WDyO++kQ8fUakJ4oaN0HYtuiymGpplFSP5vI9YTCG7tSdDN3rCJj43OeZvQpa68Xz4 wU9sHhXSRp0JgEU50axNkRWI1epdezdp9esXDbhWI2aq0V5nHAOpHzezXNs8bGeJ/p2E lDy+6/D5RxTJjLXLBMqmw4y7ydzjDA59tOnlRZW57IhsKXvbRuLW51Y42tBfrSIbCc7d kmjxTQDR482UJ0otxAFC+xsFDRZIeEOQI9EoNOb0nifN7xZdScqHJolnov/OR4c64T/S /k476ZIxm7u7D6qPyFJD96Ht1pW/9Uap7CGpdtq25YtH3X9R5aFedOa6vjA5rJ2i4sgw qLmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=AgWvvxvu6JJryfIeXGb8GsOlXGYBqmL27Y1wTQTyw1M=; b=U76RqYr8QtGio1hdIfdwwunZT1DBTll0/BUf34Waz0+jZavl7/B38Zh7BavACp79sr IoJYzHspNKWbTBs32RD3Wvit1oKmC4JklO2+41XYoxQRCv0T6Z2JKnYBvM9AUw/CB5QJ nQLkLuYOD6GVoc9C6U8TGu01/x0fBboTJimkm0EAWXGo0X5fDq1nTc93asyrdWeCPv7Y 3oK7q+dNjqRwEeY5atpD4qD4jnFHwyCLBp5gs3cGF/H7JRu/LspAW4Z9oHkk+GDh5Xg+ 0zY/57JFjbgYtosEf1OuPsrxL04Ez1YDdWtXi/38uQj6EFzAqGvs5t/OGXt65UUPa31i 8oIA== X-Gm-Message-State: AFeK/H1sWQG9Bxkrpu0CJGhYaal5r9ltcL9YYeWI4y+ROpA1QncH52OiXnVqmTJzns4edw== X-Received: by 10.25.141.73 with SMTP id p70mr12089188lfd.147.1491484758158; Thu, 06 Apr 2017 06:19:18 -0700 (PDT) Received: from smtp.gmail.com (msk-vpn.virtuozzo.com. [195.214.232.6]) by smtp.gmail.com with ESMTPSA id g65sm339465lfk.10.2017.04.06.06.19.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Apr 2017 06:19:17 -0700 (PDT) From: Dmitry Monakhov To: fstests@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, Dmitry Monakhov Subject: [PATCH 4/6] new: blockdev/003 basic blockdev T10-DIF-TYPE1 integrity checks Date: Thu, 6 Apr 2017 17:19:08 +0400 Message-Id: <1491484750-9164-5-git-send-email-dmonakhov@openvz.org> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1491484750-9164-1-git-send-email-dmonakhov@openvz.org> References: <1491484750-9164-1-git-send-email-dmonakhov@openvz.org> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Test create virtual block device via lio-targed infastructure and perform basic IO operations with data corruption detection. Temprorally mark is as dangerous, because currently it trigger BUG_ON inside blkdev_issue_flush BTW: I use 'dd' to test read from corrupted image instead of xfs_io because even if pread failed, xfs_io still exit with success, BUG? Signed-off-by: Dmitry Monakhov --- tests/blockdev/003 | 164 +++++++++++++++++++++++++++++++++++++++++++++++++ tests/blockdev/003.out | 39 ++++++++++++ tests/blockdev/group | 1 + 3 files changed, 204 insertions(+) create mode 100755 tests/blockdev/003 create mode 100644 tests/blockdev/003.out diff --git a/tests/blockdev/003 b/tests/blockdev/003 new file mode 100755 index 0000000..8f31f0d --- /dev/null +++ b/tests/blockdev/003 @@ -0,0 +1,164 @@ +#! /bin/bash +# FS QA Test 003 +# +# Check basic T10-DIF integrity features for a block device +# +# DIF/DIX TYPE: T10-DIF-TYPE1-CRC +# Kernel docs: Documentation/blockdev/data-integrity.txt +#----------------------------------------------------------------------- +# Copyright (c) 2017 Dmitry Monakhov +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# + +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.* + _liotgt_cleanup + rm -rf $TEST_DIR/$$ +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/liotarget + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +# Modify as appropriate. +_supported_fs generic +_supported_os Linux +_require_test +_require_liotarget + +mkdir -p $TEST_DIR/$$ || _fail "Can not make test dir" + +# One full test suite +_run_one() +{ + local img_name=$1 + + echo "Run: $img_name" + echo "T0: Test basic IO" + $XFS_IO_PROG -c "pwrite -S 0xa0 -b 4M 0 16M" -d $dev >>$seqres.full 2>&1 || \ + _fail "pwrite failed" + + $XFS_IO_PROG -c "pwrite -S 0xa3 -b 1k -V8 20M 32k" -d $dev >>$seqres.full 2>&1 || \ + _fail "pwrite failed" + + $XFS_IO_PROG -c "pwrite -S 0xa2 -b 1k -V8 2M 32k" -f $dev >>$seqres.full 2>&1 || \ + _fail "pwrite failed" + + $XFS_IO_PROG -c "pwrite -S 0xa1 -b 4k 1536000 8k" -f $dev >>$seqres.full 2>&1 || \ + _fail "pwrite failed" + + $XFS_IO_PROG -c "fsync" -d $dev >>$seqres.full 2>&1 || _fail "fsync failed" + + echo "Check that buffered IO" + dd if=$dev bs=4k 2>>$seqres.full | md5sum + echo "Check that direct IO" + # Small requests will not being splitted + dd if=$dev bs=64k iflag=direct 2>>$seqres.full | md5sum + # Big requests may be splitted on flight, but result MUST be the same. + dd if=$dev bs=4M iflag=direct 2>>$seqres.full | md5sum + + echo "Check csum corruption detection" + # LIO-fileio store t10 DIF data in separate file ${IMG}.protection + # struct t10_pi_tuple { + # __be16 guard_tag; /* Checksum */ + # __be16 app_tag; /* Opaque storage */ + # __be32 ref_tag; /* Target LBA or indirect LBA */ + #} + # Play with 3000'th sector -> t10_pi_tuple offset == 3000 * 8 == 24000 + # + echo "T1: Corrupt guard_tag, next read should fail" + $XFS_IO_PROG -c "pwrite -S 0xde -b2 24000 2 -w" \ + -f $TEST_DIR/$$/$img_name.protection >>$seqres.full 2>&1 + dd if=$dev of=/dev/null bs=1M count=2 iflag=direct >>$seqres.full 2>&1 && + _fail "read should fail on 3000'th sector" + + echo "T2: Check that unaffected blocks are still readable" + dd if=$dev of=/dev/null bs=1M count=1 iflag=direct >>$seqres.full 2>&1 || _fail "read failed" + + echo "T3: Rewrite corrupted sector and check that read works" + $XFS_IO_PROG -c "pwrite -S 0xa1 -b 4k 1536000 4k" -d $dev >>$seqres.full 2>&1 || \ + _fail "pwrite failed" + dd if=$dev bs=2M count=1 iflag=direct >>$seqres.full 2>&1 || _fail "read failed" + + echo "T4: Corrupt app_tag, should not affect read" + $XFS_IO_PROG -c "pwrite -S 0xde -b2 24002 2 -w" \ + -f $TEST_DIR/$$/$img_name.protection >>$seqres.full 2>&1 + dd if=$dev bs=2M count=1 iflag=direct >>$seqres.full 2>&1 || _fail "read failed" + + echo "T5: Corrupt ref_tag, next read should fail" + $XFS_IO_PROG -c "pwrite -S 0xde -b4 24004 4 -w" \ + $TEST_DIR/$$/$img_name.protection >>$seqres.full 2>&1 + dd if=$dev of=/dev/null bs=1M count=2 iflag=direct >>$seqres.full 2>&1 && + _fail "read should fail on 3000'th sector" + + echo "T6: Check that unaffected blocks are still readable" + dd if=$dev of=/dev/null bs=1M count=1 iflag=direct >>$seqres.full 2>&1 || _fail "read failed" + + echo "T7: Rewrite corrupted sector and check that read works" + $XFS_IO_PROG -c "pwrite -S 0xa1 -b 4k 1536000 4k" -d $dev >>$seqres.full 2>&1 || \ + _fail "pwrite failed" + + echo "Check that buffered and direct read works" + dd if=$dev bs=4k 2>>$seqres.full | md5sum + # Small requests will not being splitted + dd if=$dev bs=64k iflag=direct 2>>$seqres.full | md5sum + # Big requests may be splitted on flight, but result MUST be the same. + dd if=$dev bs=4M iflag=direct 2>>$seqres.full | md5sum +} + +# Create virtual scsi target with internal csum verification +name=dif-type1-w +cfg_path=$(_liotgt_create_fileio $name $TEST_DIR/$$/$name 32M) + +_liotgt_set_attribute $cfg_path pi_prot_type 1 +_liotgt_set_attribute $cfg_path pi_prot_format 1 +_liotgt_set_attribute $cfg_path pi_prot_verify 1 +dev=$(_liotgt_attach_target /backstores/fileio/$name) +_run_one $name + +# Create virtual scsi target w/o internal csum verification, +# check that core blk_integrity_profile->verify_fn works +# +name=dif-type1-wo +cfg_path=$(_liotgt_create_fileio $name $TEST_DIR/$$/$name 32M) + +_liotgt_set_attribute $cfg_path pi_prot_type 1 +_liotgt_set_attribute $cfg_path pi_prot_format 1 +_liotgt_set_attribute $cfg_path pi_prot_verify 0 +dev=$(_liotgt_attach_target /backstores/fileio/$name) +_run_one $name + +status=0 +exit diff --git a/tests/blockdev/003.out b/tests/blockdev/003.out new file mode 100644 index 0000000..be2efbb --- /dev/null +++ b/tests/blockdev/003.out @@ -0,0 +1,39 @@ +QA output created by 003 +Run: dif-type1-w +T0: Test basic IO +Check that buffered IO +f18a6c9b9d69ff8ed61daa62dfab4341 - +Check that direct IO +f18a6c9b9d69ff8ed61daa62dfab4341 - +f18a6c9b9d69ff8ed61daa62dfab4341 - +Check csum corruption detection +T1: Corrupt guard_tag, next read should fail +T2: Check that unaffected blocks are still readable +T3: Rewrite corrupted sector and check that read works +T4: Corrupt app_tag, should not affect read +T5: Corrupt ref_tag, next read should fail +T6: Check that unaffected blocks are still readable +T7: Rewrite corrupted sector and check that read works +Check that buffered and direct read works +f18a6c9b9d69ff8ed61daa62dfab4341 - +f18a6c9b9d69ff8ed61daa62dfab4341 - +f18a6c9b9d69ff8ed61daa62dfab4341 - +Run: dif-type1-wo +T0: Test basic IO +Check that buffered IO +f18a6c9b9d69ff8ed61daa62dfab4341 - +Check that direct IO +f18a6c9b9d69ff8ed61daa62dfab4341 - +f18a6c9b9d69ff8ed61daa62dfab4341 - +Check csum corruption detection +T1: Corrupt guard_tag, next read should fail +T2: Check that unaffected blocks are still readable +T3: Rewrite corrupted sector and check that read works +T4: Corrupt app_tag, should not affect read +T5: Corrupt ref_tag, next read should fail +T6: Check that unaffected blocks are still readable +T7: Rewrite corrupted sector and check that read works +Check that buffered and direct read works +f18a6c9b9d69ff8ed61daa62dfab4341 - +f18a6c9b9d69ff8ed61daa62dfab4341 - +f18a6c9b9d69ff8ed61daa62dfab4341 - diff --git a/tests/blockdev/group b/tests/blockdev/group index 0b511f3..e5ce864 100644 --- a/tests/blockdev/group +++ b/tests/blockdev/group @@ -5,3 +5,4 @@ # 001 rw blockdev 002 rw blockdev liotarget +003 rw blockdev liotarget integrity dangerous