From patchwork Tue Jul 23 08:32:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Youling Tang X-Patchwork-Id: 1963660 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=d+j7TsDH; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=150.107.74.76; helo=mail.ozlabs.org; envelope-from=srs0=qw8w=ox=vger.kernel.org=linux-ext4+bounces-3366-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WSr6b3l7qz1yYm for ; Tue, 23 Jul 2024 18:34:31 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4WSr6b3J6Xz4wd4 for ; Tue, 23 Jul 2024 18:34:31 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4WSr6b3FZrz4w2R; Tue, 23 Jul 2024 18:34:31 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: gandalf.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=d+j7TsDH; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=147.75.199.223; helo=ny.mirrors.kernel.org; envelope-from=linux-ext4+bounces-3366-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [147.75.199.223]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4WSr6b05BQz4wd4 for ; Tue, 23 Jul 2024 18:34:31 +1000 (AEST) 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 37D441C21C29 for ; Tue, 23 Jul 2024 08:34:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4D2BB14EC49; Tue, 23 Jul 2024 08:33:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="d+j7TsDH" X-Original-To: linux-ext4@vger.kernel.org Received: from out-172.mta0.migadu.com (out-172.mta0.migadu.com [91.218.175.172]) (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 4133C14EC42 for ; Tue, 23 Jul 2024 08:33:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721723601; cv=none; b=OuJwl9EJbYLCpcSSEqj4QrqrJGF641haSgG/RaudaFEIy/wio3+ViBU1rhNFams49H1Xma6MsSkSPVfZX6vlHQQtyUW7vqiAqxPdyys9E5IEOWnbP/xFIEFCiTUUpOGNO66L9Nh+VBFVU19nzbc4+7gPqg1A6gHOgxW31Xc6n9w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721723601; c=relaxed/simple; bh=/mwN5SsbhIgDMwi2o5jzaWYzFJunRtJZ5k7XEtLZcxQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KyQUNY0Q5IqU0zZE5+7YnkCeR+OxPWz3wPJnD+y1DSjnhNGO+TMIPv0MAFyycZjbYuF6i0URz37I+MpIFK64yid3RMi8usUrp59sYAmDjWmpEZ6kEjIKDOjpN+mL3xgAh5J64IP08WjYuV4kAWBr1UoO+A5NI5PJ/puLoTFAS+s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=d+j7TsDH; arc=none smtp.client-ip=91.218.175.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Envelope-To: arnd@arndb.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1721723597; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2FpchObtj1bgKZan3q5qtLR0pzIfvv/hdOK5gMl3pYc=; b=d+j7TsDHafpzbLmS3vv6N/qkImQhjEqmin45ALNJBaRxl0qHDTvOB+rqR+HlCL96wm0LOF eA2U2qzRIYTczg0xNz8D9dMn0NWdsVOeb8S60GRVOWIpHir2+okklwMqcuf8x5jN+lBWRl uhgkDt50wo+N4yrygEF4KSBzYqB6z2U= X-Envelope-To: mcgrof@kernel.org X-Envelope-To: clm@fb.com X-Envelope-To: josef@toxicpanda.com X-Envelope-To: dsterba@suse.com X-Envelope-To: tytso@mit.edu X-Envelope-To: adilger.kernel@dilger.ca X-Envelope-To: jaegeuk@kernel.org X-Envelope-To: chao@kernel.org X-Envelope-To: hch@infradead.org X-Envelope-To: linux-arch@vger.kernel.org X-Envelope-To: linux-kernel@vger.kernel.org X-Envelope-To: linux-modules@vger.kernel.org X-Envelope-To: linux-btrfs@vger.kernel.org X-Envelope-To: linux-ext4@vger.kernel.org X-Envelope-To: linux-f2fs-devel@lists.sourceforge.net X-Envelope-To: youling.tang@linux.dev X-Envelope-To: tangyouling@kylinos.cn X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Youling Tang To: Arnd Bergmann , Luis Chamberlain , Chris Mason , Josef Bacik , David Sterba , tytso@mit.edu, Andreas Dilger , Jaegeuk Kim , Chao Yu , Christoph Hellwig Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, youling.tang@linux.dev, Youling Tang Subject: [PATCH 3/4] ext4: Use module_{subinit, subexit} helper macros Date: Tue, 23 Jul 2024 16:32:38 +0800 Message-Id: <20240723083239.41533-4-youling.tang@linux.dev> In-Reply-To: <20240723083239.41533-1-youling.tang@linux.dev> References: <20240723083239.41533-1-youling.tang@linux.dev> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT From: Youling Tang Use module_{subinit, subinit} to ensure that modules init and exit are in sequence and to simplify the code. Signed-off-by: Youling Tang --- fs/ext4/super.c | 115 ++++++++++++++---------------------------------- 1 file changed, 33 insertions(+), 82 deletions(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index e72145c4ae5a..207076e7e7f0 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -7302,103 +7302,54 @@ static struct file_system_type ext4_fs_type = { }; MODULE_ALIAS_FS("ext4"); +static int register_ext(void) +{ + register_as_ext3(); + register_as_ext2(); + return register_filesystem(&ext4_fs_type); +} + +static void unregister_ext(void) +{ + unregister_as_ext2(); + unregister_as_ext3(); + unregister_filesystem(&ext4_fs_type); +} + +static struct subexitcall_rollback rollback; + +static void __exit ext4_exit_fs(void) +{ + ext4_destroy_lazyinit_thread(); + module_subexit(&rollback); +} + /* Shared across all ext4 file systems */ wait_queue_head_t ext4__ioend_wq[EXT4_WQ_HASH_SZ]; static int __init ext4_init_fs(void) { - int i, err; - ratelimit_state_init(&ext4_mount_msg_ratelimit, 30 * HZ, 64); ext4_li_info = NULL; /* Build-time check for flags consistency */ ext4_check_flag_values(); - for (i = 0; i < EXT4_WQ_HASH_SZ; i++) + for (int i = 0; i < EXT4_WQ_HASH_SZ; i++) init_waitqueue_head(&ext4__ioend_wq[i]); - err = ext4_init_es(); - if (err) - return err; - - err = ext4_init_pending(); - if (err) - goto out7; - - err = ext4_init_post_read_processing(); - if (err) - goto out6; - - err = ext4_init_pageio(); - if (err) - goto out5; - - err = ext4_init_system_zone(); - if (err) - goto out4; - - err = ext4_init_sysfs(); - if (err) - goto out3; - - err = ext4_init_mballoc(); - if (err) - goto out2; - err = init_inodecache(); - if (err) - goto out1; - - err = ext4_fc_init_dentry_cache(); - if (err) - goto out05; - - register_as_ext3(); - register_as_ext2(); - err = register_filesystem(&ext4_fs_type); - if (err) - goto out; + module_subinit(ext4_init_es, ext4_exit_es, &rollback); + module_subinit(ext4_init_pending, ext4_exit_pending, &rollback); + module_subinit(ext4_init_post_read_processing, ext4_exit_post_read_processing, &rollback); + module_subinit(ext4_init_pageio, ext4_exit_pageio, &rollback); + module_subinit(ext4_init_system_zone, ext4_exit_system_zone, &rollback); + module_subinit(ext4_init_sysfs, ext4_exit_sysfs, &rollback); + module_subinit(ext4_init_mballoc, ext4_exit_mballoc, &rollback); + module_subinit(init_inodecache, destroy_inodecache, &rollback); + module_subinit(ext4_fc_init_dentry_cache, ext4_fc_destroy_dentry_cache, &rollback); + module_subinit(register_ext, unregister_ext, &rollback); return 0; -out: - unregister_as_ext2(); - unregister_as_ext3(); - ext4_fc_destroy_dentry_cache(); -out05: - destroy_inodecache(); -out1: - ext4_exit_mballoc(); -out2: - ext4_exit_sysfs(); -out3: - ext4_exit_system_zone(); -out4: - ext4_exit_pageio(); -out5: - ext4_exit_post_read_processing(); -out6: - ext4_exit_pending(); -out7: - ext4_exit_es(); - - return err; -} - -static void __exit ext4_exit_fs(void) -{ - ext4_destroy_lazyinit_thread(); - unregister_as_ext2(); - unregister_as_ext3(); - unregister_filesystem(&ext4_fs_type); - ext4_fc_destroy_dentry_cache(); - destroy_inodecache(); - ext4_exit_mballoc(); - ext4_exit_sysfs(); - ext4_exit_system_zone(); - ext4_exit_pageio(); - ext4_exit_post_read_processing(); - ext4_exit_es(); - ext4_exit_pending(); } MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others");