From nobody Mon Feb 9 05:59:46 2026 Received: from mail-ot1-f47.google.com (mail-ot1-f47.google.com [209.85.210.47]) (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 6D7FF3A0B33 for ; Wed, 14 Jan 2026 21:46:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768427220; cv=none; b=YwAqFHCqO3x7CvJAW8rWI9LBB0YBte8PpYLIqMk7CGjwSbV7EvhAH9T7CzTfo9lNLsQSqIGske0xw2FaI6OFNGlBIk/esCttqDZWZK3KIH+z4Sd2Jx+9fTxQvRfYXo83KMuktkejZkH2I5CDeXyW/lo9MuOOQ3mJaa/Yu9QHHNo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768427220; c=relaxed/simple; bh=UH7UVmm/ifZMz2a7ctzEVAj9QL1YqJfv9TEsJAmqvl0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t7tm8PwlfTor+FLdes50WuGeXm7T7cjhxNisfR+xamCR6RRFkl+DFsrsEyY9ZZqeOXYtUgpHUTrtQ/wu2As5si22+xEa61iWXKYFNoMfhcpwj3ZRSSnc7pZ78GY23qo1xJDCaqQ65jSKMYjUTwqKv/Nu3O0pD6pMjy0bI+xkDU4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=Groves.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=U1x22Y2N; arc=none smtp.client-ip=209.85.210.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=Groves.net 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="U1x22Y2N" Received: by mail-ot1-f47.google.com with SMTP id 46e09a7af769-7cdf7529bb2so174988a34.2 for ; Wed, 14 Jan 2026 13:46:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768427188; x=1769031988; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=ezmCIUYTCpc47N9MRFviC1UdzpKfkRUPsUPtXb573Uk=; b=U1x22Y2NCadasD+0/b0bPw8Jn26D+SpJIsuZ4rfvGJuun0FUtpy0yEVTNC3SEZP49O kQVrOW6VEUFevmJ8Tfwfloc26DmUxyJoZ481dP5SY8Vnr0yaGCBUcA9VTM7MT7dob2CR oiiiZipKAFt6EypCdSmvuGhN7YU6+rNC/Omt2OxUb6Bpqs/brbeXxwniyW2pSoKXlr1j 5Nmyyb9fjC0sh1XqduP4U+K+mNhMYvlCQ/YkkA6Ud9AjV5bJHdFrgw5fg/85+1DcnwsH sECOWV2MlG2C9LRm5loBKJOi81lh/7zVpq8T+4On6fvrdPc3x9pbcjsq464wKeTHGJhD hpWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768427188; x=1769031988; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ezmCIUYTCpc47N9MRFviC1UdzpKfkRUPsUPtXb573Uk=; b=n0Gfx80qrI5MgVbnWTgY+3rcLPnuwVQ5YibQxHePKP9sBw8k8mfn0Dan5N5bpr315l nA1OHsf5J5IOpGPFMOLV0YdHlHxb3mW1yZrypJdceKrI71amnPBw2wCgl1uQS+ofUPvB 3ckTeUsvRwYrTqPhJpSirWheXmWHHgHpo40HGP84iQD5MgRJ3bPUoc7sbWp/+yfmGi4I vEFcAInMQKNg+7v6uTTajwSnfx7xIo5vi9QoGO7CMIcVw1XG0xK1cUOqaGY1j6eErd3X iRwOf5rC8mpogd349hkUeMRw0WE1X1SzliP+eTCyOdRV8wZbeUxdn4mbM7pAc5TFJRMH Q4lQ== X-Forwarded-Encrypted: i=1; AJvYcCUatklgyDfaK8GazQ1NL9qreN9S3XW/lKUxUeIamavWKnD8/Hyd5RuMOLebT0DGVQydNbVzN1KlkeyPcgg=@vger.kernel.org X-Gm-Message-State: AOJu0YyPDJMGlFG9pz+mGxHIXCxIrh2GiOBHYkTDHwXSAeCzU7y109OA xEiqY5TE0C+1uEDM0QNPrIRQLjVSDWcbPKDoGPKlI4DqWhKLjOXEmLWN X-Gm-Gg: AY/fxX6/+0yZbJspNjSEtBkBgay3FerFHZK4grrSzr7VriLKgXju4YEBNtXCcDTMPff xejZ4PCUthyfh4Eaq1nWkxdNxSkaSP5uFz/jUGmpoTRWu9toaGNM1Vv7V57VRgcu/ke5SIBGvjg SfAK+jUFEApDwgyWEgdTWiMyrSniqhdOZY+gxkcemlhqyobploM1v52WTlzyu+kwAo79Qqr7axd hLILylN86Px4YakQZirbhT/kdGrewLWCP/WdZUzCVQ1XxInQ3/Ixvq1CFrLhj0aXX7Z3DfbvUbk x5rzSo+iyZExd6IOhwSFR5V3hlJG6YDGPG4Ls2j1rAOD9lADGUuNSYRquUYBe34vTY15B/nNIyR bchBL2cyhFWzL6EKUSWmKtogC842uk2kqDzAZcKku7s+HHrZWM06jcqXApQjtvaZyjQnukKCb43 ETpWgi9wI1cSG3c2Olxc7SpLI1tXbNcZWGHbzP9o7RCcSG X-Received: by 2002:a05:6830:2541:b0:7cf:cc11:f7cc with SMTP id 46e09a7af769-7cfcc11f982mr2409830a34.36.1768427188084; Wed, 14 Jan 2026 13:46:28 -0800 (PST) Received: from localhost.localdomain ([2603:8080:1500:3d89:4c85:2962:e438:72c4]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7cfc3692f3asm3936197a34.10.2026.01.14.13.46.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 14 Jan 2026 13:46:27 -0800 (PST) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Miklos Szeredi , Dan Williams , Bernd Schubert , Alison Schofield Cc: John Groves , Jonathan Corbet , Vishal Verma , Dave Jiang , Matthew Wilcox , Jan Kara , Alexander Viro , David Hildenbrand , Christian Brauner , "Darrick J . Wong" , Randy Dunlap , Jeff Layton , Amir Goldstein , Jonathan Cameron , Stefan Hajnoczi , Joanne Koong , Josef Bacik , Bagas Sanjaya , James Morse , Fuad Tabba , Sean Christopherson , Shivank Garg , Ackerley Tng , Gregory Price , Aravind Ramesh , Ajay Joshi , venkataravis@micron.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH V2 2/2] Add test/daxctl-famfs.sh to test famfs mode transitions: Date: Wed, 14 Jan 2026 15:45:19 -0600 Message-ID: <20260114214519.29999-3-john@groves.net> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260114214519.29999-1-john@groves.net> References: <20260114153133.29420.compound@groves.net> <20260114214519.29999-1-john@groves.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: John Groves - devdax <-> famfs mode switches - Verify famfs -> system-ram is rejected (must go via devdax) - Test JSON output shows correct mode - Test error handling for invalid modes The test is added to the destructive test suite since it modifies device modes. Signed-off-by: John Groves --- test/daxctl-famfs.sh | 253 +++++++++++++++++++++++++++++++++++++++++++ test/meson.build | 2 + 2 files changed, 255 insertions(+) create mode 100755 test/daxctl-famfs.sh diff --git a/test/daxctl-famfs.sh b/test/daxctl-famfs.sh new file mode 100755 index 0000000..12fbfef --- /dev/null +++ b/test/daxctl-famfs.sh @@ -0,0 +1,253 @@ +#!/bin/bash -Ex +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2025 Micron Technology, Inc. All rights reserved. +# +# Test daxctl famfs mode transitions and mode detection + +rc=3D77 +. $(dirname $0)/common + +trap 'cleanup $LINENO' ERR + +daxdev=3D"" +original_mode=3D"" + +cleanup() +{ + printf "Error at line %d\n" "$1" + # Try to restore to original mode if we know it + if [[ $daxdev && $original_mode ]]; then + "$DAXCTL" reconfigure-device -f -m "$original_mode" "$daxdev" 2>/dev/nul= l || true + fi + exit $rc +} + +# Check if fsdev_dax module is available +check_fsdev_dax() +{ + if modinfo fsdev_dax &>/dev/null; then + return 0 + fi + if grep -qF "fsdev_dax" "/lib/modules/$(uname -r)/modules.builtin" 2>/dev= /null; then + return 0 + fi + printf "fsdev_dax module not available, skipping\n" + exit 77 +} + +# Check if kmem module is available (needed for system-ram mode tests) +check_kmem() +{ + if modinfo kmem &>/dev/null; then + return 0 + fi + if grep -qF "kmem" "/lib/modules/$(uname -r)/modules.builtin" 2>/dev/null= ; then + return 0 + fi + printf "kmem module not available, skipping system-ram tests\n" + return 1 +} + +# Find an existing dax device to test with +find_daxdev() +{ + # Look for any available dax device + daxdev=3D$("$DAXCTL" list | jq -er '.[0].chardev // empty' 2>/dev/null) |= | true + + if [[ ! $daxdev ]]; then + printf "No dax device found, skipping\n" + exit 77 + fi + + # Save the original mode so we can restore it + original_mode=3D$("$DAXCTL" list -d "$daxdev" | jq -er '.[].mode') + + printf "Found dax device: %s (current mode: %s)\n" "$daxdev" "$original_m= ode" +} + +daxctl_get_mode() +{ + "$DAXCTL" list -d "$1" | jq -er '.[].mode' +} + +# Ensure device is in devdax mode for testing +ensure_devdax_mode() +{ + local mode + mode=3D$(daxctl_get_mode "$daxdev") + + if [[ "$mode" =3D=3D "devdax" ]]; then + return 0 + fi + + if [[ "$mode" =3D=3D "system-ram" ]]; then + printf "Device is in system-ram mode, attempting to convert to devdax...= \n" + "$DAXCTL" reconfigure-device -f -m devdax "$daxdev" + elif [[ "$mode" =3D=3D "famfs" ]]; then + printf "Device is in famfs mode, converting to devdax...\n" + "$DAXCTL" reconfigure-device -m devdax "$daxdev" + else + printf "Device is in unknown mode: %s\n" "$mode" + return 1 + fi + + [[ $(daxctl_get_mode "$daxdev") =3D=3D "devdax" ]] +} + +# +# Test basic mode transitions involving famfs +# +test_famfs_mode_transitions() +{ + printf "\n=3D=3D=3D Testing famfs mode transitions =3D=3D=3D\n" + + # Ensure starting in devdax mode + ensure_devdax_mode + [[ $(daxctl_get_mode "$daxdev") =3D=3D "devdax" ]] + printf "Initial mode: devdax - OK\n" + + # Test: devdax -> famfs + printf "Testing devdax -> famfs... " + "$DAXCTL" reconfigure-device -m famfs "$daxdev" + [[ $(daxctl_get_mode "$daxdev") =3D=3D "famfs" ]] + printf "OK\n" + + # Test: famfs -> famfs (re-enable in same mode) + printf "Testing famfs -> famfs (re-enable)... " + "$DAXCTL" reconfigure-device -m famfs "$daxdev" + [[ $(daxctl_get_mode "$daxdev") =3D=3D "famfs" ]] + printf "OK\n" + + # Test: famfs -> devdax + printf "Testing famfs -> devdax... " + "$DAXCTL" reconfigure-device -m devdax "$daxdev" + [[ $(daxctl_get_mode "$daxdev") =3D=3D "devdax" ]] + printf "OK\n" + + # Test: devdax -> devdax (re-enable in same mode) + printf "Testing devdax -> devdax (re-enable)... " + "$DAXCTL" reconfigure-device -m devdax "$daxdev" + [[ $(daxctl_get_mode "$daxdev") =3D=3D "devdax" ]] + printf "OK\n" +} + +# +# Test mode transitions with system-ram (requires kmem) +# +test_system_ram_transitions() +{ + printf "\n=3D=3D=3D Testing system-ram transitions with famfs =3D=3D=3D\n" + + # Ensure we start in devdax mode + ensure_devdax_mode + [[ $(daxctl_get_mode "$daxdev") =3D=3D "devdax" ]] + + # Test: devdax -> system-ram + printf "Testing devdax -> system-ram... " + "$DAXCTL" reconfigure-device -N -m system-ram "$daxdev" + [[ $(daxctl_get_mode "$daxdev") =3D=3D "system-ram" ]] + printf "OK\n" + + # Test: system-ram -> famfs should fail + printf "Testing system-ram -> famfs (should fail)... " + if "$DAXCTL" reconfigure-device -m famfs "$daxdev" 2>/dev/null; then + printf "FAILED - should have been rejected\n" + return 1 + fi + printf "OK (correctly rejected)\n" + + # Test: system-ram -> devdax -> famfs (proper path) + printf "Testing system-ram -> devdax -> famfs... " + "$DAXCTL" reconfigure-device -f -m devdax "$daxdev" + [[ $(daxctl_get_mode "$daxdev") =3D=3D "devdax" ]] + "$DAXCTL" reconfigure-device -m famfs "$daxdev" + [[ $(daxctl_get_mode "$daxdev") =3D=3D "famfs" ]] + printf "OK\n" + + # Restore to devdax for subsequent tests + "$DAXCTL" reconfigure-device -m devdax "$daxdev" +} + +# +# Test JSON output shows correct mode +# +test_json_output() +{ + printf "\n=3D=3D=3D Testing JSON output for mode field =3D=3D=3D\n" + + # Test devdax mode in JSON + ensure_devdax_mode + printf "Testing JSON output for devdax mode... " + mode=3D$("$DAXCTL" list -d "$daxdev" | jq -er '.[].mode') + [[ "$mode" =3D=3D "devdax" ]] + printf "OK\n" + + # Test famfs mode in JSON + "$DAXCTL" reconfigure-device -m famfs "$daxdev" + printf "Testing JSON output for famfs mode... " + mode=3D$("$DAXCTL" list -d "$daxdev" | jq -er '.[].mode') + [[ "$mode" =3D=3D "famfs" ]] + printf "OK\n" + + # Restore to devdax + "$DAXCTL" reconfigure-device -m devdax "$daxdev" +} + +# +# Test error messages for invalid transitions +# +test_error_handling() +{ + printf "\n=3D=3D=3D Testing error handling =3D=3D=3D\n" + + # Ensure we're in famfs mode + "$DAXCTL" reconfigure-device -m famfs "$daxdev" + + # Test that invalid mode is rejected + printf "Testing invalid mode rejection... " + if "$DAXCTL" reconfigure-device -m invalidmode "$daxdev" 2>/dev/null; then + printf "FAILED - invalid mode should be rejected\n" + return 1 + fi + printf "OK (correctly rejected)\n" + + # Restore to devdax + "$DAXCTL" reconfigure-device -m devdax "$daxdev" +} + +# +# Main test sequence +# +main() +{ + check_fsdev_dax + find_daxdev + + rc=3D1 # From here on, failures are real failures + + test_famfs_mode_transitions + test_json_output + test_error_handling + + # System-ram tests require kmem module + if check_kmem; then + # Save and disable online policy for system-ram tests + saved_policy=3D"$(cat /sys/devices/system/memory/auto_online_blocks)" + echo "offline" > /sys/devices/system/memory/auto_online_blocks + + test_system_ram_transitions + + # Restore online policy + echo "$saved_policy" > /sys/devices/system/memory/auto_online_blocks + fi + + # Restore original mode + printf "\nRestoring device to original mode: %s\n" "$original_mode" + "$DAXCTL" reconfigure-device -f -m "$original_mode" "$daxdev" + + printf "\n=3D=3D=3D All famfs tests passed =3D=3D=3D\n" + + exit 0 +} + +main diff --git a/test/meson.build b/test/meson.build index 615376e..ad1d393 100644 --- a/test/meson.build +++ b/test/meson.build @@ -209,6 +209,7 @@ if get_option('destructive').enabled() device_dax_fio =3D find_program('device-dax-fio.sh') daxctl_devices =3D find_program('daxctl-devices.sh') daxctl_create =3D find_program('daxctl-create.sh') + daxctl_famfs =3D find_program('daxctl-famfs.sh') dm =3D find_program('dm.sh') mmap_test =3D find_program('mmap.sh') =20 @@ -226,6 +227,7 @@ if get_option('destructive').enabled() [ 'device-dax-fio.sh', device_dax_fio, 'dax' ], [ 'daxctl-devices.sh', daxctl_devices, 'dax' ], [ 'daxctl-create.sh', daxctl_create, 'dax' ], + [ 'daxctl-famfs.sh', daxctl_famfs, 'dax' ], [ 'dm.sh', dm, 'dax' ], [ 'mmap.sh', mmap_test, 'dax' ], ] --=20 2.49.0