Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7616898rwb; Mon, 12 Dec 2022 17:52:22 -0800 (PST) X-Google-Smtp-Source: AA0mqf7oeuwnl8AkV99oaRRY9AEKYgnyGzNNYNni5z9BVvVXhb/UQe9XplZIgj1MZas7iny3rG+h X-Received: by 2002:a17:906:668e:b0:79e:5ea1:4f9f with SMTP id z14-20020a170906668e00b0079e5ea14f9fmr15078943ejo.54.1670896342121; Mon, 12 Dec 2022 17:52:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670896342; cv=none; d=google.com; s=arc-20160816; b=mSciHfn3ZFK8O9jlXTnf1Ozt5r7Tc3dGoMl3zxW7RMwIhHi3uFM4saYOSxbtUhSww3 O4t+8J1DMQX81kxRyYebuXLEtZtCKeQp2RZ6rjC03FvnazYcTVWsmi8fExH5zOSxYrSk wT6LAK3aQeNi7u1fOZQ6sU5JusQfWPcEh7HN/aS5Or94eGm4BNIELYxWURDVu2048iBz MZ1RDv152ysHxKIk7lixzh+1ctWorfnTSNtFKs75btT0nY+O7jV34MRoOPbjSGsAGYuh S1i2/oVSrsd+wnOJdLefxIaaWCgnY9PgN5b7NZpC0T38qcL25B2+lzVvZUWvnlne50VH 3ygQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=3A7WMJ76bdC/yjM0taClFBBVJI+1xTiueeBFwhbcgIo=; b=zjiEHDUZ+tSDW6usPYvqXnSVfal+Of8eENogiL50id+6OyzoJ8pbM9c6bfEwd9RtTV DCgRa/trZcYExeVYoL1Sp429kgDzjh8Hyr4MKvv7hZeFKcOHnAiwDPDCEm46acfjNKbR ntSVZZq1Z3n92dIlVw8fl4/zFmhGlgS02FoiLln4qIC4SkGM1szzljB7Wbw0sDMgxM7l ehumn0JyUhLIVTDqDR1LiM7/H2Ze7oF0tKY4EpnQwtOlFD/aconPw1uXF1keh5DncbPP sZo721zyqdeWM7I77NCAZ9YF5bzNe1GrqCLSgqCAyahBpcctThXj2b8NWvGxFaY/dr6K zyiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Mt57i3C5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dd6-20020a1709069b8600b007c0b7b5ff5csi8191346ejc.646.2022.12.12.17.52.04; Mon, 12 Dec 2022 17:52:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Mt57i3C5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234228AbiLMBhn (ORCPT + 75 others); Mon, 12 Dec 2022 20:37:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234227AbiLMBhU (ORCPT ); Mon, 12 Dec 2022 20:37:20 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB9181D649 for ; Mon, 12 Dec 2022 17:37:13 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1FAF9612D8 for ; Tue, 13 Dec 2022 01:37:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56107C433EF; Tue, 13 Dec 2022 01:37:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670895432; bh=qHAKz4zQiEtNGuG7TP8jvudxvYKBpAmVefUIJ+uqs5E=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Mt57i3C5BMe59Ibi2k9I4jgtSACRzYJS0arvweYQPcpPhy7iRRIE+KkII4c/xWNcd hRjfIt71rkBnKG4PAJX2hycmuv3gvsQmZGwtGwOYxTPSBsVzqT2hfrwHeHAD1ruNVK K/vInObXv7ZofJkK18HDYx6JWgpCT1+FfUIZKmjTqyF6GfDvey3VfIAJtwSSZiCooG tMSg135iN4gbxr7nQsqF3sO1uYVDxHqAGRDgxF1QqgbOLhgb9n/APhUXwxQGc0G5wd tHpF40f+2dsjOe93JksVmiRjzhOB1FckWrPWQPhm+nFN9JRoLmY82MCHD9Z9ompw2E RZx2SyoNJH4hg== Date: Mon, 12 Dec 2022 17:37:10 -0800 From: Jaegeuk Kim To: Chao Yu Cc: Yangtao Li , linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: [PATCH] f2fs: do some cleanup for f2fs module init Message-ID: References: <20221125114736.19423-1-frank.li@vivo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/13, Chao Yu wrote: > On 2022/12/13 6:53, Jaegeuk Kim wrote: > > On 12/11, Chao Yu wrote: > > > On 2022/11/25 19:47, Yangtao Li wrote: > > > > Just for cleanup, no functional changes. > > > > > > > > Signed-off-by: Yangtao Li > > > > --- > > > > fs/f2fs/compress.c | 46 ++++++---------------------------------------- > > > > fs/f2fs/data.c | 14 ++++---------- > > > > fs/f2fs/gc.c | 4 +--- > > > > fs/f2fs/recovery.c | 4 +--- > > > > fs/f2fs/super.c | 8 ++------ > > > > 5 files changed, 14 insertions(+), 62 deletions(-) > > > > > > > > diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c > > > > index d315c2de136f..f920ba8e0e85 100644 > > > > --- a/fs/f2fs/compress.c > > > > +++ b/fs/f2fs/compress.c > > > > @@ -567,10 +567,7 @@ MODULE_PARM_DESC(num_compress_pages, > > > > int f2fs_init_compress_mempool(void) > > > > { > > > > compress_page_pool = mempool_create_page_pool(num_compress_pages, 0); > > > > - if (!compress_page_pool) > > > > - return -ENOMEM; > > > > - > > > > - return 0; > > > > + return compress_page_pool ? 0 : -ENOMEM; > > > > > > I don't think this needs cleanup, other part looks good to me. > > > > What is the point here comparing to the below? fyi; I picked this change. > > IIUC, the question is for Yangtao? :P Heh, to you. :) I think either looks fine. Hence, I'm fine with this patch. > > Thanks, > > > > > > > > > Thanks, > > > > > > > } > > > > void f2fs_destroy_compress_mempool(void) > > > > @@ -1983,9 +1980,7 @@ int f2fs_init_page_array_cache(struct f2fs_sb_info *sbi) > > > > sbi->page_array_slab = f2fs_kmem_cache_create(slab_name, > > > > sbi->page_array_slab_size); > > > > - if (!sbi->page_array_slab) > > > > - return -ENOMEM; > > > > - return 0; > > > > + return sbi->page_array_slab ? 0 : -ENOMEM; > > > > } > > > > void f2fs_destroy_page_array_cache(struct f2fs_sb_info *sbi) > > > > @@ -1993,53 +1988,24 @@ void f2fs_destroy_page_array_cache(struct f2fs_sb_info *sbi) > > > > kmem_cache_destroy(sbi->page_array_slab); > > > > } > > > > -static int __init f2fs_init_cic_cache(void) > > > > +int __init f2fs_init_compress_cache(void) > > > > { > > > > cic_entry_slab = f2fs_kmem_cache_create("f2fs_cic_entry", > > > > sizeof(struct compress_io_ctx)); > > > > if (!cic_entry_slab) > > > > return -ENOMEM; > > > > - return 0; > > > > -} > > > > - > > > > -static void f2fs_destroy_cic_cache(void) > > > > -{ > > > > - kmem_cache_destroy(cic_entry_slab); > > > > -} > > > > - > > > > -static int __init f2fs_init_dic_cache(void) > > > > -{ > > > > dic_entry_slab = f2fs_kmem_cache_create("f2fs_dic_entry", > > > > sizeof(struct decompress_io_ctx)); > > > > if (!dic_entry_slab) > > > > - return -ENOMEM; > > > > - return 0; > > > > -} > > > > - > > > > -static void f2fs_destroy_dic_cache(void) > > > > -{ > > > > - kmem_cache_destroy(dic_entry_slab); > > > > -} > > > > - > > > > -int __init f2fs_init_compress_cache(void) > > > > -{ > > > > - int err; > > > > - > > > > - err = f2fs_init_cic_cache(); > > > > - if (err) > > > > - goto out; > > > > - err = f2fs_init_dic_cache(); > > > > - if (err) > > > > goto free_cic; > > > > return 0; > > > > free_cic: > > > > - f2fs_destroy_cic_cache(); > > > > -out: > > > > + kmem_cache_destroy(cic_entry_slab); > > > > return -ENOMEM; > > > > } > > > > void f2fs_destroy_compress_cache(void) > > > > { > > > > - f2fs_destroy_dic_cache(); > > > > - f2fs_destroy_cic_cache(); > > > > + kmem_cache_destroy(dic_entry_slab); > > > > + kmem_cache_destroy(cic_entry_slab); > > > > } > > > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > > > > index 560fa80590e9..35c19248b1e2 100644 > > > > --- a/fs/f2fs/data.c > > > > +++ b/fs/f2fs/data.c > > > > @@ -39,10 +39,8 @@ static struct bio_set f2fs_bioset; > > > > int __init f2fs_init_bioset(void) > > > > { > > > > - if (bioset_init(&f2fs_bioset, F2FS_BIO_POOL_SIZE, > > > > - 0, BIOSET_NEED_BVECS)) > > > > - return -ENOMEM; > > > > - return 0; > > > > + return bioset_init(&f2fs_bioset, F2FS_BIO_POOL_SIZE, > > > > + 0, BIOSET_NEED_BVECS); > > > > } > > > > void f2fs_destroy_bioset(void) > > > > @@ -4090,9 +4088,7 @@ int f2fs_init_post_read_wq(struct f2fs_sb_info *sbi) > > > > sbi->post_read_wq = alloc_workqueue("f2fs_post_read_wq", > > > > WQ_UNBOUND | WQ_HIGHPRI, > > > > num_online_cpus()); > > > > - if (!sbi->post_read_wq) > > > > - return -ENOMEM; > > > > - return 0; > > > > + return sbi->post_read_wq ? 0 : -ENOMEM; > > > > } > > > > void f2fs_destroy_post_read_wq(struct f2fs_sb_info *sbi) > > > > @@ -4105,9 +4101,7 @@ int __init f2fs_init_bio_entry_cache(void) > > > > { > > > > bio_entry_slab = f2fs_kmem_cache_create("f2fs_bio_entry_slab", > > > > sizeof(struct bio_entry)); > > > > - if (!bio_entry_slab) > > > > - return -ENOMEM; > > > > - return 0; > > > > + return bio_entry_slab ? 0 : -ENOMEM; > > > > } > > > > void f2fs_destroy_bio_entry_cache(void) > > > > diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c > > > > index 0f967b1e98f2..4b0d2fa3a769 100644 > > > > --- a/fs/f2fs/gc.c > > > > +++ b/fs/f2fs/gc.c > > > > @@ -1903,9 +1903,7 @@ int __init f2fs_create_garbage_collection_cache(void) > > > > { > > > > victim_entry_slab = f2fs_kmem_cache_create("f2fs_victim_entry", > > > > sizeof(struct victim_entry)); > > > > - if (!victim_entry_slab) > > > > - return -ENOMEM; > > > > - return 0; > > > > + return victim_entry_slab ? 0 : -ENOMEM; > > > > } > > > > void f2fs_destroy_garbage_collection_cache(void) > > > > diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c > > > > index dea95b48b647..77fd453949b1 100644 > > > > --- a/fs/f2fs/recovery.c > > > > +++ b/fs/f2fs/recovery.c > > > > @@ -923,9 +923,7 @@ int __init f2fs_create_recovery_cache(void) > > > > { > > > > fsync_entry_slab = f2fs_kmem_cache_create("f2fs_fsync_inode_entry", > > > > sizeof(struct fsync_inode_entry)); > > > > - if (!fsync_entry_slab) > > > > - return -ENOMEM; > > > > - return 0; > > > > + return fsync_entry_slab ? 0 : -ENOMEM; > > > > } > > > > void f2fs_destroy_recovery_cache(void) > > > > diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c > > > > index 31435c8645c8..1d56cba495a5 100644 > > > > --- a/fs/f2fs/super.c > > > > +++ b/fs/f2fs/super.c > > > > @@ -288,9 +288,7 @@ static int __init f2fs_create_casefold_cache(void) > > > > { > > > > f2fs_cf_name_slab = f2fs_kmem_cache_create("f2fs_casefolded_name", > > > > F2FS_NAME_LEN); > > > > - if (!f2fs_cf_name_slab) > > > > - return -ENOMEM; > > > > - return 0; > > > > + return f2fs_cf_name_slab ? 0 : -ENOMEM; > > > > } > > > > static void f2fs_destroy_casefold_cache(void) > > > > @@ -4646,9 +4644,7 @@ static int __init init_inodecache(void) > > > > f2fs_inode_cachep = kmem_cache_create("f2fs_inode_cache", > > > > sizeof(struct f2fs_inode_info), 0, > > > > SLAB_RECLAIM_ACCOUNT|SLAB_ACCOUNT, NULL); > > > > - if (!f2fs_inode_cachep) > > > > - return -ENOMEM; > > > > - return 0; > > > > + return f2fs_inode_cachep ? 0 : -ENOMEM; > > > > } > > > > static void destroy_inodecache(void)