From patchwork Wed Apr 9 11:52:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 14044509 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BCE5E25DAE4; Wed, 9 Apr 2025 11:52:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744199551; cv=none; b=OfUb/Ru0k9/PaKe6g3MM3DVylGEoLkklPbDZF1cTog67LssEDjp8IFLkYOxEYmAebpTNYmouYFNSeds+Zk1Qj+88ou4oPSLMPQrkEyHwlZQtXyrzTYnDxlmYStuZFTgvyLJuYTg0+CxaBP8Md5tmFCO+Nmq6xdTbKUFOcC6C60U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744199551; c=relaxed/simple; bh=dOeazHLABsCF2y5mX8YLtqKavySHNwonGyUet03Aaps=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DjeBpxZp8I27V8aYlSrbh6hi4b9Dt3yUfBk1X88KAI25ScKbtT8PefQ945fC5hKNMNpuaghjEwuXoMppUUZ+B25s13sLBt1rHVOjN9rUuPfjjTKq+cEKaf3gGnfKOV6v4R7AfBgtpG8Uj8ywDk5vUWae/XKwpXPexyti1c+Jf0o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ls7oo23j; arc=none smtp.client-ip=209.85.221.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ls7oo23j" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-391342fc0b5so5209343f8f.3; Wed, 09 Apr 2025 04:52:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744199548; x=1744804348; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Gbnwx3UQ8HMr0aspq5T3L1ICouM+ZmHRZ1BZccKJ6NY=; b=ls7oo23jWY5pDaFWQ8isBFliClMKFZRyjW6OQo3g1Xfk5Ze2+6I2ciDZVQQibb2e4S NCQTJ4+GpqWipmCwgKZJ6f/ZRB09boeUfcpN2IEFv0+CJ2rYDwpTuWaAxvwYXR/VIc5v nSJLry/gjuR+VF4ZUU23Bn3oRbEYYqrCHFDSxXJx95OOFhK8Iqe6knkgHIdFmhKDB1gZ x4jwjp3g0QNE/7hgtPHO2PyrNLVXtFi/x/KQUMl/pU50h88WEw6Jc35YV2I6ZniWaOFP /9N6l2sTpRdEWPjF1zh1Sm0w2KJcx7pxC9jeDIEHywYTbjHBTqsQeddaZc2cWhCy58nF 0omA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744199548; x=1744804348; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Gbnwx3UQ8HMr0aspq5T3L1ICouM+ZmHRZ1BZccKJ6NY=; b=jDpFTlqEvVaj3iUdC0BZje7LRVMNm1wgFiPsNcHUgRSUABRySc+OaJ3mqNa8qM3YF4 tNeC1b91dpYOAro9zEZqDUqO1MANDC3iv3ZqoyltV5Y0hkxNnyqAjqoNMf1rzmm5fE7f VF73KqM9Oz1yOio/D2C7aY+1B1zB5TYoPViXBoUi0QVcoNTP5PovEE4vbzaSqfGsZUqS mNAkISWowjPnopZENxyXCns69gH82mZiC55AgQSwvKuWgXyyXNmJt9CFMXUNIsFEb4WJ VAjDbhqzHRkZQk+i1h9y1qmRLvOmknTTfH30x1Kg+QPzcjim4ywIZMi8s3iQWqCrAMgg RV9w== X-Forwarded-Encrypted: i=1; AJvYcCVaWiDkVKgZ01og8or1YZY/gpW+CmdaiyfSGZZHiLUHTRvfsPGZchoziguVokkegZwtUz9wkABM@vger.kernel.org, AJvYcCW0937P6vx/AN5X4bIyhOhOU9mNwbDQx0uVm8J+BHVtE2IbxHVj4I+PeYdOqfrv4Fy1nBaLH9H8aK9IwU2rPA==@vger.kernel.org X-Gm-Message-State: AOJu0Yxr39UBsq7CJhQLv14fWbWQe0sMK2Xiw1+M+MrzgfQZ0ms1S2WB etGbNq6HPZRTKoJiWhLTrupLR+RwGmYgGKmRe8DDDqAI5/3pXoxy X-Gm-Gg: ASbGncvP3j+cJgjxc2O+Abmvb34KuLD4dR/bP4pANBseFHS7v+55hFDTxCgqptoj9ru R6gis4gtE47gyuWM2SfUTqFbu2T8BQw5u+6t361b5HSMcu8+j2tilwVeVTMSidb4jvbhXUcW05i SH8OG3rlrXEfR1YRJD4Eog1v68AEVoIZHxAGUmC1sC+47lw1z4j8mxlgvOJhPivTWR2XCMVVWmF U4PjWjVgR9sRwuZrAyF/xwHxrbkl+Dd/cfoZPHjzE/2wdwQVCXrtjGN42rQccu7MPY+1HIy0YFQ KUCRNrMg1ZXGolctMZzeUee0PYgTOdSIKPcbJDl/qdnaK2lejfcljvrOTJZdMhMss98pJOUmknK GVq1fYjXihomyf4zKrZM+xmpy1ZSQEfB6OL6/rQ== X-Google-Smtp-Source: AGHT+IHlj8ykBwsaHbvQg8yy+TAy/VpDboqoHLrOBoozcZmz+hLx7mZC4Bk4uNM53ZExlwRxv3eH8A== X-Received: by 2002:a05:6000:4308:b0:38d:d666:5457 with SMTP id ffacd0b85a97d-39d88561926mr1909654f8f.42.1744199547544; Wed, 09 Apr 2025 04:52:27 -0700 (PDT) Received: from amir-ThinkPad-T480.arnhem.chello.nl (92-109-99-123.cable.dynamic.v4.ziggo.nl. [92.109.99.123]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43f2066d069sm17786815e9.17.2025.04.09.04.52.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Apr 2025 04:52:27 -0700 (PDT) From: Amir Goldstein To: Zorro Lang Cc: Aleksa Sarai , Christian Brauner , Jan Kara , Chuck Lever , Jeff Layton , fstests@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 1/2] open_by_handle: add support for testing connectable file handles Date: Wed, 9 Apr 2025 13:52:19 +0200 Message-Id: <20250409115220.1911467-2-amir73il@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250409115220.1911467-1-amir73il@gmail.com> References: <20250409115220.1911467-1-amir73il@gmail.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Test for kernel and filesystem support for conenctable file handles. With -N flag, encode connectable file handles and fail the test if the kernel or filesystem do not support conenctable file handles. Signed-off-by: Amir Goldstein --- common/rc | 16 +++++++++++++--- src/open_by_handle.c | 44 +++++++++++++++++++++++++++++++++++--------- 2 files changed, 48 insertions(+), 12 deletions(-) diff --git a/common/rc b/common/rc index 6592c835..6407b744 100644 --- a/common/rc +++ b/common/rc @@ -3829,8 +3829,14 @@ _require_freeze() } # Does NFS export work on this fs? -_require_exportfs() +_require_open_by_handle() { + local what="NFS export" + local opts="$1" + if [ "$1" == "-N" ]; then + what="connectable file handles" + fi + _require_test_program "open_by_handle" # virtiofs doesn't support open_by_handle_at(2) yet, though the syscall @@ -3841,10 +3847,14 @@ _require_exportfs() _notrun "$FSTYP doesn't support open_by_handle_at(2)" mkdir -p "$TEST_DIR"/exportfs_test - $here/src/open_by_handle -c "$TEST_DIR"/exportfs_test 2>&1 \ - || _notrun "$FSTYP does not support NFS export" + $here/src/open_by_handle $opts -c "$TEST_DIR"/exportfs_test 2>&1 \ + || _notrun "$FSTYP does not support $what" } +_require_exportfs() +{ + _require_open_by_handle +} # Does shutdown work on this fs? _require_scratch_shutdown() diff --git a/src/open_by_handle.c b/src/open_by_handle.c index a99cce4b..d281343a 100644 --- a/src/open_by_handle.c +++ b/src/open_by_handle.c @@ -96,6 +96,9 @@ Examples: #ifndef AT_HANDLE_MNT_ID_UNIQUE # define AT_HANDLE_MNT_ID_UNIQUE 0x001 #endif +#ifndef AT_HANDLE_CONNECTABLE +# define AT_HANDLE_CONNECTABLE 0x002 +#endif #define MAXFILES 1024 @@ -121,6 +124,7 @@ void usage(void) 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"); fprintf(stderr, "open_by_handle -M [N] - do not silently skip the mount ID verifications\n"); + fprintf(stderr, "open_by_handle -N [N] - encode connectable file handles\n"); fprintf(stderr, "open_by_handle -p - create/delete and try to open by handle also test_dir itself\n"); fprintf(stderr, "open_by_handle -i [N] - read test files handles from file and try to open by handle\n"); fprintf(stderr, "open_by_handle -o [N] - get file handles of test files and write handles to file\n"); @@ -130,14 +134,16 @@ void usage(void) fprintf(stderr, "open_by_handle -C - check if is supported by the kernel.\n"); fprintf(stderr, " can be any of the following values:\n"); fprintf(stderr, " - AT_HANDLE_MNT_ID_UNIQUE\n"); + fprintf(stderr, " - AT_HANDLE_CONNECTABLE\n"); exit(EXIT_FAILURE); } -static int do_name_to_handle_at(const char *fname, struct file_handle *fh, - int bufsz, bool force_check_mountid) +static int do_name_to_handle_at(const char *fname, struct file_handle *fh, int bufsz, + bool force_check_mountid, bool connectable) { int ret; int mntid_short; + int at_flags; static bool skip_mntid, skip_mntid_unique; @@ -181,18 +187,24 @@ static int do_name_to_handle_at(const char *fname, struct file_handle *fh, } } + at_flags = connectable ? AT_HANDLE_CONNECTABLE : 0; fh->handle_bytes = bufsz; - ret = name_to_handle_at(AT_FDCWD, fname, fh, &mntid_short, 0); + ret = name_to_handle_at(AT_FDCWD, fname, fh, &mntid_short, at_flags); if (bufsz < fh->handle_bytes) { /* Query the filesystem required bufsz and the file handle */ if (ret != -1 || errno != EOVERFLOW) { fprintf(stderr, "%s: unexpected result from name_to_handle_at: %d (%m)\n", fname, ret); return EXIT_FAILURE; } - ret = name_to_handle_at(AT_FDCWD, fname, fh, &mntid_short, 0); + ret = name_to_handle_at(AT_FDCWD, fname, fh, &mntid_short, at_flags); } if (ret < 0) { - fprintf(stderr, "%s: name_to_handle: %m\n", fname); + /* No filesystem support for encoding connectable file handles (e.g. overlayfs)? */ + if (connectable) + fprintf(stderr, "%s: name_to_handle_at(AT_HANDLE_CONNECTABLE) not supported by %s\n", + fname, errno == EINVAL ? "kernel" : "filesystem"); + else + fprintf(stderr, "%s: name_to_handle: %m\n", fname); return EXIT_FAILURE; } @@ -245,8 +257,17 @@ static int check_feature(const char *feature) return EXIT_FAILURE; } return 0; + } else if (!strcmp(feature, "AT_HANDLE_CONNECTABLE")) { + int ret = name_to_handle_at(AT_FDCWD, ".", NULL, NULL, AT_HANDLE_CONNECTABLE); + /* If AT_HANDLE_CONNECTABLE is supported, we get EFAULT. */ + if (ret < 0 && errno == EINVAL) { + fprintf(stderr, "name_to_handle_at(AT_HANDLE_CONNECTABLE) not supported by running kernel\n"); + return EXIT_FAILURE; + } + return 0; } + fprintf(stderr, "unknown feature name '%s'\n", feature); return EXIT_FAILURE; } @@ -270,13 +291,13 @@ int main(int argc, char **argv) int create = 0, delete = 0, nlink = 1, move = 0; int rd = 0, wr = 0, wrafter = 0, parent = 0; int keepopen = 0, drop_caches = 1, sleep_loop = 0; - int force_check_mountid = 0; + bool force_check_mountid = 0, connectable = 0; int bufsz = MAX_HANDLE_SZ; if (argc < 2) usage(); - while ((c = getopt(argc, argv, "cC:ludmMrwapknhi:o:sz")) != -1) { + while ((c = getopt(argc, argv, "cC:ludmMNrwapknhi:o:sz")) != -1) { switch (c) { case 'c': create = 1; @@ -313,6 +334,9 @@ int main(int argc, char **argv) case 'M': force_check_mountid = 1; break; + case 'N': + connectable = 1; + break; case 'p': parent = 1; break; @@ -445,7 +469,8 @@ int main(int argc, char **argv) return EXIT_FAILURE; } } else { - ret = do_name_to_handle_at(fname, &handle[i].fh, bufsz, force_check_mountid); + ret = do_name_to_handle_at(fname, &handle[i].fh, bufsz, + force_check_mountid, connectable); if (ret) return EXIT_FAILURE; } @@ -475,7 +500,8 @@ int main(int argc, char **argv) return EXIT_FAILURE; } } else { - ret = do_name_to_handle_at(test_dir, &dir_handle.fh, bufsz, force_check_mountid); + ret = do_name_to_handle_at(test_dir, &dir_handle.fh, bufsz, + force_check_mountid, connectable); if (ret) return EXIT_FAILURE; } From patchwork Wed Apr 9 11:52:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 14044510 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A0962253E4; Wed, 9 Apr 2025 11:52:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744199552; cv=none; b=qS5kYeWA1zDQCYM3ALG0u35igNWluDR0ZgjlNEQULLXqJQ1073OTXEFH/5cNtqzmP1irFVWj/qbLa6ODXtqnN5bdXSGDQk92fCKAuv5RsdKKwVqOjnm5znD1ub6EO7LJnc5JPjRMaMfFL40ebjNmGleX3eegfkpOR/ix/+CkjlA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744199552; c=relaxed/simple; bh=ygESd33qiScuVxyChUjjAcLNy4/vLGhH1b5w55FaXKM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hJ9K7rVPF3I/bFko6yiqndLEOw4nt1+sQnyvzsBp4FBTktAKBFUKasxZotbCvbiBqRWrtKag3oN2ZnoIdz3eu9z4A/Ji1Rk12W8/BqrrNjkSQ++2hi0iTt2/Io2BqRL8QzZzWQtytaC0Ok7aXx/vSwu2+M+Nj30Xze08izy4cDs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=AXHtTxZZ; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AXHtTxZZ" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-43d04dc73b7so70160885e9.3; Wed, 09 Apr 2025 04:52:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744199548; x=1744804348; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=g6wjh/nu+r2sCU54t8zingNxQ096FNrWAeu6JbBkdb0=; b=AXHtTxZZKvzcsTh5t2x4sytkNR688TaiqepmaQPCAzzo2OY4pMDSYv+wJ/tl/f3SWV //0+vhxy0lBdjIJiP79LlwWCr+ZJM2uuLXDbTUmpFZvuc4pPsOdlhcTruKY1INtTZgd1 BKq6/vm67RJkc9SBEMJ4nJUiYAEappJkONk2+Y9H9WZJBmNJxetVwADkSE+O2/2ipJV5 dIHLLe/66Zz4sRhtaRd4kydGeqKKoH6ffcrQM0czYqC+MdCgiHsI90UQB6ayY6zsjtZC QhUT82T2NpEZBsahagKIXwnFr4fF5XlPuFpUR5mRBw6LJjMylY8YVwZH3VzQwnkav96N /7jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744199548; x=1744804348; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=g6wjh/nu+r2sCU54t8zingNxQ096FNrWAeu6JbBkdb0=; b=KWWQQZFEjBI5ra+uvGoJB/bS1HF7ZCqko40vVzOV+qoIYLfstGD8E9UrhjTwJTQViN gN4lEnj/FatX/gBh5wqWjkEnT4ryeJ5JC5TK6hYihUqVQK8ifk08Q8Ep/SCQFIslKcka TNfGgdcDJXo/Zu5vnoQKz7MtU8lG02fgcsfPrMAE/6Ci4Op79s7i5T2K83Yx6WaRFuA7 Oa6xjrSwI5nLgKLGKHI3JDeKj8FdTdFb071vo6nYtXmCKm0m/DHIhCBN/N7k2KJWeB/P mgAmB58nU9LckfLvaQKWO08E/Jq2HZyOcLUIjZY5prKQXQ9gnebVoL7hfIGQv3zAPGES B13Q== X-Forwarded-Encrypted: i=1; AJvYcCVO8Ux7NCzWikcRBP/HRcbo+cL84P8DjE2V4nGFOt/wLsZVK88wvcFoqcLHIzd1xoMsLvcnyXa3@vger.kernel.org, AJvYcCWRIcS3yJqzUHqtg8MivH0DJo9/uyODVyP+Mrkp8wwaRjRzZ1Xk0OwRgccDqzaNvzparE1NkdklXciYM4YO0g==@vger.kernel.org X-Gm-Message-State: AOJu0YxlGz5ahb0hdOWTIwivzrlu4u4y71BMtS1oX7+fv+rcpumdE9Zw zaw2v7LMajwKgb8YUQXnDQIs0qrekG1/MN/F6yG09dyB4aBqV8HKdpXUvlLd X-Gm-Gg: ASbGncvkh45gFR3oFhWF45OqQcLry3I/7H50joSf82sswU7wVoOKKQ7HbuXsWUxkFnX buIqItowiXr1v0x1RD1oiDDdTH87CY7pokTqLKra0sVqKCXqv7mjBIXE06PO1vlCFxDUJVfeTr3 kjzsTNj49p6HHbDI9XHSl2UlkXt6LN3EVrIRt0mTisJqa2MUoQ8qC3K7QDSX59yoF2sZljCLbu5 AAyG99uu3J4vg/V9xY1P3bsJHwKi0/FOdldvVN7WNZQsafVaostUd/mDQp0AOI8eCMIIYO8b2BR TVhSZ5G7VffvOxc+rkP4iQwxe71SsqQvpZo3KMTRrM59k2vEN2o+2daOdPTLGSletMl10oKr5n/ toYJl+WjAMpYk1Ln0Z/ykyt9lclUeUTK5LoSejw== X-Google-Smtp-Source: AGHT+IE9kXa0WUnlU2syJlD9y6uKfF//w/hH5pkZrL3sJhouEV7EQDgCKxx2sPCYfH2HN919PpRGsA== X-Received: by 2002:a05:600c:5787:b0:43c:f5fe:5c26 with SMTP id 5b1f17b1804b1-43f1eda3d63mr18257915e9.4.1744199548344; Wed, 09 Apr 2025 04:52:28 -0700 (PDT) Received: from amir-ThinkPad-T480.arnhem.chello.nl (92-109-99-123.cable.dynamic.v4.ziggo.nl. [92.109.99.123]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43f2066d069sm17786815e9.17.2025.04.09.04.52.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Apr 2025 04:52:27 -0700 (PDT) From: Amir Goldstein To: Zorro Lang Cc: Aleksa Sarai , Christian Brauner , Jan Kara , Chuck Lever , Jeff Layton , fstests@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 2/2] open_by_handle: add a test for connectable file handles Date: Wed, 9 Apr 2025 13:52:20 +0200 Message-Id: <20250409115220.1911467-3-amir73il@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250409115220.1911467-1-amir73il@gmail.com> References: <20250409115220.1911467-1-amir73il@gmail.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This is a variant of generic/477 with connectable file handles. This test uses load and store of file handles from a temp file to test decoding connectable file handles after cycle mount and after renames. Decoding connectable file handles after being moved to a new parent is expected to fail. Signed-off-by: Amir Goldstein --- tests/generic/777 | 79 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/777.out | 15 ++++++++ 2 files changed, 94 insertions(+) create mode 100755 tests/generic/777 create mode 100644 tests/generic/777.out diff --git a/tests/generic/777 b/tests/generic/777 new file mode 100755 index 00000000..52a461c3 --- /dev/null +++ b/tests/generic/777 @@ -0,0 +1,79 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2018-2025 CTERA Networks. All Rights Reserved. +# +# FS QA Test No. 777 +# +# Check open by connectable file handle after cycle mount. +# +# This is a variant of test 477 with connectable file handles. +# This test uses load and store of file handles from a temp file to test +# decoding file handles after cycle mount and after directory renames. +# Decoding connectable file handles after being moved to a new parent +# is expected to fail. +# +. ./common/preamble +_begin_fstest auto quick exportfs + +# Import common functions. +. ./common/filter + + +# Modify as appropriate. +_require_test +# Require connectable file handles support +_require_open_by_handle -N + +NUMFILES=10 +testroot=$TEST_DIR/$seq-dir +testdir=$testroot/testdir + +# Create test dir and test files, encode connectable file handles and store to tmp file +create_test_files() +{ + rm -rf $testdir + mkdir -p $testdir + $here/src/open_by_handle -N -cwp -o $tmp.handles_file $testdir $NUMFILES +} + +# Decode connectable file handles loaded from tmp file +test_file_handles() +{ + local opt=$1 + local when=$2 + + echo test_file_handles after $when + $here/src/open_by_handle $opt -i $tmp.handles_file $TEST_DIR $NUMFILES +} + +# Decode file handles of files/dir after cycle mount +create_test_files +_test_cycle_mount +test_file_handles -rp "cycle mount" + +# Decode file handles of files/dir after rename of parent and cycle mount +create_test_files $testdir +rm -rf $testdir.renamed +mv $testdir $testdir.renamed/ +_test_cycle_mount +test_file_handles -rp "rename parent" + +# Decode file handles of files/dir after rename of grandparent and cycle mount +create_test_files $testdir +rm -rf $testroot.renamed +mv $testroot $testroot.renamed/ +_test_cycle_mount +test_file_handles -rp "rename grandparent" + +# Decode file handles of files/dir after move to new parent and cycle mount +# This is expected to fail because the conectable file handle encodes the +# old parent. +create_test_files $testdir +rm -rf $testdir.new +mkdir -p $testdir.new +mv $testdir/* $testdir.new/ +_test_cycle_mount +test_file_handles -r "move to new parent" | _filter_test_dir + +status=0 +exit diff --git a/tests/generic/777.out b/tests/generic/777.out new file mode 100644 index 00000000..648c480c --- /dev/null +++ b/tests/generic/777.out @@ -0,0 +1,15 @@ +QA output created by 777 +test_file_handles after cycle mount +test_file_handles after rename parent +test_file_handles after rename grandparent +test_file_handles after move to new parent +open_by_handle(TEST_DIR/file000000) returned 116 incorrectly on a linked file! +open_by_handle(TEST_DIR/file000001) returned 116 incorrectly on a linked file! +open_by_handle(TEST_DIR/file000002) returned 116 incorrectly on a linked file! +open_by_handle(TEST_DIR/file000003) returned 116 incorrectly on a linked file! +open_by_handle(TEST_DIR/file000004) returned 116 incorrectly on a linked file! +open_by_handle(TEST_DIR/file000005) returned 116 incorrectly on a linked file! +open_by_handle(TEST_DIR/file000006) returned 116 incorrectly on a linked file! +open_by_handle(TEST_DIR/file000007) returned 116 incorrectly on a linked file! +open_by_handle(TEST_DIR/file000008) returned 116 incorrectly on a linked file! +open_by_handle(TEST_DIR/file000009) returned 116 incorrectly on a linked file!