From patchwork Tue Feb 20 09:06:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kunwu X-Patchwork-Id: 13563691 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (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 660AE5F480; Tue, 20 Feb 2024 09:07:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708420037; cv=none; b=uCKUHNnqd2tt33jirugsmBU/Mj+0sL07Hn2vkgftiprmDfBDyxYhnm2a0GAViRzYH9GHQTOsKYO5s+8mn/119/XL7VQd/T7nBZ8T3b/KbMePmwa3ypJn5CRwAwiqwzWmkcvVETvkYqpuz7Ih1nPo3ttyhzZxBy9JhVJPZmxrTJM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708420037; c=relaxed/simple; bh=r8SiPrsysAc4HZ7ufEAzyTQeBwlHaR2NNXzXGtCdN6U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sD4b92E0jtVBgWAzMld03lV4oLFS8Xt9acis+78RpIk2LAVR5oYmEZ/nb3rrJFVDtrINHnu8efL0Cz+EFjazHyUk0F/Cw/xYDbf0I2wMYgQLPAtcoReInAIXqZlicThQQ9IZdOWkgtq2xGoJA6hYdmHGy0eqi2J26PVITcO8gL4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 37072fb0a82f4f7498a6919f677d2ce4-20240220 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.35,REQID:d52da3ea-fede-4560-a2c5-d9c17bc3b230,IP:10, URL:0,TC:0,Content:0,EDM:25,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACT ION:release,TS:20 X-CID-INFO: VERSION:1.1.35,REQID:d52da3ea-fede-4560-a2c5-d9c17bc3b230,IP:10,UR L:0,TC:0,Content:0,EDM:25,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:20 X-CID-META: VersionHash:5d391d7,CLOUDID:0511fefe-c16b-4159-a099-3b9d0558e447,B ulkID:240220170709ULYUHU0O,BulkQuantity:0,Recheck:0,SF:66|38|24|17|19|44|1 02,TC:nil,Content:0,EDM:5,IP:-2,URL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL :0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_FSD,TF_CID_SPAM_FSI,TF_CID_SPAM_SNR,TF_CID_SPAM_FAS X-UUID: 37072fb0a82f4f7498a6919f677d2ce4-20240220 Received: from mail.kylinos.cn [(39.156.73.10)] by mailgw (envelope-from ) (Generic MTA) with ESMTP id 1929369233; Tue, 20 Feb 2024 17:07:07 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id 28BB8E000EBC; Tue, 20 Feb 2024 17:07:07 +0800 (CST) X-ns-mid: postfix-65D46BBA-972832352 Received: from kernel.. (unknown [172.20.15.254]) by mail.kylinos.cn (NSMail) with ESMTPA id C0381E000EBC; Tue, 20 Feb 2024 17:07:03 +0800 (CST) From: Kunwu Chan To: clm@fb.com, josef@toxicpanda.com, dsterba@suse.com Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, Kunwu Chan Subject: [PATCH 1/6] btrfs: Simplify the allocation of slab caches in btrfs_delayed_inode_init Date: Tue, 20 Feb 2024 17:06:40 +0800 Message-Id: <20240220090645.108625-2-chentao@kylinos.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240220090645.108625-1-chentao@kylinos.cn> References: <20240220090645.108625-1-chentao@kylinos.cn> Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use the new KMEM_CACHE() macro instead of direct kmem_cache_create to simplify the creation of SLAB caches. Make the code cleaner and more readable. Signed-off-by: Kunwu Chan --- fs/btrfs/delayed-inode.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c index 08102883f560..8c748c6cdf6d 100644 --- a/fs/btrfs/delayed-inode.c +++ b/fs/btrfs/delayed-inode.c @@ -28,11 +28,7 @@ static struct kmem_cache *delayed_node_cache; int __init btrfs_delayed_inode_init(void) { - delayed_node_cache = kmem_cache_create("btrfs_delayed_node", - sizeof(struct btrfs_delayed_node), - 0, - SLAB_MEM_SPREAD, - NULL); + delayed_node_cache = KMEM_CACHE(btrfs_delayed_node, SLAB_MEM_SPREAD); if (!delayed_node_cache) return -ENOMEM; return 0; From patchwork Tue Feb 20 09:06:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kunwu X-Patchwork-Id: 13563692 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (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 661085F482; Tue, 20 Feb 2024 09:07:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708420038; cv=none; b=YFdgdO/7DYAJ5LX4MZbIxvs8+e54zWP1k3BtBb3x4jRElDf3jGuvORcSfBeNU+jHPfOlYyCYv+9vSgRmCbQago9jZ3EtOMu4SYJkxbpUpXR5Ok6tZOiNKAnv6cmNiuxhsHowCICmCfEYBx6nz2lP8BW4+6phcpwQFjYCt+Nrfbc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708420038; c=relaxed/simple; bh=yCeBxkcgFf4y305eEtZ2unXBrL3xPzCq8j6YfxsJYak=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=F2yWvINbleGOUWFF27utVz7zGpQ/X8I4pLveXC0SZqm+BqmgZ1+yc1ygyFYe7oPZFuygrQj/KfJCHmkj9JvaJDbNSJvo7iH1GEY5a29ZLwmoua7qw6IqIKBTorpreDouOHGYPOl8X2b8azCGWEtdILeopSA1073V1CiBlv2UAEc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: c5c450955cf741889aa72672d3c3c921-20240220 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.35,REQID:53ef1386-50fc-4d93-b6a6-f4f23f2612ef,IP:10, URL:0,TC:0,Content:0,EDM:25,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACT ION:release,TS:20 X-CID-INFO: VERSION:1.1.35,REQID:53ef1386-50fc-4d93-b6a6-f4f23f2612ef,IP:10,UR L:0,TC:0,Content:0,EDM:25,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:20 X-CID-META: VersionHash:5d391d7,CLOUDID:0911fefe-c16b-4159-a099-3b9d0558e447,B ulkID:240220170709V9SKL47A,BulkQuantity:0,Recheck:0,SF:38|24|17|19|44|66|1 02,TC:nil,Content:0,EDM:5,IP:-2,URL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL :0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_FSI,TF_CID_SPAM_SNR,TF_CID_SPAM_FAS,TF_CID_SPAM_FSD X-UUID: c5c450955cf741889aa72672d3c3c921-20240220 Received: from mail.kylinos.cn [(39.156.73.10)] by mailgw (envelope-from ) (Generic MTA) with ESMTP id 921392753; Tue, 20 Feb 2024 17:07:07 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id B4CD7E000EBC; Tue, 20 Feb 2024 17:07:07 +0800 (CST) X-ns-mid: postfix-65D46BBB-548495353 Received: from kernel.. (unknown [172.20.15.254]) by mail.kylinos.cn (NSMail) with ESMTPA id 3AFBDE000EBD; Tue, 20 Feb 2024 17:07:07 +0800 (CST) From: Kunwu Chan To: clm@fb.com, josef@toxicpanda.com, dsterba@suse.com Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, Kunwu Chan Subject: [PATCH 2/6] btrfs: Simplify the allocation of slab caches in ordered_data_init Date: Tue, 20 Feb 2024 17:06:41 +0800 Message-Id: <20240220090645.108625-3-chentao@kylinos.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240220090645.108625-1-chentao@kylinos.cn> References: <20240220090645.108625-1-chentao@kylinos.cn> Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use the new KMEM_CACHE() macro instead of direct kmem_cache_create to simplify the creation of SLAB caches. Signed-off-by: Kunwu Chan --- fs/btrfs/ordered-data.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c index 59850dc17b22..f65d681f4c65 100644 --- a/fs/btrfs/ordered-data.c +++ b/fs/btrfs/ordered-data.c @@ -1236,10 +1236,7 @@ struct btrfs_ordered_extent *btrfs_split_ordered_extent( int __init ordered_data_init(void) { - btrfs_ordered_extent_cache = kmem_cache_create("btrfs_ordered_extent", - sizeof(struct btrfs_ordered_extent), 0, - SLAB_MEM_SPREAD, - NULL); + btrfs_ordered_extent_cache = KMEM_CACHE(btrfs_ordered_extent, SLAB_MEM_SPREAD); if (!btrfs_ordered_extent_cache) return -ENOMEM; From patchwork Tue Feb 20 09:06:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kunwu X-Patchwork-Id: 13563690 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (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 BA6145CDC4; Tue, 20 Feb 2024 09:07:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708420036; cv=none; b=b4FBtX6CyQgUxvcE0bT+A2LPNHnVUuD7TpU9RAdx6WMgN0TZT9o2PjT0b4igNKDtU+MP8kaKOzzB7g/yA84f7GWk7BV/tFg75e0R9mooWq7NjLqR4kISgCZyuQiDIAaLKBe2r10F6nsvEUWVbBBv7ltiTNoyyutggKziuZ/UstE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708420036; c=relaxed/simple; bh=jViJ3zJh5S2RCOGgf/S6HMEGoMjD40/QTYwYjRnaFjY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uaNRCpEQx8BjaI/REYCMpOIXkeJ++R+Sf1LjpWoP2J+sdlvNP9QPRaEt2BMPQtmGg1tOtZ1sHEmDAtKH7Fdt3g9KonvzvBSwyjZ7+TA/DCCOUkscIPiYS3jDeWJKiO0x/sOp6GIyG9RELv6OIbPIKuw/NqZ/SCxfT2iuKycA6KE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 723cc28d881e47c1b7ad6ba5c61e9bd4-20240220 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.35,REQID:990c5bfe-920c-46b6-99b4-291616874d89,IP:10, URL:0,TC:0,Content:0,EDM:25,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACT ION:release,TS:20 X-CID-INFO: VERSION:1.1.35,REQID:990c5bfe-920c-46b6-99b4-291616874d89,IP:10,UR L:0,TC:0,Content:0,EDM:25,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:20 X-CID-META: VersionHash:5d391d7,CLOUDID:470f808f-e2c0-40b0-a8fe-7c7e47299109,B ulkID:2402201707097JI8SRP9,BulkQuantity:0,Recheck:0,SF:19|44|66|38|24|17|1 02,TC:nil,Content:0,EDM:5,IP:-2,URL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL :0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_FSD,TF_CID_SPAM_FSI,TF_CID_SPAM_SNR,TF_CID_SPAM_FAS X-UUID: 723cc28d881e47c1b7ad6ba5c61e9bd4-20240220 Received: from mail.kylinos.cn [(39.156.73.10)] by mailgw (envelope-from ) (Generic MTA) with ESMTP id 177855381; Tue, 20 Feb 2024 17:07:08 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id 4C848E000EBC; Tue, 20 Feb 2024 17:07:08 +0800 (CST) X-ns-mid: postfix-65D46BBC-112189354 Received: from kernel.. (unknown [172.20.15.254]) by mail.kylinos.cn (NSMail) with ESMTPA id C72F4E000EBD; Tue, 20 Feb 2024 17:07:07 +0800 (CST) From: Kunwu Chan To: clm@fb.com, josef@toxicpanda.com, dsterba@suse.com Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, Kunwu Chan Subject: [PATCH 3/6] btrfs: Simplify the allocation of slab caches in btrfs_transaction_init Date: Tue, 20 Feb 2024 17:06:42 +0800 Message-Id: <20240220090645.108625-4-chentao@kylinos.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240220090645.108625-1-chentao@kylinos.cn> References: <20240220090645.108625-1-chentao@kylinos.cn> Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use the new KMEM_CACHE() macro instead of direct kmem_cache_create to simplify the creation of SLAB caches. Signed-off-by: Kunwu Chan --- fs/btrfs/transaction.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 5b3333ceef04..0c069d44e77f 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -2720,9 +2720,8 @@ void __cold __btrfs_abort_transaction(struct btrfs_trans_handle *trans, int __init btrfs_transaction_init(void) { - btrfs_trans_handle_cachep = kmem_cache_create("btrfs_trans_handle", - sizeof(struct btrfs_trans_handle), 0, - SLAB_TEMPORARY | SLAB_MEM_SPREAD, NULL); + btrfs_trans_handle_cachep = KMEM_CACHE(btrfs_trans_handle, + SLAB_TEMPORARY | SLAB_MEM_SPREAD); if (!btrfs_trans_handle_cachep) return -ENOMEM; return 0; From patchwork Tue Feb 20 09:06:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kunwu X-Patchwork-Id: 13563688 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (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 0BB2E5BAC7; Tue, 20 Feb 2024 09:07:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708420036; cv=none; b=EfYq8eXijbrPEaS+bAEnL/ZElBiyX8rQ3LGIsCdhGjScU21CPvPnBW0l/d0TYz6wKaUIvZvodO84OFP8t5qL69vdDmIjt40STHhySodVqkx6WYkcanOe56tjd0rkwfRlCJW8MizGpfelJMLEIEqmfZGEAzZLIuDHquPF3fOz/ww= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708420036; c=relaxed/simple; bh=0ptHOpcD+8+srSvx3GCLyJlqRgc5rBeYkiEmoUZwQ6I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cEaY28k0+Z+SNFwBlhsqE8bXLv0Qh4EsSO/mX6zjAlA1j9bPeXQWtbHV+oK5+VQoqHlx42h2YNPUedCZBCA72ekG2mdd2t6fwWMHl1ojBPrjLwoWFPevA+gekswmYosB3Ks+wVdhzKGXEwLUHzOfxWAV+hzxEJ1H34q7QzuJ2V0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: eca98fc7509f40589942fbe30cfc6015-20240220 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.35,REQID:6c8d00cb-b530-4355-85a8-529f6d000f79,IP:10, URL:0,TC:0,Content:0,EDM:25,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACT ION:release,TS:20 X-CID-INFO: VERSION:1.1.35,REQID:6c8d00cb-b530-4355-85a8-529f6d000f79,IP:10,UR L:0,TC:0,Content:0,EDM:25,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:20 X-CID-META: VersionHash:5d391d7,CLOUDID:0a11fefe-c16b-4159-a099-3b9d0558e447,B ulkID:2402201707093T4YQ6UG,BulkQuantity:0,Recheck:0,SF:66|38|24|17|19|44|1 02,TC:nil,Content:0,EDM:5,IP:-2,URL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL :0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_FAS,TF_CID_SPAM_FSD,TF_CID_SPAM_FSI,TF_CID_SPAM_SNR X-UUID: eca98fc7509f40589942fbe30cfc6015-20240220 Received: from mail.kylinos.cn [(39.156.73.10)] by mailgw (envelope-from ) (Generic MTA) with ESMTP id 265101622; Tue, 20 Feb 2024 17:07:09 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id D75A5E000EBC; Tue, 20 Feb 2024 17:07:08 +0800 (CST) X-ns-mid: postfix-65D46BBC-690154355 Received: from kernel.. (unknown [172.20.15.254]) by mail.kylinos.cn (NSMail) with ESMTPA id 5C8B8E000EBD; Tue, 20 Feb 2024 17:07:08 +0800 (CST) From: Kunwu Chan To: clm@fb.com, josef@toxicpanda.com, dsterba@suse.com Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, Kunwu Chan Subject: [PATCH 4/6] btrfs: Simplify the allocation of slab caches in btrfs_ctree_init Date: Tue, 20 Feb 2024 17:06:43 +0800 Message-Id: <20240220090645.108625-5-chentao@kylinos.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240220090645.108625-1-chentao@kylinos.cn> References: <20240220090645.108625-1-chentao@kylinos.cn> Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use the new KMEM_CACHE() macro instead of direct kmem_cache_create to simplify the creation of SLAB caches. Signed-off-by: Kunwu Chan --- fs/btrfs/ctree.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 33145da449cc..cb9e79eb6140 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -5082,9 +5082,7 @@ int btrfs_previous_extent_item(struct btrfs_root *root, int __init btrfs_ctree_init(void) { - btrfs_path_cachep = kmem_cache_create("btrfs_path", - sizeof(struct btrfs_path), 0, - SLAB_MEM_SPREAD, NULL); + btrfs_path_cachep = KMEM_CACHE(btrfs_path, SLAB_MEM_SPREAD); if (!btrfs_path_cachep) return -ENOMEM; return 0; From patchwork Tue Feb 20 09:06:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kunwu X-Patchwork-Id: 13563693 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (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 8463F5F469; Tue, 20 Feb 2024 09:07:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708420038; cv=none; b=pIac3VrLqb+zBGs5FQlllF7ZSyXvVy7EcFhpbXSCCrEqtTgHaVKUAZNgwqckwjhPjVtX5wv8G5EvasOQdcBbnC74GmaAIm77LT7fpGBh/YnpqBmKGPmVycWH/Yss7nWGy/6XBK33V7EjYEdoa2gDCM5+E2sh3mHPFiAOLA+9F+E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708420038; c=relaxed/simple; bh=Xrzg5fUejmSCuIQ7akCUFAlybcLwAP2lB3k4kNs/lTQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DLtoEkELHsaurUSrLpJz0AIxyxqgO+tDrFOJXWdkypKNElHUn2Usp199O6suueUKpcYKUbqpwqWcW6Z/vht9yQRrPxW10v6p6TPzwiYTHJXKPDt0E1fihjMAP5qM0iAAJh7NVz5QDniKHZERTn887pT9trUm5HS9sjnFGMwFP6k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: f0d91d03f3374452aa7d6f3a41df18f7-20240220 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.35,REQID:f9401f60-a917-43c9-9c1a-23e67ad71597,IP:10, URL:0,TC:0,Content:0,EDM:0,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:-5 X-CID-INFO: VERSION:1.1.35,REQID:f9401f60-a917-43c9-9c1a-23e67ad71597,IP:10,UR L:0,TC:0,Content:0,EDM:0,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-5 X-CID-META: VersionHash:5d391d7,CLOUDID:620f808f-e2c0-40b0-a8fe-7c7e47299109,B ulkID:240220170712071GGCUW,BulkQuantity:1,Recheck:0,SF:66|38|24|17|19|44|1 02,TC:nil,Content:0,EDM:-3,IP:-2,URL:0,File:nil,Bulk:43,QS:nil,BEC:nil,COL :0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_FAS,TF_CID_SPAM_FSD,TF_CID_SPAM_FSI X-UUID: f0d91d03f3374452aa7d6f3a41df18f7-20240220 Received: from mail.kylinos.cn [(39.156.73.10)] by mailgw (envelope-from ) (Generic MTA) with ESMTP id 1887075056; Tue, 20 Feb 2024 17:07:09 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id 7C686E000EBC; Tue, 20 Feb 2024 17:07:09 +0800 (CST) X-ns-mid: postfix-65D46BBD-275354356 Received: from kernel.. (unknown [172.20.15.254]) by mail.kylinos.cn (NSMail) with ESMTPA id E974AE000EBD; Tue, 20 Feb 2024 17:07:08 +0800 (CST) From: Kunwu Chan To: clm@fb.com, josef@toxicpanda.com, dsterba@suse.com Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, Kunwu Chan Subject: [PATCH 5/6] btrfs: Simplify the allocation of slab caches in btrfs_delayed_ref_init Date: Tue, 20 Feb 2024 17:06:44 +0800 Message-Id: <20240220090645.108625-6-chentao@kylinos.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240220090645.108625-1-chentao@kylinos.cn> References: <20240220090645.108625-1-chentao@kylinos.cn> Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use the new KMEM_CACHE() macro instead of direct kmem_cache_create to simplify the creation of SLAB caches. Signed-off-by: Kunwu Chan --- fs/btrfs/delayed-ref.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c index 891ea2fa263c..4a352e00ffde 100644 --- a/fs/btrfs/delayed-ref.c +++ b/fs/btrfs/delayed-ref.c @@ -1242,31 +1242,23 @@ void __cold btrfs_delayed_ref_exit(void) int __init btrfs_delayed_ref_init(void) { - btrfs_delayed_ref_head_cachep = kmem_cache_create( - "btrfs_delayed_ref_head", - sizeof(struct btrfs_delayed_ref_head), 0, - SLAB_MEM_SPREAD, NULL); + btrfs_delayed_ref_head_cachep = KMEM_CACHE(btrfs_delayed_ref_head, + SLAB_MEM_SPREAD); if (!btrfs_delayed_ref_head_cachep) goto fail; - btrfs_delayed_tree_ref_cachep = kmem_cache_create( - "btrfs_delayed_tree_ref", - sizeof(struct btrfs_delayed_tree_ref), 0, - SLAB_MEM_SPREAD, NULL); + btrfs_delayed_tree_ref_cachep = KMEM_CACHE(btrfs_delayed_tree_ref, + SLAB_MEM_SPREAD); if (!btrfs_delayed_tree_ref_cachep) goto fail; - btrfs_delayed_data_ref_cachep = kmem_cache_create( - "btrfs_delayed_data_ref", - sizeof(struct btrfs_delayed_data_ref), 0, - SLAB_MEM_SPREAD, NULL); + btrfs_delayed_data_ref_cachep = KMEM_CACHE(btrfs_delayed_data_ref, + SLAB_MEM_SPREAD); if (!btrfs_delayed_data_ref_cachep) goto fail; - btrfs_delayed_extent_op_cachep = kmem_cache_create( - "btrfs_delayed_extent_op", - sizeof(struct btrfs_delayed_extent_op), 0, - SLAB_MEM_SPREAD, NULL); + btrfs_delayed_extent_op_cachep = KMEM_CACHE(btrfs_delayed_extent_op, + SLAB_MEM_SPREAD); if (!btrfs_delayed_extent_op_cachep) goto fail; From patchwork Tue Feb 20 09:06:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kunwu X-Patchwork-Id: 13563694 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (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 83EC264A80; Tue, 20 Feb 2024 09:07:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708420039; cv=none; b=UZ8ZOct1TsWLEy3MLWmXJk2GvRl2djwqFT30dESBVxMBYYdoy50mCRS6r1vB0lvA518F0xBa75XJ3vGS8p64OpDxJ8i6nn6PL8/51WdJei1OKwlMUzCsq5PD/toPiE8KWpStsopllhDPy4IKa+9iGPz7JKgENW3Yh2LWDZV3dso= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708420039; c=relaxed/simple; bh=ZVH9yOT4c7q095AZG2yUK+V7A9cFcYgpBeR49WkHhxw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gQMpZPQA/Ps5zJeCheUaaOuqO/+1I49AnJhPeYpQKyLTXImvGS0o4Pzr6LIdK8/QJ9tgfWT+xo7YGePWXLd0Q6awGnLfCczZEy8M6IptQV8gZZV1//BB03/7eSSdQ7OHM4/q1Oy0eQblAMsr06Z7i7NdZ7w6nIKw74iBjsHeBhA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 8883bfd10688416286ab884bab5f6b34-20240220 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.35,REQID:19ada77b-d8af-4b53-90f9-792a29b09066,IP:10, URL:0,TC:0,Content:23,EDM:25,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,AC TION:release,TS:43 X-CID-INFO: VERSION:1.1.35,REQID:19ada77b-d8af-4b53-90f9-792a29b09066,IP:10,UR L:0,TC:0,Content:23,EDM:25,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:43 X-CID-META: VersionHash:5d391d7,CLOUDID:492b1984-8d4f-477b-89d2-1e3bdbef96d1,B ulkID:240220170712071GGCUW,BulkQuantity:0,Recheck:0,SF:66|38|24|17|19|44|1 02,TC:nil,Content:4,EDM:5,IP:-2,URL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL :0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_FAS,TF_CID_SPAM_FSD,TF_CID_SPAM_FSI X-UUID: 8883bfd10688416286ab884bab5f6b34-20240220 Received: from mail.kylinos.cn [(39.156.73.10)] by mailgw (envelope-from ) (Generic MTA) with ESMTP id 1037215462; Tue, 20 Feb 2024 17:07:10 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id 132E0E000EBC; Tue, 20 Feb 2024 17:07:10 +0800 (CST) X-ns-mid: postfix-65D46BBD-883011357 Received: from kernel.. (unknown [172.20.15.254]) by mail.kylinos.cn (NSMail) with ESMTPA id 8C7E9E000EBD; Tue, 20 Feb 2024 17:07:09 +0800 (CST) From: Kunwu Chan To: clm@fb.com, josef@toxicpanda.com, dsterba@suse.com Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, Kunwu Chan Subject: [PATCH 6/6] btrfs: Simplify the allocation of slab caches in btrfs_free_space_init Date: Tue, 20 Feb 2024 17:06:45 +0800 Message-Id: <20240220090645.108625-7-chentao@kylinos.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240220090645.108625-1-chentao@kylinos.cn> References: <20240220090645.108625-1-chentao@kylinos.cn> Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use the new KMEM_CACHE() macro instead of direct kmem_cache_create to simplify the creation of SLAB caches. Signed-off-by: Kunwu Chan --- fs/btrfs/free-space-cache.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index d372c7ce0e6b..f62f5c339e18 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c @@ -4156,9 +4156,7 @@ int btrfs_set_free_space_cache_v1_active(struct btrfs_fs_info *fs_info, bool act int __init btrfs_free_space_init(void) { - btrfs_free_space_cachep = kmem_cache_create("btrfs_free_space", - sizeof(struct btrfs_free_space), 0, - SLAB_MEM_SPREAD, NULL); + btrfs_free_space_cachep = KMEM_CACHE(btrfs_free_space, SLAB_MEM_SPREAD); if (!btrfs_free_space_cachep) return -ENOMEM;