Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1313790rbb; Mon, 26 Feb 2024 05:48:40 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXHVfSLSq61ZLTsvk7X+XMHHL2Px6GDMQkzApXxDsoyuip+QSpGsQIWlPPHYluANwHXAy5gXUBZxcPB7OsSbZ9mgjXICprpBTPEjpnQcw== X-Google-Smtp-Source: AGHT+IFmoy7VTgkZFkHPODrRjIeukLqEzstlWg04SChcGfhmqMwq9Ua0GmBStuuyNvKq7dnvtOzF X-Received: by 2002:a05:6402:2499:b0:564:2d0c:b46c with SMTP id q25-20020a056402249900b005642d0cb46cmr7298519eda.0.1708955320590; Mon, 26 Feb 2024 05:48:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708955320; cv=pass; d=google.com; s=arc-20160816; b=iwt3J5j1yh19pZHjlFyLnkDfQeFmQ4FCMZUlTZB6lB7LdFm7HgjnTdeRqVqqpA/Yp+ IPVHlYBcoxLWZJgnHeh6iZcbAWzC1Jxl+UoDvt9tAwixevvoyt0DXv4D0Xua0fM+y6zs Kr6fc8XmOmL2uMjPv39qlksJICfRtn9XfCeoJILU8BPM5PYQpZLabUb/F1J5mQHgHF4s SOlrlifxDrJOPtrD/9ALs1vXqWJ4Za4KHVSOz1Q577gZNRjNzZBKjQpkEAosND4eb1/7 Kgq+2XfEIe0BiDrJWsWeQNxfmOpt0VenzJDfUXIGz7uT3QeO6Fb5WSmy5AAqlSlMd/Wi VUCQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:organization:references :in-reply-to:message-id:subject:cc:to:from:date; bh=3o6Co/X5Z2Rn9xNOeuOSxGPF/mpHh5Mk5Wti15pIaGU=; fh=NxEgvf8Rw6A11ITJWFIYtOfb5rphg3RFyVjPJ/rcJm4=; b=AzPX8esPhce5+d2NeAsdp3/uNYKzPlAilGkAkYPWrgEv8D3btXlG2fHVZ5sdNufz6N YvJ+oZVSSzcuwqnPkyCA0Cx87l+wyPsgSgsDJzudPRPP4O9ZW4VVq0G9Gt9/FEF9Jtfu MIi3KqIj0zqS1oL4Ge33h0nE+qzzckatGgkg8QFz+R9RQ0koLJmEeCib13wK80y7b3tK d/ermt51n5Pz3NiVLVlyKIsC00OFiTMHrRppjaIdjq8DKnHK11ptlaCRN7o1UgDhr9W1 VN8EN/lgzmbU1OhB91lQU0eoK8U5C7gLWsxwMadME/z9YqGGooAsOXwRnobPYGq0jM2M OiSg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-81531-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81531-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id b4-20020a509f04000000b0056403f952f5si2021309edf.577.2024.02.26.05.48.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 05:48:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81531-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-81531-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81531-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 5AA301F233DE for ; Mon, 26 Feb 2024 13:48:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1BE0F12A15D; Mon, 26 Feb 2024 13:47:56 +0000 (UTC) Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A9EF1AACC; Mon, 26 Feb 2024 13:47:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708955275; cv=none; b=ITSAAs0iLWhxWrxu7tisSKbcdjOFJktDFIPJYU1gHPcncuFmq8kPD8H8Doly7svUT/LI0krGwFziQk9zebKLYqCgON8+IWxTLxs8/71geqSfBovhwPRCJY+4hPKAMv01XVajzzCeJF8thUSJO1IjBJDyN0czAX2+WtfwaBy5dcE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708955275; c=relaxed/simple; bh=E83r2PzgmcARJDM5rhAvuhFm7oVmjpWV1yfSKzHMk8E=; h=Date:From:To:CC:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hg07kq/lHaLt0zq3aWrURdiNuhcPAOIVe5xHlRrLOPz+78Cjs5xV7KdmtmX21meeHc5yNrlhLv5aded4HLtmMJr0EqCLjJtlIfycmLk4xGbblCMdy64eTzdosFT848Yc4Bf7+3m4UbIIBf9h9YJNhXStB3QGhjvinKgPb3HI6jQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=Huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=185.176.79.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=Huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.18.186.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4Tk20704Rnz6K9PX; Mon, 26 Feb 2024 21:44:07 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (unknown [7.191.163.240]) by mail.maildlp.com (Postfix) with ESMTPS id 4623F1418DD; Mon, 26 Feb 2024 21:47:50 +0800 (CST) Received: from localhost (10.202.227.76) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Mon, 26 Feb 2024 13:47:49 +0000 Date: Mon, 26 Feb 2024 13:47:48 +0000 From: Jonathan Cameron To: John Groves CC: John Groves , Jonathan Corbet , "Dan Williams" , Vishal Verma , Dave Jiang , "Alexander Viro" , Christian Brauner , "Jan Kara" , Matthew Wilcox , , , , , , , Dave Chinner , Christoph Hellwig , , Subject: Re: [RFC PATCH 17/20] famfs: Add module stuff Message-ID: <20240226134748.00003f57@Huawei.com> In-Reply-To: References: Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) 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-Transfer-Encoding: 7bit X-ClientProxiedBy: lhrpeml100002.china.huawei.com (7.191.160.241) To lhrpeml500005.china.huawei.com (7.191.163.240) On Fri, 23 Feb 2024 11:42:01 -0600 John Groves wrote: > This commit introduces the module init and exit machinery for famfs. > > Signed-off-by: John Groves I'd prefer to see this from the start with the functionality of the module built up as you go + build logic in place. Makes it easy to spot places where the patches aren't appropriately self constrained. > --- > 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 I'd drop these drivers structure comments. They add little beyond a high possibility of being wrong after the code has evolved a bit. > + */ > +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); If this fails, do we not leak the kobj and sysfs groups? > +} > + > +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");