Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1368314rbb; Mon, 26 Feb 2024 07:13:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUukwrmuEg8H1mVkc0aU9ym/SCI33GAcfxm9z7RF6dWFMuCg+H7u7t2NuHQ/PQhIyDcymZI99gEgl7i24DISRgH0W109/tFYmM3SqSG3A== X-Google-Smtp-Source: AGHT+IH3OEx8RsuRmvgUtSVrERKuazIKxMwCqPgZg5uGY4wkw3X+51FNmpy4tPhYk9Cmt3rmU9Rn X-Received: by 2002:a05:6870:2248:b0:21e:bc5a:963a with SMTP id j8-20020a056870224800b0021ebc5a963amr9889609oaf.34.1708960424185; Mon, 26 Feb 2024 07:13:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708960424; cv=pass; d=google.com; s=arc-20160816; b=w+IvekSZIpLAOnO8XzFs7VJfqnq1wWnQhXMzGKiA5ycM3rX/dCcKfUhRYkX/oIV9c2 xVVpHNkiH+9wLDRHOrnatpGOfnUlVzexWBI9CZAMKM1SyTiYytjlmQ2uyE+eJggvnQp9 ChKl3p7TOYIli1TEGUMZ9Hfx/z4zT6loqjmpPjefWzxoysuIwvmJmDPfr6R0WWWcLZ1l IzQsNLDY1mocCGpZ3c3PuCxdazud+hk3N2ZMXiCOshZU+zAB43nkWwkaTtNqxIMtYY99 UOIfpLySL5vIsC2Zsrxtyg1ZJGyQK4L8lwibiYFSvZo3vEexMRyMqbPu4jpErDGYjGrN dWlQ== 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=H53FQFuV0tEvJqPL0XJbu4yTTLUCR5gSsoYwOTRibBQ=; fh=yuaY9WYAbUclu8QAkOc628+EKm7wntwWCar1IrhYOGo=; b=r8uU3a9QYtXWu39vql1d7/d62Pf+xzysybIPioVmE/4XI9WrjSVgWoAHJb0mY3JgM8 EnfBrnuLbW6mu1F1WcbXdN1OcW4AEKtDQ/vkj16zb8UvWdx6LONhg8AjROCW7J4xYEbh FyLnd+SKDhIk4yTfEZO/3WZp1ZSaUSdNRl+xP3P+xcEZTdAi6pOswJlpQQcquavymsDu u0IzvfbcZdj2PRLrn8qeJ2SLLvnnJ1KNmLYDkxAXuw2e9r8GskwA9obuWA4h2eohmxeM 0tU/68DXCo/G0wgpd6Q6ragRJNttvkTEBMmuPv1POoZ8GV+F6IJr1YUhIEwrt3PVAlp2 qe+Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=IhYgae0g; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-81752-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81752-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id s190-20020a632cc7000000b005e2b1d8f234si3705618pgs.342.2024.02.26.07.13.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 07:13:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81752-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=IhYgae0g; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-81752-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81752-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id C6BC729DACC for ; Mon, 26 Feb 2024 15:13:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8AC3312F592; Mon, 26 Feb 2024 15:00:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IhYgae0g" Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) (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 1755C12F585; Mon, 26 Feb 2024 15:00:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708959639; cv=none; b=Znq7eK8KEsg7JvTpNGVvXRe0LKFdrRG7lEvVXtecKyw0sFGtowNb/IwTNKMm5YdgvCdHITHyuzVAY2X87TrSWhL17mRNnA+3VURb9yD2IYs13EQQzU+NpuIHcHu7wf9k9x9qaGvF+RXororlGZT5jMPR9QMY15Rrf8UC7h/AbJ0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708959639; c=relaxed/simple; bh=pDJ+S710TU3tYtsI7/uIBNbjN3ZFzSKvc9q9SE7JkjA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hAxypBRHLMZmeILJPa35ne2ROSGMCJFsFB7WrM2uM9rJHDopxRkvn2dQPu1QfX+ckRmBg0gYx5kDbsmkHMhR51mCBYV2CLGtiLenlXzK/2d0HrcZdENfQrPTAnh8qoraRZ+Z7v7xPtBrfiqerjG8XZq3F5h/TpnkWBiBM6zUJZM= 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=IhYgae0g; arc=none smtp.client-ip=209.85.167.175 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-f175.google.com with SMTP id 5614622812f47-3bd72353d9fso2099166b6e.3; Mon, 26 Feb 2024 07:00:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708959636; x=1709564436; 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=H53FQFuV0tEvJqPL0XJbu4yTTLUCR5gSsoYwOTRibBQ=; b=IhYgae0g3nZG9oAIkAQ1fcWtFDwjwQ5YB/dFwO0sjO/hgkjp/HRkO97oNNhHU7hP3p aR1Zakobi9+hCNdYjeLoAx143L5J81GeNCkla4Hy0Q6MZ7ug1TryMpmXZkcc0LTcJFh2 FEqZCpNDJShU0tCuXGYBx9roJgJ4UpVkBswMTx8JLKtuAQ4CMMU0IOGLw1VltS7VrbaZ +9ghOdE2dyHRWdt54E8F/gES0GcRiDoyUT4/DfrxxgVi87P+vlJ3cu83l8GOu9DVxgzK 9/QutbESqXz4fwOqSNf5+Kxjqx43KQuSz9mPIfR35xbbIPksvthRVWofCAc8clsvz1J1 iICA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708959636; x=1709564436; 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=H53FQFuV0tEvJqPL0XJbu4yTTLUCR5gSsoYwOTRibBQ=; b=hxT1bTksG6MD9uc1qBihv0CsbIll5Knu+vOJmDaj7syvYhaeSylygKz2tnXHV9gWJL UMiJFB/NPfQvt8ftWE23YKTDsb14+d4T7m+RdJekLq2wJ9tF/TupKspsKOoEGVQsjJII EEzFiksDKUW4A9U1MUtei9XS+VO0mhY7we2i8nINqIw7nsuXmM3CRE4nmcuZyj45s7xA iQ3EkzutKjslstNIZaJewfVf9DR6VbhqFHvvqu5h2jHCyqWXCXzqsfClyzRMDX9AMFCb pwbnf9EDqdfX12JGyRwY4kFmAWaJqX7Erf/ux/s8jsxlE/4NZm8UFE3uJT9/v/nYVqkT lbAA== X-Forwarded-Encrypted: i=1; AJvYcCVxU65RefR1rmV+zGoO+9K58gV7W3aONR6nTOK0xA1Adk6VzpUr3Lcsr+HaBqBwGwNDK9XwQJSqmkcBESKDj2ihZAQEXj51x8lWalS7kMoYe3t39jhFsxvneRqqqVyBuft3+dLJBllvXFEIg69fYJqcWAZzAIKmg80hGK68FIhqqz4odPppx4OUmdOJl3Hn83fZKGMB320E+FZ0yT5deBWixA== X-Gm-Message-State: AOJu0YzUAGXqtf4R1Pb8jYdJbZZ/Zo4C1MueE1KNQ9/xw8laS7xc5j1h EA857RiJEuPTswX9XgBz7/KKj/yefh63qjgbMZH3rQTdB2p2SboR X-Received: by 2002:a05:6808:10ce:b0:3c1:3215:1881 with SMTP id s14-20020a05680810ce00b003c132151881mr9820277ois.7.1708959635473; Mon, 26 Feb 2024 07:00:35 -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 ca22-20020a056808331600b003c1a9ed75casm59821oib.18.2024.02.26.07.00.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 07:00:34 -0800 (PST) Sender: John Groves Date: Mon, 26 Feb 2024 09:00:31 -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 02/20] dev_dax_iomap: Add fs_dax_get() func to prepare dax for fs-dax usage Message-ID: <7t6n6c4cycu2hqh4ajsl4egtu2womq54unj4ikqeu3rehmxwzw@64ydmjh5x2ga> References: <69ed4a3064bd9b48fd0593941038dd111fcfb8f3.1708709155.git.john@groves.net> <20240226120535.00007a36@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: <20240226120535.00007a36@Huawei.com> On 24/02/26 12:05PM, Jonathan Cameron wrote: > On Fri, 23 Feb 2024 11:41:46 -0600 > John Groves wrote: > > > 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 > > A few trivial comments form a first read to get my head around this. > > Yeah, it is only an RFC, but who doesn't like tidy code? :) Hope your eyes don't burn too much ;) > > > > --- > > 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() > > Smells like kernel doc but fairly sure it needs a short description. > Have you sanity checked for warnings when running scripts/kerneldoc on it? Right, and there were other cases. Randy pointed one out, and I've already gone through and "fixed" them. > > > + * > > + * fs-dax file systems call this function to prepare to use a devdax device for fsdax. > Trivial but lines too long. Keep under 80 chars unless there is a strong > readability arguement for not doing so. I was under the impression the "kids these days" have a 100 column standard. But I will go through and limit line to 80 except where it gets too awkward. > > > > + * 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. > > Not familiar with this area: what does exclusive mean here? The holder_ops are set via cmpxchg, in such a way that if there are already holder_ops, the call to fs_dax_get() will fail. (as it should) > > > + * > > + * @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 > > Why not return < 0 and use somewhat useful return values? Good idea, will do. > > > + */ > > +int fs_dax_get( > > + struct dax_device *dax_dev, > > + void *holder, > > + const struct dax_holder_operations *hops) > > Match local style for indents - it's a bit inconsistent but probably... > > int fs_dax_get(struct dad_device *dev_dax, void *holder, > const struct dax_holder_operations *hops) Done > > > +{ > > + /* 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)) > > You dereferenced dax_dev on the line above so check is too late or > unnecessary Good catch, thank you! > > > + return -1; > > + > > + if (cmpxchg(&dax_dev->holder_data, NULL, holder)) { > > + pr_warn("%s: holder_data already set\n", __func__); > > Perhaps nicer to use a pr_fmt() deal with the func name if you need it. > or make it pr_debug and let dynamic debug control formatting if anyone > wants the function name. Sounds good. > > > + 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); > line wrap < 80 chars Roger that > > > +#endif > > void *dax_holder(struct dax_device *dax_dev); > > +struct dax_device *inode_dax(struct inode *inode); > > Unrelated change? Kinda, but I'm not sure there is a better home for this one. Patch 18, which is a famfs patch, calls inode_dax(). It was already exported but not prototyped in dax.h. Mixing it in with other dev_dax_iomap content seems better than mixing it with famfs content. Could make it a separate patch, but I was trying to some old docs that said keep patch sets <=15 - which I deemed impossible here. What say others? > > > 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); > Thanks Jonathan!