From patchwork Sat Mar 10 18:18:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andiry Xu X-Patchwork-Id: 10273963 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1EB1D605D2 for ; Sat, 10 Mar 2018 18:21:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D4C629106 for ; Sat, 10 Mar 2018 18:21:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0181E296E5; Sat, 10 Mar 2018 18:21:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=no version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AFD8D2975F for ; Sat, 10 Mar 2018 18:21:46 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 85B9F226462FB; Sat, 10 Mar 2018 10:15:18 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400e:c00::243; helo=mail-pf0-x243.google.com; envelope-from=jix024@eng.ucsd.edu; receiver=linux-nvdimm@lists.01.org Received: from mail-pf0-x243.google.com (mail-pf0-x243.google.com [IPv6:2607:f8b0:400e:c00::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 8B926226462F8 for ; Sat, 10 Mar 2018 10:15:17 -0800 (PST) Received: by mail-pf0-x243.google.com with SMTP id a16so2614909pfn.9 for ; Sat, 10 Mar 2018 10:21:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eng.ucsd.edu; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9C9qI/DKDRVjJe2Nglx8k6p2hItWb+mTwUASmPBBnnI=; b=dD+Hn+pZrHLn0SCI3zYUzrmTU/jbEaFEWltuk16QGGV/0hlYDi6vi14kb48BJmtWiO WuS3wnuf9FhUbRRHe+H+nK57beVkdzn0BjsA+9QdL9zaq7/blB7KPpNGLnQZMfsmMZq5 4h+4xp0eeS5ieEpYAuoBe4EUoKUZUBZHtSCWQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9C9qI/DKDRVjJe2Nglx8k6p2hItWb+mTwUASmPBBnnI=; b=M5N3icHf/+dQr2jNag5kLzYhbDjM1wdKVlEu+UC746cpDWyok1Ui5TLhmV8pNeqXPE SPvUnq34xD+YLZmYwt/0ueTC9ngoS5Y5X4MEGiybK+ksLQLR3ufLWJ2rC0WsuszbQeWj CLDlTer+HYYaIMRPsPsHSEWnbnKCLJGAg0Mz16Zl7SoZPha6tRUgb8GZTO++933mS1X8 olnsOMxX3aqiSRVbf/JpEBY96PLlpdb/TnsUtvJETXlkw5LP+YnRSfzNSZUp9+Co/RpV Ttlf1nIbvtpGcx9atzQKHLgQfqhP5nq5P7ulIwYX0GPzgEDmBa5afZF3Y3N2+ZXWITIq gCPw== X-Gm-Message-State: AElRT7H+vlEgBUadikZm2dGFJcKVMPMpQOIsJRxHUm0JhWVtZhys39Rf NgvIQtTxqIcGAFyv0dHj7hSEeo8eB4M= X-Google-Smtp-Source: AG47ELulDUAgZUTVK2ROzVZgfJG+ElgT710/k7s3/YY7WkaqkyqUHYEMWeqvShsq3CkwUoMVR8EsvA== X-Received: by 10.99.105.202 with SMTP id e193mr2186262pgc.84.1520706096005; Sat, 10 Mar 2018 10:21:36 -0800 (PST) Received: from brienza-desktop.8.8.4.4 (andxu.ucsd.edu. [132.239.17.134]) by smtp.gmail.com with ESMTPSA id h80sm9210167pfj.181.2018.03.10.10.21.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 10 Mar 2018 10:21:35 -0800 (PST) From: Andiry Xu To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org Subject: [RFC v2 66/83] Super: Add file write item cache. Date: Sat, 10 Mar 2018 10:18:47 -0800 Message-Id: <1520705944-6723-67-git-send-email-jix024@eng.ucsd.edu> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520705944-6723-1-git-send-email-jix024@eng.ucsd.edu> References: <1520705944-6723-1-git-send-email-jix024@eng.ucsd.edu> X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: coughlan@redhat.com, miklos@szeredi.hu, Andiry Xu , david@fromorbit.com, jack@suse.com, swanson@cs.ucsd.edu, swhiteho@redhat.com, andiry.xu@gmail.com MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP From: Andiry Xu nova_file_write_item combines a file write item with a list head. NOVA uses a linked list of file write items to describe a write operation. Signed-off-by: Andiry Xu --- fs/nova/super.c | 43 ++++++++++++++++++++++++++++++++++++++++++- fs/nova/super.h | 3 +++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/fs/nova/super.c b/fs/nova/super.c index 0847e57..9710be8 100644 --- a/fs/nova/super.c +++ b/fs/nova/super.c @@ -55,6 +55,7 @@ static const struct export_operations nova_export_ops; static struct kmem_cache *nova_inode_cachep; static struct kmem_cache *nova_range_node_cachep; +static struct kmem_cache *nova_file_write_item_cachep; /* FIXME: should the following variable be one per NOVA instance? */ @@ -791,6 +792,21 @@ inline void nova_free_inode_node(struct super_block *sb, nova_free_range_node(node); } +inline void nova_free_file_write_item(struct nova_file_write_item *item) +{ + kmem_cache_free(nova_file_write_item_cachep, item); +} + +inline struct nova_file_write_item * +nova_alloc_file_write_item(struct super_block *sb) +{ + struct nova_file_write_item *p; + + p = (struct nova_file_write_item *) + kmem_cache_alloc(nova_file_write_item_cachep, GFP_NOFS); + return p; +} + inline struct nova_range_node *nova_alloc_range_node(struct super_block *sb) { struct nova_range_node *p; @@ -849,6 +865,18 @@ static int __init init_rangenode_cache(void) return 0; } +static int __init init_file_write_item_cache(void) +{ + nova_file_write_item_cachep = kmem_cache_create( + "nova_file_write_item_cache", + sizeof(struct nova_file_write_item), + 0, (SLAB_RECLAIM_ACCOUNT | + SLAB_MEM_SPREAD), NULL); + if (nova_file_write_item_cachep == NULL) + return -ENOMEM; + return 0; +} + static int __init init_inodecache(void) { nova_inode_cachep = kmem_cache_create("nova_inode_cache", @@ -875,6 +903,11 @@ static void destroy_rangenode_cache(void) kmem_cache_destroy(nova_range_node_cachep); } +static void destroy_file_write_item_cache(void) +{ + kmem_cache_destroy(nova_file_write_item_cachep); +} + /* * the super block writes are all done "on the fly", so the @@ -974,14 +1007,21 @@ static int __init init_nova_fs(void) if (rc) goto out1; - rc = register_filesystem(&nova_fs_type); + rc = init_file_write_item_cache(); if (rc) goto out2; + rc = register_filesystem(&nova_fs_type); + if (rc) + goto out3; + out: NOVA_END_TIMING(init_t, init_time); return rc; +out3: + destroy_file_write_item_cache(); + out2: destroy_inodecache(); @@ -993,6 +1033,7 @@ static int __init init_nova_fs(void) static void __exit exit_nova_fs(void) { unregister_filesystem(&nova_fs_type); + destroy_file_write_item_cache(); destroy_inodecache(); destroy_rangenode_cache(); } diff --git a/fs/nova/super.h b/fs/nova/super.h index 56a840e..bcf9548 100644 --- a/fs/nova/super.h +++ b/fs/nova/super.h @@ -160,8 +160,11 @@ static inline struct nova_super_block *nova_get_super(struct super_block *sb) extern void nova_error_mng(struct super_block *sb, const char *fmt, ...); extern struct nova_range_node *nova_alloc_range_node(struct super_block *sb); extern inline struct nova_range_node *nova_alloc_inode_node(struct super_block *sb); +extern struct nova_file_write_item * +nova_alloc_file_write_item(struct super_block *sb); extern void nova_free_range_node(struct nova_range_node *node); extern inline void nova_free_inode_node(struct super_block *sb, struct nova_range_node *node); +void nova_free_file_write_item(struct nova_file_write_item *item); #endif