From nobody Wed Oct 8 00:27:10 2025 Received: from mail-ot1-f45.google.com (mail-ot1-f45.google.com [209.85.210.45]) (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 400ED1C5F08; Thu, 3 Jul 2025 18:50:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751568643; cv=none; b=CIJg/tfcWFLAKF6o/IcSKnhkZSQi3tNpfrMRKpZH5uKlOgIjzxvHNrMYgLxO7pyR55tNI99u2gC0RvHN7cY+sXEsuV2HmrbK5vtYIp2s08jAUSRr1L2ljtC/6VD4L2DIZZUaKtPY2jM+n6RWANsjyoQefeESbZShvxxsHVBgI6A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751568643; c=relaxed/simple; bh=r7zU/NI6k0w2nK9GLUrhezJkiaHouNNrUAqAk2AR65M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bfEeFWVJXbThRHzG6JY0YMMajLCiPE5k9aKo7PPzpSxxoNQMLEyJDPw8YDH6tR2dhJU9b5vo4EdQkXJUJWUOJMzpuidwbzK3+x2nsnYnctVXLaaLeOsOLilcJWugtde4aRYaC0Vvc7+tnSEP+FGQu9uicXFjxU0wHON2uV8wgak= 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=Rm7AkplL; arc=none smtp.client-ip=209.85.210.45 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="Rm7AkplL" Received: by mail-ot1-f45.google.com with SMTP id 46e09a7af769-73a8d0e3822so140869a34.2; Thu, 03 Jul 2025 11:50:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751568640; x=1752173440; 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=+TgC0a/U5AW9OV2eqK8aHn6K3OlQMlAMMt+8AXwopR0=; b=Rm7AkplLu4wGTMQIB7Wm2tb5yA7YLMTf9U57qbrjhm3dCel/vvL+vV2vJI1c/IkdWC hIuPpUZJ1cvGFspWSHzI0pEsVbLzYb05kVtDZNT+aAFG9DThiNITZxNanoL5goPkWjw0 QegdJy5jxFumdJe1h3fPpmIIYuxstRxGg2sS5g3CvcRbD0xDoEw7smZAJb6AN5q1qqZR 9F3+hXJeOclNWwi1LERi1MXloQ4xBW9zWl97o1YpTri+WhtP+kVSHahvcIHPruiAvtvd rOmSlP42wpQI/LRm3gxpIjFOoUbYHz3YgOLb2TUEKhZch9OJ92DEmMzNsnKtWh94u66s axDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751568640; x=1752173440; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=+TgC0a/U5AW9OV2eqK8aHn6K3OlQMlAMMt+8AXwopR0=; b=I6DMORXXSysqSGWxCTPOYUCdSHrlSWGbjzbfNiTY6Wv9bSJEUQ56Xh4DRt684YAKN2 Osz30dpaHqure/wUDe2KTRSclurOJ5S0i+dSiieknccTq7GGfHxnwHcskUBqpCKXt1hG n/vnpqjLMjOUvb2FhhJLjNLE1HX5S56olVPHmrBBG6/IbGy427dSpmER2x/sxBFEVquo 1g4reBcH275IgX0L/bNfq4wrv+Bdcyr3PtytMqWXZmvoAxLOm42KDUBaehyW6UdAkCmk YPiXMFlO4aJWmRL9WujhUATqr/6k7njt9tA/vMPR7W4Uu2h8cVLv9ScxsEnXMaoecDFx jZmQ== X-Forwarded-Encrypted: i=1; AJvYcCVPrWFgb0bCTIhq6WEPwKeMmskhvN/IjG4l6Vi9lJbms5rMWKBapH1qkge9cEy7effLCYd4G+G6HrI=@vger.kernel.org, AJvYcCVwQxNIgHPCBrHrxZBKckkYzZexU+m/XulCr6g8n2mluT2GK52ar59x4mwrr24/0jZoMiHc5Ha2E0uv@vger.kernel.org, AJvYcCXMJuIWQTt5IGYM86LA6u4C871tFXCKQqRjV2AyPy21CTLdMNOyWfGQZdcN/TTS4PJE5oYNxY3VBzq9TXP1@vger.kernel.org, AJvYcCXwwonuSB0ahPwOZmSDCPQgQ2COIILA7rOknbgwPpMhTWNxWEhpLk/yoAl88MRMvgE50C21Mrv9vwVQ57gAgg==@vger.kernel.org X-Gm-Message-State: AOJu0YwzwhVdtGCLNMajT8WG1f76CdneqvCHW3vDK3XmttswSmQvTQWI 0jK+iO4UaDVSnobzgxEgOuMUM+9+NRhP+nAeYyL5/yXYYtZijrhJNXKT X-Gm-Gg: ASbGnctO4It7lR2v+j9epOms7VpSKbCgvhACxtHWEAsnJuwt/f8rc2PwO7xZqH/L1Oz FmhWsOZgkIUkerB1XZLmmq0ozcLZJjaAxf4DkO1WkcFL9s2RRrxiqEx12BKEmxdyq6wnSCFIBYo 6R+1P7fx8QrHUPuyr8s9UJoP0lMRO2u0iI8v67mbRWzzHUHa+LeEcakEvz7hwQFlOumO1+Sy3Oi xVvzZv6wbVZE1KQnUj+WtpjyB37eD80YBPDYAOdLfzUz0egBTZ+GvSp8dS6JwylTmgQIQEL6hu1 KFx5i9EIA2I1cp/obhUolCbhV/tOh8mnvObCR7j5EM4Eq+zuttTOcF1iyjbkB8MBTJPgfi1M2vR Rxj7DHAoV3pxPJw== X-Google-Smtp-Source: AGHT+IF73hX0JJIFBHibtD6A0+6uqUWfKLCEXmyBw6pOmIubhMzzPV9Jpbwsi9M9zd7Nm7jge6Jo8g== X-Received: by 2002:a05:6808:1b07:b0:404:e0b3:12f with SMTP id 5614622812f47-40b8876eecbmr6495647b6e.11.1751568640087; Thu, 03 Jul 2025 11:50:40 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:cd4:2776:8c4a:3597]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-73c9f90d1ccsm68195a34.44.2025.07.03.11.50.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 03 Jul 2025 11:50:39 -0700 (PDT) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Dan Williams , Miklos Szeredi , Bernd Schubert Cc: John Groves , Jonathan Corbet , Vishal Verma , Dave Jiang , Matthew Wilcox , Jan Kara , Alexander Viro , Christian Brauner , "Darrick J . Wong" , Randy Dunlap , Jeff Layton , Kent Overstreet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, Amir Goldstein , Jonathan Cameron , Stefan Hajnoczi , Joanne Koong , Josef Bacik , Aravind Ramesh , Ajay Joshi , John Groves Subject: [RFC V2 01/18] dev_dax_iomap: Move dax_pgoff_to_phys() from device.c to bus.c Date: Thu, 3 Jul 2025 13:50:15 -0500 Message-Id: <20250703185032.46568-2-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250703185032.46568-1-john@groves.net> References: <20250703185032.46568-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" No changes to the function - just moved it. dev_dax_iomap needs to call this function from drivers/dax/bus.c. drivers/dax/bus.c can't call functions in drivers/dax/device.c - that creates a circular linkage dependency - but device.c can call functions in bus.c. Also exports dax_pgoff_to_phys() since both bus.c and device.c now call it. Signed-off-by: John Groves --- drivers/dax/bus.c | 24 ++++++++++++++++++++++++ drivers/dax/device.c | 23 ----------------------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c index fde29e0ad68b..9d9a4ae7bbc0 100644 --- a/drivers/dax/bus.c +++ b/drivers/dax/bus.c @@ -1417,6 +1417,30 @@ static const struct device_type dev_dax_type =3D { .groups =3D dax_attribute_groups, }; =20 +/* see "strong" declaration in tools/testing/nvdimm/dax-dev.c */ +__weak phys_addr_t dax_pgoff_to_phys(struct dev_dax *dev_dax, pgoff_t pgof= f, + unsigned long size) +{ + int i; + + for (i =3D 0; i < dev_dax->nr_range; i++) { + struct dev_dax_range *dax_range =3D &dev_dax->ranges[i]; + struct range *range =3D &dax_range->range; + unsigned long long pgoff_end; + phys_addr_t phys; + + pgoff_end =3D dax_range->pgoff + PHYS_PFN(range_len(range)) - 1; + if (pgoff < dax_range->pgoff || pgoff > pgoff_end) + continue; + phys =3D PFN_PHYS(pgoff - dax_range->pgoff) + range->start; + if (phys + size - 1 <=3D range->end) + return phys; + break; + } + return -1; +} +EXPORT_SYMBOL_GPL(dax_pgoff_to_phys); + static struct dev_dax *__devm_create_dev_dax(struct dev_dax_data *data) { struct dax_region *dax_region =3D data->dax_region; diff --git a/drivers/dax/device.c b/drivers/dax/device.c index 6d74e62bbee0..29f61771fef0 100644 --- a/drivers/dax/device.c +++ b/drivers/dax/device.c @@ -50,29 +50,6 @@ static int check_vma(struct dev_dax *dev_dax, struct vm_= area_struct *vma, return 0; } =20 -/* see "strong" declaration in tools/testing/nvdimm/dax-dev.c */ -__weak phys_addr_t dax_pgoff_to_phys(struct dev_dax *dev_dax, pgoff_t pgof= f, - unsigned long size) -{ - int i; - - for (i =3D 0; i < dev_dax->nr_range; i++) { - struct dev_dax_range *dax_range =3D &dev_dax->ranges[i]; - struct range *range =3D &dax_range->range; - unsigned long long pgoff_end; - phys_addr_t phys; - - pgoff_end =3D dax_range->pgoff + PHYS_PFN(range_len(range)) - 1; - if (pgoff < dax_range->pgoff || pgoff > pgoff_end) - continue; - phys =3D PFN_PHYS(pgoff - dax_range->pgoff) + range->start; - if (phys + size - 1 <=3D range->end) - return phys; - break; - } - return -1; -} - static void dax_set_mapping(struct vm_fault *vmf, pfn_t pfn, unsigned long fault_size) { --=20 2.49.0 From nobody Wed Oct 8 00:27:10 2025 Received: from mail-oa1-f47.google.com (mail-oa1-f47.google.com [209.85.160.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 EC8E52F2735; Thu, 3 Jul 2025 18:50:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751568645; cv=none; b=un4r4Z7VjLeZp2bPHHb01Tt3A+4Y1JnCTqhAL0BHdOR4y8Kyo9GcgntCvquwVDT9uWgjPLV9ZWP+L9Dvw/Dyk7NJOjIAK07V5Y9QHGxv8idJ8tYFnVtCYhA7PsIUMhr5bcVI7W+ecJbW+Q2i0z65cAbFQWwDTIgGsBzQNvGIVdc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751568645; c=relaxed/simple; bh=gsIhmfFsaL+5EF4z3f0VUnIpcZS1jFVcEdA2B4rIq38=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cOuH7qb0jGdi+0nakU0bUss/0M1a/4oTHU/L17yS9DZmAzyNNoHPNoTzVrVEgKRf4d3BoXjfQYaKBNSTLHWZXL6lcXULIWTAkDvtAopMFeKwJYZ8dGJyflW6z/W5m2dclrhZWAinKISl+q8WSfr1ig52RcvHBT8Va1KsEhZzyJw= 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=SSiDdKeo; arc=none smtp.client-ip=209.85.160.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="SSiDdKeo" Received: by mail-oa1-f47.google.com with SMTP id 586e51a60fabf-2eff5d1c7efso203670fac.2; Thu, 03 Jul 2025 11:50:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751568643; x=1752173443; 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=37keBjnXcy0vWAMphYKQfFgDhN7R9v7a8FhgLd8vRyw=; b=SSiDdKeo7G5rAvx0AI6SPLId6Dsc1OUWlU8WUWBOdiOvKNDZeNLyB4DuAhrgzyhmTf uRQtK55IfnbrfCq5szAS9n/v58WmpjFtlTZdeduzGmE8NhRX/cJ4ndvYjQmBKbspD+MJ czAEIwbXK71aayf4VrIyaDxKzpYt46ekhS3EdGzaie1tx3o4Sdtoub2iiwFSx8yTFtvK fWwfzlscsseX3hDlFMVCN7aG2cg1x+rEuWp1qadQAGjDlPXSnByIYI51+wIpY61++dZO jPR6UegcjHB+r0/a6rhSpCs3N0dq780JpzmcZjzdVzFXEaJf7LjVIdQgBFEn60y9Eg1o YM+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751568643; x=1752173443; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=37keBjnXcy0vWAMphYKQfFgDhN7R9v7a8FhgLd8vRyw=; b=eDAJnJnEccfGrDekwFuAigMmyuBZdrfCK6+NnmQqKHIkJSRefQDpPGQuOJS41bmmWN 5sdKkybBDYpdbsYQMRMrzsWLotMR8p3qypFarkkDSPmdgsU/dxOWgjYvq34TVdS9xMpj rGSiPjcfw+whrRFWsB5EECTuhdzrN6+Wt5Fg6Tb3HvmnN6dIViGNzYXTFUhh4BiXTeow DAqv2UwMCGq7X9plDvlbpFgTaen2DUCVqHHhXJ1AKzDPO95P+ZKnyTvw4srbs97kuIFW rLkg9W1OntmaHRkr0krmqXaTrnSKu4Ws0E6sbhHjjuuGpmVHOTjsGwWWgKmsmqoOheL/ VsMw== X-Forwarded-Encrypted: i=1; AJvYcCUBuwqmAtZpZ3PutQZrRtWfv4OiL16OAQWMdWH+QmY63Lj64hD9nJiEqT4OIzqfEOgABn+NzL9laMS+@vger.kernel.org, AJvYcCUNiUtfFfdqC7eugzxiWrkFOFlv3SmTXcIdDn1vF5XGB6ZCHIH/3LUtd8WpLPC8NeE/KXVZv/hHWuPLJAg0@vger.kernel.org, AJvYcCVfMOCT2W2tiNVQHH9kxTF44ApDw9CvoLRULTOY6bQVFhJn3spP/HkUAd4vuDqcQkoSQWJ2AuqiJrM=@vger.kernel.org, AJvYcCWoitsnxDB3fjLBFJQrrKyVwAjC13sKsRPFRalIn5IfnZP0sJyXxOGMLlAQheBc4X46HgWPMVP7U0gbygcckw==@vger.kernel.org X-Gm-Message-State: AOJu0YwqY5/2PUgmsD66UZa4hqzOZaRfTWSsydzl6wWDXNpHVXNlXwc2 ujrerkBYwT40h20LkLFxNJWTH1+ToyelikbMOP/uZhDbedrStiQPkXEq X-Gm-Gg: ASbGncvlsQrNt2dRqKiD2+/Njga22es2h7HxHXxhDH7KX+d3Ru04/8uhzLrz8ure5Vd JXvNzixGMe+h3GhJqxUFSPo7LQumJ/ohb1cJ4llCIJRb2cz64nNVEWRwNhpAA5iCLM4FiWyiNwG ujf9YPhqwQ7UHPjuzT1HTtXQfKebBuFF5ubnH7hhx2/KgO5tt1xWmQwZ212uxL/AILXuQaXGZQE f7XeVRfmD2e/NHI2u6KGlcIxjy4wXbZIZv7CYxMaaBLBypJLzLHG9yHbl6m/c2OMIEDVDGsFkhV 1Wzdfz0OvoFEMUK7y3qOcFIlb/H9s+OXmKTnrRmmWmj0i7fo9Z/Ga8FEYczfU+D/YyUwg2L+46X 6TARJD/0qINjF6d4zwVbrA179 X-Google-Smtp-Source: AGHT+IGGO26vNj25TCeR8caAFdVMd/7bQ1PotJARXetJW6yAE8gTTCz/lmho2fjx9+U6Hq3mnqrM6w== X-Received: by 2002:a05:6871:8416:b0:2f7:64ff:aae2 with SMTP id 586e51a60fabf-2f764ffaf42mr2834618fac.36.1751568642961; Thu, 03 Jul 2025 11:50:42 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:cd4:2776:8c4a:3597]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-73c9f90d1ccsm68195a34.44.2025.07.03.11.50.41 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 03 Jul 2025 11:50:42 -0700 (PDT) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Dan Williams , Miklos Szeredi , Bernd Schubert Cc: John Groves , Jonathan Corbet , Vishal Verma , Dave Jiang , Matthew Wilcox , Jan Kara , Alexander Viro , Christian Brauner , "Darrick J . Wong" , Randy Dunlap , Jeff Layton , Kent Overstreet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, Amir Goldstein , Jonathan Cameron , Stefan Hajnoczi , Joanne Koong , Josef Bacik , Aravind Ramesh , Ajay Joshi , John Groves Subject: [RFC V2 02/18] dev_dax_iomap: Add fs_dax_get() func to prepare dax for fs-dax usage Date: Thu, 3 Jul 2025 13:50:16 -0500 Message-Id: <20250703185032.46568-3-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250703185032.46568-1-john@groves.net> References: <20250703185032.46568-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" This function should be called by fs-dax file systems after opening the devdax device. This adds holder_operations, which effects exclusivity between callers of fs_dax_get(). This function serves the same role as fs_dax_get_by_bdev(), which dax file systems call after opening the pmem block device. This also adds the CONFIG_DEV_DAX_IOMAP Kconfig parameter Signed-off-by: John Groves --- drivers/dax/Kconfig | 6 ++++++ drivers/dax/super.c | 30 ++++++++++++++++++++++++++++++ include/linux/dax.h | 5 +++++ 3 files changed, 41 insertions(+) diff --git a/drivers/dax/Kconfig b/drivers/dax/Kconfig index d656e4c0eb84..ad19fa966b8b 100644 --- a/drivers/dax/Kconfig +++ b/drivers/dax/Kconfig @@ -78,4 +78,10 @@ config DEV_DAX_KMEM =20 Say N if unsure. =20 +config DEV_DAX_IOMAP + depends on DEV_DAX && DAX + def_bool y + help + Support iomap mapping of devdax devices (for FS-DAX file + systems that reside on character /dev/dax devices) endif diff --git a/drivers/dax/super.c b/drivers/dax/super.c index e16d1d40d773..48bab9b5f341 100644 --- a/drivers/dax/super.c +++ b/drivers/dax/super.c @@ -122,6 +122,36 @@ void fs_put_dax(struct dax_device *dax_dev, void *hold= er) EXPORT_SYMBOL_GPL(fs_put_dax); #endif /* CONFIG_BLOCK && CONFIG_FS_DAX */ =20 +#if IS_ENABLED(CONFIG_DEV_DAX_IOMAP) +/** + * fs_dax_get() + * + * fs-dax file systems call this function to prepare to use a devdax devic= e for + * fsdax. This is like fs_dax_get_by_bdev(), but the caller already has st= ruct + * dev_dax (and there * is no bdev). The holder makes this exclusive. + * + * @dax_dev: dev to be prepared for fs-dax usage + * @holder: filesystem or mapped device inside the dax_device + * @hops: operations for the inner holder + * + * Returns: 0 on success, <0 on failure + */ +int fs_dax_get(struct dax_device *dax_dev, void *holder, + const struct dax_holder_operations *hops) +{ + if (!dax_dev || !dax_alive(dax_dev) || !igrab(&dax_dev->inode)) + return -ENODEV; + + if (cmpxchg(&dax_dev->holder_data, NULL, holder)) + return -EBUSY; + + dax_dev->holder_ops =3D hops; + + return 0; +} +EXPORT_SYMBOL_GPL(fs_dax_get); +#endif /* DEV_DAX_IOMAP */ + enum dax_device_flags { /* !alive + rcu grace period =3D=3D no new operations / mappings */ DAXDEV_ALIVE, diff --git a/include/linux/dax.h b/include/linux/dax.h index df41a0017b31..86bf5922f1b0 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -51,6 +51,11 @@ struct dax_holder_operations { =20 #if IS_ENABLED(CONFIG_DAX) struct dax_device *alloc_dax(void *private, const struct dax_operations *o= ps); + +#if IS_ENABLED(CONFIG_DEV_DAX_IOMAP) +int fs_dax_get(struct dax_device *dax_dev, void *holder, const struct dax_= holder_operations *hops); +struct dax_device *inode_dax(struct inode *inode); +#endif void *dax_holder(struct dax_device *dax_dev); void put_dax(struct dax_device *dax_dev); void kill_dax(struct dax_device *dax_dev); --=20 2.49.0 From nobody Wed Oct 8 00:27:10 2025 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 674552989B6; Thu, 3 Jul 2025 18:50:46 +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=1751568648; cv=none; b=HA3S9asj6woSW3dDR01U/XK9lXHDGGAcNEJZUmZWr7rrwwVvBsQ5WhFceHIdXQflN6B5o2f7iqXWUGIS370264QE1aONxiDpMPVDPA9tlsbfnNSX02lI6KWV/idzpgiq4r4tAg90S75b5gbKizrIwysFseoyNj6lJpbxasM53bs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751568648; c=relaxed/simple; bh=SM8Xj4dnyYwoGjDXor6hvaRx7QAO8yyyxbfokVYE+S8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qha20TER0Jd9W50ULEVLB2UNy3aIWhc8TJU3mrTvvoS63/rTuu2SQ0QB98y13RyHajXJRB+IJVF5QXFEF4qwDOSkuuVW0q1mfR5bphRfTHVAFh3OqdbYUkeLMCmQilnb4FA7rOZMVDTeOXfZZyKVMlfcBVtj9frLFA9f2gHnAhU= 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=fG57Wpsj; 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="fG57Wpsj" Received: by mail-ot1-f47.google.com with SMTP id 46e09a7af769-735a6d7c5b1so152492a34.2; Thu, 03 Jul 2025 11:50:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751568645; x=1752173445; 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=CJswZ+V2KGwmP5G+n4PEaC6MizB6DbX3hqjndqhvdZU=; b=fG57WpsjFDlEaFgTdBlpaUv7z8CQ2uDkKVmc0EtgNUIiG9peGxt0LFxwTPA59MNMmk LXP0wGnvew6eE3Jqm5lzR953aHnqrv6YrZuDTRYcyvHPdBA7blS5FrPf9SvWMQrcEsf8 Cqszh2jPf+qtXuTsxS4xZFBaB8GHYx3BAuuYoFTdd29J72Lcc0I6/ZzDTMUH2JllXZ/L WJcLwHz0oLxoznZ8100t+s3L2K8UKNXq5Bk3jJJBKEkv1/v4VRCZwp+UV+RZ/KDrDHsT rHdCxhsiWB1ya4rKe8ANUTuJ4w85waRlDPVlBiUhNO1TdGCquJFS5mk9aQ8AO426jEjR FsPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751568645; x=1752173445; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=CJswZ+V2KGwmP5G+n4PEaC6MizB6DbX3hqjndqhvdZU=; b=GJAOm3PA9q5CnFzJbEbUCkw3nZY83rCywh3ZLG4JjTSYocjSQuv1R2ygxQcRtsYNGF 1DB3d2RBSlfVnCfH/TdPPxCZvchHNgxjeREu1qjmA9bCgDjWCVYToCLbNQGJ9tsCxtJY 5LQP9E93hGe9OK57yU/FssLu6poBAboKV3XfRA8O1gSkKDkqYlKgbk/M7BjOc9mfbfm2 Yw+28eaxsDYx+LhSrLWb3eP/5kCXTBK7SrKUigaaDp0p5nRCq8oljDlRTLsN9cUp9gEx FLvhzggFofvdtvIj/n8H4APRNu1FCKOFWo7ggQ7o0HQXD8xkdJAKP+yOwQoHIO5G9I3j 4mdA== X-Forwarded-Encrypted: i=1; AJvYcCUUl8pz7wJoyWYTrytMy8RkgY+Varnlt2OLOiSchLkOMCZiH6znjwQOWKbKe5r6gwC7f+abnFfu40HD46/j@vger.kernel.org, AJvYcCV4FvidpTWus+7Xx9vB1nxB7OuoVEkJ3BgK3sRucEvf7ytQQqyPKNNd5vBPiiipVKpZgmwLDDUJkoZxyFvh6A==@vger.kernel.org, AJvYcCWHXwHLCa0xachH+ORCQsT2OKRQGtY4GgLZNRGRGg4W1YKd7LhZp1rd2UfQf+/uMJrdoexesWj+gLs=@vger.kernel.org, AJvYcCWQ64a5RtEy2nxGMrqmZsHHi5AolDTcGoWogNFT5Qeo2dLMQT+os1qp6wUZq82pIX8EbC+z39GOExJl@vger.kernel.org X-Gm-Message-State: AOJu0Ywo+KPIrCAEjTpkQ1O8CtHuE2cib82PATicnBjTu2PFI//ZrfQD 1FAVn8/D0m7e+YQdsmbo1nQpQdFdjObUNDEwuUnTBuvQq1CS81l+W0uxifizMfX3 X-Gm-Gg: ASbGnctLzD0cNFVFJtzRJpigf3TGyY7OPAL/9E7owVrGzmiyYMVKTHTCDvtGl0SPpD/ Gu0rHbolWkxeL3Z77nLhuHNW1W6vciX2PqkM7ryZ79u/1WxWQNNRmJZeQ5upHFh1OJbEQhn29V0 wXxgXj7dDhUVY9Hyh6oP2kvtz3mrMc38s9H7Cf7odMtt8Nj2lZ/cbDrPdngCYjfo/xJqu9CDg5f 4zVKvdWVNuVbORpPzTeePv4xprAs40SW5YtQhxcBcj5D+Spkgk5HiM4fGJxRDTCh8KppRtYoBZp DZIyxYrxnuKb00mamIXDCFBQAqE2NcCSgaGw67RP/A9vtZyjWKj6Zw2cVTuvCZ7nXvFHfEu4JCA hlUoxfy64WtJhevrO0BLfgMNM X-Google-Smtp-Source: AGHT+IGf6EnisMiDGZyZbVSv29Y7ewVQGRvUqtA17icw2gxtyfeO9BNRhEvAJBrTRu+vFRFvecQ+Zw== X-Received: by 2002:a05:6830:2c07:b0:727:24ab:3e4 with SMTP id 46e09a7af769-73c8c248e02mr2426451a34.9.1751568645493; Thu, 03 Jul 2025 11:50:45 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:cd4:2776:8c4a:3597]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-73c9f90d1ccsm68195a34.44.2025.07.03.11.50.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 03 Jul 2025 11:50:45 -0700 (PDT) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Dan Williams , Miklos Szeredi , Bernd Schubert Cc: John Groves , Jonathan Corbet , Vishal Verma , Dave Jiang , Matthew Wilcox , Jan Kara , Alexander Viro , Christian Brauner , "Darrick J . Wong" , Randy Dunlap , Jeff Layton , Kent Overstreet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, Amir Goldstein , Jonathan Cameron , Stefan Hajnoczi , Joanne Koong , Josef Bacik , Aravind Ramesh , Ajay Joshi , John Groves Subject: [RFC V2 03/18] dev_dax_iomap: Save the kva from memremap Date: Thu, 3 Jul 2025 13:50:17 -0500 Message-Id: <20250703185032.46568-4-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250703185032.46568-1-john@groves.net> References: <20250703185032.46568-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" Save the kva from memremap because we need it for iomap rw support. Prior to famfs, there were no iomap users of /dev/dax - so the virtual address from memremap was not needed. Also: in some cases dev_dax_probe() is called with the first dev_dax->range offset past the start of pgmap[0].range. In those cases we need to add the difference to virt_addr in order to have the physaddr's in dev_dax->ranges match dev_dax->virt_addr. This happens with devdax devices that started as pmem and got converted to devdax. I'm not sure whether the offset is due to label storage, or page tables, but this works in all known cases. Signed-off-by: John Groves --- drivers/dax/dax-private.h | 1 + drivers/dax/device.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/drivers/dax/dax-private.h b/drivers/dax/dax-private.h index 0867115aeef2..2a6b07813f9f 100644 --- a/drivers/dax/dax-private.h +++ b/drivers/dax/dax-private.h @@ -81,6 +81,7 @@ struct dev_dax_range { struct dev_dax { struct dax_region *region; struct dax_device *dax_dev; + void *virt_addr; unsigned int align; int target_node; bool dyn_id; diff --git a/drivers/dax/device.c b/drivers/dax/device.c index 29f61771fef0..583150478dcc 100644 --- a/drivers/dax/device.c +++ b/drivers/dax/device.c @@ -372,6 +372,7 @@ static int dev_dax_probe(struct dev_dax *dev_dax) struct dax_device *dax_dev =3D dev_dax->dax_dev; struct device *dev =3D &dev_dax->dev; struct dev_pagemap *pgmap; + u64 data_offset =3D 0; struct inode *inode; struct cdev *cdev; void *addr; @@ -426,6 +427,20 @@ static int dev_dax_probe(struct dev_dax *dev_dax) if (IS_ERR(addr)) return PTR_ERR(addr); =20 + /* Detect whether the data is at a non-zero offset into the memory */ + if (pgmap->range.start !=3D dev_dax->ranges[0].range.start) { + u64 phys =3D dev_dax->ranges[0].range.start; + u64 pgmap_phys =3D dev_dax->pgmap[0].range.start; + u64 vmemmap_shift =3D dev_dax->pgmap[0].vmemmap_shift; + + if (!WARN_ON(pgmap_phys > phys)) + data_offset =3D phys - pgmap_phys; + + pr_debug("%s: offset detected phys=3D%llx pgmap_phys=3D%llx offset=3D%ll= x shift=3D%llx\n", + __func__, phys, pgmap_phys, data_offset, vmemmap_shift); + } + dev_dax->virt_addr =3D addr + data_offset; + inode =3D dax_inode(dax_dev); cdev =3D inode->i_cdev; cdev_init(cdev, &dax_fops); --=20 2.49.0 From nobody Wed Oct 8 00:27:10 2025 Received: from mail-ot1-f41.google.com (mail-ot1-f41.google.com [209.85.210.41]) (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 6A5B4291C11; Thu, 3 Jul 2025 18:50:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751568654; cv=none; b=aZTZhDLJEY4oRIHHnemNIIHuVWBuoJaAhQwkYksmkZla51onymLrYrjE16m2pU2a3X76VKiIohks3AtEIp1pFnJW+lE/Lq/YV0mYfAQOQmOg5pCB9VCVExTGWraaAafdiqAT8NYlKeF41s1EQY8H0itGTLpR2MQOLS9dd9v4m/g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751568654; c=relaxed/simple; bh=Pw428QKL7vU/Q+rAmnYuMV/vyS2i6xzQE57G20v2vFg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=H65Ia5k/Ds0mZq03qGQgA/J2MPSfWXgcGK/pLMJyKrpjoFTY9aGhcMCZc1HKhJ1V8wPrGk2X5x4j3n+H+qnFUPWMkNvHI7SdMhUTAkxwrVhkSOkcWJCQApOf/Xomx4E/q06KqjP+wuiJLt6YcatPH4SsssmqRqA0HAHeYMwHaF8= 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=cTrLyX/T; arc=none smtp.client-ip=209.85.210.41 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="cTrLyX/T" Received: by mail-ot1-f41.google.com with SMTP id 46e09a7af769-72c47631b4cso193852a34.1; Thu, 03 Jul 2025 11:50:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751568651; x=1752173451; 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=wgKTg4/Nk6wm5J+WL43f3KfjMbT1HMf3Vkuk3EBDHmU=; b=cTrLyX/Tbs89Rpf3SvB/1q3aaP8L0eO+9h+B6fsgho2tUU7wWtEw5our7cO4lVp3xp nozG2ib6Hg2qDUk6+jGxYBJW7zWexzD9A5GN1B4eCfCGdgnEhsc/oOaX9KKvT/IFciDj eUPKxE1u4Nwt/fc+6W14YtOkoKDsoW5ZfdsbeNYLFzSaop6lgjm36mJBMgEDTE2aETG9 WjcBpn6gieiqSryLNYq6WSwYS08VSZERLv7QOy1ngLo67PyDI31GY1yHYOZJqdQQZfTQ 9NpxiQnuvirSdGrAknKf00lrF4Dk1Fnrv/28vmix4wd8yGme/TJ8+2GZMQWUuFTRInDn DPIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751568651; x=1752173451; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=wgKTg4/Nk6wm5J+WL43f3KfjMbT1HMf3Vkuk3EBDHmU=; b=PM8Pmh8PSCAsMj27UhtOELTy+CSeVOD5pX3qVLLM7d+820hC8ySlGv4xKdSMQVRQ/m DQTmJCL6aBwhlrmGWxyDewrNeWncV2cA20a8R/M9Fb55QmtGxusFE80vflghURYS0BAf RdQIlCPSJ139MHqwb4isoQsEFXOPdllHjQz9mKLLnup1ZTU+6gohIZBVrrSdiXg2h8zI wW/W7uemEdz8j8NCOKdyAsXAYk5PMr7c6CFOnYLJYeyvRJVLXrdrCEJtabBt02MBUz+X A3Wx+HFe7OvojwZ9VHkeZI8/H8OuOhWA8OZgKmVxesXx0D18fe+3YsThKhCBtGr6BGrd PpfA== X-Forwarded-Encrypted: i=1; AJvYcCVkpy6IrkX6r9JgPAZDfZw50YbFJUb2ttNhs2omI4Slw8p9lc/O87wg3FousmF/5rldvNpOek0J55NjODpL@vger.kernel.org, AJvYcCX5ZUxCTLByS+sGtAD4mYzObaBdNg2IFJbqcjg3D31oo3YRMr15+jb7MLiH+5toJHEE/rcW1A6kcytpMCffXw==@vger.kernel.org, AJvYcCXJwIm2xjFkvy9JvAYjcsnjWKhKbrHDbI2ptmrD2B/R77BydUSpA+AeHDV6Q5ZQocMH5HLqXl5anCZ5@vger.kernel.org, AJvYcCXyOdcunEjBfZVAvZC7MgHFJ5SEYrNcgZdX+xKOyoMW6D8iGD+ssW4W0n1+1OTdVOiucWDBBLcl9As=@vger.kernel.org X-Gm-Message-State: AOJu0YziLrRIMaM8jOT7IZxF6BfoFHlzmlaTeqYBc/lrH/7F3dl4qti3 iXXOyfsUrdSOIcn/5qX7Bulz9sn9VMxWaulhlnEJFcWNJqhkx1LvNLrp X-Gm-Gg: ASbGncuAh/dEiaLqFSH/A0/8binC2q36lT4e0fOdqSiNhdlEEp+CIeIk42iEdA12G94 lWwrrmphTEtxKiVUavJSmWDKp0RkyCCBTF+NODNmjVOtjbPHESeNfadPADTOMbwk7Bi+l8eTVp3 6fZySz+3HwxCNPCkd2a75Mz+BjZTXRuJEn2lfrIO/m6KPhnCOuDiX5+hBV9u60oK9UUjosXRzs8 Y2PFXMiSbwRfGa00qRNh9Vb8bqjDI8+RxWegLolWj9nw0h8wWJXugQ2gq3JfN+OwRvNolWDUxZ9 i+JJk8dmETc8gqFsYRwXGsVPJlbYNaXAxO53kT+X5bkPtmw9Tm5El4IADP35sAH6zDCeBrworjj eJjRMwmz0pZ8WSqpiY4ukNMd7 X-Google-Smtp-Source: AGHT+IGNEYE8azkCu6i4tdt/Jh/JzWWu2d955CfMIRLR2kAADDQEL7D+pI5ll8ogxoQ3Xa3+A+d+Cg== X-Received: by 2002:a05:6830:3c8d:b0:739:fcb4:db17 with SMTP id 46e09a7af769-73b4cb2f25amr6347478a34.15.1751568650976; Thu, 03 Jul 2025 11:50:50 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:cd4:2776:8c4a:3597]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-73c9f90d1ccsm68195a34.44.2025.07.03.11.50.48 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 03 Jul 2025 11:50:49 -0700 (PDT) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Dan Williams , Miklos Szeredi , Bernd Schubert Cc: John Groves , Jonathan Corbet , Vishal Verma , Dave Jiang , Matthew Wilcox , Jan Kara , Alexander Viro , Christian Brauner , "Darrick J . Wong" , Randy Dunlap , Jeff Layton , Kent Overstreet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, Amir Goldstein , Jonathan Cameron , Stefan Hajnoczi , Joanne Koong , Josef Bacik , Aravind Ramesh , Ajay Joshi , John Groves Subject: [RFC V2 04/18] dev_dax_iomap: Add dax_operations for use by fs-dax on devdax Date: Thu, 3 Jul 2025 13:50:18 -0500 Message-Id: <20250703185032.46568-5-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250703185032.46568-1-john@groves.net> References: <20250703185032.46568-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" Notes about this commit: * These methods are based on pmem_dax_ops from drivers/nvdimm/pmem.c * dev_dax_direct_access() is returns the hpa, pfn and kva. The kva was newly stored as dev_dax->virt_addr by dev_dax_probe(). * The hpa/pfn are used for mmap (dax_iomap_fault()), and the kva is used for read/write (dax_iomap_rw()) * dev_dax_recovery_write() and dev_dax_zero_page_range() have not been tested yet. I'm looking for suggestions as to how to test those. Signed-off-by: John Groves --- drivers/dax/bus.c | 120 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 115 insertions(+), 5 deletions(-) diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c index 9d9a4ae7bbc0..61a8d1b3c07a 100644 --- a/drivers/dax/bus.c +++ b/drivers/dax/bus.c @@ -7,6 +7,10 @@ #include #include #include +#include +#include +#include +#include #include "dax-private.h" #include "bus.h" =20 @@ -1441,6 +1445,105 @@ __weak phys_addr_t dax_pgoff_to_phys(struct dev_dax= *dev_dax, pgoff_t pgoff, } EXPORT_SYMBOL_GPL(dax_pgoff_to_phys); =20 +#if IS_ENABLED(CONFIG_DEV_DAX_IOMAP) + +static void write_dax(void *pmem_addr, struct page *page, + unsigned int off, unsigned int len) +{ + unsigned int chunk; + void *mem; + + while (len) { + mem =3D kmap_local_page(page); + chunk =3D min_t(unsigned int, len, PAGE_SIZE - off); + memcpy_flushcache(pmem_addr, mem + off, chunk); + kunmap_local(mem); + len -=3D chunk; + off =3D 0; + page++; + pmem_addr +=3D chunk; + } +} + +static long __dev_dax_direct_access(struct dax_device *dax_dev, pgoff_t pg= off, + long nr_pages, enum dax_access_mode mode, void **kaddr, + pfn_t *pfn) +{ + struct dev_dax *dev_dax =3D dax_get_private(dax_dev); + size_t size =3D nr_pages << PAGE_SHIFT; + size_t offset =3D pgoff << PAGE_SHIFT; + void *virt_addr =3D dev_dax->virt_addr + offset; + u64 flags =3D PFN_DEV|PFN_MAP; + phys_addr_t phys; + pfn_t local_pfn; + size_t dax_size; + + WARN_ON(!dev_dax->virt_addr); + + if (down_read_interruptible(&dax_dev_rwsem)) + return 0; /* no valid data since we were killed */ + dax_size =3D dev_dax_size(dev_dax); + up_read(&dax_dev_rwsem); + + phys =3D dax_pgoff_to_phys(dev_dax, pgoff, nr_pages << PAGE_SHIFT); + + if (kaddr) + *kaddr =3D virt_addr; + + local_pfn =3D phys_to_pfn_t(phys, flags); /* are flags correct? */ + if (pfn) + *pfn =3D local_pfn; + + /* This the valid size at the specified address */ + return PHYS_PFN(min_t(size_t, size, dax_size - offset)); +} + +static int dev_dax_zero_page_range(struct dax_device *dax_dev, pgoff_t pgo= ff, + size_t nr_pages) +{ + long resid =3D nr_pages << PAGE_SHIFT; + long offset =3D pgoff << PAGE_SHIFT; + + /* Break into one write per dax region */ + while (resid > 0) { + void *kaddr; + pgoff_t poff =3D offset >> PAGE_SHIFT; + long len =3D __dev_dax_direct_access(dax_dev, poff, + nr_pages, DAX_ACCESS, &kaddr, NULL); + len =3D min_t(long, len, PAGE_SIZE); + write_dax(kaddr, ZERO_PAGE(0), offset, len); + + offset +=3D len; + resid -=3D len; + } + return 0; +} + +static long dev_dax_direct_access(struct dax_device *dax_dev, + pgoff_t pgoff, long nr_pages, enum dax_access_mode mode, + void **kaddr, pfn_t *pfn) +{ + return __dev_dax_direct_access(dax_dev, pgoff, nr_pages, mode, kaddr, pfn= ); +} + +static size_t dev_dax_recovery_write(struct dax_device *dax_dev, pgoff_t p= goff, + void *addr, size_t bytes, struct iov_iter *i) +{ + size_t off; + + off =3D offset_in_page(addr); + + return _copy_from_iter_flushcache(addr, bytes, i); +} + +static const struct dax_operations dev_dax_ops =3D { + .direct_access =3D dev_dax_direct_access, + .zero_page_range =3D dev_dax_zero_page_range, + .recovery_write =3D dev_dax_recovery_write, +}; + +#endif /* IS_ENABLED(CONFIG_DEV_DAX_IOMAP) */ + static struct dev_dax *__devm_create_dev_dax(struct dev_dax_data *data) { struct dax_region *dax_region =3D data->dax_region; @@ -1496,11 +1599,18 @@ static struct dev_dax *__devm_create_dev_dax(struct= dev_dax_data *data) } } =20 - /* - * No dax_operations since there is no access to this device outside of - * mmap of the resulting character device. - */ - dax_dev =3D alloc_dax(dev_dax, NULL); + if (IS_ENABLED(CONFIG_DEV_DAX_IOMAP)) + /* holder_ops currently populated separately in a slightly + * hacky way + */ + dax_dev =3D alloc_dax(dev_dax, &dev_dax_ops); + else + /* + * No dax_operations since there is no access to this device + * outside of mmap of the resulting character device. + */ + dax_dev =3D alloc_dax(dev_dax, NULL); + if (IS_ERR(dax_dev)) { rc =3D PTR_ERR(dax_dev); goto err_alloc_dax; --=20 2.49.0 From nobody Wed Oct 8 00:27:10 2025 Received: from mail-ot1-f51.google.com (mail-ot1-f51.google.com [209.85.210.51]) (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 1C3BD2F4327; Thu, 3 Jul 2025 18:50:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751568656; cv=none; b=KmYMSL10K4JIzgLjmdUKpu2iDXeAatpunwUoEY6OHRG3YBdMAY6owwVPTAy0gGWn7RMVAF5+uRGegsmNLryrXN+SJNjpjtMaBTATBZeRBoCYO702XkH/jpFz1+RZnkwmHSuHdD4SNbUAduUgmRjUmyBKlK+ZxBeA1VRX7Ep3LrY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751568656; c=relaxed/simple; bh=3KazfK/QQTaTKMCPWi0YxDdEC7X6OVxJtOIOm2yyTcs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kmGX0u94mV4QPwkWnbJAKBdiR+7pgC4RZuVoJvnSPxvP7ohxnorWsXmQw8JXKSnRugIgSuZnO7lplwMK5eWwfDmhjve2qEwNlOhKvDOujVlKIYQivo6iwlc01FvbE5av0mobRQuuPOTqZCkz1xRqAzpSWdg4E26YBHbIzFKtCTY= 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=BpXvOiW2; arc=none smtp.client-ip=209.85.210.51 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="BpXvOiW2" Received: by mail-ot1-f51.google.com with SMTP id 46e09a7af769-7382ffcb373so158586a34.0; Thu, 03 Jul 2025 11:50:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751568654; x=1752173454; 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=PaZvyCikUvPqtnjUjM92+A61XpmMjGb4Ba8q0a5FCxQ=; b=BpXvOiW2YfI5BrKVWmJ4j3ntBBMS0BBWEomgtyOZrTi3uRmqCtkz4Pt2AEIDWzQbc1 hhOS5RgCKHIprUxXQDAgEpKasHfEUV0e74NUQdjcC2iP2pIjVb5IXEO1nB9Zyk/mdZBj UFYOmZM4bOy6jUc+595OL2qLts1cSqu6qSc4gmNgCW3rTbBjCdkQxovLOzf8mh6Xgk2c xmkctnLBNcV1grRv1EdUabA8p9tP9nHYT0AyVecvSirdusnML6EqYGLEjgDBP4HCbsfm BZdwB3zge7l+Tsihi5E6LtrfCZGdbI2532D8LnzHFGlk0swmNigz6wzYmyEzY5qJeesj 49hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751568654; x=1752173454; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=PaZvyCikUvPqtnjUjM92+A61XpmMjGb4Ba8q0a5FCxQ=; b=cXdFvRti6Qs2ZLpKfOoibSDXfZmsghQPU6Nb+ajoRwARoH4emr4brWSPl5IaGonKCj Se28m7N/lC0fOhH0zvAY5qd3BcZYlVh9+mgUhezkFNGBbR+s6XPMi1vvfSWUebCDKG3J tXp5FC45k5734XMJpuDO7bTzxXWMKIBM6ZaYbQtc/RG8bBcHsqEpsD5t2XHiy4Wd8d82 TOa5y30MFBaHypWUQfTo3XXS/xtkgUu38F/CVa/Md6zuR/AeczDhhW/Ewgvzhw2Irdl6 BkCcpi3IM6WRZU83N3dUbR8HDmS67k1T9ad3CJYRs32j1RvBRTTbpm+uWrC1S78hcWAt ekrA== X-Forwarded-Encrypted: i=1; AJvYcCWtg5RwpES+I5DcnrfIzfJ0D8nRZUAcf3LCZzIGn+8RZ0OA0QdalNSMsySvstyffY2r4H0Kn9ZOYD0=@vger.kernel.org, AJvYcCWw+bK1I/5CrDkIiXu8FGwN44rjhj0Iv/hAh+IYES4NmU5Ke2Hf+K0wzPSKPENmC4wq2no0PG4xlOSqQn8L9Q==@vger.kernel.org, AJvYcCX4jB+cCMAfBck18dzLIxLZPweCHyZgXrQ6X/GESVKqxcJreSh9ebE79PZDRsgWkmwy3Dfb8Q0mcSpk@vger.kernel.org, AJvYcCXbcv0LRHtWyYpXKaiaTHprjjyC+Xcdqrm/CSMZQ4Rag3NDGJ+LtZSL5zx9132ec7XLZ4gvapkv6W004O/2@vger.kernel.org X-Gm-Message-State: AOJu0YyZg4sZ3MkC4EZBvT5WFWZNDCCKvrfBleoHsjlfIr+48tU5S21o 1LoAiZntpVtZ9RG6tCBujLlVk4RHKqni4lxLGVHNVZ65P+1p8md9U70D X-Gm-Gg: ASbGncvHoGfKAEqTmS/zIfywi3fdZYDcwlqsrSNbsown8OyQBcVHY5VpkBuARXt+I0O ixA/TKSwA86I8C/Zk7qcMDT4tGuFlC6apyCTI8mRChGC+oNtm7eE+MiPR3F8zmylBFDd2lv0d+O BseBYTtCKUadO9XR/NwAr3vaAAFHkybevW0Fduwm8AA2TrUbZ7HJ5JAv0GFJ2jftY89cQBNM1C6 hEmegrMdXCvhnxMZjXTF8Ye474WIGLcaTKjuMKW9P3d6joMA0UEBmLaJfqQGX6rMeqcJtkqG5Q9 K1kwmglXYQaAtL/WsK2yMUtfH84h5w/A1ppDd7KP7S7zhzpd2rQ/8xO/Xl3cL5joZQmslmIzcBL cZWbdQPubHcFV1A== X-Google-Smtp-Source: AGHT+IG1W2DMSfl06LORBDysLa+UgwkOnJVfP99hi5suwjrNBfuyFXSpDfxUXAAn0IKIrMiIDsFKRg== X-Received: by 2002:a05:6830:f8b:b0:73b:2c88:8ec3 with SMTP id 46e09a7af769-73c8c5d0bccmr3217610a34.27.1751568654018; Thu, 03 Jul 2025 11:50:54 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:cd4:2776:8c4a:3597]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-73c9f90d1ccsm68195a34.44.2025.07.03.11.50.52 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 03 Jul 2025 11:50:53 -0700 (PDT) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Dan Williams , Miklos Szeredi , Bernd Schubert Cc: John Groves , Jonathan Corbet , Vishal Verma , Dave Jiang , Matthew Wilcox , Jan Kara , Alexander Viro , Christian Brauner , "Darrick J . Wong" , Randy Dunlap , Jeff Layton , Kent Overstreet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, Amir Goldstein , Jonathan Cameron , Stefan Hajnoczi , Joanne Koong , Josef Bacik , Aravind Ramesh , Ajay Joshi , John Groves Subject: [RFC V2 05/18] dev_dax_iomap: export dax_dev_get() Date: Thu, 3 Jul 2025 13:50:19 -0500 Message-Id: <20250703185032.46568-6-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250703185032.46568-1-john@groves.net> References: <20250703185032.46568-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" famfs needs access to dev_dax_get() Signed-off-by: John Groves --- drivers/dax/super.c | 3 ++- include/linux/dax.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/dax/super.c b/drivers/dax/super.c index 48bab9b5f341..033fd841c2bb 100644 --- a/drivers/dax/super.c +++ b/drivers/dax/super.c @@ -452,7 +452,7 @@ static int dax_set(struct inode *inode, void *data) return 0; } =20 -static struct dax_device *dax_dev_get(dev_t devt) +struct dax_device *dax_dev_get(dev_t devt) { struct dax_device *dax_dev; struct inode *inode; @@ -475,6 +475,7 @@ static struct dax_device *dax_dev_get(dev_t devt) =20 return dax_dev; } +EXPORT_SYMBOL_GPL(dax_dev_get); =20 struct dax_device *alloc_dax(void *private, const struct dax_operations *o= ps) { diff --git a/include/linux/dax.h b/include/linux/dax.h index 86bf5922f1b0..c7bf03535b52 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -55,6 +55,7 @@ struct dax_device *alloc_dax(void *private, const struct = dax_operations *ops); #if IS_ENABLED(CONFIG_DEV_DAX_IOMAP) int fs_dax_get(struct dax_device *dax_dev, void *holder, const struct dax_= holder_operations *hops); struct dax_device *inode_dax(struct inode *inode); +struct dax_device *dax_dev_get(dev_t devt); #endif void *dax_holder(struct dax_device *dax_dev); void put_dax(struct dax_device *dax_dev); --=20 2.49.0 From nobody Wed Oct 8 00:27:10 2025 Received: from mail-ot1-f52.google.com (mail-ot1-f52.google.com [209.85.210.52]) (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 941852F49FD; Thu, 3 Jul 2025 18:50:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751568659; cv=none; b=ub6TJo29RQEaUVRp0mMKLlXEp5FlFL5bHEKMJFWDV1NFFQY7qOzRxqQnA8hM6ctq5oqHnc7fBsHlU82MdD1R69oMOsmLuzWIAdg+IuzzIrXS2sSx7gxzw5qxxOKMW72X4HN0P7UiRaECCf+z9Xhor/uIqPT01R+Y6blQFCBItk8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751568659; c=relaxed/simple; bh=9z/0+wP63OG5wXftLWkn27sSwdysRUwo3gRSnRSt66U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HMWHow8dL7Nns5Egqc9qxNYMqzqLi8nKN7iEixXOKWjvWA/RYBEefjJFywYdvMRcwkC77AMdRm4rkDY/Uf4ha/02ficMGrDV5czWfjbL2KyoTgKwmQx19TFqhJuZEXUlZWGNb8IdAw+o/yh5O1Ui/Zx2TZAJMLJV0p2k+u2k6jk= 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=g38Tbq8g; arc=none smtp.client-ip=209.85.210.52 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="g38Tbq8g" Received: by mail-ot1-f52.google.com with SMTP id 46e09a7af769-72c14138668so96510a34.2; Thu, 03 Jul 2025 11:50:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751568657; x=1752173457; 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=jHFHSP5AI7GYN3LviveRts2reQTV/UFJRypYogMzU4M=; b=g38Tbq8ghEAz5EJUZcKjNtNc0Icf/uHsp9c6BNxz+M6RxENGeXEjELrK132DVLXqg5 Dr0DAtXqXnblS/FqCn0mFgyJ2eLeFyUWf0aZXZ08kFpvFrHf1CnAK0w5Yf3FSVYQzvSk 9q63gAei5QC5/r3DNJWlP+SvU7CFJ17S+FhXUE8K/VdPfOY93QY0gGZRXExDkH9W9lqK PHhAYcpNv9EcjpbpJ7FBwwnk+7Srl69syHAI8sqZePft+9VFLrV/lg5a1NDftGOXS1Td tmBvND2MeveghiMdlH/QU+cIwopYhsXdBTQJaV7hDdIr7G99+FMrftneyijxuraM4n3T IzUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751568657; x=1752173457; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=jHFHSP5AI7GYN3LviveRts2reQTV/UFJRypYogMzU4M=; b=Z4LeIfY0tif3q115ulVOuwnS7R2B1Df857zxLLPzMDkzIRKhwtbIhe07tqd1MYSUg0 SjxKSgjrEy8xvk4vkoID3pRua/+BJ8d1tNhDgyjCg4Bh4EFfffGDTmLCDvNU0LA2sOjt N/eHHHMMzOo6mjyfh/qkyprXlVoUckCVraGyKM41NeUUCo2adYzEz/EcGVW6PBvy3zA4 LrjipHD2HsZd+R+DCvOCBVmVCE6ow09dbZvmnd8cHmmaOUlC2MPfhP9XQvAaLU7FWeKV tLlrP5U4zZgDaU7PAusf+Q3AenQ24q/Ck1tw6WlaOFDHEb9fStaVkYCpgtFxKzuZUIQ/ YCNg== X-Forwarded-Encrypted: i=1; AJvYcCUXTiUIFVJfydTfeR2shBPwUoaMjYGUI1v8Lsy+ptBsOh3/UmwGuMErBmTOgLGI7vLIAF70LzCXSVJpk1xkqw==@vger.kernel.org, AJvYcCUnKlb4EA1BkR+HoEsxSh6LpCRer2kUd7T9+9t+AasOae8k6dqaih2c3LNEsFiwGeYJC4jTLtei/AXv@vger.kernel.org, AJvYcCV7fQX08uNm/o51Iq3REzZkUw2YynN/MiNV5eecPJjVozxHszABjZSEbz5yCFqXx1WdDWAVYBF+WR+or1pI@vger.kernel.org, AJvYcCXusgD9Wgpe2ei7aIF2tCctS9EOx7OteJbZI3vXTDUcAoQ0MKLUYg9qcwS1k+apGCvpOXE99mPcNzw=@vger.kernel.org X-Gm-Message-State: AOJu0Yxm8MujzIX2m6E4I5gY/LkhBIdX1HcZ8pCLSs8Uz+x4YQ0c2DTf lVZM3Gdc2//TIxhWfhOEyTbGLMZMeQh4IglOXOYMW6KLsRyKAfGXU6xV X-Gm-Gg: ASbGncs7hm3nZfCsZPWcSF8R5fLDm9mXFQDcYOTI1XtTP62cVMI3ETG56so2FOMWe0Y H5tOe/RAYWqcHMQRZHJqIs/LqxZA/T+o9JXkrs8ylkUgpaMUq4+BimMUNh0wNOIOJPlInJZK3aC X3FSQTgKpFKjU2SeSNeitgukwHLz9iVldLn/lG2tNJZWEOUDKwnHyM4zu4VK7mC3J8MU6/2NRXt 6DHIoYNuk2ohMHhOKQolw4L0w1MCupyPMWBn6EcIPy/JCmaQQ8vmhTnPVtTeuV/ZLFmaTYIO9A5 gHvJw9bo0mFW19yzMZ/IRc1IXJOQPAeDpbnyIhV9CRD2vZ7BVgGYauCgkqJRicB14v2T6z2Dr+n AaQ+S2oz57Mi9jw== X-Google-Smtp-Source: AGHT+IF0yW0ffG1FgWh4UvPzdITwKwUQUwagTaujR+MOBNLBlFUmukcBu+glnTJT7fKxI7YS3bMYPA== X-Received: by 2002:a05:6830:440b:b0:72a:11aa:6ebd with SMTP id 46e09a7af769-73c897e113dmr3275732a34.23.1751568656688; Thu, 03 Jul 2025 11:50:56 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:cd4:2776:8c4a:3597]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-73c9f90d1ccsm68195a34.44.2025.07.03.11.50.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 03 Jul 2025 11:50:56 -0700 (PDT) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Dan Williams , Miklos Szeredi , Bernd Schubert Cc: John Groves , Jonathan Corbet , Vishal Verma , Dave Jiang , Matthew Wilcox , Jan Kara , Alexander Viro , Christian Brauner , "Darrick J . Wong" , Randy Dunlap , Jeff Layton , Kent Overstreet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, Amir Goldstein , Jonathan Cameron , Stefan Hajnoczi , Joanne Koong , Josef Bacik , Aravind Ramesh , Ajay Joshi , John Groves Subject: [RFC V2 06/18] dev_dax_iomap: (ignore!) Drop poisoned page warning in fs/dax.c Date: Thu, 3 Jul 2025 13:50:20 -0500 Message-Id: <20250703185032.46568-7-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250703185032.46568-1-john@groves.net> References: <20250703185032.46568-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" This just works around a the "poisoned page" warning that will be properly fixed in a future version of this patch set. Please ignore for the moment. Signed-off-by: John Groves --- fs/dax.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/dax.c b/fs/dax.c index 21b47402b3dc..635937593d5e 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -369,7 +369,6 @@ static void dax_associate_entry(void *entry, struct add= ress_space *mapping, if (shared) { dax_page_share_get(page); } else { - WARN_ON_ONCE(page->mapping); page->mapping =3D mapping; page->index =3D index + i++; } --=20 2.49.0 From nobody Wed Oct 8 00:27:10 2025 Received: from mail-oa1-f53.google.com (mail-oa1-f53.google.com [209.85.160.53]) (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 9F4642F271A; Thu, 3 Jul 2025 18:51:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751568662; cv=none; b=mBiyGVhoqJA7m3TqYl6/qh8p16YJWzKS6Mo+HowCJ4OTELFtZ3dhl6biUbp0VWZuFkTIweAoo8031YzAVmPJp4UVrqhJnQDYDwAgijd/NPeAo/5irgetK6+eslXoEpfgqLJO5Xla/cofJ07WCsNXXZD7jP/PJEPvOiBq32+NYdk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751568662; c=relaxed/simple; bh=i2RCOjAti+UF5LQ1PHdINLhvfnaWKUaVeHHuyTJYyzc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SlND5VbbWuGOyiX2UNyG9hLU0NtTCJmApwOdipa+unUtwZwky4nTRwJ4Pmrnj4Hm6iK8Hifo1lNMVXzCIDJfsfuTUSrCVpwC//YzCmnMNTh9joIwwQj5cyx2S+pN4B4l3RSAczuh66znWsxfn7iJlA2fIziwVE6pL7BT6CuGIiA= 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=EyMzbUpe; arc=none smtp.client-ip=209.85.160.53 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="EyMzbUpe" Received: by mail-oa1-f53.google.com with SMTP id 586e51a60fabf-2ea58f008e9so278691fac.0; Thu, 03 Jul 2025 11:51:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751568660; x=1752173460; 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=s2xZpjaui5XzSxxh0Gj0eCk++fJOkriDnBX6FJshI1g=; b=EyMzbUpeuNlVa0TWNpunez4Re03nlVbjXKe/0CzftYiPEF4ZDyD2t8OyUKPfXzgORD vQ6wxJT8T7Ci399Ss+hPFFuT9YDrpaRuRVRggCrfF/sfLPMf8QiU9XLekZAMRJoRaJnW kZz7riQ9JTuv9qBxCTQgfdgBQBA8Hd79Jg2bDVjsPXjdxsE25mPTgBeELG5mFvxOAp7c iXEKaG1f+VS5SYzvm+q4rZ7SPI2QHrzrkLtitSNR1f9mRH6oqD1BradSnQgiyrFCEI+G I1WbkRDLuio8yxMRPs6XaVPwKCeYKHasEVJ5nOWA3Ck4nmdy7J2jeCVHikjKOeyJtmAS L9GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751568660; x=1752173460; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=s2xZpjaui5XzSxxh0Gj0eCk++fJOkriDnBX6FJshI1g=; b=AxBApliwSIAkwNpYGFTmULck+nKW4OPppvjQnA/nMWl84uNGIJ2q8zVQbuz+BV+9YQ 6fz6vfdgm0lILT/Ei1f0kf9AiWq8ho5+0lXbUcOvRp9zR7TEunvtrWJ4iB10ssWbsUAx yP8W7P1062zOA3+C9S0fS/jDfJLF1ppNAX3OKAj5FeavMAA4HnG2hu5QZfiekLqCtl1D 9REcGcJ2OTLLDRGL52Ao70tUVPkXXg/AZYHCN6lIDvErxPKoPyNy2Caj3TDVugW/ca+A WCG3px7aLvhZ8dU9IDUZFvTFJ7ibiCB5q1w6mgcLj4TPg1lLUR5lKO8h8L92lplyFQio xSKQ== X-Forwarded-Encrypted: i=1; AJvYcCUEywq2IuB0c3tF/FNNQR+uyArQX5WmjSdKh12lJhS+yXGuHwLxdk0pHTEPa3uEHPy+oRY46Dz7MHQ=@vger.kernel.org, AJvYcCV1TJZ3x1dvAboRKOsPZ4XHsaZrjluEFHG2jn3xRXC//TnGYOcqNrGrbIovrg7klNiUDsa7t1e3V4jSfpYc@vger.kernel.org, AJvYcCWK3WY+2cEPGj0pTEPWGk1o00hdOkVzLRliQ57d7e2GV0ZCy4bYc8HvA6KpHUpaZzzrX7aYZFIKtCLY@vger.kernel.org, AJvYcCXbrV2dRGLJfMEO/cmM0sz8lcsbyzumNDrnj1yWVaNq2r2UVJYCVfCrjADNsm4CYdEccqqN/wxPEnpbNuDwXw==@vger.kernel.org X-Gm-Message-State: AOJu0YzSjW25+P0OM9C3P8CiutWYvbwTayr1Ep4SUL+Jued7c7S2Hd4f 83zZhaBtyyfyUGbXIKO5JK4rC+Nfmrh/Q6vD6UX8G0wlcKNGgrZ2Ruaa X-Gm-Gg: ASbGncuU71kWIOKi5z9u/bF8f2hWxkN6ln4r0cYEOaZFDfXXGBOr7sRgpKrvg5+vL0Q 140mT4YQAmEzzVgAToT2exApFuRdGQFRMFkO8/KNNH0eYfH6q3IZudtkTsEBIE7WtoyxwLdqXTu 4CRtxxo8G4BSMvUzLzWP07u7uNqgBvrduGdENcuisR0LRw+ZHraHVrLisgLRdhiMzv8oNoNSKmM 0WvNSwLDoOWs2pBfLPsOOys7Fgsd3jdb4+057BptQB1XdSovtHojaBg9xyoN3YZzq1Z259hDg5s JddbgjY56SkzHj1/l9MI9LeCftOFdji7lsUFJXhthTUZmSFAFQZCgrzPH72i0eecph/NpgP7WNt A0j1Hk3eusEG6hQ== X-Google-Smtp-Source: AGHT+IFWojQvKP3cIpPU0Ex4gOP0RyReOaJ9oJ//8+DQ1D2UxOY6HF2XKVzeow4Q9s0j3FT7ZnZiXw== X-Received: by 2002:a05:6870:b201:b0:2f3:e087:6b08 with SMTP id 586e51a60fabf-2f5a8b9022bmr6076525fac.24.1751568659637; Thu, 03 Jul 2025 11:50:59 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:cd4:2776:8c4a:3597]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-73c9f90d1ccsm68195a34.44.2025.07.03.11.50.57 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 03 Jul 2025 11:50:59 -0700 (PDT) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Dan Williams , Miklos Szeredi , Bernd Schubert Cc: John Groves , Jonathan Corbet , Vishal Verma , Dave Jiang , Matthew Wilcox , Jan Kara , Alexander Viro , Christian Brauner , "Darrick J . Wong" , Randy Dunlap , Jeff Layton , Kent Overstreet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, Amir Goldstein , Jonathan Cameron , Stefan Hajnoczi , Joanne Koong , Josef Bacik , Aravind Ramesh , Ajay Joshi , John Groves Subject: [RFC V2 07/18] famfs_fuse: magic.h: Add famfs magic numbers Date: Thu, 3 Jul 2025 13:50:21 -0500 Message-Id: <20250703185032.46568-8-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250703185032.46568-1-john@groves.net> References: <20250703185032.46568-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" Famfs distinguishes between its on-media and in-memory superblocks Signed-off-by: John Groves --- include/uapi/linux/magic.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h index bb575f3ab45e..ee497665d8d7 100644 --- a/include/uapi/linux/magic.h +++ b/include/uapi/linux/magic.h @@ -38,6 +38,8 @@ #define OVERLAYFS_SUPER_MAGIC 0x794c7630 #define FUSE_SUPER_MAGIC 0x65735546 #define BCACHEFS_SUPER_MAGIC 0xca451a4e +#define FAMFS_SUPER_MAGIC 0x87b282ff +#define FAMFS_STATFS_MAGIC 0x87b282fd =20 #define MINIX_SUPER_MAGIC 0x137F /* minix v1 fs, 14 char names */ #define MINIX_SUPER_MAGIC2 0x138F /* minix v1 fs, 30 char names */ --=20 2.49.0 From nobody Wed Oct 8 00:27:10 2025 Received: from mail-ot1-f43.google.com (mail-ot1-f43.google.com [209.85.210.43]) (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 ED4822F5323; Thu, 3 Jul 2025 18:51:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751568666; cv=none; b=EmjHOOt3CGhg462W8laQbPjji2D4R7d5Y+unVoknj73lNHnyn4WZzw7mrk5zU+RkvW7FmPQW35Mst8igOxNn2EfLcq9F8+BglxDmTr195eVSJNkmKU1rp3E57LjYfV/0FLt/6O412l7oiIe13vsneyxjAQ9y7gC3/1mZKeEyPhU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751568666; c=relaxed/simple; bh=kGGXBghV4lzKmeRVN+j+pfeJiQeXOVHeL7W4dyeFZvE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ekUuHTLeBSfYbXWPlqeZNQ/o/eerzP9oWIVHsT1P/C5KNQvMd+dJe1uf9dDhSapws8ruBlSnBnn2rqnUVxI0BP1BOAaR2QwVEIv6gOw5YChLwcCEU+32K9eqaJWrC0jdmiDNPBZ2xQ7cgnhjb2kEMc5UZE4I/I7H4iSWW4cOMBY= 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=mQDg/Gfq; arc=none smtp.client-ip=209.85.210.43 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="mQDg/Gfq" Received: by mail-ot1-f43.google.com with SMTP id 46e09a7af769-735b2699d5dso153399a34.0; Thu, 03 Jul 2025 11:51:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751568663; x=1752173463; 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=b/+tFl2/Decgi2IQHespB0RF7ZlGK7hVUQHMC/s+Z0A=; b=mQDg/Gfq9zg6RN7gx9H6Y+3M3Fit6PdZhemdKA3X4Tg+++XVfYUU493ZTkG/vKQWyS 9od+qPSbfEAS0bnHSL1fXJUPXuzq7mn/82pCFPy/Qle08DNnHP+zMEeiTPDuEXsrAbi8 qEuq/9TFFTj/WEDy74RIYnOe1G2Mt+CLm8W8iYZc9aqQb6MYJd5IJXJoiLqrQdWTcS3o RbHsuhG7yuseuhRLm/RqSkpTFuC/jBR2Xx0O3JZYLZvD+Ru9o7WESHnB+60VXOHfeAfE l3xzeqvsOjN4S4kM/Yq3Nm9qaurXV4O66vE+P9jSA3I4ijgqbGtgDCVAcScxOnFuBjWT Sdpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751568663; x=1752173463; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=b/+tFl2/Decgi2IQHespB0RF7ZlGK7hVUQHMC/s+Z0A=; b=fi/2UA1gjrR9/Nqt9M4NVGTYwHOeMD8SmzX0TrdSNFNG6pieEJEEB/MbC9B7hD4Ryo j6rKliVJFgEJA+mGqpxhzUj0qF8lwrgmc5/Xf+56o/wYTlm+TMxNfQuacPqLEl3imRsW W4YyoR6JclbgsnsG5El0T/NmPZe+h56J0vlcjnJX8t3jOLEcdZVDdzp+Y+Mdmrx4t4LJ 8aIljJ+FyqekPVQdEwJXFsQ7X/ZWYOEONKyn8mzaKT6pXf3xMm/E92+E5znEc+fYuKWs 57fUD6P6ufRzGOhX5dw9Y3cQN16pHtnBQ0Nq+YAvQ/2kwOiOTLDGWtMikt4fGujatZhx fspw== X-Forwarded-Encrypted: i=1; AJvYcCUcM3g8h4Xz6ajfjT7fbFh6JpW/DhAzmPr3Qq5Oy8e6Gh+HIKyPrHeFirwMzZuRS1G/iwzLIyuvuec8NOnj@vger.kernel.org, AJvYcCVCzRBuIGCOkM6fWtKi5BZ4TomLtYvcm3ES1MdzEqzSNWDp9ncCp4zFsXMiqsioozKRiTHmwrmY7+/NSbWEAg==@vger.kernel.org, AJvYcCWW1ZUh/8SFl3PBh7cGL5sZME3Zxd4g9rMnoJ1P8BiE2roBvYiQOktYSmwfkhd4mDEzz/gHy27ZFhKd@vger.kernel.org, AJvYcCWoIDSQedsCvczWyDU08i2arfJBnkC6fepkfvLoX+ixjpKpc5jc5LM7Q+nZdXSsWoY/GRzr9kq0caY=@vger.kernel.org X-Gm-Message-State: AOJu0Yz2+c1FQi3JN+88i5NaKIzF3lIRKO2CYnDxbC/uW9cSqVxs83If CTunc08mG3/6OQDa/fmhMDMjHorVEO2C5dIwJQ9wgOM3AkuunwMR9XoJ X-Gm-Gg: ASbGncuXO226wIS6BBoiZzzxfazPOmwXp0Ii112agQNCHziLM4h+ykQeelSMSJ4uDDR LnxysAWXvTLEnmRC8eW11SSyQYzsktQHbost3xvCoh+F6uJDkEzQniTsDfAsIQoPojDbVUQilgk dyaigopSWyYvjBhOoChjRhwfk4p6nrx42dehJHX7J8ptbOD7huri73bO9ecU14wrZaK3SQsqLQg KtKHJrFZ/OWay0GsS1rKC6td7Xfz8jcls+qGSjWaO6LLl7E0FQ+58HIdgu7N0xXm1rGXBy4RNJY TaVpjQc4iZzD4m7IS6XDXpTY1mW4BnJy4UdtLE9CAF4tSSz3AaT9ITlvbQxrUYX+jfB3I9yS/5U R2kQPzsKqrIW25A== X-Google-Smtp-Source: AGHT+IGO7sODaaFj8dS4msIF49YLoYQDdi+gB7SnaLJLRU0NcABvpJXyxo3DQ89xtl0K0dJU2j4aYw== X-Received: by 2002:a05:6830:630d:b0:73a:6904:1b45 with SMTP id 46e09a7af769-73b4c9c704bmr7359023a34.8.1751568662976; Thu, 03 Jul 2025 11:51:02 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:cd4:2776:8c4a:3597]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-73c9f90d1ccsm68195a34.44.2025.07.03.11.51.00 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 03 Jul 2025 11:51:01 -0700 (PDT) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Dan Williams , Miklos Szeredi , Bernd Schubert Cc: John Groves , Jonathan Corbet , Vishal Verma , Dave Jiang , Matthew Wilcox , Jan Kara , Alexander Viro , Christian Brauner , "Darrick J . Wong" , Randy Dunlap , Jeff Layton , Kent Overstreet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, Amir Goldstein , Jonathan Cameron , Stefan Hajnoczi , Joanne Koong , Josef Bacik , Aravind Ramesh , Ajay Joshi , John Groves Subject: [RFC V2 08/18] famfs_fuse: Kconfig Date: Thu, 3 Jul 2025 13:50:22 -0500 Message-Id: <20250703185032.46568-9-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250703185032.46568-1-john@groves.net> References: <20250703185032.46568-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" Add FUSE_FAMFS_DAX config parameter, to control compilation of famfs within fuse. Signed-off-by: John Groves --- fs/fuse/Kconfig | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/fs/fuse/Kconfig b/fs/fuse/Kconfig index ca215a3cba3e..e6d554f2a21c 100644 --- a/fs/fuse/Kconfig +++ b/fs/fuse/Kconfig @@ -75,3 +75,16 @@ config FUSE_IO_URING =20 If you want to allow fuse server/client communication through io-uring, answer Y + +config FUSE_FAMFS_DAX + bool "FUSE support for fs-dax filesystems backed by devdax" + depends on FUSE_FS + default FUSE_FS + select DEV_DAX_IOMAP + help + This enables the fabric-attached memory file system (famfs), + which enables formatting devdax memory as a file system. Famfs + is primarily intended for scale-out shared access to + disaggregated memory. + + To enable famfs or other fuse/fs-dax file systems, answer Y --=20 2.49.0 From nobody Wed Oct 8 00:27:10 2025 Received: from mail-oa1-f46.google.com (mail-oa1-f46.google.com [209.85.160.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 2E70E2F5321; Thu, 3 Jul 2025 18:51:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751568668; cv=none; b=QSr4wFnTZMD4CIJBp2z8/y2w74FhW6YVTSY90x5p+J6/BCfIHyS3dHeb0GzHk+i3jQF/Rwy6yAuML9P24G/DygpnNEIIog4YOT8APe+dBABJeDEe2L2q+Tq3NvQJ2pXbEKZdTK9bI+4lbXOe6gCThDKab9JOjL6gQJrwjexljZk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751568668; c=relaxed/simple; bh=FwBWWFE2JodQotEAZ09YSPxNok+WslGJ0gzN2M0oH74=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=A+5BejKtFoZvnILbCPq6v6fB44kXAGjX8dnv5uB5cXQqitmL1L4EuEex3gH5s31q6EPZYTqM6ttmuyWYc0S5RcrrUbZZ7N41RaRqqFSbYLivEZ6KSLCDY9BFXNVGZ99AE9/SjSmti3VE84MRjYgkHxuQtaOysfA0Jes7ZzeBALs= 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=Ozd2GKoJ; arc=none smtp.client-ip=209.85.160.46 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="Ozd2GKoJ" Received: by mail-oa1-f46.google.com with SMTP id 586e51a60fabf-2efb0b03e40so112884fac.0; Thu, 03 Jul 2025 11:51:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751568666; x=1752173466; 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=evCDkhJIR08sNUN0+XWT7gI7+J9O9q1SPYxnVNyV/TY=; b=Ozd2GKoJVH8cywxS+UqI2P8BgSxWMJelhUXfCXd2FDA7YI8EPCCUjyKMnwfuEOACbH clt50WP7tcy2zGhz22wQUbVo0chpMX9pnMxgkwecNZgkvum0ETQXKNOFBfsEmUsptE0j Z03pdCn+c+xoVQp6pp1bKHMJc/7rU0ZTB2a7H9NMJMKdVns3WcSY7c+ij/kRqAIfSSQ1 DT5w3l4RNHa904QPIsGTcRv8SDP6uxGQUSembWUnUUXAKxocti9kq5i/uar5YYCa0D7l ZckhevsJ7mPd206d3cyRSZXBB4GgDfUq8QDgDVDhrNtSWU82pdqDZsGZyn9z2FcpmTSe NaBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751568666; x=1752173466; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=evCDkhJIR08sNUN0+XWT7gI7+J9O9q1SPYxnVNyV/TY=; b=b7XS3JVHjbZIVuklEYUbiPW0hgRfZT3uLDrk2WNRLChdX1M6rvNeVpZK6Rm9VLUsH4 KrE4DIR4gKO/qy0LGSgWVtNjRRJB/Hze7zSRZoSiiK3fqBa6YK/dq6WjZqzWRtoZGckr i9t/ftcNEKvLyuGQcfiRzSOVhiHU4D9GHznj3wEj8B3W9Wggv9T2ppQPu6RA4NlEe4K/ /o20jnZzqJe/ZSBt9n8nnEFdounAtGTWIhffiOAdCTw0rS6SVoK/48UqQamQ8KGUWQtO K2Y9th/rq6/B6aqgtgsClr8fKX75YlrALaFItEXzxX2c/iwOYcUBmVbSRXAVe4CEvpHY fkrA== X-Forwarded-Encrypted: i=1; AJvYcCVudaXaMgP/Am1zylI+5cXIFDT4phPp+mPNMrBu61dobaHkARYHbrn0N/hiSrnu55d/YrypTdOC2njx@vger.kernel.org, AJvYcCX439xIPS2BYO2B3ayGHRdXKIvPU4/q29sbRv3Y1sBJ8vOVSXsvxhKvKk5dDXjZAMDZVMpq7wUppmb3nTHmtQ==@vger.kernel.org, AJvYcCX8zyZgfNVi+/zbmbzH6ZOo1/yVe6RT2h5wKhdNilPrBRhpdWfKsQz+8IFVOYRqTwF2BAR2CiM5aNg=@vger.kernel.org, AJvYcCXR6s4srXuwcCp8ymMwBEHi4Twgb0tmIq+Y+ZpFPSJvqfBG+8mC2Cy3BGVJB2HjHxRZIC2seKmc6XfUjVQu@vger.kernel.org X-Gm-Message-State: AOJu0YwtZwXAI9hdtu6uoefgf8GYRBZqqac/aEA05QDBF/dbSD7LFWRi mH4bw2q3Rtfv2/ymFX8nSUw9EwtFdhkmOHXOrfe9/JlOqxQPZIE/eQvE X-Gm-Gg: ASbGncu8pVVz0/gLC3W4rQtecndCCyBTpe08wkCLoX/DXZAP0fDXykNb0VDjBh89KNj SL7fLWjbnvlnWbYH3P6yyYBqJGTw/1rTbiAIfsmZ//W9hKkjCX1jtROCFEznuZFSDxUaSfBPzzF AEWzisyF8s1eizQ9II1p7ESOswIQZ+6ERrueHr4cBMFQC6whYUGS6ipZ9IcXqv5KPR+COZbaoqw IWx/hjDICkUjwoGkk9R6HgyATQLjZ4scPHcod3uKjb0/wOuGrgF7cJ0VctNn6lHk3qja1ksD4US 7ZtSVfxYjzbTKq6LJgSMCqR3SmJfx0ZfIKHzUatlL7jLO1qaf7cvO+7dd7ux01Ok3PMH5HPrfvB 0YiycILeL4qz7gQ== X-Google-Smtp-Source: AGHT+IHyOroDuVjL8bFbm4j8Va1txfDJ2jVi74kI/xcjqq2IUD/Ra3Bu/QoyyOKZVocj62ILUhcOoA== X-Received: by 2002:a05:6870:479b:b0:2ef:de7e:544d with SMTP id 586e51a60fabf-2f5a8cf7e46mr6599486fac.27.1751568666156; Thu, 03 Jul 2025 11:51:06 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:cd4:2776:8c4a:3597]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-73c9f90d1ccsm68195a34.44.2025.07.03.11.51.03 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 03 Jul 2025 11:51:05 -0700 (PDT) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Dan Williams , Miklos Szeredi , Bernd Schubert Cc: John Groves , Jonathan Corbet , Vishal Verma , Dave Jiang , Matthew Wilcox , Jan Kara , Alexander Viro , Christian Brauner , "Darrick J . Wong" , Randy Dunlap , Jeff Layton , Kent Overstreet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, Amir Goldstein , Jonathan Cameron , Stefan Hajnoczi , Joanne Koong , Josef Bacik , Aravind Ramesh , Ajay Joshi , John Groves Subject: [RFC V2 09/18] famfs_fuse: Update macro s/FUSE_IS_DAX/FUSE_IS_VIRTIO_DAX/ Date: Thu, 3 Jul 2025 13:50:23 -0500 Message-Id: <20250703185032.46568-10-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250703185032.46568-1-john@groves.net> References: <20250703185032.46568-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" Virtio_fs now needs to determine if an inode is DAX && not famfs. Signed-off-by: John Groves --- fs/fuse/dir.c | 2 +- fs/fuse/file.c | 13 ++++++++----- fs/fuse/fuse_i.h | 6 +++++- fs/fuse/inode.c | 2 +- fs/fuse/iomode.c | 2 +- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 8f699c67561f..ad8cdf7b864a 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -1939,7 +1939,7 @@ int fuse_do_setattr(struct mnt_idmap *idmap, struct d= entry *dentry, is_truncate =3D true; } =20 - if (FUSE_IS_DAX(inode) && is_truncate) { + if (FUSE_IS_VIRTIO_DAX(fi) && is_truncate) { filemap_invalidate_lock(mapping); fault_blocked =3D true; err =3D fuse_dax_break_layouts(inode, 0, -1); diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 754378dd9f71..93b82660f0c8 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -239,7 +239,7 @@ static int fuse_open(struct inode *inode, struct file *= file) int err; bool is_truncate =3D (file->f_flags & O_TRUNC) && fc->atomic_o_trunc; bool is_wb_truncate =3D is_truncate && fc->writeback_cache; - bool dax_truncate =3D is_truncate && FUSE_IS_DAX(inode); + bool dax_truncate =3D is_truncate && FUSE_IS_VIRTIO_DAX(fi); =20 if (fuse_is_bad(inode)) return -EIO; @@ -1770,11 +1770,12 @@ static ssize_t fuse_file_read_iter(struct kiocb *io= cb, struct iov_iter *to) struct file *file =3D iocb->ki_filp; struct fuse_file *ff =3D file->private_data; struct inode *inode =3D file_inode(file); + struct fuse_inode *fi =3D get_fuse_inode(inode); =20 if (fuse_is_bad(inode)) return -EIO; =20 - if (FUSE_IS_DAX(inode)) + if (FUSE_IS_VIRTIO_DAX(fi)) return fuse_dax_read_iter(iocb, to); =20 /* FOPEN_DIRECT_IO overrides FOPEN_PASSTHROUGH */ @@ -1791,11 +1792,12 @@ static ssize_t fuse_file_write_iter(struct kiocb *i= ocb, struct iov_iter *from) struct file *file =3D iocb->ki_filp; struct fuse_file *ff =3D file->private_data; struct inode *inode =3D file_inode(file); + struct fuse_inode *fi =3D get_fuse_inode(inode); =20 if (fuse_is_bad(inode)) return -EIO; =20 - if (FUSE_IS_DAX(inode)) + if (FUSE_IS_VIRTIO_DAX(fi)) return fuse_dax_write_iter(iocb, from); =20 /* FOPEN_DIRECT_IO overrides FOPEN_PASSTHROUGH */ @@ -2627,10 +2629,11 @@ static int fuse_file_mmap(struct file *file, struct= vm_area_struct *vma) struct fuse_file *ff =3D file->private_data; struct fuse_conn *fc =3D ff->fm->fc; struct inode *inode =3D file_inode(file); + struct fuse_inode *fi =3D get_fuse_inode(inode); int rc; =20 /* DAX mmap is superior to direct_io mmap */ - if (FUSE_IS_DAX(inode)) + if (FUSE_IS_VIRTIO_DAX(fi)) return fuse_dax_mmap(file, vma); =20 /* @@ -3191,7 +3194,7 @@ static long fuse_file_fallocate(struct file *file, in= t mode, loff_t offset, .mode =3D mode }; int err; - bool block_faults =3D FUSE_IS_DAX(inode) && + bool block_faults =3D FUSE_IS_VIRTIO_DAX(fi) && (!(mode & FALLOC_FL_KEEP_SIZE) || (mode & (FALLOC_FL_PUNCH_HOLE | FALLOC_FL_ZERO_RANGE))); =20 diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 2086dac7243b..9d87ac48d724 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -1426,7 +1426,11 @@ void fuse_free_conn(struct fuse_conn *fc); =20 /* dax.c */ =20 -#define FUSE_IS_DAX(inode) (IS_ENABLED(CONFIG_FUSE_DAX) && IS_DAX(inode)) +/* This macro is used by virtio_fs, but now it also needs to filter for + * "not famfs" + */ +#define FUSE_IS_VIRTIO_DAX(fuse_inode) (IS_ENABLED(CONFIG_FUSE_DAX) \ + && IS_DAX(&fuse_inode->inode)) =20 ssize_t fuse_dax_read_iter(struct kiocb *iocb, struct iov_iter *to); ssize_t fuse_dax_write_iter(struct kiocb *iocb, struct iov_iter *from); diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index e9db2cb8c150..29147657a99f 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -164,7 +164,7 @@ static void fuse_evict_inode(struct inode *inode) if (inode->i_sb->s_flags & SB_ACTIVE) { struct fuse_conn *fc =3D get_fuse_conn(inode); =20 - if (FUSE_IS_DAX(inode)) + if (FUSE_IS_VIRTIO_DAX(fi)) fuse_dax_inode_cleanup(inode); if (fi->nlookup) { fuse_queue_forget(fc, fi->forget, fi->nodeid, diff --git a/fs/fuse/iomode.c b/fs/fuse/iomode.c index c99e285f3183..aec4aecb5d79 100644 --- a/fs/fuse/iomode.c +++ b/fs/fuse/iomode.c @@ -204,7 +204,7 @@ int fuse_file_io_open(struct file *file, struct inode *= inode) * io modes are not relevant with DAX and with server that does not * implement open. */ - if (FUSE_IS_DAX(inode) || !ff->args) + if (FUSE_IS_VIRTIO_DAX(fi) || !ff->args) return 0; =20 /* --=20 2.49.0 From nobody Wed Oct 8 00:27:10 2025 Received: from mail-ot1-f48.google.com (mail-ot1-f48.google.com [209.85.210.48]) (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 BA6FA2F2C6B; Thu, 3 Jul 2025 18:51:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751568674; cv=none; b=QBSHMA3tsbJ2Z5XiJSmAtAXCBS9UtUWGSerqZpw3hl9hHHxPbxxjjbi9knZn9KFPYFRQo6N0DyLsNJKzg78qp+eEcWDDLrKdAXveAGdM4bHGgHIZeMQ8d7vw24w6YypwqiohGncSGw5DeVUvR6bb5EZ4QJ2dIP2LOzEIH+6ki5c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751568674; c=relaxed/simple; bh=mMW0UbMGTQwYwRZyOjOzEYWkKRV1p4nf8Yc9UlNqkSY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pnc+AvZm8VbRAaylxK83lrJdwbUFt6wFfZFaqzE/zJDDxdy+waIqkV+56aCP9WrG3EfCYilvk8KoRzKdqlC4Nv0psNm1RKrvhTlOBle9MbKtv62Ks0rNAWA6JTYRtuvpNuzUfhGB+V8S31pWPSVUtw4xSGM6XA1N2d8vqElQ/LM= 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=SAaxPdsU; arc=none smtp.client-ip=209.85.210.48 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="SAaxPdsU" Received: by mail-ot1-f48.google.com with SMTP id 46e09a7af769-73ac40e810eso87945a34.1; Thu, 03 Jul 2025 11:51:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751568672; x=1752173472; 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=oWEMonaAutVoYmJ29X2qmwGpA5xB0/IYZPa9u5OJI9E=; b=SAaxPdsU3Oz/fwZD39LD9NzYw0vSS7zDOo9DA03mxiPExQ6pB7cQI8vMjdsQrorOKc 8XAjs3Vy/PP0I7SFWo2E9pjpDZlfYR+QVS4q5PSgVmW6dbdaYceN08NLOnPMbbp0ohmQ v9F6boIOstCXHvEMAkVMNKGxECIP8IzhS14StccESVj7JHtXWtXoG5XT2mDCNpX0otV8 1ZF/pXI7qhZtnk5CdripKIq/VdIgWhXEZxTrGSOo5Dxh93v/n4JrIFJc5XkU3jj9/V23 aKoyFk+o4pjkoAMWss4/NZHeLzaMrdCzBcAAdDnbeP+Z8eSrcEdd/IxKCGywfgEo4/Gl UkVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751568672; x=1752173472; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=oWEMonaAutVoYmJ29X2qmwGpA5xB0/IYZPa9u5OJI9E=; b=SW8/RCXqHq/0LZeWvMk9A9a8z8RSiQ+BZPLhvu61WfYnfV8E2SHHbmH8pJY+T63dx+ feOtlLUf05OwQ8oyU9n79MzITGLhr7K9dGWXSV3Ijraz0OG+a+8ZOXFUeOE/BWt1NX1a 51QUbs6qrAtRfy55RYUoxRlTS9TEgmiRAXEGWSKEkpjftIr3IT7UnfM/+9grmn6CUuar KsEzLb3iXDMKP7wPP9uMP/wRIUBlwy69BSwWEBRoO07rzuMMCx04OJ4NKHUHW1xqWc5O lNlN2eKKROgllLlAxrJsC4pitU8w2CrGRc/nz6BCBlHG1eA3T6/ZBUWwnAoY+XFgtYyc jNCw== X-Forwarded-Encrypted: i=1; AJvYcCUd7WBBaWa07pZ0BZVcaP1YOIRicNZQjmqfZ++m3keQlA2YVfPM667aSfvgdSO5TIVe4H72EonsD9LEtI/J@vger.kernel.org, AJvYcCVFV1DHGU4E0pNPGA9vimRwQbiSvMqB4GzTqh/lLsK1/AZPSCVWTzgQ7GqamcpnVyj63gizMvV3qY0=@vger.kernel.org, AJvYcCVZc/9qxvYz60rMon3bk88T5tDY4qPgiAbtziTtEU2qBbhq5UjGOlWeEpADJJZmZnkEwMxViJOUe+S+@vger.kernel.org, AJvYcCXqHqi9EZ6vuUEwVkASrV1e42zEYXb1UEoQ548FlT7/6xAMaLuJz9829tw6Fd5TMzAhyTKn50vIqYUoSJQflQ==@vger.kernel.org X-Gm-Message-State: AOJu0Ywaa3OvJ9Rsx0T/q/C1IsioZn5tFL/04oJGwhe1v9wxQQzRa4Tc 5ftBYCHwN6xVWi6wl6BFEh4jH+SZIGPccZTpeFhsPMF3TDmryUZ3CHN4 X-Gm-Gg: ASbGncsor2H6JKW7WPFOm5odW0jCWVqH/ADMqUzxKRT/sQ6TncGRSbhiR+igFfTNJuQ 14POUE5ot6MRyL94+MCxXh0z/EVjAC3fTl3+XWezmyMquUhMw4HAnBCvgtmeUpSuJIkMbLzPxwY EK7fJrlXiRPdtH1q9g3KCUV8wKOcTa12PNO9ScgMnhoOwbTJpWa3mjhgNM47rpzAPhNJbZMw2/o N73d7nAV7NrxG44cVBOcTJPiRjbyzT8PmdtYn6PTbasq+tIcMJlpwA0ZiuChQDRdPa371IE4ypP AACsvXXD6lOSD/brlnaiE+bpR6Xu2QLQssWoqIrIrP2J2nJaJwa9w9yO7zmA/E32DDBWDSamuwJ wwVr5V2NzRf3Ojw== X-Google-Smtp-Source: AGHT+IHUwBODwIp7ctJ4MwNp6YGMLaTDNPH7V/WuiY/SsNw4SKPQYUNXiEa1+Y5X/8t1R2ZxfJ9uFQ== X-Received: by 2002:a05:6830:8008:b0:73c:47f0:b0f2 with SMTP id 46e09a7af769-73c8980e0e1mr3246513a34.27.1751568671716; Thu, 03 Jul 2025 11:51:11 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:cd4:2776:8c4a:3597]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-73c9f90d1ccsm68195a34.44.2025.07.03.11.51.06 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 03 Jul 2025 11:51:08 -0700 (PDT) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Dan Williams , Miklos Szeredi , Bernd Schubert Cc: John Groves , Jonathan Corbet , Vishal Verma , Dave Jiang , Matthew Wilcox , Jan Kara , Alexander Viro , Christian Brauner , "Darrick J . Wong" , Randy Dunlap , Jeff Layton , Kent Overstreet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, Amir Goldstein , Jonathan Cameron , Stefan Hajnoczi , Joanne Koong , Josef Bacik , Aravind Ramesh , Ajay Joshi , John Groves Subject: [RFC V2 10/18] famfs_fuse: Basic fuse kernel ABI enablement for famfs Date: Thu, 3 Jul 2025 13:50:24 -0500 Message-Id: <20250703185032.46568-11-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250703185032.46568-1-john@groves.net> References: <20250703185032.46568-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" * FUSE_DAX_FMAP flag in INIT request/reply * fuse_conn->famfs_iomap (enable famfs-mapped files) to denote a famfs-enabled connection Signed-off-by: John Groves --- fs/fuse/fuse_i.h | 3 +++ fs/fuse/inode.c | 14 ++++++++++++++ include/uapi/linux/fuse.h | 4 ++++ 3 files changed, 21 insertions(+) diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 9d87ac48d724..a592c1002861 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -873,6 +873,9 @@ struct fuse_conn { /* Use io_uring for communication */ unsigned int io_uring; =20 + /* dev_dax_iomap support for famfs */ + unsigned int famfs_iomap:1; + /** Maximum stack depth for passthrough backing files */ int max_stack_depth; =20 diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 29147657a99f..e48e11c3f9f3 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -1392,6 +1392,18 @@ static void process_init_reply(struct fuse_mount *fm= , struct fuse_args *args, } if (flags & FUSE_OVER_IO_URING && fuse_uring_enabled()) fc->io_uring =3D 1; + if (IS_ENABLED(CONFIG_FUSE_FAMFS_DAX) && + flags & FUSE_DAX_FMAP) { + /* XXX: Should also check that fuse server + * has CAP_SYS_RAWIO and/or CAP_SYS_ADMIN, + * since it is directing the kernel to access + * dax memory directly - but this function + * appears not to be called in fuse server + * process context (b/c even if it drops + * those capabilities, they are held here). + */ + fc->famfs_iomap =3D 1; + } } else { ra_pages =3D fc->max_read / PAGE_SIZE; fc->no_lock =3D 1; @@ -1450,6 +1462,8 @@ void fuse_send_init(struct fuse_mount *fm) flags |=3D FUSE_SUBMOUNTS; if (IS_ENABLED(CONFIG_FUSE_PASSTHROUGH)) flags |=3D FUSE_PASSTHROUGH; + if (IS_ENABLED(CONFIG_FUSE_FAMFS_DAX)) + flags |=3D FUSE_DAX_FMAP; =20 /* * This is just an information flag for fuse server. No need to check diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h index 5e0eb41d967e..6c384640c79b 100644 --- a/include/uapi/linux/fuse.h +++ b/include/uapi/linux/fuse.h @@ -229,6 +229,8 @@ * - FUSE_URING_IN_OUT_HEADER_SZ * - FUSE_URING_OP_IN_OUT_SZ * - enum fuse_uring_cmd + * 7.43 + * - Add FUSE_DAX_FMAP capability - ability to handle in-kernel fsdax m= aps */ =20 #ifndef _LINUX_FUSE_H @@ -435,6 +437,7 @@ struct fuse_file_lock { * of the request ID indicates resend requests * FUSE_ALLOW_IDMAP: allow creation of idmapped mounts * FUSE_OVER_IO_URING: Indicate that client supports io-uring + * FUSE_DAX_FMAP: kernel supports dev_dax_iomap (aka famfs) fmaps */ #define FUSE_ASYNC_READ (1 << 0) #define FUSE_POSIX_LOCKS (1 << 1) @@ -482,6 +485,7 @@ struct fuse_file_lock { #define FUSE_DIRECT_IO_RELAX FUSE_DIRECT_IO_ALLOW_MMAP #define FUSE_ALLOW_IDMAP (1ULL << 40) #define FUSE_OVER_IO_URING (1ULL << 41) +#define FUSE_DAX_FMAP (1ULL << 42) =20 /** * CUSE INIT request/reply flags --=20 2.49.0 From nobody Wed Oct 8 00:27:10 2025 Received: from mail-oa1-f43.google.com (mail-oa1-f43.google.com [209.85.160.43]) (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 ABCF92F3624; Thu, 3 Jul 2025 18:51:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751568678; cv=none; b=mEyUkNQJOSFUFJCK1pfRcNZVaJi+60OwnVwxVY8KgRatle9whLkZg+mY5SGCjjPMYkFs9QvCDXtKe5yglrFipFy5CEhAL/UBstoKTC4r6wDLv268NvjsJtfFi9epGsikQ0xQR9Oew6pOKuaKYzO0lqG5N6pqTJLEv1OeFqJDGC4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751568678; c=relaxed/simple; bh=AwpmHSUwtyys54NEGAXRI09zoURnC8vbuHi9iQ+9sBI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UewyQcgsYYSMMlYTqZZjxpHDb9Q0HRpEsTja0A7mAEJ0xIaeQA/A4xxsaPZ7CtQiWdFejWJrPj7JQhDQydTn+Ptfr0ckxcBr61qv9XUkjbVePF/JWCpnc7x67l3OuIyqpb7Kv1Jk1yV/kwEw0zSsJt1ENkXOeSFeTp+mGgqSPzs= 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=DWPoSXAk; arc=none smtp.client-ip=209.85.160.43 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="DWPoSXAk" Received: by mail-oa1-f43.google.com with SMTP id 586e51a60fabf-2ea6dd628a7so198972fac.1; Thu, 03 Jul 2025 11:51:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751568675; x=1752173475; 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=oDkFGX1XbHNMHX4qdJagUzrPXsT4EJAQRqP6IodfCe4=; b=DWPoSXAkjHSwSobfeXI1UPx5NeEUrb32tDI+JjNBRFyN5yzTKiScLrVjpNNo6X4iGd fsEpt/7cfZNr3QEs+iZv966e5m3MDssu1f47uCiceKo9nnuqmXn7dhesq8/QpdFfsv5N 29f6vOb0F7XOreVv8zn4qFAsN7SUnfHWEZnF5LinhJPkaVWMgPeET6kapqFoJD0NYNfu lGe4WrZemy0y5+tJWJPbyHsMzq/w4+AZmaWAfwK3MZaVjSBzyPB70SXI1Y85HtGELsn5 0MByYOcDVVeY23Z2Tl3PBDJDaeARHs1CwnPBEWYVokqh/dinn1RexJjH1A+9+bCypQz7 HPFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751568675; x=1752173475; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=oDkFGX1XbHNMHX4qdJagUzrPXsT4EJAQRqP6IodfCe4=; b=DM/jiTe7wxUys9HxzE2JVun9oyr32gB0yKDrruZx46hwy7RZSIWK4kt1eXnPgNx+cJ Hty2ZWja6qczPrYzvF/O5gAP1eDYqmtUZcj3f/iYIndSloLfqqByyW/0VPWmunz9DISN mG7XZQg3Pd/J8hyqeiMTDq4Rlv8QQ/5jeOgFQElifBeOotmbjnrpfGKURNgYDaZt9Niq CPYbQcA1oufpLvSdDCMjQPfG6gJt50l+xknBnB8wknptCiYttSgfdtM1+395PxcamCDg 0aJjgoXta0ULGNv31ScY0l4/H70SQxWVBVy3c25SnDePj9DYyn2O2Jgh85diOeTON6qM GtkQ== X-Forwarded-Encrypted: i=1; AJvYcCW1XCW2r9ASVqiKZaqTe5qLlMJ3rgv13wICeC40gwky1yOKgWq0Xly+b+cSUq6onqkrTZOq1m8JIvE=@vger.kernel.org, AJvYcCWD3KnmMGOyzOtNOgreKjGVzp8ZQ8cvOa0Ih2WhRBezOOGLCwOr0/hmXCjzCNtjscANQS/ZFdiIiE7oBH5B@vger.kernel.org, AJvYcCX/cts8XKieLG4p+QXwuZk593TxVd52aU2tuhc5QLeVBSwt+Du/M8MDzhZvKUEvsGYTt5PoYdNGbfkaza49Cg==@vger.kernel.org, AJvYcCXnbfoV11NBoT94oZqaRUa4C1KnsJB0V/m4vi9FFA5lRzi1rSwfmKyeoYIayEELS0nm+6L/u20rgJex@vger.kernel.org X-Gm-Message-State: AOJu0YzGfnvVlDTF1VwLgxG0SymK4ov2kGaQECnwggULeiqSJAEa6vtY zDMizS5+ReWOwHpY71DNpigb31bpov/E5tTGL8GmOTcMEl4sWdJ1n+gk X-Gm-Gg: ASbGncs+tWkABgYI89uPeasdxvZFTNo8uUpJTYZ3wosaiHDKDS50toBt0qX+zHYMSFU FYvfRlhkKzY+E/I1OS8V93WnAeOWQZk2hW9Fz0EoTd72rxnflnZSUJbR2bjyrTVI4InCypiCG/v sYPcGsdkNdYv57lbpxXgQ5RmslcQq7ozfr4sLi3i1amNyhDtnEOBk4a4RQejsgvhPAjKeCczx9o H+Q18eLks4dYUvd41N2c5+TZyDkybmOGJH/U7E6AExe4arIqgXqZdiohKnlr/4giAFdpQ/ZQNRK 0Z4ngFuNYHOU8fsOrrrxXYqFxdAhBB+ywx3CCFixA2WMl6z9NPynSMSRuJ9YItX6qzKG+DOqehj vLe8R1YFmYzrPRQ== X-Google-Smtp-Source: AGHT+IGvk7MVTbXEVO8MsBWhLFSbBMBlbcME3R7purdewnEgQEPBsk82mX9lJGQ/44BnQtmyeHJu2w== X-Received: by 2002:a05:6871:898a:b0:2ea:841f:773c with SMTP id 586e51a60fabf-2f5a8c25e66mr7281432fac.35.1751568674740; Thu, 03 Jul 2025 11:51:14 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:cd4:2776:8c4a:3597]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-73c9f90d1ccsm68195a34.44.2025.07.03.11.51.12 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 03 Jul 2025 11:51:14 -0700 (PDT) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Dan Williams , Miklos Szeredi , Bernd Schubert Cc: John Groves , Jonathan Corbet , Vishal Verma , Dave Jiang , Matthew Wilcox , Jan Kara , Alexander Viro , Christian Brauner , "Darrick J . Wong" , Randy Dunlap , Jeff Layton , Kent Overstreet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, Amir Goldstein , Jonathan Cameron , Stefan Hajnoczi , Joanne Koong , Josef Bacik , Aravind Ramesh , Ajay Joshi , John Groves Subject: [RFC V2 11/18] famfs_fuse: Basic famfs mount opts Date: Thu, 3 Jul 2025 13:50:25 -0500 Message-Id: <20250703185032.46568-12-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250703185032.46568-1-john@groves.net> References: <20250703185032.46568-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" * -o shadow=3D * -o daxdev=3D Signed-off-by: John Groves --- fs/fuse/fuse_i.h | 8 +++++++- fs/fuse/inode.c | 28 +++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index a592c1002861..f4ee61046578 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -583,9 +583,11 @@ struct fuse_fs_context { unsigned int blksize; const char *subtype; =20 - /* DAX device, may be NULL */ + /* DAX device for virtiofs, may be NULL */ struct dax_device *dax_dev; =20 + const char *shadow; /* famfs - null if not famfs */ + /* fuse_dev pointer to fill in, should contain NULL on entry */ void **fudptr; }; @@ -941,6 +943,10 @@ struct fuse_conn { /** uring connection information*/ struct fuse_ring *ring; #endif + +#if IS_ENABLED(CONFIG_FUSE_FAMFS_DAX) + char *shadow; +#endif }; =20 /* diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index e48e11c3f9f3..a7e1cf8257b0 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -766,6 +766,9 @@ enum { OPT_ALLOW_OTHER, OPT_MAX_READ, OPT_BLKSIZE, +#if IS_ENABLED(CONFIG_FUSE_FAMFS_DAX) + OPT_SHADOW, +#endif OPT_ERR }; =20 @@ -780,6 +783,9 @@ static const struct fs_parameter_spec fuse_fs_parameter= s[] =3D { fsparam_u32 ("max_read", OPT_MAX_READ), fsparam_u32 ("blksize", OPT_BLKSIZE), fsparam_string ("subtype", OPT_SUBTYPE), +#if IS_ENABLED(CONFIG_FUSE_FAMFS_DAX) + fsparam_string("shadow", OPT_SHADOW), +#endif {} }; =20 @@ -875,6 +881,15 @@ static int fuse_parse_param(struct fs_context *fsc, st= ruct fs_parameter *param) ctx->blksize =3D result.uint_32; break; =20 +#if IS_ENABLED(CONFIG_FUSE_FAMFS_DAX) + case OPT_SHADOW: + if (ctx->shadow) + return invalfc(fsc, "Multiple shadows specified"); + ctx->shadow =3D param->string; + param->string =3D NULL; + break; +#endif + default: return -EINVAL; } @@ -888,6 +903,7 @@ static void fuse_free_fsc(struct fs_context *fsc) =20 if (ctx) { kfree(ctx->subtype); + kfree(ctx->shadow); kfree(ctx); } } @@ -919,7 +935,10 @@ static int fuse_show_options(struct seq_file *m, struc= t dentry *root) else if (fc->dax_mode =3D=3D FUSE_DAX_INODE_USER) seq_puts(m, ",dax=3Dinode"); #endif - +#if IS_ENABLED(CONFIG_FUSE_FAMFS_DAX) + if (fc->shadow) + seq_printf(m, ",shadow=3D%s", fc->shadow); +#endif return 0; } =20 @@ -1017,6 +1036,9 @@ void fuse_conn_put(struct fuse_conn *fc) } if (IS_ENABLED(CONFIG_FUSE_PASSTHROUGH)) fuse_backing_files_free(fc); +#if IS_ENABLED(CONFIG_FUSE_FAMFS_DAX) + kfree(fc->shadow); +#endif call_rcu(&fc->rcu, delayed_release); } } @@ -1834,6 +1856,10 @@ int fuse_fill_super_common(struct super_block *sb, s= truct fuse_fs_context *ctx) sb->s_root =3D root_dentry; if (ctx->fudptr) *ctx->fudptr =3D fud; + +#if IS_ENABLED(CONFIG_FUSE_FAMFS_DAX) + fc->shadow =3D kstrdup(ctx->shadow, GFP_KERNEL); +#endif mutex_unlock(&fuse_mutex); return 0; =20 --=20 2.49.0 From nobody Wed Oct 8 00:27:10 2025 Received: from mail-oa1-f51.google.com (mail-oa1-f51.google.com [209.85.160.51]) (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 15EA12F362C; Thu, 3 Jul 2025 18:51:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751568683; cv=none; b=NBxXGo7uBaAfahUAPVhY+ELJmNXdMvGRoFdYNN/s9F2T/eHjvh/8sJ77pDUIAqLbgJLgqSD/kl1DBn+zYn9F+FnuPYpjeumt19e38JkRbcZkqB6i0uBOwsPWH4TZa0po+rBo6avwqhYAgCxh6JEijBVIlwUL9NeneXJtTKCpN80= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751568683; c=relaxed/simple; bh=W6SSJ5n4WkmPzzWxMdPih1XAcuC59u2vCqd3I2mEN/Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DzWuJfuRy7MvDXj5i7zYSL73troEMN0VZ0iUKUjNoxUmf4sk/Nx6KoQQixv9iX/P5oY8mou+aN+w0a9AZhQwLUVojowfQQv6YH8AWALU6kYv3ki2Wvo1PSjdd7Mi2VVJWDr+L/EsipKQllhRu7nL7EU7VN9yB9xDuwk8FDqepE0= 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=P5869NT3; arc=none smtp.client-ip=209.85.160.51 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="P5869NT3" Received: by mail-oa1-f51.google.com with SMTP id 586e51a60fabf-2ef8dfb3742so67445fac.3; Thu, 03 Jul 2025 11:51:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751568680; x=1752173480; 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=vJKfVlCAjxcUIymiAHgKO7vuVphUoIXt4cecFTyUAAA=; b=P5869NT3jXSDXST5q1+w6z1d9ISMJGrnA5oNYLlUK5MQcnqB+prSHbJaFI+O6UHkkp YwMkBqFGgyiRDSIHRQxD8m6waADINT2VRs3mXA6VsphhgmLmDrsK2U8gEexTkgJYG4Kh d2TOvBfPeiGYQdsplfU3wPgJnZswcY8mIMZ80S5G7Ea3cCjgIE7cxl+uyPdAdjL8xyaN HlYAKaoGwJByRpuclrLMMH+f7FAYm03Sw6GoVtKqmehZA6JgJb9lbBQkZFkS6dKtegKV kjpgzu/GGs7mGkkRusgwYAUD874KhqUVrrXYbkCfWnrz2058SSIi80M44RaxWyImjD2q it0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751568680; x=1752173480; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=vJKfVlCAjxcUIymiAHgKO7vuVphUoIXt4cecFTyUAAA=; b=dxds9SkdM3amNmvlmZN00cE8cndTKBJ8Ewt9ykOeAHzQCqUPPy5TFykXNpXLHKo9nS rcYKxn+EuEMc1gGN0Eh8CEqF/2gXe6qBGWl0fSVfJXx1JvvPFGMb1elQ7fKaao8Zcnab 7DEubHxuw0TQNyiQtOlT2lcbfRATJcezAoLkzv2jcmU6U36gqhrcfAN9mh1g54yIj7+6 ovo75DjS4jrdZjhD715lcZjj9aRHLMrsgAdUvvv7uohtb81wqtMPUwLu4cItTjiD/R/L X/JZ149C/ZcF/6gpJOnfFohwym2DmwBV5eB0RY3LNMQGCfOZG44CN0FPbqbwL4KweM2l Ay9A== X-Forwarded-Encrypted: i=1; AJvYcCVrVgjr+2WZfMHST0+ztI0BGl2GW14gEqlrLbPcTZ+zd0K7bDGJOXJE5Cu8gHZTNpHKF8tvmgTnET8=@vger.kernel.org, AJvYcCX+xX24ihWNWeKKeZnr/aDRSXeph2EEJctBmIV2EDjdUrdaZh9Qvipn5lAbvS4hem3g4WDCHdibzvfD@vger.kernel.org, AJvYcCXhnTF6c0pDLWPz4ZCrVJGuYsFGfFO5P745YertLcOMW7mdb3CNHzNTFS5W5QROCCAcEl5B22w79/b78GWhDA==@vger.kernel.org, AJvYcCXkWlgX54qs75/TEfv66B2XLUGoq62ifulkkNyJoD4aorPAwxNU3/ULQ4KC0aNChITFP3SjvozRAG6pWYl8@vger.kernel.org X-Gm-Message-State: AOJu0YzFlZaiyEYHOUVzG7RYw2vzj5e7NZIu5NBPq5zVbDxgO/AoChRS Eobaxfz+3E2gER6Hd9KmxVVf2CrH0UGat/ClZVtIPvXjIaM57Z/gU8gx X-Gm-Gg: ASbGncujaemSLvRk5AjHf62o+XVzPz8Mko8VZKWgCBz+ugyAQ6pAfaapCVmLO2UmH/n XarI/ACwg1kLLkMMzFIdqxlKoXtEfBuc2+zrFnvUXZH9HLXJX+Rj78gaYzjau1WMq8mE5+OVwYT GcntDu7qV7XqMbCaYcF62WQXdhgCDqErkV4wXjuzGKXGQ/9+ZrndxpA7iSgXX6JrhcW7YlH+Qc+ GJZLoxRrXFVXIwSG2y+TgBREyMEyAan0OBeXjWITbu/6gGTyMDSUANr5i/xXyIkvHtrjGpfEy+W SJYiIPWA5aViRyi7bVCg1iClZJgvflB2S2ZCTC2ooNdLsb8pDAjUT3utyE8PZp0JN1AP3tq84Z6 /pH87wLYx/6zxNA== X-Google-Smtp-Source: AGHT+IHFvVcUbFzxb95rdveSXgYGAH77wTve8JwIh+zgeFvLOJRWZQ+6TNPtIGSAG50EJt081mp86g== X-Received: by 2002:a05:6871:314b:b0:2d5:2955:aa6c with SMTP id 586e51a60fabf-2f76c9ed2cbmr3501437fac.31.1751568680025; Thu, 03 Jul 2025 11:51:20 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:cd4:2776:8c4a:3597]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-73c9f90d1ccsm68195a34.44.2025.07.03.11.51.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 03 Jul 2025 11:51:19 -0700 (PDT) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Dan Williams , Miklos Szeredi , Bernd Schubert Cc: John Groves , Jonathan Corbet , Vishal Verma , Dave Jiang , Matthew Wilcox , Jan Kara , Alexander Viro , Christian Brauner , "Darrick J . Wong" , Randy Dunlap , Jeff Layton , Kent Overstreet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, Amir Goldstein , Jonathan Cameron , Stefan Hajnoczi , Joanne Koong , Josef Bacik , Aravind Ramesh , Ajay Joshi , John Groves Subject: [RFC V2 12/18] famfs_fuse: Plumb the GET_FMAP message/response Date: Thu, 3 Jul 2025 13:50:26 -0500 Message-Id: <20250703185032.46568-13-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250703185032.46568-1-john@groves.net> References: <20250703185032.46568-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" Upon completion of an OPEN, if we're in famfs-mode we do a GET_FMAP to retrieve and cache up the file-to-dax map in the kernel. If this succeeds, read/write/mmap are resolved direct-to-dax with no upcalls. GET_FMAP has a variable-size response payload, and the allocated size is sent in the in_args[0].size field. If the fmap would overflow the message, the fuse server sends a reply of size 'sizeof(uint32_t)' which specifies the size of the fmap message. Then the kernel can realloc a large enough buffer and try again. Signed-off-by: John Groves --- fs/fuse/file.c | 84 +++++++++++++++++++++++++++++++++++++++ fs/fuse/fuse_i.h | 36 ++++++++++++++++- fs/fuse/inode.c | 19 +++++++-- fs/fuse/iomode.c | 2 +- include/uapi/linux/fuse.h | 18 +++++++++ 5 files changed, 154 insertions(+), 5 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 93b82660f0c8..8616fb0a6d61 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -230,6 +230,77 @@ static void fuse_truncate_update_attr(struct inode *in= ode, struct file *file) fuse_invalidate_attr_mask(inode, FUSE_STATX_MODSIZE); } =20 +#if IS_ENABLED(CONFIG_FUSE_FAMFS_DAX) + +#define FMAP_BUFSIZE 4096 + +static int +fuse_get_fmap(struct fuse_mount *fm, struct inode *inode, u64 nodeid) +{ + struct fuse_get_fmap_in inarg =3D { 0 }; + size_t fmap_bufsize =3D FMAP_BUFSIZE; + ssize_t fmap_size; + int retries =3D 1; + void *fmap_buf; + int rc; + + FUSE_ARGS(args); + + fmap_buf =3D kcalloc(1, FMAP_BUFSIZE, GFP_KERNEL); + if (!fmap_buf) + return -EIO; + + retry_once: + inarg.size =3D fmap_bufsize; + + args.opcode =3D FUSE_GET_FMAP; + args.nodeid =3D nodeid; + + args.in_numargs =3D 1; + args.in_args[0].size =3D sizeof(inarg); + args.in_args[0].value =3D &inarg; + + /* Variable-sized output buffer + * this causes fuse_simple_request() to return the size of the + * output payload + */ + args.out_argvar =3D true; + args.out_numargs =3D 1; + args.out_args[0].size =3D fmap_bufsize; + args.out_args[0].value =3D fmap_buf; + + /* Send GET_FMAP command */ + rc =3D fuse_simple_request(fm, &args); + if (rc < 0) { + pr_err("%s: err=3D%d from fuse_simple_request()\n", + __func__, rc); + return rc; + } + fmap_size =3D rc; + + if (retries && fmap_size =3D=3D sizeof(uint32_t)) { + /* fmap size exceeded fmap_bufsize; + * actual fmap size returned in fmap_buf; + * realloc and retry once + */ + fmap_bufsize =3D *((uint32_t *)fmap_buf); + + --retries; + kfree(fmap_buf); + fmap_buf =3D kcalloc(1, fmap_bufsize, GFP_KERNEL); + if (!fmap_buf) + return -EIO; + + goto retry_once; + } + + /* Will call famfs_file_init_dax() when that gets added */ + + kfree(fmap_buf); + return 0; +} +#endif + static int fuse_open(struct inode *inode, struct file *file) { struct fuse_mount *fm =3D get_fuse_mount(inode); @@ -263,6 +334,19 @@ static int fuse_open(struct inode *inode, struct file = *file) =20 err =3D fuse_do_open(fm, get_node_id(inode), file, false); if (!err) { +#if IS_ENABLED(CONFIG_FUSE_FAMFS_DAX) + if (fm->fc->famfs_iomap) { + if (S_ISREG(inode->i_mode)) { + int rc; + /* Get the famfs fmap */ + rc =3D fuse_get_fmap(fm, inode, + get_node_id(inode)); + if (rc) + pr_err("%s: fuse_get_fmap err=3D%d\n", + __func__, rc); + } + } +#endif ff =3D file->private_data; err =3D fuse_finish_open(inode, file); if (err) diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index f4ee61046578..e01d6e5c6e93 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -193,6 +193,10 @@ struct fuse_inode { /** Reference to backing file in passthrough mode */ struct fuse_backing *fb; #endif + +#if IS_ENABLED(CONFIG_FUSE_FAMFS_DAX) + void *famfs_meta; +#endif }; =20 /** FUSE inode state bits */ @@ -945,6 +949,8 @@ struct fuse_conn { #endif =20 #if IS_ENABLED(CONFIG_FUSE_FAMFS_DAX) + struct rw_semaphore famfs_devlist_sem; + struct famfs_dax_devlist *dax_devlist; char *shadow; #endif }; @@ -1435,11 +1441,14 @@ void fuse_free_conn(struct fuse_conn *fc); =20 /* dax.c */ =20 +static inline int fuse_file_famfs(struct fuse_inode *fi); /* forward */ + /* This macro is used by virtio_fs, but now it also needs to filter for * "not famfs" */ #define FUSE_IS_VIRTIO_DAX(fuse_inode) (IS_ENABLED(CONFIG_FUSE_DAX) \ - && IS_DAX(&fuse_inode->inode)) + && IS_DAX(&fuse_inode->inode) \ + && !fuse_file_famfs(fuse_inode)) =20 ssize_t fuse_dax_read_iter(struct kiocb *iocb, struct iov_iter *to); ssize_t fuse_dax_write_iter(struct kiocb *iocb, struct iov_iter *from); @@ -1550,4 +1559,29 @@ extern void fuse_sysctl_unregister(void); #define fuse_sysctl_unregister() do { } while (0) #endif /* CONFIG_SYSCTL */ =20 +/* famfs.c */ +static inline struct fuse_backing *famfs_meta_set(struct fuse_inode *fi, + void *meta) +{ +#if IS_ENABLED(CONFIG_FUSE_FAMFS_DAX) + return xchg(&fi->famfs_meta, meta); +#else + return NULL; +#endif +} + +static inline void famfs_meta_free(struct fuse_inode *fi) +{ + /* Stub wil be connected in a subsequent commit */ +} + +static inline int fuse_file_famfs(struct fuse_inode *fi) +{ +#if IS_ENABLED(CONFIG_FUSE_FAMFS_DAX) + return (READ_ONCE(fi->famfs_meta) !=3D NULL); +#else + return 0; +#endif +} + #endif /* _FS_FUSE_I_H */ diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index a7e1cf8257b0..b071d16f7d04 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -117,6 +117,9 @@ static struct inode *fuse_alloc_inode(struct super_bloc= k *sb) if (IS_ENABLED(CONFIG_FUSE_PASSTHROUGH)) fuse_inode_backing_set(fi, NULL); =20 + if (IS_ENABLED(CONFIG_FUSE_FAMFS_DAX)) + famfs_meta_set(fi, NULL); + return &fi->inode; =20 out_free_forget: @@ -138,6 +141,13 @@ static void fuse_free_inode(struct inode *inode) if (IS_ENABLED(CONFIG_FUSE_PASSTHROUGH)) fuse_backing_put(fuse_inode_backing(fi)); =20 +#if IS_ENABLED(CONFIG_FUSE_FAMFS_DAX) + if (S_ISREG(inode->i_mode) && fi->famfs_meta) { + famfs_meta_free(fi); + famfs_meta_set(fi, NULL); + } +#endif + kmem_cache_free(fuse_inode_cachep, fi); } =20 @@ -1002,6 +1012,9 @@ void fuse_conn_init(struct fuse_conn *fc, struct fuse= _mount *fm, if (IS_ENABLED(CONFIG_FUSE_PASSTHROUGH)) fuse_backing_files_init(fc); =20 + if (IS_ENABLED(CONFIG_FUSE_FAMFS_DAX)) + pr_notice("%s: Kernel is FUSE_FAMFS_DAX capable\n", __func__); + INIT_LIST_HEAD(&fc->mounts); list_add(&fm->fc_entry, &fc->mounts); fm->fc =3D fc; @@ -1036,9 +1049,8 @@ void fuse_conn_put(struct fuse_conn *fc) } if (IS_ENABLED(CONFIG_FUSE_PASSTHROUGH)) fuse_backing_files_free(fc); -#if IS_ENABLED(CONFIG_FUSE_FAMFS_DAX) - kfree(fc->shadow); -#endif + if (IS_ENABLED(CONFIG_FUSE_FAMFS_DAX)) + kfree(fc->shadow); call_rcu(&fc->rcu, delayed_release); } } @@ -1425,6 +1437,7 @@ static void process_init_reply(struct fuse_mount *fm,= struct fuse_args *args, * those capabilities, they are held here). */ fc->famfs_iomap =3D 1; + init_rwsem(&fc->famfs_devlist_sem); } } else { ra_pages =3D fc->max_read / PAGE_SIZE; diff --git a/fs/fuse/iomode.c b/fs/fuse/iomode.c index aec4aecb5d79..443b337b0c05 100644 --- a/fs/fuse/iomode.c +++ b/fs/fuse/iomode.c @@ -204,7 +204,7 @@ int fuse_file_io_open(struct file *file, struct inode *= inode) * io modes are not relevant with DAX and with server that does not * implement open. */ - if (FUSE_IS_VIRTIO_DAX(fi) || !ff->args) + if (FUSE_IS_VIRTIO_DAX(fi) || fuse_file_famfs(fi) || !ff->args) return 0; =20 /* diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h index 6c384640c79b..dff5aa62543e 100644 --- a/include/uapi/linux/fuse.h +++ b/include/uapi/linux/fuse.h @@ -654,6 +654,10 @@ enum fuse_opcode { FUSE_TMPFILE =3D 51, FUSE_STATX =3D 52, =20 + /* Famfs / devdax opcodes */ + FUSE_GET_FMAP =3D 53, + FUSE_GET_DAXDEV =3D 54, + /* CUSE specific operations */ CUSE_INIT =3D 4096, =20 @@ -888,6 +892,16 @@ struct fuse_access_in { uint32_t padding; }; =20 +struct fuse_get_fmap_in { + uint32_t size; + uint32_t padding; +}; + +struct fuse_get_fmap_out { + uint32_t size; + uint32_t padding; +}; + struct fuse_init_in { uint32_t major; uint32_t minor; @@ -1284,4 +1298,8 @@ struct fuse_uring_cmd_req { uint8_t padding[6]; }; =20 +/* Famfs fmap message components */ + +#define FAMFS_FMAP_MAX 32768 /* Largest supported fmap message */ + #endif /* _LINUX_FUSE_H */ --=20 2.49.0 From nobody Wed Oct 8 00:27:10 2025 Received: from mail-ot1-f53.google.com (mail-ot1-f53.google.com [209.85.210.53]) (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 D42832F3639; Thu, 3 Jul 2025 18:51:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751568685; cv=none; b=QU8j0P+PoqzRkQwv/P8s+dhlICtKwfHBuneJo1oJLx37HgJcyJK9GgWRK+CQOx+5X6u4L0rTLIohZlOTpscrfuSEY+hu4HHMaYv4a01XvLMDOcKrV5YsWMkRVyMECeHu5liEl8oA114GuhcE3dtgF+t7OUmryU/cHc0FVymHtU4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751568685; c=relaxed/simple; bh=3uq435KcAdEmXJ2dEvmM663qcKbyyXlb5cIDAXxXSAM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NJgH/pgRe/XsQaqoT3/G9bxwq9XLms2zGNJwmfYdLKG/AhBhJmYi97uzrGqQMcn5IaQ3UpGhgxp2KBnlP+pVfGG3oLjlCILKyvEV9LO9kNY4kHdwSvrxqNOjb6i3EiTtMQBlB2z7Zvaied572Tt8ElUYkviRFPerPL8G5n7f+nM= 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=WnuCf4qm; arc=none smtp.client-ip=209.85.210.53 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="WnuCf4qm" Received: by mail-ot1-f53.google.com with SMTP id 46e09a7af769-72c172f1de1so146129a34.3; Thu, 03 Jul 2025 11:51:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751568683; x=1752173483; 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=BiBVfwSLB223dPTff0BfZzAs2J9PXPdtMbuyCEnzUFk=; b=WnuCf4qm1DOCO5+o9qsamwTczdIaBnKVQgiqWCqXySkmagYiyrtMayVo/S9PDFdB7p i7lxSirU/m+m1GuxpCY5IEJ9081t2wJu4+r3KXSCfnIa1TA6+uMP2Q+xaWqzLUtgk3cy /tyrelrl2B6TdGtznJnrAwkpTCZwxzou841DXQ2behOPcpSjha41qE91XSCFbjBsyOuf QaPmlLgQ93soMV3vEEB+6aHltO0d5QHLB3InC3SwqInsGdkQizI/yZmclwX+NcwkV2B6 6PHdr2baNpUU5xb8siyx7rQvvjCxhZQq4WB3u/JFWmE8UnTYc/WszW0S/buF0U0sgwTy KxcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751568683; x=1752173483; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=BiBVfwSLB223dPTff0BfZzAs2J9PXPdtMbuyCEnzUFk=; b=JnTGX7boThbp98iMKZGW+YXd6O4Cx/BOnXFR9qm7xAvWUA2BZciIwwJHdYFJcMfY9W yhRGWsjGp/OpB5y8K7Jfk+gfx9JQns4hxwWDjmaleI7K+IVDYxxqNt0T7edkJIO28Gib CSLG+087qC/YYT1rQ1hMBt9zIs1EciQXexfWSHiOy5cGNB5aI6dnNdiBkW1+fTr3Z1ln 1dU6bHE/dFv0aezwfYG9OGbq/H3WwIXbazXYU1HiAxo4zVPH4cspmsW6Yn7wFoPRdYJB U8OajSWg3znfUgiRrQy5WhzxZlTAH2cjbo1/lrcB20lBXSbhnR7BAHe0sL+NafQa0leb 1dqA== X-Forwarded-Encrypted: i=1; AJvYcCULLo2MyKbnfGk7kQ9ILfXF+xZ8n4eA2R73Nrr2i1crzR2Ql+KAc1BYC1MtRVWrTWh7GwWJXTEDKIC5R3oJfQ==@vger.kernel.org, AJvYcCUvYJRAKS9+Ml94rRCAkmYlPIRuwwznFF7hcllT6QL7dRoTXtsBNAAHEiUOUYk/5i2LwXhgaKjERwXn@vger.kernel.org, AJvYcCWFBKV9I2FMoi5PUTW0xW7CJxYy1ZAkCnWr4c6yY0xo8T3/CfCMpfGlkEm0sJal6SuYHkm8jSJ/d4w=@vger.kernel.org, AJvYcCWhCbhP7VztFCEHvm4WmL7vrH3dWnskGoNYio4Y2iPMFGMNSxwQj8XrItPRdsVJzTaEZxB/NuGJUXPLFKcn@vger.kernel.org X-Gm-Message-State: AOJu0YxkdN7f3A+kheTEM12l533yuP9DRQvxGLbPtdL8+FLLB3f22v9T VftXGkC1js0up8ZgA5dr80TDRfYXlphQ0O0/5poji//iPaUi0XWl1mcF X-Gm-Gg: ASbGncsC3e04kaFOHRsmRi3DPdgKPkgDWSlGu+ziClx9lW7mCbYVBIr8trPc4O3II+X NnsWjZXk22K2ke/Sy70s2u22hAJ4edUdoV/h1l24lyX9pEWQ2wus0mL1JffBa3AU3B6O7yAQktP L5+RBoqXMiU3s99XLTMXZSboVxaIZERfLqv73vlWMrU6c3v3TTi9IamZl3hg6xvelUFB7HQSCl2 pKIOPf0BPcpUFxwEkZTUiD+j+O1gpktMebmKlxA6C0TCbhSYMIwCKKVVdR5rTQV9PV2/tFrD3+z MUmHN8gMZ7qwJ7DJ2kK06xMGiDiNP+99izu5W3L8T2oFDd0aT5nLhIdFjysq9Trbaf16kufqV1m 5Zgsgqxl5VUB6Ag== X-Google-Smtp-Source: AGHT+IGmPzpo0HD5BF6fh2iRd9KU+SpEfPKk/EoogvAH+BoC56Diym3E75i5H5FPOtaQzBZoqTn2dw== X-Received: by 2002:a05:6830:3151:b0:73a:9d3d:7bea with SMTP id 46e09a7af769-73b4cce14a7mr6284108a34.24.1751568682800; Thu, 03 Jul 2025 11:51:22 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:cd4:2776:8c4a:3597]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-73c9f90d1ccsm68195a34.44.2025.07.03.11.51.20 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 03 Jul 2025 11:51:22 -0700 (PDT) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Dan Williams , Miklos Szeredi , Bernd Schubert Cc: John Groves , Jonathan Corbet , Vishal Verma , Dave Jiang , Matthew Wilcox , Jan Kara , Alexander Viro , Christian Brauner , "Darrick J . Wong" , Randy Dunlap , Jeff Layton , Kent Overstreet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, Amir Goldstein , Jonathan Cameron , Stefan Hajnoczi , Joanne Koong , Josef Bacik , Aravind Ramesh , Ajay Joshi , John Groves Subject: [RFC V2 13/18] famfs_fuse: Create files with famfs fmaps Date: Thu, 3 Jul 2025 13:50:27 -0500 Message-Id: <20250703185032.46568-14-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250703185032.46568-1-john@groves.net> References: <20250703185032.46568-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" On completion of GET_FMAP message/response, setup the full famfs metadata such that it's possible to handle read/write/mmap directly to dax. Note that the devdax_iomap plumbing is not in yet... Update MAINTAINERS for the new files. Signed-off-by: John Groves --- MAINTAINERS | 9 + fs/fuse/Makefile | 2 +- fs/fuse/famfs.c | 360 ++++++++++++++++++++++++++++++++++++++ fs/fuse/famfs_kfmap.h | 63 +++++++ fs/fuse/file.c | 15 +- fs/fuse/fuse_i.h | 16 +- fs/fuse/inode.c | 2 +- include/uapi/linux/fuse.h | 56 ++++++ 8 files changed, 518 insertions(+), 5 deletions(-) create mode 100644 fs/fuse/famfs.c create mode 100644 fs/fuse/famfs_kfmap.h diff --git a/MAINTAINERS b/MAINTAINERS index c0d5232a473b..02688f27a4d0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8808,6 +8808,15 @@ F: Documentation/networking/failover.rst F: include/net/failover.h F: net/core/failover.c =20 +FAMFS +M: John Groves +M: John Groves +L: linux-cxl@vger.kernel.org +L: linux-fsdevel@vger.kernel.org +S: Supported +F: fs/fuse/famfs.c +F: fs/fuse/famfs_kfmap.h + FANOTIFY M: Jan Kara R: Amir Goldstein diff --git a/fs/fuse/Makefile b/fs/fuse/Makefile index 3f0f312a31c1..65a12975d734 100644 --- a/fs/fuse/Makefile +++ b/fs/fuse/Makefile @@ -16,5 +16,5 @@ fuse-$(CONFIG_FUSE_DAX) +=3D dax.o fuse-$(CONFIG_FUSE_PASSTHROUGH) +=3D passthrough.o fuse-$(CONFIG_SYSCTL) +=3D sysctl.o fuse-$(CONFIG_FUSE_IO_URING) +=3D dev_uring.o - +fuse-$(CONFIG_FUSE_FAMFS_DAX) +=3D famfs.o virtiofs-y :=3D virtio_fs.o diff --git a/fs/fuse/famfs.c b/fs/fuse/famfs.c new file mode 100644 index 000000000000..41c4d92f1451 --- /dev/null +++ b/fs/fuse/famfs.c @@ -0,0 +1,360 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * famfs - dax file system for shared fabric-attached memory + * + * Copyright 2023-2025 Micron Technology, Inc. + * + * This file system, originally based on ramfs the dax support from xfs, + * is intended to allow multiple host systems to mount a common file system + * view of dax files that map to shared memory. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "famfs_kfmap.h" +#include "fuse_i.h" + + +void +__famfs_meta_free(void *famfs_meta) +{ + struct famfs_file_meta *fmap =3D famfs_meta; + + if (!fmap) + return; + + if (fmap) { + switch (fmap->fm_extent_type) { + case SIMPLE_DAX_EXTENT: + kfree(fmap->se); + break; + case INTERLEAVED_EXTENT: + if (fmap->ie) + kfree(fmap->ie->ie_strips); + + kfree(fmap->ie); + break; + default: + pr_err("%s: invalid fmap type\n", __func__); + break; + } + } + kfree(fmap); +} + +static int +famfs_check_ext_alignment(struct famfs_meta_simple_ext *se) +{ + int errs =3D 0; + + if (se->dev_index !=3D 0) + errs++; + + /* TODO: pass in alignment so we can support the other page sizes */ + if (!IS_ALIGNED(se->ext_offset, PMD_SIZE)) + errs++; + + if (!IS_ALIGNED(se->ext_len, PMD_SIZE)) + errs++; + + return errs; +} + +/** + * famfs_fuse_meta_alloc() - Allocate famfs file metadata + * @metap: Pointer to an mcache_map_meta pointer + * @ext_count: The number of extents needed + * + * Returns: 0=3Dsuccess + * -errno=3Dfailure + */ +static int +famfs_fuse_meta_alloc( + void *fmap_buf, + size_t fmap_buf_size, + struct famfs_file_meta **metap) +{ + struct famfs_file_meta *meta =3D NULL; + struct fuse_famfs_fmap_header *fmh; + size_t extent_total =3D 0; + size_t next_offset =3D 0; + int errs =3D 0; + int i, j; + int rc; + + fmh =3D (struct fuse_famfs_fmap_header *)fmap_buf; + + /* Move past fmh in fmap_buf */ + next_offset +=3D sizeof(*fmh); + if (next_offset > fmap_buf_size) { + pr_err("%s:%d: fmap_buf underflow offset/size %ld/%ld\n", + __func__, __LINE__, next_offset, fmap_buf_size); + return -EINVAL; + } + + if (fmh->nextents < 1) { + pr_err("%s: nextents %d < 1\n", __func__, fmh->nextents); + return -EINVAL; + } + + if (fmh->nextents > FUSE_FAMFS_MAX_EXTENTS) { + pr_err("%s: nextents %d > max (%d) 1\n", + __func__, fmh->nextents, FUSE_FAMFS_MAX_EXTENTS); + return -E2BIG; + } + + meta =3D kzalloc(sizeof(*meta), GFP_KERNEL); + if (!meta) + return -ENOMEM; + + meta->error =3D false; + meta->file_type =3D fmh->file_type; + meta->file_size =3D fmh->file_size; + meta->fm_extent_type =3D fmh->ext_type; + + switch (fmh->ext_type) { + case FUSE_FAMFS_EXT_SIMPLE: { + struct fuse_famfs_simple_ext *se_in; + + se_in =3D (struct fuse_famfs_simple_ext *)(fmap_buf + next_offset); + + /* Move past simple extents */ + next_offset +=3D fmh->nextents * sizeof(*se_in); + if (next_offset > fmap_buf_size) { + pr_err("%s:%d: fmap_buf underflow offset/size %ld/%ld\n", + __func__, __LINE__, next_offset, fmap_buf_size); + rc =3D -EINVAL; + goto errout; + } + + meta->fm_nextents =3D fmh->nextents; + + meta->se =3D kcalloc(meta->fm_nextents, sizeof(*(meta->se)), + GFP_KERNEL); + if (!meta->se) { + rc =3D -ENOMEM; + goto errout; + } + + if ((meta->fm_nextents > FUSE_FAMFS_MAX_EXTENTS) || + (meta->fm_nextents < 1)) { + rc =3D -EINVAL; + goto errout; + } + + for (i =3D 0; i < fmh->nextents; i++) { + meta->se[i].dev_index =3D se_in[i].se_devindex; + meta->se[i].ext_offset =3D se_in[i].se_offset; + meta->se[i].ext_len =3D se_in[i].se_len; + + /* Record bitmap of referenced daxdev indices */ + meta->dev_bitmap |=3D (1 << meta->se[i].dev_index); + + errs +=3D famfs_check_ext_alignment(&meta->se[i]); + + extent_total +=3D meta->se[i].ext_len; + } + break; + } + + case FUSE_FAMFS_EXT_INTERLEAVE: { + s64 size_remainder =3D meta->file_size; + struct fuse_famfs_iext *ie_in; + int niext =3D fmh->nextents; + + meta->fm_niext =3D niext; + + /* Allocate interleaved extent */ + meta->ie =3D kcalloc(niext, sizeof(*(meta->ie)), GFP_KERNEL); + if (!meta->ie) { + rc =3D -ENOMEM; + goto errout; + } + + /* + * Each interleaved extent has a simple extent list of strips. + * Outer loop is over separate interleaved extents + */ + for (i =3D 0; i < niext; i++) { + u64 nstrips; + struct fuse_famfs_simple_ext *sie_in; + + /* ie_in =3D one interleaved extent in fmap_buf */ + ie_in =3D (struct fuse_famfs_iext *) + (fmap_buf + next_offset); + + /* Move past one interleaved extent header in fmap_buf */ + next_offset +=3D sizeof(*ie_in); + if (next_offset > fmap_buf_size) { + pr_err("%s:%d: fmap_buf underflow offset/size %ld/%ld\n", + __func__, __LINE__, next_offset, + fmap_buf_size); + rc =3D -EINVAL; + goto errout; + } + + nstrips =3D ie_in->ie_nstrips; + meta->ie[i].fie_chunk_size =3D ie_in->ie_chunk_size; + meta->ie[i].fie_nstrips =3D ie_in->ie_nstrips; + meta->ie[i].fie_nbytes =3D ie_in->ie_nbytes; + + if (!meta->ie[i].fie_nbytes) { + pr_err("%s: zero-length interleave!\n", + __func__); + rc =3D -EINVAL; + goto errout; + } + + /* sie_in =3D the strip extents in fmap_buf */ + sie_in =3D (struct fuse_famfs_simple_ext *) + (fmap_buf + next_offset); + + /* Move past strip extents in fmap_buf */ + next_offset +=3D nstrips * sizeof(*sie_in); + if (next_offset > fmap_buf_size) { + pr_err("%s:%d: fmap_buf underflow offset/size %ld/%ld\n", + __func__, __LINE__, next_offset, + fmap_buf_size); + rc =3D -EINVAL; + goto errout; + } + + if ((nstrips > FUSE_FAMFS_MAX_STRIPS) || (nstrips < 1)) { + pr_err("%s: invalid nstrips=3D%lld (max=3D%d)\n", + __func__, nstrips, + FUSE_FAMFS_MAX_STRIPS); + errs++; + } + + /* Allocate strip extent array */ + meta->ie[i].ie_strips =3D kcalloc(ie_in->ie_nstrips, + sizeof(meta->ie[i].ie_strips[0]), + GFP_KERNEL); + if (!meta->ie[i].ie_strips) { + rc =3D -ENOMEM; + goto errout; + } + + /* Inner loop is over strips */ + for (j =3D 0; j < nstrips; j++) { + struct famfs_meta_simple_ext *strips_out; + u64 devindex =3D sie_in[j].se_devindex; + u64 offset =3D sie_in[j].se_offset; + u64 len =3D sie_in[j].se_len; + + strips_out =3D meta->ie[i].ie_strips; + strips_out[j].dev_index =3D devindex; + strips_out[j].ext_offset =3D offset; + strips_out[j].ext_len =3D len; + + /* Record bitmap of referenced daxdev indices */ + meta->dev_bitmap |=3D (1 << devindex); + + extent_total +=3D len; + errs +=3D famfs_check_ext_alignment(&strips_out[j]); + size_remainder -=3D len; + } + } + + if (size_remainder > 0) { + /* Sum of interleaved extent sizes is less than file size! */ + pr_err("%s: size_remainder %lld (0x%llx)\n", + __func__, size_remainder, size_remainder); + rc =3D -EINVAL; + goto errout; + } + break; + } + + default: + pr_err("%s: invalid ext_type %d\n", __func__, fmh->ext_type); + rc =3D -EINVAL; + goto errout; + } + + if (errs > 0) { + pr_err("%s: %d alignment errors found\n", __func__, errs); + rc =3D -EINVAL; + goto errout; + } + + /* More sanity checks */ + if (extent_total < meta->file_size) { + pr_err("%s: file size %ld larger than map size %ld\n", + __func__, meta->file_size, extent_total); + rc =3D -EINVAL; + goto errout; + } + + *metap =3D meta; + + return 0; +errout: + __famfs_meta_free(meta); + return rc; +} + +/** + * famfs_file_init_dax() - init famfs dax file metadata + * + * @fm: fuse_mount + * @inode: the inode + * @fmap_buf: fmap response message + * @fmap_size: Size of the fmap message + * + * Initialize famfs metadata for a file, based on the contents of the GET_= FMAP + * response + * + * Return: 0=3Dsuccess + * -errno=3Dfailure + */ +int +famfs_file_init_dax( + struct fuse_mount *fm, + struct inode *inode, + void *fmap_buf, + size_t fmap_size) +{ + struct fuse_inode *fi =3D get_fuse_inode(inode); + struct famfs_file_meta *meta =3D NULL; + int rc; + + if (fi->famfs_meta) { + pr_notice("%s: i_no=3D%ld fmap_size=3D%ld ALREADY INITIALIZED\n", + __func__, + inode->i_ino, fmap_size); + return -EEXIST; + } + + rc =3D famfs_fuse_meta_alloc(fmap_buf, fmap_size, &meta); + if (rc) + goto errout; + + /* Publish the famfs metadata on fi->famfs_meta */ + inode_lock(inode); + if (fi->famfs_meta) { + rc =3D -EEXIST; /* file already has famfs metadata */ + } else { + if (famfs_meta_set(fi, meta) !=3D NULL) { + pr_err("%s: file already had metadata\n", __func__); + rc =3D -EALREADY; + goto errout; + } + i_size_write(inode, meta->file_size); + inode->i_flags |=3D S_DAX; + } + inode_unlock(inode); + + errout: + if (rc) + __famfs_meta_free(meta); + + return rc; +} + diff --git a/fs/fuse/famfs_kfmap.h b/fs/fuse/famfs_kfmap.h new file mode 100644 index 000000000000..ce785d76719c --- /dev/null +++ b/fs/fuse/famfs_kfmap.h @@ -0,0 +1,63 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * famfs - dax file system for shared fabric-attached memory + * + * Copyright 2023-2025 Micron Technology, Inc. + */ +#ifndef FAMFS_KFMAP_H +#define FAMFS_KFMAP_H + +/* + * These structures are the in-memory metadata format for famfs files. Met= adata + * retrieved via the GET_FMAP response is converted to this format for use= in + * resolving file mapping faults. + */ + +enum famfs_file_type { + FAMFS_REG, + FAMFS_SUPERBLOCK, + FAMFS_LOG, +}; + +/* We anticipate the possiblity of supporting additional types of extents = */ +enum famfs_extent_type { + SIMPLE_DAX_EXTENT, + INTERLEAVED_EXTENT, + INVALID_EXTENT_TYPE, +}; + +struct famfs_meta_simple_ext { + u64 dev_index; + u64 ext_offset; + u64 ext_len; +}; + +struct famfs_meta_interleaved_ext { + u64 fie_nstrips; + u64 fie_chunk_size; + u64 fie_nbytes; + struct famfs_meta_simple_ext *ie_strips; +}; + +/* + * Each famfs dax file has this hanging from its fuse_inode->famfs_meta + */ +struct famfs_file_meta { + bool error; + enum famfs_file_type file_type; + size_t file_size; + enum famfs_extent_type fm_extent_type; + u64 dev_bitmap; /* bitmap of referenced daxdevs by index */ + union { /* This will make code a bit more readable */ + struct { + size_t fm_nextents; + struct famfs_meta_simple_ext *se; + }; + struct { + size_t fm_niext; + struct famfs_meta_interleaved_ext *ie; + }; + }; +}; + +#endif /* FAMFS_KFMAP_H */ diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 8616fb0a6d61..5d205eadb48f 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -237,6 +237,7 @@ static void fuse_truncate_update_attr(struct inode *ino= de, struct file *file) static int fuse_get_fmap(struct fuse_mount *fm, struct inode *inode, u64 nodeid) { + struct fuse_inode *fi =3D get_fuse_inode(inode); struct fuse_get_fmap_in inarg =3D { 0 }; size_t fmap_bufsize =3D FMAP_BUFSIZE; ssize_t fmap_size; @@ -246,6 +247,10 @@ fuse_get_fmap(struct fuse_mount *fm, struct inode *ino= de, u64 nodeid) =20 FUSE_ARGS(args); =20 + /* Don't retrieve if we already have the famfs metadata */ + if (fi->famfs_meta) + return 0; + fmap_buf =3D kcalloc(1, FMAP_BUFSIZE, GFP_KERNEL); if (!fmap_buf) return -EIO; @@ -285,6 +290,13 @@ fuse_get_fmap(struct fuse_mount *fm, struct inode *ino= de, u64 nodeid) */ fmap_bufsize =3D *((uint32_t *)fmap_buf); =20 + if (fmap_bufsize < fmap_msg_min_size() + || fmap_bufsize > FAMFS_FMAP_MAX) { + pr_err("%s: fmap_size=3D%ld out of range\n", + __func__, fmap_bufsize); + return -EIO; + } + --retries; kfree(fmap_buf); fmap_buf =3D kcalloc(1, fmap_bufsize, GFP_KERNEL); @@ -294,7 +306,8 @@ fuse_get_fmap(struct fuse_mount *fm, struct inode *inod= e, u64 nodeid) goto retry_once; } =20 - /* Will call famfs_file_init_dax() when that gets added */ + /* Convert fmap into in-memory format and hang from inode */ + famfs_file_init_dax(fm, inode, fmap_buf, fmap_size); =20 kfree(fmap_buf); return 0; diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index e01d6e5c6e93..fb6095655403 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -1560,11 +1560,18 @@ extern void fuse_sysctl_unregister(void); #endif /* CONFIG_SYSCTL */ =20 /* famfs.c */ +#if IS_ENABLED(CONFIG_FUSE_FAMFS_DAX) +int famfs_file_init_dax(struct fuse_mount *fm, + struct inode *inode, void *fmap_buf, + size_t fmap_size); +void __famfs_meta_free(void *map); +#endif + static inline struct fuse_backing *famfs_meta_set(struct fuse_inode *fi, void *meta) { #if IS_ENABLED(CONFIG_FUSE_FAMFS_DAX) - return xchg(&fi->famfs_meta, meta); + return cmpxchg(&fi->famfs_meta, NULL, meta); #else return NULL; #endif @@ -1572,7 +1579,12 @@ static inline struct fuse_backing *famfs_meta_set(st= ruct fuse_inode *fi, =20 static inline void famfs_meta_free(struct fuse_inode *fi) { - /* Stub wil be connected in a subsequent commit */ +#if IS_ENABLED(CONFIG_FUSE_FAMFS_DAX) + if (fi->famfs_meta !=3D NULL) { + __famfs_meta_free(fi->famfs_meta); + famfs_meta_set(fi, NULL); + } +#endif } =20 static inline int fuse_file_famfs(struct fuse_inode *fi) diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index b071d16f7d04..1682755abf30 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -118,7 +118,7 @@ static struct inode *fuse_alloc_inode(struct super_bloc= k *sb) fuse_inode_backing_set(fi, NULL); =20 if (IS_ENABLED(CONFIG_FUSE_FAMFS_DAX)) - famfs_meta_set(fi, NULL); + fi->famfs_meta =3D NULL; /* XXX new inodes currently not zeroed; why not= ? */ =20 return &fi->inode; =20 diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h index dff5aa62543e..ecaaa62910f0 100644 --- a/include/uapi/linux/fuse.h +++ b/include/uapi/linux/fuse.h @@ -231,6 +231,13 @@ * - enum fuse_uring_cmd * 7.43 * - Add FUSE_DAX_FMAP capability - ability to handle in-kernel fsdax m= aps + * - Add the following structures for the GET_FMAP message reply compon= ents: + * - struct fuse_famfs_simple_ext + * - struct fuse_famfs_iext + * - struct fuse_famfs_fmap_header + * - Add the following enumerated types + * - enum fuse_famfs_file_type + * - enum famfs_ext_type */ =20 #ifndef _LINUX_FUSE_H @@ -1300,6 +1307,55 @@ struct fuse_uring_cmd_req { =20 /* Famfs fmap message components */ =20 +#define FAMFS_FMAP_VERSION 1 + #define FAMFS_FMAP_MAX 32768 /* Largest supported fmap message */ +#define FUSE_FAMFS_MAX_EXTENTS 32 +#define FUSE_FAMFS_MAX_STRIPS 32 + +enum fuse_famfs_file_type { + FUSE_FAMFS_FILE_REG, + FUSE_FAMFS_FILE_SUPERBLOCK, + FUSE_FAMFS_FILE_LOG, +}; + +enum famfs_ext_type { + FUSE_FAMFS_EXT_SIMPLE =3D 0, + FUSE_FAMFS_EXT_INTERLEAVE =3D 1, +}; + +struct fuse_famfs_simple_ext { + uint32_t se_devindex; + uint32_t reserved; + uint64_t se_offset; + uint64_t se_len; +}; + +struct fuse_famfs_iext { /* Interleaved extent */ + uint32_t ie_nstrips; + uint32_t ie_chunk_size; + uint64_t ie_nbytes; /* Total bytes for this interleaved_ext; + * sum of strips may be more + */ + uint64_t reserved; +}; + +struct fuse_famfs_fmap_header { + uint8_t file_type; /* enum famfs_file_type */ + uint8_t reserved; + uint16_t fmap_version; + uint32_t ext_type; /* enum famfs_log_ext_type */ + uint32_t nextents; + uint32_t reserved0; + uint64_t file_size; + uint64_t reserved1; +}; + +static inline int32_t fmap_msg_min_size(void) +{ + /* Smallest fmap message is a header plus one simple extent */ + return (sizeof(struct fuse_famfs_fmap_header) + + sizeof(struct fuse_famfs_simple_ext)); +} =20 #endif /* _LINUX_FUSE_H */ --=20 2.49.0 From nobody Wed Oct 8 00:27:10 2025 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 BC9332F6FA9; Thu, 3 Jul 2025 18:51:26 +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=1751568688; cv=none; b=pmgeQxPkiBWJconuyUP+Os2xlTRwfbLrYurCaM33tYmhaOdhBUtws6qQ4b3YdloHcqcMdDDVSzYmmhnAfizOcioXPllz2+m3FdadY5WoJKPi7U6BolkCPQnPImdlmuKshnGnfYkZf7BHRZ4EtFB69dcvVoqpJQhywoU1ZtSA2F8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751568688; c=relaxed/simple; bh=akSaRL3RX+WvtwUWvfOzwjDiTkfVYFgkfRs13hWFzFk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gjZTjdxVcHo3xSpv9oLo+ihvYgac7MSHRkkZzTpY9OFjuvpakn+iR6qDUHwKTaD+pmgjIRBxsWVkl9FWbO0d7Sk1jXzbhxMCVw38a83jLZZyGqQ7zwXOQ9k51MtB3i3sUbjzAQUpYMK621V1WdsqyrrkEEZWOUArPVXYVH2pyx8= 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=lGoKcBuw; 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="lGoKcBuw" Received: by mail-ot1-f47.google.com with SMTP id 46e09a7af769-735a6d7c5b1so152891a34.2; Thu, 03 Jul 2025 11:51:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751568685; x=1752173485; 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=CSYWWRwywlLa7gF9aEQucwjgFx3QvAjkIfteydqpUEU=; b=lGoKcBuwMCU9WzhyKjIAIrleojLKbkL1FO5UnqQdYdYqkDCst1fppbLcoe0n/qqhID xHJw7OGttbS7iU90Pz0yXbqkMAZutoa3zbHfu6eAKqypoQP1bFlkGEtpMHoPlKR0X1t+ ZpLdHanD7IkaL+b4dygij3cgd4gIS4nm44uF4IQQILk8YCWQQ0WkKPyONz1lFaWrNoZJ V7T45yfITTBPWpAp46H0DK/mAoMDzVZ3nSpkkTBL8zgFgjj797Nn5tv+s6wAuxeBnCg7 +yDD6cpVM7lZQp3l8ZB0dcc51pWwRlyXcUUF0JT2GT3q+impbVbN2+m9G21pHPmhDiSZ pCHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751568685; x=1752173485; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=CSYWWRwywlLa7gF9aEQucwjgFx3QvAjkIfteydqpUEU=; b=ZD0uLeOy0QW+IkK1k109W/5ob3BFGqyMRU7sO7uzv9UYQau2xmDmIfdO6W909Lc0WA PktjiqHjurcGWvwZJkfPSmfIU0AXr+UNr7xp+n3Ow4s6WMVuWFdK8Z3n+apWoUgIBlJ8 alNm4rpsBWi+aAkPOFb/TCkVce8PgZRFqLDCLkT0O1/HVpDe0GDMl6DZfsm1UaO74+WJ pR3ER+j0p6JelIUni4wgspn5tKAAIgW8de6fJp/ogdRdi0zRuD/s5d1Hdj717DLkPPwX 3RCRNKIuU0I4WKnp0Nwuxp2jVE5tlglRngs3rdv4QHWQti1QU8b3tPQjylIXa1aN9xoM N1hg== X-Forwarded-Encrypted: i=1; AJvYcCUmLaciwwXxSv4pDQxd05gMdC2gzGDMyhU7M/EmpHcEt1Wqd8klx7J64BkhhXAMfwzmd32KNFMl8D8cY6TW@vger.kernel.org, AJvYcCVQJ5ykixr6ReG/cRRe2h4C9SwMtOV2wKYu+4H6FJayzQAcHUTf1zdYoS2uuAHqdMZxjTmWtH/S+7WJ@vger.kernel.org, AJvYcCVqg4rBI1AEt3D7cr7iXiJQaK5iLXftisWidnGNZic5ertI0bwGoOYTOQFjBHUE9db1Wy0uwds6u80=@vger.kernel.org, AJvYcCWrEVjW9eHw1VES5SqHxPA8riNIpA0DTY3mY5Z6H3FYvE60ZO2FqhyWZbSs3aqMLUyjJhNN/LRgwRJZulXCtQ==@vger.kernel.org X-Gm-Message-State: AOJu0Yzrw8Qs8gN3llLBWnVzUvw0X4vWcoM9bTeK9zBrKWMWwAH9b5jR I/iBnjNLN+hKPp2wP9I6OVYeukmdPRZntncGpyuU42fjcmGgjdbqa6RX X-Gm-Gg: ASbGncsFxo+eGBWKjgRgVqj3Prj8f8K8WcJ2mtwDRSwKOvia4zSoZa7la175HL6iRUY YtRgNHUj9plAdn6wPIdYpYUofMaVNTloknkV0WWUVSgyl9rrSJr05O+ESEEQ3pTYCsjjZ4spE8s qZmPCdQWGTF1toyMAe1Jtin0tMkvhQQ+b9VhbPoSWZ+Vp5hnaF2T92pqijy8spznHWqnI2euiEp Obj1HduOwk406lqGytmdrzob2PVJ5lpSfCDxz0LeJFPJHhgU/OmUrzqPnNuTYc1kkJrf4klk8Pn y3IZZQNhhZRK82BGc7qlFkDM808YUJlNDiD4pnHKdVEXkmR8MPJQWdX0ikUtUYHOyU4BUJ4tdpj LJllxpKXXMygOwA== X-Google-Smtp-Source: AGHT+IFxF3BaEfdAPQz8g2KUep0eOXOM/aFDkALhw9dVTss75dxJINqAI1lP3b72xWIrM5//XNirxA== X-Received: by 2002:a05:6830:8104:b0:72b:93c9:41a6 with SMTP id 46e09a7af769-73c8c540f40mr2455436a34.20.1751568685472; Thu, 03 Jul 2025 11:51:25 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:cd4:2776:8c4a:3597]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-73c9f90d1ccsm68195a34.44.2025.07.03.11.51.23 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 03 Jul 2025 11:51:25 -0700 (PDT) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Dan Williams , Miklos Szeredi , Bernd Schubert Cc: John Groves , Jonathan Corbet , Vishal Verma , Dave Jiang , Matthew Wilcox , Jan Kara , Alexander Viro , Christian Brauner , "Darrick J . Wong" , Randy Dunlap , Jeff Layton , Kent Overstreet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, Amir Goldstein , Jonathan Cameron , Stefan Hajnoczi , Joanne Koong , Josef Bacik , Aravind Ramesh , Ajay Joshi , John Groves Subject: [RFC V2 14/18] famfs_fuse: GET_DAXDEV message and daxdev_table Date: Thu, 3 Jul 2025 13:50:28 -0500 Message-Id: <20250703185032.46568-15-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250703185032.46568-1-john@groves.net> References: <20250703185032.46568-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" * The new GET_DAXDEV message/response is enabled * The command it triggered by the update_daxdev_table() call, if there are any daxdevs in the subject fmap that are not represented in the daxdev_dable yet. Signed-off-by: John Groves --- fs/fuse/famfs.c | 227 ++++++++++++++++++++++++++++++++++++++ fs/fuse/famfs_kfmap.h | 26 +++++ fs/fuse/fuse_i.h | 1 + fs/fuse/inode.c | 4 +- fs/namei.c | 1 + include/uapi/linux/fuse.h | 18 +++ 6 files changed, 276 insertions(+), 1 deletion(-) diff --git a/fs/fuse/famfs.c b/fs/fuse/famfs.c index 41c4d92f1451..f5e01032b825 100644 --- a/fs/fuse/famfs.c +++ b/fs/fuse/famfs.c @@ -20,6 +20,230 @@ #include "famfs_kfmap.h" #include "fuse_i.h" =20 +/* + * famfs_teardown() + * + * Deallocate famfs metadata for a fuse_conn + */ +void /* XXX valid xfs or fuse format? */ +famfs_teardown(struct fuse_conn *fc) +{ + struct famfs_dax_devlist *devlist =3D fc->dax_devlist; + int i; + + fc->dax_devlist =3D NULL; + + if (!devlist) + return; + + if (!devlist->devlist) + goto out; + + /* Close & release all the daxdevs in our table */ + for (i =3D 0; i < devlist->nslots; i++) { + if (devlist->devlist[i].valid && devlist->devlist[i].devp) + fs_put_dax(devlist->devlist[i].devp, fc); + } + kfree(devlist->devlist); + +out: + kfree(devlist); +} + +static int +famfs_verify_daxdev(const char *pathname, dev_t *devno) +{ + struct inode *inode; + struct path path; + int err; + + if (!pathname || !*pathname) + return -EINVAL; + + err =3D kern_path(pathname, LOOKUP_FOLLOW, &path); + if (err) + return err; + + inode =3D d_backing_inode(path.dentry); + if (!S_ISCHR(inode->i_mode)) { + err =3D -EINVAL; + goto out_path_put; + } + + if (!may_open_dev(&path)) { /* had to export this */ + err =3D -EACCES; + goto out_path_put; + } + + *devno =3D inode->i_rdev; + +out_path_put: + path_put(&path); + return err; +} + +/** + * famfs_fuse_get_daxdev() - Retrieve info for a DAX device from fuse serv= er + * + * Send a GET_DAXDEV message to the fuse server to retrieve info on a + * dax device. + * + * @fm: fuse_mount + * @index: the index of the dax device; daxdevs are referred to by index + * in fmaps, and the server resolves the index to a particular da= xdev + * + * Returns: 0=3Dsuccess + * -errno=3Dfailure + */ +static int +famfs_fuse_get_daxdev(struct fuse_mount *fm, const u64 index) +{ + struct fuse_daxdev_out daxdev_out =3D { 0 }; + struct fuse_conn *fc =3D fm->fc; + struct famfs_daxdev *daxdev; + int err =3D 0; + + FUSE_ARGS(args); + + /* Store the daxdev in our table */ + if (index >=3D fc->dax_devlist->nslots) { + pr_err("%s: index(%lld) > nslots(%d)\n", + __func__, index, fc->dax_devlist->nslots); + err =3D -EINVAL; + goto out; + } + + args.opcode =3D FUSE_GET_DAXDEV; + args.nodeid =3D index; + + args.in_numargs =3D 0; + + args.out_numargs =3D 1; + args.out_args[0].size =3D sizeof(daxdev_out); + args.out_args[0].value =3D &daxdev_out; + + /* Send GET_DAXDEV command */ + err =3D fuse_simple_request(fm, &args); + if (err) { + pr_err("%s: err=3D%d from fuse_simple_request()\n", + __func__, err); + /* + * Error will be that the payload is smaller than FMAP_BUFSIZE, + * which is the max we can handle. Empty payload handled below. + */ + goto out; + } + + down_write(&fc->famfs_devlist_sem); + + daxdev =3D &fc->dax_devlist->devlist[index]; + + /* Abort if daxdev is now valid */ + if (daxdev->valid) { + up_write(&fc->famfs_devlist_sem); + /* We already have a valid entry at this index */ + err =3D -EALREADY; + goto out; + } + + /* Verify that the dev is valid and can be opened and gets the devno */ + err =3D famfs_verify_daxdev(daxdev_out.name, &daxdev->devno); + if (err) { + up_write(&fc->famfs_devlist_sem); + pr_err("%s: err=3D%d from famfs_verify_daxdev()\n", __func__, err); + goto out; + } + + /* This will fail if it's not a dax device */ + daxdev->devp =3D dax_dev_get(daxdev->devno); + if (!daxdev->devp) { + up_write(&fc->famfs_devlist_sem); + pr_warn("%s: device %s not found or not dax\n", + __func__, daxdev_out.name); + err =3D -ENODEV; + goto out; + } + + daxdev->name =3D kstrdup(daxdev_out.name, GFP_KERNEL); + wmb(); /* all daxdev fields must be visible before marking it valid */ + daxdev->valid =3D 1; + + up_write(&fc->famfs_devlist_sem); + +out: + return err; +} + +/** + * famfs_update_daxdev_table() - Update the daxdev table + * @fm - fuse_mount + * @meta - famfs_file_meta, in-memory format, built from a GET_FMAP respon= se + * + * This function is called for each new file fmap, to verify whether all + * referenced daxdevs are already known (i.e. in the table). Any daxdev + * indices that referenced in @meta but not in the table will be retrieved= via + * famfs_fuse_get_daxdev() and added to the table + * + * Return: 0=3Dsuccess + * -errno=3Dfailure + */ +static int +famfs_update_daxdev_table( + struct fuse_mount *fm, + const struct famfs_file_meta *meta) +{ + struct famfs_dax_devlist *local_devlist; + struct fuse_conn *fc =3D fm->fc; + int err; + int i; + + /* First time through we will need to allocate the dax_devlist */ + if (!fc->dax_devlist) { + local_devlist =3D kcalloc(1, sizeof(*fc->dax_devlist), GFP_KERNEL); + if (!local_devlist) + return -ENOMEM; + + local_devlist->nslots =3D MAX_DAXDEVS; + + local_devlist->devlist =3D kcalloc(MAX_DAXDEVS, + sizeof(struct famfs_daxdev), + GFP_KERNEL); + if (!local_devlist->devlist) { + kfree(local_devlist); + return -ENOMEM; + } + + /* We don't need the famfs_devlist_sem here because we use cmpxchg... */ + if (cmpxchg(&fc->dax_devlist, NULL, local_devlist) !=3D NULL) { + kfree(local_devlist->devlist); + kfree(local_devlist); /* another thread beat us to it */ + } + } + + down_read(&fc->famfs_devlist_sem); + for (i =3D 0; i < fc->dax_devlist->nslots; i++) { + if (meta->dev_bitmap & (1ULL << i)) { + /* This file meta struct references devindex i + * if devindex i isn't in the table; get it... + */ + if (!(fc->dax_devlist->devlist[i].valid)) { + up_read(&fc->famfs_devlist_sem); + + err =3D famfs_fuse_get_daxdev(fm, i); + if (err) + pr_err("%s: failed to get daxdev=3D%d\n", + __func__, i); + + down_read(&fc->famfs_devlist_sem); + } + } + } + up_read(&fc->famfs_devlist_sem); + + return 0; +} + +/*************************************************************************= **/ =20 void __famfs_meta_free(void *famfs_meta) @@ -336,6 +560,9 @@ famfs_file_init_dax( if (rc) goto errout; =20 + /* Make sure this fmap doesn't reference any unknown daxdevs */ + famfs_update_daxdev_table(fm, meta); + /* Publish the famfs metadata on fi->famfs_meta */ inode_lock(inode); if (fi->famfs_meta) { diff --git a/fs/fuse/famfs_kfmap.h b/fs/fuse/famfs_kfmap.h index ce785d76719c..f79707b9f761 100644 --- a/fs/fuse/famfs_kfmap.h +++ b/fs/fuse/famfs_kfmap.h @@ -60,4 +60,30 @@ struct famfs_file_meta { }; }; =20 +/** + * famfs_daxdev - tracking struct for a daxdev within a famfs file system + * + * This is the in-memory daxdev metadata that is populated by + * the responses to GET_FMAP messages + */ +struct famfs_daxdev { + /* Include dev uuid? */ + bool valid; + bool error; + dev_t devno; + struct dax_device *devp; + char *name; +}; + +#define MAX_DAXDEVS 24 + +/** + * famfs_dax_devlist - list of famfs_daxdev's + */ +struct famfs_dax_devlist { + int nslots; + int ndevs; + struct famfs_daxdev *devlist; /* XXX: make this an xarray! */ +}; + #endif /* FAMFS_KFMAP_H */ diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index fb6095655403..37298551539c 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -1565,6 +1565,7 @@ int famfs_file_init_dax(struct fuse_mount *fm, struct inode *inode, void *fmap_buf, size_t fmap_size); void __famfs_meta_free(void *map); +void famfs_teardown(struct fuse_conn *fc); #endif =20 static inline struct fuse_backing *famfs_meta_set(struct fuse_inode *fi, diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 1682755abf30..c29e9d96ea92 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -1049,8 +1049,10 @@ void fuse_conn_put(struct fuse_conn *fc) } if (IS_ENABLED(CONFIG_FUSE_PASSTHROUGH)) fuse_backing_files_free(fc); - if (IS_ENABLED(CONFIG_FUSE_FAMFS_DAX)) + if (IS_ENABLED(CONFIG_FUSE_FAMFS_DAX)) { kfree(fc->shadow); + famfs_teardown(fc); + } call_rcu(&fc->rcu, delayed_release); } } diff --git a/fs/namei.c b/fs/namei.c index ecb7b95c2ca3..75a1e1d46593 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3380,6 +3380,7 @@ bool may_open_dev(const struct path *path) return !(path->mnt->mnt_flags & MNT_NODEV) && !(path->mnt->mnt_sb->s_iflags & SB_I_NODEV); } +EXPORT_SYMBOL(may_open_dev); =20 static int may_open(struct mnt_idmap *idmap, const struct path *path, int acc_mode, int flag) diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h index ecaaa62910f0..8a81b6c334fe 100644 --- a/include/uapi/linux/fuse.h +++ b/include/uapi/linux/fuse.h @@ -235,6 +235,9 @@ * - struct fuse_famfs_simple_ext * - struct fuse_famfs_iext * - struct fuse_famfs_fmap_header + * - Add the following structs for the GET_DAXDEV message and reply + * - struct fuse_get_daxdev_in + * - struct fuse_get_daxdev_out * - Add the following enumerated types * - enum fuse_famfs_file_type * - enum famfs_ext_type @@ -1351,6 +1354,20 @@ struct fuse_famfs_fmap_header { uint64_t reserved1; }; =20 +struct fuse_get_daxdev_in { + uint32_t daxdev_num; +}; + +#define DAXDEV_NAME_MAX 256 +struct fuse_daxdev_out { + uint16_t index; + uint16_t reserved; + uint32_t reserved2; + uint64_t reserved3; /* enough space for a uuid if we need it */ + uint64_t reserved4; + char name[DAXDEV_NAME_MAX]; +}; + static inline int32_t fmap_msg_min_size(void) { /* Smallest fmap message is a header plus one simple extent */ @@ -1358,4 +1375,5 @@ static inline int32_t fmap_msg_min_size(void) + sizeof(struct fuse_famfs_simple_ext)); } =20 + #endif /* _LINUX_FUSE_H */ --=20 2.49.0 From nobody Wed Oct 8 00:27:10 2025 Received: from mail-oo1-f41.google.com (mail-oo1-f41.google.com [209.85.161.41]) (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 6D50F2F6F9E; Thu, 3 Jul 2025 18:51:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751568693; cv=none; b=f53m+VWfnDOXOorHFgdsWH55u6xaetxhJ0LmizNGJ8nt4ivqJj/PRG5VSYk/GnleWYQJTPlUx5TYUvWCFZJmpYF3m8z+eKM9I0TxOirVAMwLHgm9muR9qVFqnVxjVC6e7qYh+cQElAw7eQtEfo/X5jGksVX8ln7OpYLlNB+R4sE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751568693; c=relaxed/simple; bh=BOJsAT5JU9yIFYDpfXEyB9+S+7Hv/3A62M+Z0QOijvU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VTPjafO2x8hF5jaIJiZP6Rcr0St2zu8p1dE07u34MB1OVnZ2RQ1SNzoJ9klKOZlQiywEYqKdGnv0xxXKU6D3UMKwlIw25hsrjn7MY1bUou3YxwC9Ntme+VdtWXN3okNCxTkFWvX6rnWAgx20RqmaU5+nh6P7BlFGK/wSilXBJY0= 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=iYRdxbEI; arc=none smtp.client-ip=209.85.161.41 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="iYRdxbEI" Received: by mail-oo1-f41.google.com with SMTP id 006d021491bc7-6113f0cafb2so142458eaf.1; Thu, 03 Jul 2025 11:51:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751568689; x=1752173489; 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=WFyIPtwb+f2wfKhEolNXeubDWmjHM8QVbI6ON/boaXs=; b=iYRdxbEISYFe1oC4C3AO9Np85SWKm11rlYbX4X9x2gNsUj3TzOg9CZmNegVhraHgxM mWSpZBZzGP1/WfHaQjWs4fLxQhQr51ry9q9uw3z4sYt42U/k1+FfeymBXSqxuUGhK8FU kBuwHNXN2lNd1/bLSBAGYd/y1i3jR9vLU3KxXfeH4tP16N1GWULa8uHukH//FGN1ImI5 4l/isbg6u6ibexheYaZaYJwmJgpInXhUt86AvWGHaY9FMv1SNVLRbzps1jCvgiI3+ql2 2cGREwBXepDHqSAHuO8NNF0ji9pHVk+NcOQZtHqW0aPoidEBlYIRO5MVYMCkawNZiOgd uqIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751568689; x=1752173489; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=WFyIPtwb+f2wfKhEolNXeubDWmjHM8QVbI6ON/boaXs=; b=ObxRVhriHer4b6RoAgYNCr3M7dTOCvF1rK7nbq3B2rChnloy4qQhs5K/02MvYlcVAH GDk0qUyqCw8KYIe2eJDGWwKyHbV9LmRuIQigDJ6GEOCpKwW0DsIjiVdqJpQ9LpzsIHPh Sann0YUkztOwafHLF2oTJw9l4W+kqCUkRgCGTC9Vbd6YDZlO15cIU24Fj3Gt3p4VGiOe t4pNhTZkK2AXEthv6J0ood3lrSvCC0laXGObZQs01hLA/huVjO0WDkgsPSVMrlidEY4e rTggvKQXmBnWjw+Dewr3IGSbxvBNZSdTf62j6iHk06xGeiG+dbSwtGGDnMv+gkPtpoWK BQpw== X-Forwarded-Encrypted: i=1; AJvYcCU9FECwdlrTaUuYOM9M3ReOkqVnrJRQ7QxxKdwnzDzoInuwCsWwhIONM01CUSObtA/oPYYwE9csE+dgGLfL/A==@vger.kernel.org, AJvYcCUxIAml3xkrPKFq04HUupL57t7Qtxe/pqmwCgXwhkmG2nZDTB7VUqRVZTPPBnkx3r7B6GrbL5G3zdvz@vger.kernel.org, AJvYcCWNhoFc7OQXhGPIBSTs3ihl/1iT8tvi2Tv6WDrs1cMnspNWaebnaJ/AhrbV6dcbD0CPXXtErYkxv0hvK4Sd@vger.kernel.org, AJvYcCWt+GYkLtXMyuuCZkWsER3O2L0TBaYP4dW1+Zi+bTKJbzjT7AlmLYiYdhAmneWUUAE7xtzWTBY+2bE=@vger.kernel.org X-Gm-Message-State: AOJu0YyhCPLFcx1S8+gnLli81pf65zlwP9IUlTzRQaOrxWSP7XkeW1Se mFU7gzhpRdaRKQulYOOfjpQWM7Y6W6xgP5ZqI8gbyfPauruZb1xVe7rs X-Gm-Gg: ASbGnctFxMo1YXugbw2AnGovc0YzhhflzOdfYIwSf2h4zkzHNVo6dL4S5VL6hK4MTPl +DmbHYfWCHyG8XOTRyX+PZG1Z0AotjU5pSiD0xzQ3RAsrop9h/tfbn3QLPe6OGWuKQWQRvLTzki 65fRDEEmLGGNF/7LAX9Er3HMzGmVK4OdmuCg5fq6IpT9Y8oWsdiLHzFwaHIuC3mB1awYT15BsJn uhQKg55zdt2So/pLc3855MVuiCmmm5Kx5nDMwjHnXTxahks7tYoEa34J7C9Nue7A3Wx14GNimur 4RYuifYzFrUcFTV1kBDFSvKkRTC8UmsLy1pSvVVeomXG5RSdFL0kZ8o6qoOlRhIUgmGV+hEwA8j mJcFmEdgFFXugVQ== X-Google-Smtp-Source: AGHT+IF4/AsU3hXYlgzsQBOZuCM/ZTnM/cRNgmQIpHz32m+WBgqaD9fRFFVAIOuVCyBfHh/4SEtLSQ== X-Received: by 2002:a05:6820:4b17:b0:611:31a:6ff5 with SMTP id 006d021491bc7-6120116eb87mr6669807eaf.7.1751568689254; Thu, 03 Jul 2025 11:51:29 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:cd4:2776:8c4a:3597]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-73c9f90d1ccsm68195a34.44.2025.07.03.11.51.26 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 03 Jul 2025 11:51:28 -0700 (PDT) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Dan Williams , Miklos Szeredi , Bernd Schubert Cc: John Groves , Jonathan Corbet , Vishal Verma , Dave Jiang , Matthew Wilcox , Jan Kara , Alexander Viro , Christian Brauner , "Darrick J . Wong" , Randy Dunlap , Jeff Layton , Kent Overstreet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, Amir Goldstein , Jonathan Cameron , Stefan Hajnoczi , Joanne Koong , Josef Bacik , Aravind Ramesh , Ajay Joshi , John Groves Subject: [RFC V2 15/18] famfs_fuse: Plumb dax iomap and fuse read/write/mmap Date: Thu, 3 Jul 2025 13:50:29 -0500 Message-Id: <20250703185032.46568-16-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250703185032.46568-1-john@groves.net> References: <20250703185032.46568-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" This commit fills in read/write/mmap handling for famfs files. The dev_dax_iomap interface is used - just like xfs in fs-dax mode. Signed-off-by: John Groves --- fs/fuse/famfs.c | 436 +++++++++++++++++++++++++++++++++++++++++++++++ fs/fuse/file.c | 14 ++ fs/fuse/fuse_i.h | 3 + 3 files changed, 453 insertions(+) diff --git a/fs/fuse/famfs.c b/fs/fuse/famfs.c index f5e01032b825..1973eb10b60b 100644 --- a/fs/fuse/famfs.c +++ b/fs/fuse/famfs.c @@ -585,3 +585,439 @@ famfs_file_init_dax( return rc; } =20 +/********************************************************************* + * iomap_operations + * + * This stuff uses the iomap (dax-related) helpers to resolve file offsets= to + * offsets within a dax device. + */ + +static ssize_t famfs_file_bad(struct inode *inode); + +static int +famfs_interleave_fileofs_to_daxofs(struct inode *inode, struct iomap *ioma= p, + loff_t file_offset, off_t len, unsigned int flags) +{ + struct fuse_inode *fi =3D get_fuse_inode(inode); + struct famfs_file_meta *meta =3D fi->famfs_meta; + struct fuse_conn *fc =3D get_fuse_conn(inode); + loff_t local_offset =3D file_offset; + int i; + + /* This function is only for extent_type INTERLEAVED_EXTENT */ + if (meta->fm_extent_type !=3D INTERLEAVED_EXTENT) { + pr_err("%s: bad extent type\n", __func__); + goto err_out; + } + + if (famfs_file_bad(inode)) + goto err_out; + + iomap->offset =3D file_offset; + + for (i =3D 0; i < meta->fm_niext; i++) { + struct famfs_meta_interleaved_ext *fei =3D &meta->ie[i]; + u64 chunk_size =3D fei->fie_chunk_size; + u64 nstrips =3D fei->fie_nstrips; + u64 ext_size =3D fei->fie_nbytes; + + ext_size =3D min_t(u64, ext_size, meta->file_size); + + if (ext_size =3D=3D 0) { + pr_err("%s: ext_size=3D%lld file_size=3D%ld\n", + __func__, fei->fie_nbytes, meta->file_size); + goto err_out; + } + + /* Is the data is in this striped extent? */ + if (local_offset < ext_size) { + u64 chunk_num =3D local_offset / chunk_size; + u64 chunk_offset =3D local_offset % chunk_size; + u64 stripe_num =3D chunk_num / nstrips; + u64 strip_num =3D chunk_num % nstrips; + u64 chunk_remainder =3D chunk_size - chunk_offset; + u64 strip_offset =3D chunk_offset + (stripe_num * chunk_size); + u64 strip_dax_ofs =3D fei->ie_strips[strip_num].ext_offset; + u64 strip_devidx =3D fei->ie_strips[strip_num].dev_index; + + if (!fc->dax_devlist->devlist[strip_devidx].valid) { + pr_err("%s: daxdev=3D%lld invalid\n", __func__, + strip_devidx); + goto err_out; + } + iomap->addr =3D strip_dax_ofs + strip_offset; + iomap->offset =3D file_offset; + iomap->length =3D min_t(loff_t, len, chunk_remainder); + + iomap->dax_dev =3D fc->dax_devlist->devlist[strip_devidx].devp; + + iomap->type =3D IOMAP_MAPPED; + iomap->flags =3D flags; + + return 0; + } + local_offset -=3D ext_size; /* offset is beyond this striped extent */ + } + + err_out: + pr_err("%s: err_out\n", __func__); + + /* We fell out the end of the extent list. + * Set iomap to zero length in this case, and return 0 + * This just means that the r/w is past EOF + */ + iomap->addr =3D 0; /* there is no valid dax device offset */ + iomap->offset =3D file_offset; /* file offset */ + iomap->length =3D 0; /* this had better result in no access to dax mem */ + iomap->dax_dev =3D NULL; + iomap->type =3D IOMAP_MAPPED; + iomap->flags =3D flags; + + return 0; +} + +/** + * famfs_fileofs_to_daxofs() - Resolve (file, offset, len) to (daxdev, off= set, len) + * + * This function is called by famfs_fuse_iomap_begin() to resolve an offse= t in a + * file to an offset in a dax device. This is upcalled from dax from calls= to + * both * dax_iomap_fault() and dax_iomap_rw(). Dax finishes the job reso= lving + * a fault to a specific physical page (the fault case) or doing a memcpy + * variant (the rw case) + * + * Pages can be PTE (4k), PMD (2MiB) or (theoretically) PuD (1GiB) + * (these sizes are for X86; may vary on other cpu architectures + * + * @inode: The file where the fault occurred + * @iomap: To be filled in to indicate where to find the right memor= y, + * relative to a dax device. + * @file_offset: Within the file where the fault occurred (will be page bo= undary) + * @len: The length of the faulted mapping (will be a page multipl= e) + * (will be trimmed in *iomap if it's disjoint in the extent= list) + * @flags: + * + * Return values: 0. (info is returned in a modified @iomap struct) + */ +static int +famfs_fileofs_to_daxofs(struct inode *inode, struct iomap *iomap, + loff_t file_offset, off_t len, unsigned int flags) +{ + struct fuse_inode *fi =3D get_fuse_inode(inode); + struct famfs_file_meta *meta =3D fi->famfs_meta; + struct fuse_conn *fc =3D get_fuse_conn(inode); + loff_t local_offset =3D file_offset; + int i; + + if (!fc->dax_devlist) { + pr_err("%s: null dax_devlist\n", __func__); + goto err_out; + } + + if (famfs_file_bad(inode)) + goto err_out; + + if (meta->fm_extent_type =3D=3D INTERLEAVED_EXTENT) + return famfs_interleave_fileofs_to_daxofs(inode, iomap, + file_offset, + len, flags); + + iomap->offset =3D file_offset; + + for (i =3D 0; i < meta->fm_nextents; i++) { + /* TODO: check devindex too */ + loff_t dax_ext_offset =3D meta->se[i].ext_offset; + loff_t dax_ext_len =3D meta->se[i].ext_len; + u64 daxdev_idx =3D meta->se[i].dev_index; + + if ((dax_ext_offset =3D=3D 0) && + (meta->file_type !=3D FAMFS_SUPERBLOCK)) + pr_warn("%s: zero offset on non-superblock file!!\n", + __func__); + + /* local_offset is the offset minus the size of extents skipped + * so far; If local_offset < dax_ext_len, the data of interest + * starts in this extent + */ + if (local_offset < dax_ext_len) { + loff_t ext_len_remainder =3D dax_ext_len - local_offset; + struct famfs_daxdev *dd; + + dd =3D &fc->dax_devlist->devlist[daxdev_idx]; + + if (!dd->valid || dd->error) { + pr_err("%s: daxdev=3D%lld %s\n", __func__, + daxdev_idx, + dd->valid ? "error" : "invalid"); + goto err_out; + } + + /* + * OK, we found the file metadata extent where this + * data begins + * @local_offset - The offset within the current + * extent + * @ext_len_remainder - Remaining length of ext after + * skipping local_offset + * Outputs: + * iomap->addr: the offset within the dax device where + * the data starts + * iomap->offset: the file offset + * iomap->length: the valid length resolved here + */ + iomap->addr =3D dax_ext_offset + local_offset; + iomap->offset =3D file_offset; + iomap->length =3D min_t(loff_t, len, ext_len_remainder); + + iomap->dax_dev =3D fc->dax_devlist->devlist[daxdev_idx].devp; + + iomap->type =3D IOMAP_MAPPED; + iomap->flags =3D flags; + return 0; + } + local_offset -=3D dax_ext_len; /* Get ready for the next extent */ + } + + err_out: + pr_err("%s: err_out\n", __func__); + + /* We fell out the end of the extent list. + * Set iomap to zero length in this case, and return 0 + * This just means that the r/w is past EOF + */ + iomap->addr =3D 0; /* there is no valid dax device offset */ + iomap->offset =3D file_offset; /* file offset */ + iomap->length =3D 0; /* this had better result in no access to dax mem */ + iomap->dax_dev =3D NULL; + iomap->type =3D IOMAP_MAPPED; + iomap->flags =3D flags; + + return 0; +} + +/** + * famfs_fuse_iomap_begin() - Handler for iomap_begin upcall from dax + * + * This function is pretty simple because files are + * * never partially allocated + * * never have holes (never sparse) + * * never "allocate on write" + * + * @inode: inode for the file being accessed + * @offset: offset within the file + * @length: Length being accessed at offset + * @flags: + * @iomap: iomap struct to be filled in, resolving (offset, length) to + * (daxdev, offset, len) + * @srcmap: + */ +static int +famfs_fuse_iomap_begin(struct inode *inode, loff_t offset, loff_t length, + unsigned int flags, struct iomap *iomap, struct iomap *srcmap) +{ + struct fuse_inode *fi =3D get_fuse_inode(inode); + struct famfs_file_meta *meta =3D fi->famfs_meta; + size_t size; + + size =3D i_size_read(inode); + + WARN_ON(size !=3D meta->file_size); + + return famfs_fileofs_to_daxofs(inode, iomap, offset, length, flags); +} + +/* Note: We never need a special set of write_iomap_ops because famfs never + * performs allocation on write. + */ +const struct iomap_ops famfs_iomap_ops =3D { + .iomap_begin =3D famfs_fuse_iomap_begin, +}; + +/********************************************************************* + * vm_operations + */ +static vm_fault_t +__famfs_fuse_filemap_fault(struct vm_fault *vmf, unsigned int pe_size, + bool write_fault) +{ + struct inode *inode =3D file_inode(vmf->vma->vm_file); + vm_fault_t ret; + pfn_t pfn; + + if (!IS_DAX(file_inode(vmf->vma->vm_file))) { + pr_err("%s: file not marked IS_DAX!!\n", __func__); + return VM_FAULT_SIGBUS; + } + + if (write_fault) { + sb_start_pagefault(inode->i_sb); + file_update_time(vmf->vma->vm_file); + } + + ret =3D dax_iomap_fault(vmf, pe_size, &pfn, NULL, &famfs_iomap_ops); + if (ret & VM_FAULT_NEEDDSYNC) + ret =3D dax_finish_sync_fault(vmf, pe_size, pfn); + + if (write_fault) + sb_end_pagefault(inode->i_sb); + + return ret; +} + +static inline bool +famfs_is_write_fault(struct vm_fault *vmf) +{ + return (vmf->flags & FAULT_FLAG_WRITE) && + (vmf->vma->vm_flags & VM_SHARED); +} + +static vm_fault_t +famfs_filemap_fault(struct vm_fault *vmf) +{ + return __famfs_fuse_filemap_fault(vmf, 0, famfs_is_write_fault(vmf)); +} + +static vm_fault_t +famfs_filemap_huge_fault(struct vm_fault *vmf, unsigned int pe_size) +{ + return __famfs_fuse_filemap_fault(vmf, pe_size, famfs_is_write_fault(vmf)= ); +} + +static vm_fault_t +famfs_filemap_page_mkwrite(struct vm_fault *vmf) +{ + return __famfs_fuse_filemap_fault(vmf, 0, true); +} + +static vm_fault_t +famfs_filemap_pfn_mkwrite(struct vm_fault *vmf) +{ + return __famfs_fuse_filemap_fault(vmf, 0, true); +} + +static vm_fault_t +famfs_filemap_map_pages(struct vm_fault *vmf, pgoff_t start_pgoff, + pgoff_t end_pgoff) +{ + return filemap_map_pages(vmf, start_pgoff, end_pgoff); +} + +const struct vm_operations_struct famfs_file_vm_ops =3D { + .fault =3D famfs_filemap_fault, + .huge_fault =3D famfs_filemap_huge_fault, + .map_pages =3D famfs_filemap_map_pages, + .page_mkwrite =3D famfs_filemap_page_mkwrite, + .pfn_mkwrite =3D famfs_filemap_pfn_mkwrite, +}; + +/********************************************************************* + * file_operations + */ + +/** + * famfs_file_bad() - Check for files that aren't in a valid state + * + * @inode - inode + * + * Returns: 0=3Dsuccess + * -errno=3Dfailure + */ +static ssize_t +famfs_file_bad(struct inode *inode) +{ + struct fuse_inode *fi =3D get_fuse_inode(inode); + struct famfs_file_meta *meta =3D fi->famfs_meta; + size_t i_size =3D i_size_read(inode); + + if (!meta) { + pr_err("%s: un-initialized famfs file\n", __func__); + return -EIO; + } + if (meta->error) { + pr_debug("%s: previously detected metadata errors\n", __func__); + return -EIO; + } + if (i_size !=3D meta->file_size) { + pr_warn("%s: i_size overwritten from %ld to %ld\n", + __func__, meta->file_size, i_size); + meta->error =3D true; + return -ENXIO; + } + if (!IS_DAX(inode)) { + pr_debug("%s: inode %llx IS_DAX is false\n", __func__, (u64)inode); + return -ENXIO; + } + return 0; +} + +static ssize_t +famfs_fuse_rw_prep(struct kiocb *iocb, struct iov_iter *ubuf) +{ + struct inode *inode =3D iocb->ki_filp->f_mapping->host; + size_t i_size =3D i_size_read(inode); + size_t count =3D iov_iter_count(ubuf); + size_t max_count; + ssize_t rc; + + rc =3D famfs_file_bad(inode); + if (rc) + return rc; + + max_count =3D max_t(size_t, 0, i_size - iocb->ki_pos); + + if (count > max_count) + iov_iter_truncate(ubuf, max_count); + + if (!iov_iter_count(ubuf)) + return 0; + + return rc; +} + +ssize_t +famfs_fuse_read_iter(struct kiocb *iocb, struct iov_iter *to) +{ + ssize_t rc; + + rc =3D famfs_fuse_rw_prep(iocb, to); + if (rc) + return rc; + + if (!iov_iter_count(to)) + return 0; + + rc =3D dax_iomap_rw(iocb, to, &famfs_iomap_ops); + + file_accessed(iocb->ki_filp); + return rc; +} + +ssize_t +famfs_fuse_write_iter(struct kiocb *iocb, struct iov_iter *from) +{ + ssize_t rc; + + rc =3D famfs_fuse_rw_prep(iocb, from); + if (rc) + return rc; + + if (!iov_iter_count(from)) + return 0; + + return dax_iomap_rw(iocb, from, &famfs_iomap_ops); +} + +int +famfs_fuse_mmap(struct file *file, struct vm_area_struct *vma) +{ + struct inode *inode =3D file_inode(file); + ssize_t rc; + + rc =3D famfs_file_bad(inode); + if (rc) + return (int)rc; + + file_accessed(file); + vma->vm_ops =3D &famfs_file_vm_ops; + vm_flags_set(vma, VM_HUGEPAGE); + return 0; +} diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 5d205eadb48f..24a14b176510 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1874,6 +1874,8 @@ static ssize_t fuse_file_read_iter(struct kiocb *iocb= , struct iov_iter *to) =20 if (FUSE_IS_VIRTIO_DAX(fi)) return fuse_dax_read_iter(iocb, to); + if (fuse_file_famfs(fi)) + return famfs_fuse_read_iter(iocb, to); =20 /* FOPEN_DIRECT_IO overrides FOPEN_PASSTHROUGH */ if (ff->open_flags & FOPEN_DIRECT_IO) @@ -1896,6 +1898,8 @@ static ssize_t fuse_file_write_iter(struct kiocb *ioc= b, struct iov_iter *from) =20 if (FUSE_IS_VIRTIO_DAX(fi)) return fuse_dax_write_iter(iocb, from); + if (fuse_file_famfs(fi)) + return famfs_fuse_write_iter(iocb, from); =20 /* FOPEN_DIRECT_IO overrides FOPEN_PASSTHROUGH */ if (ff->open_flags & FOPEN_DIRECT_IO) @@ -1911,10 +1915,14 @@ static ssize_t fuse_splice_read(struct file *in, lo= ff_t *ppos, unsigned int flags) { struct fuse_file *ff =3D in->private_data; + struct inode *inode =3D file_inode(in); + struct fuse_inode *fi =3D get_fuse_inode(inode); =20 /* FOPEN_DIRECT_IO overrides FOPEN_PASSTHROUGH */ if (fuse_file_passthrough(ff) && !(ff->open_flags & FOPEN_DIRECT_IO)) return fuse_passthrough_splice_read(in, ppos, pipe, len, flags); + else if (fuse_file_famfs(fi)) + return -EIO; /* direct I/O doesn't make sense in dax_iomap */ else return filemap_splice_read(in, ppos, pipe, len, flags); } @@ -1923,10 +1931,14 @@ static ssize_t fuse_splice_write(struct pipe_inode_= info *pipe, struct file *out, loff_t *ppos, size_t len, unsigned int flags) { struct fuse_file *ff =3D out->private_data; + struct inode *inode =3D file_inode(out); + struct fuse_inode *fi =3D get_fuse_inode(inode); =20 /* FOPEN_DIRECT_IO overrides FOPEN_PASSTHROUGH */ if (fuse_file_passthrough(ff) && !(ff->open_flags & FOPEN_DIRECT_IO)) return fuse_passthrough_splice_write(pipe, out, ppos, len, flags); + else if (fuse_file_famfs(fi)) + return -EIO; /* direct I/O doesn't make sense in dax_iomap */ else return iter_file_splice_write(pipe, out, ppos, len, flags); } @@ -2732,6 +2744,8 @@ static int fuse_file_mmap(struct file *file, struct v= m_area_struct *vma) /* DAX mmap is superior to direct_io mmap */ if (FUSE_IS_VIRTIO_DAX(fi)) return fuse_dax_mmap(file, vma); + if (fuse_file_famfs(fi)) + return famfs_fuse_mmap(file, vma); =20 /* * If inode is in passthrough io mode, because it has some file open diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 37298551539c..3b3a1d95367f 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -1564,6 +1564,9 @@ extern void fuse_sysctl_unregister(void); int famfs_file_init_dax(struct fuse_mount *fm, struct inode *inode, void *fmap_buf, size_t fmap_size); +ssize_t famfs_fuse_write_iter(struct kiocb *iocb, struct iov_iter *from); +ssize_t famfs_fuse_read_iter(struct kiocb *iocb, struct iov_iter *to); +int famfs_fuse_mmap(struct file *file, struct vm_area_struct *vma); void __famfs_meta_free(void *map); void famfs_teardown(struct fuse_conn *fc); #endif --=20 2.49.0 From nobody Wed Oct 8 00:27:10 2025 Received: from mail-oi1-f176.google.com (mail-oi1-f176.google.com [209.85.167.176]) (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 D51362F85CF; Thu, 3 Jul 2025 18:51:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751568695; cv=none; b=TQSkAw3tzvKfqy6EmXzzrAd9wOMRUw8fJTRUJm6Jts6+r3nau5qqtL6Syhc9OM2lBcYXyS0BhiVcEFLv+H7LEA1x+vc8bqyaejncaiFWNnGkYW2Cp9GQ/31Ha5fJPDdO8kAJP9M8sjiPSzIdSGkU/oZvHL0WIi5sfRVeIAkoR/w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751568695; c=relaxed/simple; bh=PqmaxnJIHXHdpAtoc4Brn2JoOI6Zdfs/rpGuWzqN4FY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fsf5VreMJZj2RLbS0Cb/oPjcieTO+Bzokw90MB8lSgwgoOyNLL47+IEyCu6D8KAGoZ712cuCt1/2F+vIApAHFse+ZvFUSYRRzai71QY5BiEe7INjfMQ+KA3MTQSAQGPzmhJWBNS2vQCwBO7hvmhWn2eSJbKXr/FKheNzP1iKdKk= 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=alGk5z21; arc=none smtp.client-ip=209.85.167.176 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="alGk5z21" Received: by mail-oi1-f176.google.com with SMTP id 5614622812f47-40abe6f8f08so226686b6e.0; Thu, 03 Jul 2025 11:51:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751568693; x=1752173493; 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=JOOgV+Jpk1CRsXiqsiDMUbyUGi7OO3TH0ZkMJhZELeU=; b=alGk5z21EEM14eDXdC9KFUxRvQEOygUsOc9mOuJCr+phfoUEeHnutdCGWS0kyn19Xt kP3MS4qW2DkjKq7tIwU5HR2PBUI6Itwmkvm9Uo6/3VAk7t4j6fmgrlkdXoxgjgtQ5mz6 K3SI/RAEHKzBMdhgIudnD7z1hjMvGR1DUoy1qS1c8t4yDaM4n+P995/Kxf1aCtgh0AQ+ Q2oc1RvrUh0o/UzkteuVzKoAUZ2iZ9PQ96H8d9HIGliEObXiUaysqWLJj0kWbdB0mDN4 IZXeGGW5hZyVcWNVqnj+/hri+aR+glAgjunFviRBh3O27+bctFIUnDzLYJVlQIF0JzHr Eybw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751568693; x=1752173493; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=JOOgV+Jpk1CRsXiqsiDMUbyUGi7OO3TH0ZkMJhZELeU=; b=VmvUZlaneLB82DbpGswIxys/bg8mdUXMSifehIHHpCQifCPNnbUZsFpJp1Gm+Oax2O VhhVT2Y64W8ipbWg0CIdIZ6wsGm0aHiPKLnjNuX+7jQxQz9eLzO1794X5OdlRXKLbnuo hQNTCisdVv/rbEQJJrW27Ww6AXcnCMWyYWZ1Q7UfpMxJOzkHKoiR0rQ/91dJ9v8SO/Ec eDR7SgqToxOAqmqsqmd0VBYEAS+EEFHdK+2939rY8fvFyo8Is7crMx2TaZ9XilO1qGgj l5tccX1Ff6eBpFio9luDVc+dkEsU5QRIgdNfn0FSseTVHQZKfvgHR1f/60wYz7lbvbli a97A== X-Forwarded-Encrypted: i=1; AJvYcCUIr175H9GfBuSc+iziOOiactzqJh2favjvxtqCjBNmpzxMvsv80sqw2JSEQCmJFR7W58FJNVgXO90=@vger.kernel.org, AJvYcCWbD09sHJX/TcKZ9n6a8q/T3QW74aF5oYU1FB+VyUYIO8o3I1cTrAxh6nPFLko4bL+fzq6D/Z8i5Ti9K0Su@vger.kernel.org, AJvYcCWdcC38muUYNk9SPJqh9j67VRJKBT3EMC1018ZFhwnTHI39tVCXmy+jijz4qA1Cfo86OJw/zz8tyZDh@vger.kernel.org, AJvYcCWjPJfZjRfV1vvqk1rnAC8kNU2wSpePP3RZy/jKUt+0CfHf0UZNEljzHCdwIiVXsO0f747jKWKmYUMqARKOeA==@vger.kernel.org X-Gm-Message-State: AOJu0Yx1wPTDrFDrMNqJ2hl7ort8EUZto5A06SLg0OIQVGb8NV7mAPuZ bhEAKKizvDx2v/OyOYIEhM5iQ/XH/uQEUo7XNoa3YvQl2MJwHjM6lExa X-Gm-Gg: ASbGncvAirJ9ak5OLbf4oJoY0Sxx5w2tNSNPBjJh7XHhXGyHlw9AfYfvcH0ACtsqL8m mf6PoFtjMeFCAdA4EGXa2iHPDLKw1C0Y0nOnoHYxy3cvPR8OOMV5pEcbjOVCtpBaD1b8Bc+1x3O d2TAd0WUnHn0agBn/VwaA/PTobIE86FKpyTkwyoHadUXFagUybI3/a0D4b5JxrWZUMbpbY0j3Uk GGQKumBLLolBw/cV+CtNjXttOgjJU6GKQclWsjwVF7JfCv/sk67ZMk0mdkPfX+ux3cQAQ0QZpVa HMLsRg5Y6H4kQIH1QIyeFnMf8LIP+gWWwPKUDXmrRPXoK1AnuRWWu1TCd1uteL9KGFPSDzPVCXz iH5xcaohfPvLMWw== X-Google-Smtp-Source: AGHT+IF9Qqe/sVn4WtiU4VKCMm5wn96/NUIAh0VWVYCM001PD+1WVs4eZFRWpr4uPXB+DulmACrV7Q== X-Received: by 2002:a05:6808:1887:b0:3fa:82f6:f74d with SMTP id 5614622812f47-40b88e07fa0mr6745164b6e.23.1751568692616; Thu, 03 Jul 2025 11:51:32 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:cd4:2776:8c4a:3597]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-73c9f90d1ccsm68195a34.44.2025.07.03.11.51.30 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 03 Jul 2025 11:51:31 -0700 (PDT) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Dan Williams , Miklos Szeredi , Bernd Schubert Cc: John Groves , Jonathan Corbet , Vishal Verma , Dave Jiang , Matthew Wilcox , Jan Kara , Alexander Viro , Christian Brauner , "Darrick J . Wong" , Randy Dunlap , Jeff Layton , Kent Overstreet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, Amir Goldstein , Jonathan Cameron , Stefan Hajnoczi , Joanne Koong , Josef Bacik , Aravind Ramesh , Ajay Joshi , John Groves Subject: [RFC V2 16/18] famfs_fuse: Add holder_operations for dax notify_failure() Date: Thu, 3 Jul 2025 13:50:30 -0500 Message-Id: <20250703185032.46568-17-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250703185032.46568-1-john@groves.net> References: <20250703185032.46568-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" If we get a notify_failure() call on a daxdev, set its error flag and prevent further access to that device. Signed-off-by: John Groves --- fs/fuse/famfs.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 3 deletions(-) diff --git a/fs/fuse/famfs.c b/fs/fuse/famfs.c index 1973eb10b60b..62c01d5b9d78 100644 --- a/fs/fuse/famfs.c +++ b/fs/fuse/famfs.c @@ -20,6 +20,26 @@ #include "famfs_kfmap.h" #include "fuse_i.h" =20 +static void famfs_set_daxdev_err( + struct fuse_conn *fc, struct dax_device *dax_devp); + +static int +famfs_dax_notify_failure(struct dax_device *dax_devp, u64 offset, + u64 len, int mf_flags) +{ + struct fuse_conn *fc =3D dax_holder(dax_devp); + + famfs_set_daxdev_err(fc, dax_devp); + + return 0; +} + +static const struct dax_holder_operations famfs_fuse_dax_holder_ops =3D { + .notify_failure =3D famfs_dax_notify_failure, +}; + +/*************************************************************************= ****/ + /* * famfs_teardown() * @@ -164,6 +184,15 @@ famfs_fuse_get_daxdev(struct fuse_mount *fm, const u64= index) goto out; } =20 + err =3D fs_dax_get(daxdev->devp, fc, &famfs_fuse_dax_holder_ops); + if (err) { + up_write(&fc->famfs_devlist_sem); + pr_err("%s: fs_dax_get(%lld) failed\n", + __func__, (u64)daxdev->devno); + err =3D -EBUSY; + goto out; + } + daxdev->name =3D kstrdup(daxdev_out.name, GFP_KERNEL); wmb(); /* all daxdev fields must be visible before marking it valid */ daxdev->valid =3D 1; @@ -243,6 +272,38 @@ famfs_update_daxdev_table( return 0; } =20 +static void +famfs_set_daxdev_err( + struct fuse_conn *fc, + struct dax_device *dax_devp) +{ + int i; + + /* Gotta search the list by dax_devp; + * read lock because we're not adding or removing daxdev entries + */ + down_read(&fc->famfs_devlist_sem); + for (i =3D 0; i < fc->dax_devlist->nslots; i++) { + if (fc->dax_devlist->devlist[i].valid) { + struct famfs_daxdev *dd =3D &fc->dax_devlist->devlist[i]; + + if (dd->devp !=3D dax_devp) + continue; + + dd->error =3D true; + up_read(&fc->famfs_devlist_sem); + + pr_err("%s: memory error on daxdev %s (%d)\n", + __func__, dd->name, i); + goto done; + } + } + up_read(&fc->famfs_devlist_sem); + pr_err("%s: memory err on unrecognized daxdev\n", __func__); + +done: +} + /*************************************************************************= **/ =20 void @@ -631,6 +692,7 @@ famfs_interleave_fileofs_to_daxofs(struct inode *inode,= struct iomap *iomap, =20 /* Is the data is in this striped extent? */ if (local_offset < ext_size) { + struct famfs_daxdev *dd; u64 chunk_num =3D local_offset / chunk_size; u64 chunk_offset =3D local_offset % chunk_size; u64 stripe_num =3D chunk_num / nstrips; @@ -640,9 +702,11 @@ famfs_interleave_fileofs_to_daxofs(struct inode *inode= , struct iomap *iomap, u64 strip_dax_ofs =3D fei->ie_strips[strip_num].ext_offset; u64 strip_devidx =3D fei->ie_strips[strip_num].dev_index; =20 - if (!fc->dax_devlist->devlist[strip_devidx].valid) { - pr_err("%s: daxdev=3D%lld invalid\n", __func__, - strip_devidx); + dd =3D &fc->dax_devlist->devlist[strip_devidx]; + if (!dd->valid || dd->error) { + pr_err("%s: daxdev=3D%lld %s\n", __func__, + strip_devidx, + dd->valid ? "error" : "invalid"); goto err_out; } iomap->addr =3D strip_dax_ofs + strip_offset; --=20 2.49.0 From nobody Wed Oct 8 00:27:10 2025 Received: from mail-oa1-f45.google.com (mail-oa1-f45.google.com [209.85.160.45]) (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 D066D2F9492; Thu, 3 Jul 2025 18:51:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751568700; cv=none; b=tEwxl91dpQLSJqglIJdYQPngcYcfwtBroyl9ADxGWF6li4mwqbpvA2jbaYNAnCMg/QxB3ZPjMu2Ig4UkiEK28SMXt9Vy9qGf2+1GkGAmw4C90gHehmJ6Vkwg+p2sJP8LazauFZZr85enTAXG7mffgCJbHYXcAdxNbtRvjOMsDXA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751568700; c=relaxed/simple; bh=nISANB0XlQ0BLoj4/fUTHodInegZ2G/VHJowR2UMMe4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=tQrZXM4kSeZEMcZSKZfPAu+/5Xpl/2HqceWLGmeA24xiNU4POX7i1Z4qNFuj+p6nkM2CJMNI2UgV+m73K5MdUgv4SwcbcfQXjF0PeCYYb3iEfZechy/FSZIXvaHWCWX9ngiK3ikCzK5FmCiXoCiIAhp73xJ3R/NuOdvnHRLfcic= 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=OiqTCkpC; arc=none smtp.client-ip=209.85.160.45 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="OiqTCkpC" Received: by mail-oa1-f45.google.com with SMTP id 586e51a60fabf-2ea08399ec8so232630fac.1; Thu, 03 Jul 2025 11:51:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751568696; x=1752173496; 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=4P2ebQHmA7kMFafoMqaSVOZx8bY3tIBj6NaPdz6n/Mg=; b=OiqTCkpCzqTPAHGzSORGblX6AIYQXG2kJUj65O0TnlEZki8x9xKgLwAR/u0GQgD/N7 5SVTXbHbfYusduE7yyvu2HCcoxM9jdJO+JT4S0thFklfvvA7ikMNJ2Pm7pfq8/4uW941 jGjhQ3AEpmwwn9caSnsW66XtOAXyZR9wR34hiRsoatY/Iy/OtWdCVRuFzK4d6nDCVLaV R9FzMy059CFj/IKauQmTd7b7FoPZ6YVA2D2U59BSE2Qdpcb7igy6dBUkG3Wx4X439oxt ZFmtCr2TEwVwwBtj0n7od5nvBlGofSIvURLa/WL4gY01pIJuoJ5pMdCHkAczo9J46Zma FurQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751568696; x=1752173496; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=4P2ebQHmA7kMFafoMqaSVOZx8bY3tIBj6NaPdz6n/Mg=; b=ab/Ja6ZxzXyyaSVFnUlbbAKtAGeXwZRgIVrH2LibgD8YD7dz4NvD/J3PpYypsazPU9 laiuFC1RY3sPruROBXd5fOJ9A+u/Yswj02xQpEK2gX7sX3jC86QXNPDivIy411W8EQIM jZuir8yNPZ9cg1n/dPP65Uf4WCyqHpRVPMrotjcR9CtWUXSP5V1aInRjewRD6iZgZge1 4e1orqnzqGLfXeKgPiUnR8+7hCQFPtvP3MeH0gZAgnYohEV7rYPNb643Iq+FIfsy42tP bRrSPvfFjGOPf8n6Nt7HbtEYatmgWpaS7k0mkjgRo32/JykITObK2udMDj30jfysJDgp 3PLQ== X-Forwarded-Encrypted: i=1; AJvYcCUWKuM7XCtgBlZFz17v+3bvNImz6sNrqyLZcWmEZHxmXKLtlSmRPoLb7Cda6R36lO2VVp79C7jRbzghtZHD@vger.kernel.org, AJvYcCUmUf6Vi84v4NJEwaCcWt7rGSI5PSbsU2Xf1/rieerNbqyXWJtnjVb2NaxE1ISHUkAeAuaMsMQKQkZAcLhFcQ==@vger.kernel.org, AJvYcCVBlUQKXVgwMwWA/qAjJyqnFPuphz1OFxaH9erKfy3Ls79HP9b4IKTjANhlGw5BwDsKb/rGCW3p0XDg@vger.kernel.org, AJvYcCX/JaB7LHfmEc3cyZ6Lq41mylq1H+2lXqH4WBDplbA9OoaeVXH7rwvP2q9E49/JMXgG17Hg48j/ye0=@vger.kernel.org X-Gm-Message-State: AOJu0Yy5pk9LJAqhgXifokrRFmIHnr5b40UFMq35V3aZFMxVSH/DWuhs bXi5FC5GRFjlBTh6PW34IZ99dbgaZKejLprDG0Nm7W/eeVBMa1unU1dp X-Gm-Gg: ASbGnctSoW9JjMu+/l0LFilrWBL6HeoYKkwEq8WpQVmCPbEwlIQJ1km6RtuBC4osd35 jNPHruqfHHockJ0HCV+kWXpiyXvwo1y+mFZ2pQPe2Gq7kk2KPJv2ym7geUr+S6F5Nbw8iNgvdxI wkqxEcaypFd/tkMCIE1znnD2IcQtPD5PvYPOiG4WPbhiQIgFGdiej+jDuYc7iDFZ6DYlXVdxzar R1fCgkKpUk4GhsEAL7sDbFD78qIhz0uXnz9l65pQ2n8O7OM3DgyC7ENVaPT0+d+UMgA/hzr0V/E Lwxtb90QDWP2lHrjuYZcxCIytavSrm78///bKJKCWOeV+rspgwimx5e+ire0eJWjXPhEHG7gaUL Cw0xO50rMBTzScw== X-Google-Smtp-Source: AGHT+IFnaohm+1vpUnTkm3zoIOdovIzr+/8MuJ2xXxfmzv2Todd3FjvaTkrldDEH046PZ67gRIosKQ== X-Received: by 2002:a05:6871:68a:b0:2eb:87a9:7fc5 with SMTP id 586e51a60fabf-2f791de6e45mr6858fac.16.1751568695843; Thu, 03 Jul 2025 11:51:35 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:cd4:2776:8c4a:3597]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-73c9f90d1ccsm68195a34.44.2025.07.03.11.51.32 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 03 Jul 2025 11:51:34 -0700 (PDT) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Dan Williams , Miklos Szeredi , Bernd Schubert Cc: John Groves , Jonathan Corbet , Vishal Verma , Dave Jiang , Matthew Wilcox , Jan Kara , Alexander Viro , Christian Brauner , "Darrick J . Wong" , Randy Dunlap , Jeff Layton , Kent Overstreet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, Amir Goldstein , Jonathan Cameron , Stefan Hajnoczi , Joanne Koong , Josef Bacik , Aravind Ramesh , Ajay Joshi , John Groves Subject: [RFC V2 17/18] famfs_fuse: Add famfs metadata documentation Date: Thu, 3 Jul 2025 13:50:31 -0500 Message-Id: <20250703185032.46568-18-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250703185032.46568-1-john@groves.net> References: <20250703185032.46568-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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: John Groves This describes the fmap metadata - both simple and interleaved Signed-off-by: John Groves --- fs/fuse/famfs_kfmap.h | 87 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 82 insertions(+), 5 deletions(-) diff --git a/fs/fuse/famfs_kfmap.h b/fs/fuse/famfs_kfmap.h index f79707b9f761..2c317554b151 100644 --- a/fs/fuse/famfs_kfmap.h +++ b/fs/fuse/famfs_kfmap.h @@ -7,10 +7,87 @@ #ifndef FAMFS_KFMAP_H #define FAMFS_KFMAP_H =20 +/* KABI version 43 (aka v2) fmap structures + * + * The location of the memory backing for a famfs file is described by + * the response to the GET_FMAP fuse message (defined in + * include/uapi/linux/fuse.h + * + * There are currently two extent formats: Simple and Interleaved. + * + * Simple extents are just (devindex, offset, length) tuples, where devind= ex + * references a devdax device that must be retrievable via the GET_DAXDEV + * message/response. + * + * The extent list size must be >=3D file_size. + * + * Interleaved extents merit some additional explanation. Interleaved + * extents stripe data across a collection of strips. Each strip is a + * contiguous allocation from a single devdax device - and is described by + * a simple_extent structure. + * + * Interleaved_extent example: + * ie_nstrips =3D 4 + * ie_chunk_size =3D 2MiB + * ie_nbytes =3D 24MiB + * + * =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=90=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=90=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=90=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=90 + * =E2=94=82Chunk =3D 0 =E2=94=82Chunk =3D 1 =E2=94=82Chunk =3D 2 = =E2=94=82Chunk =3D 3 =E2=94=82 + * =E2=94=82Strip =3D 0 =E2=94=82Strip =3D 1 =E2=94=82Strip =3D 2 = =E2=94=82Strip =3D 3 =E2=94=82 + * =E2=94=82Stripe =3D 0 =E2=94=82Stripe =3D 0 =E2=94=82Stripe =3D 0 = =E2=94=82Stripe =3D 0 =E2=94=82 + * =E2=94=82 =E2=94=82 =E2=94=82 =E2=94= =82 =E2=94=82 + * =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=98=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=98=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=98=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=98 + * =E2=94=82Chunk =3D 4 =E2=94=82Chunk =3D 5 =E2=94=82Chunk =3D 6 = =E2=94=82Chunk =3D 7 =E2=94=82 + * =E2=94=82Strip =3D 0 =E2=94=82Strip =3D 1 =E2=94=82Strip =3D 2 = =E2=94=82Strip =3D 3 =E2=94=82 + * =E2=94=82Stripe =3D 1 =E2=94=82Stripe =3D 1 =E2=94=82Stripe =3D 1 = =E2=94=82Stripe =3D 1 =E2=94=82 + * =E2=94=82 =E2=94=82 =E2=94=82 =E2=94= =82 =E2=94=82 + * =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=98=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=98=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=98=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=98 + * =E2=94=82Chunk =3D 8 =E2=94=82Chunk =3D 9 =E2=94=82Chunk =3D 10 = =E2=94=82Chunk =3D 11 =E2=94=82 + * =E2=94=82Strip =3D 0 =E2=94=82Strip =3D 1 =E2=94=82Strip =3D 2 = =E2=94=82Strip =3D 3 =E2=94=82 + * =E2=94=82Stripe =3D 2 =E2=94=82Stripe =3D 2 =E2=94=82Stripe =3D 2 = =E2=94=82Stripe =3D 2 =E2=94=82 + * =E2=94=82 =E2=94=82 =E2=94=82 =E2=94= =82 =E2=94=82 + * =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=98=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=98=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=98=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=98 + * + * * Data is laid out across chunks in chunk # order + * * Columns are strips + * * Strips are contiguous devdax extents, normally each coming from a + * different memory device + * * Rows are stripes + * * The number of chunks is (int)((file_size + chunk_size - 1) / chunk_si= ze) + * (and obviously the last chunk could be partial) + * * The stripe_size =3D (nstrips * chunk_size) + * * chunk_num(offset) =3D offset / chunk_size //integer division + * * strip_num(offset) =3D chunk_num(offset) % nchunks + * * stripe_num(offset) =3D offset / stripe_size //integer division + * * ...You get the idea - see the code for more details... + * + * Some concrete examples from the layout above: + * * Offset 0 in the file is offset 0 in chunk 0, which is offset 0 in + * strip 0 + * * Offset 4MiB in the file is offset 0 in chunk 2, which is offset 0 in + * strip 2 + * * Offset 15MiB in the file is offset 1MiB in chunk 7, which is offset + * 3MiB in strip 3 + * + * Notes about this metadata format: + * + * * For various reasons, chunk_size must be a multiple of the applicable + * PAGE_SIZE + * * Since chunk_size and nstrips are constant within an interleaved_exten= t, + * resolving a file offset to a strip offset within a single + * interleaved_ext is order 1. + * * If nstrips=3D=3D1, a list of interleaved_ext structures degenerates t= o a + * regular extent list (albeit with some wasted struct space). + */ + /* - * These structures are the in-memory metadata format for famfs files. Met= adata - * retrieved via the GET_FMAP response is converted to this format for use= in - * resolving file mapping faults. + * The structures below are the in-memory metadata format for famfs files. + * Metadata retrieved via the GET_FMAP response is converted to this format + * for use in resolving file mapping faults. + * + * The GET_FMAP response contains the same information, but in a more + * message-and-versioning-friendly format. Those structs can be found in t= he + * famfs section of include/uapi/linux/fuse.h (aka fuse_kernel.h in libfus= e) */ =20 enum famfs_file_type { @@ -19,7 +96,7 @@ enum famfs_file_type { FAMFS_LOG, }; =20 -/* We anticipate the possiblity of supporting additional types of extents = */ +/* We anticipate the possibility of supporting additional types of extents= */ enum famfs_extent_type { SIMPLE_DAX_EXTENT, INTERLEAVED_EXTENT, @@ -63,7 +140,7 @@ struct famfs_file_meta { /** * famfs_daxdev - tracking struct for a daxdev within a famfs file system * - * This is the in-memory daxdev metadata that is populated by + * This is the in-memory daxdev metadata that is populated by parsing * the responses to GET_FMAP messages */ struct famfs_daxdev { --=20 2.49.0 From nobody Wed Oct 8 00:27:10 2025 Received: from mail-oa1-f51.google.com (mail-oa1-f51.google.com [209.85.160.51]) (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 2F54E2F94A7; Thu, 3 Jul 2025 18:51:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751568704; cv=none; b=t5uW9afaBlzauWU7FE2jMW6p9muG37lZEyf3sAm3V5vxnYkfLoyOnW+rst6O9VKIbA96mEBZkvSvOFJDXV8lhVXYSiskeHcwaUtvjlEqw++76DGKKPRT3IR3Pyj8uBYSIumBDAqbbOKIToYS3tdoe7z8V8YK/T0+ii77TcdvD7w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751568704; c=relaxed/simple; bh=2GAozt3GI52rhisyuFm59adRbnyMvu8uPfkVdb4WXbo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XP5ft2FZdU3E7I85FK9Bp6tGn2GdD/xLpLvOpr3e/Yrk1g5BVf0F248qftY30tThvspXBff79cmaMhZ1z2y4YRyNRQ6+TLAy3ryvWQoGCfqJIHrjpnSEybUG7H80kyici6gqSOcf3BvHiLlhSJynsfx4zEoGWJSHKNOY89CRZUo= 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=Xou/obCu; arc=none smtp.client-ip=209.85.160.51 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="Xou/obCu" Received: by mail-oa1-f51.google.com with SMTP id 586e51a60fabf-2ea080f900cso82302fac.2; Thu, 03 Jul 2025 11:51:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751568701; x=1752173501; 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=kk7l0GfRD3h+I6lOGqS5B01ZAdefY7DdGtDZDmtpdlE=; b=Xou/obCuVVLFMEBeXWLXeJOZVN49NFOmZmnM4ZdpOZ35swNumJw0LLJ4on/MuZi6S+ gICUhcKhnvvEgZn3vsgqwMryICPLhZHWr8qR9Hm7Wt2paQebJmc/i+MlNbsdgVhISJPS UoHIGlAgcqZ9E4P2nGwFFWp8V4CNRL9tB5Q116X+9S5Gt+hrcbA3i7GZa+/0eDrBnZvF OA4Wx6EDOzrTfA67cKhjUCqh60iA4hbh6rjwFX4bSjw10HznrO4d0J7kjvMQ3lrNCvCl HWpu5sgIvlIXCM7RxolTSinETLJEF/IfaDbkhUdsnm0ahLzZxkvUFnZ22V4O8G4XS1hQ 31mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751568701; x=1752173501; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=kk7l0GfRD3h+I6lOGqS5B01ZAdefY7DdGtDZDmtpdlE=; b=s9OFtsyfqHPVOcZFIktdQSu2QVbPsO2z6wigjUPLDE5pQqzZdlyQffv7FOR2CTBZ03 n4CIek3IcZlfkfrLPOlx9ZB/qe394EbtYLeFneiV0Upi/o9I5cUDSg19CLJJ8hZvM9va PiE+KCniprAJ+byEsfkMSW2sXorJ00isSg9IiqJXCrAASlN2mPufazU48rmguNhNLYRJ aw4EjR/9RqkBT8U0ba6igenCk/p3Y4yeCeA9umWt/GOVzgl3vecNZNzFMx7pV5I8sch4 CD2eievXz/+7Vf200oeNpIqqkWiKXP6F6bOU+LB1j16shSwatlthUfftcRlyhqwqaiEI 3TRQ== X-Forwarded-Encrypted: i=1; AJvYcCVS4rgzQpMIKUzDgMN4AMDzaWod6BrvzAoKdyT4s0vx64E/JQYzdjZQGmGxABRrSw5O6zwmhXR9m/yQWUj1CQ==@vger.kernel.org, AJvYcCW9EMjY4OWjLiti0bmvfx7RqSQhdVsVWFMq6+R514EEHewjyv3ruggkQQR4QoX2lIgJV2N5QolnadKg@vger.kernel.org, AJvYcCWM/n/SJ2X8WXT8CgCQXFLu5LM6RNiYpT4LluHVEJ1Y1hRyUIDgG3OjAePqQdy8UYvzsqsJse3I0X4=@vger.kernel.org, AJvYcCWqWwbLKRnsNAWCrkxxeHn2mcuggsSXKuAhrdXsk/qMlv/LrumuFA5EeyItS3KWFjzTCVVfg4t0uWNM/ieb@vger.kernel.org X-Gm-Message-State: AOJu0YxDZbbprWlpKFNcwzgxOtu4A+DS+1RxrrKI1Q4hzhO3tFYcXfz0 dBzug5sLPUC74agd3e+m0pkxpQwwvm4qJOMENiGFkeNdUlCB+YeO8Ch7 X-Gm-Gg: ASbGncuE3QcISYzFAz5JF6oE3wNkTFnakPMTPBcn9NKMkG47sxe0xdtnPaV2Are/NrA xIiyiQLqWySk89pcDodVHtpmbhkDMr4H1xbD+V5GqU9NdhiW60vMp2JXzCTo4qsUuOnPJgU05Pl 9aiBnE4Gal5AnT/JcjVDZtvi4zB/pqZRdZDrsVOBYqZXhJGSfz9R/gRu544Akv54uZXCoYybztJ jL4TcDHVAK3QBdznOKHoKrbPfyUoqECtP44pJAJj2G9F4DUkJPIQL5Az6u6C2SBRhwstwGpScF2 Lzu9xhmPa4ShE0PZyy5Q8WAKZEKRI2UEfXt9w1iXbDHKdi2angNOx8ZAWetaZhQcuyCJnezx9sK AkO1hdXXA9IHlPNJ7qCgrFFYq X-Google-Smtp-Source: AGHT+IGyynocoCnJ7HhmXu2ub5GrunKuCD0K0j7iMXpe886ZyEto3OHXwpTDbVj7W1yPxb0He4yvEQ== X-Received: by 2002:a05:6871:454:b0:2e8:eccb:fe1c with SMTP id 586e51a60fabf-2f76ca3651cmr3726270fac.31.1751568700979; Thu, 03 Jul 2025 11:51:40 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:cd4:2776:8c4a:3597]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-73c9f90d1ccsm68195a34.44.2025.07.03.11.51.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 03 Jul 2025 11:51:40 -0700 (PDT) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Dan Williams , Miklos Szeredi , Bernd Schubert Cc: John Groves , Jonathan Corbet , Vishal Verma , Dave Jiang , Matthew Wilcox , Jan Kara , Alexander Viro , Christian Brauner , "Darrick J . Wong" , Randy Dunlap , Jeff Layton , Kent Overstreet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, Amir Goldstein , Jonathan Cameron , Stefan Hajnoczi , Joanne Koong , Josef Bacik , Aravind Ramesh , Ajay Joshi , John Groves Subject: [RFC V2 18/18] famfs_fuse: Add documentation Date: Thu, 3 Jul 2025 13:50:32 -0500 Message-Id: <20250703185032.46568-19-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250703185032.46568-1-john@groves.net> References: <20250703185032.46568-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" Add Documentation/filesystems/famfs.rst and update MAINTAINERS Signed-off-by: John Groves Reviewed-by: Randy Dunlap Tested-by: Randy Dunlap --- Documentation/filesystems/famfs.rst | 142 ++++++++++++++++++++++++++++ Documentation/filesystems/index.rst | 1 + MAINTAINERS | 1 + 3 files changed, 144 insertions(+) create mode 100644 Documentation/filesystems/famfs.rst diff --git a/Documentation/filesystems/famfs.rst b/Documentation/filesystem= s/famfs.rst new file mode 100644 index 000000000000..0d3c9ba9b7a8 --- /dev/null +++ b/Documentation/filesystems/famfs.rst @@ -0,0 +1,142 @@ +.. SPDX-License-Identifier: GPL-2.0 + +.. _famfs_index: + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +famfs: The fabric-attached memory file system +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +- Copyright (C) 2024-2025 Micron Technology, Inc. + +Introduction +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Compute Express Link (CXL) provides a mechanism for disaggregated or +fabric-attached memory (FAM). This creates opportunities for data sharing; +clustered apps that would otherwise have to shard or replicate data can +share one copy in disaggregated memory. + +Famfs, which is not CXL-specific in any way, provides a mechanism for +multiple hosts to concurrently access data in shared memory, by giving it +a file system interface. With famfs, any app that understands files can +access data sets in shared memory. Although famfs supports read and write, +the real point is to support mmap, which provides direct (dax) access to +the memory - either writable or read-only. + +Shared memory can pose complex coherency and synchronization issues, but +there are also simple cases. Two simple and eminently useful patterns that +occur frequently in data analytics and AI are: + +* Serial Sharing - Only one host or process at a time has access to a file +* Read-only Sharing - Multiple hosts or processes share read-only access + to a file + +The famfs fuse file system is part of the famfs framework; user space +components [1] handle metadata allocation and distribution, and provide a +low-level fuse server to expose files that map directly to [presumably +shared] memory. + +The famfs framework manages coherency of its own metadata and structures, +but does not attempt to manage coherency for applications. + +Famfs also provides data isolation between files. That is, even though +the host has access to an entire memory "device" (as a devdax device), apps +cannot write to memory for which the file is read-only, and mapping one +file provides isolation from the memory of all other files. This is pretty +basic, but some experimental shared memory usage patterns provide no such +isolation. + +Principles of Operation +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Famfs is a file system with one or more devdax devices as a first-class +backing device(s). Metadata maintenance and query operations happen +entirely in user space. + +The famfs low-level fuse server daemon provides file maps (fmaps) and +devdax device info to the fuse/famfs kernel component so that +read/write/mapping faults can be handled without up-calls for all active +files. + +The famfs user space is responsible for maintaining and distributing +consistent metadata. This is currently handled via an append-only +metadata log within the memory, but this is orthogonal to the fuse/famfs +kernel code. + +Once instantiated, "the same file" on each host points to the same shared +memory, but in-memory metadata (inodes, etc.) is ephemeral on each host +that has a famfs instance mounted. Use cases are free to allow or not +allow mutations to data on a file-by-file basis. + +When an app accesses a data object in a famfs file, there is no page cache +involvement. The CPU cache is loaded directly from the shared memory. In +some use cases, this is an enormous reduction read amplification compared +to loading an entire page into the page cache. + + +Famfs is Not a Conventional File System +--------------------------------------- + +Famfs files can be accessed by conventional means, but there are +limitations. The kernel component of fuse/famfs is not involved in the +allocation of backing memory for files at all; the famfs user space +creates files and responds as a low-level fuse server with fmaps and +devdax device info upon request. + +Famfs differs in some important ways from conventional file systems: + +* Files must be pre-allocated by the famfs framework; allocation is never + performed on (or after) write. +* Any operation that changes a file's size is considered to put the file + in an invalid state, disabling access to the data. It may be possible to + revisit this in the future. (Typically the famfs user space can restore + files to a valid state by replaying the famfs metadata log.) + +Famfs exists to apply the existing file system abstractions to shared +memory so applications and workflows can more easily adapt to an +environment with disaggregated shared memory. + +Memory Error Handling +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Possible memory errors include timeouts, poison and unexpected +reconfiguration of an underlying dax device. In all of these cases, famfs +receives a call from the devdax layer via its iomap_ops->notify_failure() +function. If any memory errors have been detected, access to the affected +daxdev is disabled to avoid further errors or corruption. + +In all known cases, famfs can be unmounted cleanly. In most cases errors +can be cleared by re-initializing the memory - at which point a new famfs +file system can be created. + +Key Requirements +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +The primary requirements for famfs are: + +1. Must support a file system abstraction backed by sharable devdax memory +2. Files must efficiently handle VMA faults +3. Must support metadata distribution in a sharable way +4. Must handle clients with a stale copy of metadata + +The famfs kernel component takes care of 1-2 above by caching each file's +mapping metadata in the kernel. + +Requirements 3 and 4 are handled by the user space components, and are +largely orthogonal to the functionality of the famfs kernel module. + +Requirements 3 and 4 cannot be met by conventional fs-dax file systems +(e.g. xfs) because they use write-back metadata; it is not valid to mount +such a file system on two hosts from the same in-memory image. + + +Famfs Usage +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Famfs usage is documented at [1]. + + +References +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +- [1] Famfs user space repository and documentation + https://github.com/cxl-micron-reskit/famfs diff --git a/Documentation/filesystems/index.rst b/Documentation/filesystem= s/index.rst index 2636f2a41bd3..5aad315206ee 100644 --- a/Documentation/filesystems/index.rst +++ b/Documentation/filesystems/index.rst @@ -90,6 +90,7 @@ Documentation for filesystem implementations. ext3 ext4/index f2fs + famfs gfs2 gfs2-uevents gfs2-glocks diff --git a/MAINTAINERS b/MAINTAINERS index 02688f27a4d0..faa7de4a43de 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8814,6 +8814,7 @@ M: John Groves L: linux-cxl@vger.kernel.org L: linux-fsdevel@vger.kernel.org S: Supported +F: Documentation/filesystems/famfs.rst F: fs/fuse/famfs.c F: fs/fuse/famfs_kfmap.h =20 --=20 2.49.0