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: 13569737 Received: from mail-oa1-f54.google.com (mail-oa1-f54.google.com [209.85.160.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA72913248A for ; Fri, 23 Feb 2024 17:42:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710142; cv=none; b=O6bnu9hPY/UwYFj1aIuWljr8LL+sqe/IBpfDEo00B9thJTtcRytx0c3nt2mrmrsrPEC8xuEZbRUT/cVRYfTMkghxDUy1biCazo7m1rKGC6bCCK9wh9j31IHSBOlZO7VeBHYvBIPCPZlCMirIEcl9LFUzwJ2lhpI80ZmAHNOeH5Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710142; c=relaxed/simple; bh=GoMsVLjZ2QsC8jpJba4e1MZuvUQxhdOSn97WPVZGJsM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AkF4kIEwuVqA7S5OzyC5aS/OxDrTS2uM/eZLhjiqly0lKVITA/eS+GYiSx91wcb3mag6WTGckpYc+s8HXKGPyEXBuGwohTx1JOqJcWqtynnZduTg20GUMM6Ih2BdJo8PXyCb8+vhfdax3ybVBA3OuAM2mnekCasaNJzuQmqDwn4= 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=Ft07fLtS; arc=none smtp.client-ip=209.85.160.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=Groves.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ft07fLtS" Received: by mail-oa1-f54.google.com with SMTP id 586e51a60fabf-21f996af9bdso224990fac.2 for ; 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=lists.linux.dev; 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=Ft07fLtSytDagNEx2FOef5EnfQSoOfx+DFqSxMUeDRcmMz6eh7g96Vl44jKQ2dlxAb bGj/nAoI2W6KV5vo0aVMecLRCNZ89aYZ2POle49cG0Qq9g9n8/xkM+sa+duYlgUoKAX9 vxSwpNJ5IfOzJsc1W0N+IPHJhkWwpyId4HL5XnBGEp9k0gihR7UvTebPWdJgqTiYUN/t r1U/fn2VuVsX35iTUKgNlbJf7s1FYk4xAl7BA7f5d6tYt0oBp0LoAjNwqcUH1qJ7CHSY f1s+KuHA6UNZmtAnv/28x1rmWeBXBeTU0c5dBeHPNruToLWQCD2gnQ41KGubSz+CK3Dt nrew== 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=ewCLuOE0NDY76Y9ipo6cE/eu9gtNqRCXZ/8jDrdwnwsH6BduTUr6EVzeX6K0+PNH/7 nU4nBZj4vKnOrczBE44jn121l/cP9jkvLCCs4aRGNJox3p/hPYRGRu2NQXdLYEcbbJHz JscMOsWvKzDNOy2wLnAp1Z/I4m2k2GKrqPmsd58hX0uNJD2b14yrG96sxyehVEf1VRsQ 9Jxdqyv++ipFGYg/O/Hen4N4763YsZjfj0n6mlJfgYauIgIIZCJDiDri59CGtXcScZaZ qfP703QI4FNrQbOAjQz9TahGhbNHCpUdjUt9Hfzx7hfCorzKJqRzneDzX8zvkeMuCupz 5fog== X-Forwarded-Encrypted: i=1; AJvYcCWdu9DNU+LKrJHuK4NVEE4u0lzvBsrjI43LUzGE6nB+YyUSt3+/4PRLGZHT6Q6KbzmUncVIJ/3i5G9JVfeUucP3K3BkRPlS X-Gm-Message-State: AOJu0YwWq353XPFgQ1dficdK7vRMMAFhmeqP56zUi47pKdyQj+3CZTAB 3mF9oasQMT5oByFVYwjyQexsSUpa4rsmD9AjliG0QwYvrjxwytKk63LAkX+cD7o= 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: nvdimm@lists.linux.dev 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: 13569738 Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C324113A870 for ; Fri, 23 Feb 2024 17:42:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710146; cv=none; b=FD7JW9WYGP9FbCHG/WejfyoHqGvg+kNz2c67mgoEaBNgWS6DXhE+l+opEXjxNwHt9RGJ/o0lwmiRORuN//SJdLPxfaQcvcCUJHDqp1GHNsysRR6BK35Wnik8wmFV6OskH8/HVKLgljj1G/WxuIo8EXmGdPWkaTZEvmycMShip4s= 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=gxWv4BtY; arc=none smtp.client-ip=209.85.210.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=Groves.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gxWv4BtY" Received: by mail-ot1-f50.google.com with SMTP id 46e09a7af769-6e2e5824687so401405a34.0 for ; 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=lists.linux.dev; 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=gxWv4BtYleBqylRA41x4SvuyZ3vtcu/RAYjnc2m6LTg9QYp64cFlIeq0BRxMZ2CbiJ dTmKtquE75F72yqZ+fJxcJwuXSGgLrwbQVJeW4myNqPIXszgkrCRjyakvG6LyrrehBBf sKjVcShuP5TYffooFWFyCHf1QZJkd2zEZ04L7zB6GCkRwtGHtAcyz3YWv6PMmumJ20xT O9xs1/QG5Zo3yF0y5+CdYcv63sbQEFv4Y8tkIidHLZkXOMqI1oV6b4gJUiqhy4wtkEKx Rfb4lxL1UeUOY9JGfi4NfrsUW/jGwpdlVRfqeJqLJJ85AU0tHYUYr6TNyyJJsCwQs0B2 HXxA== 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=v9IhMPDr+aAK8MPAkQMPe1Ga95HTJiSdezmME4/FFJJcN4Q1bS7ZG7lM6Yn1ie1QmC lpBC9sK4aKSnUD41FIozJuNuHcl0q8La8eMS/HrGlPgK6iP9DLKAIkURMf26CMmyWKF/ jceBTe98nKh9NHfdLhYsazTAceNrHc16nr8avt0OglpKNdoiooFiuO7vUyoIczeM57/7 lPQpUlBO0Kgl6JK9PLrx5uILqvqGNZRQQdXdclOMvOXMGH6FPOOtlPIK3hl/YPcXBv0F YlgvOkr6CouBOwJq4CG1WIZNw2YnXkJW66MbFwqSix/5jhxpaLm9/Hg01NUEytZ1Ujnc qiYw== X-Forwarded-Encrypted: i=1; AJvYcCW4G4rhi4pfvpuykOSDl7ueEMQmaE2T/1lv3gKH0gROOvcpMF+fuNYS+XtFMdP/PgtRtZQwzNVTM/tuLeVhhRDzpjvVFwVD X-Gm-Message-State: AOJu0YyCqglVQi6ufmiYXPm+9GDHl14oQ8BJf4FsRNqESBBl7Ldq+jnj 9uTHIrm0hJEz5nBOcjtjcBPPX9le17gD3MxjXAWaIxJW72TzsbDRcO1IM2ai/II= 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: nvdimm@lists.linux.dev 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: 13569739 Received: from mail-oa1-f46.google.com (mail-oa1-f46.google.com [209.85.160.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2898913B7A5 for ; Fri, 23 Feb 2024 17:42:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710148; cv=none; b=YxFYWbOm4E8yse/wgUjXATyCov6ufXpvyUqnYOil76HbQkYKPbBIJHpBpMVI07hYlaMF5zD1UEcPFDgCKnBoOcCABZlAniuYJnK9f3fr0ccUPUo6wbcjh3oH30YLL8Y+Pkhj24uqJjS9ehdi2nIbpBshHvwMLh+KxxmQeQuuPM4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710148; c=relaxed/simple; bh=ZbfxtKf+CEH2wGLH6RSoWosZOiwKXV+zrcJLYgSF8z4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FElpCEywKzOTRgZfYV9yktuFdCl8MIB9M+MuBT9xUoi4GK7YaATsBuXRwTzZTzQczEDDFb1fYn689pXzIgbSgb4qUFtaRaTCKiSVJyAHBLI+iITLKgyUm/6Z4RokNXqiyAyG+yWtCgRI6p9im45Q9+2OKdE/qw7JL28W0LhOh0Q= 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=Wwx7JRwq; arc=none smtp.client-ip=209.85.160.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=Groves.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Wwx7JRwq" Received: by mail-oa1-f46.google.com with SMTP id 586e51a60fabf-21e8a740439so211615fac.1 for ; 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=lists.linux.dev; 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=Wwx7JRwqvlq7PUFBYoibOj1FhTTVi2A/CDikqpUXryizemjg9ou7bu4DfKFQsSgVZp ERqhDxEoI/0967iNKomReoQrR2kqRVY6o27YGIjPKIAnXPlZlOdv6NcpWNDjwrBSmwt/ R/PUrWJ1QEyiFuXJC/fKTR3A2SUuEdD+3v8dbid7xYdFSWDOI/f/91wVMxQmRyeHT2ov f9Cq1HwH5T6QKxFXzcVFsm2QPJkKQQratDkFSnFYqXFhkG/AJ8LuERojej62KrMq/Y6K GGUf0EI7Xq0R9p3sdzs7NYT1zcjDQeEKDFdq9w3h/RJf9F5B5F+RdSeE9uLlCmNbft9e QiOQ== 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=XUNuLQHmpmgTK8tTJT83BeNIINraAbb+7itzD0GO6nbCU2WiRhV3GV4cBONlmNH5GR qZtrY60n49IZN6KicjzR7f90ZUEHFG4P8oK2y7gseJqUBCcVBjhu595ELyU9Kd3P50+e VF0XF7Rzdez2lnVCyvCRyOLV/3eU1zU/yMDHlKttntCx4YHiI6A4DSRGPRgRd5OYA/F3 ETulEjJ7sc8BWEhj0LGbma6yNRmHE6KH8eJNtiT2zZJajENLKHiTvrJRS2Cb8KlnF3aV sFLqziiMSfe74Ia/N1KxyPslZGnl6OGJZprgfBfv0Y4eR5YITtgKol8gg6khxbOATo4I GmIw== X-Forwarded-Encrypted: i=1; AJvYcCXQ3OZRSjY3NFZCR89j94OoQxkgr0ANRSzWSqQEgVoX6NqE4/p53e8nbU7tvLdlehurDqa+hCtJUrBIEwB9jEw3yXKRcRUG X-Gm-Message-State: AOJu0Ywb0ucywvL3GUCk6vpad1cxlzjQggMgVzD434Lfg+/8sIR88DQ4 CWGdiaj2co0AnSigrbc20Tl2Nm9YowCeCEWyqgivuUcZ5pR53qvw 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: nvdimm@lists.linux.dev 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: 13569740 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 1E170133995 for ; Fri, 23 Feb 2024 17:42:29 +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=1708710151; cv=none; b=Fz+WIa6tojjQGbK5HUqMpQ/2WPnOwWl8twFjHfW0jLDIyC8Z/0U3XZj3kg8B6PTPYsuTvcoOLRoJFukfKZiM2e+DHTsNgZdNnUnlsQfPam9quNJMkxXEWRNfXxx2qc/SfquHViB6uRKJmeM8osJcTeMnYMzTZkcUMlIhRZnsKkY= 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=jpO6CQyk; 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="jpO6CQyk" Received: by mail-oi1-f181.google.com with SMTP id 5614622812f47-3bbb4806f67so386329b6e.3 for ; 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=lists.linux.dev; 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=jpO6CQykLg49v0ovCPfr4sjMzC3og8/f+PIclRxpsfhv3F27KG1RwJakZ4Vl09biJj asdJ36FC18koZ7+sklvnFldAmCgCGJ+4G1jF2hcuyUuhRVF1FJH9zayEa5Rjkwwfowx0 DM8U7LK9aDjswH9ogSud3PNFWhB2gSOB8cLBGWWvB/7eaExFIq9v66LiMIyc4upmDTeN BjdZ9FwgBDtvi3qj6loff5PUvN28QPxRg3z/bo5uAlsStw1C8vR+4HlPV04VnW+ETi0H kxuCdakqu9APBLENO5kSKWUA7KXQ4lmx1baeydnN5OU44GCi6sYR7rB8tvAwNW0wxQQC uRzw== 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=W9uTZ0ELq0lmH0yaZS5hJUe7/DnQrQx15iRmNjCNyCmW6RfShe0a+pRpjllWLQ/0hv DreEZUthQohcu1y7k6Xv32MT2AJcTIIGmR9y5SvabXG1xGqwkzhCnysnU0O/RJv8ugt/ DkFUw+aBftoa6OeUvIny76XSSz+M+YmKFKa+AK16/TTMTNZsh6vpWO2UWjeDnWVo0PAP SSNFLxfDOed0sf6qG2s7xavkkJLT7bYlqKafEtHodq+qPLKvKnbhtXbRdoStv6lbiezr Fx1rkljDbv/kAeHnLxpwd6jq9kOZ9IqeIbOMRxP51ZfVNPpVUZjJcJPC56WZtE9QCJnu VAxA== X-Forwarded-Encrypted: i=1; AJvYcCUSe6gIkQJy0QvmRZV3DYP6m+IUGXUDOnjPviuWPEYd9o1fmSSfSmDu1DzQzMCe9rbv9fhPV3eNIK3/SSba5PXThOIxohRW X-Gm-Message-State: AOJu0YzXkwdwwGbszzMBy5nhsc20dwCd2B/qJ8dXFmyLVGrVX6NMPebE AnNNh/uiri5vEd3wp87/GFnROYVaz2eYz17xGakFQFblpqcv3uyD 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: nvdimm@lists.linux.dev 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: 13569741 Received: from mail-oa1-f43.google.com (mail-oa1-f43.google.com [209.85.160.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 05BFC13EFEC for ; Fri, 23 Feb 2024 17:42:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710156; cv=none; b=hhEB9xU7nQgS3ZxBZsotJPtrz3+t0wj/cf5l+o1ebMxVykIM6JxRmLaPbpfN4t/HH/Jl79zTZ9IFrr919I5BR3mqXlipmaHPeJUR8JnwprUHr/2EC1zcFMTa2nkfX4tsktz2hV+4yythvnU8vYx9KJlLzsBJRrUR52UM+ALilD0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710156; c=relaxed/simple; bh=ONsam/yo/NB0rVpRcPxD7RtX2OC7QDpgecXyPCxVYcI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JvumO6ivTKQU4xUFp2RelLva4AfAwuP4eRID+5nL3C8M0SB2jZ8mu/h/vhDT34dm4JmpohMe6UZuXwwuF9Pw0pvVbpzv3RS9AsUF674CywV+c8Zv6Leq9S32zJjRdvae7cS1gMXE+WNp0FB1mPe8guRdDWCl3VzGFOBcxX099sA= 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=i9KTCYGp; arc=none smtp.client-ip=209.85.160.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=Groves.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="i9KTCYGp" Received: by mail-oa1-f43.google.com with SMTP id 586e51a60fabf-20536d5c5c7so778209fac.2 for ; 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=lists.linux.dev; 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=i9KTCYGprDg304lVrmUNhBo36q2QxQ+5BS4uAuxjXhDZcGas3LpbKPvThdfXX6aqRN 0DuvVLfqNFJJcbeTI1+dMcyv4QqlCB7FqxfroPgGkjJtiBf7iOYs//YXlky+0byHsIM8 0iTH9XZ8MqtnKAHz3NFdo3UJJZcWm9hdec4PVlGRTNhEWXuvM1345dwK/Hi4+kBusPwd XyjyQ4ad/t9QyUjLMrnAaWYfsvRkBZyggNnZ2doNXvt9N0FGHtxZHneOCbtSymHJDh9F wmZ3iivI5x8kOx5GguxioMIW6ja/AbsQTO59JrhW79Fut8bQPOH4A9nPYA0rZ8SqbKMo yDsQ== 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=w2nsVqen53DBx3DyeRw6qxmAMz9YthCbGp4A0iJQu7bIUFL625jjdGOLuHROMf1NjC uDTs+L9ug4FL9uMnPiA5FUD/G1Yrex7XVkAS2gNeBhvIoSh7K1zljo8C7K2yCvWNu9ZM aYggje3RJqUdeEOG4NQdREsF+GwJhvCYpIkmRg7MdLahMBmwjhhsN1aAmdpFUw9bnT8e UFE4GleAuHqLO/Do4ydEgx4U230aEhnMbA9L6YqWz5AtxkFjFCLIFynGh3o2bC5WSmUs NCJsvxLFW2U916sGeE9QpdyP+vs7ZS89AE0v1uEggIcK6b/OWBw22Ag+bz10WEr3VlPp RuHg== X-Forwarded-Encrypted: i=1; AJvYcCVBRGiJw9Op1tBOMREQSz1BkUHo1siGUEe4aI4w8feMGoQ5Zlf+4WWWKA0yg+m4Ls9ur4Z23JQQiT4whB2I7vQsl2JQSDqW X-Gm-Message-State: AOJu0YzVisrdJomYmvAEdlt8ZCr51QuqqKBVz6qY7XViRWyuOc2+xVhr rucNpmpvwWy1c1hNEaUqLZuITXuX0dq6RfUYUVbRPWK3q46yLDlE 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: nvdimm@lists.linux.dev 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: 13569742 Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) (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 8AF2113F00E for ; Fri, 23 Feb 2024 17:42:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710157; cv=none; b=i1yqhc3ccgzbI+Ra2Fpi604/dhrNREgw5u2oFgpTsdECcBTJ+17/yhgxj8y7RS1yHO5Cbn4iXYd14GAJg1LUcFKxDe4y4spkVP+XJtlqXkcOjPlX07c69DB0D39sXgLjE99myLU+RWe1T/urSI+zarhQf3M7dEP60gvnYevdRc8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710157; c=relaxed/simple; bh=B2obSwDEVHBkcnZehtnKyWZ0YBP4Jo3Z+lXXRsHPDaw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XhKrjNlRyR5p2qP1ODkRqmFs6pUuxvMRLxXEezI/E9xxrWFvH7WZ0c+z/6RBRDEw4E4FQJPt81ANGXHoLzucWWEzqo/HoWonFfN4+b78nNR49mPSs8U6ERL4YqB9FU15XePdVZSqvFrRWfwcYFfHiW3eAD3obzGullSYSoEX2B8= 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=WaUQhNd7; arc=none smtp.client-ip=209.85.167.178 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="WaUQhNd7" Received: by mail-oi1-f178.google.com with SMTP id 5614622812f47-3c15bef14c3so607571b6e.2 for ; 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=lists.linux.dev; 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=WaUQhNd7ez59BmrB4e6+wktf5cMTvbty61OG3PZc4cbMPBdDyu2zVxETq2zsQmC5uj aUrwJ7yAAwCjEfFNoOi/qMbgYTswj5h/D1VPGpjZx7d7onb+boDBvLdV79q+VI4Y2Ml2 mF3kww6l9CmWdha6HiKPfWvsHjgRnG17twORqPqhZheRBjvCM11yUgfS4pvCvQnAuF2b 0OM6VPrMQyVshv93L1gbHbAmL0z74owNgfTgJkCWM8vY22maEL8FbKLKPE1/91Yn0Fxt pCR3QmFUzP0lm5ui3NklPu0DzWSquUKJR+54Iykfu7dXmEjHhMQSKJ8+coUNlj8cyWON bt6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708710155; x=1709314955; 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=HO0WbSOFqWgCY9ELtvwGGsKvPOEOi+lnBmYl3D88ezJTF1lRDMvDJdSLq0a3zAGbot Ow7WeovJVfs2VxNeLMUVKsGG1WY35hYMu8M9rfYB5KZq9QJHpvD0U4Sfg6BUdQzVzone vKXDooU7CSMbkatulp2tLwQLCrnNhjfUMqjDlSIL84MSLyFL1M8pLKoXpb2GZ9v1np42 E3SOhNu7fiNtrFHODF0XpnFGNT0pjAux9fKuGnYK5Ecpv/3fNTHU1EaOBGSvfa5u3l4o Be3iIYrdDYoBZV7yNMQfFhKOvekh0TlvLvatUa9B8OE1dpBBQGSFa4h4z3ZfkhyuTYzn aYcg== X-Forwarded-Encrypted: i=1; AJvYcCWgQ858Um/F0+KS8T72pRlRX/6Q8Bd7VagtxGjGs19f6ngUz5ZL42w+ln/DawKI1TJFbFhN85SVbIJWomx54VRwyrziR8BZ X-Gm-Message-State: AOJu0YzRXQTdlTTssyn3tfHwB7MayC8u+i681Zlgk0xoneEOr83mQhld UDt+aaq4USJXn7GU6ftAjA/AFhVRaK3fXv/XlqyVmy7119ZOiy1P 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: nvdimm@lists.linux.dev 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: 13569743 Received: from mail-oi1-f172.google.com (mail-oi1-f172.google.com [209.85.167.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3FCA3134CE5 for ; Fri, 23 Feb 2024 17:42:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710159; cv=none; b=M6THpHmC4GDbbLHAXC4XA5ioKvdwpgK+kQOh80+9T+Ba3i7YGNpASZ9sJ8+HMgoboV3AprbnGD+yTVMiwn02RQ0kEkC86O3jwfHRX3G1tYlxj83lQMIle3ocjg6pdcI0b8GRqC4tAQkj3tuAI0usz54bYGKQQsrR4170GZuiMaw= 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=fl6NxP86; arc=none smtp.client-ip=209.85.167.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=Groves.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fl6NxP86" Received: by mail-oi1-f172.google.com with SMTP id 5614622812f47-3c0485fc8b8so732686b6e.3 for ; 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=lists.linux.dev; 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=fl6NxP86hEFTErGqYSt0Vr4C1+whIjVdoLbZReIldPl1xuo2hTNVlu3AfYjmzsb9df 8HUkmXVKHv5ml06vni0cYCoU5K7tr0O3TaKVCLjib5c5+7YRKYRiQQmXLIN0++PCHw2E ZODr3KtqWWkIzadUj1XdmCUuL6gZy3tSdQL28lMg6KEJPWQ4mPd7cC4nYQbdikVFRXSL 7xzVrH8zcoh2/XKSBrf9TApoDhnsfpUrJgVkcU9C7fP6xkARM1DNxBiVDrm07V/Rtl/D JjvPLehHcMwLZC4abjxmYTHLj4BCfqxOoIZ87X7OP8QowpcoOQaHps1DrQYJQB3tIIy0 b7Jw== 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=T8GsagmHaHaa3f9xa9wgsk8ZVMECirqjvdoD+aRbI1RHyi7FGS63+5gQtyCjSd4khN 8+mqjBQI+kBFPs4cnfbJ+CpdBj7L2qPUXHvdsuk7Wx7t2uSuu1EEQc5AaZCVwDE8fKr0 jZwjrjj2G+nJlCJON8JQCfc21Z9YHwaWtg0wMjOPA5Zr31V80gOJGVjJgkshpJnnWmMP aoir4FXQLCPc+XkvF772VWKjA13EJCVZk4v05XPIhutfep7JK0qr0oYNl1QsWKtt7XZj XwxlvGMxjtVvOIFhmFhhyNG2Jbg2mGyJn37bQT3rROUqki+4QgnWwsqq11zyAL6XaVBx oNsQ== X-Forwarded-Encrypted: i=1; AJvYcCXYp9csoIN40W/uIdrcQnEQMpiwT/AzRVi86mIHWGSK2WslMGr/WY0d/3bJOBwnpGAXdYUjC5zJX4eNlF/QsRhnSp7Cep2L X-Gm-Message-State: AOJu0YwYb03CtSGTaLOplqBfIvZ2xqm6S3Tr/0Zqj8qASWWzrAQ3RaGS WXuEbH7xW1hLiHMgwQdZx9rtiO170o0JSsRqiIkDm33fo7qfV7+SgE8XWM+82cA= 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: nvdimm@lists.linux.dev 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: 13569744 Received: from mail-oa1-f53.google.com (mail-oa1-f53.google.com [209.85.160.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF312141981 for ; Fri, 23 Feb 2024 17:42:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710163; cv=none; b=toc23aMRAzBhk98IxbwUVl6PdoQJ0nxsjtdq/Q6peXFv7BkDq55I5qKjXZ2gTBEv7OkKHVVG+5NJa2IjAdFMLVke9YviQEPjLP1jE7uN7wYe+51Kpbfit0CaKkKqdiLIMOu+YdcMArV8fhcANse88Ov3AIDXsC/M/VxLD9SC4yI= 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=a402c4Bx; arc=none smtp.client-ip=209.85.160.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=Groves.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="a402c4Bx" Received: by mail-oa1-f53.google.com with SMTP id 586e51a60fabf-21f5ab945e9so475954fac.0 for ; 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=lists.linux.dev; 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=a402c4BxLpgPTCdg8dPK7oXTCkyRUOAHTye87bjWZxdOmTAQiywoB3aZHJdH00oBw8 hTwciufsCZLd/g8qHfcDSfRQQC5ZapWz+UCKr6CvMsZH/OFlhF+SCRGiztW4dsOsPqIO NPRrx1wY7mknS+wKkKCgBI2GUeO85DwTeG1jKJ+3V7KWc4h3JYlTOOHFWBn2SptB/IBK ULPXVY87496xkl2sLAXuAQQ89KkyxZzIn16ZFbXwx61gO/Z0eUnjEiBYXc+EAwU03zN7 Qfh/VJ1N8G9DhRk4ir5/nA0hoqJy1+GkoqWg8MJ44P9B1SZxcqJk81tUCtBhhyy+7Muc LJUQ== 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=l24AqxdnmBotQCDZehXtuSyh3Jiob2J+ZFbtK5AErsFzVRIc69EC7hpRB7RJjrjWTL RgUU0fHUBA1etPoESJi22fOvr7YIR+ti2vjUzlcMAYBS+RibcEV9rJlclnS6R1NqtmJh +ydJRrbeqU3oVYkhuPN5G8/DNJF/6J8iuTOBHuu6fkrpyC0ES5N/++stEOvtFhHmp5iP PBhlq3x4ihRP/eBBVbwUsWCw8HcsNHlwe6vL8B4OPIizt02L3EX2nutSJun3BwM5nUIf fGyFMhPjkgClAPg0leGg2YNH1U92qF/iIRH6uZEyV7LJFI7TofdmCu/HayUhW3tJ+a6v TT1Q== X-Forwarded-Encrypted: i=1; AJvYcCXgF61Uzrx8Q5BjPyM0jhWQtsZHAYGWh/33Ic884OQp16iDzXrUBwsLBN77YOn7jeyd1Qow1NZZ6WOsC76ao4Zr5sNIoAkQ X-Gm-Message-State: AOJu0YzwZLgU8VSMjS0Ww72SxIaqbCWaS5DybeE5w8G3VOYhcTHH1269 9EYztuRLEx3JaGWdYgMCxcfnhYxacAv1yoqKa3P9jh/mPUrXDkk4 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: nvdimm@lists.linux.dev 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: 13569745 Received: from mail-ot1-f48.google.com (mail-ot1-f48.google.com [209.85.210.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 628051420B5 for ; Fri, 23 Feb 2024 17:42:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710166; cv=none; b=JrRZLBuWM0xlIhRMxHS5J3Oy+Xod4VxGH2GGJJy7zBMmpX88oGmmtP3PojCYBNuRQLP+7QcqPPtkOwKitf37ujTAVV1ccZoGErQyr2kFr0PtUNJhGH1YTUOqhMC8BhWrD4plj/MntHJ82eMAb4b8AeZivAY/I5f58suJ5nAIVZs= 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=EaobnUEI; arc=none smtp.client-ip=209.85.210.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=Groves.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EaobnUEI" Received: by mail-ot1-f48.google.com with SMTP id 46e09a7af769-6e4423b64acso496916a34.2 for ; 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=lists.linux.dev; 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=EaobnUEIIX8pjufoPSVeOFW97jUED0GdZ2PQgFM9SSvIzEa++jI7sfZEbhJiNrvoEC htgs56eEuMXdd8jqJjMus/ZALACtzy1HJewtLcwZ78Nz3cgP06Turp6aw8TvAFfscZPD AjkO0IqxgRHfEVGyODkCj4Zhnd6iZ3mPxsGMsvWfHyWAvZbFyJSD83ApMyOBhttld7Po ZjOzgj/RV1Q2+Uhh4g1ppfvl/khw7+9ffE+4oHXE9f5xR+gEedfIv6pf7TSJoj1FOfqC pdQv1PuNbCVFObI+g7j5tmWcyFzvAPtBtPXMQp6t+6hk4kxTb4ZUUO7l5bZ+k8IpSwvK SDYQ== 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=b1q6V58O6raYcOwXU2PDpqwGm7YqccYQ0P3WW75xTl2W/470TztI7D576+hjkrgylk phn0U8Nb4i+XAr7k/FbRGuWoZi6i3637LzLkSIpUTLa3kjYmE+kXICxwy/eW1gZXUSjr o+HBjYRC9jSnForsNRXtQjPK0jgbwsjoZM3CtRP/26tKlRAyjyhtl9YE7KMcAR/dm49x k7Mfee1bl+Uy/3vpZ+9TTnEFqijs1BSK3FPkpeN8W0bXVDZNT87Epf6+nYX9uRvWwp/w M4zuuBWdIfEJIDyRhvZTJD2urQWPOoDJzGDj9ksjVA1QyE9cQKwxPLwYmwvfnS3iIrBD PLoA== X-Forwarded-Encrypted: i=1; AJvYcCX29BxXpekFT2aCAyVoqsC0t+CS1/zN5xwR1EZ0REKefmtgSahP+vjx9pVVWy1bM1QOh3KRBUxWY/jBp889oyUa3M9a4bJb X-Gm-Message-State: AOJu0YynWZEXQJ9lFRvpD87qaLb1DDL809NG7AvEe6asDFj4JYdCsfUZ efdgLtjvBljlFmFaP32QqcRucptFw4sUCBwND1/POFbBn24DHIJQ 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: nvdimm@lists.linux.dev 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: 13569746 Received: from mail-ot1-f42.google.com (mail-ot1-f42.google.com [209.85.210.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 08A6014262E for ; Fri, 23 Feb 2024 17:42:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710168; cv=none; b=V/AQoerDkAHkJyTLrFT5xiyvaL8iOX5Q0vzdlxxzTia5MANu6vaI+eIffky31r+1ynBzihPcNE7kGXGL2S6C67Snki6CWMN/2L8KLysu1UesXkKB5AM8MxohazWLW0K5iinWONtmn6ntIcyKb4YmHiahBXaiC+59anTfbUVyYmI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710168; c=relaxed/simple; bh=srzo99OmjkDCUvG5svVH4unqtaTIPC9o374VcuR+GuM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JCGXhCZ0ITc6w/em2mPbXdfReXFxMscbEoELeSs5VrSQCApZMzjHBHiRyX1BOICV9Z8UNmoMtkPjqquALifJyv7FbyVbKwjYU+g49me5nathcrJ/2kLp7PUxGwPJgWAKPO2smXfSSIQVfQR81YC24LWTKy5+0H0kyWullltJmJQ= 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=fOE4xswE; arc=none smtp.client-ip=209.85.210.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=Groves.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fOE4xswE" Received: by mail-ot1-f42.google.com with SMTP id 46e09a7af769-6e4899fa7f1so93872a34.0 for ; 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=lists.linux.dev; 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=fOE4xswEDuXjPJLzUBIf4EExXW05fDTrdnBwX7aZA1iKo+tpo7sjoPrSxInrxf35En h9uUrBrzPCal4J+IciTw2V7qLJLa2hyOQCMJur70u31xefdIaZxwxbwqURA7L/TRRf6Y 5at7wXvdmmxO44XVtktXwkRwiTbSqha8o0VESo3SNQhIzGjuggwZksRe7/hObzMVpdiJ c+5f1OVUGHMD254YTsFMgeLhX23IWRMrHqYbG6uhOWSIVw5yIX0y8OoT97ARxsHYIsnU FHAJeQHpqzShDebqpWDTaiolx9BoeXStj/TNaxJELKHxZ5x4C7+4qC3Xz9pZkPRRKjrE GpAQ== 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=jkSf33ChHNABcQsuEZVkkhO8PQhnHEcsj3FYBqwZ7auJGdIhquY9pLcfq6m52TXeOD DNe1EN8SxMMEP0vkyLLyy4yHrIEhH+o7enYBDdZHP0RhyQcMDPfs+fDmovcr+GXdfSS6 QM3nP6hgmkBsncOVkc4fMDx8kgWC2FQv5KMOKB5Zws/OtQVfLDn9sTdnDy9vqPgm8cv5 cQXRoHTVarTwh3ZwmYMVJrHRWtubiibX+mjy3yYxuS8hXJWXb94Eax1E6pakqkBrlbkv oZoEN0J4+PA6wSbYilWjq2jIqX7nO9XQ4DKcVN3THbs2qJP8bIKNLhdZTcDM/7QpnlFl ZXUA== X-Forwarded-Encrypted: i=1; AJvYcCUOeGVWrwfaBCKmXcFI4xZ67VIPkWcylEPnEbxCPJ+EQCh6NFCrm5eiXW/oFJALbfcDzAEVJVpzhZM8+ORpWZb7SO1LeHAO X-Gm-Message-State: AOJu0YwrKjlUnD/mcDgr/jpf8V76ke8uIBeF52tMI77r0Yh7NeTRy1xF xeNCAAWyn/9ZYyhijz/eNK+/pRp1Lnl8ORe/2bKJ+ulNIdJLUlGr 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: nvdimm@lists.linux.dev 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: 13569747 Received: from mail-oa1-f54.google.com (mail-oa1-f54.google.com [209.85.160.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB823142641 for ; Fri, 23 Feb 2024 17:42:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710171; cv=none; b=J1vkF3EEtnSYUq3Kg0y6/XmpBgYWdQcxbs9QqVOxqhKXnaKdXuiRMTVXSIFdTboQX71lRV9q5kojSNgAgfZX48JcDh37g2jpZegByVTB/k+wm6HTJ1nJu18tWM/0+QijbyWeFi0o/E8T7wF/f2q8i8512+zuaiKvp0cB13d5BMU= 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=nHRfnyYz; arc=none smtp.client-ip=209.85.160.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=Groves.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nHRfnyYz" Received: by mail-oa1-f54.google.com with SMTP id 586e51a60fabf-21f2f6a1035so616161fac.2 for ; 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=lists.linux.dev; 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=nHRfnyYzqMTlIy7oaD1zNZgRSXa1aK5lGyow0pFFlaHH87qSJ4UtEzdMTYL+QQTuY9 DiaxuojEx3hm/YImvNxWbVzBjtMmgsx+7AXmUoZa6acbtoHsLvWMr1uSqqd38PQrBfBB fKJgcFHEVB0BJw5ZxUWL6m++FGOV2Ye8UzzVbeJhgFR9nlijhkNRD3Lj2onvrQXlGpeF qxybEhiluFatQ+F0P+ugh8rCAVbXQhW4WDdRsvHwzDn5pQ1ZQ7JE9Nt5tRQ+rySaYaJP 75E1S5/Snng81OtCKB1XQ744dP6sqPzWorYdhCC7752nH3n5zUSo/B6l6OsNyxY16eZB zALA== 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=nKNvKDVIl5RCLZfmZ2mb+l0kzivKqJWXJfIXZeBaMa49gHQbIL8ctpEf+A/PL69apI gNLzoUJrXb2Z2v40Fs197grDCS9crMrowMP/dTLjeCoKJSLXluSCNeDlROf/XQJZcP5i sF9nXDYQaP8zEfoAc9LJgL2T0UaksAt2xBmLw2uCiThg5CHlu/xDw+4VDJ73rBtD9nkr Mz8mcJjrEpCSO2GeULl5U2gAueDXxrl2ZgySWM7SnlL1S9TRw3cC9VR5+UTdWa7OgO45 q4w4WWDrKOyseyeiUk3kjwVqcgl8DeKJfiSXT1xjo4PlISf01TKfhSUQ4Vmy436ORivs lV7g== X-Forwarded-Encrypted: i=1; AJvYcCUcLHmj3Jr2+1WO3xIrW17631T1RS3nKVXxut4uS+/GC7vZepoM9CHMlLpo7W0v92HFKMrbCASWG+r9qOSEAbt3+DREsJAp X-Gm-Message-State: AOJu0YxTNIv05CMHhW+SMD46cEWi8uC4HJA2RPMjNLIsk4P1R8E8L8Dj QgTaPiKkoosoLhqNdN8BgKj7M+WElvoi/sK340BBBO3q2oloVrDd 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: nvdimm@lists.linux.dev 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: 13569748 Received: from mail-oi1-f170.google.com (mail-oi1-f170.google.com [209.85.167.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ACE91143C5F for ; Fri, 23 Feb 2024 17:42:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710174; cv=none; b=qCbO7dcXwV1q5TQ6f10EPepFkQUTwjlA4CMGa2ZD4ZZpg8CRAa8QBebCvSz7SwHKM5j4p+1jpeZC7xKgCF5ze7XCtyZhFVgm6UGVH4A/B2fb2j97nysabn2cc6Eeo3CbIT+p/XAvLn0GNUBXCddFopsTxA/Prfnt3WiHVmw6PkI= 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=YAcCVO48; arc=none smtp.client-ip=209.85.167.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=Groves.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YAcCVO48" Received: by mail-oi1-f170.google.com with SMTP id 5614622812f47-3c13410a319so701462b6e.3 for ; 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=lists.linux.dev; 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=YAcCVO48cUCPXVEINkjFwgourq4xofqsPntsUwpcyvXOUCv5qxIO38MMAgfKa5fb7N TIcE0SSdMuiV8AAKFuw/8WsbdP2uV6gr0jEf/wODegZghBGPx5Di5/iXYjypRmz9aFty S4YMkeE5/8LE/IYXypEUw4PIwc7kyGJyh/WVxDDfZFKg9IFDsafo8staCZkwlKPfux9E PbYvxwI7K4miTyThJsu8crF32PB2ADBCTjlYVWx/WTQOnR3hQ3zvCZMHfCBADzdLw8ER E97+3luT3ZLGKBAsP4uFPjSR/ja4Cajjq2dFIgx15G7LFiB59IU+Ga9nRpJDormBMsa4 6QzA== 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=mhLAnmvr9WYmpILyCk4u5VTfDZG7TzQlcLd2GSEovOkZ420ujZKnxamR0Iofd5nu93 cxnuUDwL86nZEY3WJkuwTgjFM4gMWpr2NDANkQG8Hhm8wBPaXocyWE0rtFemmzztAv+h t59cNNeSsFyfb9j313S9zJ42xNLtvSvTCLWRks6kA36aERej3YkkrTOu9dsai5skVjWt GHQ23T4Z42KYpSR7bDCy5PO9HTt64GGTcaGjK5kXLphPIk1BMWCoFHtvXTpSk0Hzt1ML RQUgdv/DmiyT2ogJ4+/B0MY8qNe9F+2wF7npi3tOoVaWmirzJxo8TBOuNPsb7IWcK1VS pIlg== X-Forwarded-Encrypted: i=1; AJvYcCWy+PRMlNId5BKriyNSX3bg68+HegILEmOAwH+JHgwW9losM238RrG9Z8NYMCDM4gcmSOiXEDEqGTK24eYJUX1mMsrwFGb6 X-Gm-Message-State: AOJu0YytAtZ7p5b1GERAhLxEAd2GffSzlu+kil/4iaI9gytNEwJBTIyC KUz2+YCrC9wZTT21DwLFWKs3q+3/yUApZzz39U//KWeV/nvtjZq/ 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: nvdimm@lists.linux.dev 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: 13569749 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 1992D13A27A for ; Fri, 23 Feb 2024 17:42:56 +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=1708710178; cv=none; b=DIn2sXL5Zdoo4OkIj+BHkmFuUyqtnkyXpzS2GDA0rmOvCLFBvIuDylmAIkqTEYl918OHTXhpNVuF7uyzsjQMU0kwu1W3jB3eJQTL99rd4Qh7NEh44JtG8QGbD7R8sXBTRjbNTfUxwdqsmuMlv/fsydaMeml8/udUXl+9rivbDl8= 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=Hjffp+fl; 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="Hjffp+fl" Received: by mail-ot1-f53.google.com with SMTP id 46e09a7af769-6e4875e875aso166122a34.2 for ; 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=lists.linux.dev; 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=Hjffp+flVNG2hu1n2i6ktPXlJYjaqtG5cRSyupqhzakMQ8ONJmsj43s3H2f6c7C5vp mrsTlQsmEOx24oW2g0T0oiv+XP0Hl8rDB2OyEz7uFYRgqNY+g2//vpqUNmgXYD2P4rd7 E7lIo0/vQXH2jZO/8J4Y0KJPkOTzUa4L45FvTDBy2INCj+tppRhpLElx3JpXyIquC+aq iK1S0heNM0zcVeuQjby+Itnv7RdXH3SSXbLdQ8vDoCsh/JMh5kMKCGBoHURhV7BBW+F9 cFx/gkts0dH+uJ3bAFUUENX2GJ9Cs/5H+Yk19xryNn9sRjhA1T1ERKu5bTW/eeIsZqTC pv3A== 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=RMPqmJ95vN8ymgRIsUs91qyAhPDbRiXCpN8rGVRlPXeVyQ4zpyyw6XigKTMyBFGAIC 18kVKxsrvBVUod7tUJwRdDck7TK4LVW3v1U7deDQdEssYPojcruqouo9HPp3/yGlRpOc RaHfmKxqoecSCe0/sARVwBLTr7xWkItlhGEX792iecIyhs1MyWBaFBOXT+tF0fCUXWd4 qn9nCyUXGZBy0Ine66y8iI1AWeWZTktPiaKR9GNIMq6D1HyMVK2kGZ8VXOSV7qybhpPw tgFXziYzkp80jC71NCTsPFiT92dikAMfs/3zajdyGcj38pz96FkII77EjjBYMKtWCNtb 6Hng== X-Forwarded-Encrypted: i=1; AJvYcCUy03UZdIJWzkfXqilYBzXcSPdG2DOU4cgxy6D+oHjnKBEeA0NL0rHfA+g3SHLpgdxbaS5xcBhJ6m02HAdpCG6XFOf/l29r X-Gm-Message-State: AOJu0YxN2qzsR42V4yuacGDWRmoeGqvR+EAlOz6GjLDvbx2wK2e43pJe EE9YIHhjAzYvrOp/AQchm+0EAYlbekPys+vcQFkuZ6ln6B0rCuA0 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: nvdimm@lists.linux.dev 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: 13569750 Received: from mail-ot1-f47.google.com (mail-ot1-f47.google.com [209.85.210.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD5DE145338 for ; Fri, 23 Feb 2024 17:42:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710180; cv=none; b=d01xWXDKBu/YzF4zrEChWslXXdWiafG0c3K2Q4rKAxclWg6B8GcgOxDVxK9a0Y9AjSuAHVKnTLfnhOsxp+H8s4dLm87gp1kOidwzPUPrh6Kw1U3zWM41xsSTaTQq+t98BmRKgMFvIZ7W3n+kUBJb2+BAHZGpnRtUJ6Hi/zMKcNo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710180; c=relaxed/simple; bh=jYmxy3JFMAN0mad3tJYaUDo5JWHwAqTIs9pH9XFTFKg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oWVVoNUuTg4s4o11fEFHno68vuzAto2oCUrfAM8suvPWdo6C0NM4ZOwovQALbb2WEMZhxh2+wrYTPQrS/ISD7X7/+XXjmiRFbqNtNvThlWpcoTDJx6NVLJvcG0mZdFaRebVrAluBirmIVpjRmAKHaIc9AZz4XFK/0iLO9VgPJbU= 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=KHISop0Q; arc=none smtp.client-ip=209.85.210.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=Groves.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KHISop0Q" Received: by mail-ot1-f47.google.com with SMTP id 46e09a7af769-6e2da00185dso497567a34.1 for ; 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=lists.linux.dev; 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=KHISop0QOGs1tUqiaCNHLXORSyI+iK6uov+Gbj2SYo0QcKgVI9kSYCZ7W9vllLZb+/ phTBHdHustr4891iPI7FO3HqgKbdu3yZxRLlUTVTTnMPSTbK4gehmJerLhDLLzdmcpxB +EiEmJL1WLSNBGE9TRZQqgmjBnlgE8edmHPt6o0hVfBPj+ItibednQVGOEkA1I+qLWHu 7lj/cuvpomBXeBle5ETUVSw9oeRfSDnsrdNHktjCor0pq0kM/BPqWgeqRLxxx8PVnzEQ fwJPZOEYvAnjpyhHNbg2k5j4f30PaSWVoN8wV1T/0CPuxgomJUwkoUr4ZoV1wm8CxWmR yQtQ== 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=DOl15HokxlluDIk5Ylld7G6eAWoKP/l25eVKMhpAxLiFuSfAmw2FtGgUDP5A3UgyXw tOvk+2Z892p6nQQ9OsvzsO+9KjmIz60lVe79N3NjfhIOQMCOFagTpVSSd9Io6ey9zgEm fRGknwhoJnb9Y6LStHDjHTPvnXIUdrH3Vt71ybUVW+h6qSMHs3ttYhdCS4UKq7bfCdSh yek9FWmhPKT42GEQbq4ieIjWXprRRPkf/wWDcUVB9K2v1L9K9zARJRYEpadHd9QrEQq8 pWg3vVfPgF5UyXFWWq8xZT6k+lAaPhckJC5iGZ12RSxMm9juTCoJrsja04q55pAtSZth eZjQ== X-Forwarded-Encrypted: i=1; AJvYcCUbEGVRGyfJa4npDVN658IOQQS4bfPE9OSdKOGZwMVZnxNQ2FMiw2WAfabGLdIdiBSEpa0cbiVWChUnrR0GzkrilZ8qbpj3 X-Gm-Message-State: AOJu0YzJKevfb1ivjLeLrPjk5fRx4RtEh75OtskIbrVOflrmCwuUZ4OT FQxXV5P5fGkor7mORKuVLD4Nh8CYsmVjlwuJID5sK7REMjmv8Tcq 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: nvdimm@lists.linux.dev 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: 13569751 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 85DFA145B33 for ; Fri, 23 Feb 2024 17:43:01 +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=1708710184; cv=none; b=EcGc6rKmSWJmPWfiHQE80SH2ut1kksgSW5E8SM7WgRu25E65X8aAps1qSEfJxAT+TXLtvO63ajCi0e6R48EvT2Mx+eO8+0W2i32321agW4GBZoa0Q4MssCDrwoSBju0wsP1Y1o1igeIuOayOBB6p1nCbLbzYxf0WzUIAHY/eTjE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710184; c=relaxed/simple; bh=gfDqrv2IB8dGuNuxnTRTAgf83rxue/Tl0NVJJQh84Bw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kAfTevrRaZqicvdPCdpavFyC70D7E+lue2nrGmeFdMZN0zBHl1peZGDMdDwNpXgqY0CA6wCpJAtXDpMKR51CtR6PgcfaRqsMJwVy/klP1FwYnorRiPx395gUhhA2KV+5xFqqUHyteqV4860zDBomJ6fVqMxMdrq7IVbLvnIKqwU= 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=S5SpdbcM; 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="S5SpdbcM" Received: by mail-oa1-f42.google.com with SMTP id 586e51a60fabf-21f0c82e97fso713819fac.2 for ; 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=lists.linux.dev; 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=S5SpdbcMYSuMqTaBEO8++1XDQ4pWofOTX1l96GM5Oy2h73Zx17COqYWaZ9bZ97WsOV l2qpLYjFEuGevsBbvULQF0FAyhcfjnv9z0aadBdFm0pU2xMgK27UMo1efm52BnU+SDBs a13hHuOkCH2Ty+gagb7lUCfGQY1xsO9rZWe+wckqMzaMCqbyKlg5SfLH8T5f3hOVFilx qpk9AqozqTFUBT+nv8JQw7tDtpAlnP/lEB5aoqlX7cX/IS5p7fKIEg24ziJTDEZldD+o RevjHmLUz7jKK350IsBu5Gly/Hr4SrQqoSJL6BzQDX3y03b1f18l7lCndtgbqTC9C9EF 2HDw== 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=JIsKsBXzNkXm924sOZvHGJ/maEgkrdnU92b36iT/XtcTvMZijybr5rRKopeqxtplvs ha8rffk8Erb60ghBVzZt1iWs1KJgPj0uO4+DAWFgrnzH2t0n0YTJZy0jz0FAJXi4nDno 7xUo55nEHbmUPDVtaelXL3n35hWQqd89Cwh88kS0/IlwA4pc7cSjQi7TEeyO8RvAcguW Y0Im53w6rMYrgJy2Z7jExKxStc1mkJoSdvQYMWeiieZcZ8ZjT1NlIiR5Ar/O3/tqrNN5 bTOGLy5ykf/o3bdqSjrY/2rKBb/gE6GsWW3yMUcIfEf5bOHlHKL2PbKETJSfbkkuiCH8 64zA== X-Forwarded-Encrypted: i=1; AJvYcCXakxwruBbJvIQz2N+yieRmwwietPVAu/m7JIEWYocRQfnEf19lHxpb7Rtwl+jMFyMjLdkUB72vLxzfnTIwZNnv18Y2ekyO X-Gm-Message-State: AOJu0YyruQfF39mkp/AK8TKQ+FBHDj4S0FX59skoHAwTVKqkpWZDwV2z GOfREWNcWY8h1gIuvaGKAqfpfOiYikySxmbvwe+h0KInBomRk4kJ 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: nvdimm@lists.linux.dev 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: 13569752 Received: from mail-ot1-f52.google.com (mail-ot1-f52.google.com [209.85.210.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF2C5146E74 for ; Fri, 23 Feb 2024 17:43:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710185; cv=none; b=UeKHjn23oWoCSlrCVSKPe7ggSzC/95Oos5wkzEzWuGpwKuH+MD1JzBTH6dQUJWBfuzWTdyX+xlpVZFsOT+RjDl6OxNERubWIidFr6yX+pyon5zRnfpdJS4ecHWY6gN7+jUGS6YmyEwJOKX6ug1LlCZKqoEJfCMEhuRnsCHSQ5wE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710185; c=relaxed/simple; bh=fyP1dnJB44f2zHUX/KhaAT1o3vyBlQVFBHhanjGgGrc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mzj1mCVE0a7Xc5j2H/TytiX7s0xZCwb0d5BXcCedny3eRlVV7XnWOtOH/zFn/nq1pm6oVK1bOWDDICUuWM+sup7hbR2S5tfswjfKXuCTAUj0izhqC29fGZO5E2pBCk6Ty4QVTfg+Vle4+Eg6HzU3Ajnbh2G9bwl2n2RJxxLXZys= 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=Jx9WdpGI; arc=none smtp.client-ip=209.85.210.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=Groves.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Jx9WdpGI" Received: by mail-ot1-f52.google.com with SMTP id 46e09a7af769-6e480af11f2so364723a34.2 for ; 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=lists.linux.dev; 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=Jx9WdpGIdqbAd6dL8cr90HhOxfXyX6KinQ43LAQcVfyfe17pjUCVqAV6jwd1vtvCz9 0btM2y+Q5XadHWNM7FRh3p85WwoyjC1/chyYgDLIH34q/vKQCmA/wSAyIe4JluY8GtvT wEgF2jsLA4gb2o5iaTHtECMl0xB+j4VRbea0KMnhZSmCXNZvjBU4BjkFCdErUwWzhPw8 OJ5sjahQlr+UnoFZenvoA2ydWwWXBIr53tlbzC4DLHQ2jhouRPrGcXg3Aah88MYIWR9a JLsTlGW/U7OeJCQuQySgokJsopAr9/sua7MhPh4Q69ZwBUQCLhYZwEO4zz8l0HvL0k+G 5wpQ== 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=QgLS8d1Fx4+exmfmCyHra35kP0cunYhiAB+RdavILk+aZMXb+VFXlqIqY4r3bgAja8 M6mNmEGv8ApgXGGabOvdq5OrKSwELYAzEmkA4CxEDUoSLQ+mHxT6Sw66Qko3TG1+CQr5 nO6k5E/SHuDN5OwgC4DUz3YHRmqyyh0wEwV0eT8gBYdMqsaOz4ok1V56Hm7R1Xl2Uwyk jttM007sq9iDdVEyATdkfrWgLdN3ovsV/7Z51e/l+NSpunBC+UlBLU2j2P0YpKhnVxPk RPUAnszQFNqZEqhnylgT+y/5yfk+IVqUl16HD4uJMnWaF8HbcwgokFfetnEScG1H9rRS 5M3g== X-Forwarded-Encrypted: i=1; AJvYcCU/FnazX+xPP0xvX4mHFCSaJzYPJw0nAfVjgx2nNmrYFZ/e6C2AsIastsPB1uBhTTpzFLoz65HPHU42WyJBsVt6SLVJQt7c X-Gm-Message-State: AOJu0YwR+SDCqipLpEX2AnGEmeqSw5/rsShz6O8a5M4C18EWBlZHMTqF nrUBnprQMQANCL8oFctwuHYySW8ZEqI57GHnCAjih/aaEtnfEX8Q 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: nvdimm@lists.linux.dev 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: 13569753 Received: from mail-oa1-f49.google.com (mail-oa1-f49.google.com [209.85.160.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40191146E9B for ; Fri, 23 Feb 2024 17:43:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710188; cv=none; b=uqlJlU0M2ugjgMrbQqZqYsk4fWco4zCN5/icVmKZP5Ul8fhL0gAzF9rxGValkNPpeFos/AHvMURXkGE7PafegvibH/ULyGh6t8UIk850HwaI55j0BlMsLswdHfDDgL528HVfT4G9PuMeGs2onjTbiwLfAZf6w8Mm+mb7c81UpUk= 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=GGBqogeH; arc=none smtp.client-ip=209.85.160.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=Groves.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GGBqogeH" Received: by mail-oa1-f49.google.com with SMTP id 586e51a60fabf-204235d0913so761418fac.1 for ; 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=lists.linux.dev; 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=GGBqogeHGBzJC2sQJy6v77HN81KX8bxyVGXNPs06q685+L5G60H4AdHGYN7y1rSxO0 5LBPHPkQaCoa01pQRO6/Fs/y34c/3YqDMMFvkI/u7LSHvduzqmat0PPb8JeES4BCSEiF HBCjq5d10adfWeNrSWtnGNjw26UaI2Lf5MpZ4KuIjisguF8f+dkR9knEQ6Lqx3nbHYrv wltUzu+jK/qzaPW6iY85hykPkD+6Hg0RDdCdkvifjW55EwjW6Pyjfk7s9rkMfn6Jj7Pu AbG7n1GtZxFL/6PfyXxPRSPk50ITYUUreMy61Tri4/TIzmtai8WN3uXrhNmSffehV/4e zF5Q== 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=MEtlrnm7ySHYCnp598aOrQA4CDA4Q2pYTpEGpTCCGlkZwxVZkh6fIaSII3s+nXVO7V gsnc57C00+0LNBCHXhmDjdhySFXUGxMuReamH4dzlwCZhDwvbtJBWIN1Tbp34qJsU38S NV7hjV8M3tYmmWdNdyuy3rJygpJwm+6kBNax9wJgQ9hUAoLov4LSmZ8UFDq3cQWaZbqt +BCCJg8y0eKw5ckxAVlMfQaRPuElTV1Be8m1fLU8uTYdXBobaKjNa5ordiYi6i4U+v2Q 04uzrIbKjFL56vD6DCf8dnTTjXz1TzODKg+jgNSQvsF3WIGjbjJu3BdaXliUJyopauk2 3E+w== X-Forwarded-Encrypted: i=1; AJvYcCXk+AgWL0U4qIqdZzxIOsrSE944ywBdOJfaULGjOrOK1k8wfqnVg9V8iBkEmxvMghZhb7u6yLoj15W7XXEHoP7zYsVI4Qnz X-Gm-Message-State: AOJu0YyJHucHuwWRAq40nljqLNGinuGbS+ps8q2bIEHbTmTo9zJFjja7 wyUov+RU9/VswbEkXnBxRkoM+B5BL7QSKRH31lAdxZDfOBB4zlWoE8MO0+TVn08= 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: nvdimm@lists.linux.dev 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: 13569754 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 1AAAF149003 for ; 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=1708710190; cv=none; b=N8saKR6Tj184tm+NKJFpNGuzquz0AF0UwhfQB/BJUJtPjS5Bvqzu1UQ9ipCp5uymEEQCLTtem5mLmCbsDwiyerpVmTuFQzh8tEj+yjP7nYVtmwhnB2ejqpNp5rQWz/MD0uvvFfEUDcwqTyeBnMqwUQZHCX7/GBnPWi6PIngg+jc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710190; c=relaxed/simple; bh=Ezvg1m83Vs64xk30SW6VrHXVsjwp8rUkX/UFmrsqfhg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=F077Zh1ZoH3pnRIe4Q1jYSO6XS9t4nObGr4rm0VCTayd5ldIuFDvytbYL7ci0Xpm3DzAcXrhFwNrENsKUSxweN0poYqFASjoMAJRZB8WyOvSne4Z6uU2AbkL/ZsS0tHg0CRGFoGmPHUJiDoTkTNdVCWD+rWLE0PwAMgujNOkgIs= 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=c9qQZpVE; 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="c9qQZpVE" Received: by mail-oa1-f41.google.com with SMTP id 586e51a60fabf-2185739b64cso612649fac.0 for ; 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=lists.linux.dev; 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=c9qQZpVEDWRfimVOZ2T4Jv7Ss6wheioXijEXpgmg+jeM0m37Rn+zS5lOpI0rtR5G/F fR87CiN9OthD8fN6slZ85OOCr70EewVzgnwO9T+zUFq/32O8Yr5+2OR0eaEn36x66+Dg U4HbquBrMGxTbN4ZDrdvwORuHtrYPqE+ySJt5MO1bupG3cpIZOCW/wiJ8ZIb6Rsgk4UI j1fdyDzmMl+sknt1XjNmXlofl6G/gXHkG44shy1T83GFLQJf9I/ip3qqCO0qksheyjNU O7CSu9Cjs+NHATMvcgdfLf1uGFGHPiQGiB38WjI79GMmLm8wyYUwiJx7bmOH2UfODvAp yeTA== 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=rJCh/x5RCKNawZuTrbj7uRbQtpPTHu+Mg9rRAo/YVIvvByetAvZtgAGuiPvJVFOZS3 bE0lvTC6Et/GPYUR7w9qAmvxAuG5W25rY8SdPwPE8zJbuw6NEBIiXBFN/bOeV8is0RsF ZxAWfjxTLnyohfLT7XyJL2bK3lIoihbK0wK5oJkf4z1N4LS4m6hGsscoVkJw8b0U5bFW b+CsUkc4/xdwh0/SZf3NTcZ6QXytOc+vFRmP6d0qbRcl/7fhSMvNLVd06AtQ2PUSR/In 2DhsORKMdR7DCMDlw3uI64SpmPVMP+6LbTM+rZ+uBCTqCLzcIDJRsZv9wA5mx5GQhjiD jiQQ== X-Forwarded-Encrypted: i=1; AJvYcCVNsVsMp/WObDBhfG1cVHsHooPt83IGtQM9Y1MJWn+uxwQ2BHRtnsKQQG35wWGwEwgimq+vf20Pf9qfbwZBjexY0J3+1yq0 X-Gm-Message-State: AOJu0YzS/GBw3JpNrQjMAnFeha/Gq1Q+OgsX0pl6Kx0qNrU386rcOqFo OlbCpvXTaTYX0g5ySC2pxJGBtcYqdyDDqRJxotFbTWTdunK/pZOgqBLiYgaJovQ= 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: nvdimm@lists.linux.dev 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: 13569755 Received: from mail-oa1-f44.google.com (mail-oa1-f44.google.com [209.85.160.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C7F7E1493B0 for ; Fri, 23 Feb 2024 17:43:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710195; cv=none; b=baE2eaB3ir41thEEjtCezs0Oan/XcJHVrcdeU+geIpRJ5hImXDB/VwCnawKtgZKXG0eX2og3iAqZXbvIR0FhpRwwtDTTW1gEBZa7FsEm29c7rbWDqthiAhZHuK2WFY4MX79Wrqy289eyWzB5gDizeR9FHYNQrfUDmMBsF9+Hld4= 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=DCZ0M97W; arc=none smtp.client-ip=209.85.160.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=Groves.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DCZ0M97W" Received: by mail-oa1-f44.google.com with SMTP id 586e51a60fabf-21e3c16880fso564440fac.2 for ; 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=lists.linux.dev; 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=DCZ0M97Wyk3yUjpGH4O9BmlPuXi69KPXE0p67P7BVwGZBlGu9f0mKGY8biSdf6LEt0 z/YD8UwyR2In1136zLugYf09hto3Hoc7XP027fuhYrh/ROtLFUjxAbKY2H3q7GPXuNzr bAE7ekLWNdBZMwa3TweXpfSRdm+vIOM+8Lh/FwjviKY7Jp90mQm8hLGyUT927PCYM4xc MmQDqswlKCVnRGJwFyG1ZGv7vLrkQQ72gmFXAu709GHmU/EsMioXoMr/GBCbmFYf5BJk idltiexVbe45O6KL1VMA9C3GsAtxM92He3x+Lgs8R2aEAAr+DESfKFrVdpv5kQY3W8Qg s3Bw== 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=njQtwFQBwWK6uc62JC41p9FZGmm3xCs7rZ5/EWCNoKPEqe2FKx/d3g+BAZVINuXg6p xpuWgszU1YRjzybs5ge4cInFH1k0ZqI4oJjDDFRnRgdw0n7WhcEUZNNoexjgncIQXb+N PeVkES2HwuLtWcdirIhCmCXWS3tz+XxObr71M1scpGwGnvVRyHppvzQTgXnpjB1ZvJ84 uUdi2OOLGgYhzxOcI73f6FZdwUgYMO+nWZI+gqFIMO9Is8EZGZObbO3h85AwN5umaOum BeHjozWUCBYrFd0pRWm9xG7ymjyK4j/H/05I1s8zVHbSWcuKqvHunm0Kj96ck+pRn0nO J5eA== X-Forwarded-Encrypted: i=1; AJvYcCXwH5tHDL+wvDTAzmBqTfzEV9pDrPdxqfDQiS7RvMLeLJCw2dxt9/VOSUSYpDvMEvbDdVoyDJSBKALJQafqBeOoDURcW/r/ X-Gm-Message-State: AOJu0YwN8ThCjxf6VJip5irb9aMFeAiCMJ9yNLgHWkgCNOAcHV+AN8kB rVMPUZ8SQfMH7kbXby0w5m/UbnwXwaS6f6ZgohgK2MxYWXz3EXcg 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: nvdimm@lists.linux.dev 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: 13569756 Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 74A29128822 for ; Fri, 23 Feb 2024 17:43:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710198; cv=none; b=X+50OCUwANQztSMYWA6Up1OvoM8fhfr/PJRCJEyA7FsIQtrkI/jvgddVBcMzhOysjfHTq/tRO90vjhqWimYgH7oXf906V6m+e/QaLBw4DZZxN6Zz+/ebu+GgjadDs3SAKzrpzq/zxD4fuqxBCtgTHL/XEF4gEClRIhDD8Mu4a/s= 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=SNmXFW4C; arc=none smtp.client-ip=209.85.167.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=Groves.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SNmXFW4C" Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-3c15d1bd5b1so422668b6e.1 for ; 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=lists.linux.dev; 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=SNmXFW4CwTwPMgDVSEWJuiTyl42fiVo8/plh3MGKvxKY0M4vsYYMC6XbnvawLXpMTy d69ufPv3NuLLvH+nUuwkkuuUVdPD7weWAhvSS7mmWw2RWIOAFGr2TWi/Iu6QY9H1DpI4 in8z4f5oP+PNlVI8ZmDEFRl5JeYXTU7m5OwxegWMB0NtXFtU1GYRl83YpAVu7KaoqGBo mWnmH52A4bNC5NaniUWWyzGLHFj4T8O34ifi6CUeG+VckzVjGQ/PmHc8swjYgOD0Tir0 ODk65RcMatWIfTsp4Js1sbJT3Pv0WDGUE26/927j52exGGbJJO57UirAT3LK8h2HMGr5 rIZA== 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=eZbLDKTOrYZSimu/dbHw7tjDCad9GZFclTpWaVgUu9n3uvksaBZbza8wlBl+EKZU4o yz56XqDoeTkEOEYRAYIpNrNVLsqJB4JTqMlF3C3K7gI4eVwJRrxcCuOIOBvNQJByax6I tFmUuFwZILnchm3+BM6mFWamq6bVwrJHhkVc3m3QW6nfFVXBAn/jSP/MY9DVMl9wFjcs jiBA0EMIowojYox0VqB3S5l5WIYpk8TUGvr3jgyJNG1rGYAcCy8/dRD6Yk2eGH7trhp1 MBkpoWHvpLa9XlqDJNHZDepg4OR/Octf/l0bcRGlK/+ojDFg/gvJlT+DIhutLgZjuR7p Kdww== X-Forwarded-Encrypted: i=1; AJvYcCX6AHU+C8GkluOJnZK/HXDPnTJQ1NUcDIKGL/Yg4Vb4pPC0U7jbbngpuqK7XCrfLZeotUpG4CRpZu3lxho4R60moQdZ7Bdb X-Gm-Message-State: AOJu0Yw2hLJfrDltVL6hPP1QYabhZmrcGIkLZ3ALos8Gy8zvVLGKaHZY PQAQO5XzblsGNwZbSeN8e6xFBle0g3X/LpyC9bIuYp1E1e19SW3v 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: nvdimm@lists.linux.dev 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