From patchwork Fri Feb 23 17:41:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Groves X-Patchwork-Id: 13569758 Received: from mail-oa1-f41.google.com (mail-oa1-f41.google.com [209.85.160.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 B707D12FB30; Fri, 23 Feb 2024 17:42:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710141; cv=none; b=k0wa853Gf/xRy/+o3uXl9mI7ChLVTLxL0PbECB359sMGyTVKB3l++v7zgtvBVONukANeWk+WyZJnfOupoxr4LUqCuaLvpIWZeFhhRaVBLBUn3iM2UxE4NIzQ7IDZCIiiUxxacKDpjiUyCrQIav8/wtWp0xX/0bqg/nppOJOCLHU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710141; c=relaxed/simple; bh=GoMsVLjZ2QsC8jpJba4e1MZuvUQxhdOSn97WPVZGJsM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NcDHWMjKocAiKzCnf9m/12WdwTdZ84oCLAOwf5aTQYCjbKlUvHW/lAJFxKzha9/Jc1c1Cw2YVYB9gSAL2sT9RycVoUf+//jFwhm9p21ddkLP8Dawc30bIcJJnhcCyqWtz2uhOQEb95wi55VnJctSrpj6+ujMBoqGjQu7DUP1hpA= 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=GEmqD/VE; arc=none smtp.client-ip=209.85.160.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="GEmqD/VE" Received: by mail-oa1-f41.google.com with SMTP id 586e51a60fabf-21f996af9bdso224991fac.2; Fri, 23 Feb 2024 09:42:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708710139; x=1709314939; 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=L8CWGVS5oYo9Xv5uGh2hBH5hNaU6W6dhr1j9gGPoJgA=; b=GEmqD/VEWtjsFRvncfHYUIc4c4A6W/QwIh7TZDE2bsce0j8tLDnCsQMFYywgSJ9GcG pg2bjzCP+RTC0P2g9gCY5Bc9ghPFjpMxL5jnqZEJYeEFebqji0xAtzGToLHevmisfsX/ phZGIvAYdawpVCwytxoXD8Jkzd4ZYdJ+taDDMuuqV6N4ZgJmA4F4rCdTLuOITIOYO8Af 2rkNu9djhUrXe1kvl6K9J8gBNF31WCfY+rbI7/Jc9ta/BPsajbrm9i++CGUw2eRhXcK2 wsraVM14LVykJfea6bTXI1wjnPh8QezaRlPVG3fdpLORv61r286EvqY8typkWAF9mdW2 AhhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708710139; x=1709314939; 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=L8CWGVS5oYo9Xv5uGh2hBH5hNaU6W6dhr1j9gGPoJgA=; b=XGk9TwnKXMtIKdmwqOjORldkRPV/sdmIMdC08wCaUG5iScXjVomA29Yiz4n0T4N2j8 THjvkcrY++jvSU5ilMs/yBswyg97lkCkOaoJds4Xepr5SUp+a2iF+ZGsi8CcGHqAIYIx Y24KmdONOCh0IK9QewOYc5ext0lnHWYlw0SlxTksUc2jT+oCTs/iIWCR9+ee4UOaY+WE Gcg0+sJykZa1CxRKD225JohaxlZnLk5FhQLZrDFg6q97UsaMdFD8LdmwrCggJyq1swla NsS68KfCUmnOrxxgegc5V6NcKNTsMx3853+JwyycERHMi9yB5h1S+qL8MdlM/ti4vViX oZ1g== X-Forwarded-Encrypted: i=1; AJvYcCXu4Ss9ITk0N5OwRD1ZhEmYOTTsllM0euGbfe/TfpWjdS50ImNpqFw7uiXpumupXjHfZ2tge+b/rbE6BC8cap4cuiYt2EeaBABzRHefrkU3NFMgaNaQx8/YHK3+pbDBQzc1FSxZFwcCjv/aS++MLlS2FQdh29mIjikc1VNyqUI3OkXPUwaDfL5ALyfMKv/96cx/Oan8p0RgiE9/kqlbfCBPIQ== X-Gm-Message-State: AOJu0Ywe1BbyZoyp0xoGmgdAihyCatjvkdPJSPb5xEsJoMxG4TUePvUb JPr0uKk9YxXuT1ylIn6Ek7yHjS9HtZnaqgtqfomyLiGwBZn5c0BD X-Google-Smtp-Source: AGHT+IG/VHQ1jNmu0cLyUQLA9RkXGmM2Ppsm4q2QQZNlq98UjD/KtYkojX68z3AVFpsTsHIFzGrr2w== X-Received: by 2002:a05:6870:6c13:b0:21f:c7a2:9198 with SMTP id na19-20020a0568706c1300b0021fc7a29198mr231043oab.13.1708710138780; Fri, 23 Feb 2024 09:42:18 -0800 (PST) Received: from localhost.localdomain (070-114-203-196.res.spectrum.com. [70.114.203.196]) by smtp.gmail.com with ESMTPSA id rb7-20020a056871618700b0021f6a2bd4b9sm1257803oab.3.2024.02.23.09.42.17 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 23 Feb 2024 09:42:18 -0800 (PST) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Jonathan Corbet , Dan Williams , Vishal Verma , Dave Jiang , Alexander Viro , Christian Brauner , Jan Kara , Matthew Wilcox , linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev Cc: John@Groves.net, john@jagalactic.com, Dave Chinner , Christoph Hellwig , dave.hansen@linux.intel.com, gregory.price@memverge.com, John Groves Subject: [RFC PATCH 01/20] famfs: Documentation Date: Fri, 23 Feb 2024 11:41:45 -0600 Message-Id: X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Introduce Documentation/filesystems/famfs.rst into the Documentation tree Signed-off-by: John Groves --- Documentation/filesystems/famfs.rst | 124 ++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 Documentation/filesystems/famfs.rst diff --git a/Documentation/filesystems/famfs.rst b/Documentation/filesystems/famfs.rst new file mode 100644 index 000000000000..c2cc50c10d03 --- /dev/null +++ b/Documentation/filesystems/famfs.rst @@ -0,0 +1,124 @@ +.. SPDX-License-Identifier: GPL-2.0 + +.. _famfs_index: + +================================================================== +famfs: The kernel component of the famfs shared memory file system +================================================================== + +- Copyright (C) 2024 Micron Technology, Inc. + +Introduction +============ +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 use data in shared memory, by giving it a file system +interface. With famfs, any app that understands files (which is all of +them, right?) can access data sets in shared memory. Although famfs +supports read and write calls, 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 kernel file system is part of the famfs framework; User space +components [1] handle metadata allocation and distribution, and direct the +famfs kernel module to instantiate files that map to specific 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 dax 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 +======================= + +Without its user space components, the famfs kernel module is just a +semi-functional clone of ramfs with latent fs-dax support. The user space +components maintain superblocks and metadata logs, and use the famfs kernel +component to provide a file system view of shared memory across multiple +hosts. + +Each host has an independent instance of the famfs kernel module. After +mount, files are not visible until the user space component instantiates +them (normally by playing the famfs metadata log). + +Once instantiated, files on each host can point to the same shared memory, +but in-memory metadata (inodes, etc.) is ephemeral on each host that has a +famfs instance mounted. Like ramfs, the famfs in-kernel file system has no +backing store for metadata modifications. If metadata is ever persisted, +that must be done by the user space components. However, mutations to file +data are saved to the shared memory - subject to write permission and +processor cache behavior. + + +Famfs is Not a Conventional File System +--------------------------------------- + +Famfs files can be accessed by conventional means, but there are +limitations. The kernel component of famfs is not involved in the +allocation of backing memory for files at all; the famfs user space +creates files and passes the allocation extent lists into the kernel via +the per-file FAMFSIOC_MAP_CREATE ioctl. A file that lacks this metadata is +treated as invalid by the famfs kernel module. As a practical matter files +must be created via the famfs library or cli, but they can be consumed as +if they were conventional files. + +Famfs differs in some important ways from conventional file systems: + +* Files must be pre-allocated by the famfs framework; Allocation is never + performed on 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 on top of +shared memory so applications and workflows can more easily consume it. + +Key Requirements +================ + +The primary requirements for famfs are: + +1. Must support a file system abstraction backed by sharable dax 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. + +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 and ext4) 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 +=========== + +Famfs usage is documented at [1]. + + +References +========== + +- [1] Famfs user space repository and documentation + https://github.com/cxl-micron-reskit/famfs From patchwork Fri Feb 23 17:41:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Groves X-Patchwork-Id: 13569759 Received: from mail-oi1-f181.google.com (mail-oi1-f181.google.com [209.85.167.181]) (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 9A302133995; Fri, 23 Feb 2024 17:42:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710146; cv=none; b=MRS8Tce995o0XDIrrD16FXTqFbEjo7BOkzRZ5XC2jZ/qBQ1mfTbfPFLGQrkYkPYb+QI2Sn2AIvtK9gHgNe4Avil73ZuvGA991Cv1BNk/UyxEOk92i6k9JM0nF4AW+R9QG9eGvhZwesA3ugiVx0s+8ukIy1KDg8LuSGE1iCq4jbQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710146; c=relaxed/simple; bh=CkgahHLrXAzsDc1GyliBXNYmxljQ1YjaPW98OF38fIM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rBYzj/NpSEssK5hD8C9Fu3ZcyWBILtc1cJQsOp2S5qXtNN3pIo00srv6k0OnqTLJUOdWye0kpPFtx7b90b9B9LvTQIwEy9BGzOhPf9WsLZRe5J48cZFmYbyurUxb9vbH0xGstEaS3apckQSVWknQ5SzIKYuvSGScMpSTYDgqwew= 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=nX7cIouw; arc=none smtp.client-ip=209.85.167.181 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="nX7cIouw" Received: by mail-oi1-f181.google.com with SMTP id 5614622812f47-3c18190000aso895616b6e.0; Fri, 23 Feb 2024 09:42:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708710144; x=1709314944; 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=nGMjiwg1uZ6Jr5mNemJ2ScloiGdJ6cdnQKQjOvidMjQ=; b=nX7cIouwONAXINeRyPtbbK/k6MwCuGp+ndudCxQ/CejLMO16YXbv0j2Kry6T06U1VO K6Rn7qbiWOGsYFoMWAct3xtYPBViDZaIkkpmJekD7wye2lcE5JxR691OXQBiUavIgS4B jlcEpYqTU1HdUYH0uUY+dXLbZG28Ik1qT6hRgUyMWO8/ASTOYH/HCQbnkS3+BL33WrcC FS8jVKJnVgQfG3iPtxRZl6C8YJ89F+nVIBZMPZzhMXzAsNlfnb7QvX/8FCNvdL7Ew0sF kAX5I5bLxO4rrc8yTLg2eOaGsDuNBLiTyGk8kIpbU7dQl8pMZZ2qT+dZ9wk1E5xQIRLW KB+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708710144; x=1709314944; 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=nGMjiwg1uZ6Jr5mNemJ2ScloiGdJ6cdnQKQjOvidMjQ=; b=gcgjWKH4CBEX6PQtpKufiQs1ORgAePdJmpXbvw1AstCOHbi+/unkOEsFYVYPyHwzzs 67ElrzK3ZWJMGUj0qVtc7WHJ87VwHgOqV3twpfP4a61jOhDMWvTNGblXAvXyD9HiyjHr aDjMDpFEPOYjRTmqhD7WL+TrhOEkVZGuGxi3fUjPjH6XLUgPeusshKzIcUrShlmeQqLD /woOpVxTjcnx5V4aBy1oTvIwOHjWmY1YG/85oDDwtV2VjpiSLy0dRCz0a0RoQUxjgJPM 1GHuD9Tci8jjx0kX/9MRtj8nd1TktsHofHGLYuAt7Kq0IIRdwLwHQXrYtwu4j3s1UgUM iceQ== X-Forwarded-Encrypted: i=1; AJvYcCUkSqwmcvO28rZtyh9z6nmgTmUs4ERcDL2vuS5SAHpHGvM3rZvdV19poIG0PR2uux15FAziUPm/r92tXMygd+rvrNwvkzqpitIil4HevYdA92urDXvrjf/tE1wWQvs1ndBuCU2SKMLsspAZVmfZ8bDbB/H6t5F4MwvwpbInhNJN/1OKWNjcCv3zdsAzxD8YqUaljPePZ7mtQ2qE9Ms/RugvGA== X-Gm-Message-State: AOJu0YwxP5hbCPZSbkT0y30hs/hUBG09YZDclisKgS+fX8awAXoSUo9w Qe68c730eFZnnUGjIsgITliQYsjH/NbGO6QMDEt/oWj6aCtXS/YN X-Google-Smtp-Source: AGHT+IGTh/vsL/iyfr1+O5xIszFoRGO1T0cqNt3QFKtOmtVkFPM3Pqvq3kpeRl0uX4riIRv1bk+bvQ== X-Received: by 2002:a05:6871:489:b0:21f:662:e01 with SMTP id f9-20020a056871048900b0021f06620e01mr481442oaj.56.1708710143576; Fri, 23 Feb 2024 09:42:23 -0800 (PST) Received: from localhost.localdomain (070-114-203-196.res.spectrum.com. [70.114.203.196]) by smtp.gmail.com with ESMTPSA id rb7-20020a056871618700b0021f6a2bd4b9sm1257803oab.3.2024.02.23.09.42.22 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 23 Feb 2024 09:42:23 -0800 (PST) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Jonathan Corbet , Dan Williams , Vishal Verma , Dave Jiang , Alexander Viro , Christian Brauner , Jan Kara , Matthew Wilcox , linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev Cc: John@Groves.net, john@jagalactic.com, Dave Chinner , Christoph Hellwig , dave.hansen@linux.intel.com, gregory.price@memverge.com, John Groves Subject: [RFC PATCH 02/20] dev_dax_iomap: Add fs_dax_get() func to prepare dax for fs-dax usage Date: Fri, 23 Feb 2024 11:41:46 -0600 Message-Id: <69ed4a3064bd9b48fd0593941038dd111fcfb8f3.1708709155.git.john@groves.net> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This function should be called by fs-dax file systems after opening the devdax device. This adds holder_operations. This function serves the same role as fs_dax_get_by_bdev(), which dax file systems call after opening the pmem block device. Signed-off-by: John Groves --- drivers/dax/super.c | 38 ++++++++++++++++++++++++++++++++++++++ include/linux/dax.h | 5 +++++ 2 files changed, 43 insertions(+) diff --git a/drivers/dax/super.c b/drivers/dax/super.c index f4b635526345..fc96362de237 100644 --- a/drivers/dax/super.c +++ b/drivers/dax/super.c @@ -121,6 +121,44 @@ void fs_put_dax(struct dax_device *dax_dev, void *holder) EXPORT_SYMBOL_GPL(fs_put_dax); #endif /* CONFIG_BLOCK && CONFIG_FS_DAX */ +#if IS_ENABLED(CONFIG_DEV_DAX_IOMAP) + +/** + * fs_dax_get() + * + * fs-dax file systems call this function to prepare to use a devdax device for fsdax. + * This is like fs_dax_get_by_bdev(), but the caller already has struct 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, -1 on failure + */ +int fs_dax_get( + struct dax_device *dax_dev, + void *holder, + const struct dax_holder_operations *hops) +{ + /* dax_dev->ops should have been populated by devm_create_dev_dax() */ + if (WARN_ON(!dax_dev->ops)) + return -1; + + if (!dax_dev || !dax_alive(dax_dev) || !igrab(&dax_dev->inode)) + return -1; + + if (cmpxchg(&dax_dev->holder_data, NULL, holder)) { + pr_warn("%s: holder_data already set\n", __func__); + return -1; + } + dax_dev->holder_ops = hops; + + return 0; +} +EXPORT_SYMBOL_GPL(fs_dax_get); +#endif /* DEV_DAX_IOMAP */ + enum dax_device_flags { /* !alive + rcu grace period == no new operations / mappings */ DAXDEV_ALIVE, diff --git a/include/linux/dax.h b/include/linux/dax.h index b463502b16e1..e973289bfde3 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -57,7 +57,12 @@ struct dax_holder_operations { #if IS_ENABLED(CONFIG_DAX) 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); +#endif void *dax_holder(struct dax_device *dax_dev); +struct dax_device *inode_dax(struct inode *inode); void put_dax(struct dax_device *dax_dev); void kill_dax(struct dax_device *dax_dev); void dax_write_cache(struct dax_device *dax_dev, bool wc); From patchwork Fri Feb 23 17:41:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Groves X-Patchwork-Id: 13569760 Received: from mail-oo1-f47.google.com (mail-oo1-f47.google.com [209.85.161.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 2157C13B79C; Fri, 23 Feb 2024 17:42:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710149; cv=none; b=iyfvBZeVKvLF3OtL1kfraY7BrNBSWI+C2vY4JoKQBMZ3FmVJJt8HSxTtww85UZuLleHYD33xKAQs6W3bvBwcAd13P4HMMvzHtqfgCLp+iI5r6falrbt56JPM8AZRGuUNtcnISVPRbsTDdVr489U6aDAHAVtB3rjcO5mw6g6RE+o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710149; c=relaxed/simple; bh=ZbfxtKf+CEH2wGLH6RSoWosZOiwKXV+zrcJLYgSF8z4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UEA71qbFr8XkMv+eJudeq2ZUS6E3nL59gK04iZ1WgSC9B+iq/EubzyozYpXjsxyGfLiD1ePt19LpYb/hWufF87yr4bPtMpZGCpu3RZR4JxiVWSbs5U8P27mpwRZUlvSER0Hf0m3nO5oC9AJtaAK6JOlj88kiJxAabnFCMW64Hv0= 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=JNXRp9Tu; arc=none smtp.client-ip=209.85.161.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="JNXRp9Tu" Received: by mail-oo1-f47.google.com with SMTP id 006d021491bc7-5a054dfee60so104007eaf.0; Fri, 23 Feb 2024 09:42:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708710146; x=1709314946; 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=Ysyvhoe9WrIZCAbrcazj2rYc9hMFHO2LJz+Ed7fxvok=; b=JNXRp9TuTBXuGqd+mbQ47m3Dt32jh312w1lODbdhyhrTNl37wiHO8j7i29Jby2PvF2 0jWpybYMcdCk8V/j2Sqh93pYQkRq9EgZzyuF3n7NsSzfwdzWGA7kvaGHtD/tNPxiMXQ5 aZ3Vyr7usIUIisLTL1lHVhBInL3ChMUqoggI1yiq16KkLze+p9poC+CZ9VetJZVi9TfD G+X+C4msXeaI0JL+ih2A03bYLyMq0MwNzGaO13Fp/uX8PsQwUr6YiO++/RtY1Q6CCpvc 9uqheIz7sx/jp3WxjdiBqxVzzQ3XscxNU1NHkLDVAGnrRtnxGh6BYnalxr0pRVC7rQh+ iUMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708710146; x=1709314946; 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=Ysyvhoe9WrIZCAbrcazj2rYc9hMFHO2LJz+Ed7fxvok=; b=JXUcaIRK0p6CqmFWvpEJNQfx51S8uEcWANR6u9huAn3jGey5FcSKuf/mXZ+GgCv+Dm sbOWe4SpWTIumI/EZV9KUC0HO9Zc6HFTZ9aVH1sIOAhRMGMfT7qY7k4/frmMrYOCfx1g ZJ+N9oqSTj+yN+ybpFy5dovfCDZWHCi1tzm65a56mCuptDEmsTcW+MkBpA/pqH4CP+ny WeTIDLHguuwn4eA56H4Iwe6uWtnE5zfJZLj+y2cz02FQTyGQoWtK2jw4LAdNe6/3T5Kv 6NhTd33wSRczoE9G1yL3QpL/wgtkme7Y9DvEAYHc4nP22BSIAI3encqZfS7PF9xdhEfE qxLQ== X-Forwarded-Encrypted: i=1; AJvYcCVeEJJMlk13KsB5LwXKnDVRa1irr0uL3SXRHF0lKkzaTXiA19hS5TuGE3aoUTtckLMq/PeWqNrJluwfm0EoXdff1BNZ3m1iNATlgTkMgP/tHUqYpwrjIHzn7MQ0wFQ87ksPmiTlxfMd+9ATjW99iGoueVzT/Cu1lK6Wcd/HhLwCa+yjX3ZLxJygK3S8Yoe4CrlprzR6idlws0vn+s9AmCKLIA== X-Gm-Message-State: AOJu0YxDdx5/NSX33PjBV5wH0pw2TWllmEjTA8Q5N/izBQOdRt68ASnZ NDHMxZydfsgqzhc8pygKgXBX2Hb6VlMkeLhEkqn+urK6bPYWjZ8N X-Google-Smtp-Source: AGHT+IG/GUeqabU8ZjvZRSRCOteowuLlcjS4ESz2/EbniniNL6YMrlAifUs32d0i0+teK0sbm9sTzw== X-Received: by 2002:a05:6870:9108:b0:21f:c734:5b56 with SMTP id o8-20020a056870910800b0021fc7345b56mr99136oae.4.1708710146231; Fri, 23 Feb 2024 09:42:26 -0800 (PST) Received: from localhost.localdomain (070-114-203-196.res.spectrum.com. [70.114.203.196]) by smtp.gmail.com with ESMTPSA id rb7-20020a056871618700b0021f6a2bd4b9sm1257803oab.3.2024.02.23.09.42.24 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 23 Feb 2024 09:42:26 -0800 (PST) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Jonathan Corbet , Dan Williams , Vishal Verma , Dave Jiang , Alexander Viro , Christian Brauner , Jan Kara , Matthew Wilcox , linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev Cc: John@Groves.net, john@jagalactic.com, Dave Chinner , Christoph Hellwig , dave.hansen@linux.intel.com, gregory.price@memverge.com, John Groves Subject: [RFC PATCH 03/20] dev_dax_iomap: Move dax_pgoff_to_phys from device.c to bus.c since both need it now Date: Fri, 23 Feb 2024 11:41:47 -0600 Message-Id: <8d062903cded81cba05cc703f61160a0edb4578a.1708709155.git.john@groves.net> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 bus.c can't call functions in device.c - that creates a circular linkage dependency. 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 1ff1ab5fa105..664e8c1b9930 100644 --- a/drivers/dax/bus.c +++ b/drivers/dax/bus.c @@ -1325,6 +1325,30 @@ static const struct device_type dev_dax_type = { .groups = dax_attribute_groups, }; +/* 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 pgoff, + unsigned long size) +{ + int i; + + for (i = 0; i < dev_dax->nr_range; i++) { + struct dev_dax_range *dax_range = &dev_dax->ranges[i]; + struct range *range = &dax_range->range; + unsigned long long pgoff_end; + phys_addr_t phys; + + pgoff_end = dax_range->pgoff + PHYS_PFN(range_len(range)) - 1; + if (pgoff < dax_range->pgoff || pgoff > pgoff_end) + continue; + phys = PFN_PHYS(pgoff - dax_range->pgoff) + range->start; + if (phys + size - 1 <= range->end) + return phys; + break; + } + return -1; +} +EXPORT_SYMBOL_GPL(dax_pgoff_to_phys); + struct dev_dax *devm_create_dev_dax(struct dev_dax_data *data) { struct dax_region *dax_region = data->dax_region; diff --git a/drivers/dax/device.c b/drivers/dax/device.c index 93ebedc5ec8c..40ba660013cf 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; } -/* 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 pgoff, - unsigned long size) -{ - int i; - - for (i = 0; i < dev_dax->nr_range; i++) { - struct dev_dax_range *dax_range = &dev_dax->ranges[i]; - struct range *range = &dax_range->range; - unsigned long long pgoff_end; - phys_addr_t phys; - - pgoff_end = dax_range->pgoff + PHYS_PFN(range_len(range)) - 1; - if (pgoff < dax_range->pgoff || pgoff > pgoff_end) - continue; - phys = PFN_PHYS(pgoff - dax_range->pgoff) + range->start; - if (phys + size - 1 <= range->end) - return phys; - break; - } - return -1; -} - static void dax_set_mapping(struct vm_fault *vmf, pfn_t pfn, unsigned long fault_size) { From patchwork Fri Feb 23 17:41:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Groves X-Patchwork-Id: 13569761 Received: from mail-oi1-f174.google.com (mail-oi1-f174.google.com [209.85.167.174]) (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 13C0913DB80; Fri, 23 Feb 2024 17:42:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710151; cv=none; b=ktyFXpHQz3OIhA5Fybgk8rbQk/MvJ6PKamw0vDECbR2HEN5oTB4xd7+t/R7Jbqx0EwUQ65oSUAKtuJs9LkzlfoikJtnzSWxj4ZuRH6APbH7msns15RK1yC94DjSH8Jp48V76c+vhCg3nNakw7YsGw5VDoU6sF2cj+gOEkUceMhk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710151; c=relaxed/simple; bh=P4ycxMH1eLEp2A0+12tkQr5yDXMbhNTfR+V2FQ6zQjk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PxAHFRN+cnNiH/juv6JWeZuuKuPUW/SoeJu2Km2cKnkdqmN5h9rJ9YboA+ne6hRHaczYka8snGUPtQ4P8GEkM4WlgFdFE432kweYP5fu2UPz+5AjDswv3k25DoUcvOZ0BGIcL8KsrnQe8PTYMoE7Gguk4NQcufo8x7GuNt/4Lvk= 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=LQeoMEGg; arc=none smtp.client-ip=209.85.167.174 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="LQeoMEGg" Received: by mail-oi1-f174.google.com with SMTP id 5614622812f47-3c1884c33a9so539239b6e.2; Fri, 23 Feb 2024 09:42:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708710149; x=1709314949; 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=WJnJfeFGNikf7Cy1KZrMQXeMgUfPXb1BZJ051HZbDR4=; b=LQeoMEGgb9p8zmhnwOO6OakNA9uYcrRtHsF5WqvxYWpaFyumKrkY1iHc7OWvxGxsxH QFvLi0Sv+btRq0e5AETowRPHl0z/RL4aYiLSMbGP0pP7XjAvs7KD4D8l8QkWuYodXxn4 15UCXuGg3/d8rTcfJezaOhbmV6pdSHP2MON3j3TSuJpr7vH0N1CO3QFE4DveIOwmN3Mq PEX7R6LMf3Oi+LaF/RRiL5+pru2I/WL6GLObyPAlRGXE6vqvNlz7/3KQTOYd//44pXBK 0ofDPLpe5IQ228yd6pCskn7cjoCKe1Z0WAP+Itc49Q4L6FHyR5C/HnCtM/WugnM2yewM fYqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708710149; x=1709314949; 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=WJnJfeFGNikf7Cy1KZrMQXeMgUfPXb1BZJ051HZbDR4=; b=HGIj4wPnB0CJLp6zItl6V8xGOabhIz6crcCfoE/SJdxqL8S9tD4o+suT7N/zUSO0w3 /Dri9hgVgUBkAJ2QWCpZjwwKu6282kkn/XcCe/RQsUXqRZMgrqx3dHcqb8OijDYWNJGc 7VS+ND3ffoB0Ekt2AtDaUNDRuSoa/DruIJisdLbsLmtM010VnbIhAF1Msyeso/Xst8sM rPCTpwT/4i0q4DsDZxtemKZDNDPpcUVrV9qKjnEcgwhiB+MunJdiw86cNz0lu5bl2CQC A/e0GcPHEev79maaW9vJ/7nyFQXHsawPDq+dbKYVn+mc3MNuSvFhv8ew0SFaSjv2iDLV znng== X-Forwarded-Encrypted: i=1; AJvYcCUYg7gg7eZmo7XY8IGXbSsFwMqq3xHDdrZwpYiNpoRoJi7qoLrivm5H/69Nht/2AAZ6HEBp7HzxSKy3jBG6D81FDsDy3m4ygQKiJSJMj1McmV+1zdp7ma2/WAggcbeLD5eBxxws6vuh70Ra+6u4mRIpO4oogflGNNrFz3+2Jj/898XhtQOaKxhBhHjZBlWvMEavjYCBW73nr8cTSBkKjvLoFQ== X-Gm-Message-State: AOJu0YwW8zhwF8ChZjb7h8vpPVf38CnP33gbUy4OoafEz8N5lhHCPHgr hjHB9pTLhezyjlp+1EhKSuD7ycJr7oXs344wCV4sTMOZhfD3PQG0 X-Google-Smtp-Source: AGHT+IEIopUj6ImsBlvAoK0O/1OKc+IpoiZFvcZvRep/2o4LSk5XrwSkmZ5t0MNRVaK6kXRmK59Fsw== X-Received: by 2002:a05:6870:64a6:b0:21e:8c19:f716 with SMTP id cz38-20020a05687064a600b0021e8c19f716mr516277oab.49.1708710149191; Fri, 23 Feb 2024 09:42:29 -0800 (PST) Received: from localhost.localdomain (070-114-203-196.res.spectrum.com. [70.114.203.196]) by smtp.gmail.com with ESMTPSA id rb7-20020a056871618700b0021f6a2bd4b9sm1257803oab.3.2024.02.23.09.42.27 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 23 Feb 2024 09:42:28 -0800 (PST) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Jonathan Corbet , Dan Williams , Vishal Verma , Dave Jiang , Alexander Viro , Christian Brauner , Jan Kara , Matthew Wilcox , linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev Cc: John@Groves.net, john@jagalactic.com, Dave Chinner , Christoph Hellwig , dave.hansen@linux.intel.com, gregory.price@memverge.com, John Groves Subject: [RFC PATCH 04/20] dev_dax_iomap: Save the kva from memremap Date: Fri, 23 Feb 2024 11:41:48 -0600 Message-Id: <66620f69fa3f3664d955649eba7da63fdf8d65ad.1708709155.git.john@groves.net> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 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. Dragons... 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 446617b73aea..894eb1c66b4a 100644 --- a/drivers/dax/dax-private.h +++ b/drivers/dax/dax-private.h @@ -63,6 +63,7 @@ struct dax_mapping { struct dev_dax { struct dax_region *region; struct dax_device *dax_dev; + u64 virt_addr; unsigned int align; int target_node; bool dyn_id; diff --git a/drivers/dax/device.c b/drivers/dax/device.c index 40ba660013cf..6cd79d00fe1b 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 = dev_dax->dax_dev; struct device *dev = &dev_dax->dev; struct dev_pagemap *pgmap; + u64 data_offset = 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); + /* Detect whether the data is at a non-zero offset into the memory */ + if (pgmap->range.start != dev_dax->ranges[0].range.start) { + u64 phys = (u64)dev_dax->ranges[0].range.start; + u64 pgmap_phys = (u64)dev_dax->pgmap[0].range.start; + u64 vmemmap_shift = (u64)dev_dax->pgmap[0].vmemmap_shift; + + if (!WARN_ON(pgmap_phys > phys)) + data_offset = phys - pgmap_phys; + + pr_notice("%s: offset detected phys=%llx pgmap_phys=%llx offset=%llx shift=%llx\n", + __func__, phys, pgmap_phys, data_offset, vmemmap_shift); + } + dev_dax->virt_addr = (u64)addr + data_offset; + inode = dax_inode(dax_dev); cdev = inode->i_cdev; cdev_init(cdev, &dax_fops); From patchwork Fri Feb 23 17:41:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Groves X-Patchwork-Id: 13569762 Received: from mail-oa1-f48.google.com (mail-oa1-f48.google.com [209.85.160.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 0174C13EFEB; Fri, 23 Feb 2024 17:42:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710154; cv=none; b=bxmguQg/1Kpyf3LAXbcZcWc/CInhn3lKd/C480zZQzQ0UwxziKIAQvICFWAUNcvawmc0ukm/xvWOt7re9CoW6gGoI0E7IuLGAf3gt8HxR7jZ5blXA7YLJC/FeOXY1YPuG8G9WtJuokU4K+73+JKy6PO8RnufHmb/+tAvsWtJca4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710154; c=relaxed/simple; bh=ONsam/yo/NB0rVpRcPxD7RtX2OC7QDpgecXyPCxVYcI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pdhiTKmP/Q7FAME+mTA9wGIlB27jH1FHjdiTm4Ab+fbh/KkVzGoRnda+NgTAv7ORW1atg66LWhIKm3GjY4pkh+RM4cEUXiPzYE8xmhBdFTIs1OnnWMDP60+BeFtO4hcQPsisw2yEIQnC9U5pFhs8jrDJkVJkg2GZ5WABBpRFRFY= 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=bRcfj1xF; arc=none smtp.client-ip=209.85.160.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="bRcfj1xF" Received: by mail-oa1-f48.google.com with SMTP id 586e51a60fabf-21f8665908bso538164fac.3; Fri, 23 Feb 2024 09:42:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708710152; x=1709314952; 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=Y+SPGnsXaoNSfbfuHnl0d9x2mOvuVC4g7NKkHxsyha0=; b=bRcfj1xFnVXHMgKI/6QVU3iZJqZyGE2ezlQlcZXuABP01z0RXN8NWzW3peZVe60uTH KWztEqkUj0LgaD14so7ko0BtSCdKUX+jQIiMPIt+fe3eLhmnxcA/rvIbDf1w45m3nlbm Zq1sbXmUb3eCgfQErPyQHNe4paXghI9vDvIrGw6aYIgUI5xFdL19doTeHzCQrUqSsa6q RheradwFQXn0u2GfJR1VeKZcvZZo+hhNWa+UNssbajXLXcbweD3Wtn1qHtZl3NagIW7B hKOi7NPMWK45k1EiFPf2TceoRw/GGdjBp8Kd15wFCz6ToytwDxEJjw2LgEp/do6kbiPe EJWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708710152; x=1709314952; 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=Y+SPGnsXaoNSfbfuHnl0d9x2mOvuVC4g7NKkHxsyha0=; b=OoS42P6TncsLCurteAvRKm/n2PibpjCR5hih70q29s5BSY6GFVqhJb4lR86ExBywUA qv3kyIfTESoA1GJBD31yqzaEuT908ObfntCNGqGxFmd9A5nt4sRHOlFFL36fWtaEzrpk k6mViX0y7WVBO5pVNGbZy5X95Uyj3GFDDGMSPXeKD63i2u6U1O96XwcttswTAYM6c76l /NqFbMJoxVaHGxqp6YOdtmIrK82Ppe3Z8mv5Mep+6tH8B/iy7S7ANIN1BhpufPNxw3nF E1BPm1M4xNco9vD3vTUeWWzsVbACID423bQGQu6l65KPbs4JqysYZ6AQdJ0pY+za5mzA hFxw== X-Forwarded-Encrypted: i=1; AJvYcCWzMnwf/RHx5p+RyTheMNifgRZLlGr8keKBUm9Rcba7FoH3/2J4teqgj/uKyv/NXPibmTfMp/7zFn1p0Zvu0uxK0BnwKLXcfUzsnf0jSFseNWdfLtzNGIjoDoGeUAO/2zZ4lPIVrWBfJUo/s5Z462GtBRO6SW6XVNrdJpLwed9uAvKaAIqLKBvaKcZbJZFd/QkyaFXWQuBGvO4q2s6rSPubiA== X-Gm-Message-State: AOJu0YxCFaIXDmzsStxkE/ctqh6pBsFGc+qRPCjJTU3OvW30bJQklQ/B p8XQHkg4t4iCkozysb6Ld/8oenzRKD8x4j2kJc4D2+ttUX9l21exXlOfzvXI2Fg= X-Google-Smtp-Source: AGHT+IHo7d1kSgOminRJoAgE7SvJGJsPx2WRzRdQZTC6zITUaEqf+Edvz9EYo78fq+2qihcwbDC9aQ== X-Received: by 2002:a05:6870:9691:b0:21f:aad7:686c with SMTP id o17-20020a056870969100b0021faad7686cmr544319oaq.35.1708710152018; Fri, 23 Feb 2024 09:42:32 -0800 (PST) Received: from localhost.localdomain (070-114-203-196.res.spectrum.com. [70.114.203.196]) by smtp.gmail.com with ESMTPSA id rb7-20020a056871618700b0021f6a2bd4b9sm1257803oab.3.2024.02.23.09.42.30 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 23 Feb 2024 09:42:31 -0800 (PST) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Jonathan Corbet , Dan Williams , Vishal Verma , Dave Jiang , Alexander Viro , Christian Brauner , Jan Kara , Matthew Wilcox , linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev Cc: John@Groves.net, john@jagalactic.com, Dave Chinner , Christoph Hellwig , dave.hansen@linux.intel.com, gregory.price@memverge.com, John Groves Subject: [RFC PATCH 05/20] dev_dax_iomap: Add dax_operations for use by fs-dax on devdax Date: Fri, 23 Feb 2024 11:41:49 -0600 Message-Id: <5727b1be956278e3a6c4cf7b728ee4f8f037ae51.1708709155.git.john@groves.net> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Notes about this commit: * These methods are based somewhat loosely 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 | 107 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c index 664e8c1b9930..06fcda810674 100644 --- a/drivers/dax/bus.c +++ b/drivers/dax/bus.c @@ -10,6 +10,12 @@ #include "dax-private.h" #include "bus.h" +#if IS_ENABLED(CONFIG_DEV_DAX_IOMAP) +#include +#include +#include +#endif + static DEFINE_MUTEX(dax_bus_lock); #define DAX_NAME_LEN 30 @@ -1349,6 +1355,101 @@ __weak phys_addr_t dax_pgoff_to_phys(struct dev_dax *dev_dax, pgoff_t pgoff, } EXPORT_SYMBOL_GPL(dax_pgoff_to_phys); +#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 = kmap_local_page(page); + chunk = min_t(unsigned int, len, PAGE_SIZE - off); + memcpy_flushcache(pmem_addr, mem + off, chunk); + kunmap_local(mem); + len -= chunk; + off = 0; + page++; + pmem_addr += chunk; + } +} + +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) +{ + struct dev_dax *dev_dax = dax_get_private(dax_dev); + size_t dax_size = dev_dax_size(dev_dax); + size_t size = nr_pages << PAGE_SHIFT; + size_t offset = pgoff << PAGE_SHIFT; + phys_addr_t phys; + u64 virt_addr = dev_dax->virt_addr + offset; + pfn_t local_pfn; + u64 flags = PFN_DEV|PFN_MAP; + + WARN_ON(!dev_dax->virt_addr); /* virt_addr must be saved for direct_access */ + + phys = dax_pgoff_to_phys(dev_dax, pgoff, nr_pages << PAGE_SHIFT); + + if (kaddr) + *kaddr = (void *)virt_addr; + + local_pfn = phys_to_pfn_t(phys, flags); /* are flags correct? */ + if (pfn) + *pfn = 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 pgoff, + size_t nr_pages) +{ + long resid = nr_pages << PAGE_SHIFT; + long offset = pgoff << PAGE_SHIFT; + + /* Break into one write per dax region */ + while (resid > 0) { + void *kaddr; + pgoff_t poff = offset >> PAGE_SHIFT; + long len = __dev_dax_direct_access(dax_dev, poff, + nr_pages, DAX_ACCESS, &kaddr, NULL); + len = min_t(long, len, PAGE_SIZE); + write_dax(kaddr, ZERO_PAGE(0), offset, len); + + offset += len; + resid -= 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 pgoff, + void *addr, size_t bytes, struct iov_iter *i) +{ + size_t len, off; + + off = offset_in_page(addr); + len = PFN_PHYS(PFN_UP(off + bytes)); + + return _copy_from_iter_flushcache(addr, bytes, i); +} + +static const struct dax_operations dev_dax_ops = { + .direct_access = dev_dax_direct_access, + .zero_page_range = dev_dax_zero_page_range, + .recovery_write = dev_dax_recovery_write, +}; + +#endif /* IS_ENABLED(CONFIG_DEV_DAX_IOMAP) */ + struct dev_dax *devm_create_dev_dax(struct dev_dax_data *data) { struct dax_region *dax_region = data->dax_region; @@ -1404,11 +1505,17 @@ struct dev_dax *devm_create_dev_dax(struct dev_dax_data *data) } } +#if IS_ENABLED(CONFIG_DEV_DAX_IOMAP) + /* holder_ops currently populated separately in a slightly hacky way */ + dax_dev = 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 = alloc_dax(dev_dax, NULL); +#endif + if (IS_ERR(dax_dev)) { rc = PTR_ERR(dax_dev); goto err_alloc_dax; From patchwork Fri Feb 23 17:41:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Groves X-Patchwork-Id: 13569763 Received: from mail-oa1-f47.google.com (mail-oa1-f47.google.com [209.85.160.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 932BB13F010; Fri, 23 Feb 2024 17:42:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710158; cv=none; b=ockawiUsHzHbR6OC5qo12ojYc19VfvryNrfwFEz9Kd2tP8hYbmDB/2M+uJLOIjM7nCqa/YEsL2Fb3IESDxCJX6Ux++Gz0c86WzQfxBORlm9nTcz9RlLQwOYGTSg8xgcoTd9kvUjNsyA8Xn2NjNNwBOiIf6Pwjb6R2VGa8X2wlIc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710158; c=relaxed/simple; bh=B2obSwDEVHBkcnZehtnKyWZ0YBP4Jo3Z+lXXRsHPDaw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EfHJCh+lwPXeMVgwTwbH4PDXba15aklG1SO2zWgL6KruxGsC1Jl85m6x6TIXeaRIhxp8D+sXJyuDuGLT+midrmTagKnqpdOox0/r+B+JX/q2s8oDpJXVXiIk3EFwMeOR1mFcSWEe6vq0kwWtpoNfvkmEDNQajrUngo2LJBznHc0= 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=eUxcLdcb; arc=none smtp.client-ip=209.85.160.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=Groves.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eUxcLdcb" Received: by mail-oa1-f47.google.com with SMTP id 586e51a60fabf-204235d0913so761133fac.1; Fri, 23 Feb 2024 09:42:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708710154; x=1709314954; 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=aFTut3+4qkGhS8AYHqbTNfHoA7qF2QMx6EtGEpLVCik=; b=eUxcLdcbAegkQyfGlz1MY8amd3BF5iXItKpIK4QAJROOvCCRmvpaab9mhd2mBGKrTd r3sdqZLz9rSiel3kYzYRW17rBzS1FQ2OaTJOpCrmnuLPj0crUbVjMi1J1tJo5TXWj+EH uaAIBGCuaAcE9G+dBebjZHn3SR7wxUTUOtQ2lLOAPtRh+26ixRoezc3gXBvt9/e/EGBU uOK3nDzHqVGbK9P+q5+ICC91/UrX5iZs61M05DIVeDDiz1XhxFkprHONOsNs+naI+nqo y4k0NtsFdcZB/iz8asCrTbDzCELR1lh6Uv4VWYQuURMf2byUnTaLhJDJVPyQnYFJy72E 7V/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708710154; x=1709314954; 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=aFTut3+4qkGhS8AYHqbTNfHoA7qF2QMx6EtGEpLVCik=; b=eF334JAaMimfrFteYOTlseO6cu4XkUYcRmk9HENcGRYV10vluOeYJ7xJFvuXlZ8xuj 18E5x8rnbK6H3ewRPLLDJRUyjamyMRgBpvmuNH69SGJSyc27GudHnnQmO1UcILV832Q8 ZDqQRm5sslA3h5NzcZ+w0vbJpOe/n2aiKXilVxd8E8ZmUKZXtvWR9CVh9+5qyk95mFcm n15nsbxcKfOOHqYFrNeQDhVROhLzO/ZchDbAqIe9fxHuw4SM5o3Aj3iWSch2xQeujS+9 7aXhNp2c4JV27ZIf8E9UmgwDEE5g1k/rH5rIOQD3oHyEhzFztFcTT3PSHGADcGGJvGkv vGew== X-Forwarded-Encrypted: i=1; AJvYcCVY1U5MI0knWJRBoL7ghjBiuaNLfqRFD7Vh/5kc0KkgJJG/buHgMRrG5eImBWCnPZexyGoFN0guNpX4PbKnHz6P/Yy3+Qkc6mY9mtkGSsKoHSj+pmKXyc5my97OaQTwxk6tYycmoT40HyK/ygacVMhlE7ngFyYsRGAGMS1LxJCiOxO0Ml/4ZnKXP3QOcuDRN0/lZ6F+1+0oy6Tom4ja1KNkzw== X-Gm-Message-State: AOJu0Yy21zHEeFq2iv5KrkLPgpoq1d/ng0bD1kfez4YlKHj31jfCetrH GvvTx/tfuD9/rxQMwVbQTP+y1WX9Isgv51kcTKBAHUwUAZfHMS94 X-Google-Smtp-Source: AGHT+IHKTLvZO2eArKSdPtAv4KEnKXuwuYYaVhAXebKDRq6B4BATf8gx4jBDt1zV4RE8roWGKtQyow== X-Received: by 2002:a05:6870:f6a1:b0:21e:9b99:53d8 with SMTP id el33-20020a056870f6a100b0021e9b9953d8mr561935oab.22.1708710154758; Fri, 23 Feb 2024 09:42:34 -0800 (PST) Received: from localhost.localdomain (070-114-203-196.res.spectrum.com. [70.114.203.196]) by smtp.gmail.com with ESMTPSA id rb7-20020a056871618700b0021f6a2bd4b9sm1257803oab.3.2024.02.23.09.42.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 23 Feb 2024 09:42:34 -0800 (PST) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Jonathan Corbet , Dan Williams , Vishal Verma , Dave Jiang , Alexander Viro , Christian Brauner , Jan Kara , Matthew Wilcox , linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev Cc: John@Groves.net, john@jagalactic.com, Dave Chinner , Christoph Hellwig , dave.hansen@linux.intel.com, gregory.price@memverge.com, John Groves Subject: [RFC PATCH 06/20] dev_dax_iomap: Add CONFIG_DEV_DAX_IOMAP kernel build parameter Date: Fri, 23 Feb 2024 11:41:50 -0600 Message-Id: <13365680ad42ba718c36b90165c56c3db43e8fdf.1708709155.git.john@groves.net> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add the CONFIG_DEV_DAX_IOMAP kernel config parameter to control building of the iomap functionality to support fsdax on devdax. Signed-off-by: John Groves --- drivers/dax/Kconfig | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/dax/Kconfig b/drivers/dax/Kconfig index a88744244149..b1ebcc77120b 100644 --- a/drivers/dax/Kconfig +++ b/drivers/dax/Kconfig @@ -78,4 +78,10 @@ config DEV_DAX_KMEM Say N if unsure. +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 From patchwork Fri Feb 23 17:41:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Groves X-Patchwork-Id: 13569764 Received: from mail-oi1-f173.google.com (mail-oi1-f173.google.com [209.85.167.173]) (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 169D8134CCA; Fri, 23 Feb 2024 17:42:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710159; cv=none; b=uuD9fOXe8U8rn4GZZ1CCk+JjFdXaJVYO1XlPTaqI6lurNwElI0l90GT/nVse+1/qGAl7yweDO7WGDiaXcacee9iN8rXltHMMtKRwMkpcNB1qXluwbeg7kINTCuDFcO3bKBfEA/RQAUU8MtfjFfR13Ph3h6oJr2k33qCOK1rmH+8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710159; c=relaxed/simple; bh=k/M1Z1IjBAm6hPnaoO3KF5w8PO6H65N7SDu9f4q8Yyw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lCaKxVBLXRZOhc8vQ7Jg1j3ouSkhvS/680WIWg9uZyo+d2gzcf9j+GhTbybttf12t4yHfAPvkGZcdD8GIOB11RSAbr08rBevDR/ajVmaaorDLn+JZYi4iT3sETU/skL/dydTCs2hrt6ElVU/tOog6lKDj3iiHlZdPxik8SH9lRk= 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=mlkukNzF; arc=none smtp.client-ip=209.85.167.173 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="mlkukNzF" Received: by mail-oi1-f173.google.com with SMTP id 5614622812f47-3c0485fc8b8so732687b6e.3; Fri, 23 Feb 2024 09:42:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708710157; x=1709314957; 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=Z8B3WSC/oB5J5WuE4nqPN1CLkkErOjaE3oAAMcrX2mc=; b=mlkukNzFe37zJH1XsixpIgC0kTccfUOxicNqp8cmIYl8L3iy6hGvTCFElisTmkGf1X Lt3WfzDg18giGJUKeO+i7spfFcl82v8Hu1FAms1D1DRGHNd2G4osS3WiVC6pqG+1G8C7 sppSiRBkFurrJHgJy52tYpU/Jq51pbmO6Qf+Sdy0TMpYGxBPCWZ+t9JMhy0qDUkF4ysY dIveZXgGgeuQ1mnUXwqCMloUbm1Ki0hhiUFc+KRPAtm2dKNfT/FfEtPqP4NwKgxsXc0R hLnX9XvpDDQxZ0erQ6ZLAR/ehIqhgWXsFCKnIwLb9pORs+zXf9hRLUYJfmbTdbMU+pug BVOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708710157; x=1709314957; 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=Z8B3WSC/oB5J5WuE4nqPN1CLkkErOjaE3oAAMcrX2mc=; b=p0topPIHt7Sgzo78B++IB/Jk72JT9062BVBgzY5+i1Dx78989mQstKqaN0ZvdoiWyc JkZ5OTymNp2jdSoxfS6nYjlQ1OAbAr+D4qnBohUP+kli3yvU6OmDZjLXofyQPv8VHeNa CsdF7x4nY/CgsZtjiS4whclAx+IFVp/AF9I0Lkd6MPzokcwVclo5Y9ThnxeBkPI9ScAW dLhCDuarR62hfOu4+9IfQJkRt33sCfRcaZ4GeZBxlLXnF651aVoexhjLsfzu8Bt7pUOi I1mxyQXB3kkq+d5u2FCCnXlg56Un4cpRNwi3ii4vjzLRMgDNwq59SM078PvwtcRaDAy8 re6w== X-Forwarded-Encrypted: i=1; AJvYcCUn/vyOB3KxzMfW7Kc2wDWE0moRRNhHnEnHvF9yS+1f4zLZNAYNM2tzwLFp3KUV4Z1opCWKgb0a0xq40Ia/OPH8Dqsjf/92nLUhLtqNK+XG7HHQd5TDm5gy74rjcOkl+a8CsUu0KySD6+llZQiEYFJzdDfDtOf+j1jv0rXTi3yS4pWJn5COPL6t4Fdw4F/aJN7dFrzQ8T1dXpn4D3fH9YyGLA== X-Gm-Message-State: AOJu0Yx8o+FnLooIMGAMIgvtFf0pU6UakOE9mX4Iip8mb85MGUP5aXNO CcnZLM/7cPSkhXhd2QuT+9uumEvNToJQOtPCMmx4so7XVXPElTSt X-Google-Smtp-Source: AGHT+IEj8V1jRM+L2D+9halnV4FZjeOEtT0OxuoIXcJr1ybp9rMmGgfQ+zJi9Q54i2o5gJWGfNSg3w== X-Received: by 2002:a05:6871:7805:b0:21e:8cdb:1030 with SMTP id oy5-20020a056871780500b0021e8cdb1030mr638921oac.24.1708710157291; Fri, 23 Feb 2024 09:42:37 -0800 (PST) Received: from localhost.localdomain (070-114-203-196.res.spectrum.com. [70.114.203.196]) by smtp.gmail.com with ESMTPSA id rb7-20020a056871618700b0021f6a2bd4b9sm1257803oab.3.2024.02.23.09.42.35 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 23 Feb 2024 09:42:37 -0800 (PST) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Jonathan Corbet , Dan Williams , Vishal Verma , Dave Jiang , Alexander Viro , Christian Brauner , Jan Kara , Matthew Wilcox , linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev Cc: John@Groves.net, john@jagalactic.com, Dave Chinner , Christoph Hellwig , dave.hansen@linux.intel.com, gregory.price@memverge.com, John Groves Subject: [RFC PATCH 07/20] famfs: Add include/linux/famfs_ioctl.h Date: Fri, 23 Feb 2024 11:41:51 -0600 Message-Id: X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add uapi include file for famfs. The famfs user space uses ioctl on individual files to pass in mapping information and file size. This would be hard to do via sysfs or other means, since it's file-specific. Signed-off-by: John Groves --- include/uapi/linux/famfs_ioctl.h | 56 ++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 include/uapi/linux/famfs_ioctl.h diff --git a/include/uapi/linux/famfs_ioctl.h b/include/uapi/linux/famfs_ioctl.h new file mode 100644 index 000000000000..6b3e6452d02f --- /dev/null +++ b/include/uapi/linux/famfs_ioctl.h @@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * famfs - dax file system for shared fabric-attached memory + * + * Copyright 2023-2024 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. + */ +#ifndef FAMFS_IOCTL_H +#define FAMFS_IOCTL_H + +#include +#include + +#define FAMFS_MAX_EXTENTS 2 + +enum extent_type { + SIMPLE_DAX_EXTENT = 13, + INVALID_EXTENT_TYPE, +}; + +struct famfs_extent { + __u64 offset; + __u64 len; +}; + +enum famfs_file_type { + FAMFS_REG, + FAMFS_SUPERBLOCK, + FAMFS_LOG, +}; + +/** + * struct famfs_ioc_map + * + * This is the metadata that indicates where the memory is for a famfs file + */ +struct famfs_ioc_map { + enum extent_type extent_type; + enum famfs_file_type file_type; + __u64 file_size; + __u64 ext_list_count; + struct famfs_extent ext_list[FAMFS_MAX_EXTENTS]; +}; + +#define FAMFSIOC_MAGIC 'u' + +/* famfs file ioctl opcodes */ +#define FAMFSIOC_MAP_CREATE _IOW(FAMFSIOC_MAGIC, 1, struct famfs_ioc_map) +#define FAMFSIOC_MAP_GET _IOR(FAMFSIOC_MAGIC, 2, struct famfs_ioc_map) +#define FAMFSIOC_MAP_GETEXT _IOR(FAMFSIOC_MAGIC, 3, struct famfs_extent) +#define FAMFSIOC_NOP _IO(FAMFSIOC_MAGIC, 4) + +#endif /* FAMFS_IOCTL_H */ From patchwork Fri Feb 23 17:41:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Groves X-Patchwork-Id: 13569765 Received: from mail-oa1-f52.google.com (mail-oa1-f52.google.com [209.85.160.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A287C140E5C; Fri, 23 Feb 2024 17:42:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710163; cv=none; b=Xph9suXFw6voPqUqtbJOpgyFyWQXBEocTxjl3Wzhg0tobBhg8y45NEzJyx9ogFcpS6Z9sw1zTu12nwrDL++Yfm5Qci9Q6Fq65q+Nc2VsGAhvItWg5Ns3NC22ofPsxQDaBS7KUx9J6VmLHUXZUxtxr5+JJvzViIbxIE5mdHC9sPs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710163; c=relaxed/simple; bh=nLyr4TWhalrsSTbLBLYPk/fSOipP3b9UOzjhAi8tqKI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nwTcn6YiHy6jN618bJXo+3MeHN/dhQAbfAuKXj8A3l0dfl2FKr5OPQSP1WLlnGu5xNEpkbrAOdY3fkyZSSilZrXSaC6uDVzhlXvQVjEjBk5lrH5AETYw3ScU0tZyMNBjSytq/bVEZOjPZFvzjA3oWg8GR97bXU8L18tiVnrZqPg= 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=W9DbGu/t; arc=none smtp.client-ip=209.85.160.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=Groves.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="W9DbGu/t" Received: by mail-oa1-f52.google.com with SMTP id 586e51a60fabf-21f5ab945e9so475953fac.0; Fri, 23 Feb 2024 09:42:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708710160; x=1709314960; 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=DxhluQ29UqTfdm4fCVn38u2knnwILBZPsWmaO804tyk=; b=W9DbGu/tbMxbUQA2KRGjXS1SVzTHby5ZFaJWANvV29fy0gqQhwrNjX8GO0zdNRsXLP 4s7G+KJ84yC80cpcz66wdDAaErlwN4oT06sRWyh1qXZtqJpYl0aHdsKWt/zDDyRXrX+O 1A/hgTe0gpylhcBXFud8I+QQG6ZXdGA4QGUFKADgvXa7M1jqpAZGUv5+JsXom/H3C/+m hLWalNHeN8QYn6wo92XKCwJcvbCUw7VqmW7ZWBvchRYlvOpg1blMMSG6ewsKMkHKvFwW v1qzsfROKodaWyqUDPzN+mulAs0tCkPV0naIJKEqHZnuEf28iCNwBZHO7Oy7V/ScAqS1 pjlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708710160; x=1709314960; 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=DxhluQ29UqTfdm4fCVn38u2knnwILBZPsWmaO804tyk=; b=sdKh2EzV5IOTAhJkb+6jbFtO63sF2UN1i37zm97BbN7JoGbWl8jePPljJYHf8YR4ID aar0PC2m0hV0IwF7O5rJ+1avJnnuSnND7JeGuDvdOp0v7yz+ZA5/PQjZ29Q+Cp4knk13 fUbHF5yUpa9gm/V/8cO5GmpQ3ZxwMrYbYKSaYKpVozj3zZa6ouP57eK2pvzndek/N1+f 80zm4oyxBaClMR1V629TUOZO1t3vX/m6tY1F1BtsqngkOmijW8bv/ikHs6jtMBS+HG93 ouyG1V8Bht+uqAwNN/9gIn5HTu3BRABaBSxSd4pbMRZ/SfrxO3XKP3YTOtGuB42e4r63 yvrw== X-Forwarded-Encrypted: i=1; AJvYcCWrvD2hIVs1rJC9B6Nw32RashM7rP+dlqAx3zsdXltun5tLIbGTz9HFPDgRd0IZVjDH71nZ7QeeE5odFcAhmVOYx6kYfWCKjWswlINL+/4r1j2kC7dCNEMomyyvg3dqxPqgvmY4FZ8CSJlNdRLLjXRkhKLZ+U2ALt00xNjk1hqEbdoNyi0qeVy8+7P7IXEHe0dBdJdceGF+MOfNzpoa7jM9Sw== X-Gm-Message-State: AOJu0Yy+TfUZpV1aNtctV5ru160CGCNGL2qGCC6iR5VGGzyonvGNhTCz LtKdLfY3w3XPhoHuJSs+xw14ab7V4D/Lu5R5NFgMH6EPh0CSHb7x X-Google-Smtp-Source: AGHT+IG3mwMd0pVehrQmhoVUcYCZorVKFr87H6SZPXCfzXGnZuw6mwbcqWG+G90doupdIHyrTEyd5A== X-Received: by 2002:a05:6870:61cd:b0:21f:c2a4:6fe7 with SMTP id b13-20020a05687061cd00b0021fc2a46fe7mr230781oah.28.1708710160647; Fri, 23 Feb 2024 09:42:40 -0800 (PST) Received: from localhost.localdomain (070-114-203-196.res.spectrum.com. [70.114.203.196]) by smtp.gmail.com with ESMTPSA id rb7-20020a056871618700b0021f6a2bd4b9sm1257803oab.3.2024.02.23.09.42.39 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 23 Feb 2024 09:42:40 -0800 (PST) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Jonathan Corbet , Dan Williams , Vishal Verma , Dave Jiang , Alexander Viro , Christian Brauner , Jan Kara , Matthew Wilcox , linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev Cc: John@Groves.net, john@jagalactic.com, Dave Chinner , Christoph Hellwig , dave.hansen@linux.intel.com, gregory.price@memverge.com, John Groves Subject: [RFC PATCH 08/20] famfs: Add famfs_internal.h Date: Fri, 23 Feb 2024 11:41:52 -0600 Message-Id: <13556dbbd8d0f51bc31e3bdec796283fe85c6baf.1708709155.git.john@groves.net> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add the famfs_internal.h include file. This contains internal data structures such as the per-file metadata structure (famfs_file_meta) and extent formats. Signed-off-by: John Groves --- fs/famfs/famfs_internal.h | 53 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 fs/famfs/famfs_internal.h diff --git a/fs/famfs/famfs_internal.h b/fs/famfs/famfs_internal.h new file mode 100644 index 000000000000..af3990d43305 --- /dev/null +++ b/fs/famfs/famfs_internal.h @@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * famfs - dax file system for shared fabric-attached memory + * + * Copyright 2023-2024 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. + */ +#ifndef FAMFS_INTERNAL_H +#define FAMFS_INTERNAL_H + +#include +#include + +#define FAMFS_MAGIC 0x87b282ff + +#define FAMFS_BLKDEV_MODE (FMODE_READ|FMODE_WRITE) + +extern const struct file_operations famfs_file_operations; + +/* + * Each famfs dax file has this hanging from its inode->i_private. + */ +struct famfs_file_meta { + int error; + enum famfs_file_type file_type; + size_t file_size; + enum extent_type tfs_extent_type; + size_t tfs_extent_ct; + struct famfs_extent tfs_extents[]; /* flexible array */ +}; + +struct famfs_mount_opts { + umode_t mode; +}; + +extern const struct iomap_ops famfs_iomap_ops; +extern const struct vm_operations_struct famfs_file_vm_ops; + +#define ROOTDEV_STRLEN 80 + +struct famfs_fs_info { + struct famfs_mount_opts mount_opts; + struct file *dax_filp; + struct dax_device *dax_devp; + struct bdev_handle *bdev_handle; + struct list_head fsi_list; + char *rootdev; +}; + +#endif /* FAMFS_INTERNAL_H */ From patchwork Fri Feb 23 17:41:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Groves X-Patchwork-Id: 13569766 Received: from mail-ot1-f53.google.com (mail-ot1-f53.google.com [209.85.210.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 67EC61420B7; Fri, 23 Feb 2024 17:42:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710166; cv=none; b=MERb+r7lOLrf9VHQp6XUC2ALygQ4U8HiQ21Hte6EtgXBp0x50QQaLs4DjS/9kJUf+z7PuRbe336vVxDFZLDGIKIC3MsngUk6WVMg/kELWEJ+TCiFyg8EQguQxciAWsIz8nuGal6tbmGSXH2LErXqyIpu0VCcYGvB9fuglQutmEc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710166; c=relaxed/simple; bh=S1dC3s+Bdbdiu4CM5vBZY74+9xIlFu6uaw2o1TRdOz4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TS6UxjzySeHdi6vIUDl5CvPHhOUDAIiTw9xvnf/ay2odGfSy/fFGMC24t29/GchOsAZnqPZCH3PN6VPK89/ktFxSwZZKKxup7fjWv6AlEeXhR0KovEOCFTEpHarwHrcVrK2YJ/aTRwkt3TqsQdvCPQcGjBc9mo8MnB6R6z2LfbM= 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=gVhNsN97; arc=none smtp.client-ip=209.85.210.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=Groves.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gVhNsN97" Received: by mail-ot1-f53.google.com with SMTP id 46e09a7af769-6e48153c13aso376309a34.3; Fri, 23 Feb 2024 09:42:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708710163; x=1709314963; 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=nLMqFBWl5LhzqIjuwu8LKub75LEQmCe/d881zRdnRFA=; b=gVhNsN97llH4yH8WHCGFnWphxLofXGQHtAtKFUk56jAzoonI9IuVOSz1Yn+PTowWdy wncfx5eTfxymR8tpynaNptRfY+PG6uXf6VD7/UJlebI3WPAzWvfYVMLua0VFJjcMOZL2 HOiWimTrGAhOnIHrkG35L1I9eQoTf0RLjJK5KHkrqzm41vQeUPITmGI0W3AvnEChvyEN ley+0Mkhp77QrCv/P1xYTZnLqwQrSvUPGH60uw/Vh8gsfEOIs4Ee+mChNOB+hCS5kuIY oQipNq3dfxwUoXugTMSyKCvjoWG/zZ6cPUvztQG+FSY69Jka2dAlHUfHIr42kI8SbQqs 3Dbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708710163; x=1709314963; 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=nLMqFBWl5LhzqIjuwu8LKub75LEQmCe/d881zRdnRFA=; b=mQDpu1fv1SWNVmwltJZ5Nxyf9XLdjmY9CrvhCa3P7uBxz3CRSQXxR818DMNVbtT2E5 oBwhhTWjW6z25VbPG8Jd/61xn1TiVZ547gRGYEJzNttjpSdP3E4MbVy9exe22P2IU2Oi t2PwGS8us7sLSSS+by3gNfMTCiPvdqwOrUIKm0B8YQCJUH1YF1d8cJL2NowBm3GuJsF+ TkrJWfMzxwVWTmyxwSsFp/1ObzSkchFNYgh/9DR+MagWxDfZyBsWK3va4uY7y6EXw8o5 o9a+kD/GBlY75urgX1VFspIykZWYjIEWE2B/YJ0RKs3v0/6HURu1VUnlKT7pmiGM0qJ3 eiHg== X-Forwarded-Encrypted: i=1; AJvYcCXfvyZKI76QCY0BHd2aUMjclqJAMvgQjvHDK67Dsfec/huVJ+GqFycnI/OhBZSBUpceCZrMgVCnac5qJzFigUOff/BOOtPNT5wLf1vFbAP0JzDU4ku+lYWOW0Bph0KRkwG6pM5d6qdaMm/nch9EXfonS9IZvHO4wKlEO+yzHXeMgR4pfLtT4NySq4X9XZblvD3NRM05v56ggpvXvd4Z5R/mQw== X-Gm-Message-State: AOJu0Yx0pVZRJ1HveKrTCb07u5iU+cs/Z74KSC/gzyIGqld0A76pF/gf 1zJBNxMLY7/90QgMqgBrYH2ifaeWB6gkhO4GplSvjmMEu9WS4Tsg X-Google-Smtp-Source: AGHT+IH367Vw2L7iZdROKuLaJXvWJMZ5u7D0rUCk0PqnXp7KzR8fKSXYm9C614LmvLpJXYiq76cSvQ== X-Received: by 2002:a05:6870:55cd:b0:21e:e81e:36ef with SMTP id qk13-20020a05687055cd00b0021ee81e36efmr552160oac.36.1708710163445; Fri, 23 Feb 2024 09:42:43 -0800 (PST) Received: from localhost.localdomain (070-114-203-196.res.spectrum.com. [70.114.203.196]) by smtp.gmail.com with ESMTPSA id rb7-20020a056871618700b0021f6a2bd4b9sm1257803oab.3.2024.02.23.09.42.41 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 23 Feb 2024 09:42:43 -0800 (PST) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Jonathan Corbet , Dan Williams , Vishal Verma , Dave Jiang , Alexander Viro , Christian Brauner , Jan Kara , Matthew Wilcox , linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev Cc: John@Groves.net, john@jagalactic.com, Dave Chinner , Christoph Hellwig , dave.hansen@linux.intel.com, gregory.price@memverge.com, John Groves Subject: [RFC PATCH 09/20] famfs: Add super_operations Date: Fri, 23 Feb 2024 11:41:53 -0600 Message-Id: <537f836056c141ae093c42b9623d20de919083b1.1708709155.git.john@groves.net> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Introduce the famfs superblock operations Signed-off-by: John Groves --- fs/famfs/famfs_inode.c | 72 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 fs/famfs/famfs_inode.c diff --git a/fs/famfs/famfs_inode.c b/fs/famfs/famfs_inode.c new file mode 100644 index 000000000000..3329aff000d1 --- /dev/null +++ b/fs/famfs/famfs_inode.c @@ -0,0 +1,72 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * famfs - dax file system for shared fabric-attached memory + * + * Copyright 2023-2024 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "famfs_internal.h" + +#define FAMFS_DEFAULT_MODE 0755 + +static const struct super_operations famfs_ops; +static const struct inode_operations famfs_file_inode_operations; +static const struct inode_operations famfs_dir_inode_operations; + +/********************************************************************************** + * famfs super_operations + * + * TODO: implement a famfs_statfs() that shows size, free and available space, etc. + */ + +/** + * famfs_show_options() - Display the mount options in /proc/mounts. + */ +static int famfs_show_options( + struct seq_file *m, + struct dentry *root) +{ + struct famfs_fs_info *fsi = root->d_sb->s_fs_info; + + if (fsi->mount_opts.mode != FAMFS_DEFAULT_MODE) + seq_printf(m, ",mode=%o", fsi->mount_opts.mode); + + return 0; +} + +static const struct super_operations famfs_ops = { + .statfs = simple_statfs, + .drop_inode = generic_delete_inode, + .show_options = famfs_show_options, +}; + + +MODULE_LICENSE("GPL"); From patchwork Fri Feb 23 17:41:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Groves X-Patchwork-Id: 13569767 Received: from mail-oa1-f42.google.com (mail-oa1-f42.google.com [209.85.160.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 02761142624; Fri, 23 Feb 2024 17:42:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710169; cv=none; b=tiwLj5UWiNNxIh/fOEF08OO7N5/P3FwLrQp461jnXC01DrK+NXkmyEvqjPsTG/BBVqn0u9zAfg3yazyXwJ4xLMarf5F2yz/suTIlAGVee6/lnp4BrO40TXyUXcu2YBe9omDmgVUMDXZHDpWPN0821/eI0gmrdCqWmyEZhbJllys= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710169; c=relaxed/simple; bh=srzo99OmjkDCUvG5svVH4unqtaTIPC9o374VcuR+GuM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ntUgcf+bZkd5D6nFmDjFQdL66ExlkNUvEDx0BJBKcrG60anKFlT08JuwgROCt08P51ok2SDKnl7jBi4fY3IU+9C2J17OUdSrNBsEYxp2aX1FHOwjr3JSJVG2ywn3TMCwgRSTpooLcWo9GW4FlB3s0zZB7g8aLvKWAcvyH5gpTbg= 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=UpAGT7+H; arc=none smtp.client-ip=209.85.160.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="UpAGT7+H" Received: by mail-oa1-f42.google.com with SMTP id 586e51a60fabf-2185d368211so579556fac.3; Fri, 23 Feb 2024 09:42:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708710166; x=1709314966; 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=A873SqENQ+wCYjpP9mWHe+BP4BuwHGe8YCt4HStt9WQ=; b=UpAGT7+HCzTtsPs0MnjdHbtFbPO5jDityBwgGndHTeYIX5axiuxQWkVvpG7NPehcLF Xh1+xdtRVV6SO6sNpTWe80yqDUmGNoc1uuSu1K8SRXkmI8uoIWLPwSmeg2mG/O0TOOLd dPDkajj0lL05JW65OrPv3DSYaU6O2t7NvrbQmXW5id6/OX63lu0oJVgODZRl3dnZQkp8 x4xwXvYRAug7t03c93pwVnv5ys9J+Nh5dZ4e4Et80dd9YcAYic9G9OjFFW97ib8OwjCt Wyeh/iTyYE3/rsRPU+ppEFkPLsDZ95AvutKVYloE/UwgmAI1ioR19oH6wPes8X/+nrN2 7i9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708710166; x=1709314966; 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=A873SqENQ+wCYjpP9mWHe+BP4BuwHGe8YCt4HStt9WQ=; b=O9GoAACtBWHgYbkhBHvRKtSd7j589qOLnM4KTN429oz2EIz8yhQybE4gX9Gqi5/g2I yA2lx7ClQYnOO6Ij1SvxzUB8PJ9KY15OysmEDoviELXpUDFfRHgXjLa5LpiquSLvfdYb bYdmcnEfvj2pqqv4eDvDfVyHRP50WETRmY2K7qqox3zMZy4n2/QP3YWdla8DfnZx6UJE un/Cu3yAwD36M3i4G+taw51bJdrEkQceWZl5OiyW2g6Qv5GbIu8h/8E3dgyYli6R31HB 3XxNuTWDFSZ1v/9i5n11+RvW7Mpbv1Lkyza1jXk3IuLL49OYgli6MXRIX3bCj+qt4yVr rmSg== X-Forwarded-Encrypted: i=1; AJvYcCV8DvJUcCvwLYaQPKEo0v+1XyBk65RhI9E8ewYyy4VHb/1VQd+d+WX2KL9H8nfAyUrnzfziyWIErvb/9AyXoAHasESl1nfJFpBqFeWFMrNsg1eLOdPBKzBbnOpdZh+vTmuIRd0OxUsrVv2BuMQ2X3GTo2b4jTMnCUm8wyK2V5eB5I30zwTYQ5W2oZVGJI3Qi2BeoNQx+2ks39h0j7CfStC4Yg== X-Gm-Message-State: AOJu0YzJXnz+a1hs8QkoWhrRNFnJqQeGg6MNHVZjxaBvxtQY4ybRNv3v cyllY/bN0fR9qW2ZWImd1fjjDV/r5jF19bbyyn0UAvvdu69yVLrs X-Google-Smtp-Source: AGHT+IF2fmWGYszloE2KJFCTjjXL/IoXoZ6AQti5BlXVdEWVOweP5vY0ChXNH89MGd6oVU3o3oDieQ== X-Received: by 2002:a05:6870:514f:b0:21e:5647:c3e2 with SMTP id z15-20020a056870514f00b0021e5647c3e2mr604937oak.26.1708710166110; Fri, 23 Feb 2024 09:42:46 -0800 (PST) Received: from localhost.localdomain (070-114-203-196.res.spectrum.com. [70.114.203.196]) by smtp.gmail.com with ESMTPSA id rb7-20020a056871618700b0021f6a2bd4b9sm1257803oab.3.2024.02.23.09.42.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 23 Feb 2024 09:42:45 -0800 (PST) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Jonathan Corbet , Dan Williams , Vishal Verma , Dave Jiang , Alexander Viro , Christian Brauner , Jan Kara , Matthew Wilcox , linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev Cc: John@Groves.net, john@jagalactic.com, Dave Chinner , Christoph Hellwig , dave.hansen@linux.intel.com, gregory.price@memverge.com, John Groves Subject: [RFC PATCH 10/20] famfs: famfs_open_device() & dax_holder_operations Date: Fri, 23 Feb 2024 11:41:54 -0600 Message-Id: <74359fdc83688fb1aac1cb2c336fbd725590a131.1708709155.git.john@groves.net> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Famfs works on both /dev/pmem and /dev/dax devices. This commit introduces the function that opens a block (pmem) device and the struct dax_holder_operations that are needed for that ABI. In this commit, support for opening character /dev/dax is stubbed. A later commit introduces this capability. Signed-off-by: John Groves --- fs/famfs/famfs_inode.c | 83 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/fs/famfs/famfs_inode.c b/fs/famfs/famfs_inode.c index 3329aff000d1..82c861998093 100644 --- a/fs/famfs/famfs_inode.c +++ b/fs/famfs/famfs_inode.c @@ -68,5 +68,88 @@ static const struct super_operations famfs_ops = { .show_options = famfs_show_options, }; +/*************************************************************************************** + * dax_holder_operations for block dax + */ + +static int +famfs_blk_dax_notify_failure( + struct dax_device *dax_devp, + u64 offset, + u64 len, + int mf_flags) +{ + + pr_err("%s: dax_devp %llx offset %llx len %lld mf_flags %x\n", + __func__, (u64)dax_devp, (u64)offset, (u64)len, mf_flags); + return -EOPNOTSUPP; +} + +const struct dax_holder_operations famfs_blk_dax_holder_ops = { + .notify_failure = famfs_blk_dax_notify_failure, +}; + +static int +famfs_open_char_device( + struct super_block *sb, + struct fs_context *fc) +{ + pr_err("%s: Root device is %s, but your kernel does not support famfs on /dev/dax\n", + __func__, fc->source); + return -ENODEV; +} + +/** + * famfs_open_device() + * + * Open the memory device. If it looks like /dev/dax, call famfs_open_char_device(). + * Otherwise try to open it as a block/pmem device. + */ +static int +famfs_open_device( + struct super_block *sb, + struct fs_context *fc) +{ + struct famfs_fs_info *fsi = sb->s_fs_info; + struct dax_device *dax_devp; + u64 start_off = 0; + struct bdev_handle *handlep; + + if (fsi->dax_devp) { + pr_err("%s: already mounted\n", __func__); + return -EALREADY; + } + + if (strstr(fc->source, "/dev/dax")) /* There is probably a better way to check this */ + return famfs_open_char_device(sb, fc); + + if (!strstr(fc->source, "/dev/pmem")) { /* There is probably a better way to check this */ + pr_err("%s: primary backing dev (%s) is not pmem\n", + __func__, fc->source); + return -EINVAL; + } + + handlep = bdev_open_by_path(fc->source, FAMFS_BLKDEV_MODE, fsi, &fs_holder_ops); + if (IS_ERR(handlep->bdev)) { + pr_err("%s: failed blkdev_get_by_path(%s)\n", __func__, fc->source); + return PTR_ERR(handlep->bdev); + } + + dax_devp = fs_dax_get_by_bdev(handlep->bdev, &start_off, + fsi /* holder */, + &famfs_blk_dax_holder_ops); + if (IS_ERR(dax_devp)) { + pr_err("%s: unable to get daxdev from handlep->bdev\n", __func__); + bdev_release(handlep); + return -ENODEV; + } + fsi->bdev_handle = handlep; + fsi->dax_devp = dax_devp; + + pr_notice("%s: root device is block dax (%s)\n", __func__, fc->source); + return 0; +} + + MODULE_LICENSE("GPL"); From patchwork Fri Feb 23 17:41:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Groves X-Patchwork-Id: 13569768 Received: from mail-oa1-f52.google.com (mail-oa1-f52.google.com [209.85.160.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E5E0114264A; Fri, 23 Feb 2024 17:42:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710171; cv=none; b=TmHJSVDcpykqQnnHDbt4KPdmUVJb3hS4eVptaL02MDhJKSj5dLywb4F28EbIVNfgpEXY+mgpJVa9kcyP4FKjnHx/qFdh50ieKCcoPiS0QA+CUhKYt9fzXVrfpuk53aQUHBt3vlj9RAeaIwryFhkNIZT3/M1ZNl0kVKq0gkQsZ9I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710171; c=relaxed/simple; bh=r5pTLGO9XcEXrmVzZJZcGWfD/d6LrnLm1UsYwXS5ZFs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=khElskFVvQHem7zguK1wNLjaGKhmtmNuP+QUy9q2CXJ1ThM4sL9u+yCGtzjsPGqw//9r5Q811cz44OdTg/6g2h7X39uSe4zlmOJ1ewcL8EIugC9N3z584j/CF8zhXa2WK4hMCfM8CDfS5EG+9Cv9HWBvJcyGlCUWwUzhkVETEfA= 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=TTYtl4bN; arc=none smtp.client-ip=209.85.160.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=Groves.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TTYtl4bN" Received: by mail-oa1-f52.google.com with SMTP id 586e51a60fabf-21ec3ca9ab9so403432fac.3; Fri, 23 Feb 2024 09:42:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708710169; x=1709314969; 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=SDij1l2aMmKfMAAe6zSZuUvXOX3IygMutNr1gCulSkI=; b=TTYtl4bNI8ARPP6EKZ5FB7htVBjXR1ZMSq6UHvxyyA/nLA876o5tR2d3Z6u6T8fMsK cg8ZxgZdGbnC8nYvA78MAJXigtjLf2xk1URm7xsHu8/UHXKq6sT3EShbAYtjXar1EXvz daaT74sL6fJFk/w+y79ksRNHGq+0x3DRuvOmcoQg4BiWd0NJtjGJj/ExDZjSm2rLg20H ksg4N3t8ED5uq2nXbtfIyHmPCDsSQfMU/RGQC/GN9tMhxrlAvIqe9sGDvbkkdm6JpgeU LDfhlqpdhOXXNl48YdGZF9dM58Fe+bsgaIWPR7nDMI0ckS+xuqqydU4IJ2FtAzHK425h YBFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708710169; x=1709314969; 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=SDij1l2aMmKfMAAe6zSZuUvXOX3IygMutNr1gCulSkI=; b=RIiv3h6ZNOZkRNjgLSsF5SBkOJWNJEipsr6kpNpG27cn0BbxvPslC8bIvPuvmJ6Yrs BJ9GPXL4IFdsAvscNOGDJZnoCUsjik/zmwQdL7jALrefXPJ+2c3mc3vGa9I5b0zgeWvf pifE3HokinvZ8mOX9SqlW7dFj0vurWFZsEn1JqUpWVGNgVp116FgJq926kHMGlQ2kugr tGgr1O3fHArkyKsy5FiUjc7VbcupHj4NvlhWS1TBXCnlx07ILYcyEG/fck2n4iETczLn +c4pVnNeCMeln4IXh9I7kZAxAinV8gyzPJENky34YBXBiRGcCJjbazGgRxc5rAvkwfi/ DvpA== X-Forwarded-Encrypted: i=1; AJvYcCVRPF+TDSQzICcHsPhEAy11r6rP3Vh6eqrFO7bj5hfC/fYUMbessU6naaApUKcm4zxmfMf1eiwV6i7gK1DQtiZIz2WJAx9sNk9Nr2+S+sJDM9KBWS2CCBzCN/IXoQn2pKFkBb6nCRuGbwZ3Kf7Ur1t0LBZYtTFTtnlpfZTUlpSUoNH0VP3z+57qrLqdE21MGiZMGceLI3bK8kuCV/RiCZmBbA== X-Gm-Message-State: AOJu0YzprSy6ux/Ms04rJQngx4OUn5pQN9ZTWM+IAUP/u2hX9YloxFX1 5cq66c75qlFMGjBblZkmF7Ni/giaUisoo95+rIdMgG0JUWJzyvlQ X-Google-Smtp-Source: AGHT+IE5JaMy3N1Zd8Sic8j2FBFbUWeO4ntBKm5lkkpOUfdTGrk4SxVvNsysFBkwseINoLvi9Xx++Q== X-Received: by 2002:a05:6871:340c:b0:21f:c8e1:4514 with SMTP id nh12-20020a056871340c00b0021fc8e14514mr93820oac.13.1708710168899; Fri, 23 Feb 2024 09:42:48 -0800 (PST) Received: from localhost.localdomain (070-114-203-196.res.spectrum.com. [70.114.203.196]) by smtp.gmail.com with ESMTPSA id rb7-20020a056871618700b0021f6a2bd4b9sm1257803oab.3.2024.02.23.09.42.47 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 23 Feb 2024 09:42:48 -0800 (PST) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Jonathan Corbet , Dan Williams , Vishal Verma , Dave Jiang , Alexander Viro , Christian Brauner , Jan Kara , Matthew Wilcox , linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev Cc: John@Groves.net, john@jagalactic.com, Dave Chinner , Christoph Hellwig , dave.hansen@linux.intel.com, gregory.price@memverge.com, John Groves Subject: [RFC PATCH 11/20] famfs: Add fs_context_operations Date: Fri, 23 Feb 2024 11:41:55 -0600 Message-Id: X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This commit introduces the famfs fs_context_operations and famfs_get_inode() which is used by the context operations. Signed-off-by: John Groves --- fs/famfs/famfs_inode.c | 178 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 178 insertions(+) diff --git a/fs/famfs/famfs_inode.c b/fs/famfs/famfs_inode.c index 82c861998093..f98f82962d7b 100644 --- a/fs/famfs/famfs_inode.c +++ b/fs/famfs/famfs_inode.c @@ -41,6 +41,50 @@ static const struct super_operations famfs_ops; static const struct inode_operations famfs_file_inode_operations; static const struct inode_operations famfs_dir_inode_operations; +static struct inode *famfs_get_inode( + struct super_block *sb, + const struct inode *dir, + umode_t mode, + dev_t dev) +{ + struct inode *inode = new_inode(sb); + + if (inode) { + struct timespec64 tv; + + inode->i_ino = get_next_ino(); + inode_init_owner(&nop_mnt_idmap, inode, dir, mode); + inode->i_mapping->a_ops = &ram_aops; + mapping_set_gfp_mask(inode->i_mapping, GFP_HIGHUSER); + mapping_set_unevictable(inode->i_mapping); + tv = inode_set_ctime_current(inode); + inode_set_mtime_to_ts(inode, tv); + inode_set_atime_to_ts(inode, tv); + + switch (mode & S_IFMT) { + default: + init_special_inode(inode, mode, dev); + break; + case S_IFREG: + inode->i_op = &famfs_file_inode_operations; + inode->i_fop = &famfs_file_operations; + break; + case S_IFDIR: + inode->i_op = &famfs_dir_inode_operations; + inode->i_fop = &simple_dir_operations; + + /* Directory inodes start off with i_nlink == 2 (for "." entry) */ + inc_nlink(inode); + break; + case S_IFLNK: + inode->i_op = &page_symlink_inode_operations; + inode_nohighmem(inode); + break; + } + } + return inode; +} + /********************************************************************************** * famfs super_operations * @@ -150,6 +194,140 @@ famfs_open_device( return 0; } +/***************************************************************************************** + * fs_context_operations + */ +static int +famfs_fill_super( + struct super_block *sb, + struct fs_context *fc) +{ + struct famfs_fs_info *fsi = sb->s_fs_info; + struct inode *inode; + int rc = 0; + + sb->s_maxbytes = MAX_LFS_FILESIZE; + sb->s_blocksize = PAGE_SIZE; + sb->s_blocksize_bits = PAGE_SHIFT; + sb->s_magic = FAMFS_MAGIC; + sb->s_op = &famfs_ops; + sb->s_time_gran = 1; + + rc = famfs_open_device(sb, fc); + if (rc) + goto out; + + inode = famfs_get_inode(sb, NULL, S_IFDIR | fsi->mount_opts.mode, 0); + sb->s_root = d_make_root(inode); + if (!sb->s_root) + rc = -ENOMEM; + +out: + return rc; +} + +enum famfs_param { + Opt_mode, + Opt_dax, +}; + +const struct fs_parameter_spec famfs_fs_parameters[] = { + fsparam_u32oct("mode", Opt_mode), + fsparam_string("dax", Opt_dax), + {} +}; + +static int famfs_parse_param( + struct fs_context *fc, + struct fs_parameter *param) +{ + struct famfs_fs_info *fsi = fc->s_fs_info; + struct fs_parse_result result; + int opt; + + opt = fs_parse(fc, famfs_fs_parameters, param, &result); + if (opt == -ENOPARAM) { + opt = vfs_parse_fs_param_source(fc, param); + if (opt != -ENOPARAM) + return opt; + + return 0; + } + if (opt < 0) + return opt; + + switch (opt) { + case Opt_mode: + fsi->mount_opts.mode = result.uint_32 & S_IALLUGO; + break; + case Opt_dax: + if (strcmp(param->string, "always")) + pr_notice("%s: invalid dax mode %s\n", + __func__, param->string); + break; + } + + return 0; +} + +static DEFINE_MUTEX(famfs_context_mutex); +static LIST_HEAD(famfs_context_list); + +static int famfs_get_tree(struct fs_context *fc) +{ + struct famfs_fs_info *fsi_entry; + struct famfs_fs_info *fsi = fc->s_fs_info; + + fsi->rootdev = kstrdup(fc->source, GFP_KERNEL); + if (!fsi->rootdev) + return -ENOMEM; + + /* Fail if famfs is already mounted from the same device */ + mutex_lock(&famfs_context_mutex); + list_for_each_entry(fsi_entry, &famfs_context_list, fsi_list) { + if (strcmp(fsi_entry->rootdev, fc->source) == 0) { + mutex_unlock(&famfs_context_mutex); + pr_err("%s: already mounted from rootdev %s\n", __func__, fc->source); + return -EALREADY; + } + } + + list_add(&fsi->fsi_list, &famfs_context_list); + mutex_unlock(&famfs_context_mutex); + + return get_tree_nodev(fc, famfs_fill_super); + +} + +static void famfs_free_fc(struct fs_context *fc) +{ + struct famfs_fs_info *fsi = fc->s_fs_info; + + if (fsi && fsi->rootdev) + kfree(fsi->rootdev); + + kfree(fsi); +} + +static const struct fs_context_operations famfs_context_ops = { + .free = famfs_free_fc, + .parse_param = famfs_parse_param, + .get_tree = famfs_get_tree, +}; + +static int famfs_init_fs_context(struct fs_context *fc) +{ + struct famfs_fs_info *fsi; + + fsi = kzalloc(sizeof(*fsi), GFP_KERNEL); + if (!fsi) + return -ENOMEM; + + fsi->mount_opts.mode = FAMFS_DEFAULT_MODE; + fc->s_fs_info = fsi; + fc->ops = &famfs_context_ops; + return 0; +} MODULE_LICENSE("GPL"); From patchwork Fri Feb 23 17:41:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Groves X-Patchwork-Id: 13569769 Received: from mail-oa1-f41.google.com (mail-oa1-f41.google.com [209.85.160.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 D9452143C6A; Fri, 23 Feb 2024 17:42:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710174; cv=none; b=ju1/kkSi/VB/IkGJwloo24rF9Q/Gp2dz0+kkgb15t+eXsJQWgd5jHIv2+dzky6nUTQwBy9EytRt/UJ8yL7cdUp9NFsRPeARxCsZiMktxYVZn+DOAwsbN292fN9/Jy2lhSXQ2bUkzGZ3YxEGUJgNzOHWS+5v1SEkDM+rlV4lTjnA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710174; c=relaxed/simple; bh=VCUvYUMBePLjAnqLXIh0xC3E0ySm6TUv3Sa00+ZpFwE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZZ7x0dKWCC/hWhNDHW8lWITYfPJ/zsx0AlcQ0ZCkQRcaI/v8VC1G0hZLfzLN4xZ3Z7LxEZd1oG/N9/AZfAxUBKJ5evAoPgEiaMq3ad7XiDd+5zpVyXjlLxr8ZmNX2XYo7uuTSWHqkcQfYBKcthyFoEEhwf9YN80qsh92c25gAPA= 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=RgtNX9H+; arc=none smtp.client-ip=209.85.160.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="RgtNX9H+" Received: by mail-oa1-f41.google.com with SMTP id 586e51a60fabf-21f70f72fb5so627842fac.1; Fri, 23 Feb 2024 09:42:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708710172; x=1709314972; 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=p6QjmLkc27iMh7yi/z9o9l9CtGVPifxNLsali304Bg4=; b=RgtNX9H+kqUWjxLDyFr2RFG9MQRbtobQujYZvqCo1BjLgI9OLOcgkUzyhLlcRCLJoj M0fS9+4xJdC0A9THjSXQnxuJIO1QYaPMAnrXV4AqgCA6p3cOBNl8c9JERglzWOstd8O+ 22y/9lbsgetJiXmdBp6PJFNHH6bpfBbQr6R//BpvEFDf2kcQKMLJ7ZXoNDcURWW+t+0U 0SZwoOIp3d+eYjIswQ1jKHLHj70CTyHVhyxH56qoABwMSv31LqXhvrr8KLKElTYENSsf es4r3jTZsSGcdN4fJOpoyRT1aDYALD1c2LoKDbN2DmUIZchryxJFZ6vFfhqFhVztHUuC sI3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708710172; x=1709314972; 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=p6QjmLkc27iMh7yi/z9o9l9CtGVPifxNLsali304Bg4=; b=F3tQT/Tz1jktYzfDGtXTaqeCrl4gCCAbuE8zpwSz3j0CPIoY4f4kzOiAdsVsnj5kMu +EyiOiFc8ECVmnM4h4WiDFxLwb1f5FocFeOEQm66K4t1WFuw8Wm0KHDh589Ze0+fIJkE srnYamTfTq4L9PkIqP2Nnzf/OHlGnpl8ayhkXwWXArbluWdFhADRcxaqdJO+bzU5qdfh 90G8rgptjshUAR9chvLrWuoGuUy4HqBPnLBh8K65lr8arxBdV/u4H/CYJeYSnZ1jzrN1 zJiqjgGcb/P+7bnTTNOrLSgj2lkjrp8i+9v0YMQItDRg57rrKfc8jJY0ZEOBW9lCNn1d sIGQ== X-Forwarded-Encrypted: i=1; AJvYcCXFpEp8yQn2e8FgUbPKR0Em8leuiKlDlYcLPbNsiM1Ym5qR2XLDqh/jxKgmF5SQbQDJTeQQUfXcfNKxjt8FvMwR1p24cqImG8TVrlnXWP1Q3iUApj8ujor6pBXYd4L5wp/fjlxhH5Rk0373Fi06IM3SuqQylhob9mpczo0QZiPiPzhtRSkm49qdyfhvRp/DlIVz9NH/+fbCpxHImAM+9Ihvfg== X-Gm-Message-State: AOJu0Yx41x8JwHQI/OYOThoLmcyTL+ZKBgQM6HJQhi9RaTKRd8KM3Btb Q8esfJOxv0xxmVpgOK0UjekF6w9D6eQUmzxzb320q9b1xSywgx8I X-Google-Smtp-Source: AGHT+IFezMCWeCzZ2eHSXHjvcw2Pn5jzFcobtVWDICBBvL3Y3KmXgoiFcjq7tWPA9c/bY5ifdb19lg== X-Received: by 2002:a05:6871:4585:b0:21f:6758:d5b0 with SMTP id nl5-20020a056871458500b0021f6758d5b0mr489470oab.50.1708710171814; Fri, 23 Feb 2024 09:42:51 -0800 (PST) Received: from localhost.localdomain (070-114-203-196.res.spectrum.com. [70.114.203.196]) by smtp.gmail.com with ESMTPSA id rb7-20020a056871618700b0021f6a2bd4b9sm1257803oab.3.2024.02.23.09.42.50 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 23 Feb 2024 09:42:51 -0800 (PST) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Jonathan Corbet , Dan Williams , Vishal Verma , Dave Jiang , Alexander Viro , Christian Brauner , Jan Kara , Matthew Wilcox , linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev Cc: John@Groves.net, john@jagalactic.com, Dave Chinner , Christoph Hellwig , dave.hansen@linux.intel.com, gregory.price@memverge.com, John Groves Subject: [RFC PATCH 12/20] famfs: Add inode_operations and file_system_type Date: Fri, 23 Feb 2024 11:41:56 -0600 Message-Id: X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This commit introduces the famfs inode_operations. There is nothing really unique to famfs here in the inode_operations.. This commit also introduces the famfs_file_system_type struct and the famfs_kill_sb() function. Signed-off-by: John Groves --- fs/famfs/famfs_inode.c | 132 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) diff --git a/fs/famfs/famfs_inode.c b/fs/famfs/famfs_inode.c index f98f82962d7b..ab46ec50b70d 100644 --- a/fs/famfs/famfs_inode.c +++ b/fs/famfs/famfs_inode.c @@ -85,6 +85,109 @@ static struct inode *famfs_get_inode( return inode; } +/*************************************************************************** + * famfs inode_operations: these are currently pretty much boilerplate + */ + +static const struct inode_operations famfs_file_inode_operations = { + /* All generic */ + .setattr = simple_setattr, + .getattr = simple_getattr, +}; + + +/* + * File creation. Allocate an inode, and we're done.. + */ +/* SMP-safe */ +static int +famfs_mknod( + struct mnt_idmap *idmap, + struct inode *dir, + struct dentry *dentry, + umode_t mode, + dev_t dev) +{ + struct inode *inode = famfs_get_inode(dir->i_sb, dir, mode, dev); + int error = -ENOSPC; + + if (inode) { + struct timespec64 tv; + + d_instantiate(dentry, inode); + dget(dentry); /* Extra count - pin the dentry in core */ + error = 0; + tv = inode_set_ctime_current(inode); + inode_set_mtime_to_ts(inode, tv); + inode_set_atime_to_ts(inode, tv); + } + return error; +} + +static int famfs_mkdir( + struct mnt_idmap *idmap, + struct inode *dir, + struct dentry *dentry, + umode_t mode) +{ + int retval = famfs_mknod(&nop_mnt_idmap, dir, dentry, mode | S_IFDIR, 0); + + if (!retval) + inc_nlink(dir); + + return retval; +} + +static int famfs_create( + struct mnt_idmap *idmap, + struct inode *dir, + struct dentry *dentry, + umode_t mode, + bool excl) +{ + return famfs_mknod(&nop_mnt_idmap, dir, dentry, mode | S_IFREG, 0); +} + +static int famfs_symlink( + struct mnt_idmap *idmap, + struct inode *dir, + struct dentry *dentry, + const char *symname) +{ + struct inode *inode; + int error = -ENOSPC; + + inode = famfs_get_inode(dir->i_sb, dir, S_IFLNK | 0777, 0); + if (inode) { + int l = strlen(symname)+1; + + error = page_symlink(inode, symname, l); + if (!error) { + struct timespec64 tv; + + d_instantiate(dentry, inode); + dget(dentry); + tv = inode_set_ctime_current(inode); + inode_set_mtime_to_ts(inode, tv); + inode_set_atime_to_ts(inode, tv); + } else + iput(inode); + } + return error; +} + +static const struct inode_operations famfs_dir_inode_operations = { + .create = famfs_create, + .lookup = simple_lookup, + .link = simple_link, + .unlink = simple_unlink, + .symlink = famfs_symlink, + .mkdir = famfs_mkdir, + .rmdir = simple_rmdir, + .mknod = famfs_mknod, + .rename = simple_rename, +}; + /********************************************************************************** * famfs super_operations * @@ -329,5 +432,34 @@ static int famfs_init_fs_context(struct fs_context *fc) return 0; } +static void famfs_kill_sb(struct super_block *sb) +{ + struct famfs_fs_info *fsi = sb->s_fs_info; + + mutex_lock(&famfs_context_mutex); + list_del(&fsi->fsi_list); + mutex_unlock(&famfs_context_mutex); + + if (fsi->bdev_handle) + bdev_release(fsi->bdev_handle); + if (fsi->dax_devp) + fs_put_dax(fsi->dax_devp, fsi); + if (fsi->dax_filp) /* This only happens if it's char dax */ + filp_close(fsi->dax_filp, NULL); + + if (fsi && fsi->rootdev) + kfree(fsi->rootdev); + kfree(fsi); + kill_litter_super(sb); +} + +#define MODULE_NAME "famfs" +static struct file_system_type famfs_fs_type = { + .name = MODULE_NAME, + .init_fs_context = famfs_init_fs_context, + .parameters = famfs_fs_parameters, + .kill_sb = famfs_kill_sb, + .fs_flags = FS_USERNS_MOUNT, +}; MODULE_LICENSE("GPL"); From patchwork Fri Feb 23 17:41:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Groves X-Patchwork-Id: 13569770 Received: from mail-ot1-f43.google.com (mail-ot1-f43.google.com [209.85.210.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 446A01448E3; Fri, 23 Feb 2024 17:42:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710178; cv=none; b=kFkKTKd2UdYfqXGPZKAxnIKrxuK6wBiuC6P21RSGFBr5z1KJ6txuUPAjEV6pXLhX5cxscc7V3qBNBNl5+aKtIrcBhKFQRwONM9z0peGEFp5ok8fcIagvz0JmaE759Urc0RLUUMalGpZuVBn1QuBkf3J+c0lNdEE8QCifZQmUNH0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710178; c=relaxed/simple; bh=PUD0vMbRgGZdbJrCGYGYILmZtfRGBeQr9bzqDwdIVbc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FEwWVxk3/G6pV8DXnzmu0H/KtoCJ+D37TNtOwVkmwKU9X9N318eOIVxX1Hi0aQZqtT4rd3rUtBzbviMCnvwrvshwsEJwbbW5efvYLxx7TLWVrPAi2DYNgp4EyMlGvecyiXqqkkst+yeNd9VTMCkcR0lVwOB792CUZlKx0D2b+jA= 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=IV+4FOFP; arc=none smtp.client-ip=209.85.210.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=Groves.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IV+4FOFP" Received: by mail-ot1-f43.google.com with SMTP id 46e09a7af769-6e2e5824687so401698a34.0; Fri, 23 Feb 2024 09:42:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708710175; x=1709314975; 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=ffFa5LaeRHtZzXvAYgjrZx1FIfP+qFqp6PEwqgPiWCk=; b=IV+4FOFP+Ph8eCukP45OFBPJToaXpxhTLi2pLr77BWJgjae3UIMdtvuu281uDVeTgw oSeCLoWmoiw3/AMi2xb3O/Kl2fKUKv+guVx+sHh16gGwxyY2by/nRvZ9r/SAwx4uAY42 nZWuDr6+RTzsxaVGOUBafy29mOel4YUDWjJJZMyThYWRrsOCMgVFm/4oB6aQBBvE8/pd tVOBpExw1JS7ijWUdpUnTKaeM0DfcJdu6E2e1724efTsjydl6UZP7GSNrThmzJtLBuzz k3M+03j2OOAiEr+gp+txY056ZgqsXLKyhD9h3jMQzduJqRSwAnrJ9qHGKNScInB5UVth 9ing== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708710175; x=1709314975; 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=ffFa5LaeRHtZzXvAYgjrZx1FIfP+qFqp6PEwqgPiWCk=; b=M50l4hSp8v6NRlkVIpRKwjKbvi6QRAB8ozLGDYfTxGrRlWZQSKPuTn/OHtDaRXUPXK 9xdE7f4lAHNG6eEXEVQAxzo0jKAeD6JHjuaEsedc2crDS4BSwmMFP9cS2CQ5zrDrJxpj D7QSL4IubcRH4L4nu5Pwy9xBbWME6+9OqovnnLW0OLmsDSqpYmo3xWnxpAP59cXDbg1B fsjQntD4ENm9INqri96f8NjizNd/7BayL0d9R5BUloiqK5DjzPun8McnvE30jnwuukfK FCmScw8QpE+f74t7wwgBmBiMjWXarxATn6q3VwDuDwu+AF8LULoPRSynPfvK7Wg2/BqP liYQ== X-Forwarded-Encrypted: i=1; AJvYcCUNa+tmQp+7nm0bkf7TcgsL5QoJwLvAHDYd0t5+JR5mOo9R5Gr5gbjwG6X9LRvbvQCYdjx5CmDWODztke9PpxTe2/eRpud9DO7TfZjlqjbvU60k9TPGiIA9NQ/TXv3mQ5/A5fzjbkVNP80B91pMEtD+GKJWlcxbAcUpPn1cRWgz2VctALRSYDZ1Cr6KkO1hEeKbXPq4nKSFSiolU5oDMMUE5Q== X-Gm-Message-State: AOJu0YxzycEiBF83BBRFx9GFizwLX58fqcQgZcYLujupak0oYq5+TuVo /dU9mkQu3tY+7N9t4SAj77CW0tNXdZtSH0j3lxYrINsGjN1Dbril X-Google-Smtp-Source: AGHT+IEHirLXRV+6OKdrF+r7Z5tOqjqyN0zId5OKwsBBpwfkkZXqy9jpKoxd8tEFzTGfWYOfe+Tq4Q== X-Received: by 2002:a05:6871:7810:b0:21e:be10:f39d with SMTP id oy16-20020a056871781000b0021ebe10f39dmr577039oac.46.1708710175230; Fri, 23 Feb 2024 09:42:55 -0800 (PST) Received: from localhost.localdomain (070-114-203-196.res.spectrum.com. [70.114.203.196]) by smtp.gmail.com with ESMTPSA id rb7-20020a056871618700b0021f6a2bd4b9sm1257803oab.3.2024.02.23.09.42.53 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 23 Feb 2024 09:42:55 -0800 (PST) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Jonathan Corbet , Dan Williams , Vishal Verma , Dave Jiang , Alexander Viro , Christian Brauner , Jan Kara , Matthew Wilcox , linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev Cc: John@Groves.net, john@jagalactic.com, Dave Chinner , Christoph Hellwig , dave.hansen@linux.intel.com, gregory.price@memverge.com, John Groves Subject: [RFC PATCH 13/20] famfs: Add iomap_ops Date: Fri, 23 Feb 2024 11:41:57 -0600 Message-Id: <2996a7e757c3762a9a28c789645acd289f5f7bc0.1708709155.git.john@groves.net> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This commit introduces the famfs iomap_ops. When either dax_iomap_fault() or dax_iomap_rw() is called, we get a callback via our iomap_begin() handler. The question being asked is "please resolve (file, offset) to (daxdev, offset)". The function famfs_meta_to_dax_offset() does this. The per-file metadata is just an extent list to the backing dax dev. The order of this resolution is O(N) for N extents. Note with the current user space, files usually have only one extent. Signed-off-by: John Groves --- fs/famfs/famfs_file.c | 245 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 245 insertions(+) create mode 100644 fs/famfs/famfs_file.c diff --git a/fs/famfs/famfs_file.c b/fs/famfs/famfs_file.c new file mode 100644 index 000000000000..fc667d5f7be8 --- /dev/null +++ b/fs/famfs/famfs_file.c @@ -0,0 +1,245 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * famfs - dax file system for shared fabric-attached memory + * + * Copyright 2023-2024 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 +#include "famfs_internal.h" + +/********************************************************************* + * iomap_operations + * + * This stuff uses the iomap (dax-related) helpers to resolve file offsets to + * offsets within a dax device. + */ + +/** + * famfs_meta_to_dax_offset() + * + * 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 resolving 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 - struct iomap to be filled in to indicate where to find the right memory, relative + * to a dax device. + * @offset - the offset within the file where the fault occurred (will be page boundary) + * @len - the length of the faulted mapping (will be a page multiple) + * (will be trimmed in *iomap if it's disjoint in the extent list) + * @flags + */ +static int +famfs_meta_to_dax_offset( + struct inode *inode, + struct iomap *iomap, + loff_t offset, + loff_t len, + unsigned int flags) +{ + struct famfs_file_meta *meta = (struct famfs_file_meta *)inode->i_private; + int i; + loff_t local_offset = offset; + struct famfs_fs_info *fsi = inode->i_sb->s_fs_info; + + iomap->offset = offset; /* file offset */ + + for (i = 0; i < meta->tfs_extent_ct; i++) { + loff_t dax_ext_offset = meta->tfs_extents[i].offset; + loff_t dax_ext_len = meta->tfs_extents[i].len; + + if ((dax_ext_offset == 0) && (meta->file_type != FAMFS_SUPERBLOCK)) + pr_err("%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 = dax_ext_len - local_offset; + + /*+ + * 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 + * + * iomap->addr is the offset within the dax device where that data + * starts + */ + iomap->addr = dax_ext_offset + local_offset; /* dax dev offset */ + iomap->offset = offset; /* file offset */ + iomap->length = min_t(loff_t, len, ext_len_remainder); + iomap->dax_dev = fsi->dax_devp; + iomap->type = IOMAP_MAPPED; + iomap->flags = flags; + + return 0; + } + local_offset -= dax_ext_len; /* Get ready for the next extent */ + } + + /* Set iomap to zero length in this case, and return 0 + * This just means that the r/w is past EOF + */ + iomap->addr = offset; + iomap->offset = offset; /* file offset */ + iomap->length = 0; /* this had better result in no access to dax mem */ + iomap->dax_dev = fsi->dax_devp; + iomap->type = IOMAP_MAPPED; + iomap->flags = flags; + + return 0; +} + +/** + * famfs_iomap_begin() + * + * This function is pretty simple because files are + * * never partially allocated + * * never have holes (never sparse) + * * never "allocate on write" + */ +static int +famfs_iomap_begin( + struct inode *inode, + loff_t offset, + loff_t length, + unsigned int flags, + struct iomap *iomap, + struct iomap *srcmap) +{ + struct famfs_file_meta *meta = inode->i_private; + size_t size; + int rc; + + size = i_size_read(inode); + + WARN_ON(size != meta->file_size); + + rc = famfs_meta_to_dax_offset(inode, iomap, offset, length, flags); + + return rc; +} + +/* 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 = { + .iomap_begin = 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 = file_inode(vmf->vma->vm_file); + vm_fault_t ret; + + if (write_fault) { + sb_start_pagefault(inode->i_sb); + file_update_time(vmf->vma->vm_file); + } + + if (IS_DAX(inode)) { + pfn_t pfn; + + ret = dax_iomap_fault(vmf, pe_size, &pfn, NULL, &famfs_iomap_ops); + if (ret & VM_FAULT_NEEDDSYNC) + ret = dax_finish_sync_fault(vmf, pe_size, pfn); + } else { + /* All famfs faults will be dax... */ + pr_err("%s: oops, non-dax fault\n", __func__); + ret = VM_FAULT_SIGBUS; + } + + 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) +{ + /* DAX can shortcut the normal fault path on write faults! */ + return __famfs_filemap_fault(vmf, 0, + IS_DAX(file_inode(vmf->vma->vm_file)) && famfs_is_write_fault(vmf)); +} + +static vm_fault_t +famfs_filemap_huge_fault( + struct vm_fault *vmf, + unsigned int pe_size) +{ + if (!IS_DAX(file_inode(vmf->vma->vm_file))) { + pr_err("%s: file not marked IS_DAX!!\n", __func__); + return VM_FAULT_SIGBUS; + } + + /* DAX can shortcut the normal fault path on write faults! */ + 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) +{ + vm_fault_t ret; + + ret = filemap_map_pages(vmf, start_pgoff, end_pgoff); + return ret; +} + +const struct vm_operations_struct famfs_file_vm_ops = { + .fault = famfs_filemap_fault, + .huge_fault = famfs_filemap_huge_fault, + .map_pages = famfs_filemap_map_pages, + .page_mkwrite = famfs_filemap_page_mkwrite, + .pfn_mkwrite = famfs_filemap_pfn_mkwrite, +}; + From patchwork Fri Feb 23 17:41:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Groves X-Patchwork-Id: 13569771 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 A33CC143C6A; Fri, 23 Feb 2024 17:42:58 +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=1708710182; cv=none; b=abkJ1ZOBDq3uakZ0Gm0yhrwFx8hmP7S6/Dqjwe103DU+Auqk3vpiA6RMGzQchp2P0HNoeGCMEtN9swafNzLpc4B20vXsWZPOJvbkgylH8sCgJ/mbF2wFsEXxbN0CsO3MpTs7QOMZ1Q/mLYtWdvUdJ07Hfxd384kyxW4yGT/52Ys= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710182; c=relaxed/simple; bh=jYmxy3JFMAN0mad3tJYaUDo5JWHwAqTIs9pH9XFTFKg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mzxETtONorr+Zj0UgBTqM12Om83NGhCsR8ZH2gwL9oncUkQJ7vdVtAcRoqcubunlyRp/XmNhZP0fCLr21+EI69+/oQjEC2YjpKEXiGAatr1Xsp2WVytnfwOJhMCBuZ2b1r/y2Kl3YxWOTL6mYTl1Ibr+R/LGVzJeZAFxeh0jXY8= 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=duAUeAir; 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="duAUeAir" Received: by mail-ot1-f46.google.com with SMTP id 46e09a7af769-6e2da00185dso497566a34.1; Fri, 23 Feb 2024 09:42:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708710178; x=1709314978; 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=FpWp5wNXSRx+i2XDMUwzlPOWNd0LdWimzvwNrKtQTig=; b=duAUeAirkMACY+gWL5vyfTEO5QM6tc16in2Y9vsRFnHOdv/mnllRHleDOjonMA7AtP UsT/KRPiINz1hlaQa4vjqMEenIJvSYjqqp3QvSJVV9jvlSrH9i0Ssf6HyrpcpJPDyQJC V7s5hxc14tDLgQ9zhhpqQHH5+FCWnm2vZIddFJ0ttq/VrxqKuYk3nTOfx3zHl4s3ic/j zEdmSN0glfiTQFZW60g86ltwF+LzoYlYHXkeynqRyXDoRgPpW3hl9LqXfDKFivuY4WDr 6BjjyIdU7wdlGnq7ZmIco2J618uLUVbMBEGxAaJ0psUWiVdPF1cGKKuB8Wi/XAawo15H xKEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708710178; x=1709314978; 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=FpWp5wNXSRx+i2XDMUwzlPOWNd0LdWimzvwNrKtQTig=; b=awUBemIHeQ52ZgHIZBikv+ci3JA4iVD17qkONtrA3C2NBbjhuyhcQ5Scqm/cCpWwxk k0dB7T4wOHm0Kll658LJGoazU5zxClEUh0I/7zcxgaTj7PwtHx3nHEsxpz4NtgIYcUsn UHj5emg+/GE6s6hqk7/jhFIhpti2VQRm5+aHUid0VPLM8lMGP8tGosDjBjf4XZMqJ8q0 XCKRJe/UiziizqqkYt1SfZuwvNj7Sw4XYEAUDOkHxkeDgQ71juknoOYw+UcJrE+jL0l+ 8TrD4jrknXgpD/u0UhkPoRg9aBON2PWXJrL4LCcRJkmEsUjCPiUi3qGyiGZbYZeLH4uj zHWg== X-Forwarded-Encrypted: i=1; AJvYcCXdLFs3n0ml2aQCQ0GrwTZSmiu4diD86fbA1XuX9pQVyavMAhXtXXaynKyzS3+6UyP58FsZ3EpSfE14KiVV/Rd112EVFvsCnWEh/97oNyNvfRcaqIJc25jMA05P/3EZq+dTiIj88iOn9v+wiEcN0aVppZZMRn1jsa49ahCk0dZNT1ZOi3efgUCxHe/85hCOTvjLV/ppOb64m67bHFToKH3B7Q== X-Gm-Message-State: AOJu0YzzNTXRlxqaQnWjI3l4asIZckx7wKR56uXwneFInptC60pV9tyU vI+ma6AAc+AiPXDxRLyOgBg4hijZT6GVroSGB/CMnJHz7KERR5oW X-Google-Smtp-Source: AGHT+IGv8FMbQ9vzN7mZzAqvBQGzhE2aAS91+mTwvqifPrAqjLgsl4U6TqglN2diLu8SM4tYIK17Pw== X-Received: by 2002:a05:6870:d38b:b0:21f:4267:7983 with SMTP id k11-20020a056870d38b00b0021f42677983mr535476oag.49.1708710177826; Fri, 23 Feb 2024 09:42:57 -0800 (PST) Received: from localhost.localdomain (070-114-203-196.res.spectrum.com. [70.114.203.196]) by smtp.gmail.com with ESMTPSA id rb7-20020a056871618700b0021f6a2bd4b9sm1257803oab.3.2024.02.23.09.42.56 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 23 Feb 2024 09:42:57 -0800 (PST) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Jonathan Corbet , Dan Williams , Vishal Verma , Dave Jiang , Alexander Viro , Christian Brauner , Jan Kara , Matthew Wilcox , linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev Cc: John@Groves.net, john@jagalactic.com, Dave Chinner , Christoph Hellwig , dave.hansen@linux.intel.com, gregory.price@memverge.com, John Groves Subject: [RFC PATCH 14/20] famfs: Add struct file_operations Date: Fri, 23 Feb 2024 11:41:58 -0600 Message-Id: <3f19cd8daab0dc3c4d0381019ce61cd106970097.1708709155.git.john@groves.net> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This commit introduces the famfs file_operations. We call thp_get_unmapped_area() to force PMD page alignment. Our read and write handlers (famfs_dax_read_iter() and famfs_dax_write_iter()) call dax_iomap_rw() to do the work. famfs_file_invalid() checks for various ways a famfs file can be in an invalid state so we can fail I/O or fault resolution in those cases. Those cases include the following: * No famfs metadata * file i_size does not match the originally allocated size * file is not flagged as DAX * errors were detected previously on the file An invalid file can often be fixed by replaying the log, or by umount/mount/log replay - all of which are user space operations. Signed-off-by: John Groves --- fs/famfs/famfs_file.c | 136 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) diff --git a/fs/famfs/famfs_file.c b/fs/famfs/famfs_file.c index fc667d5f7be8..5228e9de1e3b 100644 --- a/fs/famfs/famfs_file.c +++ b/fs/famfs/famfs_file.c @@ -19,6 +19,142 @@ #include #include "famfs_internal.h" +/********************************************************************* + * file_operations + */ + +/* Reject I/O to files that aren't in a valid state */ +static ssize_t +famfs_file_invalid(struct inode *inode) +{ + size_t i_size = i_size_read(inode); + struct famfs_file_meta *meta = inode->i_private; + + if (!meta) { + pr_err("%s: un-initialized famfs file\n", __func__); + return -EIO; + } + if (i_size != meta->file_size) { + pr_err("%s: something changed the size from %ld to %ld\n", + __func__, meta->file_size, i_size); + meta->error = 1; + return -ENXIO; + } + if (!IS_DAX(inode)) { + pr_err("%s: inode %llx IS_DAX is false\n", __func__, (u64)inode); + meta->error = 1; + return -ENXIO; + } + if (meta->error) { + pr_err("%s: previously detected metadata errors\n", __func__); + meta->error = 1; + return -EIO; + } + return 0; +} + +static ssize_t +famfs_dax_read_iter( + struct kiocb *iocb, + struct iov_iter *to) +{ + struct inode *inode = iocb->ki_filp->f_mapping->host; + size_t i_size = i_size_read(inode); + size_t count = iov_iter_count(to); + size_t max_count; + ssize_t rc; + + rc = famfs_file_invalid(inode); + if (rc) + return rc; + + max_count = max_t(size_t, 0, i_size - iocb->ki_pos); + + if (count > max_count) + iov_iter_truncate(to, max_count); + + if (!iov_iter_count(to)) + return 0; + + rc = dax_iomap_rw(iocb, to, &famfs_iomap_ops); + + file_accessed(iocb->ki_filp); + return rc; +} + +/** + * famfs_write_iter() + * + * We need our own write-iter in order to prevent append + */ +static ssize_t +famfs_dax_write_iter( + struct kiocb *iocb, + struct iov_iter *from) +{ + struct inode *inode = iocb->ki_filp->f_mapping->host; + size_t i_size = i_size_read(inode); + size_t count = iov_iter_count(from); + size_t max_count; + ssize_t rc; + + rc = famfs_file_invalid(inode); + if (rc) + return rc; + + /* Starting offset of write is: iocb->ki_pos + * length is iov_iter_count(from) + */ + max_count = max_t(size_t, 0, i_size - iocb->ki_pos); + + /* If write would go past EOF, truncate it to end at EOF since famfs does not + * alloc-on-write + */ + if (count > max_count) + iov_iter_truncate(from, max_count); + + if (!iov_iter_count(from)) + return 0; + + return dax_iomap_rw(iocb, from, &famfs_iomap_ops); +} + +static int +famfs_file_mmap( + struct file *file, + struct vm_area_struct *vma) +{ + struct inode *inode = file_inode(file); + ssize_t rc; + + rc = famfs_file_invalid(inode); + if (rc) + return (int)rc; + + file_accessed(file); + vma->vm_ops = &famfs_file_vm_ops; + vm_flags_set(vma, VM_HUGEPAGE); + return 0; +} + +const struct file_operations famfs_file_operations = { + .owner = THIS_MODULE, + + /* Custom famfs operations */ + .write_iter = famfs_dax_write_iter, + .read_iter = famfs_dax_read_iter, + .mmap = famfs_file_mmap, + + /* Force PMD alignment for mmap */ + .get_unmapped_area = thp_get_unmapped_area, + + /* Generic Operations */ + .fsync = noop_fsync, + .splice_read = filemap_splice_read, + .splice_write = iter_file_splice_write, + .llseek = generic_file_llseek, +}; + /********************************************************************* * iomap_operations * From patchwork Fri Feb 23 17:41:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Groves X-Patchwork-Id: 13569772 Received: from mail-oa1-f48.google.com (mail-oa1-f48.google.com [209.85.160.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 6AD03145B1B; Fri, 23 Feb 2024 17:43:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710183; cv=none; b=IoM4hpDwhiCE3EOcTrqdE7g2ykjL+JUExIi4FfbgeuHAFp5VLJ+L8ZMnAoGO0nn03buCvcsPQNzZe+rBx5KY7bGwAu+kPZLJV28M7/9D2x6v0LiRlKv3r5asGIC/ZyvySFY/uCSfMl1RRDzHa/ikcBarRo7XPNnLN5XHDcfJbEo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710183; c=relaxed/simple; bh=gfDqrv2IB8dGuNuxnTRTAgf83rxue/Tl0NVJJQh84Bw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rwoThicx1DtuhVSrDWXqPD9pWg1Z5t9P6VUNoXWQ/Cj1nIShohOWPKJbrcYWMNsgW2FvLrCZL/07LwqwgW+MVmtjloB2xzwygxQFR+cQZnugddnWWqbPpUfDZ5c0RwVEBxAmULDB4ChfYl3NfbR93PuVwvK/Q3WXD2JmS+evuT0= 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=PFpF8u9U; arc=none smtp.client-ip=209.85.160.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="PFpF8u9U" Received: by mail-oa1-f48.google.com with SMTP id 586e51a60fabf-2185d368211so579688fac.3; Fri, 23 Feb 2024 09:43:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708710180; x=1709314980; 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=u1a+mGhIFV5S9yOIM/mTwkpKXjnQFwrZ+3KlU4LOk/M=; b=PFpF8u9UhXID6fzATN3sQikfuhvPwtu3FDwQ/kQdk87Xf5CeAhmBvs8UkyGOWu2SSv FZUfXAqJqm5jy/RZtSqATgjQKYwZS10AgwCWdYa40mHhrjVisD4IHcer82a/KXDZoHAl kIC5raYcnOhT0pLcRAcZbd5UHtY+Hq46xtszhesivSC9b0Pg9CCKORF5JSCHyIOHGZUl uMNaNftGcXt+Qkid/gXzMdeVORuFNyZc3lWGZWxoETlp5UtJMp083JgOj3mLP9qacH+M gDE8YxWnDxKhMO+17Z/E3W8DvRVC5UZKo/lOxun38zhgLxFI0OUDxsihtSvaAR31P6b9 qeCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708710180; x=1709314980; 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=u1a+mGhIFV5S9yOIM/mTwkpKXjnQFwrZ+3KlU4LOk/M=; b=c7sXCBL1drBu96eKrW6rTJrcmL2W1GVVtJiJ8YLfEx3okLwzk35AXiFFvoDB2H2NUK Gpa1W+xWpvMkRfi4zlhDWtikdEuSLRck9nKYy0Z6oDs4HkFbhScb5x4xv/KdB9rUhWhr +URRDejc037qsUhkJk79DnDgELY+LhkHgDKzXkPxXf+eyaZAc5jK8bgOHoN7f1AYMSG/ +PXOxmZgOT3EWQAhLXAJIhnZ8NL0tXeC6ZWYFeGS2HSKPbW9dXGS9MB2DNuc4L8Quxv9 /1N/dyP20IFPmOfcbk4DCnxecA4oVzLIYO/1ydXtDA2af3l6+G5tM92aQy4Mwc6G+L0p kP3w== X-Forwarded-Encrypted: i=1; AJvYcCWBLZw9JvwItYlOsANNRqlzt/kTPmp/LBz5imhV2BAAYHaIvbyWCaAOECF7C2ZUs5TZn7uUivMxdBNfHN1NsHauzemh4qUli1SPTd+CUcB74fhIqGZbmnw66NDQie818ka4vKxUziALW33JA+ws/+O5StRPrbe8VB+qXPbR91B8CqMd2/YoxCi+GdAe/jhkKMrKxVRAmy+sS/B4WG0o6WI27w== X-Gm-Message-State: AOJu0Yw7f7YwD004OghVWIyQrO8Stmgyg3n5v+eai4gSFeV9s7MRpJZ4 IxeN2423iLPfje/VEihNSBuKPBi7YkQq+PpW0gbbYw/L2LJXzy4O X-Google-Smtp-Source: AGHT+IGvxRx1x0iM8YFXd/Ou2m5jkMZ8OYrYEJf96MjvtDyIZQMs9edy6hMhNpE0gZvzjl3i4gWw1w== X-Received: by 2002:a05:6870:f143:b0:21e:d808:5a2a with SMTP id l3-20020a056870f14300b0021ed8085a2amr594038oac.7.1708710180571; Fri, 23 Feb 2024 09:43:00 -0800 (PST) Received: from localhost.localdomain (070-114-203-196.res.spectrum.com. [70.114.203.196]) by smtp.gmail.com with ESMTPSA id rb7-20020a056871618700b0021f6a2bd4b9sm1257803oab.3.2024.02.23.09.42.58 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 23 Feb 2024 09:43:00 -0800 (PST) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Jonathan Corbet , Dan Williams , Vishal Verma , Dave Jiang , Alexander Viro , Christian Brauner , Jan Kara , Matthew Wilcox , linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev Cc: John@Groves.net, john@jagalactic.com, Dave Chinner , Christoph Hellwig , dave.hansen@linux.intel.com, gregory.price@memverge.com, John Groves Subject: [RFC PATCH 15/20] famfs: Add ioctl to file_operations Date: Fri, 23 Feb 2024 11:41:59 -0600 Message-Id: X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This commit introduces the per-file ioctl function famfs_file_ioctl() into struct file_operations, and introduces the famfs_file_init_dax() function (which is called by famfs_file_ioct()) famfs_file_init_dax() associates a dax extent list with a file, making it into a proper famfs file. It is called from the FAMFSIOC_MAP_CREATE ioctl. Starting with an empty file (which is basically a ramfs file), this turns the file into a DAX file backed by the specified extent list. The other ioctls are: FAMFSIOC_NOP - A convenient way for user space to verify it's a famfs file FAMFSIOC_MAP_GET - Get the header of the metadata for a file FAMFSIOC_MAP_GETEXT - Get the extents for a file The latter two, together, are comparable to xfs_bmap. Our user space tools use them primarly in testing. Signed-off-by: John Groves --- fs/famfs/famfs_file.c | 226 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 226 insertions(+) diff --git a/fs/famfs/famfs_file.c b/fs/famfs/famfs_file.c index 5228e9de1e3b..fd42d5966982 100644 --- a/fs/famfs/famfs_file.c +++ b/fs/famfs/famfs_file.c @@ -19,6 +19,231 @@ #include #include "famfs_internal.h" +/** + * famfs_map_meta_alloc() - Allocate famfs file metadata + * @mapp: Pointer to an mcache_map_meta pointer + * @ext_count: The number of extents needed + */ +static int +famfs_meta_alloc( + struct famfs_file_meta **metap, + size_t ext_count) +{ + struct famfs_file_meta *meta; + size_t metasz; + + *metap = NULL; + + metasz = sizeof(*meta) + sizeof(*(meta->tfs_extents)) * ext_count; + + meta = kzalloc(metasz, GFP_KERNEL); + if (!meta) + return -ENOMEM; + + meta->tfs_extent_ct = ext_count; + *metap = meta; + + return 0; +} + +static void +famfs_meta_free( + struct famfs_file_meta *map) +{ + kfree(map); +} + +/** + * famfs_file_init_dax() - FAMFSIOC_MAP_CREATE ioctl handler + * @file: + * @arg: ptr to struct mcioc_map in user space + * + * Setup the dax mapping for a file. Files are created empty, and then function is called + * (by famfs_file_ioctl()) to setup the mapping and set the file size. + */ +static int +famfs_file_init_dax( + struct file *file, + void __user *arg) +{ + struct famfs_extent *tfs_extents = NULL; + struct famfs_file_meta *meta = NULL; + struct inode *inode; + struct famfs_ioc_map imap; + struct famfs_fs_info *fsi; + struct super_block *sb; + int alignment_errs = 0; + size_t extent_total = 0; + size_t ext_count; + int rc = 0; + int i; + + rc = copy_from_user(&imap, arg, sizeof(imap)); + if (rc) + return -EFAULT; + + ext_count = imap.ext_list_count; + if (ext_count < 1) { + rc = -ENOSPC; + goto errout; + } + + if (ext_count > FAMFS_MAX_EXTENTS) { + rc = -E2BIG; + goto errout; + } + + inode = file_inode(file); + if (!inode) { + rc = -EBADF; + goto errout; + } + sb = inode->i_sb; + fsi = inode->i_sb->s_fs_info; + + tfs_extents = &imap.ext_list[0]; + + rc = famfs_meta_alloc(&meta, ext_count); + if (rc) + goto errout; + + meta->file_type = imap.file_type; + meta->file_size = imap.file_size; + + /* Fill in the internal file metadata structure */ + for (i = 0; i < imap.ext_list_count; i++) { + size_t len; + off_t offset; + + offset = imap.ext_list[i].offset; + len = imap.ext_list[i].len; + + extent_total += len; + + if (WARN_ON(offset == 0 && meta->file_type != FAMFS_SUPERBLOCK)) { + rc = -EINVAL; + goto errout; + } + + meta->tfs_extents[i].offset = offset; + meta->tfs_extents[i].len = len; + + /* All extent addresses/offsets must be 2MiB aligned, + * and all but the last length must be a 2MiB multiple. + */ + if (!IS_ALIGNED(offset, PMD_SIZE)) { + pr_err("%s: error ext %d hpa %lx not aligned\n", + __func__, i, offset); + alignment_errs++; + } + if (i < (imap.ext_list_count - 1) && !IS_ALIGNED(len, PMD_SIZE)) { + pr_err("%s: error ext %d length %ld not aligned\n", + __func__, i, len); + alignment_errs++; + } + } + + /* + * File size can be <= ext list size, since extent sizes are constrained + * to PMD multiples + */ + if (imap.file_size > extent_total) { + pr_err("%s: file size %lld larger than ext list size %lld\n", + __func__, (u64)imap.file_size, (u64)extent_total); + rc = -EINVAL; + goto errout; + } + + if (alignment_errs > 0) { + pr_err("%s: there were %d alignment errors in the extent list\n", + __func__, alignment_errs); + rc = -EINVAL; + goto errout; + } + + /* Publish the famfs metadata on inode->i_private */ + inode_lock(inode); + if (inode->i_private) { + rc = -EEXIST; /* file already has famfs metadata */ + } else { + inode->i_private = meta; + i_size_write(inode, imap.file_size); + inode->i_flags |= S_DAX; + } + inode_unlock(inode); + + errout: + if (rc) + famfs_meta_free(meta); + + return rc; +} + +/** + * famfs_file_ioctl() - top-level famfs file ioctl handler + * @file: + * @cmd: + * @arg: + */ +static +long +famfs_file_ioctl( + struct file *file, + unsigned int cmd, + unsigned long arg) +{ + long rc; + + switch (cmd) { + case FAMFSIOC_NOP: + rc = 0; + break; + + case FAMFSIOC_MAP_CREATE: + rc = famfs_file_init_dax(file, (void *)arg); + break; + + case FAMFSIOC_MAP_GET: { + struct inode *inode = file_inode(file); + struct famfs_file_meta *meta = inode->i_private; + struct famfs_ioc_map umeta; + + memset(&umeta, 0, sizeof(umeta)); + + if (meta) { + /* TODO: do more to harmonize these structures */ + umeta.extent_type = meta->tfs_extent_type; + umeta.file_size = i_size_read(inode); + umeta.ext_list_count = meta->tfs_extent_ct; + + rc = copy_to_user((void __user *)arg, &umeta, sizeof(umeta)); + if (rc) + pr_err("%s: copy_to_user returned %ld\n", __func__, rc); + + } else { + rc = -EINVAL; + } + } + break; + case FAMFSIOC_MAP_GETEXT: { + struct inode *inode = file_inode(file); + struct famfs_file_meta *meta = inode->i_private; + + if (meta) + rc = copy_to_user((void __user *)arg, meta->tfs_extents, + meta->tfs_extent_ct * sizeof(struct famfs_extent)); + else + rc = -EINVAL; + } + break; + default: + rc = -ENOTTY; + break; + } + + return rc; +} + /********************************************************************* * file_operations */ @@ -143,6 +368,7 @@ const struct file_operations famfs_file_operations = { /* Custom famfs operations */ .write_iter = famfs_dax_write_iter, .read_iter = famfs_dax_read_iter, + .unlocked_ioctl = famfs_file_ioctl, .mmap = famfs_file_mmap, /* Force PMD alignment for mmap */ From patchwork Fri Feb 23 17:42:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Groves X-Patchwork-Id: 13569773 Received: from mail-oa1-f42.google.com (mail-oa1-f42.google.com [209.85.160.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 E5211146E73; Fri, 23 Feb 2024 17:43:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710187; cv=none; b=qIg4X7dKk8PIv2iHd/hv4NhFrmh4JQ+el5a4IKErVmhUKghjDKPNcCf0iw/TTUBVe+ETgP8+4Av5GmJTtplVlG5UfxO3tFAqg/5cTxoMnYckjWD/krm3Wad9KABbu174q7gJ1WMkiXWwCu+IveWBavwYu2pRoYaZFIGeqE5tBgo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710187; c=relaxed/simple; bh=fyP1dnJB44f2zHUX/KhaAT1o3vyBlQVFBHhanjGgGrc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mrs165MEFjjYoxj4SasJfvKYn73blJid5Z1Tb21O2t0rp02d37GysPQ4ug4N6ERDNsZOR+IatAhuUyJ3OKX7Kw+fb0rMaMCIRPKP4taArQW1eG37gjShsqQbFuKfEYL8ouFLeoCaXDJ6Z9c2G9t9lSBVIyqJJmxDfeSwdXzdj+Y= 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=Kblba6uZ; arc=none smtp.client-ip=209.85.160.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="Kblba6uZ" Received: by mail-oa1-f42.google.com with SMTP id 586e51a60fabf-214def5da12so565684fac.2; Fri, 23 Feb 2024 09:43:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708710183; x=1709314983; 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=QSU63xn35q5xIC/F3LPxUfwI8O4W4i8duNVDi3MdIz8=; b=Kblba6uZvvzHH/u0thHlvp4XF21RgBoWCGYeVk7p5IKsU5mMwGiQwsELa21KEL19KQ EpWHPC7+LkCzmcyQgel2mylFnWSXwKXIJNylgeBecfmGgzbAi/lDaVDJO6HV8Kp17daB L5c9QuhmK5oIPqZpchLVI/f46aYrT5cicU2Ce8DzE9M2GucJz72Lx/zODiR6RzCIBWzr QgymlA0U00P8CmUKCpupvKurqsqYrAIdeWBqiNZeoBZ/bgMqeVb2UNIYF8VOicIDPEHF BK6YFPYZg8+MfJ+SVTTqR7iZ9bcScyKjIMwyBJzJ8foCSQTp7YUI7qdcY2422qXEbxGe aRqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708710183; x=1709314983; 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=QSU63xn35q5xIC/F3LPxUfwI8O4W4i8duNVDi3MdIz8=; b=HuacQlLpLJGkMRL/Wbb6nW20eIKZ68Q4Sc6rAM/ZTiLNQ9otyQPsPDsSVrWVVKyq/9 tx/M3tOx+gKn4kwYxCgjVRFBd6DGBDiZj5Fwrnqv4Z2LYzipAkMZPw6BSMqh6PlTTfa2 FSkv6Mim7S5gPoKYChypG7tNvyygejgbcp1KRbZRk5YPiUYNMEYKv6HXMoRJW5DMMx/a kKg50tFvvqbPsavhk+zFYX3XKvnkF6xK7Gyf7NgpFymqwoeJ8kfIvnjZbygyTRmCVJPp SzOHJHKvVGySX5QrI3Kw3lqWAABYTVDn59etX3gAMA1Idbd/ux1dpFXBGRvJvxE7kpIW pgng== X-Forwarded-Encrypted: i=1; AJvYcCXpZb9OeqKonUxEOhTBzicp+aj1LPKwmI2Ld9Xh5MTLDnlTLzHjkT8J4ja6gBIFZrIpHD7ogvtxqPuOQae38B/GUXvZAhRZrFN5e/PHavYEORt0oJM8DmjyrkZphngNHJ74T4lQ2E5cv7vqD4z3g0+mzz58pMWLdpoMp+PGtAqQ3QU6owgeZbp/wmQxAzLvBBk/dZTxVPaoZSZXyVMf7wcvvw== X-Gm-Message-State: AOJu0Yy6fjNzBUX/HaoYEGgYNp0GjfEDZwno6tDKN4dvLkjpcTYmyqYW 4Jt9FZ2IAIUunx+9HOqM2Y82keS2JNIT2NXcmueir+jBOvEGW+Yw X-Google-Smtp-Source: AGHT+IHYLhdAVNB79UcBgLmrX8iHEz3pdisd9nD17jHPXDhHA28rwXuN54PUoWNin6tsA8ziv8tebw== X-Received: by 2002:a05:6870:f6a1:b0:21e:9b99:53d8 with SMTP id el33-20020a056870f6a100b0021e9b9953d8mr563209oab.22.1708710183097; Fri, 23 Feb 2024 09:43:03 -0800 (PST) Received: from localhost.localdomain (070-114-203-196.res.spectrum.com. [70.114.203.196]) by smtp.gmail.com with ESMTPSA id rb7-20020a056871618700b0021f6a2bd4b9sm1257803oab.3.2024.02.23.09.43.01 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 23 Feb 2024 09:43:02 -0800 (PST) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Jonathan Corbet , Dan Williams , Vishal Verma , Dave Jiang , Alexander Viro , Christian Brauner , Jan Kara , Matthew Wilcox , linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev Cc: John@Groves.net, john@jagalactic.com, Dave Chinner , Christoph Hellwig , dave.hansen@linux.intel.com, gregory.price@memverge.com, John Groves Subject: [RFC PATCH 16/20] famfs: Add fault counters Date: Fri, 23 Feb 2024 11:42:00 -0600 Message-Id: <43245b463f00506016b8c39c0252faf62bd73e35.1708709155.git.john@groves.net> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 One of the key requirements for famfs is that it service vma faults efficiently. Our metadata helps - the search order is n for n extents, and n is usually 1. But we can still observe gnarly lock contention in mm if PTE faults are happening. This commit introduces fault counters that can be enabled and read via /sys/fs/famfs/... These counters have proved useful in troubleshooting situations where PTE faults were happening instead of PMD. No performance impact when disabled. Signed-off-by: John Groves --- fs/famfs/famfs_file.c | 97 +++++++++++++++++++++++++++++++++++++++ fs/famfs/famfs_internal.h | 73 +++++++++++++++++++++++++++++ 2 files changed, 170 insertions(+) diff --git a/fs/famfs/famfs_file.c b/fs/famfs/famfs_file.c index fd42d5966982..a626f8a89790 100644 --- a/fs/famfs/famfs_file.c +++ b/fs/famfs/famfs_file.c @@ -19,6 +19,100 @@ #include #include "famfs_internal.h" +/*************************************************************************************** + * filemap_fault counters + * + * The counters and the fault_count_enable file live at + * /sys/fs/famfs/ + */ +struct famfs_fault_counters ffc; +static int fault_count_enable; + +static ssize_t +fault_count_enable_show(struct kobject *kobj, + struct kobj_attribute *attr, + char *buf) +{ + return sprintf(buf, "%d\n", fault_count_enable); +} + +static ssize_t +fault_count_enable_store(struct kobject *kobj, + struct kobj_attribute *attr, + const char *buf, + size_t count) +{ + int value; + int rc; + + rc = sscanf(buf, "%d", &value); + if (rc != 1) + return 0; + + if (value > 0) /* clear fault counters when enabling, but not when disabling */ + famfs_clear_fault_counters(&ffc); + + fault_count_enable = value; + return count; +} + +/* Individual fault counters are read-only */ +static ssize_t +fault_count_pte_show(struct kobject *kobj, + struct kobj_attribute *attr, + char *buf) +{ + return sprintf(buf, "%llu", famfs_pte_fault_ct(&ffc)); +} + +static ssize_t +fault_count_pmd_show(struct kobject *kobj, + struct kobj_attribute *attr, + char *buf) +{ + return sprintf(buf, "%llu", famfs_pmd_fault_ct(&ffc)); +} + +static ssize_t +fault_count_pud_show(struct kobject *kobj, + struct kobj_attribute *attr, + char *buf) +{ + return sprintf(buf, "%llu", famfs_pud_fault_ct(&ffc)); +} + +static struct kobj_attribute fault_count_enable_attribute = __ATTR(fault_count_enable, + 0660, + fault_count_enable_show, + fault_count_enable_store); +static struct kobj_attribute fault_count_pte_attribute = __ATTR(pte_fault_ct, + 0440, + fault_count_pte_show, + NULL); +static struct kobj_attribute fault_count_pmd_attribute = __ATTR(pmd_fault_ct, + 0440, + fault_count_pmd_show, + NULL); +static struct kobj_attribute fault_count_pud_attribute = __ATTR(pud_fault_ct, + 0440, + fault_count_pud_show, + NULL); + + +static struct attribute *attrs[] = { + &fault_count_enable_attribute.attr, + &fault_count_pte_attribute.attr, + &fault_count_pmd_attribute.attr, + &fault_count_pud_attribute.attr, + NULL, +}; + +struct attribute_group famfs_attr_group = { + .attrs = attrs, +}; + +/* End fault counters */ + /** * famfs_map_meta_alloc() - Allocate famfs file metadata * @mapp: Pointer to an mcache_map_meta pointer @@ -525,6 +619,9 @@ __famfs_filemap_fault( if (IS_DAX(inode)) { pfn_t pfn; + if (fault_count_enable) + famfs_inc_fault_counter_by_order(&ffc, pe_size); + ret = dax_iomap_fault(vmf, pe_size, &pfn, NULL, &famfs_iomap_ops); if (ret & VM_FAULT_NEEDDSYNC) ret = dax_finish_sync_fault(vmf, pe_size, pfn); diff --git a/fs/famfs/famfs_internal.h b/fs/famfs/famfs_internal.h index af3990d43305..987cb172a149 100644 --- a/fs/famfs/famfs_internal.h +++ b/fs/famfs/famfs_internal.h @@ -50,4 +50,77 @@ struct famfs_fs_info { char *rootdev; }; +/* + * filemap_fault counters + */ +extern struct attribute_group famfs_attr_group; + +enum famfs_fault { + FAMFS_PTE = 0, + FAMFS_PMD, + FAMFS_PUD, + FAMFS_NUM_FAULT_TYPES, +}; + +static inline int valid_fault_type(int type) +{ + if (unlikely(type < 0 || type > FAMFS_PUD)) + return 0; + return 1; +} + +struct famfs_fault_counters { + atomic64_t fault_ct[FAMFS_NUM_FAULT_TYPES]; +}; + +extern struct famfs_fault_counters ffc; + +static inline void famfs_clear_fault_counters(struct famfs_fault_counters *fc) +{ + int i; + + for (i = 0; i < FAMFS_NUM_FAULT_TYPES; i++) + atomic64_set(&fc->fault_ct[i], 0); +} + +static inline void famfs_inc_fault_counter(struct famfs_fault_counters *fc, + enum famfs_fault type) +{ + if (valid_fault_type(type)) + atomic64_inc(&fc->fault_ct[type]); +} + +static inline void famfs_inc_fault_counter_by_order(struct famfs_fault_counters *fc, int order) +{ + int pgf = -1; + + switch (order) { + case 0: + pgf = FAMFS_PTE; + break; + case PMD_ORDER: + pgf = FAMFS_PMD; + break; + case PUD_ORDER: + pgf = FAMFS_PUD; + break; + } + famfs_inc_fault_counter(fc, pgf); +} + +static inline u64 famfs_pte_fault_ct(struct famfs_fault_counters *fc) +{ + return atomic64_read(&fc->fault_ct[FAMFS_PTE]); +} + +static inline u64 famfs_pmd_fault_ct(struct famfs_fault_counters *fc) +{ + return atomic64_read(&fc->fault_ct[FAMFS_PMD]); +} + +static inline u64 famfs_pud_fault_ct(struct famfs_fault_counters *fc) +{ + return atomic64_read(&fc->fault_ct[FAMFS_PUD]); +} + #endif /* FAMFS_INTERNAL_H */ From patchwork Fri Feb 23 17:42:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Groves X-Patchwork-Id: 13569774 Received: from mail-oa1-f51.google.com (mail-oa1-f51.google.com [209.85.160.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E424146E93; Fri, 23 Feb 2024 17:43:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710188; cv=none; b=Oifi9VWst+AeuKyHA0CkeiI9s6d9UDP0VJlfcPhvCa+3anBfFaAP8KhVT1r+2dXEpGzcN8EOIp7y0cK/kWc4F/LpCt6YGtghF2inaSJ7l4iCKxJNwKtc4Rvn7rWI0XMPQpWEqRHk7+c+08zKfOIEVhIFwPsvGQ5/0oUlBm2m+II= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710188; c=relaxed/simple; bh=yRp5u9MQR7i0pHHhigFRLMC5jxEA/cmL4WRIc6/6wyQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Hvrwlirk9sQ8nMFNADXm5ZfrNc3pXGU4OqdQgMP+Spi3dgj+sXt4DiVck3MneobCWFUUqunfG29I4Elka2zVB3Z3jXlSJ2cw3ne7BDiOpOAeTE+6VvauW9QLRlpIvRwtguKGVdu5/6+CylgH7dS8bNGGrbiJplT8qeDKIpm3d1Y= 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=mdHUXzDV; arc=none smtp.client-ip=209.85.160.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=Groves.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mdHUXzDV" Received: by mail-oa1-f51.google.com with SMTP id 586e51a60fabf-21e45ece781so686304fac.0; Fri, 23 Feb 2024 09:43:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708710186; x=1709314986; 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=OHor3u3W+wuqia7Ht/WsFpCY9Rk+dRiHPG2C9ZesKqY=; b=mdHUXzDVJCiDjqYn0nPSeSTXTyhjUwBe9aEeIMkJVkGkRilnZ0qN4sYDIv+3y1LqNA UOES1l4aodgvqhBioTL4WImbTLyrZJ7almah4vP8g9lenuDGQP9AOZuj8Y8zF92FHJSE gJR20WV0WWEsGMahZaPisf33Wsr+B31CGGM0OfJE4XYAAi+34Ht8kBWk9LT4TMPpKdQT RB+8NMrbCLqQqxzVrXmdBn2hRDpESICgh4im4Mcjeu0DJKgZQgnl6qQuT0XGNWtXQYPe GM6s1ut0bV8K6M1k8YQzc/FT1+MESEkf2GJAGaJk+8cqcEIn/sps3M33xzRs953un2IK q5XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708710186; x=1709314986; 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=OHor3u3W+wuqia7Ht/WsFpCY9Rk+dRiHPG2C9ZesKqY=; b=VKVZnYnIKj+OQ9cIcTdRAtIBg0DzVz0Pktgq0aMKOM+qhgwfuk8LUwPgQgE6GxMtTE R2Dm/h9WWgrv5Nto+KV8tkgPaTqSdS2FQXaVKj3GkWQi5J/ajgo3VTQFGXj1mZ2+H93K a3FjEvTOQj2o/9F3r/XfmEoRWLZqP7VyLACPNKcadZdw5MLzmKL7rrwcvmKRVUoDwnyD E+qQhFk3uXB/1RmqfAYTatHUcjCWHy07tNSQ3HSsMAkfqSEglcO9Xt/2bCmavZCpbSki QeBZA5/UI/wSsJ57/hf2BR0XGY1jtHmkF+XJIGIDW8JWzNvV4Q4Ic5nx7MDg0KPFMm13 y+Ww== X-Forwarded-Encrypted: i=1; AJvYcCWYzS8kQmLIeMM4+GtluWcl9BRq4cESm+noeV2iSrAAgD2Izq0U8ItX1ixNSZL41p6MPOBw3SVaTzBC0PqR+zbZGKxRuSUfDQAmbqSQ+/8Njt2VqVi0dlH4vy978kzxSmYa9Z+FuDM5kFTJFwOQDpSCxUFTmGv78Ny1F9VV+9ZIlmVbnn/jB00kK5F5oEt8JPvP9CXA8EinkiG+Lw+Rz2e22w== X-Gm-Message-State: AOJu0YxwznGYU0GLLQFYnUNX7vYvw4Tfbbn8O/5p3/VQK67pcwYeJnY1 wVh4FOFWVQo93OpjqO9134TwqdJGaM7q79PzsVrqXk8Nu8/UK4vW X-Google-Smtp-Source: AGHT+IHNnKVpb62Lo5a6C8MsXucHX7a5scGCwnDEKNG9/0OIPbmHNqpRkF5qcIHHDdwtWWcx7RJCLQ== X-Received: by 2002:a05:6870:d109:b0:21e:e9bd:afa9 with SMTP id e9-20020a056870d10900b0021ee9bdafa9mr558439oac.21.1708710185753; Fri, 23 Feb 2024 09:43:05 -0800 (PST) Received: from localhost.localdomain (070-114-203-196.res.spectrum.com. [70.114.203.196]) by smtp.gmail.com with ESMTPSA id rb7-20020a056871618700b0021f6a2bd4b9sm1257803oab.3.2024.02.23.09.43.04 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 23 Feb 2024 09:43:05 -0800 (PST) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Jonathan Corbet , Dan Williams , Vishal Verma , Dave Jiang , Alexander Viro , Christian Brauner , Jan Kara , Matthew Wilcox , linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev Cc: John@Groves.net, john@jagalactic.com, Dave Chinner , Christoph Hellwig , dave.hansen@linux.intel.com, gregory.price@memverge.com, John Groves Subject: [RFC PATCH 17/20] famfs: Add module stuff Date: Fri, 23 Feb 2024 11:42:01 -0600 Message-Id: X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This commit introduces the module init and exit machinery for famfs. Signed-off-by: John Groves --- fs/famfs/famfs_inode.c | 44 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/fs/famfs/famfs_inode.c b/fs/famfs/famfs_inode.c index ab46ec50b70d..0d659820e8ff 100644 --- a/fs/famfs/famfs_inode.c +++ b/fs/famfs/famfs_inode.c @@ -462,4 +462,48 @@ static struct file_system_type famfs_fs_type = { .fs_flags = FS_USERNS_MOUNT, }; +/***************************************************************************************** + * Module stuff + */ +static struct kobject *famfs_kobj; + +static int __init init_famfs_fs(void) +{ + int rc; + +#if defined(CONFIG_DEV_DAX_IOMAP) + pr_notice("%s: Your kernel supports famfs on /dev/dax\n", __func__); +#else + pr_notice("%s: Your kernel does not support famfs on /dev/dax\n", __func__); +#endif + famfs_kobj = kobject_create_and_add(MODULE_NAME, fs_kobj); + if (!famfs_kobj) { + pr_warn("Failed to create kobject\n"); + return -ENOMEM; + } + + rc = sysfs_create_group(famfs_kobj, &famfs_attr_group); + if (rc) { + kobject_put(famfs_kobj); + pr_warn("%s: Failed to create sysfs group\n", __func__); + return rc; + } + + return register_filesystem(&famfs_fs_type); +} + +static void +__exit famfs_exit(void) +{ + sysfs_remove_group(famfs_kobj, &famfs_attr_group); + kobject_put(famfs_kobj); + unregister_filesystem(&famfs_fs_type); + pr_info("%s: unregistered\n", __func__); +} + + +fs_initcall(init_famfs_fs); +module_exit(famfs_exit); + +MODULE_AUTHOR("John Groves, Micron Technology"); MODULE_LICENSE("GPL"); From patchwork Fri Feb 23 17:42:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Groves X-Patchwork-Id: 13569775 Received: from mail-oa1-f41.google.com (mail-oa1-f41.google.com [209.85.160.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 1AA6B148FFE; Fri, 23 Feb 2024 17:43:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710191; cv=none; b=mSe+R1qKalQYO3lKzaIjQz5g/5hp3Uadc8ntUlsKZr/3NiL0kuPH6NG73HAOBtDXtc41F70zinKfxbouuEDqfLJBHtIZmFFThf/OSiCL8BKYzuMQrawMrD01F4558xpIzEnMyNmyT653FUeNmM+6MrbEowjoSq6tRPhQjqv//Oo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710191; c=relaxed/simple; bh=Ezvg1m83Vs64xk30SW6VrHXVsjwp8rUkX/UFmrsqfhg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=o/PBsx975/18qJc8Vpfe7zvUROT/G0WD4Kdo9lE/BvZjOzpG2abHvTQ7wLI3OijVE0/2ZyHV9SiZeKSHH2WvadKcaUtVYLORu2PtZBAGWSezmFb1883vGS7HPWxjNTB5DHs9RthlU/21pPz+gzpsrpuIFpBFZPhZpdvOo8WgcJU= 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=X7qQZgWz; arc=none smtp.client-ip=209.85.160.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="X7qQZgWz" Received: by mail-oa1-f41.google.com with SMTP id 586e51a60fabf-21f70f72fb5so627965fac.1; Fri, 23 Feb 2024 09:43:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708710188; x=1709314988; 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=5bZOoCwgmIQtQYNMOXLY20KATST0iJmwj9uPACUep5Q=; b=X7qQZgWzBIE9jwXC5zCeDjTt7OjUF4eYruUOH0k+3dTt4eaZJzZkSxsNIlRup5bBzI e5//3eaYPyue9OyU3/amXI2j+IDwxXQjeugPqAb1akZxaFFivwNTLtEaM+GefxbUQbu2 hOF3dGM4OdmeElbZgrp/h2wFX7LyhNvDHAPKCv4QlA4eEZ2Nlz453iBXdQnWt+wBNE46 cITfkdx0vlY4hyDz8n5g+EhKPgm0OlvGauC8ipbgOMyDQsvQ7nm/zPj/zKM6UiTAUknt Brlu2inEL9py4Fq01hAgxDDQyc1Qn2Hgf5NIfx/0N8uYUb5cwjvzL7fIg5iJOUt9I7MJ ZwPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708710188; x=1709314988; 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=5bZOoCwgmIQtQYNMOXLY20KATST0iJmwj9uPACUep5Q=; b=E9eOFVV5+3pT485hRcN5SvlUjUe157iy5XWr8Q7ZLuEzu15jB2EVNmdMofTU7+B1gm pQcMP18gVgWlV7F+Ui+3Bdm5barBseBvhiUKZDF6r4mzJ25Q+ApQxoWvZUrLmEBDfuZ3 gTSI6GbZUvsR1zbGeeNvXuMg4HrQQooCuw33mWHjw2OdYCoJ9Mm0ULmlIs7jYalZLB0Q vR7PqKzx4qPUIwfE6nJ8AUFxCPQ8B6gSy5x7ylWXdksNpBCdmMZQC3nhi3CsqMvYE0q9 PfytcfqQhGkLES2cNwr5lA7Mk9kFw5AfF/eZqmilgpkP/e4cr3011OqVV8Nd/qreZ94w FWdw== X-Forwarded-Encrypted: i=1; AJvYcCWT+C8AgbnYMeD/oKjDK9vHPPaWJovLj7DlSX4CN7rdfZxh/SKAIgDq7I22W2uv/MjFehN/ajiMLfCwC/w4rkkIOhsBPULdPgdc8CESJwdFv2td+QBNtVna06zP+A8169mGsVJ98rG9uaGumd9uHNuBe5ox96d5aiT1itwk46YiHsMN6GlqcUoBxQVIPEnTpjXoB7dMnRLtyaMPcG8BHN+qaQ== X-Gm-Message-State: AOJu0YyPC3P3G3tUAU2jWOHCj7P21zbJYLEcJIGQ6ZTJMhHv80h0DYjw ouLFkdgkWJDpwtYCj8ROUWhXCOo00iIR9rFHXZYGHN9ezXBmTTwf X-Google-Smtp-Source: AGHT+IHUEsDV7yeQRAIvTjc09WAn3P29Hi3DwkwU1/8Dctv6Vii+QtA1pfrR/mdognmcuCPTsC2TYg== X-Received: by 2002:a05:6870:95a8:b0:21e:87ce:87c4 with SMTP id k40-20020a05687095a800b0021e87ce87c4mr572812oao.13.1708710188345; Fri, 23 Feb 2024 09:43:08 -0800 (PST) Received: from localhost.localdomain (070-114-203-196.res.spectrum.com. [70.114.203.196]) by smtp.gmail.com with ESMTPSA id rb7-20020a056871618700b0021f6a2bd4b9sm1257803oab.3.2024.02.23.09.43.06 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 23 Feb 2024 09:43:08 -0800 (PST) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Jonathan Corbet , Dan Williams , Vishal Verma , Dave Jiang , Alexander Viro , Christian Brauner , Jan Kara , Matthew Wilcox , linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev Cc: John@Groves.net, john@jagalactic.com, Dave Chinner , Christoph Hellwig , dave.hansen@linux.intel.com, gregory.price@memverge.com, John Groves Subject: [RFC PATCH 18/20] famfs: Support character dax via the dev_dax_iomap patch Date: Fri, 23 Feb 2024 11:42:02 -0600 Message-Id: X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This commit introduces the ability to open a character /dev/dax device instead of a block /dev/pmem device. This rests on the dev_dax_iomap patches earlier in this series. Signed-off-by: John Groves --- fs/famfs/famfs_inode.c | 97 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 87 insertions(+), 10 deletions(-) diff --git a/fs/famfs/famfs_inode.c b/fs/famfs/famfs_inode.c index 0d659820e8ff..7d65ac497147 100644 --- a/fs/famfs/famfs_inode.c +++ b/fs/famfs/famfs_inode.c @@ -215,6 +215,93 @@ static const struct super_operations famfs_ops = { .show_options = famfs_show_options, }; +/*****************************************************************************/ + +#if defined(CONFIG_DEV_DAX_IOMAP) + +/* + * famfs dax_operations (for char dax) + */ +static int +famfs_dax_notify_failure(struct dax_device *dax_dev, u64 offset, + u64 len, int mf_flags) +{ + pr_err("%s: offset %lld len %llu flags %x\n", __func__, + offset, len, mf_flags); + return -EOPNOTSUPP; +} + +static const struct dax_holder_operations famfs_dax_holder_ops = { + .notify_failure = famfs_dax_notify_failure, +}; + +/*****************************************************************************/ + +/** + * famfs_open_char_device() + * + * Open a /dev/dax device. This only works in kernels with the dev_dax_iomap patch + */ +static int +famfs_open_char_device( + struct super_block *sb, + struct fs_context *fc) +{ + struct famfs_fs_info *fsi = sb->s_fs_info; + struct dax_device *dax_devp; + struct inode *daxdev_inode; + + int rc = 0; + + pr_notice("%s: Opening character dax device %s\n", __func__, fc->source); + + fsi->dax_filp = filp_open(fc->source, O_RDWR, 0); + if (IS_ERR(fsi->dax_filp)) { + pr_err("%s: failed to open dax device %s\n", + __func__, fc->source); + fsi->dax_filp = NULL; + return PTR_ERR(fsi->dax_filp); + } + + daxdev_inode = file_inode(fsi->dax_filp); + dax_devp = inode_dax(daxdev_inode); + if (IS_ERR(dax_devp)) { + pr_err("%s: unable to get daxdev from inode for %s\n", + __func__, fc->source); + rc = -ENODEV; + goto char_err; + } + + rc = fs_dax_get(dax_devp, fsi, &famfs_dax_holder_ops); + if (rc) { + pr_info("%s: err attaching famfs_dax_holder_ops\n", __func__); + goto char_err; + } + + fsi->bdev_handle = NULL; + fsi->dax_devp = dax_devp; + + return 0; + +char_err: + filp_close(fsi->dax_filp, NULL); + return rc; +} + +#else /* CONFIG_DEV_DAX_IOMAP */ +static int +famfs_open_char_device( + struct super_block *sb, + struct fs_context *fc) +{ + pr_err("%s: Root device is %s, but your kernel does not support famfs on /dev/dax\n", + __func__, fc->source); + return -ENODEV; +} + + +#endif /* CONFIG_DEV_DAX_IOMAP */ + /*************************************************************************************** * dax_holder_operations for block dax */ @@ -236,16 +323,6 @@ const struct dax_holder_operations famfs_blk_dax_holder_ops = { .notify_failure = famfs_blk_dax_notify_failure, }; -static int -famfs_open_char_device( - struct super_block *sb, - struct fs_context *fc) -{ - pr_err("%s: Root device is %s, but your kernel does not support famfs on /dev/dax\n", - __func__, fc->source); - return -ENODEV; -} - /** * famfs_open_device() * From patchwork Fri Feb 23 17:42:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Groves X-Patchwork-Id: 13569776 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 8B55D1493AE; Fri, 23 Feb 2024 17:43:13 +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=1708710195; cv=none; b=GNaLXzFLiAdEDIDa68fK6EMSDD7If9EONPB0bbriZCXeKeQ6UznS9vZqwbWRXAoEMKAgR8acZu1z/KhbvvDTTOabewwXLNQ6wBVn1weqajlSzZmFWxsGQhNVR/WI6hPaxwuUr+We79sVYQkgtukzT90So2rvTAIlCNuq+GD+PAc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710195; c=relaxed/simple; bh=VoCzY5krde0vG9xzX7YuziwxGBvoU+0AQ32A7C7kBBM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rc12CMDCscTPWgX+1xIacHHt/IRxMjAfBsgc0Hkn/JWbdHNrUsH9mJD3PnAT1AHgWE13pJvzY/Or562vY4kAjJR//Mu2Szgy0XdvkDNn90ZNyJfnohPppNEnDuK4pPbFl9TW0PCgZYpEzWKB61jtpPQQ1i8nemefmW9dmaOpJCE= 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=MvP0kNUp; 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="MvP0kNUp" Received: by mail-oa1-f45.google.com with SMTP id 586e51a60fabf-21f3a4ba205so420871fac.1; Fri, 23 Feb 2024 09:43:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708710192; x=1709314992; 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=+jGr2qgI9ixdABJ86GK3tMFCGdZwdm8K72HznrZ7mbI=; b=MvP0kNUpSb14mAbo43VKxIF8NbHNaIF7GNnXnNSBwAR696nVrt8w4RqepvmK+Nu/Ry 2PcqzUP18ZS2ogg3WAC6dRQSCXrSqvTi61o+mBfvx1HNXqPEbzFEiDFjvFymQ3xJH186 84UVw70m9E+pTE86Fs07aMYf/eaoC2Qi+gWMWc6CKzIvd8J2onHU3xPEi3Bd2AB2XTe0 icSmbQ9cgFQ+INpVWLomQv1yBvID3/8Q81l4MnfwaM3feGnJx9AFGXpzfRfenJvH2t6p NJfZKoRDuz5sjXwT9JrFo1txnkaOgREE7QBz2QvsByt3g1ldZPyBu6aWjwh1mpDmST8g vVqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708710192; x=1709314992; 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=+jGr2qgI9ixdABJ86GK3tMFCGdZwdm8K72HznrZ7mbI=; b=gU5oN5N+nTR7KbUSnYLtB9SSRXx5oMCBgP92zKLItkqLOD/evqlhqfDF7N4Bta2MA3 vVKWH4/SS2CbrEt+iYQkUIohsorA9eE1HxROON9r8PaMSfDSz8Atl5dGwwFsy9A2TaYk Q7wsnzEf7fcKD0n3p08QOjyU1J149M+F6zzUk277QDb9Okjntp/KP62786qAro7eTiId k0APv9diAx2LmTwbr4ufgpg53w3awThy6gIFZ9S6mw7+bpIu4bQSDYOZ8I/xO7IJAGb5 2O0C5Oc7tDpm2e1k00VDMAA1FWVZJ1dj6lDMChtjnaU7ftbg/tF56H7uvBfBAXnN+LBZ oZZQ== X-Forwarded-Encrypted: i=1; AJvYcCXGTfwdhLium3AEZW3tiFnpZyImCp5B7JReg5WjXpp0FAVP0Trf/fb+5J39eRQ8Bzbx3v6gQgwgm48bN3y2QnKL1w8A78/OxbMbNYnveFxh/bL0ZNbHiOGO86XsEc/W3DlfKgiGr+uEFlyBorSmVNCE7evGeci4YZ7TJast/GJEzmozj+b/B9kok/S4YyKNIMRt/koAqXJXLt//XIBLxeWxYQ== X-Gm-Message-State: AOJu0YyQI1lXqrSkglexIzLnlLtMi4lNN/vc96tiP4iVl1rvGh8VfWth TpIjRd96Q9gKXyGnQ5RGFYDuRZ8vDXOD/ekEVhmRZfUgTWxdNev9 X-Google-Smtp-Source: AGHT+IHXbrGyG5qkT8Cy2XG92vn+Onolbp2qVyL5iQ2JVI9EfiggCFq+5eaMS2dVqFrORwDcrGzuZA== X-Received: by 2002:a05:6871:431a:b0:21e:6716:65c4 with SMTP id lu26-20020a056871431a00b0021e671665c4mr576037oab.26.1708710192669; Fri, 23 Feb 2024 09:43:12 -0800 (PST) Received: from localhost.localdomain (070-114-203-196.res.spectrum.com. [70.114.203.196]) by smtp.gmail.com with ESMTPSA id rb7-20020a056871618700b0021f6a2bd4b9sm1257803oab.3.2024.02.23.09.43.10 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 23 Feb 2024 09:43:12 -0800 (PST) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Jonathan Corbet , Dan Williams , Vishal Verma , Dave Jiang , Alexander Viro , Christian Brauner , Jan Kara , Matthew Wilcox , linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev Cc: John@Groves.net, john@jagalactic.com, Dave Chinner , Christoph Hellwig , dave.hansen@linux.intel.com, gregory.price@memverge.com, John Groves Subject: [RFC PATCH 19/20] famfs: Update MAINTAINERS file Date: Fri, 23 Feb 2024 11:42:03 -0600 Message-Id: <451185e79c5b848d94eddaa3e778b834f7a35657.1708709155.git.john@groves.net> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This patch introduces famfs into the MAINTAINERS file Signed-off-by: John Groves --- MAINTAINERS | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 73d898383e51..e4e8bf3602bb 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8097,6 +8097,17 @@ F: Documentation/networking/failover.rst F: include/net/failover.h F: net/core/failover.c +FAMFS +M: John Groves +M: John Groves +M: John Groves +L: linux-cxl@vger.kernel.org +L: linux-fsdevel@vger.kernel.org +S: Supported +F: Documentation/filesystems/famfs.rst +F: fs/famfs +F: include/uapi/linux/famfs_ioctl.h + FANOTIFY M: Jan Kara R: Amir Goldstein From patchwork Fri Feb 23 17:42:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Groves X-Patchwork-Id: 13569777 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 8C21814CAA3; Fri, 23 Feb 2024 17:43:16 +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=1708710198; cv=none; b=suN0HGDBmrGeHq3rrKsvFkOoCg/jA5xXak06XRYUdUJEuo6kRK6GaY9cTJ8rCPgV7jwcFyUBI8dJqNGEtEu9v8IAj/Lhyc/VUMTonIOMAcTkpx78ElftIlmIo3i1Klz1aXFJBlSgQtuGUTMv7vY2kjFeDaWlkImWpDAUzF4BUzk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710198; c=relaxed/simple; bh=5E8ws1s3l5Z0WPoeTvetPbeYIJIcr9hUCwqUfntZF8s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UMuwP6uLuzKzYBGr5IaJmxy79QQglqb2fpuNzOL5Y/BvB13DuttO3OLoqIVlrduH9l2vZeBPfW8WvjT10Vj/NHPx/bkq6BfXnqqYPU5krBmcKEo8aDQu7u9c54vjoXBqYOiwKKkKXcFXbcuCCedvbfXM96iIXBTaWvDAUON2qiY= 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=B0bAx9pv; 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="B0bAx9pv" Received: by mail-oa1-f45.google.com with SMTP id 586e51a60fabf-214c940145bso280784fac.1; Fri, 23 Feb 2024 09:43:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708710195; x=1709314995; 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=Zu2qZWqnSX2CvxPOf8wPdAKOwn+qgMDO2ue/T6c8dWQ=; b=B0bAx9pvCF1D6/l324gryIcIkYjxGugpsY2Pr4HVR7BLnwlbxdL6UWrNrbmpGHeEkj wzA8x1J0hjuytXyRMUHvWH2be2f4n4p9WRryOJJ9Vhu/y+7vwbZywi6QNMKCjXI3q11R bvam7xwHBwNodU2b5UrzJFKIY089RXcHKSa4RAIFXPZjnVSyMh9oAdys8Sdi75YA1n8z /4emqswolk+926uXu6oMQkJMhz9JbNP/q+8xA0QmDLiWoeBpC0ApJsIDOhEUretjE+D2 c3aMOdoO9iM57YhtTtqwQq4Y5Pk2GNXzA3kl2aremxwriicNE9DtZOjNaPX554izfpHK TGTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708710195; x=1709314995; 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=Zu2qZWqnSX2CvxPOf8wPdAKOwn+qgMDO2ue/T6c8dWQ=; b=EHjcW8uLWcmeuR7wkUnp/2NMD9+1glZ5+y5zbhsu5TrO/6sQmhMFlwBvNo2xKfSb+T UXOligqjPxadd68qxj/P2WUdj+nMMnvbIC/5x595xP6B3jkAUG41lsQ8ygdenpO2bqNA GI0qiwYjVGKuU88Btom61PdmiXn0Aznr8vCr+vBFFKEvT+b1VbiP+Gb62yxtuc8qkHgz eiAKUsZOo/lDPRqjGcGRrMQUvIZCB89MJgTtx64CR2+z9deTXKi5I+yOrt+50DJX1eQH I9u2GUUKoc0pLlocP3YYR9/lP0rLCR2WiPkO4e31fWED+gsWOZLqxafieOacw8nx0g67 KY2Q== X-Forwarded-Encrypted: i=1; AJvYcCWQXCOQ25RkYQBC2sFY84KY310eSx/1Sp92fvDWh84Ka5XudqjOuWXvZA+kpAd3mEvq+5zy1msKOLcVhQuW4yJTGf3al52L1zoNZSyBwdvt9GjViTUrMM3q+RKdrzgoI0/ldJrYVOD0JFY2N4hTgveaMgIWj5z++5Bbh9z023Gu/IihjGuYowiOLIqDPfMF/Y87BRley3dMERsQTBwwak67Gw== X-Gm-Message-State: AOJu0Yy7PbfAMC0z5QQQ3l0GUcQ2NZ0TNis+xPQO3yMDfnG1RGTlwwYV lH256Tj/lcz2usCt3yaHotX62qc+4JbGbtUTlfA3jEivZ3oUsR+N X-Google-Smtp-Source: AGHT+IGYcgtz8Iy06lQQNWXgj+Ve6jWn51fNo3ZASvjNCtG6BLvd5/jrMrMZaBzsTgxAsVPTnEaAAA== X-Received: by 2002:a05:6870:93cb:b0:21e:4f99:d3c9 with SMTP id c11-20020a05687093cb00b0021e4f99d3c9mr406481oal.50.1708710195603; Fri, 23 Feb 2024 09:43:15 -0800 (PST) Received: from localhost.localdomain (070-114-203-196.res.spectrum.com. [70.114.203.196]) by smtp.gmail.com with ESMTPSA id rb7-20020a056871618700b0021f6a2bd4b9sm1257803oab.3.2024.02.23.09.43.13 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 23 Feb 2024 09:43:15 -0800 (PST) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Jonathan Corbet , Dan Williams , Vishal Verma , Dave Jiang , Alexander Viro , Christian Brauner , Jan Kara , Matthew Wilcox , linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev Cc: John@Groves.net, john@jagalactic.com, Dave Chinner , Christoph Hellwig , dave.hansen@linux.intel.com, gregory.price@memverge.com, John Groves Subject: [RFC PATCH 20/20] famfs: Add Kconfig and Makefile plumbing Date: Fri, 23 Feb 2024 11:42:04 -0600 Message-Id: <1225d42bc8756c016bb73f8a43095a384b08524a.1708709155.git.john@groves.net> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add famfs Kconfig and Makefile, and hook into fs/Kconfig and fs/Makefile Signed-off-by: John Groves --- fs/Kconfig | 2 ++ fs/Makefile | 1 + fs/famfs/Kconfig | 10 ++++++++++ fs/famfs/Makefile | 5 +++++ 4 files changed, 18 insertions(+) create mode 100644 fs/famfs/Kconfig create mode 100644 fs/famfs/Makefile diff --git a/fs/Kconfig b/fs/Kconfig index 89fdbefd1075..8a11625a54a2 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -141,6 +141,8 @@ source "fs/autofs/Kconfig" source "fs/fuse/Kconfig" source "fs/overlayfs/Kconfig" +source "fs/famfs/Kconfig" + menu "Caches" source "fs/netfs/Kconfig" diff --git a/fs/Makefile b/fs/Makefile index c09016257f05..382c1ea4f4c3 100644 --- a/fs/Makefile +++ b/fs/Makefile @@ -130,3 +130,4 @@ obj-$(CONFIG_EFIVAR_FS) += efivarfs/ obj-$(CONFIG_EROFS_FS) += erofs/ obj-$(CONFIG_VBOXSF_FS) += vboxsf/ obj-$(CONFIG_ZONEFS_FS) += zonefs/ +obj-$(CONFIG_FAMFS) += famfs/ diff --git a/fs/famfs/Kconfig b/fs/famfs/Kconfig new file mode 100644 index 000000000000..e450928d8912 --- /dev/null +++ b/fs/famfs/Kconfig @@ -0,0 +1,10 @@ + + +config FAMFS + tristate "famfs: shared memory file system" + depends on DEV_DAX && FS_DAX + help + Support for the famfs file system. Famfs is a dax file system that + can support scale-out shared access to fabric-attached memory + (e.g. CXL shared memory). Famfs is not a general purpose file system; + it is an enabler for data sets in shared memory. diff --git a/fs/famfs/Makefile b/fs/famfs/Makefile new file mode 100644 index 000000000000..8cac90c090a4 --- /dev/null +++ b/fs/famfs/Makefile @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-$(CONFIG_FAMFS) += famfs.o + +famfs-y := famfs_inode.o famfs_file.o