From patchwork Tue Apr 15 20:22:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thavatchai Makphaibulchoke X-Patchwork-Id: 339366 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 89D4A140078 for ; Wed, 16 Apr 2014 06:26:27 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753727AbaDOUZk (ORCPT ); Tue, 15 Apr 2014 16:25:40 -0400 Received: from g2t2353.austin.hp.com ([15.217.128.52]:31235 "EHLO g2t2353.austin.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752462AbaDOUZj (ORCPT ); Tue, 15 Apr 2014 16:25:39 -0400 Received: from g2t2360.austin.hp.com (g2t2360.austin.hp.com [16.197.8.247]) by g2t2353.austin.hp.com (Postfix) with ESMTP id 63946117; Tue, 15 Apr 2014 20:25:38 +0000 (UTC) Received: from [16.71.9.87] (tmaclnx.americas.hpqcorp.net [16.71.9.87]) by g2t2360.austin.hp.com (Postfix) with ESMTP id A507946; Tue, 15 Apr 2014 20:25:37 +0000 (UTC) Message-ID: <534D9517.9080701@hp.com> Date: Tue, 15 Apr 2014 14:22:47 -0600 From: Thavatchai Makphaibulchoke User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: Jan Kara CC: T Makphaibulchoke , tytso@mit.edu, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, aswin@hp.com Subject: Re: [PATCH v2] fs/ext4: increase parallelism in updating ext4 orphan list References: <1380728283-61038-1-git-send-email-tmac@hp.com> <1396456148-20455-1-git-send-email-tmac@hp.com> <20140402174109.GD8657@quack.suse.cz> <534C135A.9010803@hp.com> <20140414174024.GC13860@quack.suse.cz> <534D5E02.6030500@hp.com> <20140415172522.GA13276@quack.suse.cz> In-Reply-To: <20140415172522.GA13276@quack.suse.cz> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On 04/15/2014 11:25 AM, Jan Kara wrote: > I have checked the source and I didn't find many places where i_mutex was > not held. But maybe I'm wrong. That's why I wanted to see the patch where > you are using i_mutex instead of hashed mutexes and which didn't perform > good enough. > I've attached two patches. The first one, 0001-Orphan-patch-using-i_mutex-and-removing-s_orphan_loc.patch, is the one you requested, using i_mutex and removing the s_orphan_lock. The second one, 0001-Adding-code-to-collect-i_mutex-usage-during-orphan.patch, with the code to collect statistics on the number of orphan operations with and without holding i_mutex, in case you are also interested, can be applied on top of the first patch. Please note that these two patches is meant for data collection only, as the code is quite of submittal quality. Please also let me know if you have any further comments or suggestion. I'll hold submitting for a couple more days. > > Honza > Thanks, Mak. From a656649fcf6fa5a17697ec55b2bd2ebd77eceac0 Mon Sep 17 00:00:00 2001 From: T Makphaibulchoke Date: Tue, 15 Apr 2014 14:19:44 -0600 Subject: [PATCH] Adding code to collect i_mutex usage during orphan Signed-off-by: T. Makphaibulchoke --- fs/ext4/namei.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 4a1a6a0..e747e43 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -48,6 +48,46 @@ #define NAMEI_RA_BLOCKS 4 #define NAMEI_RA_SIZE (NAMEI_RA_CHUNKS * NAMEI_RA_BLOCKS) +static unsigned long num_add_call; +static unsigned long num_del_call; +static unsigned long num_add_mutex_lock; +static unsigned long num_del_mutex_lock; +static unsigned long num_add_error; +static unsigned long num_del_error; + +static struct kobject *ext4_orphan_kobj; + +static ssize_t ext4_print_count(struct kobject *kobj, struct kobj_attribute + *attr, char *buff) +{ + return sprintf(buff, "Add_mutex_lock %ld(%ld), Del_mutex_lock %ld(%ld).\n", + num_add_mutex_lock, num_add_call, + num_del_mutex_lock, num_del_call); +} + +static ssize_t ext4_print_error(struct kobject *kobj, struct kobj_attribute + *attr, char *buff) +{ + return sprintf(buff, "Add_mutex_lock %ld(%ld), Del_mutex_lock %ld(%ld).\n", + num_add_error, num_add_call, num_del_error, num_del_call); +} + +static struct kobj_attribute ext4_show_count = + __ATTR(ext4_mutex_lock, 0444, ext4_print_count, NULL); + +static struct kobj_attribute ext4_show_error = + __ATTR(ext4_mutex_error, 0444, ext4_print_error, NULL); + +static struct attribute * attrs[] = { + &ext4_show_count.attr, + &ext4_show_error.attr, + NULL +}; + +static struct attribute_group attr_group = { + .attrs = attrs +}; + static struct buffer_head *ext4_append(handle_t *handle, struct inode *inode, ext4_lblk_t *block) @@ -2557,9 +2597,21 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode) if (!EXT4_SB(sb)->s_journal) return 0; + if (!ext4_orphan_kobj) { + ext4_orphan_kobj = kobject_create_and_add("ext4_orphan", NULL); + if (ext4_orphan_kobj) { + int ret = sysfs_create_group(ext4_orphan_kobj, + &attr_group); + pr_warning("%s: sys_create_group ret %d.\n", + __func__, ret); + } + } + + ++num_add_call; if (!mutex_is_locked(&inode->i_mutex)) { lock_mutex = 1; mutex_lock(&inode->i_mutex); + ++num_add_mutex_lock; } if (!list_empty(&EXT4_I(inode)->i_orphan)) @@ -2588,6 +2640,7 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode) */ if (NEXT_ORPHAN(inode) && NEXT_ORPHAN(inode) <= (le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count))) { + ++num_add_error; brelse(iloc.bh); mutex_lock(&EXT4_SB(sb)->s_ondisk_orphan_lock); ////spin_lock(&EXT4_SB(sb)->s_orphan_lock); @@ -2655,9 +2708,11 @@ int ext4_orphan_del(handle_t *handle, struct inode *inode) !(sbi->s_mount_state & EXT4_ORPHAN_FS)) return 0; + ++num_del_call; if (!mutex_is_locked(&inode->i_mutex)) { lock_mutex = 1; mutex_lock(&inode->i_mutex); + ++num_del_mutex_lock; } if (list_empty(&ei->i_orphan)) { @@ -2679,6 +2734,7 @@ int ext4_orphan_del(handle_t *handle, struct inode *inode) list_del_init(&ei->i_orphan); mutex_unlock(&sbi->s_ondisk_orphan_lock); ////spin_unlock(&sbi->s_orphan_lock); + ++num_del_error; } else err = ext4_reserve_inode_write(handle, inode, &iloc); -- 1.7.11.3