From patchwork Thu Mar 29 12:06:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10315303 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 8462960383 for ; Thu, 29 Mar 2018 12:05:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 653122A1EE for ; Thu, 29 Mar 2018 12:05:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 59D0B2A1FC; Thu, 29 Mar 2018 12:05:45 +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 4BA4A2A1F2 for ; Thu, 29 Mar 2018 12:05:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751207AbeC2MFl (ORCPT ); Thu, 29 Mar 2018 08:05:41 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:39737 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752626AbeC2MFk (ORCPT ); Thu, 29 Mar 2018 08:05:40 -0400 Received: by mail-wm0-f66.google.com with SMTP id f125so11102326wme.4; Thu, 29 Mar 2018 05:05:39 -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=+UHhwxd8y7OfspFQRMmkOlIgisYy6ctFAhIcC4KQ0KI=; b=k3k2+9OP6zVymCUhfd02OE3QKqDdmfKwcrXPVNSxWqKkLut5YDOxsJAA8qgbPonrQh gBYE7Eqc17xGPQLdKCZyq7l7qRsKi5EmMD1e9GmxaM7DonlhfJtW8aSOpi6nOyL7uTrm 4UZ/H1vYhoLXdRAgr++uvgdHjH1fLfhigJ301l5UWzeC8P/2JYfV9jld2wCtDJJfAtKP ElIqM6HNnHO3xZe37OhkI+5m0FhVZ8DwOKlhm5sxRa4rCnHHetSlFLcolZSHh4ZMu83X h8PLuVe5in0sP5pyVkgJn5xHHnA/wFd04u5tP+ASgUG5Di4NotbrK1OTPpKqBG8PLWBp ZtjA== 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=+UHhwxd8y7OfspFQRMmkOlIgisYy6ctFAhIcC4KQ0KI=; b=fGzjYUvk7RUsU7L4NGI9lLgpslC5wSDKJovT8YaEqBjl3bkdtp6rGOFiqtSNYTUIyp Ns8I4t4KY7iGo88ra3VrWf4iZoTgsV9kE+SmGVg7P2WaxAPyXBNcXI4ZW9qqMZd3tEZM H8akgrCmJAvBwLUtL5oaY0SvRKANkBfXTsa9unoIUi47jLh1IyQbuzSKVYf9gj3NKe7t CEY+aZVwNgMy7AVU2s9zAsZIPEU8grKWK894uQwhy9b6kjZUfuVeGEFLGGQd6ktmAvHY Kjw+c9yBQ98GG0IZW0Q9C8XMhf4FSCZYEqGfdwd71bfSgPpfBhZu3hhdbRA2tKtsx+51 Y1tw== X-Gm-Message-State: AElRT7FSscNOs9KVzG1yS0fb+YZA90VX6Beo+JT/XKr/IBzD9Yygm5A1 7w3sGoLdokie0n1zo3q2+HKjQA== X-Google-Smtp-Source: AIpwx4+vKNlhCCbEK+XIVeJbsugj+whBxGvr0AcE88DFpk1LYgLbAMZYAYh4ItKdMuieXGIIjnvUOg== X-Received: by 10.28.191.20 with SMTP id p20mr5553982wmf.100.1522325139126; Thu, 29 Mar 2018 05:05:39 -0700 (PDT) Received: from localhost.localdomain ([141.226.13.13]) by smtp.gmail.com with ESMTPSA id s15sm6699694wrg.28.2018.03.29.05.05.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Mar 2018 05:05:38 -0700 (PDT) From: Amir Goldstein To: Eryu Guan Cc: Miklos Szeredi , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH v2 3/5] open_by_handle: add -n option to suppress drop caches Date: Thu, 29 Mar 2018 15:06:48 +0300 Message-Id: <1522325210-17900-4-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522325210-17900-1-git-send-email-amir73il@gmail.com> References: <1522325210-17900-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 7dfb395..d3beb78 100644 --- a/src/open_by_handle.c +++ b/src/open_by_handle.c @@ -27,7 +27,7 @@ /* -usage: open_by_handle [-cludmrwapkh] [<-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 [-cludmrwapkh] [<-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, "cludmrwapkhi: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; + } } /*