From patchwork Thu Nov 2 10:15:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10038305 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 31799603B5 for ; Thu, 2 Nov 2017 10:15:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1EDB728EE0 for ; Thu, 2 Nov 2017 10:15:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 11F2028EDE; Thu, 2 Nov 2017 10:15:06 +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.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 A9C5628EDE for ; Thu, 2 Nov 2017 10:15:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933305AbdKBKPD (ORCPT ); Thu, 2 Nov 2017 06:15:03 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:46209 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933301AbdKBKPA (ORCPT ); Thu, 2 Nov 2017 06:15:00 -0400 Received: by mail-wm0-f66.google.com with SMTP id m72so9898116wmc.1; Thu, 02 Nov 2017 03:14:59 -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=GXO3WlVpfMnkWK2WVsAWCMugb+jzIsgYaLrqWjjxH2c=; b=mwhNZTpjJwJH3OGwKirDINUixPYSwneZHon6kordwhW9xMvfxo/3mfUeC9GR2eOEiN 2ZKB27lfcArWjZaXjArwu+W0y4G80CBh0B387/r601r5pEvW4hYwbE1oPD9EEqTXHMPh 3/gBeR7dbdH3W4s9ANsByOniMN/+sSO3YWfRC/77ZjrejUI2YqX0mRNQlaAEH0UA+Bai vvsrVSWiq4nR5JAlXaDPaiZRJvLveCbxpMldpoNwYmKfpEBVpV30dHUQ6qhNEXGcR3+6 zAFtnmVrv8i1sGTZ+kbHLg2DYhKkEZjcqtNcwPCg1SZtnkEEnidvLwXKsNanjE7lH3Ff c/nw== 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=GXO3WlVpfMnkWK2WVsAWCMugb+jzIsgYaLrqWjjxH2c=; b=VnNTZ5qgTmp1fn3b/kL8raf/+MBRkUweBEYFGsbuj6+jv/V0oQXMmt6nQwnBVmcmur 5qDpM70mEGD2QLeU8jy27HxFq2MZ3nX1Yv47CuAN2MOJxYfTJCe6RL0j9jb4xmNCNpdK ChnHTbjlJJ5T9hd04qXHsHyiHMz4e/VGEaiShxDXNTokNC8kIr8MJt4ETfbgVxRgD7pi kbPGXORCLFGS6Yk9A3ufLTqL9cL5iJAx4GY+IbiaWIFtPK8VanUiwqNIboOq+rkWjjkQ a3Shcpox2PGcyaMcvLnPh2uQUde3k4tCoYQZM/BGblhg9C+GmEAMTkhIlmqyHXQ42HfI yCrg== X-Gm-Message-State: AJaThX4rhm610jnDs1L9eUljSli+hZ3HfqzmPQRknG39rCdB1yG9tK0S UWYIfvwlb+nYvOLKskpLnLU= X-Google-Smtp-Source: ABhQp+Rc+IeEKrXYrc3xmtuzfyDGg2V8mcNuS/8wrfO370j3aywh7i4rpxKg3+ozvPQmbih6qo21Pw== X-Received: by 10.28.6.6 with SMTP id 6mr1215765wmg.114.1509617698459; Thu, 02 Nov 2017 03:14:58 -0700 (PDT) Received: from localhost.localdomain ([31.210.182.123]) by smtp.gmail.com with ESMTPSA id e6sm7190026wrg.53.2017.11.02.03.14.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 02 Nov 2017 03:14:58 -0700 (PDT) From: Amir Goldstein To: Eryu Guan Cc: Jeff Layton , "J . Bruce Fields" , Miklos Szeredi , fstests@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-unionfs@vger.kernel.org Subject: [PATCH 2/7] open_by_handle: test file handles of renamed files Date: Thu, 2 Nov 2017 12:15:34 +0200 Message-Id: <1509617739-15744-3-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1509617739-15744-1-git-send-email-amir73il@gmail.com> References: <1509617739-15744-1-git-send-email-amir73il@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP usage: open_by_handle -m [N] Get file handles for existing test set, rename all test files, drop cache and try to open all files by handle. This is needed for testing that overlayfs can find the upper inode from lower file handle even when upper is not in the same path as lower. Signed-off-by: Amir Goldstein --- src/open_by_handle.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/open_by_handle.c b/src/open_by_handle.c index 52973c6..8b12df3 100644 --- a/src/open_by_handle.c +++ b/src/open_by_handle.c @@ -27,7 +27,7 @@ /* -usage: open_by_handle [-c|-l|-u|-d] [num_files] +usage: open_by_handle [-cludm] [num_files] Examples: @@ -48,7 +48,12 @@ Examples: open_by_handle -d [N] -4. Get file handles for existing test set, hardlink all test files, +4. 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] + +5. 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): @@ -84,13 +89,14 @@ struct handle { void usage(void) { - fprintf(stderr, "usage: open_by_handle [-c|-l|-u|-d] [num_files]\n"); + fprintf(stderr, "usage: open_by_handle [-cludm] [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 -l [N] - create hardlinks to test files, drop caches and try to open by handle\n"); fprintf(stderr, "open_by_handle -u [N] - unlink (hardlinked) test files, drop caches and try to open by handle\n"); fprintf(stderr, "open_by_handle -d [N] - unlink test files and hardlinks, drop caches and try to open by handle\n"); + fprintf(stderr, "open_by_handle -m [N] - rename test files, drop caches and try to open by handle\n"); exit(EXIT_FAILURE); } @@ -105,12 +111,12 @@ int main(int argc, char **argv) char *test_dir; int mount_fd, mount_id; int numfiles = 1; - int create = 0, delete = 0, nlink = 1; + int create = 0, delete = 0, nlink = 1, move = 0; if (argc < 2 || argc > 4) usage(); - while ((c = getopt(argc, argv, "clud")) != -1) { + while ((c = getopt(argc, argv, "cludm")) != -1) { switch (c) { case 'c': create = 1; @@ -126,6 +132,9 @@ int main(int argc, char **argv) delete = 1; nlink = 0; break; + case 'm': + move = 1; + break; default: fprintf(stderr, "illegal option '%s'\n", argv[optind]); case 'h': @@ -201,6 +210,18 @@ int main(int argc, char **argv) } } + /* rename the files */ + for (i=0; move && i < numfiles; i++) { + sprintf(fname, "%s/file%06d", test_dir, i); + sprintf(fname2, "%s/link%06d", test_dir, i); + ret = rename(fname, fname2); + if (ret < 0) { + strcat(fname2, ": rename"); + perror(fname2); + return EXIT_FAILURE; + } + } + /* unlink the files */ for (i=0; delete && i < numfiles; i++) { sprintf(fname, "%s/file%06d", test_dir, i);