From patchwork Sun Mar 25 14:53:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10306659 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 08D6B600CC for ; Sun, 25 Mar 2018 14:52:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EBF4929263 for ; Sun, 25 Mar 2018 14:52:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E0986293D5; Sun, 25 Mar 2018 14:52:01 +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 6334429263 for ; Sun, 25 Mar 2018 14:52:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753378AbeCYOwA (ORCPT ); Sun, 25 Mar 2018 10:52:00 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:33037 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753321AbeCYOv7 (ORCPT ); Sun, 25 Mar 2018 10:51:59 -0400 Received: by mail-wr0-f196.google.com with SMTP id z73so16425682wrb.0; Sun, 25 Mar 2018 07:51:58 -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=xQLJpNIX/ql6b8vrj5smMq5/Jv+AMKp4ZY9NQ/hFS+Y=; b=tJHVa8uDaiJJskXl/aZgW4aoVFu/rsCgjfR+nhhRwUkgCNYt8z0D1iGnUZCrjBU7hh sC3WRI6HOL3QGPcnVxgQnXbNGJAZXg71s6z4FzbasI8ObL4KlVj/JFmwDyqgReS/oUsv IerU6Zcq9dZX0BVXll9ZYGd4Vvldan2D8RFQco3vW75GYt+cqoGq3xn7zquuiROImTzD Ujx6KBAFvbUu4B8CgUkU+zxMquL4DdAQM4nb5A75AVZ08P2kTuxQ2cx37ktMdeHZT3uo V4N2DfrMhrkhj0wXbmSBDdgIFEgfeLJM21gQH2lb2/ieUdlUMovOJY+LY6+QGTqd4F+Y tpZg== 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=xQLJpNIX/ql6b8vrj5smMq5/Jv+AMKp4ZY9NQ/hFS+Y=; b=tUf+3ScZ3sI3aWAT79ruqs7bog/QztyTb8f5k5Avyqg/aWe8dnCRWwod9vxLPVnedE 7Cx2ZVDhyU70h32i5PEScrBUdQpGd0BuNglrFvHVb5vD3yy5XGsX0COhzSPVFFSOdlue E68nMmzxPBkymN7s9p5P2SxPUcRHyjAbVnxHVMINYAFC+Ft7goUulnAmZxT2vnQRF0ia k17OK/ULMn5QeFtfndG90eX25JCfEyU7i5velfFKuBO2IoJ4up5V/YG2KY1yhIm9Lh5K NHscfGYdNfdih+2bkbM5ghhXjLOfQgNduislOpQCXPNxUD6eOGFoe8lkIwZnd25yYAyh KJgQ== X-Gm-Message-State: AElRT7FrE/dDO5B04H394KucIT5DZacc1cNS0v7htcLRC2/9L8q6pG9o ifkwnATq9ZWZ/VALEFRYSyQ= X-Google-Smtp-Source: AIpwx49dTrkjrpkZSC/BJI0FVjmfe4n9eycNgr6kWiw6HJUCiTbXFLv/7FybdhPUyLDIu/tZtcGlrg== X-Received: by 10.223.182.78 with SMTP id i14mr1934214wre.140.1521989518255; Sun, 25 Mar 2018 07:51:58 -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.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 25 Mar 2018 07:51:57 -0700 (PDT) From: Amir Goldstein To: Eryu Guan Cc: Miklos Szeredi , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH 1/3] open_by_handle: add -n option to suppress drop caches Date: Sun, 25 Mar 2018 17:53:09 +0300 Message-Id: <1521989591-9496-2-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 By default, open_by_handle drops inode and page caches before trying to open by file handles. Add an option to suppress drop caches for testing open by handle with warm caches. Usage: open_by_handle -n [N] Signed-off-by: Amir Goldstein --- src/open_by_handle.c | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/src/open_by_handle.c b/src/open_by_handle.c index 78f7ef7..d3beb78 100644 --- a/src/open_by_handle.c +++ b/src/open_by_handle.c @@ -27,7 +27,7 @@ /* -usage: open_by_handle [-cludmrwapk] [<-i|-o> ] [num_files] +usage: open_by_handle [-cludmrwapknh] [<-i|-o> ] [num_files] Examples: @@ -43,36 +43,39 @@ Examples: open_by_handle -p [N] -3. Get file handles for existing test set and write them to a file. - Read file handles from file and open files by handle: +3. Get file handles for existing test set and write them to a file: open_by_handle -p -o [N] - open_by_handle -p -i [N] -4. Get file handles for existing test set, write data to files, +4. Read file handles from file and open files by handle without + dropping caches beforehand: + + open_by_handle -np -i [N] + +5. Get file handles for existing test set, write data to files, drop caches, open all files by handle, read and verify written data, write new data to file: open_by_handle -rwa [N] -5. Get file handles for existing test set, unlink all test files, +6. Get file handles for existing test set, unlink all test files, remove test_dir, drop caches, try to open all files by handle and expect ESTALE: open_by_handle -dp [N] -6. Get file handles for existing test set, keep open file handles for all +7. Get file handles for existing test set, keep open file handles for all test files, unlink all test files, drop caches and try to open all files by handle (should work): open_by_handle -dk [N] -7. Get file handles for existing test set, rename all test files, +8. Get file handles for existing test set, rename all test files, drop caches, try to open all files by handle (should work): open_by_handle -m [N] -8. Get file handles for existing test set, hardlink all test files, +9. Get file handles for existing test set, hardlink all test files, then unlink the original files, drop caches and try to open all files by handle (should work): @@ -109,10 +112,11 @@ struct handle { void usage(void) { - fprintf(stderr, "usage: open_by_handle [-cludmrwapk] [<-i|-o> ] [num_files]\n"); + fprintf(stderr, "usage: open_by_handle [-cludmrwapknh] [<-i|-o> ] [num_files]\n"); fprintf(stderr, "\n"); fprintf(stderr, "open_by_handle -c [N] - create N test files under test_dir, try to get file handles and exit\n"); fprintf(stderr, "open_by_handle [N] - get file handles of test files, drop caches and try to open by handle\n"); + fprintf(stderr, "open_by_handle -n [N] - get file handles of test files and try to open by handle without drop caches\n"); fprintf(stderr, "open_by_handle -k [N] - get file handles of files that are kept open, drop caches and try to open by handle\n"); fprintf(stderr, "open_by_handle -w [N] - write data to test files before open by handle\n"); fprintf(stderr, "open_by_handle -r [N] - read data from test files after open by handle and verify written data\n"); @@ -144,12 +148,12 @@ int main(int argc, char **argv) int numfiles = 1; int create = 0, delete = 0, nlink = 1, move = 0; int rd = 0, wr = 0, wrafter = 0, parent = 0; - int keepopen = 0; + int keepopen = 0, drop_caches = 1; if (argc < 2) usage(); - while ((c = getopt(argc, argv, "cludmrwapki:o:")) != -1) { + while ((c = getopt(argc, argv, "cludmrwapknhi:o:")) != -1) { switch (c) { case 'c': create = 1; @@ -186,6 +190,9 @@ int main(int argc, char **argv) case 'k': keepopen = 1; break; + case 'n': + drop_caches = 0; + break; case 'i': infile = optarg; in_fd = open(infile, O_RDONLY); @@ -438,10 +445,12 @@ int main(int argc, char **argv) * buftarg page cache is emptied so that the inode cluster has to be * fetched from disk again for the open_by_handle() call. */ - ret = system("echo 3 > /proc/sys/vm/drop_caches"); - if (ret < 0) { - perror("drop_caches"); - return EXIT_FAILURE; + if (drop_caches) { + ret = system("echo 3 > /proc/sys/vm/drop_caches"); + if (ret < 0) { + perror("drop_caches"); + return EXIT_FAILURE; + } } /*