From patchwork Mon Jul 15 12:55:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 11043979 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1377013BD for ; Mon, 15 Jul 2019 12:55:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 029272766D for ; Mon, 15 Jul 2019 12:55:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0111E28438; Mon, 15 Jul 2019 12:55:26 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 B67302766D for ; Mon, 15 Jul 2019 12:55:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728933AbfGOMz0 (ORCPT ); Mon, 15 Jul 2019 08:55:26 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:39447 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730012AbfGOMzZ (ORCPT ); Mon, 15 Jul 2019 08:55:25 -0400 Received: by mail-wr1-f67.google.com with SMTP id x4so16962835wrt.6; Mon, 15 Jul 2019 05:55:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=x8+ET7vxAVjRgnK7tq9lJZBKdxKLB5BJlAWtcRWokrg=; b=mrEevGftlTk1FJHkCUAfyzb8cnRmJC2zxDwRK636L4GY0bw2rcG19R0SwFKNylGMYs /vVfuXdXcwYBWJKTku2f7RqpqQM4tsJS4ML1SPTV1RX4xwS7S9pq+N+XvZgSuxlVE7r5 uBcF5VQyPxrdmsCPjTliQfBLBamdLcl7IMKV6xubKRqMqtEIBs645e+iz9Hu5mTe8/ML i6zBmsO6uPtPG0o4bF79k/+YQWWZU7tdfqX3CZqKQeNiOeVsFHrDJROj2Yu7HdR+5MmF 3Lp4eThv85nuKIL2Zzi/teBRTh9f3ZD08cLl30Xkohrby8zH8DxYzksO3frrxWq7yjoD uLYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=x8+ET7vxAVjRgnK7tq9lJZBKdxKLB5BJlAWtcRWokrg=; b=ET8AJyxeoJvCejskzQOkIibMz1YWc8GrVc1iufFVJ+m3fFqGoT85VPTdIsVy6i/3PM FtmuNCrXHvWKGU2YYgN/XkDs7h8wxwFiTd0jZp4cdS2VPzNd08eSmYUEvM6tKA1mkCMH rCyVJKhvVG12sh5LNvXY01TeVnoOHQcSDgng94yBxI8lqvdJDVWmSrpeJPKvTeQXp+RN Ui0J82vULhCSjsODfXZKvTXILCfrPDDYXbjaceyivFX4+6WceB3MlMsH8u3sG/f0CXBo X3Fnj8RSvhqPcMs3IC49xRhkHX5rWu8COvdQkIlQEZ3LwjI+rl9Tpo0Nt/z6Jy9MTEk6 Lhpg== X-Gm-Message-State: APjAAAXGaWQzrxnfOCDyE9oiXLUigqDXFQNoic4jplMP1GZ7zEElQGi+ NQMBIWoPzj87ahsCMQUVU2k= X-Google-Smtp-Source: APXvYqw15pbS1a69y/uI18Cm/1IytKsI/6afs/aOTds3C2luoxZBP8GJ3HzfrYcGPiVNXp/6luRd7g== X-Received: by 2002:a5d:51c1:: with SMTP id n1mr24851259wrv.254.1563195323896; Mon, 15 Jul 2019 05:55:23 -0700 (PDT) Received: from amir-ThinkPad-T480.ctera.local (bzq-166-168-31-246.red.bezeqint.net. [31.168.166.246]) by smtp.gmail.com with ESMTPSA id u6sm20747920wml.9.2019.07.15.05.55.22 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 15 Jul 2019 05:55:23 -0700 (PDT) From: Amir Goldstein To: Eryu Guan Cc: "Darrick J . Wong" , Dave Chinner , Olga Kornievskaia , fstests@vger.kernel.org, linux-xfs@vger.kernel.org Subject: [PATCH v4 1/3] common/rc: check support for xfs_io copy_range -f N Date: Mon, 15 Jul 2019 15:55:14 +0300 Message-Id: <20190715125516.7367-2-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190715125516.7367-1-amir73il@gmail.com> References: <20190715125516.7367-1-amir73il@gmail.com> Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Implement "_require_xfs_io_command copy_range -f" to check for the option added by following xfsprogs commit: xfs_io: allow passing an open file to copy_range Signed-off-by: Amir Goldstein --- common/rc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/common/rc b/common/rc index 000a7cc8..f1cec5ad 100644 --- a/common/rc +++ b/common/rc @@ -2105,9 +2105,16 @@ _require_xfs_io_command() ;; "copy_range") local testcopy=$TEST_DIR/$$.copy.xfs_io + local copy_opts=$testfile + if [ "$param" == "-f" ]; then + # source file is the open destination file + testcopy=$testfile + copy_opts="0 -d 4k" + fi $XFS_IO_PROG -F -f -c "pwrite 0 4k" $testfile > /dev/null 2>&1 - testio=`$XFS_IO_PROG -F -f -c "copy_range $testfile" $testcopy 2>&1` + testio=`$XFS_IO_PROG -F -f -c "copy_range $param $copy_opts" $testcopy 2>&1` rm -f $testcopy > /dev/null 2>&1 + param_checked="$param" ;; "falloc" ) testio=`$XFS_IO_PROG -F -f -c "falloc $param 0 1m" $testfile 2>&1` From patchwork Mon Jul 15 12:55:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 11043981 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8EBAF13B1 for ; Mon, 15 Jul 2019 12:55:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F56C2842E for ; Mon, 15 Jul 2019 12:55:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 73C9828433; Mon, 15 Jul 2019 12:55:30 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 C857528438 for ; Mon, 15 Jul 2019 12:55:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730071AbfGOMz3 (ORCPT ); Mon, 15 Jul 2019 08:55:29 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:40076 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730012AbfGOMz3 (ORCPT ); Mon, 15 Jul 2019 08:55:29 -0400 Received: by mail-wr1-f68.google.com with SMTP id r1so16958850wrl.7; Mon, 15 Jul 2019 05:55:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tIYRiaVOTPf3kfssJipPNQwE3j1/vFC7tibHXwYRosI=; b=EMpYTTfdqOt0jMCwf2JHQkIqPU5gAQ+3Q8FCXMUItYhmk7453J5H2T3wYxeM5Pfvsc G45qZOcaM/KdcChQK6N9TkR1hMdr3O7D3X1Qq+1Li0S3dpHkbluf9qSfwxxpzaVXispD ItVwmicrJyGXH2dnqCNPKzOR3LNwwv10EWfQoujjEdheE5M0TIwMwG8T6oeB63ytHuQe T49sFbluad3RgrebC1BdkSwBqbQs2HSnbuTnK+mBpC2qL5B55jFLliSL2fM5O27gC7/J 28NGUDTvasaWlQDVuw8PDIXMYMKNR7VmoTrhNyXLJeIUVgY/K/jW3ywGp23bG5622SIE dvCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tIYRiaVOTPf3kfssJipPNQwE3j1/vFC7tibHXwYRosI=; b=hEA9nBWzQ4aDeEh8b6JP29Q5J1+btop4xG4DQ+8S7GgRPfuqnxn5YYc1iogL4mTg58 1QFebpC2F5jp579+GO0ZJvWsDPHtDurazJhGbY4qPh73334/iYdSvptAUxcqFa3B7FSg Vi/aC7WFNISWSkdRHQ/URSE/Yl/YbIdVG4/J+yLC4nH0nfpzq98S0eP4DDmL4mBZ6bwj Zgqmn/tBJelTdGiO71hWimMPaoIql0TN5PrwD+eFtLBZY5X/VPaXYXg4zq9xqFBXrxuj rjMMfiRM97EIp/lTCCjBZ8ZllOccykz7dNS8YOrg4yp4xgXb5ZW1JqAaMkDurF9Ucq9F Y4rQ== X-Gm-Message-State: APjAAAWI2mLP9D5/zbxVjMsxiXKI40SjRvfgdPnYZ6AnTNN/LhJ3QXEl TbyUqS5hLsot0/dHJdJU5EHoPEPV X-Google-Smtp-Source: APXvYqwDEwCR4eA3jiiBqkd2pWW36jXPCOnOe2zKw7YSVC+I91pzu7GfCBnloLWOZujbgxmm/TKufw== X-Received: by 2002:adf:ec0f:: with SMTP id x15mr29316947wrn.165.1563195325276; Mon, 15 Jul 2019 05:55:25 -0700 (PDT) Received: from amir-ThinkPad-T480.ctera.local (bzq-166-168-31-246.red.bezeqint.net. [31.168.166.246]) by smtp.gmail.com with ESMTPSA id u6sm20747920wml.9.2019.07.15.05.55.23 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 15 Jul 2019 05:55:24 -0700 (PDT) From: Amir Goldstein To: Eryu Guan Cc: "Darrick J . Wong" , Dave Chinner , Olga Kornievskaia , fstests@vger.kernel.org, linux-xfs@vger.kernel.org, Dave Chinner Subject: [PATCH v4 2/3] generic: copy_file_range bounds test Date: Mon, 15 Jul 2019 15:55:15 +0300 Message-Id: <20190715125516.7367-3-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190715125516.7367-1-amir73il@gmail.com> References: <20190715125516.7367-1-amir73il@gmail.com> Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Test that copy_file_range will return the correct errors for various error conditions and boundary constraints. This is a regression test for kernel commit: 5dae222a5ff0 vfs: allow copy_file_range to copy across devices [Amir] Split out cross-device copy_range test and use only test dev. Split out immutable/swapfile test cases to reduce the requirements to run the bounds check to minimum and get coverage for more filesystems. Remove the tests for read past EOF and write after chmod -r, because we decided to stick with read(2)/write(2) semantics. Add requirements needed for large size copy tests and fifo test. Use existing char/block devices for char/block dev tests. Signed-off-by: Dave Chinner Signed-off-by: Amir Goldstein --- tests/generic/990 | 134 ++++++++++++++++++++++++++++++++++++++++++ tests/generic/990.out | 37 ++++++++++++ tests/generic/group | 1 + 3 files changed, 172 insertions(+) create mode 100755 tests/generic/990 create mode 100644 tests/generic/990.out diff --git a/tests/generic/990 b/tests/generic/990 new file mode 100755 index 00000000..cdb8302b --- /dev/null +++ b/tests/generic/990 @@ -0,0 +1,134 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2018 Red Hat, Inc. All Rights Reserved. +# +# FS QA Test No. 990 +# +# Exercise copy_file_range() syscall error conditions. +# +# This is a regression test for kernel commit: +# 96e6e8f4a68d ("vfs: add missing checks to copy_file_range") +# +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 7 15 + +_cleanup() +{ + cd / + rm -rf $tmp.* + [ -z "$loopdev" ] || _destroy_loop_device $loopdev +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here +_supported_os Linux +_supported_fs generic + +rm -f $seqres.full + +_require_test +_require_loop +# +# This test effectively requires xfs_io with these commits +# 2a42470b xfs_io: copy_file_range length is a size_t +# 1a05efba io: open pipes in non-blocking mode +# +# Without those commits test will hang on old kernel when copying +# very large size and when copying from a pipe. +# +# We require a new xfs_io feature of passing an open file as the +# copy source, as an indication that the test can run without hanging +# with large size argument and to avoid opening pipe in blocking mode. +# +_require_xfs_io_command "copy_range" "-f" + +testdir="$TEST_DIR/test-$seq" +rm -rf $testdir +mkdir $testdir + +rm -f $seqres.full + +$XFS_IO_PROG -f -c "pwrite -S 0x61 0 128k" $testdir/file >> $seqres.full 2>&1 + +echo source range overlaps destination range in same file returns EINVAL +$XFS_IO_PROG -f -c "copy_range -s 32k -d 48k -l 32k $testdir/file" $testdir/file + +echo +echo destination file O_RDONLY returns EBADF +$XFS_IO_PROG -f -r -c "copy_range -l 32k $testdir/file" $testdir/copy + +echo +echo destination file O_APPEND returns EBADF +$XFS_IO_PROG -f -a -c "copy_range -l 32k $testdir/file" $testdir/copy + +echo +echo source/destination as directory returns EISDIR +$XFS_IO_PROG -c "copy_range -l 32k $testdir/file" $testdir +$XFS_IO_PROG -f -c "copy_range -l 32k $testdir" $testdir/copy + +echo +echo source/destination as blkdev returns EINVAL +$XFS_IO_PROG -f -c "truncate 128k" $testdir/img >> $seqres.full 2>&1 +loopdev=`_create_loop_device $testdir/img` +$XFS_IO_PROG -c "copy_range -l 32k $testdir/file" $loopdev +$XFS_IO_PROG -f -c "copy_range -l 32k $loopdev" $testdir/copy +_destroy_loop_device $loopdev +loopdev= + +echo +echo source/destination as chardev returns EINVAL +$XFS_IO_PROG -c "copy_range -l 32k $testdir/file" /dev/null +$XFS_IO_PROG -f -c "copy_range -l 32k /dev/zero" $testdir/copy + +echo +echo source/destination as FIFO returns EINVAL +mkfifo $testdir/fifo +$XFS_IO_PROG -c "copy_range -l 32k $testdir/file" $testdir/fifo +# Pass input pipe as non-blocking open file to avoid old xfs_io (<4.20) +# opening the pipe in blocking mode and causing the test to hang +$XFS_IO_PROG -r -n -f -c "open $testdir/copy" -C "copy_range -l 32k -f 0" $testdir/fifo + +max_off=$((8 * 2**60 - 65536 - 1)) +min_off=65537 + +echo +echo length beyond 8EiB wraps around 0 returns EOVERFLOW +$XFS_IO_PROG -f -c "copy_range -l 10e -s $max_off $testdir/file" $testdir/copy +$XFS_IO_PROG -f -c "copy_range -l 10e -d $max_off $testdir/file" $testdir/copy + +echo +echo source range beyond 8TiB returns 0 +$XFS_IO_PROG -c "copy_range -s $max_off -l $min_off -d 0 $testdir/file" $testdir/copy + +echo +echo destination range beyond 8TiB returns EFBIG +$XFS_IO_PROG -c "copy_range -l $min_off -s 0 -d $max_off $testdir/file" $testdir/copy + +echo +echo destination larger than rlimit returns EFBIG +rm -f $testdir/copy +$XFS_IO_PROG -c "truncate 128k" $testdir/file + +# need a wrapper so the "File size limit exceeded" error can be filtered +do_rlimit_copy() +{ + $XFS_IO_PROG -f -c "copy_range -l 32k -s 0 -d 16m $testdir/file" $testdir/copy +} + +ulimit -f $((8 * 1024)) +ulimit -c 0 +do_rlimit_copy 2>&1 | grep -o "File size limit exceeded" +ulimit -f unlimited + +# success, all done +status=0 +exit diff --git a/tests/generic/990.out b/tests/generic/990.out new file mode 100644 index 00000000..05d137de --- /dev/null +++ b/tests/generic/990.out @@ -0,0 +1,37 @@ +QA output created by 990 +source range overlaps destination range in same file returns EINVAL +copy_range: Invalid argument + +destination file O_RDONLY returns EBADF +copy_range: Bad file descriptor + +destination file O_APPEND returns EBADF +copy_range: Bad file descriptor + +source/destination as directory returns EISDIR +copy_range: Is a directory +copy_range: Is a directory + +source/destination as blkdev returns EINVAL +copy_range: Invalid argument +copy_range: Invalid argument + +source/destination as chardev returns EINVAL +copy_range: Invalid argument +copy_range: Invalid argument + +source/destination as FIFO returns EINVAL +copy_range: Invalid argument +copy_range: Invalid argument + +length beyond 8EiB wraps around 0 returns EOVERFLOW +copy_range: Value too large for defined data type +copy_range: Value too large for defined data type + +source range beyond 8TiB returns 0 + +destination range beyond 8TiB returns EFBIG +copy_range: File too large + +destination larger than rlimit returns EFBIG +File size limit exceeded diff --git a/tests/generic/group b/tests/generic/group index 9ceaf317..8e764597 100644 --- a/tests/generic/group +++ b/tests/generic/group @@ -565,3 +565,4 @@ 560 auto stress dedupe 561 auto stress dedupe 562 auto clone +990 auto quick copy_range From patchwork Mon Jul 15 12:55:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 11043987 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E75F91823 for ; Mon, 15 Jul 2019 12:55:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D728F283AF for ; Mon, 15 Jul 2019 12:55:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB86C26D05; Mon, 15 Jul 2019 12:55:30 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 36163283AF for ; Mon, 15 Jul 2019 12:55:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730079AbfGOMza (ORCPT ); Mon, 15 Jul 2019 08:55:30 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:33279 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730046AbfGOMz3 (ORCPT ); Mon, 15 Jul 2019 08:55:29 -0400 Received: by mail-wr1-f65.google.com with SMTP id n9so17044128wru.0; Mon, 15 Jul 2019 05:55:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vLeoU+hrQeU5oCVVzoS+w8oqWbkmdrGKWbcspdAxY7w=; b=fue0ema9+B4XL6b3/Oe7JXkRrJwRPoJ3MOmFRsWlCM63aYcfdmjwo492gT8ll8/MTv KG2nQ9dPQrJVBAXLBSU3Li5wnIMxgnkPyzuJdfhcW5MqO2ZPPCXL9ZmrBpLudCGu9FA2 yUiKeSPDqbhjUvTkLTXsaEOrIh1x2VMgOk04VBVw68vfd71UmrMUTB5pn5OWG70KpCNR UTByVFYxWonmktIrb6MLz3yDG8NtoqFcUayxUXMB59Yz0C7WUsL6TrgrORQaWwpihePC v87ZcJE6n+wvkocdTbUlX1NQ+8Vcw2LmHK0dIetxkrLYNWUR6Z8dihsyVFc8NpXXrwKy dgjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vLeoU+hrQeU5oCVVzoS+w8oqWbkmdrGKWbcspdAxY7w=; b=Dkhdf1QL4WanO6o8dopPFOwoyoP0nYc9m3Gh2yAHHuTbGKg6Pq+W+jICAa54yx+Koh W0CIh9zCCL26GwOBdBD4Vu7/r9AaRGAIp5u82QgBnDQoqJPKL1vUcWZriRPGYr78dVcB CjnRyw8hgGg13JzLaFIRWYgdaJOXSAw3EkZu+WCKMmBNiStrgG/DRfq34i16L2/EHWCi HU41n45nUhdWdGjaBRfeamnnUJqyiKZ0zgxmGZsLbR6zirBGpdzAupqMAqEPi77FwYa9 L8GiHm1MsMwIf0K1LemMNQR9o7yXuglbjZwbb4rQtDGLwNcjtRXzWZbMRoAo4p2uZSx8 gR1A== X-Gm-Message-State: APjAAAWw4g9fVQWJ8IynFAC8TsDZhhlRhYWAGgddMeXdVOSw09ccGhgm xUkiaZa3hMWHytHE7ZQ3zAIsgVhk X-Google-Smtp-Source: APXvYqz90+Vmm9xgZAEnRpg4C+kYVITgHPcXLbEx6iPzzUEH37tYsNgZwbh6z04YLulWc12is7ZyiQ== X-Received: by 2002:adf:afe7:: with SMTP id y39mr28394197wrd.350.1563195326720; Mon, 15 Jul 2019 05:55:26 -0700 (PDT) Received: from amir-ThinkPad-T480.ctera.local (bzq-166-168-31-246.red.bezeqint.net. [31.168.166.246]) by smtp.gmail.com with ESMTPSA id u6sm20747920wml.9.2019.07.15.05.55.25 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 15 Jul 2019 05:55:26 -0700 (PDT) From: Amir Goldstein To: Eryu Guan Cc: "Darrick J . Wong" , Dave Chinner , Olga Kornievskaia , fstests@vger.kernel.org, linux-xfs@vger.kernel.org, Dave Chinner Subject: [PATCH v4 3/3] generic: cross-device copy_file_range test Date: Mon, 15 Jul 2019 15:55:16 +0300 Message-Id: <20190715125516.7367-4-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190715125516.7367-1-amir73il@gmail.com> References: <20190715125516.7367-1-amir73il@gmail.com> Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Old kernels do not support cross-device copy_file_range. This is a regression test for kernel commit: 5dae222a5ff0 vfs: allow copy_file_range to copy across devices [Amir] Split out cross-device copy_range test to a new test and _notrun if kernel/filesystem do not support cross-device copy_range. Signed-off-by: Dave Chinner Signed-off-by: Amir Goldstein --- tests/generic/991 | 64 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/991.out | 4 +++ tests/generic/group | 1 + 3 files changed, 69 insertions(+) create mode 100755 tests/generic/991 create mode 100644 tests/generic/991.out diff --git a/tests/generic/991 b/tests/generic/991 new file mode 100755 index 00000000..69b8d3d5 --- /dev/null +++ b/tests/generic/991 @@ -0,0 +1,64 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2018 Red Hat, Inc. All Rights Reserved. +# +# FS QA Test No. 991 +# +# Exercise copy_file_range() across devices supported by some +# filesystems since kernel commit: +# +# 5dae222a5ff0 vfs: allow copy_file_range to copy across devices +# +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 7 15 + +_cleanup() +{ + cd / + rm -rf $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here +_supported_os Linux +_supported_fs generic + +rm -f $seqres.full + +_require_test +_require_scratch +_require_xfs_io_command "copy_range" + +_scratch_mkfs 2>&1 >> $seqres.full +_scratch_mount + + +testdir=$TEST_DIR/test-$seq +rm -rf $testdir +mkdir $testdir +rm -f $seqres.full + +$XFS_IO_PROG -f -c "pwrite -S 0x61 0 128k" $testdir/file >> $seqres.full 2>&1 + +# expect success or EXDEV on filesystem/kernel that do not support +# cross-device copy_range +testio=`$XFS_IO_PROG -f -c "copy_range -l 128k $testdir/file" $SCRATCH_MNT/copy 2>&1` +echo $testio | grep -q "cross-device" && \ + _notrun "$FSTYP does not support cross-device copy_file_range" +echo -n $testio +cmp $testdir/file $SCRATCH_MNT/copy +echo "md5sums after xdev copy:" +md5sum $testdir/file $SCRATCH_MNT/copy | _filter_test_dir | _filter_scratch + +# success, all done +status=0 +exit diff --git a/tests/generic/991.out b/tests/generic/991.out new file mode 100644 index 00000000..19c22dfe --- /dev/null +++ b/tests/generic/991.out @@ -0,0 +1,4 @@ +QA output created by 991 +md5sums after xdev copy: +81615449a98aaaad8dc179b3bec87f38 TEST_DIR/test-991/file +81615449a98aaaad8dc179b3bec87f38 SCRATCH_MNT/copy diff --git a/tests/generic/group b/tests/generic/group index 8e764597..b1a7c594 100644 --- a/tests/generic/group +++ b/tests/generic/group @@ -566,3 +566,4 @@ 561 auto stress dedupe 562 auto clone 990 auto quick copy_range +991 auto quick copy_range