From patchwork Sun Jan 27 08:38:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10782709 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 995F5139A for ; Sun, 27 Jan 2019 08:39:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 83A6F2BA65 for ; Sun, 27 Jan 2019 08:39:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 70F292BA7F; Sun, 27 Jan 2019 08:39:00 +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 012E22BA65 for ; Sun, 27 Jan 2019 08:38:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726408AbfA0Ii7 (ORCPT ); Sun, 27 Jan 2019 03:38:59 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:39774 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726327AbfA0Ii7 (ORCPT ); Sun, 27 Jan 2019 03:38:59 -0500 Received: by mail-wr1-f66.google.com with SMTP id t27so14549452wra.6; Sun, 27 Jan 2019 00:38:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=NAeXzT4E/N5N28FZLnauRiA+RhMkatCqL1R36tz7GLE=; b=UCAJBOGuQBnrWD+jOV9qjJcFKjANGZWWHeQwFh62WfLGwGpVMTEJVn2f4MVbpbKjsH iG4bIKSyYtGe0TUkyKtSPyq/v453RNXbj0lCGiyjpzzM4ZhJmSaXghEfmmAPWhrrS+Cu QnjJhzqvKd2/XzGQrSeJjYflMSHrGYWnToS6WiHKvoERTYEkCVJcOi91UIyZC09QeHXn 4vEoXo9HVhBbTwtDjLjgIuKwtqY7oY9Snn+zJWkYp5Wp/TI9BWE5j/Uhu+Tu9QGB96lh PKVjOu2Godb2rm4HUBVrie8bY4HZU+bkUQxnVpNrqmzk0p9jlzYemrvD5THBaUoJ5h7v y59w== 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; bh=NAeXzT4E/N5N28FZLnauRiA+RhMkatCqL1R36tz7GLE=; b=rBd4Epi0vWvx3mOp6zTu+86pdNiZmludGQtsvlKI2TSkEaq/WkmAtXf7IqmD7Eqcl6 tw6gR/Px6Z2cksFDk0Eu58NGlXl+/8f8fSZYTgGGABWdI6wnzcjmYAD18nI3KPPMmBiy QQycXcXtE3Q2zpJplBS+4RUch3P9D90uuTV17bIyaywzL6MfekAXL3aGjK4JrYnVITd6 3vn9bITjTAkuh7DISD1rZrArCKioNCg545DRTIj2NsmhtHjeAASYz+ynQOzRugkrGGDY fCdPQMOVa0gF4G1TgbHSU/WxG+Ap2+hpaHsOfNEyg+07k913FzOz2RndQt5YHCaZV6Ma eOMg== X-Gm-Message-State: AJcUukdQjjnERF3qW/IjStuXiEHeXX7riu+jv3LU3hxfpTYoDkHsaWl+ NObfDW+35Q7+WNCdgXnHaFVDENXs X-Google-Smtp-Source: ALg8bN5W/LxZu6g3gVg8/BGPNCFFxfDUEgFwfj8vJORoCkSAcwSal7wWmSdqMkAYjYAjM7fdt17APQ== X-Received: by 2002:adf:f149:: with SMTP id y9mr18711049wro.284.1548578336774; Sun, 27 Jan 2019 00:38:56 -0800 (PST) Received: from amir-VirtualBox.ctera.local ([188.120.129.201]) by smtp.gmail.com with ESMTPSA id j8sm184525564wmd.0.2019.01.27.00.38.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 27 Jan 2019 00:38:56 -0800 (PST) From: Amir Goldstein To: Eryu Guan Cc: Miklos Szeredi , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH] overlay/061: enhance mmap ro/rw inconsistencies test Date: Sun, 27 Jan 2019 10:38:50 +0200 Message-Id: <20190127083850.28834-1-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP overlay/061 is currently the only overlay test that is expected to fail on upstream kernel. It is a flavor of test overlay/016 with mread in stead of pread. The ro/rw inconsistencies related to file read()/write() API were fixed with stacked file operations in v4.19, but the ro/rw inconsistencies related to shared mmap read/write remain to be fixed. The test currently checks cache coherency between mmap read and file write(), but this sort of cache coherency is a Linux implementation detail not a requirement of the API. Instead of mread vs. pwrite, check consistency of mread vs. mwrite to shared mmap, which is required by the MMAP_SHARED API. Because we can, perform the test on shared memory that maps files that are already close and check also that mwrite after file is closed is persistent. This adds test coverage for future overlayfs writeback code. Signed-off-by: Amir Goldstein --- tests/overlay/061 | 36 +++++++++++++++++++++++++++++------- tests/overlay/061.out | 4 ++-- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/tests/overlay/061 b/tests/overlay/061 index aea72eb9..47be2cc3 100755 --- a/tests/overlay/061 +++ b/tests/overlay/061 @@ -4,14 +4,15 @@ # # FSQA Test No. 061 # -# Test ro/rw fd data inconsistecies +# Test memory mapped data inconsistencies # # This is a variant of test overlay/016 with mread instead of pread. # # This simple test demonstrates a known issue with overlayfs: -# - process A opens file F for read + mmap -# - process B writes new data to file F -# - process A reads old data from mapped memory +# - process A created shared ro mmap on file F +# - process B created shared rw mmap on file F +# - process B writes new data to shared mmap +# - process A reads old data from shared mmap # seq=`basename $0` seqres=$RESULT_DIR/$seq @@ -49,15 +50,36 @@ echo "This is old news" > $lowerdir/foo _scratch_mount +filter_xfs_io_mmap() +{ + # filter out these lines: + # [000] 0x7f3d9aece000 - 0x7f3d9aece010 r-- SCRATCH_MNT/foo (0 : 16) + grep -Fv '[00' +} + # # mmap MAP_SHARED|PROT_READ of rofd -# write to rwfd -# read from mapped memory +# mmap MAP_SHARED|PROT_WRITE of rwfd +# write to rw mmap +# read from ro mmap # $XFS_IO_PROG -r $SCRATCH_MNT/foo \ -C "mmap -r 0 16" \ + -C "close" \ -C "open $SCRATCH_MNT/foo" \ - -C "pwrite -S 0x61 0 16" \ + -C "mmap -w 0 16" \ + -C "close" \ + -C "mwrite -S 0x61 0 16" \ + -C "munmap" \ + -C "mread -v 0 16" \ +| _filter_xfs_io | _filter_scratch | filter_xfs_io_mmap + +_scratch_cycle_mount + +# Verify mmap write after close has persisted through mount cycle +echo "After mount cycle:" +$XFS_IO_PROG -r $SCRATCH_MNT/foo \ + -C "mmap -r 0 16" \ -C "mread -v 0 16" \ | _filter_xfs_io | _filter_scratch diff --git a/tests/overlay/061.out b/tests/overlay/061.out index 0662721c..d0e8b86e 100644 --- a/tests/overlay/061.out +++ b/tests/overlay/061.out @@ -1,4 +1,4 @@ QA output created by 061 -wrote 16/16 bytes at offset 0 -XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +00000000: 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 aaaaaaaaaaaaaaaa +After mount cycle: 00000000: 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 aaaaaaaaaaaaaaaa