From patchwork Fri Aug 3 21:10:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 1272421 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 9D0993FC71 for ; Fri, 3 Aug 2012 21:05:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753119Ab2HCVFp (ORCPT ); Fri, 3 Aug 2012 17:05:45 -0400 Received: from mx1.fusionio.com ([66.114.96.30]:38434 "EHLO mx1.fusionio.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752714Ab2HCVFo (ORCPT ); Fri, 3 Aug 2012 17:05:44 -0400 X-ASG-Debug-ID: 1344027944-03d6a5623f2d28b0001-6jHSXT Received: from mail1.int.fusionio.com (mail1.int.fusionio.com [10.101.1.21]) by mx1.fusionio.com with ESMTP id LhsrhPvaK5GUKU3n (version=TLSv1 cipher=AES128-SHA bits=128 verify=NO) for ; Fri, 03 Aug 2012 15:05:44 -0600 (MDT) X-Barracuda-Envelope-From: JBacik@fusionio.com Received: from localhost (174.99.51.113) by mail.fusionio.com (10.101.1.19) with Microsoft SMTP Server (TLS) id 8.3.83.0; Fri, 3 Aug 2012 15:05:43 -0600 From: Josef Bacik To: Subject: [PATCH] Btrfs: use a slab for btrfs_dio_private Date: Fri, 3 Aug 2012 17:10:47 -0400 X-ASG-Orig-Subj: [PATCH] Btrfs: use a slab for btrfs_dio_private Message-ID: <1344028247-3143-1-git-send-email-jbacik@fusionio.com> X-Mailer: git-send-email 1.7.7.6 MIME-Version: 1.0 X-Barracuda-Connect: mail1.int.fusionio.com[10.101.1.21] X-Barracuda-Start-Time: 1344027944 X-Barracuda-Encrypted: AES128-SHA X-Barracuda-URL: http://10.101.1.180:8000/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at fusionio.com X-Barracuda-Bayes: INNOCENT GLOBAL 0.0000 1.0000 -2.0210 X-Barracuda-Spam-Score: -2.02 X-Barracuda-Spam-Status: No, SCORE=-2.02 using per-user scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=9.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.104596 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org This is in the IO path, let's try to avoid latencies by having our own slab. Thanks, Signed-off-by: Josef Bacik --- fs/btrfs/inode.c | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 8a8f0d6..351dd3b 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -75,6 +75,7 @@ struct kmem_cache *btrfs_trans_handle_cachep; struct kmem_cache *btrfs_transaction_cachep; struct kmem_cache *btrfs_path_cachep; struct kmem_cache *btrfs_free_space_cachep; +struct kmem_cache *btrfs_dip_cachep; #define S_SHIFT 12 static unsigned char btrfs_type_by_mode[S_IFMT >> S_SHIFT] = { @@ -6076,7 +6077,7 @@ failed: dip->logical_offset + dip->bytes - 1); bio->bi_private = dip->private; - kfree(dip); + kmem_cache_free(btrfs_dip_cachep, dip); /* If we had a csum failure make sure to clear the uptodate flag */ if (err) @@ -6121,7 +6122,7 @@ out_test: out_done: bio->bi_private = dip->private; - kfree(dip); + kmem_cache_free(btrfs_dip_cachep, dip); /* If we had an error make sure to clear the uptodate flag */ if (err) @@ -6344,7 +6345,7 @@ static void btrfs_submit_direct(int rw, struct bio *bio, struct inode *inode, skip_sum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM; - dip = kmalloc(sizeof(*dip), GFP_NOFS); + dip = kmem_cache_alloc(btrfs_dip_cachep, GFP_NOFS); if (!dip) { ret = -ENOMEM; goto free_ordered; @@ -7062,6 +7063,8 @@ void btrfs_destroy_cachep(void) kmem_cache_destroy(btrfs_path_cachep); if (btrfs_free_space_cachep) kmem_cache_destroy(btrfs_free_space_cachep); + if (btrfs_dip_cachep) + kmem_cache_destroy(btrfs_dip_cachep); } int btrfs_init_cachep(void) @@ -7096,6 +7099,12 @@ int btrfs_init_cachep(void) if (!btrfs_free_space_cachep) goto fail; + btrfs_dip_cachep = kmem_cache_create("btrfs_dio_private_cache", + sizeof(struct btrfs_dio_private), 0, + SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD, NULL); + if (!btrfs_dip_cachep) + goto fail; + return 0; fail: btrfs_destroy_cachep();