From patchwork Thu Nov 24 20:12:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 9446237 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 D38D36071C for ; Thu, 24 Nov 2016 20:12:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA8C9280F4 for ; Thu, 24 Nov 2016 20:12:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD82428119; Thu, 24 Nov 2016 20:12:42 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 2F0B5280F4 for ; Thu, 24 Nov 2016 20:12:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757393AbcKXUMl (ORCPT ); Thu, 24 Nov 2016 15:12:41 -0500 Received: from mail-wj0-f196.google.com ([209.85.210.196]:36671 "EHLO mail-wj0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757276AbcKXUMk (ORCPT ); Thu, 24 Nov 2016 15:12:40 -0500 Received: by mail-wj0-f196.google.com with SMTP id jb2so3958971wjb.3; Thu, 24 Nov 2016 12:12:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=GygKpH7hmeIWu2r/OeIDc+IlXG1bst9OuQE5e0C92nk=; b=ZL4vaoM8My/ukSrfsTOjZ9Z89HO4L09mTn+NSLExJNfl4nHqM0v5oxPw5g10T8r3bM Iaw+Y6+YfpNfKfpxxKB8z4WO49LPgubUWYDiLCnkodrE3lMdnT7xksqAr0AWITcDXhbk TDM3Ms2ONcvaYK0R4KJ8zzWe2KubXImGicBH3bP6U1XhL+C00Z4DKpU7cqLEJyD9192J eLWJvoCpP3Hy+kpKEYKQ5Y4nvc6tImm6Qor7xMv9Oph1ncZ3F1+RyUGa0TPqAl/AgZEa kG7IyJvSbj8/L+uZNtHCINq2XfdX4fVVwr+GqCd4jw6u1tWOTrllsYbwxC5qHtp3sdqM k+bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=GygKpH7hmeIWu2r/OeIDc+IlXG1bst9OuQE5e0C92nk=; b=VDcTbEjbezfmSAKZzokKxgt2jOSUOrUS38Fu+ZUa5VlrFioccMLnFoZYUvAJ7VnMGg nm7fE5r4M2efeG4DP33r15VmwA916Pwl57/VhjJgSlv7xsFikw50lY/lyLX1k6aNwZB6 JLtFWtgHzCBCcEwxWHje8g7tthjfUxFaVYr3p+tRTv4OeOYlG9h7Woy3X0q+n5nDDLOq buTm+LNJPDTjpnK5CDW3vIqJe8z/qw8DzmnNmVaVroog9YV96zKElS9sEZbId2mDgnGg 0Oqb+f4AT61NX4rudaySK66JcWEHbRB34ai2sfaOjWnrpxGx1ctUb07ee45YV57NtHuA GORg== X-Gm-Message-State: AKaTC01lSdVopzbB0tIOXteKPUp2wgl9UEFIrs0jXKSE3kYHUy8JTmNLytXXHMnGKU0tpA== X-Received: by 10.194.79.5 with SMTP id f5mr4422850wjx.13.1480018358182; Thu, 24 Nov 2016 12:12:38 -0800 (PST) Received: from amir-VirtualBox.Home (bzq-79-177-89-54.red.bezeqint.net. [79.177.89.54]) by smtp.gmail.com with ESMTPSA id q7sm43517951wjh.9.2016.11.24.12.12.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 24 Nov 2016 12:12:37 -0800 (PST) From: Amir Goldstein To: Eryu Guan Cc: Miklos Szeredi , Xiong Zhou , Filipe Manana , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH] overlay: test ro/rw fd data inconsistecies Date: Thu, 24 Nov 2016 22:12:12 +0200 Message-Id: <1480018332-16567-1-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Introduce a new test to demonstrates a known issue with overlayfs: - process A opens file F for read - process B writes new data to file F - process A reads old data from file F This issue is about to be fixed with a patch set by Miklos Szeredi. Signed-off-by: Amir Goldstein --- tests/overlay/016 | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/overlay/016.out | 12 +++++++ tests/overlay/group | 1 + 3 files changed, 111 insertions(+) create mode 100755 tests/overlay/016 create mode 100644 tests/overlay/016.out diff --git a/tests/overlay/016 b/tests/overlay/016 new file mode 100755 index 0000000..6d3e339 --- /dev/null +++ b/tests/overlay/016 @@ -0,0 +1,98 @@ +#! /bin/bash +# FSQA Test No. 016 +# +# Test ro/rw fd data inconsistecies +# +# This simple test demonstrates a known issue with overlayfs: +# - process A opens file F for read +# - process B writes new data to file F +# - process A reads old data from file F +# +#----------------------------------------------------------------------- +# +# Copyright (C) 2016 CTERA Networks. All Rights Reserved. +# Author: Amir Goldstein +# +# 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" + +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here +_supported_fs overlay +_supported_os Linux +_require_scratch + +rm -f $seqres.full + +_scratch_mkfs >>$seqres.full 2>&1 + +# Create our test files. +lowerdir=$SCRATCH_DEV/$OVERLAY_LOWER_DIR +mkdir -p $lowerdir +echo "This is old news" > $lowerdir/foo +echo "This is old news" > $lowerdir/bar + +_scratch_mount + +cd $SCRATCH_MNT + +# +# case #1: +# open file for read (rofd) +# open file for write (rwfd) +# write to rwfd +# read from rofd +# +$XFS_IO_PROG << EOF | _filter_xfs_io +open -r foo +open foo +pwrite -S 0x61 0 16 +file 0 +pread -v 0 16 +EOF + +# +# case #2: +# mmap MAP_SHARED|PROT_READ of rofd +# write to rwfd +# read from mapped memory +# +$XFS_IO_PROG << EOF | _filter_xfs_io +open -r bar +mmap -r 0 16 +open bar +pwrite -S 0x61 0 16 +mread -v 0 16 +EOF + +status=0 +exit diff --git a/tests/overlay/016.out b/tests/overlay/016.out new file mode 100644 index 0000000..52b8cd7 --- /dev/null +++ b/tests/overlay/016.out @@ -0,0 +1,12 @@ +QA output created by 016 +xfs_io> xfs_io> xfs_io> wrote 16/16 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +xfs_io> [000] foo (foreign,non-sync,non-direct,read-only) + 001 foo (foreign,non-sync,non-direct,read-write) +xfs_io> 00000000: 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 aaaaaaaaaaaaaaaa +read 16/16 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +xfs_io> xfs_io> xfs_io> xfs_io> xfs_io> wrote 16/16 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +xfs_io> 00000000: 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 aaaaaaaaaaaaaaaa +xfs_io> \ No newline at end of file diff --git a/tests/overlay/group b/tests/overlay/group index 84850b1..5740d2a 100644 --- a/tests/overlay/group +++ b/tests/overlay/group @@ -18,3 +18,4 @@ 013 auto quick 014 auto quick copyup 015 auto quick whiteout +016 auto quick