From nobody Sat Feb 7 12:35:05 2026 Received: from mail-oi1-f172.google.com (mail-oi1-f172.google.com [209.85.167.172]) (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 66677399025 for ; Wed, 7 Jan 2026 15:35:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767800111; cv=none; b=XncfBkh2zuWXaBJD3KOY3aCYoEYVEnRiTK18BAPArkF+UgStln5Ob7ThPneY1LiLRe97Ua13YlNSqRnAYUkozt2lDbhS/As5kTkUqXHLyo3g8MAElH2rRPD9N9GY3dM0NAgoYvUbps+NakC+nnVAFUwPK3qUtvXawk0moRlYy/s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767800111; c=relaxed/simple; bh=r9IqegKKXF0hOodqnrc7EmAalu0NN7c//lGhFFS/Wr4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=g1QeY7EEWeV8+mDQVu8uaPRCx/y6OCu3/qVcZo4NpysX1EIJIY17c9WVJ2twCMPf7O3z7+isDIXhwvLMMpoqboBUb8zoZ8a/pjdxavPxaLyAbtkBvPC5J8/pSSAUG6Q3YqPNrEFm3txUwxDFAMezTutaq/2cElOAFuAy1jjEcZA= 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=H3TdIF7d; arc=none smtp.client-ip=209.85.167.172 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="H3TdIF7d" Received: by mail-oi1-f172.google.com with SMTP id 5614622812f47-450b2715b6cso1325211b6e.0 for ; Wed, 07 Jan 2026 07:35:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767800107; x=1768404907; 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=dJ1yqTOSIYfzgCIPomxp4mh5lXIFW6Vqr0XKillgvQc=; b=H3TdIF7d/5+LEF1QIFQ7iujVmgDwfVacrRcyO5bHe/pXkovi8WtVwSuSwKqbzjJCgJ 8CvHJZm/A/D+7DeBfhvfY8es5GdZcg/M4VWkQs+3JllRmJRF7fIhLFN1EHh1lFNP5/x/ GhNM4ROwGb7Mef0zmfw+NHlcEHkJoyt80EmbavTOTm7QGhNn9Vq4739kX4PcpSrcKCgK xDZwsPmISvAn6G1oa7aSWiJvd2IqMuaXv821IGmsMV9AZ+8Py/3MIVJSdC9uEO0WsBVZ 7SuhaM/4wwf4AgwFxO/IeNPSuYuG6n8HHxzxC9WI6v3yZQpF23gYqvHuC5ftLMu6ZVIC BDIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767800107; x=1768404907; 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=dJ1yqTOSIYfzgCIPomxp4mh5lXIFW6Vqr0XKillgvQc=; b=h0lonl4UyLfOr49gZ/PsQ1RaycKVTwz5oyiRSulyK1SnNXm0KUTQrtNJUCnUqGcfDJ fqSpYcxy1PQZ6/SXUcvA9ScsLtbkhfKJZ0H7iLmNprZal8N7FscdQY3CAegKyPXhwqtH T+V+l0+tG7kiuL+NvBRsjRWlz4RbSM9ASaBl29w1lrl5/+tcCptn6iB1Kg9evzdSUmdE y/oBVXmEYPFPEgsKJPNVO6ulWSOIOBe+5MYs9DNKXtLiOcMzHOB7Rp/MTJOkV8uZRtVs 1C+wAEBeCLLhNIgbzfz44TyoP1dxyLn2ZPe+ARM4Rl7kyTWtLZA+AGbkmnqLjhIVh4Vq p3ug== X-Forwarded-Encrypted: i=1; AJvYcCVgDko91+yeB5jtIw598YvV8pnXMdXLdkd1/0NvqV+Q51cavQcFFtRfvOSkuYufAEow8jCNLbSnuIGMBhE=@vger.kernel.org X-Gm-Message-State: AOJu0YwCEyC7foJJgQ36CBZxEAsKyIH0lgt1F9cbF5BTqmAnOOjARAtl uKozRXbJC9efI+GxejMyKhsjpGR4NPZaDgwkw5T/UkmoVJz4baiy44a4 X-Gm-Gg: AY/fxX4xBhxa9gPkZj7cDqk4QwAM4TCcqUUu6vBw1w7BCAYFlRYN/FzVRYxXQr5uC5b 91aplEq0aWr2cxObb++BDf/2tNZCikanv4erW08Wjl02e1+UD+IQytQ1ro44Il/YQVRpYN8BW1C 1356BZH7DdMXhmisErgMkcF9yNbsN0N+1dxfBgkaJe1Z96/V+OeskEcCMxQhoQqoPUlDnnHveEC aGCWpk5Gv4W4mcCXnZotPX+WE5NiNuz8Po3Dz1QdjmJ0km4NlTII5AXXU3gd5N1dlOoNiAvvB1j K8OzBdq0aIro8iecWlWxW1Hn3nPiGCwT5GAEAsfI5d2mxrcrcSD85UGMsrbj/fXLLP28mpUURYf XXmxF/QVbgwjZ7X89rFynqlrjsM7oLUr8C+AmHfRPLiFXIXsJdoaEphEZ3oO3N8Yp4A9JtZ3ykp Te+ht09sZeJ8zHFGoUq5QaKzNnGQXENy7ew+r8fZ3k1gFI X-Google-Smtp-Source: AGHT+IFhZzTBYXOyULopr/miqFWcFwpZ56BKeqT24Ye9+avl9LSKcVCkPXTacK24wfwEckn/JSxlfA== X-Received: by 2002:a05:6808:f94:b0:453:797b:79d1 with SMTP id 5614622812f47-45a6bee7f78mr1417557b6e.33.1767800107198; Wed, 07 Jan 2026 07:35:07 -0800 (PST) Received: from localhost.localdomain ([2603:8080:1500:3d89:a917:5124:7300:7cef]) by smtp.gmail.com with ESMTPSA id 5614622812f47-45a5e183cd4sm2415499b6e.1.2026.01.07.07.35.05 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 07 Jan 2026 07:35:06 -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 , Chen Linxuan , 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, John Groves Subject: [PATCH 1/2] daxctl: Add support for famfs mode Date: Wed, 7 Jan 2026 09:34:58 -0600 Message-ID: <20260107153459.64821-2-john@groves.net> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260107153459.64821-1-john@groves.net> References: <20260107153244.64703-1-john@groves.net> <20260107153459.64821-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 Putting a daxdev in famfs mode means binding it to fsdev_dax.ko (drivers/dax/fsdev.c). Finding a daxdev bound to fsdev_dax means it is in famfs mode. The test is added to the destructive test suite since it modifies device modes. With devdax, famfs, and system-ram modes, the previous logic that assumed 'not in mode X means in mode Y' needed to get slightly more complicated Add explicit mode detection functions: - daxctl_dev_is_famfs_mode(): check if bound to fsdev_dax driver - daxctl_dev_is_devdax_mode(): check if bound to device_dax driver Fix mode transition logic in device.c: - disable_devdax_device(): verify device is actually in devdax mode - disable_famfs_device(): verify device is actually in famfs mode - All reconfig_mode_*() functions now explicitly check each mode - Handle unknown mode with error instead of wrong assumption Modify json.c to show 'unknown' if device is not in a recognized mode. Signed-off-by: John Groves --- daxctl/device.c | 126 ++++++++++++++++++++++++++++++--- daxctl/json.c | 6 +- daxctl/lib/libdaxctl-private.h | 2 + daxctl/lib/libdaxctl.c | 77 ++++++++++++++++++++ daxctl/lib/libdaxctl.sym | 7 ++ daxctl/libdaxctl.h | 3 + 6 files changed, 210 insertions(+), 11 deletions(-) diff --git a/daxctl/device.c b/daxctl/device.c index e3993b1..14e1796 100644 --- a/daxctl/device.c +++ b/daxctl/device.c @@ -42,6 +42,7 @@ enum dev_mode { DAXCTL_DEV_MODE_UNKNOWN, DAXCTL_DEV_MODE_DEVDAX, DAXCTL_DEV_MODE_RAM, + DAXCTL_DEV_MODE_FAMFS, }; =20 struct mapping { @@ -471,6 +472,13 @@ static const char *parse_device_options(int argc, cons= t char **argv, "--no-online is incompatible with --mode=3Ddevdax\n"); rc =3D -EINVAL; } + } else if (strcmp(param.mode, "famfs") =3D=3D 0) { + reconfig_mode =3D DAXCTL_DEV_MODE_FAMFS; + if (param.no_online) { + fprintf(stderr, + "--no-online is incompatible with --mode=3Dfamfs\n"); + rc =3D -EINVAL; + } } break; case ACTION_CREATE: @@ -696,8 +704,42 @@ static int disable_devdax_device(struct daxctl_dev *de= v) int rc; =20 if (mem) { - fprintf(stderr, "%s was already in system-ram mode\n", - devname); + fprintf(stderr, "%s is in system-ram mode\n", devname); + return 1; + } + if (daxctl_dev_is_famfs_mode(dev)) { + fprintf(stderr, "%s is in famfs mode\n", devname); + return 1; + } + if (!daxctl_dev_is_devdax_mode(dev)) { + fprintf(stderr, "%s is not in devdax mode\n", devname); + return 1; + } + rc =3D daxctl_dev_disable(dev); + if (rc) { + fprintf(stderr, "%s: disable failed: %s\n", + daxctl_dev_get_devname(dev), strerror(-rc)); + return rc; + } + return 0; +} + +static int disable_famfs_device(struct daxctl_dev *dev) +{ + struct daxctl_memory *mem =3D daxctl_dev_get_memory(dev); + const char *devname =3D daxctl_dev_get_devname(dev); + int rc; + + if (mem) { + fprintf(stderr, "%s is in system-ram mode\n", devname); + return 1; + } + if (daxctl_dev_is_devdax_mode(dev)) { + fprintf(stderr, "%s is in devdax mode\n", devname); + return 1; + } + if (!daxctl_dev_is_famfs_mode(dev)) { + fprintf(stderr, "%s is not in famfs mode\n", devname); return 1; } rc =3D daxctl_dev_disable(dev); @@ -711,6 +753,7 @@ static int disable_devdax_device(struct daxctl_dev *dev) =20 static int reconfig_mode_system_ram(struct daxctl_dev *dev) { + struct daxctl_memory *mem =3D daxctl_dev_get_memory(dev); const char *devname =3D daxctl_dev_get_devname(dev); int rc, skip_enable =3D 0; =20 @@ -724,11 +767,21 @@ static int reconfig_mode_system_ram(struct daxctl_dev= *dev) } =20 if (daxctl_dev_is_enabled(dev)) { - rc =3D disable_devdax_device(dev); - if (rc < 0) - return rc; - if (rc > 0) + if (mem) { + /* already in system-ram mode */ skip_enable =3D 1; + } else if (daxctl_dev_is_famfs_mode(dev)) { + rc =3D disable_famfs_device(dev); + if (rc) + return rc; + } else if (daxctl_dev_is_devdax_mode(dev)) { + rc =3D disable_devdax_device(dev); + if (rc) + return rc; + } else { + fprintf(stderr, "%s: unknown mode\n", devname); + return -EINVAL; + } } =20 if (!skip_enable) { @@ -750,7 +803,7 @@ static int disable_system_ram_device(struct daxctl_dev = *dev) int rc; =20 if (!mem) { - fprintf(stderr, "%s was already in devdax mode\n", devname); + fprintf(stderr, "%s is not in system-ram mode\n", devname); return 1; } =20 @@ -786,12 +839,28 @@ static int disable_system_ram_device(struct daxctl_de= v *dev) =20 static int reconfig_mode_devdax(struct daxctl_dev *dev) { + struct daxctl_memory *mem =3D daxctl_dev_get_memory(dev); + const char *devname =3D daxctl_dev_get_devname(dev); int rc; =20 if (daxctl_dev_is_enabled(dev)) { - rc =3D disable_system_ram_device(dev); - if (rc) - return rc; + if (mem) { + rc =3D disable_system_ram_device(dev); + if (rc) + return rc; + } else if (daxctl_dev_is_famfs_mode(dev)) { + rc =3D disable_famfs_device(dev); + if (rc) + return rc; + } else if (daxctl_dev_is_devdax_mode(dev)) { + /* already in devdax mode, just re-enable */ + rc =3D daxctl_dev_disable(dev); + if (rc) + return rc; + } else { + fprintf(stderr, "%s: unknown mode\n", devname); + return -EINVAL; + } } =20 rc =3D daxctl_dev_enable_devdax(dev); @@ -801,6 +870,40 @@ static int reconfig_mode_devdax(struct daxctl_dev *dev) return 0; } =20 +static int reconfig_mode_famfs(struct daxctl_dev *dev) +{ + struct daxctl_memory *mem =3D daxctl_dev_get_memory(dev); + const char *devname =3D daxctl_dev_get_devname(dev); + int rc; + + if (daxctl_dev_is_enabled(dev)) { + if (mem) { + fprintf(stderr, + "%s is in system-ram mode, must be in devdax mode to convert to famfs\= n", + devname); + return -EINVAL; + } else if (daxctl_dev_is_famfs_mode(dev)) { + /* already in famfs mode, just re-enable */ + rc =3D daxctl_dev_disable(dev); + if (rc) + return rc; + } else if (daxctl_dev_is_devdax_mode(dev)) { + rc =3D disable_devdax_device(dev); + if (rc) + return rc; + } else { + fprintf(stderr, "%s: unknown mode\n", devname); + return -EINVAL; + } + } + + rc =3D daxctl_dev_enable_famfs(dev); + if (rc) + return rc; + + return 0; +} + static int do_create(struct daxctl_region *region, long long val, struct json_object **jdevs) { @@ -887,6 +990,9 @@ static int do_reconfig(struct daxctl_dev *dev, enum dev= _mode mode, case DAXCTL_DEV_MODE_DEVDAX: rc =3D reconfig_mode_devdax(dev); break; + case DAXCTL_DEV_MODE_FAMFS: + rc =3D reconfig_mode_famfs(dev); + break; default: fprintf(stderr, "%s: unknown mode requested: %d\n", devname, mode); diff --git a/daxctl/json.c b/daxctl/json.c index 3cbce9d..01f139b 100644 --- a/daxctl/json.c +++ b/daxctl/json.c @@ -48,8 +48,12 @@ struct json_object *util_daxctl_dev_to_json(struct daxct= l_dev *dev, =20 if (mem) jobj =3D json_object_new_string("system-ram"); - else + else if (daxctl_dev_is_famfs_mode(dev)) + jobj =3D json_object_new_string("famfs"); + else if (daxctl_dev_is_devdax_mode(dev)) jobj =3D json_object_new_string("devdax"); + else + jobj =3D json_object_new_string("unknown"); if (jobj) json_object_object_add(jdev, "mode", jobj); =20 diff --git a/daxctl/lib/libdaxctl-private.h b/daxctl/lib/libdaxctl-private.h index ae45311..0bb73e8 100644 --- a/daxctl/lib/libdaxctl-private.h +++ b/daxctl/lib/libdaxctl-private.h @@ -21,12 +21,14 @@ static const char *dax_subsystems[] =3D { enum daxctl_dev_mode { DAXCTL_DEV_MODE_DEVDAX =3D 0, DAXCTL_DEV_MODE_RAM, + DAXCTL_DEV_MODE_FAMFS, DAXCTL_DEV_MODE_END, }; =20 static const char *dax_modules[] =3D { [DAXCTL_DEV_MODE_DEVDAX] =3D "device_dax", [DAXCTL_DEV_MODE_RAM] =3D "kmem", + [DAXCTL_DEV_MODE_FAMFS] =3D "fsdev_dax", }; =20 enum memory_op { diff --git a/daxctl/lib/libdaxctl.c b/daxctl/lib/libdaxctl.c index b7fa0de..0a6cbfe 100644 --- a/daxctl/lib/libdaxctl.c +++ b/daxctl/lib/libdaxctl.c @@ -418,6 +418,78 @@ DAXCTL_EXPORT int daxctl_dev_is_system_ram_capable(str= uct daxctl_dev *dev) return false; } =20 +/* + * Check if device is currently in famfs mode (bound to fsdev_dax driver) + */ +DAXCTL_EXPORT int daxctl_dev_is_famfs_mode(struct daxctl_dev *dev) +{ + const char *devname =3D daxctl_dev_get_devname(dev); + struct daxctl_ctx *ctx =3D daxctl_dev_get_ctx(dev); + char *mod_path, *mod_base; + char path[200]; + const int len =3D sizeof(path); + + if (!device_model_is_dax_bus(dev)) + return false; + + if (!daxctl_dev_is_enabled(dev)) + return false; + + if (snprintf(path, len, "%s/driver", dev->dev_path) >=3D len) { + err(ctx, "%s: buffer too small!\n", devname); + return false; + } + + mod_path =3D realpath(path, NULL); + if (!mod_path) + return false; + + mod_base =3D basename(mod_path); + if (strcmp(mod_base, dax_modules[DAXCTL_DEV_MODE_FAMFS]) =3D=3D 0) { + free(mod_path); + return true; + } + + free(mod_path); + return false; +} + +/* + * Check if device is currently in devdax mode (bound to device_dax driver) + */ +DAXCTL_EXPORT int daxctl_dev_is_devdax_mode(struct daxctl_dev *dev) +{ + const char *devname =3D daxctl_dev_get_devname(dev); + struct daxctl_ctx *ctx =3D daxctl_dev_get_ctx(dev); + char *mod_path, *mod_base; + char path[200]; + const int len =3D sizeof(path); + + if (!device_model_is_dax_bus(dev)) + return false; + + if (!daxctl_dev_is_enabled(dev)) + return false; + + if (snprintf(path, len, "%s/driver", dev->dev_path) >=3D len) { + err(ctx, "%s: buffer too small!\n", devname); + return false; + } + + mod_path =3D realpath(path, NULL); + if (!mod_path) + return false; + + mod_base =3D basename(mod_path); + if (strcmp(mod_base, dax_modules[DAXCTL_DEV_MODE_DEVDAX]) =3D=3D 0) { + free(mod_path); + return true; + } + + free(mod_path); + return false; +} + /* * This checks for the device to be in system-ram mode, so calling * daxctl_dev_get_memory() on a devdax mode device will always return NULL. @@ -982,6 +1054,11 @@ DAXCTL_EXPORT int daxctl_dev_enable_ram(struct daxctl= _dev *dev) return daxctl_dev_enable(dev, DAXCTL_DEV_MODE_RAM); } =20 +DAXCTL_EXPORT int daxctl_dev_enable_famfs(struct daxctl_dev *dev) +{ + return daxctl_dev_enable(dev, DAXCTL_DEV_MODE_FAMFS); +} + DAXCTL_EXPORT int daxctl_dev_disable(struct daxctl_dev *dev) { const char *devname =3D daxctl_dev_get_devname(dev); diff --git a/daxctl/lib/libdaxctl.sym b/daxctl/lib/libdaxctl.sym index 3098811..2a812c6 100644 --- a/daxctl/lib/libdaxctl.sym +++ b/daxctl/lib/libdaxctl.sym @@ -104,3 +104,10 @@ LIBDAXCTL_10 { global: daxctl_dev_is_system_ram_capable; } LIBDAXCTL_9; + +LIBDAXCTL_11 { +global: + daxctl_dev_enable_famfs; + daxctl_dev_is_famfs_mode; + daxctl_dev_is_devdax_mode; +} LIBDAXCTL_10; diff --git a/daxctl/libdaxctl.h b/daxctl/libdaxctl.h index 53c6bbd..84fcdb4 100644 --- a/daxctl/libdaxctl.h +++ b/daxctl/libdaxctl.h @@ -72,12 +72,15 @@ int daxctl_dev_is_enabled(struct daxctl_dev *dev); int daxctl_dev_disable(struct daxctl_dev *dev); int daxctl_dev_enable_devdax(struct daxctl_dev *dev); int daxctl_dev_enable_ram(struct daxctl_dev *dev); +int daxctl_dev_enable_famfs(struct daxctl_dev *dev); int daxctl_dev_get_target_node(struct daxctl_dev *dev); int daxctl_dev_will_auto_online_memory(struct daxctl_dev *dev); int daxctl_dev_has_online_memory(struct daxctl_dev *dev); =20 struct daxctl_memory; int daxctl_dev_is_system_ram_capable(struct daxctl_dev *dev); +int daxctl_dev_is_famfs_mode(struct daxctl_dev *dev); +int daxctl_dev_is_devdax_mode(struct daxctl_dev *dev); struct daxctl_memory *daxctl_dev_get_memory(struct daxctl_dev *dev); struct daxctl_dev *daxctl_memory_get_dev(struct daxctl_memory *mem); const char *daxctl_memory_get_node_path(struct daxctl_memory *mem); --=20 2.49.0 From nobody Sat Feb 7 12:35:05 2026 Received: from mail-oi1-f170.google.com (mail-oi1-f170.google.com [209.85.167.170]) (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 981D439A7F5 for ; Wed, 7 Jan 2026 15:35:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767800115; cv=none; b=Xv2Rx+YfS+yZ22GvhXSk87ISV8yYW3nU+i8zO7Kuy24cIsKPCQ4EVnbe51AZNe92Y1tCvs4VSeTADeEy0j5pIegYpW0sbdhXzSWFeP1lbq9WngEBmmIaaoGdwrMLDeiDhiPdKr5I4fSPs4Clk4KFDYIKo1bcMmNEsSAHGWw8Z3U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767800115; c=relaxed/simple; bh=UH7UVmm/ifZMz2a7ctzEVAj9QL1YqJfv9TEsJAmqvl0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tk5kRCRy4NoDc6AzDF18+x3mytUi7N1FhEpJZbNAb0C+EPecitTEKLtE/0Dq/znH1sfzLoF7W7LbwXkU8HcsNmjjK8aMOpDqhGUXBVowV8d5HTKTGGZ+vi5jXM0h/O+5zhU8D55i4Gwf4ATvqhxAtwX7rZgQiAWeYEdv3hMoQUs= 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=bMuO/cKD; arc=none smtp.client-ip=209.85.167.170 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="bMuO/cKD" Received: by mail-oi1-f170.google.com with SMTP id 5614622812f47-450be85b7d9so1408777b6e.0 for ; Wed, 07 Jan 2026 07:35:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767800110; x=1768404910; 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=bMuO/cKDgBQ7MDSk9U5rZupNeiODJwTx7I9gFDCFydqoRNF5bb5XBxGm7iO3pn2zmN RJWqRTwynU8DZ/Me9oX3OL1LfaPxg14B7bdiRmWRZS4TZHssZrk3Ihp97s+ZtjHgWNh8 YIjNdzcT0FtM+bnOwTgYOjNB8SCxhrBqERxthL0J3Mt/FA+v5wfAwF54UwLNOv5dmsA0 EcVHjxwIK7HTCh57TbkiagniQE4U0EG04F69w+iLXXUK3kwMCPRTkYLC444XDiw9oYf5 aXZlR7uvFrBdaNyQhR/ylbn4O75Y8KrKto8jynUQU7yvwgquWvo1bIsqDzcVZzo4TFGl 9tBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767800110; x=1768404910; 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=w27bPAQZQPpcfg6yz8KlYJ4/dCGQUM6KXnqppXn7EJLFFdlI4rI7r27MTddkP+HHeF MAQN/A1ZKAYFrWcHJJuNMPC7FhVKPXpWBVXdI/ts9iMrGAmsguunYj7BYEVkQgJZK3/9 8VZtt7xNXts50UOfhO3e+Y2Q9eyRICwkxZ5CSoguwcckPArjuyIqBzi++iHlXB5U9TCF 9qrxwvdI7OhvCMV/cYqZnhGgwimwUAflZhpmAJl+hiODKvD4rZT4CY3a3gwdN9+4mJV6 DFyyoM6qtmf1EG1mLqHSEEUn277hULb+UmaFbwFXUl8JagjONAmQmeMYLtgrb+Y5Gh5C jm5Q== X-Forwarded-Encrypted: i=1; AJvYcCU7fS0wJ4kuqNYIAQoWl9NX01cX1VnhA3LBXXKbKGbCGBGv9My7Z/HbgCH3XfY7ArOq+CgsinxNHAbhXEA=@vger.kernel.org X-Gm-Message-State: AOJu0YztVzG3ZwpabpQD09Xv5J841kTTBXzgLdo8P8JWsFUEtNkuKRgW gEWiZgYr9MBvbatIkwZzIXa88178eOjz0DoCWSFm5HXgjCEEb4n8bQoz X-Gm-Gg: AY/fxX6eXG7rff+NP9NHtCdwAslKEKKeXH4qQbzJiGlNy6Swhv4cK3yTl09bTNL9z7t 9FuVGNTt58ZyNEppSh54tBoPIT7m+pcmopKZXTW86olfHYqF35CaEqCiADuQtyxvI5kPUB00Ev9 C7cPCgJgGoGaZ4sun1Uf4aKIWhS+aOypBMpKcC9H+cg0Rdpe4nrHBYz6us5wYFE9pu26+wIj7/G sDt8Ji3uLfJTGQavTX1tumFYSGtDQIGoXEPT2BsdcLfeoryhSa+nfau6OXGlYMq3WPk+zC+17vu xYJ1X4zGkCSut2po6TiHLs2IBEJSlBuVuZy0OVvI33zIcdMaUygZuWgvPeH+zLpArUCyC21LD4h P7+YMQyIpWr8KGWJLMI9U1F+eeA7Gk0Ki6QFgCMORq5sk8Sebj7nkcuZdBz2Zbvq/Auy+yEIpK5 VQTTvxiaYz+E3EmEPPqq4Bj4UzB+jtHbybhr2ZEwud4Myc X-Google-Smtp-Source: AGHT+IHvJerAp0F2qVu0ANwUQaq5jdMW03NUN3RN1p6cxOBwInFyFNG7vh1+02TkB75u28LmDWlVDQ== X-Received: by 2002:a05:6808:2208:b0:459:bcff:a9ff with SMTP id 5614622812f47-45a6be8b053mr1272252b6e.34.1767800109996; Wed, 07 Jan 2026 07:35:09 -0800 (PST) Received: from localhost.localdomain ([2603:8080:1500:3d89:a917:5124:7300:7cef]) by smtp.gmail.com with ESMTPSA id 5614622812f47-45a5e183cd4sm2415499b6e.1.2026.01.07.07.35.07 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 07 Jan 2026 07:35:09 -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 , Chen Linxuan , 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, John Groves Subject: [PATCH 2/2] Add test/daxctl-famfs.sh to test famfs mode transitions: Date: Wed, 7 Jan 2026 09:34:59 -0600 Message-ID: <20260107153459.64821-3-john@groves.net> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260107153459.64821-1-john@groves.net> References: <20260107153244.64703-1-john@groves.net> <20260107153459.64821-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