Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1582712rbb; Mon, 26 Feb 2024 14:24:06 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWo5AASgEmhTDDFdI1ntHuA4J0t/RScx5oUUoq6P8+gP/bbtVwRHvDN4Ovjngn9oARxmrTWDJFW3IupPlPVHDVCBGv6oaX3KCwdUGfQ9Q== X-Google-Smtp-Source: AGHT+IGrGQ4ZZk4o4jeiGErcrHtO8dlTyt23HnM4KZcj/ec0EcLcmdRVe5wJ3cq7XUnqOl9yg4wS X-Received: by 2002:a05:6359:4b82:b0:17b:61ff:730c with SMTP id oi2-20020a0563594b8200b0017b61ff730cmr14373328rwb.25.1708986246490; Mon, 26 Feb 2024 14:24:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708986246; cv=pass; d=google.com; s=arc-20160816; b=f+KdMoagVeDT118RB9s72Jj+4m8p3qEdEMcdd45XhR13A10XO7bbjrrgx6z5dO3+b1 nEuazV6tXcBKUKFTq4nLiilvL0QF1IYmp/2PCns3xsODg+Q3slKUSH24ZWQGPUP/weNF 51ptoV/1BYn9TcwR1wEUVInIdfg25ni0jcr1CdhcPQDherqDtOGgfk3oC5R6/lh6hzo/ 9le12F22poLOqTIkjlSuAwqxhFbbSgY7w2i9CDK+014wSiY4ibqKYAPyUBwluecn4Cvg uLqjKEaFRVElL7m0LJAryvIUQBBl/rM6+PS8Iu4Xm6ufBTkwhnIWMaJT5IchL43V13O8 Sgcw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:sender:dkim-signature; bh=uCljusvDbpC85XBVMK3c5kvPOrdu09iyxvjz7pu6Gtk=; fh=Ezd+o6tZP4ZqGl7/t+9Xyi/9EW25PYHSV9XZRmO5hr8=; b=nrflygPx6LBM2VAtSn8ZHItMC9Sgl3amEgn1HdFTLS8QSfAtsJnwt6uOWUwL5fBxz8 85+EDmbZKpbA6EeZqsgnJIQqsqRuMb74/Vc6WrObJnls8uc5RSjLJLBDvTYoFi1dIuGT tk4CvqiI3yAb1/WDSIi1DTLEK0/S9+H1MaJXZrR08pzWM8/Wq2UXtvSF6s02myEGnzMI We/kgzlbaM7k4gLkuo5QQKQvrEhc3V/ShoFi960S4AP/6GzKpoLcXa+O2KhzCkpAE1pp jk9CT2Uj5fdu/sqgNELysIl8D8pKu5WSvCAgKBd3lvWGyiZty1uN88hvFPvJLiJNA7Lq 6o4g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fMeBzee4; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-82384-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82384-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id v69-20020a638948000000b005dc4e6679absi4206322pgd.844.2024.02.26.14.24.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 14:24:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82384-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fMeBzee4; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-82384-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82384-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 30056B22B5B for ; Mon, 26 Feb 2024 22:22:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AC307132465; Mon, 26 Feb 2024 22:22:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fMeBzee4" Received: from mail-oi1-f182.google.com (mail-oi1-f182.google.com [209.85.167.182]) (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 15084131E3F; Mon, 26 Feb 2024 22:22:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708986135; cv=none; b=GNhMbt3VgyaKzf3tpNE8JcMBR8K2VdyA0hLHWTf2sVgyWvALMD/iwtvbDlAu6kkBxyk2DibG5gkjQ3dUI5DQlR5gb2FtV6uLCyP1IRQzaCnnYTFIqIGokl8t2SEpkGulHtoZfSmgMbSuIN+oK5ejuM2B3z8ZAZrCfXc3g0ya5hw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708986135; c=relaxed/simple; bh=9B9sVk95/X6RVwf+p1Qn/KhyyBM6EhLa8TimasuHcWM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=pp4BMSMpdcf95S9tA9BPQ7bjpi4oX6XRTkkWi1K0dcnAps4kaBTTgT7z+pjX9VxIXenypbr1VsysxWRJycsRHLJKN7apsr5P1GHUdnRLR0Wsqhjc4h7qpSBjjFIRykNalCgsAqxXM7L1FlJPsV8E4WhSNFfSeb0fQF26yJuPFBc= 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=fMeBzee4; arc=none smtp.client-ip=209.85.167.182 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 Received: by mail-oi1-f182.google.com with SMTP id 5614622812f47-3c19bc08f96so1752168b6e.2; Mon, 26 Feb 2024 14:22:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708986133; x=1709590933; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=uCljusvDbpC85XBVMK3c5kvPOrdu09iyxvjz7pu6Gtk=; b=fMeBzee4rdGqRf++KZpHwK7fHc2KRak3BUg2XDr3gOIp1HTm4uKJhiOT13ukFACDBM CBh3Z6QSKr4UjoYxztmAUvdsvnyJG6B9Rp1B1VdCA9SxWIQASYb6y4gl11PcufsYGTrO xUhzTwlTdkJtDS2HL+CVIJiaeXDRTSChPHhTcHFj5ql5PaPwxt2OOqlaftJ7REsNwiWN TxzTXcmNAq+x/xv7BKV4m+ZxGAoUr92ltlUgj0LchQP/SfqW7ladtmkvU2ABsYqvM5vK m4nNhTJFOHN3dNyjWqKZ1NSfm/vQkxjjU0yjQYXDVPH44zhAFQHnQnUuJ8t1WRmNnkrI f8HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708986133; x=1709590933; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uCljusvDbpC85XBVMK3c5kvPOrdu09iyxvjz7pu6Gtk=; b=dZ3FcY8n8YULEBQ7+deg+QT5m6E/R+7rBaSTGHKm3QP8UvRctVkB8c1RW8t6JOEAJm ncju6Pfidtt2L2UAKJ/DCsQdjfz1H78LwJGKw73Pkq5yne4DoC0Qt46bq04wvxzgQDSQ Bc7l2novsCR+RKeNLI7Lzz6M9UrN4AGUho5G1mxFEwNjae0MEtcxLeiaMcBhvj8/fTMe tqYlneV1BkVuazZRjqIfP1N+YvGGlahujqVRZp1IAWqNaGdOC0iCBKa5ONdfFMOWmJ2G +bSS5UGvB1l9LTrMAJUJK84HPaZpABYm7d5sjAmNIsWxPrFvm8YhNxiIJk6KKR1iwbLM 6f/g== X-Forwarded-Encrypted: i=1; AJvYcCWI2vmopXK3UjJyM3SzokcPDBUXKySdHHe5GhHync58JDBo/zpVD3uPhZV60H6IOc75cm4TOwBLrCyuDhcPw5u2PAIhniVDcZPn5oMWUEzwN9cbx4NrBUhF0q9kZacXWMCDlr3mOBVfNDE/HsDWlwVjBKifrn0Z/O0Afn+Dh6qSgWXnppG/StLzrrfzByd5h4lijWc40zNuyuXawt+8xbkx1w== X-Gm-Message-State: AOJu0YwEuNwUwsF1kJU3Q2CWRQFYfGwLUVnDQkAMP92khA94Xw+yndnO O2Qa+09Pfsy/HxlGIqN2m8sFc8H6gRKVREp5ckKedblU4F10JfBC X-Received: by 2002:a05:6808:168e:b0:3c0:3752:626f with SMTP id bb14-20020a056808168e00b003c03752626fmr434507oib.58.1708986133186; Mon, 26 Feb 2024 14:22:13 -0800 (PST) Received: from Borg-9.local (070-114-203-196.res.spectrum.com. [70.114.203.196]) by smtp.gmail.com with ESMTPSA id d17-20020a05680805d100b003c1ad351e43sm50022oij.1.2024.02.26.14.22.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 14:22:12 -0800 (PST) Sender: John Groves Date: Mon, 26 Feb 2024 16:22:11 -0600 From: John Groves To: Jonathan Cameron Cc: 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, john@jagalactic.com, Dave Chinner , Christoph Hellwig , dave.hansen@linux.intel.com, gregory.price@memverge.com Subject: Re: [RFC PATCH 10/20] famfs: famfs_open_device() & dax_holder_operations Message-ID: References: <74359fdc83688fb1aac1cb2c336fbd725590a131.1708709155.git.john@groves.net> <20240226125642.000076d2@Huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240226125642.000076d2@Huawei.com> On 24/02/26 12:56PM, Jonathan Cameron wrote: > On Fri, 23 Feb 2024 11:41:54 -0600 > John Groves wrote: > > > 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 > > Formatting comments mostly same as previous patches, so I'll stop repeating them. I tried to bulk apply those recommendations. > > > --- > > 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; > Definitely don't force alignment in local parameter definitions. > Always goes wrong and makes for unreadable mess in patches! Okay, undone. Everywhere. > > > + > > + if (fsi->dax_devp) { > > + pr_err("%s: already mounted\n", __func__); > Fine to fail but worth a error message? Not sure on convention on this but seems noisy > and maybe in userspace control which isn't good. Changing to pr_debug. Would be good to have access to it in that way > > + 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); > > pr_debug() Kernel log is too noisy anyway! + I'd assume we can tell this succeeded > in lots of other ways. Done > > > > + return 0; > > +} > > + > > + > > > > MODULE_LICENSE("GPL"); Thanks, John >