From nobody Sun Dec 14 19:37:09 2025 Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) (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 2604173176; Mon, 21 Apr 2025 01:33:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745199241; cv=none; b=C+nJp3bGRK5+rY/13UAd3wBL4NZBqgzwB1y1SYbcSRHKDssmjMxpY/k7ZQ3Ysa/tbBCMu2TgPOWbDgWTKRkgjfvAjhqu8aqmTC55oPFeXCVxYlMT2/ue+hoOXKAZlyUFBGyN02JtDuvwIw4IXJHOYTscbZlu54i4kU/yYhr1mFI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745199241; c=relaxed/simple; bh=r7zU/NI6k0w2nK9GLUrhezJkiaHouNNrUAqAk2AR65M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VXiAb9C72aiWHor4OH42r88I2ubqgOfb2TutnsnuWXRa+mnjhhFHiRPcU9HOQqKg+T9XVVDTJfmYmSyRSLk2Vf2GZewLbEFTZEUMFks9GJtNlkxK24IrkXez+LsNcGd4ltjZB8LAxHJV6xxEN/UP/U9Qwe8zAMn7aQkqtlzxJbg= 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=A7wo08gL; arc=none smtp.client-ip=209.85.210.50 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="A7wo08gL" Received: by mail-ot1-f50.google.com with SMTP id 46e09a7af769-72bb97260ceso1235611a34.1; Sun, 20 Apr 2025 18:33:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745199238; x=1745804038; 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=A7wo08gLFUB8loQKCQOwE8hNHMoZiB0swSWh8EEIrzq2ZIWHrSYE+0nK6IsWB7JNqb KkjypUCxqrFxvnw9wzDSf/SOJh2zPugd6eHBcXn7w+gGrEFZmWdXIBtn0Lz7DzIUeQVH bX+UX+NsMCPuvtTw6/nnTQREt/915BzuYVfZ8aAsRBsjFVrgH5YC30SWbxpptExLo/3G gBsRxs8k3nYssjHV/jGFaH1DwOfqRHUkXmGDPzjNuMnpk3Qny0igHz8Ya4LNfBtf0sTN v9+Na1B9IguRZjQh+Vi/fezOrfeiZ3XClswBJDavtR6GmxBpCqSVJpmas97xMarPfUil zOAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745199238; x=1745804038; 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=P0XcXkKVCMoUDasG1oP/dLVX2ZEGNtsKlTg2WlF15OK7srJnjtuVYthrFk6/sN4ktU k8NeLDoQilUemxODaQsEM4aInW6mmWwMnjbPeeSgDaBuiJkk1+kJMN1h8joIHoLjOGMi 3eZqirdY+9gnH45+iXAdFLqp7BRBmVjFE9Sug1vi59CE89YNias8b6SEHaGRf6cq5p3z ufxm1pbbRrAh7OPmpHSdyx2W78tLZ6OvOjQ87pPNHVNA0I7CRvUn+aCz7Qo0DgQHhDpe 4YeqcDpghzI74aRw76PODYxhRNKCAaClAuOUtAs/dm8YN7NQNHhm+nWv8AzfdHbFmDus KasQ== X-Forwarded-Encrypted: i=1; AJvYcCV9urrWTnzLjhMe8u9PqY7gBEmyAj6r9w3xDrvc/FjzI297sh4P7wvA0BOWYcjoKuSIMQ1Uzgz2j45m@vger.kernel.org, AJvYcCW6hpZUSwC+Jr2vvV5b8PcLO/Mtd0s6axjwsDHDKM0XEkfCAVeJ0U1wC/ztbpESlizWbIGfDLBxwpdlHpjd3g==@vger.kernel.org, AJvYcCW7YhiHXsvjY/299sO6o4et0Lrhk4cAKpMnC4lEX5xWdkFMj6egsg8QAftaJtr8zndrOAeDJiT9pkX+Q3tz@vger.kernel.org, AJvYcCXsgquvG7HCBI5w/YNrNxRGLZPUkRfroAZ12aWSZ5ruVbvBpsiSiE6x4PVMSIq98MXTAZFBDYNIgMA=@vger.kernel.org X-Gm-Message-State: AOJu0YwHid3krvPxdeRpjDvsrWQqsJODm2hZDY4q1YnnxJuA2WPy7hdV Hsg3EGXZQll2b9dxcZxfc7+UqDFU4/OIFpw/V2L7a3Ft5XKMVK5K X-Gm-Gg: ASbGnctyfVLzUtdA4gteD5hCqWUzl5AYacVw7zukA2UFWLm2rZCML0uzBpGkX+Z5Csj W+crD60mfGovTIlyRMsR6V5nZpyOh6ilNBFOVBiC+YWJYc4qaEdTMV5mSu2vW4r1L5HIFvkx0lG 8qxkwoduPbTDC/JLVXPaQhHlbTKgbNq1BT9nSUTPOY5nMfvRpV2fXxaCUtW6qkBsiFMfLKWZMXB R39SLGVT0lRXBw/fRhJLLuqEbT+vx2ZyV9vT3PV9Ssn3nKZwq040cOCSqc3IrGTTAjkxIHi0Quy gQDPH6+jpqXfSO87wVI4Z62inmq6SjVrmHHYW+Vl0iZr4HHZadysGM6yiS9GinaLPQFS6g== X-Google-Smtp-Source: AGHT+IFBx0fNmEgiQthzAlpMH4F40IVe6eGZu2FBLlSysev0+wG7SqfOtkvNjIGeE/XEwgNUmsfiWQ== X-Received: by 2002:a05:6830:3483:b0:727:4576:36f9 with SMTP id 46e09a7af769-730061e81edmr6260327a34.3.1745199238227; Sun, 20 Apr 2025 18:33:58 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:a8f7:1b36:93ce:8dbf]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7300489cd44sm1267588a34.66.2025.04.20.18.33.56 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 20 Apr 2025 18:33:57 -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" , Luis Henriques , Randy Dunlap , Jeff Layton , Kent Overstreet , Petr Vorel , Brian Foster , 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 PATCH 01/19] dev_dax_iomap: Move dax_pgoff_to_phys() from device.c to bus.c Date: Sun, 20 Apr 2025 20:33:28 -0500 Message-Id: <20250421013346.32530-2-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250421013346.32530-1-john@groves.net> References: <20250421013346.32530-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 Sun Dec 14 19:37:09 2025 Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.44]) (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 41AD313635E; Mon, 21 Apr 2025 01:34:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745199244; cv=none; b=QuAMqnioPcP0hIB2Flt0l0JOzf0drBb7nMrecYDb+rFA6lcGxtXXnEGKyfyJgH4MOKup3YOo1kkzbaQf5QD4mbYRuPsEfzRJ8BgGEUfZ1DZF3jUrZ+J6zT/Dx5i478DPlyfVSVA3Akh12RrLnxk3Ti13N+FJvdXcOZ7mXmnXgwo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745199244; c=relaxed/simple; bh=gsIhmfFsaL+5EF4z3f0VUnIpcZS1jFVcEdA2B4rIq38=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=n7VhlzfFIldAGWJ20ubSi9pj0oN6Qt+MyzuPZa8JyWgp4K3ozwoknlDWdFVgWYlqBxWnEqd8pxEVSA4wuXC1ngPx7TdARrT6acKK/wfmM5J0o2KIrck9Itm3X24iyM6cIJERGjJfoVi7d8IxeZU9LUnBqspBqo6dn6WdmnHUXZ8= 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=P2nAhr07; arc=none smtp.client-ip=209.85.210.44 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="P2nAhr07" Received: by mail-ot1-f44.google.com with SMTP id 46e09a7af769-72b7a53ceb6so2123321a34.0; Sun, 20 Apr 2025 18:34:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745199241; x=1745804041; 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=P2nAhr076pc5Udx/CnzJlrC5JYvTZdTnybZ/umvXrx+6P7NB+aZ8imzhdH/zPV1wo8 Qnvlq00m6W7DPALISQNSQGU4L44d1dlEainKMG0usajTyKh1N/3FMLIhiat8cAyY19yJ 4g+vwcGocJunvcqqGXropFCKdQqGbs4WQrUIIz1+9t3EA/gWdGtJCz9HJHykRdvIoWDa lQuUeNE2vPfUP42AkY/m55KXQw+ppwohEWw1ixndDGjhh9ticrurodjHyc2EoNZjXDX/ J+adSXWS8QT6CcLKb6nhHiWtJkx/7YuivWd1BmA7Ip8k1Eb5wYU963+VF3S17OKG75KI KBPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745199241; x=1745804041; 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=RPUdO8I9YxkTN8GCvCbTLSX93I6T4ztcZFR4ltN1bYXnIPlAS3svIWxMQ1ZV+uPnEf 4H0oHKdxB0p9BwY4qxw3mP4jPKKUt0YBItnDSgGIBsZde3gMJ2VNoeFnYxtq/ijI19R/ oLjjS6qVTcVmKYVyYHfA/pvEWfu3l0IrifAQP1E1WqQ5SkJLyhjEzpTlBptR4cJmMBLs 3if2jz0rTdgRsSDRBKqHeDNiIltfWBoG2MB99vBmVIL+tP8XygO1AbC6vgj/rw4rAFJV E7GdiuPyeOd0mUEbIrhrX+3LFFerZSpVGTCIUmgjFTTcNjLFYs2GAv5Tqj+FBOIcLOpC JmPQ== X-Forwarded-Encrypted: i=1; AJvYcCUJoLqqPOwyDo9DpTkW6TUyC7/dcYBQJ1/olNqDuoJXlmcp81me7MPW121gwq1TzZvvaR51Ljp7hIX6lDPF@vger.kernel.org, AJvYcCVATgc7W0tPbZa5SaeItEUs/fJObuJEiiZ2+6WX+jiSs5R1vhICNV3vxW5SbK1eSaijKPg3f74hziDLu76LNA==@vger.kernel.org, AJvYcCXNE6DOX7i4iUgYqt0PX6XrADP94zTzTOPxHY1T7FCSb/15xytNOeDCdtbTen2Lx4R8yH9sYgKnnPs=@vger.kernel.org, AJvYcCXWLyFcIdL9KBz+UugrirDrNlv0xyNgLnOuK2okkuhxk6cVFgX1zw5ounnha2liyITEXFH/YQFmq57c@vger.kernel.org X-Gm-Message-State: AOJu0YwTtqhS0JXmLfVMKy5IkYE05HIXTVvx/ssnVIzAmQQx6kjT9rqq OVywAu7XpC6AfqndvQZWwJJzU5Hr7UZ58x2MLbczAx87Gy+ztuRx X-Gm-Gg: ASbGnct2NyvEsicEzjfk0DU76myKb1YWQPUyxxPDdFbKeaIVMpvr+dSiz5WjjgpBEoQ wwruQWogiwjpmGc37TKQnpzKh0ALUYrj4BZlwoMzipQ9xRYTdOO+wQMpiG5orv7urBlOGkIJLjA Jz3lJdCdIvxPTZQpfAeDa2DJcy2XGn+dPjQKnwEpkdRvSZrErehW7G8nCY3F8/ihhX3QcUgeuXI 0p5XgSUJHwY9pdl2fqwLEphBlJzQUBg6Qs5L1EzQBCaFNKrTMXdawInHVUyDS9TPluO1OS9TDLR 7sfvg/SBN8Ml014ZiPVINj3JVaLebVqTlcwbaTA7pGlScZN4ullVOw/Y3wNJ2RDRYU8vXA== X-Google-Smtp-Source: AGHT+IGp8RZLlzeUTFl1h5mg3H6My52ABBiCe3Ryq979SMBCBftURNPp06AGz5RNSl+DLM/21GFUdA== X-Received: by 2002:a05:6830:630b:b0:72a:1222:9e8a with SMTP id 46e09a7af769-7300606460dmr5662821a34.14.1745199241117; Sun, 20 Apr 2025 18:34:01 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:a8f7:1b36:93ce:8dbf]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7300489cd44sm1267588a34.66.2025.04.20.18.33.59 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 20 Apr 2025 18:34:00 -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" , Luis Henriques , Randy Dunlap , Jeff Layton , Kent Overstreet , Petr Vorel , Brian Foster , 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 PATCH 02/19] dev_dax_iomap: Add fs_dax_get() func to prepare dax for fs-dax usage Date: Sun, 20 Apr 2025 20:33:29 -0500 Message-Id: <20250421013346.32530-3-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250421013346.32530-1-john@groves.net> References: <20250421013346.32530-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 Sun Dec 14 19:37:09 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 CDCEE1459EA; Mon, 21 Apr 2025 01:34:04 +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=1745199246; cv=none; b=qWLhXLVUAakv6qOcTi+P66f6lI60FQ4lvHFBKO+dx0n1xPzPj4AxbX/6ggKWk4WT3xh4tNK1Fq8KBCEAFU7Zm0+iltArHiESBWXlThJ1GiOjG3iWrAfkw19qOKbn3wKSE9CEssPvRFwjR2Y2ZXHU+6heCk8+0oYWVKh/xuOIlC0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745199246; c=relaxed/simple; bh=SM8Xj4dnyYwoGjDXor6hvaRx7QAO8yyyxbfokVYE+S8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=l0qv1Qr9j/o9FGSs/vM5K8SFE3sYRk5Ow4BsqLv25L719/ydWxxSb5bG1gq760KZueRBTOfo/hqPGvC6x/zPVu1rwQFfjSnfnQLk3qMVh70ebx8kTryC8IbWKhNI2RIC/t9i8Jnlp4WDWlbqAJEQIBsforktP7oCbhOUjcEZg8g= 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=EcVjzU+E; 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="EcVjzU+E" Received: by mail-ot1-f41.google.com with SMTP id 46e09a7af769-72c7336ed99so1045352a34.0; Sun, 20 Apr 2025 18:34:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745199244; x=1745804044; 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=EcVjzU+EIvfAhyqloKxOahWMMzSFl30w7oB54xxnBZ5o+ohQQlE/nRlbkQU5g8DFxo 0rytWycHUpB3c/n79wucHA+NePH5yEhIHIV3gvXM9SIWmf6yvfxGpv0rkTIhK+tZYW28 BvPw68wHhCLSXQRNKcoQN2ecccbuVZou2Nc6q+rpLRZIjNxEwz8GuoQ2GIUWN9bb3vyu SRDwZBDb/U4pjf6Qs13PcqJo8R7VV7y6FcdnLoEJAIAE2PrNKrGVkTmecKSdWpBKwgbr i9f12HO3whly7F5tiNW8kMEwdxdNwIGyXpvFbJmhksmHbC8BLoG4pmJTm3liBb5LigXe 9jPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745199244; x=1745804044; 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=AuLat9tawGycWs1YAIwl1oYMlCooGdOYd9eyWu/8zHEhRLQakkGxVTPP/cB1WcQRd+ KalNVhW5l9HvTpa8tMzbGGQLNjd8HxTAQTW1cNQhUaTVLh48NpTJHIZC6H31mzgX1qtD g55CsBwF6ou2kD8JIZZRcPraWZkMLUD54Ksl6fORgDVCGfEzeET5qvlZqyZqEP1qo649 +ahSla9a9MEpNWOJpZ4qkxbhT/vWcmDa8wbBmcRJtTByOHgxvi3hBNFgW++Wli9hGRY4 4EbLHDdkXj9uwepXR7Vhe7Q8K5DFhw9cILWsBx+w/iXUxe6HKmvDbzYVn+PpP2FqTp5o QWHg== X-Forwarded-Encrypted: i=1; AJvYcCUssHqnfEDFweGzvXgdCUas4PTXzIgk2442V+ZN2HDfwmfp7vKk9L/X4nwMeXSbITcJZJSDH8Vlep46E6zAqQ==@vger.kernel.org, AJvYcCV7gdTL0hoq6gYyYVylIJ1nPa8d/hChHxTxj9lw5ms/f1hfnqxNmMUOBAOUQ7cBelfQgxAhkiYElQwhT5rG@vger.kernel.org, AJvYcCX8+k7fv/ZvV3RjSTR7hiW3MqjZds4xoM5T4U8vu+/+VnJlRrKKSk3jSd6Wzl+rpGzxKHOTzavInw8=@vger.kernel.org, AJvYcCX9cpjtSVJIBpnIU2OAY+yoV2DhJZT4Uw9lo6lI6K3JzqRIc2o1N7apNhQaD3XoeMdNyowQP6Rm+EmH@vger.kernel.org X-Gm-Message-State: AOJu0Yx0sV8NIaVseZikIpw17m9liDjNOOi6gtEQpgN/v0s1GYLYRKPr E11cBQ96Wl21X+gg6E9xl/L6ooFe4RUP+12/WYAFY7+jxHnk/LTt X-Gm-Gg: ASbGnctpaVPNoExg9ozIbUEf3F7CzcGOGfDThWRgTTSV+h1iC3R/WII5dArOkn/C1M3 1ZfSP7yF3rwVv9q4HfdEeig4U/I1g9YX1n80OWCACaoJo6/M7LMOYZKPPZ++EjMWFFpVgjrFWWi uwu8WE0Et5bpYeL4XyTWSUTwbFvNWSTjGHYV5v2AZafXnxDoQ42pv1rea7JIbBhXD5akU+//aUs 2FEj0Q3TDPCuwGIUBgyPkVY3hGC15A4x8vjal2IY/qpK5v9WQrfxxgWLrIVLXGWA8plEFgGollS ELmixLO9GSlPKkZMuFhkBZyLjgTm0ilcI+2/Ma4oot4/ptpf/1tC3jzLT1uB/1uqJddEbQ== X-Google-Smtp-Source: AGHT+IHRSyjVpRQa2MLAEuuQnotFbd3RCybPdxGlv+ddIkS2NgjbTnLA8P/hoj1HDXSaxjqDyXt1wQ== X-Received: by 2002:a05:6830:71a6:b0:72b:8c4b:8ef2 with SMTP id 46e09a7af769-7300635568amr5548316a34.24.1745199243747; Sun, 20 Apr 2025 18:34:03 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:a8f7:1b36:93ce:8dbf]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7300489cd44sm1267588a34.66.2025.04.20.18.34.02 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 20 Apr 2025 18:34:03 -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" , Luis Henriques , Randy Dunlap , Jeff Layton , Kent Overstreet , Petr Vorel , Brian Foster , 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 PATCH 03/19] dev_dax_iomap: Save the kva from memremap Date: Sun, 20 Apr 2025 20:33:30 -0500 Message-Id: <20250421013346.32530-4-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250421013346.32530-1-john@groves.net> References: <20250421013346.32530-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 Sun Dec 14 19:37:09 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 1FB3B1624D0; Mon, 21 Apr 2025 01:34:07 +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=1745199249; cv=none; b=GJUnD3tyv01alsoj2R2DzmdlJxLtHZA1LZNxZEzSmzGiSz4S1bfpZbf0TXWPtf8UwnW4iIJBekYv85ywBjP67orjbijvDi2oEfTE8eO5f8l21NYOzRXlKne1okSkDPHHZWnqIb5tEWFEuKQ+WRlTgW1CorCIK+4I+lgdgXt5W6U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745199249; c=relaxed/simple; bh=Pw428QKL7vU/Q+rAmnYuMV/vyS2i6xzQE57G20v2vFg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rfWOGq6PsLkQD0R+nA5dDOeSPZ0kYULVQd6e9Bcr/61jI3ahBksKEKH7UB3KpKJfimw1vUlmw+U8jjCtNhmSGSWv+6m1b4sIe5RbQNU6cTzsWl6KUcvwScQAX4qkUIt+AME84erJwcJASFYLO2kgnsHYfAztp9wSi9ZcSDrPVqI= 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=fe4JeiZU; 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="fe4JeiZU" Received: by mail-ot1-f48.google.com with SMTP id 46e09a7af769-72b0626c785so3023586a34.2; Sun, 20 Apr 2025 18:34:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745199247; x=1745804047; 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=fe4JeiZUDmCEeLgT1F6BjS6kfAQuFIiWuFcsrCS/rLGYdunESxfS2qfH3BRrqHjeMG YcztIhZZyIKCw1BAgQ7cftEt6wIti3/DBxyhbL0lAUKgFM+5aKsHHEdgPRNGM/qLCeht JHrEznqio6rwcY4Dl/91aH2B/gevt1lJfgQn3n5FpzoK33FBHikUwUwGezBjziJQfVep oHUVXfGP6aWvYWSO1Qs85kKL3K1lar0w+sNw8W098zakwLOZcSSn3RePCX/qitHDy97G P/15hEc7qF8GLFvX5Asegrlk2JYHenAv3Ixt2/d2+dcPaGuXmPYiQKPaMk7waiVvud3R +wIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745199247; x=1745804047; 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=D/ho8GnNBSG2jnaFq+XjWnuCc/MuHno0MSzL/EOmZxfQBDBVllzxIKZM4bcoGvGgc9 gceiQWGwnTpcWcpPAWyXz4Q1QGoqDzPAmNgGqbjnht8K+bXzQIMgT4+3DM09RzNtrFBh sQV75XeVcaI3ee6liDlwnJig/5qK6Hzbd9UEiSFBIwiqEdtSt9tZiTF7GslDSVSrjkYQ UFswdOQe3+2afM4oJXviF2SeZrMd8dkSj7v7U7hh1OmRqSr5gCLJ5kVyjWKSi678OivI sQhbfB66yKRZTkpCm3RLGmRAcd+G1sJHB3kul42upNlNU0FptNpHH7Dt7YJn/Ax6D80S ijew== X-Forwarded-Encrypted: i=1; AJvYcCVacVpwhH99H85sOXnoFI8uuUOCANpa9nO2FYkDf2YntgyA85mAkgbzugMCExqLnJAcD2UrLMYeDCKURNFi@vger.kernel.org, AJvYcCVmUeggnvDwNN/MMw25TrI6rrNIJS3kcxwgr1jRNUt74X6MAERvYaSUW+jaM7ScvtdGn9GdCaeIln1ZR85T2Q==@vger.kernel.org, AJvYcCWEZWmlBhYBUQAUJ6+IGI8KJmAQVOjRaeqalCVSsshWqDJ3YsQWBvi5nDQgypOD81cMvaGRV3WefUc=@vger.kernel.org, AJvYcCWfug0dufP2z0KF4xjU0LWEef0kWMdiNFc+h0UJHgYgdbYGBKqyAtWUpC3K8fG11WxqqZ/Yn5llNxAg@vger.kernel.org X-Gm-Message-State: AOJu0Yx6crTA3zqiExbw5WhUUdYIxu7UgZUhSR+9r9V4pgJIOfeAWo9Q gVw2JAiazZMP5GeDxnAfFie2n2+3aV4TOld1XgkllLn5IJqrqXJM X-Gm-Gg: ASbGncuEyLZUpwYyXUqv0UpP4fl2v18pkcvOH18GyqKPyIzdsQdeHea9C9OzXU/Vg8P Cd6QKanXQg/sV1kQJ8D2go6Cu1ieFu3L98nttR9ChFqPMw6+qKvWTdRJXLN79o1mRbJ+tfKYCMA 8g9/8wcs7PgfRO4OMj6OMNp33m78zRQwPQuSaMqsycr+XZ0w2Zz+S84JlYwOPiFo4TEwlRRaqM4 1kOwzASKXSI7BEKqJvN8o4DMhibY6M9c6tU1cBOzMsYcnXOtSFjujO4Hsn1nvIaXPVAc/YtQ4zb m63u+8tom1MryErg8uEOTP3xklcNhoT32sSC/lWbYYGS4XhOkZ+80Vnj0rvPqP/wUP4Mlg== X-Google-Smtp-Source: AGHT+IEsMa4dpZJjBid8/pLKvlf+SmLNSge/Fka+TntF/FXSs3PgaAfQ5jAVyn8KSUpKFBCYf59yRg== X-Received: by 2002:a05:6830:a92:b0:72b:8974:e3db with SMTP id 46e09a7af769-7300634d735mr6694059a34.25.1745199247110; Sun, 20 Apr 2025 18:34:07 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:a8f7:1b36:93ce:8dbf]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7300489cd44sm1267588a34.66.2025.04.20.18.34.05 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 20 Apr 2025 18:34:06 -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" , Luis Henriques , Randy Dunlap , Jeff Layton , Kent Overstreet , Petr Vorel , Brian Foster , 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 PATCH 04/19] dev_dax_iomap: Add dax_operations for use by fs-dax on devdax Date: Sun, 20 Apr 2025 20:33:31 -0500 Message-Id: <20250421013346.32530-5-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250421013346.32530-1-john@groves.net> References: <20250421013346.32530-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 Sun Dec 14 19:37:09 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 267DD18732B; Mon, 21 Apr 2025 01:34:12 +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=1745199255; cv=none; b=QZrfRB5yWY/TizEZjmD7imsUp52w7s4Aj4yoDNaUOSEDCVrIgk+QhVrnlAGe6WZMIilobHMXaNgY3+nFC9mqNjNvQDDwttVaf+cdKh2mNmBxm2eM/R+P+d2tJryZ4LeT75/OMLkjIrgnZXo0NWsZLqzDOTSPfUlHi3/pMvYbpkU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745199255; c=relaxed/simple; bh=3KazfK/QQTaTKMCPWi0YxDdEC7X6OVxJtOIOm2yyTcs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ieQRBJ2nTa2bf3pvIjCavuwXdho+QJXgwXgsgZpZ5ocfGVa6a2/whGRFMpna6vs4pmOtykubvOiCWhFwOoJR6hPvrQrVhJk8p7oD6ScOScfjB0wfcPbyqkw+r5WRaIclMc6bcvE3BtYkdTntsTT2GVDjCDjzanRD/UgRcLv7GDw= 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=k4K50SGO; 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="k4K50SGO" Received: by mail-oa1-f53.google.com with SMTP id 586e51a60fabf-2d4f8c42f49so2070891fac.1; Sun, 20 Apr 2025 18:34:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745199252; x=1745804052; 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=k4K50SGOagZkCVK1g+jBKel8P3tEzO0umPfFgTg66344ZszA6PzSIXYggpH69qGF6D /ipRt72iarDoH7/6nNQEX46ms71ZsxETMB4q/JH1csvybaUK26zFVWk4+lOakPm0Pkt3 SbJhuS8YUjrweyls/NEPIOTNSv51XNVZg8H9yKy5FQBQ6iD0sdqqDKqIRf+5ukmgr2HY 489p79Kt8AASTmp+WXaE8doa+GhHhSxrwHl8h0S9+YtIWWsVlxjQxth1MVcqOpAVqRGm A7w7yxEdf0K+GC+HcjMmphygoV/3NG0Y9ypmG8x/1gSye8wsRaRxX/I5i0MsHjtieDLu jLog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745199252; x=1745804052; 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=wmpvGVcaB5S4vZuwaRfvxPjwEh5bgxryGkWLfO0xuVuBzOjBmht52hB3fAMEpxM9ma lKLRJ2IQlEfkf6tHgNPP429bp8n5C+4wvPeq5ZYvj8W50lP7Qi0Ctaiipy1yM19NcWxB jndx3vi4jzySRBQZbLt43xKmnBf9I518TLwGEIN9QZmIpLWaJ95otYEH5uAfVz7LIJbl rbzxHMW+Cr6c6wx7lqEOnLPhtl8+Bp5/877KYLH71sQnNeH9K2YuELht5bTr1x5MBLM5 oN4AUljCJ5OEYp2r0LrccLVED2mxfn3c7dsAS0Pz3LIgPlDx1EQaECurRdHGmHQ9lKr2 M3XA== X-Forwarded-Encrypted: i=1; AJvYcCU1xB/b1vqXmPIk9nF+MCCDaYDxyvkkp9jhGzz9ADxvszndn88iqXHV27Lgw/x41bovvjskmoTgOig=@vger.kernel.org, AJvYcCWwMuoGso0g0UnTZXR8HePsw/Sgm9qVYrFTM5j+ojrwL2ECR0qabB1GLFeQPoiKtRgBIpOGbia+ultVu1N1@vger.kernel.org, AJvYcCX9mQ+WBjdzdxOL9j92YVFj00n81Zkys6/3SbmBU7hpEv/vLLutdLvbJgRvwOk6O5XP7MGgtoykXmKV@vger.kernel.org, AJvYcCXWW21oJd1NsVRnlTxAxXj6a7SIEADXukdOklg1E6bXBG4Pu99g90K0xFMahyMlFGwvUzvsbmMXNtDl9Sb2hQ==@vger.kernel.org X-Gm-Message-State: AOJu0YwFUgGZT/7BUorb357lLea38WHnupMZJ5m5VvXrLAB7fyKNxG6I A51advt3OjxkQeMC08PMr2TY/+V/2+muixcBcfL9Ic6ByCEth0QF X-Gm-Gg: ASbGncuxTcZC8AbdKCwfb4kkceFbAJxEqGcfjjn7fQm0ddu8CGDsiUJ7ggPUM95qlA4 t/KAB0L7co5b7y4owAVlgN4WfZIdEoo9/cpftSZi2Vb9173HB3yOFocVcgS/qNNo/SLrHY4MA4S I3T0RFmR3h/bORyDufZ18QYUixeUNdGrqgi7AOgaPUl+4/mUYFMVZBYzxNu8IRYN8WjswLebfiN gdpxePKReDd3Pd4lL5Z++On33M47NKzSBmhyDoA2LdYQvZUnr4Wq9BNA8KFztc8vTOlYfODcu7M WnjQcg+/mcB3bUY77OI0FvrX2EtuF5lqYPDNbTcu8w/x+faiVK/9FnItN56rVjfKyXDOGjClFyU RVTfn X-Google-Smtp-Source: AGHT+IGCQNEZypkRNMPI57FiYqCy8iQHVYwKVOXbiWyff9YUegbi0IX622RgL2rwTfO/kYbxNmvVtg== X-Received: by 2002:a05:6871:24ca:b0:29f:bdf0:f0f5 with SMTP id 586e51a60fabf-2d51df20f01mr6123664fac.17.1745199252117; Sun, 20 Apr 2025 18:34:12 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:a8f7:1b36:93ce:8dbf]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7300489cd44sm1267588a34.66.2025.04.20.18.34.10 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 20 Apr 2025 18:34:11 -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" , Luis Henriques , Randy Dunlap , Jeff Layton , Kent Overstreet , Petr Vorel , Brian Foster , 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 PATCH 05/19] dev_dax_iomap: export dax_dev_get() Date: Sun, 20 Apr 2025 20:33:32 -0500 Message-Id: <20250421013346.32530-6-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250421013346.32530-1-john@groves.net> References: <20250421013346.32530-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 Sun Dec 14 19:37:09 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 412D918A6A6; Mon, 21 Apr 2025 01:34:15 +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=1745199257; cv=none; b=DEx55raoXGgGx72qvUsIjMw7I2/Mht5+HkXeA9FQ705uFErYOQ2PgdV1peW1X6WdenNRVkJJSU0CFIF90JPqmpo4txEUudRfaNFoCPcqloMizitJOwWmYdgBwBAY8aMKM9d/530HGDvwtjlgRLNGE43TL1pYKy/gUA1NM8EdB6E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745199257; c=relaxed/simple; bh=9z/0+wP63OG5wXftLWkn27sSwdysRUwo3gRSnRSt66U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jEz1RnnrkzXt4jcUOJI4aen38F6B4o3CeFyPbGkMe0a5BAQrWNpfc0Ty5bZqJ0i5DY5UXXbqU21dDFfdpE1mpa8sFBPRr10H9jY8+6xgEhr0f3XVZcflVRfYQrR9v2+ANZvqNHgkOgMtCz1qQfJjaG4Ofgi77tWXMFo//tVUlXw= 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=EelSLeUC; 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="EelSLeUC" Received: by mail-ot1-f48.google.com with SMTP id 46e09a7af769-7302a769534so174089a34.1; Sun, 20 Apr 2025 18:34:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745199254; x=1745804054; 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=EelSLeUCJGTHX0cAt60kTIhPcJwX5fi0AhH++YvybKQuQtgLR/VYK7oWThN3kYb9FR zRSo7Pf9Eix0uYfRFMO0FJyoWG2Lcifd7peEnEWLxshb//onfTrEu//cNl1tQC8Ksi6T Fef6zZ/lRcMnU+NX3afl1SvmjQ7q4hcTvxCCWkSLPETfEEJK151BQ605Z9QBJcGQx0zM YQUgF0PhxlwT+BXoq1PV3PKTs95PZd5K92Nut1zOhd+mWgMum+5Rl858sRI/joUgtl+Q J/STNQgdTXwc9dKHWJThgc2W6DzwC5JoR9nS5oitGVmoAPVT0uc051TCZCwpLwzhiISQ v8FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745199254; x=1745804054; 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=O200AVKTtulvWEhctxhc6vLaJQ2L3Rsal2c/CUCmBzJ4CQQgcpqoc25dzoB2xp8ia+ xV/W21gS4aMBYFKxmzU20d7Pt0FpVNRHpCLH1p0bPsGeWH2H4vjAq1vEXt7raFpiPvjB 9intTAeS6eFZNNZ9XywRwC+WDB/BOf2q2aLKzi0e2LUOL+BFqEtPCbsweQ2ctrzDZBtz Y7B7T048OyhYz+VVF44SwMuXxeFkpEc7wEKwkjM5eaizuKieavteT7SToVg32IGZTSDI hHWhZ/ccq4HTPzAO3kRfojG8ZRtIrB6T/mEhHcjrMkngxo2IDUP8VYT8AufV7IK1THGS Gi+Q== X-Forwarded-Encrypted: i=1; AJvYcCUumZDw6DM57765jYOOT6d0GkUF0opQ7NN7oqUGhzJHs6uMuaK/I3Kpcbrrp/ZvzGU2lm/prZPApRU3qIi/pQ==@vger.kernel.org, AJvYcCVFkqOf07uSYuR1WM0sSgXqh0Of3OsMZx+g84+Z+MKI+RbmTsPLBrw7d7k9ejJ/fowHI4Dw5k9IIro=@vger.kernel.org, AJvYcCWWZb0zZIjcDvHgS/rkO4xKH5xn/6HevEU1uIPuCQd8El79ewW01kskyNrfhwcXtYaf6Nh4jFlFV9ADuphz@vger.kernel.org, AJvYcCXFgDo7l7f5eKXITi7INTTHbbSpw1YKY+8BGtvdRmBaD7OODvbxNNd+gavUWv+NreJOYJv02galTS9G@vger.kernel.org X-Gm-Message-State: AOJu0Yziqzm2DVrLQ2xWHeMoc5n+4ai8FC50766Zh6BrRaEJhEerHI8x nHrfQ6q+powbNfaoXR1AGMBQHBiIZMP1lic0QOdsMWFloBY7RO9m X-Gm-Gg: ASbGncv6gf1K5zm5R+ef36G8YSGeSBH2X/hKBTvGNs2hkAW7JE7pkBQsGVeb1Rhoooj Ljcxhv+9UsjSzSRNDH0aCsMupiBeIjv/POXB68Mt9R4w3OJ/gP+FkLExPbToQbPj02K9JTX4kGk 5maX07SakbU9PnSTbJLUe0Zma0tAYjsgOEkiDTI6oMtnIBxozM8sVv9FOnzWxfWuCTnZ7CDpzxv tkWJYEspAzna+HIDFM+OYjq+vws32aEevrX1d4n0XoNmLPIdNxl5n8q5EGhJkUhXTvEvP1ZZSrG ZtQP/ad7P440Q5ZXLAy66QUru6Wh9p0AAcwn+QCoiBg62EeapKRYKr1AO548ppRYC5ipxsLnKke Nc2py X-Google-Smtp-Source: AGHT+IFU3nJijIBNsm6B3bDuLSoCNQ73pwfzPnYiqQH6OAqYrzMNb3svUhszpN80Fdd0UtVEY411YA== X-Received: by 2002:a05:6830:618d:b0:72b:946e:ccc7 with SMTP id 46e09a7af769-730060b501amr6213415a34.0.1745199254417; Sun, 20 Apr 2025 18:34:14 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:a8f7:1b36:93ce:8dbf]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7300489cd44sm1267588a34.66.2025.04.20.18.34.12 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 20 Apr 2025 18:34: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" , Luis Henriques , Randy Dunlap , Jeff Layton , Kent Overstreet , Petr Vorel , Brian Foster , 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 PATCH 06/19] dev_dax_iomap: (ignore!) Drop poisoned page warning in fs/dax.c Date: Sun, 20 Apr 2025 20:33:33 -0500 Message-Id: <20250421013346.32530-7-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250421013346.32530-1-john@groves.net> References: <20250421013346.32530-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 Sun Dec 14 19:37:09 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 2A928190468; Mon, 21 Apr 2025 01:34:17 +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=1745199260; cv=none; b=UJy+CspAphMChAIjDYU4AgUg8d6GkzKDLJA74KuDvururQuhYCPdPp2rwECLSsEoAKO0CibcoJSzqMVNsDoDyhPMRTuhogWZo3MWJt3ecNs8iPJ9mp7fC0tAZTzuYvVW0BoEMjG2qp6uCm7DLF4ohO+OoyWqYYbWjRwQuoqtaHw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745199260; c=relaxed/simple; bh=i2RCOjAti+UF5LQ1PHdINLhvfnaWKUaVeHHuyTJYyzc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kFO49KbGX4cRzXklJjH80bARzYfMfXn1vroolYxLi8Q0tgev+sJ/QqOzXZlL3e56ndmmcwsW4i0ojYNoE5fLJgax8aNXCFXIylpQAWXENJfjD2NlhZgd5EhO4Z+DgWz0R/dgLV+JJxsYCVLoxAf+Xom47NvfmX7UYGQnnGQvaKw= 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=GaPJlKw4; 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="GaPJlKw4" Received: by mail-oa1-f43.google.com with SMTP id 586e51a60fabf-2c873231e7bso2209059fac.3; Sun, 20 Apr 2025 18:34:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745199257; x=1745804057; 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=GaPJlKw4oOBmhMwXK/KDuouvINdt9HEgtLeeLE6wyWA88ObauK6h6b8ci11MdOAhMC 0ODtNp85v68Vac4WOfoh8wddkXLaQRtDbnkQEeTufdg4m65203N39Q3s4D5FPsVnfklG ic2RXnQpYjw8wqRnoB6r3khzhN0onCDn/nwza1TTJmyN85NiFULVveLLfAzGjPDCSJsG 4zWs9E8lGa9e1Ckk3vgb7q7g2684OVaIzsCnG3YjGowPE7b6XTfn4MQKhhW6GlIt3eFg 4xXMAJoaJhqHsHvA8BNSPY863bmuw8EDl+LUXPGiy/jAJlNxOxLCUmVj8H3qVH14Dnka vCgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745199257; x=1745804057; 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=jFjMquyzxN7t3o2d54dyN04PeyqyBeRaV4Vv+eteYZ46+p0kjeTYaFiMzmOKClVK1B dEbs4cJOrylKd4dSvFPUC5aVFjywXtmHFu89RQLWdoFwap6Ku00GyChartPg6z2i/Xau +Rbrxy0LCsEt4EI93CFXLmK/YnywEwc/u72Jti5SfCFp2ttnNaVZy1KrY9hibUidexym ZgY3HlLOR+WjkEBGOa7WOU6mo9MJupf+Rrhbewt1z37DwU1ip0ZFx2ujKXVEVM+VySbu u71lQeo/gnGKJnRoq1FP1eGEhmITXD3Q5MJW6WavrNew7CqGPc2GpiooktDCUATGWD91 B3ig== X-Forwarded-Encrypted: i=1; AJvYcCU75sESvL2SHq5ab4F/l6B6McNLsmyMkBValUB5CTo3prCUq9d/DhnOhTr23XbW5E0OfD5JshirURg=@vger.kernel.org, AJvYcCUGLHnnDx6hq/2TA3MzY6O7uwhVllVunkprXtXd/ZUyv2kR4gOOGRHwIGoegYsnHy7DZaz1zsty5TljsVh7/Q==@vger.kernel.org, AJvYcCUTJNMrmoZGiWt2VVVYeCf615Y7H/o9uosw4F6/IjeuRn300RwI+VcWcxvlWM3hS6YFVsOOOWqJ3Ca9UpOy@vger.kernel.org, AJvYcCVP5icK94qJVhuR6otovHM3M76CPL6pYQWjpHxUwZKO2MT6OMjhm1WCc9B/DkrwjrQnbbtmDKkrIJOe@vger.kernel.org X-Gm-Message-State: AOJu0YwTfcRVM7T941CO4jRz7xSbfturnSSAo57Dyjdh+lzA4Z1ZlZC9 YRYAL8VPW5Zk2OFn9ZBGcycL/SU1F9IYPVzmB7eCnuRhm3kPq+ga X-Gm-Gg: ASbGncssIf4IRF2kiCOXPjp5/I7Tu5e8NSYHujRqfOUhOlXgwdfhtbdakI/2oaGP0lV XYPZFlfG0ixGlOfRaSCjUnIj5KGvBwSpDr4hLUPdhh8uswFTx3+QbO6Gzy4uP9aIiI4iDiJvXT9 tcGA484a4Pmc8E+zXK4Tz7Tq5hh1n4G2iRFd9KwQyAsKzsXQleXKhp00fOKKQKpvu1fr4NAQ5HE jqGEZ+e1J9a0vRmFonb/fh7pDgc1Fa11lvpLUl1fEsbAlnEIDa4sDwIbsqXb5aq1doCQQn4AehB l/XqnYLn8e7mZ9EV2KRLk4JG5cH2eLlIJJjAtHoZSfgrZiJvWLV+iaxyDznf0VFnHucnmg== X-Google-Smtp-Source: AGHT+IHCLVWvYpObY4uNOR1oTBCfkL9tkIi0WbVuxLpCH24LCz6hBnpqZN4tzVwpynAzf1wjqnSRrg== X-Received: by 2002:a05:6871:bc8a:b0:2d5:6c97:8f92 with SMTP id 586e51a60fabf-2d56c97cb4cmr2290882fac.14.1745199257157; Sun, 20 Apr 2025 18:34:17 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:a8f7:1b36:93ce:8dbf]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7300489cd44sm1267588a34.66.2025.04.20.18.34.15 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 20 Apr 2025 18:34:16 -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" , Luis Henriques , Randy Dunlap , Jeff Layton , Kent Overstreet , Petr Vorel , Brian Foster , 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 PATCH 07/19] famfs_fuse: magic.h: Add famfs magic numbers Date: Sun, 20 Apr 2025 20:33:34 -0500 Message-Id: <20250421013346.32530-8-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250421013346.32530-1-john@groves.net> References: <20250421013346.32530-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 Sun Dec 14 19:37:09 2025 Received: from mail-ot1-f54.google.com (mail-ot1-f54.google.com [209.85.210.54]) (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 E479B192D66; Mon, 21 Apr 2025 01:34:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745199262; cv=none; b=t1a7YXASYXUma7SpYCGaE/CNmtifuNJWLvhHmQoq23nR4nVZtaOyOqP3ohzz72k7aCraVVq7SnqHvtDVBSpDgrStdeiSo+7lCCh7J+0v4TwsO71MIFcdkN9cUeGeI7Re5dt6IkpDuyHdBZcXxcMc6+lsAKjd4WLlJ5jGxlR+jO8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745199262; c=relaxed/simple; bh=kGGXBghV4lzKmeRVN+j+pfeJiQeXOVHeL7W4dyeFZvE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JoghSZyHHMvGfXrmTGh45c9UW4tfLW2fhxzfQW0QcqTWjpQCuDGyppFhgjFeCrc+I+Qaeo8PWArcW0O6sFvL0EIz65bxpEwYOjmTc7rvAffqgNSSU5CO3554qoun82XICWNTrZyZrgaubMQWAnXC6AcW2D4B4mztAl5KVDlM9bc= 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=G3mFbJBH; arc=none smtp.client-ip=209.85.210.54 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="G3mFbJBH" Received: by mail-ot1-f54.google.com with SMTP id 46e09a7af769-7301c227512so671146a34.2; Sun, 20 Apr 2025 18:34:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745199260; x=1745804060; 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=G3mFbJBH6+0zyZZ/MIdyUQG7anqXHqygHFeTJnSxk65y8Nty492srfbQKx0JuSXT+v qE3h+K4OoyFk5t6FuRtA53OON8F9vwyDidVyjPQE3dDCGblkV13DS3ngQKzkgEfv6iNg gJPNeonD43Olg3QvWvXGzXQ5u34oJqo0j7t0p+zwqZnQB2cPPY478FzX6GhiYayRzVWc Gl4Qd3CVyKUVqhL6cQgfXf575eTUB/NycWxZE8lJe5bpZCf0YP+jCCCsyWLC+H584aED uX7FfpnXibKReF/hNhIK7Ry97l31J599Rb8uPb6gZU7uVfnGmjLls9zhVLeNtNxsIBzs 173Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745199260; x=1745804060; 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=S64294o3flon9Jz3u8wUdEZxMdU1iSJ/QkSEDMyb6HgNMIM1eyXjNkDwiQlePlrVTN desvgdjEtRju5DechysPeD6TpDL7hwfb1HhETYNwcTRanmPp3kg/ScSEP/mPqSxEPEEW x5Og+SL1nGsrZDaQL+pZ5LoLZxTbUGwZFDa7SqBaUzZYIJR3U0H3D6wDr8HofEe0BzuY BEXSTO0UbnSiI8P8D2dUTt16k6KhGmPqs8vfqSMQbYd3cb4i07P/QCDKeCV2FNgx8rBm 19wK2om1e5Ft3LxbrcRl3077P+xWFw0jh7TPrtkVQzXcPobqNZ2UydtmCP1cQUERptV5 ZP4w== X-Forwarded-Encrypted: i=1; AJvYcCUd3dCAe1tqBiEz2pauqORMzfgrV4feKZTt5h08RVVuuic8DBWf936NsbhQKBPj97TZs/DnHWgrq4baSrjg9Q==@vger.kernel.org, AJvYcCV1bkRRTrf/wJWRTbeMGhKAlng/dffP1RZCkzevJusES83PWzFUKhguCnMoWVeT3IJml27jclYp9kb5dvV4@vger.kernel.org, AJvYcCVKA2FpfVERbhDppGAA7dcZbXwUBBs4UI0hDAPSED75ZhQ4SeUg4lf16Qfi2OrIp6Iei9syl7uJq5hY@vger.kernel.org, AJvYcCWHDm7UFSkFHQmNeJp0n0kljBmCrYI5mr1jynfkfVdmDmZ66pXbLwqNYEwdgYF/+yWZG+O2JVm/V9M=@vger.kernel.org X-Gm-Message-State: AOJu0YxD59s55eUbLP9zCe1Y4Ez2zVMQs+PhINH2cqIDT+S4YvxXz7gl p8Y+dmxD8sEcgS3Pr4WbACGVIgHFUYUYFMehOyYMlbZxBqW50bwg X-Gm-Gg: ASbGncvY6JLl2FTvPdTaM+RFiNfFBmDsiZsHYhUiCsSOSUayykjFdO4W3Bth3mLi14V Se1YVYTmGaRFfmA2eIGulqJ5FwNcVJdwt6fodwrDLuHrLdCFyK98nRgTNn3HQtT/+0Umtbnu3Em MnkabMrNj+6mOdTfk5TZzScddaoguB9mVJLGjK/xa90xvbsSWo8QRvWJD4PVz0SuUvZYqhUGRrP 8XyMMuqhCN3GIzxe2GS8/OjL3M84SyJVdiaIIHLB9GntZ03zd+ktk+qmp9cz4TijOX3GzjySOJf PDEdnvQFUxLVvJD+b9w/9IMPIJKL8xjk4ezmPIwoxZl193C+lVaFWY2pm3d9mVVUTW5dSw== X-Google-Smtp-Source: AGHT+IEz5bP7JM3BwiQMEUcJwi1iHjsHutNBExuPGxHLduN/ka75Z9MzoFBPbybdCpgm9y3qzmrR2g== X-Received: by 2002:a05:6830:d06:b0:72b:9bb3:67cd with SMTP id 46e09a7af769-7300620ff0dmr6144248a34.12.1745199259823; Sun, 20 Apr 2025 18:34:19 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:a8f7:1b36:93ce:8dbf]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7300489cd44sm1267588a34.66.2025.04.20.18.34.17 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 20 Apr 2025 18:34: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" , Luis Henriques , Randy Dunlap , Jeff Layton , Kent Overstreet , Petr Vorel , Brian Foster , 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 PATCH 08/19] famfs_fuse: Kconfig Date: Sun, 20 Apr 2025 20:33:35 -0500 Message-Id: <20250421013346.32530-9-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250421013346.32530-1-john@groves.net> References: <20250421013346.32530-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 Sun Dec 14 19:37:09 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 61DE519AD90; Mon, 21 Apr 2025 01:34:23 +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=1745199265; cv=none; b=Zx+cHl8v1KaFVsvKG1W1Itb0lSgyBATdh73W2mlONmojt9WmMkMBwWLkLsoKmRiqlJh/XbD/Pr/HDdG65D+sDhIT9P8kxE0q1jYht6v0MlsygGdUFuOyO78xmWyKE+aUvsf7QUZSqQuCxLuEJx6lzuCbX6zWo1uJD/9xLZyYxd0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745199265; c=relaxed/simple; bh=NBFBCMmJVtINYLC+p85CstqmUXiKs92cuvnznL6fml0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GIzCvC2TUc3MY+vz4y4Cg/TfGSiENhiZtfPSWhlwvLehqfJWwyrFmHAE4XnpFdNksY9Mxjd0DQZVpolH5XBSV60X7BUf9dimuaWWGFJrJo6SAZurVTpLT98+266L3gaLmaV4IMrFAi25599V4TgqngTMk3PY/e569h6+JSurRzk= 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=gyfLxza2; 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="gyfLxza2" Received: by mail-oa1-f45.google.com with SMTP id 586e51a60fabf-2c12b7af278so2616115fac.0; Sun, 20 Apr 2025 18:34:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745199262; x=1745804062; 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=S4l0xj8nWHJ4Rf/x2g8EIw8lI123T+hiPwW7l4PX87U=; b=gyfLxza227j4z+2ihhUTJfzSZt4LEMGx1Sk+kuVLKpXnePC8uIx3jKoNszlLtV2Eut /CljHDSKYgOnvaR+WFsVSwNF0EB+KiPD/yvmCTDsTNziaasHWhfq+FRlMU4A+0hiYZHH YyHohiGl1irnpDtPtlxg/CwnCyC2JoYpkbZLLYoV3lXCo7OXJoimakCxLs5ixE58DFj5 nNCnjOjlo0BIK8Kb/bz/ELeN2mudSmoSoPocCLOVIm1D++7b9TDlJCiWRRbVxA/jTr2S tRQNfg3Io5SRdAUjFZGzMppwZ5vNm26MPCcaVWO2RSNb7sGN5WRSwS6O2GRkoSlGDzkL wXSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745199262; x=1745804062; 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=S4l0xj8nWHJ4Rf/x2g8EIw8lI123T+hiPwW7l4PX87U=; b=i2j1vCe0xh2BuG+XyzTbKHJ3x8mQXYgGybQoqBRh3zXxf/qdy7yIYhY6fxI7rCGofU VKLBDgOl8ow/GP8cJzZwwV9WANftzcXrr3UZxi84IlFQVb3XwCp3gWdF2UnJxBIskuY+ X0zP35uv7esSA1hG+0on1Y34o/ZD/3VPlOyWs7I0XGxaPoEq46AkYLUys8TFQ8fv+YuW B8iZMXlkT7DoEcUhPEezgQUQOsQW5t6wU/QYHCoParxiFQVV/627FZIB9qBgHHF1e/5Q TdTIRwmib2jqX4kILMJ9j+jciny4U8jtLhB7lDq/FWO6rW/wOK3DKZey3FXYgmt0P5Xa fGnw== X-Forwarded-Encrypted: i=1; AJvYcCVrRJymvnrol8OPvoRYsD1mmazSFGyg8U1EkiuuipdVoPmXz0IeeQmPAPy+M+gcgwMn4tHr/vyg20g=@vger.kernel.org, AJvYcCVyUSAN8BYdxGF+tClIZtJjr5Iez0TJb3+eXU6saEeA5Y7L9x1F5ABY7295SqJmLnzfYSco7Wj8iv+z@vger.kernel.org, AJvYcCWhwMbf1Sx3Xa2KfA7O2sSNxSSRQHt0m+y7tTFeX0UDXbaE+CnGY1Q1sBCAAVqdBsnxH43j6jJcPsL9T4j8GQ==@vger.kernel.org, AJvYcCWlWzbPCcAGIFl+N1X2SkHbpzeyHzR8xq5eIDnErgMfHc2FyMV81D5aXYi6If51kZbP/6ENeAFMpeV5Elv2@vger.kernel.org X-Gm-Message-State: AOJu0Yz6MFF79+8FdRk9OT7q0QINUgmyZENnNaN3SmPAUSGjRc9e/hDM v7BPWlzNWTNk2Iz0Md9jkTk6SSarREHCMD5ETIPPJAgjfBBpIoFL X-Gm-Gg: ASbGncu1iJt5FL91IPrCDmhX7alxLQKIqw+G/x3wYy0I0kbVuvXwPS2R/VNJKrmjYWG 5lkxqMN3Fj5f9useVfVIbrG7sTppECFwTXwmuhziLrshUbr0TAyS+ZA/hZ9FMEhUl10qQXJtc7i dVL9bjwkO+3OEQNVqlc2/15JukGOABFuKeuQ1kx561tht2uj3pTkmceVRC5LBLd015R6g0CeK+f 5hxGy3KuDWTC4Ljcpczqf1NtP+oAv8nfI0Zmri3TDAXw5ajC3ivLupQcdLzvPI7P3ZvGs4s2Ko9 2/dCuCs5gBok1sbw6oXHf9Cp2FN44ts3/zfY9nDDOwutRXbNLAVS2yw49jjRQ4zC/d8Ltw== X-Google-Smtp-Source: AGHT+IH+F+vidrl3lXbIj79JZOASg2RETw/fdPHhelmpnW9w5aZoCaDED62KrXIK7M8C0GadLQoEYw== X-Received: by 2002:a05:6871:551e:b0:2c1:2262:7941 with SMTP id 586e51a60fabf-2d5288102f8mr5483185fac.16.1745199262491; Sun, 20 Apr 2025 18:34:22 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:a8f7:1b36:93ce:8dbf]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7300489cd44sm1267588a34.66.2025.04.20.18.34.20 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 20 Apr 2025 18:34: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" , Luis Henriques , Randy Dunlap , Jeff Layton , Kent Overstreet , Petr Vorel , Brian Foster , 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 PATCH 09/19] famfs_fuse: Update macro s/FUSE_IS_DAX/FUSE_IS_VIRTIO_DAX/ Date: Sun, 20 Apr 2025 20:33:36 -0500 Message-Id: <20250421013346.32530-10-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250421013346.32530-1-john@groves.net> References: <20250421013346.32530-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 3805f9b06c9d..bc29db0117f4 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -1937,7 +1937,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, 0); diff --git a/fs/fuse/file.c b/fs/fuse/file.c index d63e56fd3dd2..6f10ae54e710 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 fee96fe7887b..e04d160fa995 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -1423,7 +1423,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 Sun Dec 14 19:37:09 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 572B819F116; Mon, 21 Apr 2025 01:34:25 +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=1745199267; cv=none; b=rya9oprqGFSSgE3Wd6NUunNu76LFT/TXak5iKxXbNnnsiLZ8JH4C6SBSDJDQQdq2wGpJzGFfLb1E6FNCGZbS13ATRSMYyiatNsO7i32KaC6gvdUhdMqPSOJQlopnHmYodH+WHETzNy6BktUmcP/J8jpt+JNWbhd4jfYcWSCe7wM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745199267; c=relaxed/simple; bh=oeJWVqoXTfM85DPBtFlVkuLxvj/f4i/x+rX/RZYjhZ8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=m1FD6gETJqGiwoLqu3D654YXW3QVAHGk44kasHvE+cJBZuUlxhhPaI9C5Vc20YqGNZmjhwxrT/f9FYBvKXH9w5kLDLyALtR68cHEwCM+iqEAY0Kym7JGBWcZstu3qs0iHBfV1o7kGeEmEIc+7WBnOuvTepf/QWLomAYucmtW8GU= 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=kLR0akHF; 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="kLR0akHF" Received: by mail-ot1-f51.google.com with SMTP id 46e09a7af769-72ec58e45baso2259251a34.2; Sun, 20 Apr 2025 18:34:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745199265; x=1745804065; 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=zJTUPxCr5iXCtHx04L7AsNg2Bv7yPa69NQGQVSsPk1Y=; b=kLR0akHFQ0+52RWtD4lRShBqEAribyBdAVWv9fQh8vE8WLC3g8vyBWpHt/Gwgvow0M JXCQ0IAplJDmHQsxk4CViP7Nxu7GnaQnd7SPcrksJ1lEwlCmmF3y79RaZMc1BDeEKbPl 8gM4pFIXZjnraJ7DzswdoOOF9KiCclYAv12hUbiRw7jgLZ3ErgVDuhlpVT8izq5XnKhU Nv6fcMV3F/cdGWuv8a2s4+7WlR22vX5YAm4cdLB0ejmhczagnAuZZ0eFvhg8IuSW3tHk 5wdTJZb3vIB60R3jh8Y5/bDiRhRddQY6wh6tK30gWa8aNb/RXe0NnZTyvsEbqL5zOott gZOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745199265; x=1745804065; 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=zJTUPxCr5iXCtHx04L7AsNg2Bv7yPa69NQGQVSsPk1Y=; b=BIaKNY3XZkyUNh03DkddMDPSsOsZdY2Lz4ga7TU8NJGGseP+wUWNxwyPp0ps1kpQ7l 3UQ2hHaL6I/F9v+VSkKt/n4GWagGKJ4zrzgC15LH7BDVtgfzkH05NAohSPJyXyh3LtUo rrsHZXURfD17EJw295fVIuF8k+g+upRNfN7yNuATQAT/jRi0oNo6/wy2pV0eJqy+h5ok rYAS1g8DUpL1CB6fPKiG/dfGzhTYRTSB+pGqtApaUYX7UhegTPkEk5z02188xCtjbpWz neaq9p0aoxC9pIe1p/Q6zlTO/ig+9ewheMioZyuctkauzT1QZVkS2ovdSgHIU9lzutXV 4UYw== X-Forwarded-Encrypted: i=1; AJvYcCUaDypVcEPor3eaiXKin36XuB7YpQu3mk6P0/NbxesnG/jvJGkxoISdC+z7Rw2JiYftRUVgAYll8egE@vger.kernel.org, AJvYcCVhz3ltE3McIFcdtpaPSVTT2F5q3iDMg0YYgbLY58TSx3A7NhKpncmcYm+cpxgRacmCEFe0uJOyaNs=@vger.kernel.org, AJvYcCW1cjoH0dafsGopPfW/2ei4Iu13OZiV1gSFR1bRO385K85uLy5rNHYmOU5c/okAV/EjHYnGZBkzDa6xrFwLtQ==@vger.kernel.org, AJvYcCWeOOBYyNLY09Q61Mi8Gui+PG68MiyiogWva3npDsbg0TzepGe/aIovNJmI8L8Sua1u9v1bbA+s70w3v2u9@vger.kernel.org X-Gm-Message-State: AOJu0YwBnlCudrXOZcKVG2UIkM6r/IOdCRW74245EBeEfcNALz+P5mQs onnJD/AxBbz7W4N9TEEReKM8+RNkSL7FyLOtoOGuTC15TCidjFZK X-Gm-Gg: ASbGncvCOGML/ZECNPXmTh/jx9sSlAnbPTNH8uwg8Y2vNonlebGwsTthW863gcOjtPt g0TgP1NK1deVtdJEsAnZR2Ks3NldzG9h/TLyNjmgd5QbmhrCPgRZe4FS3JxKXnVs9toAh7BTl+5 toxbFtScIWF/CApHs0hlrRHjzMFAKJdME5iBaOTYDaQB1bd4XDoKydWd0yFmCPTdftSL0yCjOrc 6nkylPIdeQh7xcet5US+RHcqF3kWQwkL4EoQKQoVhD6iMCaba6GSEeg8kSs2hKwbnK0udtrKu1K LylOvldc6u5gge+ADBeSFKFOPFCuPl2l6Dju6jOjXrF/HFBU6PCaITihuFId1uj7TYIRbw== X-Google-Smtp-Source: AGHT+IEeWI/ZWY1Oz4SEkKzVLnxG9+3nSwWecNs4VxQIfI4WYWMi4G/PZMw2CRTN5C5Uzp8choe8BQ== X-Received: by 2002:a05:6830:3902:b0:727:3e60:b44b with SMTP id 46e09a7af769-7300622c63dmr5997735a34.14.1745199265163; Sun, 20 Apr 2025 18:34:25 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:a8f7:1b36:93ce:8dbf]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7300489cd44sm1267588a34.66.2025.04.20.18.34.23 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 20 Apr 2025 18:34:24 -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" , Luis Henriques , Randy Dunlap , Jeff Layton , Kent Overstreet , Petr Vorel , Brian Foster , 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 PATCH 10/19] famfs_fuse: Basic fuse kernel ABI enablement for famfs Date: Sun, 20 Apr 2025 20:33:37 -0500 Message-Id: <20250421013346.32530-11-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250421013346.32530-1-john@groves.net> References: <20250421013346.32530-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 | 5 +++++ include/uapi/linux/fuse.h | 2 ++ 3 files changed, 10 insertions(+) diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index e04d160fa995..b2c563b1a1c8 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -870,6 +870,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..5c6947b12503 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -1392,6 +1392,9 @@ 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) + fc->famfs_iomap =3D 1; } else { ra_pages =3D fc->max_read / PAGE_SIZE; fc->no_lock =3D 1; @@ -1450,6 +1453,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..f9e14180367a 100644 --- a/include/uapi/linux/fuse.h +++ b/include/uapi/linux/fuse.h @@ -435,6 +435,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 +483,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 Sun Dec 14 19:37:09 2025 Received: from mail-oa1-f49.google.com (mail-oa1-f49.google.com [209.85.160.49]) (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 9A81D1A2C06; Mon, 21 Apr 2025 01:34:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745199270; cv=none; b=qBhSi/cxj5JpvKwfoCCC7BUorrkKRTi/TG+fHYMLGBtFtOXn0ovia8RxTUQa0qME56Oom7yuqvkKipKC9r0lG22bheansgJnMKUPe466955efgyPVBTWTPvRJ3B3i6rksKnF+mIcweoFMyg1oarxdr9FitC2gV146n+VogTAN7c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745199270; c=relaxed/simple; bh=hS9bzYfAqAxrTx0CKZe+FDkhAKFDz+WpXq24E9q0oXo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gS8oU6S7wKuH+be42wdTnn+P4hj60Q0MjFRyBm6IAb0Fi2Q9SbKKxWBhNEp80hXZBg1EyKPZ/3iLMV9anXUWfwILmhUy0chbSk4T0VwM3Yhn+Mqu5XgjgyyV9j0HkSyRrYcOEw18fW/YE4H7IVWwX0Z7PhnTdmX5nE0dAUFU+E0= 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=L1Smidfi; arc=none smtp.client-ip=209.85.160.49 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="L1Smidfi" Received: by mail-oa1-f49.google.com with SMTP id 586e51a60fabf-2c2504fa876so912326fac.0; Sun, 20 Apr 2025 18:34:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745199267; x=1745804067; 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=6jlW0o3VSdWrbOaw+r3nQgVEXzp70rzZbAdQEvNAOUs=; b=L1SmidfixXlr0jmS7NNvLFQWgQuz+mfiDA/yyPadyJOS2r2yTcH7vWoEp9NaopPfQs 83Lhm+pZYlKzudOfUqJYPg2S8xPVo7MEn4ICF50z45hJCbs/hPojgDF8R8BRacqRmcrz XQSmCt1Ac+gZ42Pw4OBWjAn/D4w2q7e0sCvtpUw9eeGnsfomLXa9EGSUoRotynwVtZI9 gdfS3bJSYrl5+VfsDTGe2V3GTg5/IbNhy2cfVo1f/GCkt87+T+o91OtdI0YkTYRCrk2g 0zmjwuABb9KvNQJNtLvbAp0pIfyTZE6nVMdHtB+6143f9SSiolzIkJcK3rlQ/1SDLAX4 WflQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745199267; x=1745804067; 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=6jlW0o3VSdWrbOaw+r3nQgVEXzp70rzZbAdQEvNAOUs=; b=qhK7tEj1blL4RoIddc0vaa5WQKIZgGrVz4q2Y5R3zGzrcz+Sl/Ma7wzwO7yrfe8mlw WoVOxiz27sH7Vx4+NYW9bVX/74rh8oIEBlTiszIPmuG6h7ZWLu8l0vEQNfDGxl21GSCP uuHtQIZUw8/gyNAf/c6PL2FrUFh48d9oFSEBRPIoUFzmG7YOa5QcMuuxa/mO7eOL8Cyh lddNChiMl84zDYtfY7GLv2akhIb5fgKiRN5RxdNn3QdkMjBxBTLUYFpi9kivjlMmKoDX 7xjAD2HgvwSKDKGbRftpIbYjWKtuHFGM7AE9/g7myi44XadM9xcC//ylZTpBFbZyYfqL V33w== X-Forwarded-Encrypted: i=1; AJvYcCVBgUJRMKfGMbY4QJkBcea57g1cZ27fCuqILF7KRDLRD7VH9aca9vN20srkxYW6i2c8sUM6quhuzFjLCHFCfw==@vger.kernel.org, AJvYcCW2YxpR5pwPpLnI3Sg8oPyL1X2Bh82kmDBiSnn7aWvwOBntkeWOQxSYzBbpUyqvq85i7chTVhOKGyHwDwfU@vger.kernel.org, AJvYcCX0ijQSPix8/mOa+0+U7i/1brzjxw6CFLiJS0c31hdV6PMJiIIeZJyGjey4YBwsNWVTR7HFMGytAM6s@vger.kernel.org, AJvYcCXg1sOa/z6qq81fuxPGOlHEyR+E86yyfDi2QRVSClNWbOmLXf3CmW9vdSUfoU2Q+ZJRqvGW10GojsY=@vger.kernel.org X-Gm-Message-State: AOJu0YxGKsJwlJhiOPgJjsIUvYTsvi3jMa3C6LszTXqExEgqPMsOfRqx fDh0cK/99XLNrncm3/OP7yq4prfxHsbTGOH+2AfDbhdBpW3jI2u1 X-Gm-Gg: ASbGncvSO2dtT37GDZRquf+jARuJvwJU6su7gNyiq68evDg7OvE7ZFB0Zs2AcsX2fzp iZTFyUU3A5rNp9vwtoKlX1ewNUaNuEUTIil38wbBiSFteF0wxfR7oew7zt6qC5X0X4y1CRN8Qbv DfVFnz3hZOtkwlFHWzzQyKA0QYBDZD2jMsqjiBZJ3tXoan0/bPEm9shbNkKfhydRagCSVM2Aa0P 1sVDkGQLXVNxmBIkraSfm4M98J4Dy4y9vfGeoyEXMz5B30mgR57i1YvHhs53IyaLvgTN7jT9jcc 7gjTw6zfKSkjDhFyKFvT1eEBWrW/ZljhlLOoRp9Hdc4ZbxjF3KuSmca5TYZKQ8+L4d0TBA== X-Google-Smtp-Source: AGHT+IF+9XYJIqWLgWlGUpPhWJ2tjvUozsrrXpH8oCW29Y/FQldm3qVZQBAnxt74Itja45OzzhFhaw== X-Received: by 2002:a05:6871:bd07:b0:2d5:4fd4:a1a9 with SMTP id 586e51a60fabf-2d54fd4b0a3mr3864201fac.6.1745199267484; Sun, 20 Apr 2025 18:34:27 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:a8f7:1b36:93ce:8dbf]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7300489cd44sm1267588a34.66.2025.04.20.18.34.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 20 Apr 2025 18:34:27 -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" , Luis Henriques , Randy Dunlap , Jeff Layton , Kent Overstreet , Petr Vorel , Brian Foster , 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 PATCH 11/19] famfs_fuse: Basic famfs mount opts Date: Sun, 20 Apr 2025 20:33:38 -0500 Message-Id: <20250421013346.32530-12-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250421013346.32530-1-john@groves.net> References: <20250421013346.32530-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 | 25 ++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index b2c563b1a1c8..931613102d32 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -580,9 +580,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; }; @@ -938,6 +940,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 5c6947b12503..7f4b73e739cb 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 @@ -1825,6 +1844,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 Sun Dec 14 19:37:09 2025 Received: from mail-ot1-f46.google.com (mail-ot1-f46.google.com [209.85.210.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 A88531C84BC; Mon, 21 Apr 2025 01:34:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745199273; cv=none; b=dtRHivjcTUaYvUW5nfACjFP+gOALM+UiVIPIpYcNVvpjerLGwqAuqaESLMM2N8kWqp8kvXizqzD4UDZ0U0UFQij0UpDPG8TiN1jJCeUEe0pDl5uCdjhAn+Vs/SUs8bTwKi9mt8O+8LgSUReUEgURveHQFX3PLkes/2fyLoAM8G4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745199273; c=relaxed/simple; bh=Jht53ChYFHgs9fVdkHxX2GDuBPGNdx3JRH/1uFqn5+Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TqGiCP4T9dhjPfdN4ebMzYE5hcg4oJnxiacBu0rDcfJ25bioXxnkpW+axNTzNzqrI/s4Td4mysdgn9EWhavVfx9Ajee6NpGcd7UOiG0rlGbipnmgq/Eye/xyeu4rEC5PbZcSBN5DQTfJZ9Va23mxldt3ketuUtr+5ngpnyqron8= 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=d6Wja49Y; arc=none smtp.client-ip=209.85.210.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="d6Wja49Y" Received: by mail-ot1-f46.google.com with SMTP id 46e09a7af769-7272f9b4132so3007827a34.0; Sun, 20 Apr 2025 18:34:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745199271; x=1745804071; 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=87hDz9VklLiiv0z6ZzoGmsWmujXBj1aSDF9l5QzufPk=; b=d6Wja49YOmNmk8sk/Al3t0bx0wf57fjCupxD1mZ+t+HzjvFmHHaqF+5q10STxbnx0I yh8tvzim94bvx+AQQ/pbd++kWEjYMFrLuzlzyF6u4aulLd4Ar3p47CBbRX1OGdKfBtpo AQOCnQLYThO49oY8nNItmU4nX9LOIaRBZQmGQs15ADHhNH+ohnaNmJs/baVlx+Xeay8s XLhewDpkWmgmr5uO16E+pgBbhHuKsZyITXYRzk/Slepee97/OFebiI6XswBpKS7Gf4I1 645eFdx4LawDYOGHxHz+ssogAInQMpDksjY0v+ADNyC/XyaXFhDweO1AR3bWEJjK3VjT XLpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745199271; x=1745804071; 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=87hDz9VklLiiv0z6ZzoGmsWmujXBj1aSDF9l5QzufPk=; b=bgAbLrJXz4ecJCRUeslAfjjNsRRgj9pDTTCluWta5tirKvH2csnxWGpGE0y010DoWr RUonC1pqF4Bhofgp3TgL3U5ClKkAbiuKMAikWUEZl0M8+luvFaC0cvPzUSx9Q/C/FuP6 VjRnwwiehU0hxiTrl6KeKW8JTvodt+4vDxh17TpbvUoywaEMl/NUfmWU2/VdX6RFKJUc HoCweSJ8C9ZZv+qatxBnXJUhErj+8kqz0qOPapIZzSNNQbI7X9KRz0wHatEwGmXsnPwW BVHZBNzbqyvfeKJOtyA9QN/nI7HeAlK3zWtx9qZdv3q2ihvpJFq+Bv7eIVEjI00eBfcp BoeQ== X-Forwarded-Encrypted: i=1; AJvYcCUdLo2UPSRm2l82dFAKU1PK/Tyd072TJTvZkh/H6l+yQL5u1OymUxW83V3/PN8blhSa/rsawc2VYfnTFN31Mg==@vger.kernel.org, AJvYcCUqUR/IR2GY+5HcB0JKuP6nrsrMEmu6Ac5OgK3QcbVSEm/K/QMY89jwPdgNmH4xVcaYdnDlHiKTIpU=@vger.kernel.org, AJvYcCVcwpXigDVdMtwh2UIzdw0RWqQM+84P//IM/5kuFmgpq9P8bFUB16rY0I05BDBf5qZlRDEJ/FF44CFQ@vger.kernel.org, AJvYcCXJSKWwm0Sigmr//l+fiwq3Hd/mOHsaRTZejHcaKCpBL9IR018cf9dWsjm+Jc9tESTp2zk6IZQMD1q3dhCn@vger.kernel.org X-Gm-Message-State: AOJu0YzWOc00EWJZPVIv6SgHJ27yiPXVfrcwMR5pXVmbZes3YE2zssjn KKvPekcC3r4hZPTT6JxOFA6MmiONubitrA9W7tGIHe1NdqQ16ewY X-Gm-Gg: ASbGncvIun3afxJXvb4Cdr7ix5arS/C5r1JqUjm5DMCYq/nBnttUo/knMWdjATAvsRw GOBvsbyAb2YenIyona+5pXj9jXPgn1IobX1YBbsDMtSxju3qD0kWzCFEOnGYzWaftdZTGjxCret TW9eIDAmfw+c2bH2PLhQdM0rIoc7imzt1FB3bsBiwfNVnByONus6uGfarnPCokQUPQYaanBedUp I+U+oehTOGpT40ibZN+ZidoWDxGWvPXl5T9ncK78+XXxANqcx8yK+rkPQtw8e7q2tA3eHP2JpbU HxX6l9PijdhwNCGXTBIFf5JTYMWDgUAvkpu5XK/+6ebbHMeOUxtCcmigFAEP+2CTnb2E3w== X-Google-Smtp-Source: AGHT+IGp4vZtteKLozsEBPtZC1nWHMzjwcz0JoCBKnIYiH3inoL0umeX/iB+Kt+6JBcOpEy/kE2pLg== X-Received: by 2002:a05:6830:6203:b0:72a:47ec:12da with SMTP id 46e09a7af769-7300621892cmr6947779a34.10.1745199270715; Sun, 20 Apr 2025 18:34:30 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:a8f7:1b36:93ce:8dbf]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7300489cd44sm1267588a34.66.2025.04.20.18.34.28 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 20 Apr 2025 18:34:30 -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" , Luis Henriques , Randy Dunlap , Jeff Layton , Kent Overstreet , Petr Vorel , Brian Foster , 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 PATCH 12/19] famfs_fuse: Plumb the GET_FMAP message/response Date: Sun, 20 Apr 2025 20:33:39 -0500 Message-Id: <20250421013346.32530-13-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250421013346.32530-1-john@groves.net> References: <20250421013346.32530-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 a LOOKUP, 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. Signed-off-by: John Groves --- fs/fuse/dir.c | 69 +++++++++++++++++++++++++++++++++++++++ fs/fuse/fuse_i.h | 36 +++++++++++++++++++- fs/fuse/inode.c | 15 +++++++++ include/uapi/linux/fuse.h | 4 +++ 4 files changed, 123 insertions(+), 1 deletion(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index bc29db0117f4..ae135c55b9f6 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -359,6 +359,56 @@ bool fuse_invalid_attr(struct fuse_attr *attr) return !fuse_valid_type(attr->mode) || !fuse_valid_size(attr->size); } =20 +#define FMAP_BUFSIZE 4096 + +#if IS_ENABLED(CONFIG_FUSE_FAMFS_DAX) +static void +fuse_get_fmap_init( + struct fuse_conn *fc, + struct fuse_args *args, + u64 nodeid, + void *outbuf, + size_t outbuf_size) +{ + memset(outbuf, 0, outbuf_size); + args->opcode =3D FUSE_GET_FMAP; + args->nodeid =3D nodeid; + + args->in_numargs =3D 0; + + args->out_numargs =3D 1; + args->out_args[0].size =3D FMAP_BUFSIZE; + args->out_args[0].value =3D outbuf; +} + +static int +fuse_get_fmap(struct fuse_mount *fm, struct inode *inode, u64 nodeid) +{ + size_t fmap_size; + void *fmap_buf; + int err; + + pr_notice("%s: nodeid=3D%lld, inode=3D%llx\n", __func__, + nodeid, (u64)inode); + fmap_buf =3D kcalloc(1, FMAP_BUFSIZE, GFP_KERNEL); + FUSE_ARGS(args); + fuse_get_fmap_init(fm->fc, &args, nodeid, fmap_buf, FMAP_BUFSIZE); + + /* Send GET_FMAP command */ + err =3D fuse_simple_request(fm, &args); + if (err) { + pr_err("%s: err=3D%d from fuse_simple_request()\n", + __func__, err); + return err; + } + + fmap_size =3D args.out_args[0].size; + pr_notice("%s: nodei=3D%lld fmap_size=3D%ld\n", __func__, nodeid, fmap_si= ze); + + return 0; +} +#endif + int fuse_lookup_name(struct super_block *sb, u64 nodeid, const struct qstr= *name, struct fuse_entry_out *outarg, struct inode **inode) { @@ -404,6 +454,25 @@ int fuse_lookup_name(struct super_block *sb, u64 nodei= d, const struct qstr *name fuse_queue_forget(fm->fc, forget, outarg->nodeid, 1); goto out; } + +#if IS_ENABLED(CONFIG_FUSE_FAMFS_DAX) + if (fm->fc->famfs_iomap) { + if (S_ISREG((*inode)->i_mode)) { + /* Note Lookup returns the looked-up inode in the attr + * struct, but not in outarg->nodeid ! + */ + pr_notice("%s: outarg: size=3D%d nodeid=3D%lld attr.ino=3D%lld\n", + __func__, args.out_args[0].size, outarg->nodeid, + outarg->attr.ino); + /* Get the famfs fmap */ + fuse_get_fmap(fm, *inode, outarg->attr.ino); + } else + pr_notice("%s: no get_fmap for non-regular file\n", + __func__); + } else + pr_notice("%s: fc->dax_iomap is not set\n", __func__); +#endif + err =3D 0; =20 out_put_forget: diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 931613102d32..437177c2f092 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 */ @@ -942,6 +946,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 }; @@ -1432,11 +1438,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); @@ -1547,4 +1556,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 (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 7f4b73e739cb..848c8818e6f7 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,11 @@ void fuse_conn_init(struct fuse_conn *fc, struct fus= e_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_rwsem(&fc->famfs_devlist_sem); + } + INIT_LIST_HEAD(&fc->mounts); list_add(&fm->fc_entry, &fc->mounts); fm->fc =3D fc; diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h index f9e14180367a..d85fb692cf3b 100644 --- a/include/uapi/linux/fuse.h +++ b/include/uapi/linux/fuse.h @@ -652,6 +652,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 --=20 2.49.0 From nobody Sun Dec 14 19:37:09 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 A42101D7995; Mon, 21 Apr 2025 01:34:34 +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=1745199277; cv=none; b=V2jTosE/16INbZQUH35p5s7iEuma+9wBHPvHHDIT190lsRRuS4iNloXC/tWufm7T4tZEcWWVJ7MBxHElglg19wMLptqIiZazpFDF0VQSURG6iroAWW2K/dRmGEiAgNI7BnV2pg8mQ1bVPrt0wamw+0Ms+/eliu6sdgp9HZ3EaXc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745199277; c=relaxed/simple; bh=p9J/hhOWY52q/sw1CWxpWAvkdj1QBwGeVqTLavpE/Kc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BGiPTKJ+riuYDhGD+S+viIDCc6xcIq1kdjUnAsESB68f/KA9aEZuuotJcxQsckaWTEgbX0TynyqWTFb+paMbkFMcGM1BYuRXJdf6/ZzV1rudchbOM9X+1dcOiuZqlcbNG4bZZQJxyLJjD/vx4rdkPgq6x9brEBkl1fIKhV0hGsM= 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=dtNddCQC; 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="dtNddCQC" Received: by mail-ot1-f48.google.com with SMTP id 46e09a7af769-72c09f8369cso1158308a34.3; Sun, 20 Apr 2025 18:34:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745199274; x=1745804074; 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=nhICuByT9KL4EMgR/9Xxszh4ipNPx4oJeNamJ6LIdko=; b=dtNddCQCXMaZdKse1xMYWkz/FQ9+1f2991wbBe5jxkuBMEgj3sk8o6SgtDB6iRKyy3 rGVhkfDEMAAHCyfsMR/tnnt78eFyxDYIEcUPXQWEp0UCxZZmIBiM6bpHox89/I8LKRuY BXHH/fMfFQ9LA3h553UGZc3GCuyXX5nA6tokbqPN9pIDtPnhUWOIUAXOJ9DbZIVmDBxN EyHwHKqAi0ToBDGPOPU3/hqGVrrA5dsijgZ+RVxJB/KyFEVUrRKUpb2BQ+Q4a0x966iX tP4FMKFrBidYjI6tSq5w8vnGglmJ9aMaFAVn9cPPHEjS2Lkhs6/lai/7usgCOSCHw25N sMsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745199274; x=1745804074; 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=nhICuByT9KL4EMgR/9Xxszh4ipNPx4oJeNamJ6LIdko=; b=ZwgZAwlqljKBDgbbhE/PM3LMpQoqxMff19o4itrLCMvfdKsZk5aFzmvqBXWiUBXCxk 7Dk1HLfHyXQLvLlB7O5T56HeDhpKuP6fStmVeaW/EA0QnGtChXvj1fCuyWF6/Q+1Yf8S rcRGOaTD+Gu+yANcqUEOhYDx6IyHYQk8QqQSHkr+4ZEDW/rg7x9IKP9XKMhbRyD9v9Bf j2+kNZpZ2liw1kXKO7MnSsmxgxWyuWSbgjuJdn3aCoqmK5VaRRj+P7ztptfbhN14E7OT RJ0MMnmU+dgYl3+niFrqPEsZampw2fZ3wTzMAaQT9zcq4li0qjO8JNQmtm/wdhVVu+RC bsKg== X-Forwarded-Encrypted: i=1; AJvYcCUmH3dhpTrPSmd0wf39GFgO6FJ2dgSYPK70X/0F5iytw4FHRWUNaIz7rl/5kqAXqQGuEr2/NsMq+hU=@vger.kernel.org, AJvYcCWpcU21igJjG22AxERCv5cXvwN2UuZ2gJ+qFCpFmKlJD8h4L3X7WPA5NuySgy93E1MVnf5XPYyvqsVqpMqW@vger.kernel.org, AJvYcCXqxh5E/VkW8H2hYqpnN6ouyfCriVnO962vzcS/i/e+URNo4sgKkmbS0ySji2j0Iq6CQjj8uy1Ebff39+qTug==@vger.kernel.org, AJvYcCXuHt5ddYLTNeAksVK0mffqy56HOW2PwI7nK1dBI45y1pgJamV5WYzy5fDgX5NZo8Ah0bINV96OlvyI@vger.kernel.org X-Gm-Message-State: AOJu0YwP0x2ZVDq7PPHBb+Pup9ToJz9OezE9XWHbC+UYY6qDxCjNWY/E uJeGhOyTuYKAgXz5hGo1h2YCW/189szfIgIhALHVF9y0meY0XxGl X-Gm-Gg: ASbGncvokIKFmuDXihSJuVzwBtq0coDGvyHW3QnDwCH+qrsSgtoA/eEBYqWnMi5KPGN nlfE6SvJv0QT+hHnjw6NLGArfDkTIetu2gv+beJAeuqEV0bw356QWlDX/+73l6YpfSWdcnvHgDn WuZawC1mcYNNrzwtsiOpe66Ai5Yr31Waoge7jxlMXiGf2+tNADAAftHw1hrOZeZPimnx9XIw6z2 EPeyrVJ/ulzD2fmNAD7qWQVX3nZ/FvxUWSZDzlNDK/FHR4LunTCUb+pR9Si6o8tte2Qm8/FGSP9 JzHdKARo7CTPyl5h+ON0JmOau4bTz2ZPXAIDwHy6n5HsZdMAdGEB83CFqjfxrO07gRWcf1abI5U AdtbK X-Google-Smtp-Source: AGHT+IHzAih5qG4lDizKHCfnZxss9qruAZ0Yni8C+RMovh+bJfBfAS4FHwMfJkY73kvaXV2xKj3Zig== X-Received: by 2002:a05:6830:d8b:b0:72b:80b4:dbca with SMTP id 46e09a7af769-730061ef879mr6648168a34.5.1745199273681; Sun, 20 Apr 2025 18:34:33 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:a8f7:1b36:93ce:8dbf]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7300489cd44sm1267588a34.66.2025.04.20.18.34.31 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 20 Apr 2025 18:34:33 -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" , Luis Henriques , Randy Dunlap , Jeff Layton , Kent Overstreet , Petr Vorel , Brian Foster , 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 PATCH 13/19] famfs_fuse: Create files with famfs fmaps Date: Sun, 20 Apr 2025 20:33:40 -0500 Message-Id: <20250421013346.32530-14-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250421013346.32530-1-john@groves.net> References: <20250421013346.32530-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/dir.c | 3 + fs/fuse/famfs.c | 344 ++++++++++++++++++++++++++++++++++++++ fs/fuse/famfs_kfmap.h | 63 +++++++ fs/fuse/fuse_i.h | 16 +- fs/fuse/inode.c | 2 +- include/uapi/linux/fuse.h | 42 +++++ 8 files changed, 477 insertions(+), 4 deletions(-) create mode 100644 fs/fuse/famfs.c create mode 100644 fs/fuse/famfs_kfmap.h diff --git a/MAINTAINERS b/MAINTAINERS index 00e94bec401e..2a5a7e0e8b28 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/dir.c b/fs/fuse/dir.c index ae135c55b9f6..b28a1e912d6b 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -405,6 +405,9 @@ fuse_get_fmap(struct fuse_mount *fm, struct inode *inod= e, u64 nodeid) fmap_size =3D args.out_args[0].size; pr_notice("%s: nodei=3D%lld fmap_size=3D%ld\n", __func__, nodeid, fmap_si= ze); =20 + /* Convert fmap into in-memory format and hang from inode */ + famfs_file_init_dax(fm, inode, fmap_buf, fmap_size); + return 0; } #endif diff --git a/fs/fuse/famfs.c b/fs/fuse/famfs.c new file mode 100644 index 000000000000..e62c047d0950 --- /dev/null +++ b/fs/fuse/famfs.c @@ -0,0 +1,344 @@ +// 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_meta_alloc() - Allocate famfs file metadata + * @metap: Pointer to an mcache_map_meta pointer + * @ext_count: The number of extents needed + */ +static int +famfs_meta_alloc_v3( + 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); + rc =3D -EINVAL; + goto errout; + } + + if (fmh->nextents < 1) { + pr_err("%s: nextents %d < 1\n", __func__, fmh->nextents); + rc =3D -EINVAL; + goto errout; + } + + if (fmh->nextents > FUSE_FAMFS_MAX_EXTENTS) { + pr_err("%s: nextents %d > max (%d) 1\n", + __func__, fmh->nextents, FUSE_FAMFS_MAX_EXTENTS); + rc =3D -E2BIG; + goto errout; + } + + 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; +} + +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_meta_alloc_v3(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/fuse_i.h b/fs/fuse/fuse_i.h index 437177c2f092..d8e0ac784224 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -1557,11 +1557,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 @@ -1569,7 +1576,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 848c8818e6f7..e86bf330117f 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 d85fb692cf3b..0f6ff1ffb23d 100644 --- a/include/uapi/linux/fuse.h +++ b/include/uapi/linux/fuse.h @@ -1286,4 +1286,46 @@ struct fuse_uring_cmd_req { uint8_t padding[6]; }; =20 +/* Famfs fmap message components */ + +#define FAMFS_FMAP_VERSION 1 + +#define FUSE_FAMFS_MAX_EXTENTS 2 +#define FUSE_FAMFS_MAX_STRIPS 16 + +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 strip= s 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; +}; #endif /* _LINUX_FUSE_H */ --=20 2.49.0 From nobody Sun Dec 14 19:37:09 2025 Received: from mail-ot1-f42.google.com (mail-ot1-f42.google.com [209.85.210.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2AFD31DB13A; Mon, 21 Apr 2025 01:34:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745199279; cv=none; b=ODFCs/jYNTHn5toDornAZYu96tBLquftbAawsdn6/uitWEFHxu+5LYcInOEWGCEWPMtFmpaz9RLU8nmDWEWfg6wcQZ340das6XjZYHVsZqZjiOdvrQ1t6uPQOC8U5vOEWduyTvI+meoPMt81LSUWC0PWNQ6uxwcya3Rb88PqkxU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745199279; c=relaxed/simple; bh=JJavKmU5g6tWJWTxuJpGUXY96eQIHoKD8uqAsnDeOI4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MuxFCdX+8mLGyS4zOBLrHg8TE1qUMS2FDBx3BWUvWrjuZLTWYlgNhmLmWLHaQBGsKIKvRkekGH0qpVawqfYpBQ4/elG45+nedVPZlRBfswDB1r34PdUDW4G4V+M4Fn8OjbbhZcwfx/siAUooFVR4WL4gnSP1N7yLDOxhG3r6HqE= 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=L1sjEvyF; arc=none smtp.client-ip=209.85.210.42 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="L1sjEvyF" Received: by mail-ot1-f42.google.com with SMTP id 46e09a7af769-72c16e658f4so1984138a34.1; Sun, 20 Apr 2025 18:34:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745199276; x=1745804076; 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=YcrAxqtjszSaQiT74e0heontuc8sXS7oh97ApQYTn+o=; b=L1sjEvyF/ZoPxACrgHziDW8eLOUxFTfOREfYryQNoOQjZc4zlhQn/c9m/awm7x0HEM ipLrztYJSEunAxkgQk9AOsd7i7fn5GW0OqrDbh85s3UkpsAK3Ek5fmxx60VRqWVhgK4n BnpzDBK3rFS9rbTA5PhZACdhXEea6jrMYjEXnFCl3UPPefupJX+65Gymfwoc6fchtCPN K4E9aCtH/+on9ap0nnyhHW9i/r72lkyntO/p8+xFv11C3rvjZKDbJUmULHbooXwKC7qA IAiYWHcZgHqsLmjgCW+3NepeRHgKdPpCvmnnNKmGNbwRiUfrwpiYhaNkvZ9uuvMqBfR8 leDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745199276; x=1745804076; 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=YcrAxqtjszSaQiT74e0heontuc8sXS7oh97ApQYTn+o=; b=AKFh6KEVwSFsKWoRR1OgoN5h0nnON1DlOMsV0ylIuj/vWeg7USw/vzSIlgCRW8KXEY bo68iZT/Lk8Np8Qj33pWRM1km8XuTyP+Nl7P6eWaWL4Sl/wHgCYbtBGebVo+kmA2qhgq KxF4Dc8oyWxvIAoPKF6ZxLwmGOLCz7QZirbRcmbMzUmhmBp1Rb2NBPM5lsQMEEc0ukOS 3U4ymIlgEuMS+fRUra8AlnT6OjNUXCsIp6egUoSgXSqvTHE9NggueZJ18JHKpdcs+gIX E/4e+GGO2CMwMTl8SJ1O0fBskH1hnaqlv7QQi4Ch+KmQ1JceHo0DN8pXysCL0IOtdykT 54/A== X-Forwarded-Encrypted: i=1; AJvYcCUpIlXhQKmXa3IlurN1ge56K37Mx8IEIXRpxLvfIBPqdyaXjxXaobAKWMpmfgS2nm5ZMw7ekEJ4jmM=@vger.kernel.org, AJvYcCVnciWQKCW5hsitHmlzgUlZPyMQZvfpM3hTC3Et1MQ3ny0OXpJ7OyTgh/3yCOh6/9BC6XmNHwLjmJBdFOk6Xg==@vger.kernel.org, AJvYcCWAISmNmx+j1sb3lUK4F9uIzhTt3CqUYpcNUSOkTDGy1jle9oGYAN3jnDt2uDLo9Q5cYcc57wAMRqHIyyV+@vger.kernel.org, AJvYcCXm0FlpJH1p+Kk6cWhpTfsJeH7Ja6t0Bd5BTms+fus8UpkEIi40BWjVjC4rumin2AsL/e7nl8S8sxfD@vger.kernel.org X-Gm-Message-State: AOJu0Yx0Eyn34kgJWQ/OIufHJ+akxr1ANrqp6nf74Uu3DEbPRFe0ND+t kIB00QVAy7CPSaoPczDrnjtV8+fVZyUI2a0bOLe4rsTtJ/6s301c X-Gm-Gg: ASbGncsunO79mvBb/OvpJT8qLPSFq33YibVpuTqBYPse7YMydAxXUQT2uRCzo1f7yJx iePxR+mv2kQPV6jjeVNBlUlnoRgpLEW3fVssy6CX1kWeUGqdBlxe+tasAplFaEM5/JfydDjKG8O bd2flYOQ7avtl3jp1Hv6196w7CmbIwV23J0I6a4tNzKIlocxrVrSczetxiix7/jFm3/+HWtp/rk 4bylrpZ39PHdAG0DQy6yPgOntheIpsuK6bTCkIWQgbNg6MLPmSCrmS+8K1v2LcKcQ3wMZR2Nvl1 pCJvt1lbWnSm2I6r7BQrcuQ2314sjy8PVHZBch18cSGcTCsq1gwvzf/+oEv0F+gCz9Vv4hyaosC 8TciN X-Google-Smtp-Source: AGHT+IFWNSElaLO5LfPycQSgAB52unjbLEM8kKy6vLbqFxmUQJ1htR96UknIbJZHxCYAGWw5emcl2Q== X-Received: by 2002:a05:6830:670c:b0:72b:a6a9:8465 with SMTP id 46e09a7af769-73006333daemr6668386a34.23.1745199276180; Sun, 20 Apr 2025 18:34:36 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:a8f7:1b36:93ce:8dbf]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7300489cd44sm1267588a34.66.2025.04.20.18.34.34 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 20 Apr 2025 18:34:35 -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" , Luis Henriques , Randy Dunlap , Jeff Layton , Kent Overstreet , Petr Vorel , Brian Foster , 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 PATCH 14/19] famfs_fuse: GET_DAXDEV message and daxdev_table Date: Sun, 20 Apr 2025 20:33:41 -0500 Message-Id: <20250421013346.32530-15-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250421013346.32530-1-john@groves.net> References: <20250421013346.32530-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 | 281 ++++++++++++++++++++++++++++++++++++-- fs/fuse/famfs_kfmap.h | 23 ++++ fs/fuse/fuse_i.h | 4 + fs/fuse/inode.c | 2 + fs/namei.c | 1 + include/uapi/linux/fuse.h | 15 ++ 6 files changed, 316 insertions(+), 10 deletions(-) diff --git a/fs/fuse/famfs.c b/fs/fuse/famfs.c index e62c047d0950..2e182cb7d7c9 100644 --- a/fs/fuse/famfs.c +++ b/fs/fuse/famfs.c @@ -20,6 +20,250 @@ #include "famfs_kfmap.h" #include "fuse_i.h" =20 +/* + * famfs_teardown() + * + * Deallocate famfs metadata for a fuse_conn + */ +void +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() + * + * 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); + + pr_notice("%s: index=3D%lld\n", __func__, index); + + /* 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]; + pr_debug("%s: dax_devlist %llx daxdev[%lld]=3D%llx\n", __func__, + (u64)fc->dax_devlist, index, (u64)daxdev); + + /* 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; + } + + /* This verifies that the dev is valid and can be opened and gets the dev= no */ + pr_debug("%s: famfs_verify_daxdev(%s)\n", __func__, daxdev_out.name); + 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 */ + pr_debug("%s: dax_dev_get(%x)\n", __func__, daxdev->devno); + 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); + + pr_debug("%s: daxdev(%lld, %s)=3D%llx opened and marked valid\n", + __func__, index, daxdev->name, (u64)daxdev); + +out: + return err; +} + +/** + * famfs_update_daxdev_table() + * + * 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 are not in the table will be retrieved via + * famfs_fuse_get_daxdev() + * @fm - fuse_mount + * @meta - famfs_file_meta, in-memory format, built from a GET_FMAP respon= se + * + * Returns: 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; + + pr_debug("%s: dev_bitmap=3D0x%llx\n", __func__, meta->dev_bitmap); + + /* 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; + pr_debug("%s: allocate dax_devlist=3D%llx\n", __func__, + (u64)local_devlist); + + 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) { + pr_debug("%s: aborting new devlist\n", __func__); + kfree(local_devlist->devlist); + kfree(local_devlist); /* another thread beat us to it */ + } else { + pr_debug("%s: published new dax_devlist %llx / %llx\n", + __func__, (u64)local_devlist, + (u64)local_devlist->devlist); + } + } + + 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); + + pr_notice("%s: daxdev=3D%d (%llx) invalid...getting\n", + __func__, i, + (u64)(&fc->dax_devlist->devlist[i])); + 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) @@ -67,12 +311,15 @@ famfs_check_ext_alignment(struct famfs_meta_simple_ext= *se) } =20 /** - * famfs_meta_alloc() - Allocate famfs file metadata + * 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_meta_alloc_v3( +famfs_fuse_meta_alloc( void *fmap_buf, size_t fmap_buf_size, struct famfs_file_meta **metap) @@ -92,28 +339,25 @@ famfs_meta_alloc_v3( 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; + return -EINVAL; } =20 if (fmh->nextents < 1) { pr_err("%s: nextents %d < 1\n", __func__, fmh->nextents); - rc =3D -EINVAL; - goto errout; + return -EINVAL; } =20 if (fmh->nextents > FUSE_FAMFS_MAX_EXTENTS) { pr_err("%s: nextents %d > max (%d) 1\n", __func__, fmh->nextents, FUSE_FAMFS_MAX_EXTENTS); - rc =3D -E2BIG; - goto errout; + return -E2BIG; } =20 meta =3D kzalloc(sizeof(*meta), GFP_KERNEL); if (!meta) return -ENOMEM; - meta->error =3D false; =20 + 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; @@ -298,6 +542,20 @@ famfs_meta_alloc_v3( return rc; } =20 +/** + * famfs_file_init_dax() + * + * Initialize famfs metadata for a file, based on the contents of the GET_= FMAP + * response + * + * @fm - fuse_mount + * @inode - the inode + * @fmap_buf - fmap response message + * @fmap_size - Size of the fmap message + * + * Returns: 0=3Dsuccess + * -errno=3Dfailure + */ int famfs_file_init_dax( struct fuse_mount *fm, @@ -316,10 +574,13 @@ famfs_file_init_dax( return -EEXIST; } =20 - rc =3D famfs_meta_alloc_v3(fmap_buf, fmap_size, &meta); + rc =3D famfs_fuse_meta_alloc(fmap_buf, fmap_size, &meta); 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..325adb8b99c5 100644 --- a/fs/fuse/famfs_kfmap.h +++ b/fs/fuse/famfs_kfmap.h @@ -60,4 +60,27 @@ struct famfs_file_meta { }; }; =20 +/* + * dax_devlist + * + * 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 + +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 d8e0ac784224..4c4c4f0ff280 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -1561,7 +1561,11 @@ 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_dax_write_iter(struct kiocb *iocb, struct iov_iter *from); +ssize_t famfs_dax_read_iter(struct kiocb *iocb, struct iov_iter *to); +int famfs_file_mmap(struct file *file, struct vm_area_struct *vma); 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 e86bf330117f..af1629b07a30 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -1051,6 +1051,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)) + 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 0f6ff1ffb23d..982d4fc66ef8 100644 --- a/include/uapi/linux/fuse.h +++ b/include/uapi/linux/fuse.h @@ -1328,4 +1328,19 @@ struct fuse_famfs_fmap_header { uint64_t file_size; uint64_t reserved1; }; + +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]; +}; + #endif /* _LINUX_FUSE_H */ --=20 2.49.0 From nobody Sun Dec 14 19:37:09 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 CC2461448F2; Mon, 21 Apr 2025 01:34:39 +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=1745199282; cv=none; b=fl4lpiA5zz+pTN67MS9KRS2f2Ict131SXzJlPmdaKjlY6K8O+TdLnGxAfGRgTqj2l53swLfja2JG20RrBvN0EBEong95/AbNG45wEja5PD9em2jkAEK++oxJ/u4cLBM6oFkSGrOCN3QMEk+zy0KaHnIBZ9XH3cfamrEQfaq1FVw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745199282; c=relaxed/simple; bh=7LPsnCgN6Wf1+1fxE3SNCSA4gVF70/ncBSiCbYjIJWI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FVT3cwo3TnZHr6goon/GW/otGMw2gXp/OYPk1+otGzdF2fHGWhXGCG+70wtRKgc3OVs6ro/qmEDS075/53B0VHGSHdWxkpB0w1hyqUJCYTIH50Cuj1v6fxLeSuhmapopdrakoTCPXUFxkwsRxUtV6Qhkvk88puWCiDX1RbZii3I= 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=Mtwr2ES2; 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="Mtwr2ES2" Received: by mail-ot1-f47.google.com with SMTP id 46e09a7af769-72c13802133so984108a34.3; Sun, 20 Apr 2025 18:34:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745199279; x=1745804079; 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=m8SJmasm0V30Jvmxq2kFniFgyggUbSM9Iglxc1i5dZ4=; b=Mtwr2ES2vh9mmZvHSmucQgQ6hrYUrlZASLBJDqfq/8wawt5W1KuPn5TgAclcF47I+I o+1qPWYP3Q8Hr7FSCwSnYqjhKnMZu6819a5ZLvkT1wrRNvB40hYCaQJUoHEyGxQr7SL5 q2vO0YCzHtEGFcXfndXAZ3wSPCaMl/I7Jm/N+RHel92DUPlEZdERU9J8m9PWCUVoNJ0K vAbfou58SaQlTwnV3mE8bQYhHIU43LwMBzGfWqPAK9ZwnUk9OP9P7RNOMi0ZiHwaB32Y rAfYalks4ElUHUBR4MObx/zfuykgQqnl9kVSAkHNOvR09A0Nznx48utSPLTAVqTa5uNG 4WJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745199279; x=1745804079; 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=m8SJmasm0V30Jvmxq2kFniFgyggUbSM9Iglxc1i5dZ4=; b=sNvZMmxBIw6SKorap6Wo4dSX4N4m/B+xnrM2loVYwLXg9kaSWCpchZhUCYVyXeew02 3Lz06/vV2bExlYAV+z3J3DuCdM6A6sH7+GGElIoob7EcuRjYmkXhTSRD0YwkMkT/yIg+ iXaqts88SiEFQU3dALA+DRoJljANoATVYSd56EIOG0YAi1qbXvempZijJwNJ99TIx3W2 kvLBA/wfruV/RYiw0IZEijI6yYEXNFPE877xZv2lx/NtXF8A2fkq6/mz7jxbVT0wgYyX +FhlkD2pWVQqaAEOPePJX8qFFEag9akwLYw9ik6vWVwomoXYI+oZtwOKY1B/J8qKXShY wM9w== X-Forwarded-Encrypted: i=1; AJvYcCWCPZkarJdY363rpDbidQAQbwMIYcH7inShttACsOdZ2KJjl2dPGw7sRZ2I37Xxmk2aAanp4CqqVPNddj7zDg==@vger.kernel.org, AJvYcCWM/vKtT7BGopOXFNwEsMZ2SC+EsA4eoYz9T3khBROUJ4XrLNPKvdjQ90Sx5fROFG6FWWozyrR8GrfrySZW@vger.kernel.org, AJvYcCWqn/Bf1qQ4mf6b59lmkQoR//7rmd+ZnkUB0cUM/UQN1NZN1C8Pkf0+dufyANzIh9PT7hMm5NxSCk46@vger.kernel.org, AJvYcCX15Q7TeEGQJRQCseyosR0zDY89z4EERyPKpCZiXhP3bdSc1hCWWr6Krc3hI2is6A8QBVOkgsQRcuU=@vger.kernel.org X-Gm-Message-State: AOJu0YxMYyQwo0BH4BMxFUms8f5wA9qHm7X4Z9DD2nMmQJK6po98ETpb 7UHG24gCeoyYrMHG4qoZLOUdQwpvLVa3ItHnSe17Z9zrsGKD2EJE X-Gm-Gg: ASbGnctkxV9i5Oupjg5VIQzuVvOL0y9NSZYAohGg0qVuqA9XIiVqYHTnykcg05vIh8B Vj7MFDNKD1Ryrxp7e5X8WEtf0F0cJbFCq8z7XkqxXx8GcKXGNK9R40EX86V2z/9JpMJuJfdGbNZ JE8LCqkoj9RO03m6Lg6IGfYokC823UrMKPAXvYhM+qR4CIKASpXFy8o5LneYr9SxRMgjTeaKl4R V4mbfOuoaCPJd6Wyz48+yk4fFWMlbo6x2q2Krva1TjU2FUAble42CKx0SlbSum8kBsSZdcL+H5i yTtpkZJtT1T4JBRAzC8dsc5eD070EdrywcF6jZLATGNQ+RMn8Cl2kPnfCV3xzEC3S4bXGQ== X-Google-Smtp-Source: AGHT+IEZOGs7SEaXsmFSc3RV7jjtkulCA3X06E+ACwSEK1VbuP6DgiYTa6rahn8ABtq4X6vYSOP9cw== X-Received: by 2002:a05:6830:3881:b0:72b:9d5e:9429 with SMTP id 46e09a7af769-73006211bacmr6321988a34.12.1745199278554; Sun, 20 Apr 2025 18:34:38 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:a8f7:1b36:93ce:8dbf]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7300489cd44sm1267588a34.66.2025.04.20.18.34.36 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 20 Apr 2025 18:34:38 -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" , Luis Henriques , Randy Dunlap , Jeff Layton , Kent Overstreet , Petr Vorel , Brian Foster , 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 PATCH 15/19] famfs_fuse: Plumb dax iomap and fuse read/write/mmap Date: Sun, 20 Apr 2025 20:33:42 -0500 Message-Id: <20250421013346.32530-16-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250421013346.32530-1-john@groves.net> References: <20250421013346.32530-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 | 432 ++++++++++++++++++++++++++++++++++++++++++++++++ fs/fuse/file.c | 14 ++ 2 files changed, 446 insertions(+) diff --git a/fs/fuse/famfs.c b/fs/fuse/famfs.c index 2e182cb7d7c9..8c12e8bd96b2 100644 --- a/fs/fuse/famfs.c +++ b/fs/fuse/famfs.c @@ -603,3 +603,435 @@ 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_invalid(struct inode *inode); + +static int +famfs_meta_to_dax_offset_v2(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; + + /* 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_invalid(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_meta_to_dax_offset() - Resolve (file, offset, len) to (daxdev, of= fset, len) + * + * This function is called by famfs_iomap_begin() to resolve an offset 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_meta_to_dax_offset(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_invalid(inode)) + goto err_out; + + if (meta->fm_extent_type =3D=3D INTERLEAVED_EXTENT) + return famfs_meta_to_dax_offset_v2(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; + + if (!fc->dax_devlist->devlist[daxdev_idx].valid) { + pr_err("%s: daxdev=3D%lld invalid\n", __func__, + daxdev_idx); + 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_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_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_meta_to_dax_offset(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_iomap_begin, +}; + +/********************************************************************* + * vm_operations + */ +static vm_fault_t +__famfs_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_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_filemap_fault(vmf, pe_size, famfs_is_write_fault(vmf)); +} + +static vm_fault_t +famfs_filemap_page_mkwrite(struct vm_fault *vmf) +{ + return __famfs_filemap_fault(vmf, 0, true); +} + +static vm_fault_t +famfs_filemap_pfn_mkwrite(struct vm_fault *vmf) +{ + return __famfs_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 + */ + +/* Reject I/O to files that aren't in a valid state */ +static ssize_t +famfs_file_invalid(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_debug("%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_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_invalid(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_dax_read_iter(struct kiocb *iocb, struct iov_iter *to) +{ + ssize_t rc; + + rc =3D famfs_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; +} + +/** + * famfs_dax_write_iter() + * + * We need our own write-iter in order to prevent append + * + * @iocb: + * @from: iterator describing the user memory source for the write + */ +ssize_t +famfs_dax_write_iter(struct kiocb *iocb, struct iov_iter *from) +{ + ssize_t rc; + + rc =3D famfs_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_file_mmap(struct file *file, struct vm_area_struct *vma) +{ + struct inode *inode =3D file_inode(file); + ssize_t rc; + + rc =3D famfs_file_invalid(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 6f10ae54e710..11201195924d 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1777,6 +1777,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_dax_read_iter(iocb, to); =20 /* FOPEN_DIRECT_IO overrides FOPEN_PASSTHROUGH */ if (ff->open_flags & FOPEN_DIRECT_IO) @@ -1799,6 +1801,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_dax_write_iter(iocb, from); =20 /* FOPEN_DIRECT_IO overrides FOPEN_PASSTHROUGH */ if (ff->open_flags & FOPEN_DIRECT_IO) @@ -1814,10 +1818,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); } @@ -1826,10 +1834,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); } @@ -2635,6 +2647,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_file_mmap(file, vma); =20 /* * If inode is in passthrough io mode, because it has some file open --=20 2.49.0 From nobody Sun Dec 14 19:37:09 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 2BDF01E0DE3; Mon, 21 Apr 2025 01:34:45 +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=1745199288; cv=none; b=shTqhZSF/LsqvS3AzUOFRRqI5WNK9ty8AjXLhaRJ0borY30Kgn4BbT7sXZX4fwApdrXIGDoQ+DbZNOFKDb0qLTm4qUPuTHYvZ2e0jODc18a62qC7JGzrstwPww/CFzDLxxNgCorldmrk/q2tOhdCKmjolaoWO+sSwf6Rr/hdaA0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745199288; c=relaxed/simple; bh=xGy57wKMHcPHaHQmqC7PU7UgEP988xP7vfKFR5LKz6A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JtmlQUf5QSaj+dSe1rC/dOogxU79sWt5wkWBMON9Gk1Qpt4WecYCNlMvAvSQt+f2vPVYIVXOGZIJMh4W6hgxQpE1tKveFpaKXHWUaIHVqayEGOJsoR/tUXAnuVhQrXTj9FwCbHNwEvBe0gx7ktLz0vtAGsbr6P+9lMMQrxo0Cnc= 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=PtfeptV1; 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="PtfeptV1" Received: by mail-ot1-f47.google.com with SMTP id 46e09a7af769-72b82c8230aso1089700a34.2; Sun, 20 Apr 2025 18:34:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745199284; x=1745804084; 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=kGY/iAQALrENz7kCElkxfNZCIv66dIEClpF9MaGB4Dg=; b=PtfeptV1Cr92tV9d8Sl/8CYXhfRbu+QJlrvQeYf7INWEDHZA1VE8nPMgsoi7s2Aw90 k5NZwt5dNyAHAgpINE7a12MsdlgmRo1WQ+XItNwWjZxZRTcYDBGVYfqatZMTqHoXTGgJ MzbnaFIV434jusIGg4SG9G8JO/E/Khlm4R1EBXa/aBS3QeHElAOLP86EjIwoAltDbmpl 7ke/XAal5SWhwUwbBP3wtjS5dlOF+Ds5x9OszDUZyPLb0iWnICdVxvkUJuEc9k8gWrcB 4uLbbEfljT+OCN4SeYAW8ZxZZoIWZiaibw95kNgkVKWEqcJpuDmQgkRYSeWLNa3Wz4vn Eabw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745199284; x=1745804084; 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=kGY/iAQALrENz7kCElkxfNZCIv66dIEClpF9MaGB4Dg=; b=l0IYcXNMDXzdDg4GHPPNMo9pC6bbdAk2FMQ88eC3Bp8e4k29ryv1vRzqMSeTSJ5gsn 1gfwIjoJlZRY0b//VIlO4UZQp6uIOVcgUhJukeWVhHTqdv++vp6x5IkoxA/AXlc/tZML AL//8uHBQSAd0s+lhPC5grPdORlvit6DfwaY7smnAhAphQp66lx9vCldK5/DrXeAqbUg 3vYowf6BGFu9GwElU9VyyGylycSm4keXm2I7nveUPBTK1Tjhz4vpTg16rBk9iyGGtvyb OcZZGLfO+DCigNOPb41ZM2a3LzST6d4laz6SFdTMfY/WYxB1RnSSrZHdiWhKYS8klrR8 lZsg== X-Forwarded-Encrypted: i=1; AJvYcCUjHYB4ftp+ukPG1Sgxkx6lAOtU+V/Ed0GtQSdna+VWyt+YofV9NzdP6OW9q/wOXcxILY9VRsxTzokesCrikg==@vger.kernel.org, AJvYcCVlrkJO6/1jCUsPU+XQZdeEK5zdMmanH9gtSBt7Eh5PALiIndYEgbKoe4OUGLKLeyMGEUBCdAr4sWB+@vger.kernel.org, AJvYcCWwt6YDuYE9/J4v2PG8+cMpdQRPSZMa3K4rFsF9VgkPPXTAbVfjdY30qmT1xnSK4GCRXcN6ik3E8hs=@vger.kernel.org, AJvYcCXI8xlbnqfSUgNpuh3VIg3YSg37lSh1VkEn77W4TqbYUpkC7kp6MOE2aRoQGObmtZp7375cgMNn8CQ65tlK@vger.kernel.org X-Gm-Message-State: AOJu0YwV+xcMCvH1Jj0sBbD82FOBiliswo1JRuU8JCWledxH8GRBDM3M SrM4CrJcYdXCrYonWiDRARqRJ99OKYumg5svV/hV2XPIc36UTs/W X-Gm-Gg: ASbGncv/tHEAxPGiCAQAdJUO1AwaRgHZ2clUmwhhkbijMJ2MNEELPpyes/zbCJb1Uw7 ik4g4kqUVA2n4BXA/CuotmHEsOXNLp9muOU27fSXUzxg7WK3+sxLF/SO9X9RSjf6SRIM172G1Qb hzd/ECnUiuw6s+xtfsH4tnFBLrFzTe5+IAt5FRNAtLYmwWldu6RQ/8JR2XxiiNaZwMBnc/kA53P zoYrx1vorKsqb2Z6PS75y2N5gZViQZng9vxD4eU+6dFpm687sUijztuPPaoUHOhXTLXm2FGTOJf Z3UvPd9HrOAm92ssFiqOFe4GoVE2ZPpdcxBUBZdkC8NfCHDuM+3nnbhVzj3p/gnYenSkyQ== X-Google-Smtp-Source: AGHT+IHi4NS1xMTqypMU3t1y5JPLpqGjkg0Jz7FECLjaMyt6sb+shrqrVp3uCCLvcJOP+hFAPH4l6Q== X-Received: by 2002:a05:6830:4709:b0:72b:992b:e41 with SMTP id 46e09a7af769-730063311a1mr6130128a34.23.1745199284265; Sun, 20 Apr 2025 18:34:44 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:a8f7:1b36:93ce:8dbf]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7300489cd44sm1267588a34.66.2025.04.20.18.34.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 20 Apr 2025 18:34:43 -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" , Luis Henriques , Randy Dunlap , Jeff Layton , Kent Overstreet , Petr Vorel , Brian Foster , 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 PATCH 16/19] famfs_fuse: Add holder_operations for dax notify_failure() Date: Sun, 20 Apr 2025 20:33:43 -0500 Message-Id: <20250421013346.32530-17-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250421013346.32530-1-john@groves.net> References: <20250421013346.32530-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 | 154 ++++++++++++++++++++++++++++++++++------------- fs/fuse/file.c | 6 +- fs/fuse/fuse_i.h | 6 +- 3 files changed, 117 insertions(+), 49 deletions(-) diff --git a/fs/fuse/famfs.c b/fs/fuse/famfs.c index 8c12e8bd96b2..363031704c8d 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() * @@ -169,6 +189,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; @@ -263,6 +292,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 @@ -610,10 +671,10 @@ famfs_file_init_dax( * offsets within a dax device. */ =20 -static ssize_t famfs_file_invalid(struct inode *inode); +static ssize_t famfs_file_bad(struct inode *inode); =20 static int -famfs_meta_to_dax_offset_v2(struct inode *inode, struct iomap *iomap, +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); @@ -628,7 +689,7 @@ famfs_meta_to_dax_offset_v2(struct inode *inode, struct= iomap *iomap, goto err_out; } =20 - if (famfs_file_invalid(inode)) + if (famfs_file_bad(inode)) goto err_out; =20 iomap->offset =3D file_offset; @@ -649,6 +710,7 @@ famfs_meta_to_dax_offset_v2(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; @@ -658,9 +720,11 @@ famfs_meta_to_dax_offset_v2(struct inode *inode, struc= t 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; @@ -695,9 +759,9 @@ famfs_meta_to_dax_offset_v2(struct inode *inode, struct= iomap *iomap, } =20 /** - * famfs_meta_to_dax_offset() - Resolve (file, offset, len) to (daxdev, of= fset, len) + * famfs_fileofs_to_daxofs() - Resolve (file, offset, len) to (daxdev, off= set, len) * - * This function is called by famfs_iomap_begin() to resolve an offset in a + * 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 @@ -717,7 +781,7 @@ famfs_meta_to_dax_offset_v2(struct inode *inode, struct= iomap *iomap, * Return values: 0. (info is returned in a modified @iomap struct) */ static int -famfs_meta_to_dax_offset(struct inode *inode, struct iomap *iomap, +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); @@ -731,12 +795,13 @@ famfs_meta_to_dax_offset(struct inode *inode, struct = iomap *iomap, goto err_out; } =20 - if (famfs_file_invalid(inode)) + if (famfs_file_bad(inode)) goto err_out; =20 if (meta->fm_extent_type =3D=3D INTERLEAVED_EXTENT) - return famfs_meta_to_dax_offset_v2(inode, iomap, file_offset, - len, flags); + return famfs_interleave_fileofs_to_daxofs(inode, iomap, + file_offset, + len, flags); =20 iomap->offset =3D file_offset; =20 @@ -757,10 +822,14 @@ famfs_meta_to_dax_offset(struct inode *inode, struct = iomap *iomap, */ 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]; =20 - if (!fc->dax_devlist->devlist[daxdev_idx].valid) { - pr_err("%s: daxdev=3D%lld invalid\n", __func__, - 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; } =20 @@ -808,7 +877,7 @@ famfs_meta_to_dax_offset(struct inode *inode, struct io= map *iomap, } =20 /** - * famfs_iomap_begin() - Handler for iomap_begin upcall from dax + * famfs_fuse_iomap_begin() - Handler for iomap_begin upcall from dax * * This function is pretty simple because files are * * never partially allocated @@ -824,7 +893,7 @@ famfs_meta_to_dax_offset(struct inode *inode, struct io= map *iomap, * @srcmap: */ static int -famfs_iomap_begin(struct inode *inode, loff_t offset, loff_t length, +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); @@ -835,21 +904,21 @@ famfs_iomap_begin(struct inode *inode, loff_t offset,= loff_t length, =20 WARN_ON(size !=3D meta->file_size); =20 - return famfs_meta_to_dax_offset(inode, iomap, offset, length, flags); + return famfs_fileofs_to_daxofs(inode, iomap, offset, length, flags); } =20 /* 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_iomap_begin, + .iomap_begin =3D famfs_fuse_iomap_begin, }; =20 /********************************************************************* * vm_operations */ static vm_fault_t -__famfs_filemap_fault(struct vm_fault *vmf, unsigned int pe_size, +__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); @@ -886,25 +955,25 @@ famfs_is_write_fault(struct vm_fault *vmf) static vm_fault_t famfs_filemap_fault(struct vm_fault *vmf) { - return __famfs_filemap_fault(vmf, 0, famfs_is_write_fault(vmf)); + return __famfs_fuse_filemap_fault(vmf, 0, famfs_is_write_fault(vmf)); } =20 static vm_fault_t famfs_filemap_huge_fault(struct vm_fault *vmf, unsigned int pe_size) { - return __famfs_filemap_fault(vmf, pe_size, famfs_is_write_fault(vmf)); + return __famfs_fuse_filemap_fault(vmf, pe_size, famfs_is_write_fault(vmf)= ); } =20 static vm_fault_t famfs_filemap_page_mkwrite(struct vm_fault *vmf) { - return __famfs_filemap_fault(vmf, 0, true); + return __famfs_fuse_filemap_fault(vmf, 0, true); } =20 static vm_fault_t famfs_filemap_pfn_mkwrite(struct vm_fault *vmf) { - return __famfs_filemap_fault(vmf, 0, true); + return __famfs_fuse_filemap_fault(vmf, 0, true); } =20 static vm_fault_t @@ -926,16 +995,23 @@ const struct vm_operations_struct famfs_file_vm_ops = =3D { * file_operations */ =20 -/* Reject I/O to files that aren't in a valid state */ +/** + * 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_invalid(struct inode *inode) +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); =20 if (!meta) { - pr_debug("%s: un-initialized famfs file\n", __func__); + pr_err("%s: un-initialized famfs file\n", __func__); return -EIO; } if (meta->error) { @@ -956,7 +1032,7 @@ famfs_file_invalid(struct inode *inode) } =20 static ssize_t -famfs_rw_prep(struct kiocb *iocb, struct iov_iter *ubuf) +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); @@ -964,7 +1040,7 @@ famfs_rw_prep(struct kiocb *iocb, struct iov_iter *ubu= f) size_t max_count; ssize_t rc; =20 - rc =3D famfs_file_invalid(inode); + rc =3D famfs_file_bad(inode); if (rc) return rc; =20 @@ -980,11 +1056,11 @@ famfs_rw_prep(struct kiocb *iocb, struct iov_iter *u= buf) } =20 ssize_t -famfs_dax_read_iter(struct kiocb *iocb, struct iov_iter *to) +famfs_fuse_read_iter(struct kiocb *iocb, struct iov_iter *to) { ssize_t rc; =20 - rc =3D famfs_rw_prep(iocb, to); + rc =3D famfs_fuse_rw_prep(iocb, to); if (rc) return rc; =20 @@ -997,20 +1073,12 @@ famfs_dax_read_iter(struct kiocb *iocb, struct iov_i= ter *to) return rc; } =20 -/** - * famfs_dax_write_iter() - * - * We need our own write-iter in order to prevent append - * - * @iocb: - * @from: iterator describing the user memory source for the write - */ ssize_t -famfs_dax_write_iter(struct kiocb *iocb, struct iov_iter *from) +famfs_fuse_write_iter(struct kiocb *iocb, struct iov_iter *from) { ssize_t rc; =20 - rc =3D famfs_rw_prep(iocb, from); + rc =3D famfs_fuse_rw_prep(iocb, from); if (rc) return rc; =20 @@ -1021,12 +1089,12 @@ famfs_dax_write_iter(struct kiocb *iocb, struct iov= _iter *from) } =20 int -famfs_file_mmap(struct file *file, struct vm_area_struct *vma) +famfs_fuse_mmap(struct file *file, struct vm_area_struct *vma) { struct inode *inode =3D file_inode(file); ssize_t rc; =20 - rc =3D famfs_file_invalid(inode); + rc =3D famfs_file_bad(inode); if (rc) return (int)rc; =20 diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 11201195924d..47b3d76acb38 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1778,7 +1778,7 @@ static ssize_t fuse_file_read_iter(struct kiocb *iocb= , struct iov_iter *to) if (FUSE_IS_VIRTIO_DAX(fi)) return fuse_dax_read_iter(iocb, to); if (fuse_file_famfs(fi)) - return famfs_dax_read_iter(iocb, to); + return famfs_fuse_read_iter(iocb, to); =20 /* FOPEN_DIRECT_IO overrides FOPEN_PASSTHROUGH */ if (ff->open_flags & FOPEN_DIRECT_IO) @@ -1802,7 +1802,7 @@ static ssize_t fuse_file_write_iter(struct kiocb *ioc= b, struct iov_iter *from) if (FUSE_IS_VIRTIO_DAX(fi)) return fuse_dax_write_iter(iocb, from); if (fuse_file_famfs(fi)) - return famfs_dax_write_iter(iocb, from); + return famfs_fuse_write_iter(iocb, from); =20 /* FOPEN_DIRECT_IO overrides FOPEN_PASSTHROUGH */ if (ff->open_flags & FOPEN_DIRECT_IO) @@ -2648,7 +2648,7 @@ static int fuse_file_mmap(struct file *file, struct v= m_area_struct *vma) if (FUSE_IS_VIRTIO_DAX(fi)) return fuse_dax_mmap(file, vma); if (fuse_file_famfs(fi)) - return famfs_file_mmap(file, vma); + 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 4c4c4f0ff280..702c1849720c 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -1561,9 +1561,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_dax_write_iter(struct kiocb *iocb, struct iov_iter *from); -ssize_t famfs_dax_read_iter(struct kiocb *iocb, struct iov_iter *to); -int famfs_file_mmap(struct file *file, struct vm_area_struct *vma); +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 Sun Dec 14 19:37:09 2025 Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.179]) (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 02AF81E130F; Mon, 21 Apr 2025 01:34:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745199290; cv=none; b=R3pRABDvD7nBdUvoB38YMdywp5tDe/7IgI1WRsIJ0JePdhTbdsF5Q7TR4ZIbVFM8dwY6oPeU/c8YNPJRxxMJJnqFkz22pP/MZZZk9VIk5GGsY+9droxPJgej+gU9Ab/Q2VB3gcz3zF0q2K+WgUjbsvIryrmt0O9fzkLsL9F7fjw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745199290; c=relaxed/simple; bh=MM13n9Dx+H0dyx/Dhthrh9y/E3RrzqwxsXubhn+xKog=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=iDXu4sHIhFIqwUg9injW+TNzr4P4TiNKoE0s3YUZEsfSF+EJcWebu4b2Q+nve3R+mRDlIyJZD8caU9aF0E8z9lC6enFZk4hOZs3LzCA3AQT/xF96aDum1Piy2kPMRaFvCUlv7beL8V4LoFT7qJgbuROptceYuo6N8tcf5B1vO/E= 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=FZmGsK4u; arc=none smtp.client-ip=209.85.167.179 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="FZmGsK4u" Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-3fa6c54cc1aso2188990b6e.1; Sun, 20 Apr 2025 18:34:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745199288; x=1745804088; 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=8DZkuvGPoZyvYY7CYd1QUDkY8rgPO2CgXNLlDQXY+DU=; b=FZmGsK4ux79y00KkD3hUmSUc9N3lSc+zeTiclyuXSKPJoEloduaxkiqKbkB8ATj2qt 6QqAUEcF1fJpJecJVL4NGHk5qlm86EsnnuElMCfXeV7IF4cQ4WblH5K1e4iDAKsUtXJ0 E0WxNr2LtVd5+0KCjYSZKKfJzO03dbmsETf8h2voy9frshhsbsuk2XUdVaOWoNL+jhp5 riMVq2uvHqkO6vFYv7Jc+bTKTBuNZoAogJbEA4g5XxsD7QHSrO3hKrj0c9ud8nAihiUY 0i005FyBL7EQDF8P7d/vgEMZp5HoAq8aW2zyYrAUNWRdVG+0tmZaWyI2ABjt/e0/4ukN hejg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745199288; x=1745804088; 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=8DZkuvGPoZyvYY7CYd1QUDkY8rgPO2CgXNLlDQXY+DU=; b=tvJ+BxwJ2Er7R0J0SwlmhO1TkkVT+qPIrWkuu0767yA1NuUXCDE8/ecjSsC4NDwegQ XFI59iYuFpqZ6sEyX/h088TpsHo2DDCwRjxdWkK6zY8CbfNRLFWisAANXrePKoYheJG9 OjS7Rcg/X7e+LMzJ5XDMxhggs4qmsA+/8TMUShTG07roV4t99V1n7DMiN7hLzIs+gGu7 bpMt6fkDjAJtTethkaqqrT3i23Sab+3880KFHypjmKPOIRiJooXzzIkxzO703wc66V5L SaN2wkAHO5qgzgd2VahWVSn8wlebbbLKUzXfC6U4kYicrhZwamVtg5YRZMVYPaeRDtfv gHcw== X-Forwarded-Encrypted: i=1; AJvYcCUh6Ft2ze+ZBIqVQ/v7AlDE2iFXOKMGKARtcGzSF/HPi10WwgDbJtTNQ1pL+po53t5yyMWpxp6VV1DnePhF/w==@vger.kernel.org, AJvYcCUijj6R4YNQZeE1eAoq3trFk7MtRi1cA7XZpgurfplUQVfA5Q+fvu2pcyOFIS70G06G8r0PZof5rhs0VMzU@vger.kernel.org, AJvYcCW2w77vWm4ovqpvuH2KGv9Q2UMBq854SNiRNejYXVOEdW+jMttrJvI8L7gvnt3XhS5JQrtO7lZqTi7r@vger.kernel.org, AJvYcCXPtFhnaSaHH0veLkkY8YFIbGP1Gd+asqFNYILw/74yLM9dh43hBKClxrFpWEeue1c4vqqtxa6gwds=@vger.kernel.org X-Gm-Message-State: AOJu0YxNOBNXI0iZKcFKXyj7InCoyGWYM3HDQzj/OBoGezJ2iR3Kzn/5 H11kVtna0e3fKfV1eOPT9aIk3WR3oDaUlxXzl3ypr+l6hPG/WDvD X-Gm-Gg: ASbGncv2zv6Y8foV2UIy4Sgyw3CXhZn2zpCsjnyncFSOPzgqnyEsPH2Oy//ToivJ9+c qpo9C7VXZZRUtLuDu9BCV6WPKiZXyg+jJwtAtjpHxB8xxxSRXgt/KYO+zD342cAEdoINoP9HtFw 0SJdRtLq0IXrWbKZnadP2uxbhsOixo1wceCacn0QV57mlQJG5yucGemjtklw7xwoR+s8QafNBGj x9AZ++YZrLOO8/zeBQwmOjFkSHlQansy7/lpDoU4ygo2H+nqwp7HpxhBasBg1vwHr0GhKr3Zifh d7CKKpaDjuh9zCUgJu+YbilA3OBLh6Fgq4JH6ANVIcKzNou4dyBLUni2txGrAfHNbvSVzQ== X-Google-Smtp-Source: AGHT+IHRzHbpEH68+SMoh6y648whfivnAKStZ+3OUKcCZuorXP0l5a3+idNZSKoZxCVX8afRpNyjWg== X-Received: by 2002:a05:6830:4193:b0:72b:8ec6:e533 with SMTP id 46e09a7af769-7300620c89fmr5674124a34.7.1745199287924; Sun, 20 Apr 2025 18:34:47 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:a8f7:1b36:93ce:8dbf]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7300489cd44sm1267588a34.66.2025.04.20.18.34.46 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 20 Apr 2025 18:34:47 -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" , Luis Henriques , Randy Dunlap , Jeff Layton , Kent Overstreet , Petr Vorel , Brian Foster , 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 PATCH 17/19] famfs_fuse: Add famfs metadata documentation Date: Sun, 20 Apr 2025 20:33:44 -0500 Message-Id: <20250421013346.32530-18-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250421013346.32530-1-john@groves.net> References: <20250421013346.32530-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 | 90 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 85 insertions(+), 5 deletions(-) diff --git a/fs/fuse/famfs_kfmap.h b/fs/fuse/famfs_kfmap.h index 325adb8b99c5..7c8d57b52e64 100644 --- a/fs/fuse/famfs_kfmap.h +++ b/fs/fuse/famfs_kfmap.h @@ -7,10 +7,90 @@ #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 (devined 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 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 +99,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 +143,7 @@ struct famfs_file_meta { /* * dax_devlist * - * 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 Sun Dec 14 19:37:09 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 EEF9D1E2848; Mon, 21 Apr 2025 01:34:51 +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=1745199293; cv=none; b=Bd2d7qQiAc/v+gEj3QHZXH5nVVETNtxnxHKtWM3Z+b7T/23tNNTj3Lkv3Sv3f0zmtdVvheE26laI+6iE/Gj3J45mkb/+QpxtOEFxTIz93HuB57L9A6ifG/5Wh4MQ3q01bYxI2FYCUlBK2/tZyTkf+QziDJpkSvK5XyZvjCo0+UM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745199293; c=relaxed/simple; bh=KPHEXE5Cp/zGdVywYOsVdEbL6sn2rwfyb9wjdHeyhi0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ROIjpkiSSNPBSQcohUb3i69QkT9C52/vCTLUp0vV+R6nDY2L6R6TCB9l37aggxIv1Or04FrV5RUtuNvKv82uPJo1senGE5Pifi4UQwtWiLaIPMwfpDOxkuK66e7IKP5rkTwcw/lSa8gLEAy/vsqAlyGltnb6PTHjDWiL27VjWPg= 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=iVWkWp10; 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="iVWkWp10" Received: by mail-ot1-f48.google.com with SMTP id 46e09a7af769-72c1425fbfcso1462685a34.3; Sun, 20 Apr 2025 18:34:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745199291; x=1745804091; 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=Oc4Vdr0o+nfx1QBJZJ6xepmEuT/UhfqhypvD0CxI7Ro=; b=iVWkWp10DK7t/zHk/+7b4yrffxMUoax3r0cmL0tD/l6KypQxho5HKxAV/y29a5HAHJ oUEsYJpkYBJbtjKNKg6zQxrHB2Qmi/fmOQYyFEuEVUkDMzXSIZgBpvYC29OyScSmOOfe urLyYHKmkSZa8OCODRGJm4UTrHaL2DxT5Wxg1Sok01VKBj8Y0Ji2n9lAvqtMqnErD3CB BGpuDzdaOkr5tuMRt5S8DyyUWpWZZyTcvQJy+qESajtQkMN5tUB4ykKPqQGJ9GZDcAFG iGp0yQg1kVqK30YBUA+dB38V4aV5/ghe228udouMeGX7A7k+MVLa/BKkBmaba3fO8X2v hRJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745199291; x=1745804091; 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=Oc4Vdr0o+nfx1QBJZJ6xepmEuT/UhfqhypvD0CxI7Ro=; b=RaJKPEU1l7FfB33PRfOizu4pJrJk69wPWq/fU3IHd2zmPPaNTOYunk5kEawwg4Cus+ 2Ca9JJnFpbyRGaRdpgkuYxokggtkajqu//WP7d+JvgUdkHSkI5fxzEZ3Iy48lbDTPbJi GGM4SGiS+LvvR5cRahCKG+GjT3slzn0h1L/SxZFjdJrJWfcNkcGaVuw/u7Yx7PpQUwJ5 OwZE89UUIhLy+gJn1nWnOm5SFGvQzmK1Dj5szHmLhgIkiFv1mtz+BSKEeay+ehcAA9aK 4/oCXOJEMWBw9ZD0gDdBKaBUJGtVf6EGO/YcP2+g52HzwEqDMar9i3EJbCd97niz2tHl hznw== X-Forwarded-Encrypted: i=1; AJvYcCUUO//b+QG1I1DaML0XjXD8REL5wNmuQ8kbSbv9bFgaO5ZGbhk9g62itJB6CxB55yF/7WxCKnJi/n4=@vger.kernel.org, AJvYcCUtsU0pAH/pQpXCCrIPrdifFqaN/Tql6orUc9axzaR97Tp9SkU228dUVx89zKf/nEZo3Tm55PmaSMnf@vger.kernel.org, AJvYcCVJF1d9C12M1aYIxfV27TIa7KJrBmHjUI7XQxlVv/qU/BJriaUKhjxf5sDQhzsj34l7jEndFnCjMx0y75wW@vger.kernel.org, AJvYcCWJnc6IBGBFUJ8IJzc5n+xR9xQpVc3ukCUKQXo7ypRkokgUAaOdA+OzhT/E1jMNBASgobvJza6504CBsNyctw==@vger.kernel.org X-Gm-Message-State: AOJu0YyUO3XrbOw2CA5n9RkrFtYYk9EHZUCUKXHqgh++0SUjG0j7eLUS p/L/E2XH7/pqc8fGMJdvj1C+6hZrrRZJy7j3xx4DkzHFZdL3WK/1 X-Gm-Gg: ASbGncvxQsKzsS+/DaLIQAklqy39NW4jYw/YLka+kTrCODHnhRcbkxpnNhdlu2kwY4I UWspSt7mVqTlBrBJYN1AYl+Sd/5pkwZTAvf4tGqEhYKY2JBQm+uw/pnhaNk/4IULNegMQezyTYl O0Xsc30bF7cMRjTyCUgZsNOk0itR6i97YQsbdjAxY62+Yt7nNIOGlz/jskX7pHHusjVnhwxHqgo KNFJqiV0bErkVNzXd9+gpgf3IBRFvnhypIb8eJSD98ESI42t+oro+e/3lf+n3FW27Iwpc4mX9Zp l261Fo4ObzgsN79eXx6mf8+F6kgMhkOCDShEBLtPvy8l4Kc0vPCiu2ny7PG9xR5z/Pvv2Q== X-Google-Smtp-Source: AGHT+IFvfaaZSi7N+55feNIb6bsiG1ALvnMH5W+/Xpyce53EuyD/gGFkOnKxGp91Sfa8827mA2MSVg== X-Received: by 2002:a05:6830:4988:b0:72b:955a:852c with SMTP id 46e09a7af769-73006212cc9mr6434150a34.11.1745199290828; Sun, 20 Apr 2025 18:34:50 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:a8f7:1b36:93ce:8dbf]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7300489cd44sm1267588a34.66.2025.04.20.18.34.48 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 20 Apr 2025 18:34:50 -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" , Luis Henriques , Randy Dunlap , Jeff Layton , Kent Overstreet , Petr Vorel , Brian Foster , 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 PATCH 18/19] famfs_fuse: Add documentation Date: Sun, 20 Apr 2025 20:33:45 -0500 Message-Id: <20250421013346.32530-19-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250421013346.32530-1-john@groves.net> References: <20250421013346.32530-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 --- 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..b6b3500b6905 --- /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 2a5a7e0e8b28..46744be9e6d1 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 From nobody Sun Dec 14 19:37:09 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 2AF371E51FA; Mon, 21 Apr 2025 01:34:54 +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=1745199296; cv=none; b=GcDufSfbSZaJoRZnMhgVwCqsfJXpv3wcTxoy12QW0N6fpVl6pHc1e+IC7h3+eZ5haa1o6n5+yJdnsfa5NgObzpAHK6urURFCGvbdCCH8VzLdoPGaOPMrpjZu3vy7nf6oMUNrzMsI3dKNcVoEBpVY6JYWSaaaX1aZDnaFx9yS/0o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745199296; c=relaxed/simple; bh=PEQixm1WSR8qIvIweIBLz5yb47diHKRVT7ZCrAw41jE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OV8IxPDR27Ubs+TncNRDCHUPAtM0v9WkvVdKw0CPfZ+SJ39jMkgSkgkUFmei2NvEp5kmhtZkp4pK8uHv3YpR9iD/gakyCp6AvpDhEpVWQzqmLxWjhk529rIZC/VXBl94noEJwo+ZsT1frkhUYN45ARjC0mhHPsclxw85sVnqnpE= 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=X1RGC1be; 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="X1RGC1be" Received: by mail-ot1-f45.google.com with SMTP id 46e09a7af769-72c3b863b8eso2361800a34.2; Sun, 20 Apr 2025 18:34:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745199294; x=1745804094; 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=mdQVZhgSGxPpGqga5Gwo7PXNt34SxV9og+/VWo3OSP8=; b=X1RGC1beM8DJyHo5JWSKeZifBqirEQb9uu7/JfNOgLHU+r7f/ltEFXy2XlRgKKfQDN qj3J8yz0l6SntKjjJ7otVXCLMuUPpDp42pk3EmE//e0iZEtTxQn9D6CYqgyWkJRyw3RK k80JuQF7qniaLctZQqV61XZimkqAAI+bdMe4pK4hh4wdx0ak6LDVsUXdJ/Nc/4kC5ZAL lodJpvPsG3JU2UhFr6kr7zGncNdvz2xBMW/FM1HoospPFhIfrAlJyiGjGRiejJUDwLyl PIGprGznbIwJFZJfJ9a4Z3/O7XbcElHgjvx7dRUpSnf7+kLRUS53ZHXOIT4HBP/rWkCL cOYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745199294; x=1745804094; 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=mdQVZhgSGxPpGqga5Gwo7PXNt34SxV9og+/VWo3OSP8=; b=vjlLSM+m6L6peVEjM4q4F08nVLO573O5C0NXiWkN53J5T0bzs1SnAGltQdSn1lDaH1 pXOSGirB9ArJsL/BUO0eIM+uObPIKPBypA1yFIMrrkCXW1rdmMXe3l/2kc4XXjKUeeoE dSV/yrYLRfMw9BhOgcN7U1L9BT42bGjgSz4JKZDGV9EsgP2wkaEQOAFx8kMEhKOOeX/1 X193B0Irw1PUtEdj8EyKrVeck0thYGo9yDnuq3chlBp9y3nvD14ts6+mz8jgwmWrcVZA ubdkiHw5U74v0Idl/YixaWuk0op/RJvdfeYxDabtSYEGvaul/PN72ZXm6fnASZRXNhqi /R0A== X-Forwarded-Encrypted: i=1; AJvYcCUtbCGncwFLb+UDZj3+wD/gu07OxzvHq8px8LRBgRQ3gVzIMj4ke5rfAIS30HDBh4upxmmuQkly7mVa@vger.kernel.org, AJvYcCVj1xlZPNTLzRn2hsDCnnMxGwGvjhM1kbaBgHlUUL6dzR5BaxtJvP+wl2gYGoymCXrTC69UF0l761BiG3AH@vger.kernel.org, AJvYcCWJpY6zBJyjyZcS0DHT3e9WqkLQ5S60U1N+vwvpNgh6bLFuexx2nyQYjx7dAc7Q7/Ks7UUM/+pb1sVShfg9RA==@vger.kernel.org, AJvYcCWwhTEaZv4nhKRbdhgctcThKXSzmjxuykHJI8A4EvXe7U7OnryR88uS7LVeem0WlOmDgWcfr6/LOMA=@vger.kernel.org X-Gm-Message-State: AOJu0YzJMuOwmTGfVUF5dXFIE9EnSZuSkxVOjyJhYjqZXEjK7xIokmEA Zo7H+ct5YPIo9Wv01pxE+GPattQnY+vltbloIj1iEAcCMt66JZY/wJZsD9bK1Go= X-Gm-Gg: ASbGnctj7Qlw5hpV4fQf0nh6fI3Cwd7rDcNqj5sstbTVbE14TFmEl51sDcoC2so206x xBdBCWwtV3gE90+LVcYxGTGaLHrgih2kV8PllpfynpY4fB7NyDxLayE16tZfz0nFHOylGJxSBC+ rYP+m5jCPpJgkPK//+UIIraAlL/atyVJbuzOEeBFzle03bTrSPFJKbov+yK3VvGbInxlcjkwujm ylSrp4cVzXtIylavRm/X+T3zBuwD8xMBI1qXAshqFMChWHd/AbLlzBGr10CMtYouT8flGndqTxd EMWA/o3K6Wni2mkMW5tcJSejZks2d8b0P7zhVLyW1eU9fwbYZD5vOfcVMHQb8thKwU+gqQ== X-Google-Smtp-Source: AGHT+IFvhi11eKZv5Y/gzRlzyAgr2UzcgOUfeV5gBpd2B3+8/z28bKwE37MnSOlyjxSbt8eeloMeSg== X-Received: by 2002:a05:6830:7182:b0:72b:80b8:8c67 with SMTP id 46e09a7af769-73006333e6fmr5754877a34.28.1745199294139; Sun, 20 Apr 2025 18:34:54 -0700 (PDT) Received: from localhost.localdomain ([2603:8080:1500:3d89:a8f7:1b36:93ce:8dbf]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7300489cd44sm1267588a34.66.2025.04.20.18.34.52 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 20 Apr 2025 18:34: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" , Luis Henriques , Randy Dunlap , Jeff Layton , Kent Overstreet , Petr Vorel , Brian Foster , 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 PATCH 19/19] famfs_fuse: (ignore) debug cruft Date: Sun, 20 Apr 2025 20:33:46 -0500 Message-Id: <20250421013346.32530-20-john@groves.net> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250421013346.32530-1-john@groves.net> References: <20250421013346.32530-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 debug cruft will be dropped from the "real" patch set Signed-off-by: John Groves --- fs/fuse/Makefile | 2 +- fs/fuse/dev.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/fs/fuse/Makefile b/fs/fuse/Makefile index 65a12975d734..ad3e06a9a809 100644 --- a/fs/fuse/Makefile +++ b/fs/fuse/Makefile @@ -4,7 +4,7 @@ # =20 # Needed for trace events -ccflags-y =3D -I$(src) +ccflags-y =3D -I$(src) -g -DDEBUG -fno-inline -fno-omit-frame-pointer =20 obj-$(CONFIG_FUSE_FS) +=3D fuse.o obj-$(CONFIG_CUSE) +=3D cuse.o diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 51e31df4c546..ba947511a379 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -30,6 +30,60 @@ MODULE_ALIAS_MISCDEV(FUSE_MINOR); MODULE_ALIAS("devname:fuse"); =20 +static char *opname[] =3D { + [FUSE_LOOKUP] =3D "LOOKUP", + [FUSE_FORGET] =3D "FORGET", + [FUSE_GETATTR] =3D "GETATTR", + [FUSE_SETATTR] =3D "SETATTR", + [FUSE_READLINK] =3D "READLINK", + [FUSE_SYMLINK] =3D "SYMLINK", + [FUSE_MKNOD] =3D "MKNOD", + [FUSE_MKDIR] =3D "MKDIR", + [FUSE_UNLINK] =3D "UNLINK", + [FUSE_RMDIR] =3D "RMDIR", + [FUSE_RENAME] =3D "RENAME", + [FUSE_LINK] =3D "LINK", + [FUSE_OPEN] =3D "OPEN", + [FUSE_READ] =3D "READ", + [FUSE_WRITE] =3D "WRITE", + [FUSE_STATFS] =3D "STATFS", + [FUSE_STATX] =3D "STATX", + [FUSE_RELEASE] =3D "RELEASE", + [FUSE_FSYNC] =3D "FSYNC", + [FUSE_SETXATTR] =3D "SETXATTR", + [FUSE_GETXATTR] =3D "GETXATTR", + [FUSE_LISTXATTR] =3D "LISTXATTR", + [FUSE_REMOVEXATTR] =3D "REMOVEXATTR", + [FUSE_FLUSH] =3D "FLUSH", + [FUSE_INIT] =3D "INIT", + [FUSE_OPENDIR] =3D "OPENDIR", + [FUSE_READDIR] =3D "READDIR", + [FUSE_RELEASEDIR] =3D "RELEASEDIR", + [FUSE_FSYNCDIR] =3D "FSYNCDIR", + [FUSE_GETLK] =3D "GETLK", + [FUSE_SETLK] =3D "SETLK", + [FUSE_SETLKW] =3D "SETLKW", + [FUSE_ACCESS] =3D "ACCESS", + [FUSE_CREATE] =3D "CREATE", + [FUSE_INTERRUPT] =3D "INTERRUPT", + [FUSE_BMAP] =3D "BMAP", + [FUSE_IOCTL] =3D "IOCTL", + [FUSE_POLL] =3D "POLL", + [FUSE_FALLOCATE] =3D "FALLOCATE", + [FUSE_DESTROY] =3D "DESTROY", + [FUSE_NOTIFY_REPLY] =3D "NOTIFY_REPLY", + [FUSE_BATCH_FORGET] =3D "BATCH_FORGET", + [FUSE_READDIRPLUS] =3D "READDIRPLUS", + [FUSE_RENAME2] =3D "RENAME2", + [FUSE_COPY_FILE_RANGE] =3D "COPY_FILE_RANGE", + [FUSE_LSEEK] =3D "LSEEK", + [CUSE_INIT] =3D "CUSE_INIT", + [FUSE_TMPFILE] =3D "TMPFILE", + [FUSE_SYNCFS] =3D "SYNCFS", + [FUSE_GET_FMAP] =3D "GET_FMAP", + [FUSE_GET_DAXDEV] =3D "GET_DAXDEV", +}; + static struct kmem_cache *fuse_req_cachep; =20 static void fuse_request_init(struct fuse_mount *fm, struct fuse_req *req) @@ -566,6 +620,13 @@ ssize_t __fuse_simple_request(struct mnt_idmap *idmap, } fuse_put_request(req); =20 + pr_debug("%s: opcode=3D%s (%d) nodeid=3D%lld out_numargs=3D%d len[0]=3D%d= len[1]=3D%d\n", + __func__, opname[args->opcode], args->opcode, + args->nodeid, + args->out_numargs, + args->out_args[0].size, + (args->out_numargs > 1) ? args->out_args[1].size : 0); + return ret; } =20 --=20 2.49.0