From patchwork Sun Mar 25 14:53:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10306663 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 B18A360212 for ; Sun, 25 Mar 2018 14:52:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A139929263 for ; Sun, 25 Mar 2018 14:52:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 95E2F293D5; Sun, 25 Mar 2018 14:52:04 +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 F274729263 for ; Sun, 25 Mar 2018 14:52:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753286AbeCYOwD (ORCPT ); Sun, 25 Mar 2018 10:52:03 -0400 Received: from mail-wr0-f181.google.com ([209.85.128.181]:45421 "EHLO mail-wr0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753321AbeCYOwC (ORCPT ); Sun, 25 Mar 2018 10:52:02 -0400 Received: by mail-wr0-f181.google.com with SMTP id u11so4103934wri.12; Sun, 25 Mar 2018 07:52:01 -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=WcnP27e2MZ19mbqcKVlCORa0+PgbVRj3SNDvsBJxD4g=; b=ju/C7wtfb9z2ikxOZXDntKW7HDXni0yYnkCHPFCcCFB90RluF7xDtHbYinifGN6tId Jqc6/nc8UA9uK8Eb2KQVmkekvVCaD9Eju1FyBVA6ToBbPHYBTbNmR/9VDioG+ahL/Vfa yvVUbw+PtRvyQREfnVjJT5lGMCtLBGX/CMrQHoHKX9rRoUkwDG0v8ELL0G0KyKyoOqRn 2eo10Uh+GnTw5h3p2XoiNt4oDf2aT8SHeXwUT0iG9dRmuOOOofpUt26dvppso35gEou0 j006SKOjktZe19UqIAO3LxG5ZyN04uh015eHdV9sMqgFgx0WB28EMrv0Tr4glOscn/pW Z7Pg== 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=WcnP27e2MZ19mbqcKVlCORa0+PgbVRj3SNDvsBJxD4g=; b=YaCQ8ynzBBbLCwgnA4l+ygsUXXeQ2mxhkNtQuE3gGRA8upDnK/MtJlIsDdxfFZybU4 CUkQASoB1kO4x5hqMx/vvQy/aFQhP9z8NzQO6+OlV+6+kBlzbH5VixH8T3yXk02M1/0F dFNOWVavW7FW+XV3HYRfitvuo9WMYnn30wnBu1aA6sWNx327RHizBge06jUQzPnjs+xm rnG/a5nNkKe/VSO+Z5ocZUCLCT9hoIYREWo0yK4OrB1m4p9V+xZYX/EI+JlGlIN1kk6x 14sc66275r3uLo4H7oemAkjq8HcJiOsJIcnSJFKGbUXwnAxH6UwlZTTHK04VOG3uxWjQ alDw== X-Gm-Message-State: AElRT7ERV8bTZ8V9QkDOPIfW3NS15mk6u3uROsWbxcoTWlqcmVLwqtni qnik+JXZyXOQ2htKFu9bBBY= X-Google-Smtp-Source: AIpwx48XQeDF2kHAIy+3E7CSDUboFL+kHO6BvAZ3cfFU8KouIS9VxICJYGFOd1e13j6HHHdb+2rGvA== X-Received: by 10.223.225.17 with SMTP id d17mr1202645wri.51.1521989520674; Sun, 25 Mar 2018 07:52:00 -0700 (PDT) Received: from amir-VirtualBox.ctera.local (bzq-166-168-31-246.red.bezeqint.net. [31.168.166.246]) by smtp.gmail.com with ESMTPSA id a63sm16537054wrc.22.2018.03.25.07.51.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 25 Mar 2018 07:52:00 -0700 (PDT) From: Amir Goldstein To: Eryu Guan Cc: Miklos Szeredi , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH 3/3] overlay: test decoding overlay file handles with warm/cold dentry cache Date: Sun, 25 Mar 2018 17:53:11 +0300 Message-Id: <1521989591-9496-4-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521989591-9496-1-git-send-email-amir73il@gmail.com> References: <1521989591-9496-1-git-send-email-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 When opening a non-dir by file handle and the decoded inode/dentry are not in cache, the resulting dentry is "disconnected" (i.e. unknown path). This is a common case that is already covered by previous tests. This test covers the case of decoding an overlay file handle, while a disconnected dentry is still in cache. Signed-off-by: Amir Goldstein --- tests/overlay/058 | 137 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/overlay/058.out | 9 ++++ tests/overlay/group | 1 + 3 files changed, 147 insertions(+) create mode 100755 tests/overlay/058 create mode 100644 tests/overlay/058.out diff --git a/tests/overlay/058 b/tests/overlay/058 new file mode 100755 index 0000000..4c4ca45 --- /dev/null +++ b/tests/overlay/058 @@ -0,0 +1,137 @@ +#! /bin/bash +# FS QA Test No. 058 +# +# Test decoding overlay file handles with warm/cold dentry cache +# +# When opening a non-dir by file handle and the decoded inode/dentry +# are not in cache, the resulting dentry is "disconnected" (i.e. unknown +# path). This is a common case that is already covered by previous tests. +# This test covers the case of decoding an overlay file handle, while a +# disconnected dentry is still in cache. +# +# This test requires and enables overlayfs NFS export support. +# NFS export support depends on and requires overlayfs index feature. +# +#----------------------------------------------------------------------- +# Copyright (C) 2018 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" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + $KILLALL_PROG -9 open_by_handle >/dev/null 2>&1 + wait + 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 +_require_test_program "open_by_handle" +# We need to require all features together, because nfs_export cannot +# be enabled when index is disabled +_require_scratch_overlay_features index nfs_export +_require_command "$KILLALL_PROG" killall + +# All overlay dirs are on scratch partition +lower=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER +upper=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER +work=$OVL_BASE_SCRATCH_MNT/$OVL_WORK + +# Keep this number > 1, because open_by_handle -rp does faccessat() +# on file file000000, which makes that dentry connected +NUMFILES=10 + +# Create test dir and empty test files +create_test_files() +{ + local dir=$1 + local opt=$2 + + mkdir -p $dir + $here/src/open_by_handle -cp $opt $dir $NUMFILES +} + +# Test encode/decode file handles on overlay mount +test_file_handles() +{ + local dir=$1 + shift + + echo test_file_handles $dir $* | _filter_scratch | \ + sed -e "s,$tmp\.,,g" + $here/src/open_by_handle $* $dir $NUMFILES +} + +# Create lower/upper dir and files +_scratch_mkfs +create_test_files $upper/uppertestdir -w +create_test_files $lower/lowertestdir -w +_scratch_mount -o "index=on,nfs_export=on" +# Encode upper file handles +test_file_handles $SCRATCH_MNT/uppertestdir -p -o $tmp.upper_file_handles +# Encode lower file handles +test_file_handles $SCRATCH_MNT/lowertestdir -p -o $tmp.lower_file_handles + +# Check decode and read from stored file handles with warm caches - +# At this time, all non-dir dentries are connected, because the entries +# were created on lookup, before encoding the file handles. +test_file_handles $SCRATCH_MNT -rnp -i $tmp.upper_file_handles +test_file_handles $SCRATCH_MNT -rnp -i $tmp.lower_file_handles + +# Check decode and read/readdir from stored file handles with cold caches - +# -s sleeps in the background to keep files open and keep disconnected +# overlay dentries in cache +_scratch_cycle_mount "index=on,nfs_export=on" +test_file_handles $SCRATCH_MNT -rnps -i $tmp.upper_file_handles & +# Give the above 1 second to get to sleep loop +sleep 1 +test_file_handles $SCRATCH_MNT -rnps -i $tmp.lower_file_handles & +# Give the above 1 second to get to sleep loop +sleep 1 + +# Check decode and read/readdir from stored file handles with warm caches - +# At this time, all non-dir dentries are disconnected, because there was +# no lookup to the files since drop caches. The expection to this rule +# is lower and upper file000000. open_by_handle -rp above did faccessat() +# on file file000000, which created a connected dentry alias in addition +# to the disconnected dentry alias. +test_file_handles $SCRATCH_MNT -rnp -i $tmp.upper_file_handles +test_file_handles $SCRATCH_MNT -rnp -i $tmp.lower_file_handles + +# SIGPIPE avoids Terminated/Killed message from bash +$KILLALL_PROG -q -13 open_by_handle +wait + +status=0 +exit diff --git a/tests/overlay/058.out b/tests/overlay/058.out new file mode 100644 index 0000000..6ff9811 --- /dev/null +++ b/tests/overlay/058.out @@ -0,0 +1,9 @@ +QA output created by 058 +test_file_handles SCRATCH_MNT/uppertestdir -p -o upper_file_handles +test_file_handles SCRATCH_MNT/lowertestdir -p -o lower_file_handles +test_file_handles SCRATCH_MNT -rnp -i upper_file_handles +test_file_handles SCRATCH_MNT -rnp -i lower_file_handles +test_file_handles SCRATCH_MNT -rnps -i upper_file_handles +test_file_handles SCRATCH_MNT -rnps -i lower_file_handles +test_file_handles SCRATCH_MNT -rnp -i upper_file_handles +test_file_handles SCRATCH_MNT -rnp -i lower_file_handles diff --git a/tests/overlay/group b/tests/overlay/group index c49ae3a..359ed42 100644 --- a/tests/overlay/group +++ b/tests/overlay/group @@ -60,3 +60,4 @@ 055 auto quick copyup redirect exportfs nonsamefs 056 auto quick fsck 057 auto quick redirect +058 auto quick exportfs