From patchwork Tue Jan 19 06:08:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: lokesh jaliminche X-Patchwork-Id: 569801 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 7A63314031D for ; Tue, 19 Jan 2016 17:08:24 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=y3alqcZi; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751467AbcASGIX (ORCPT ); Tue, 19 Jan 2016 01:08:23 -0500 Received: from mail-pa0-f68.google.com ([209.85.220.68]:33361 "EHLO mail-pa0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750930AbcASGIV (ORCPT ); Tue, 19 Jan 2016 01:08:21 -0500 Received: by mail-pa0-f68.google.com with SMTP id pv5so34509565pac.0 for ; Mon, 18 Jan 2016 22:08:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=/Ud8hz7nnEiTC9mGDpOFeVqdHA1tuHglXqIMyeTQI+M=; b=y3alqcZifGzlDNhoCMTQs59PD+cxdDjcg9OJ0fnFjAzcMT1iF8GChcwIxvBVjuZ1fY zurlR4GO+dSAsWbb976Qx0X6VdaE/XObvaQqs2LctFdAlsE8JqJoc/Y46t/2XQAbA3P4 lt4EJn21grRI8wLYXZ4TXvCukGjCoDNfz+cjgmdf1nFAWQeBPn9Ma2y/8dIMvKF92zoN 87/sv9RzhntKoaXiYFjOBce+NARArdRBKATcRQ0IxkriiNj1DwAINxHIEk5AnBZwmEXz 4oKF3jCOVXpmgqOz80o+jMhfwjcMgLvyOcO1VeOsE4lP+rcpZGAFNatOrVnelFFkbVvl RBSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=/Ud8hz7nnEiTC9mGDpOFeVqdHA1tuHglXqIMyeTQI+M=; b=gAqOEs9TtHWd86AXMmjhAgKwbNGOI2fOz/9RoSAbpZo5wm+hzvBZOz/C7FNz6nMgEx CwApfKueeZTsXxX7IkBepEvub4I30A/Iu3bLiQmgK0tZERQeaSGWeh95Z6L+a7JS/jZJ 90w8s+mP39bclCjY8+Mrb9mR0QQd7P0/BZmFDn2tKusBRAHByEo3hmTRVW2iRubNLz66 OAUEuUdKfTHHZbCdhoR1FenE60PGY/PGyVgtewghOjUAON72SgTgxB/uP6+E2ghC6uuE RGJFlp+oyg+GAatSFyN53G3uTpiQJv/7PsrinWg88YMEwnYR7tPjNapsii7r1XpRcFFc 7ZRQ== X-Gm-Message-State: ALoCoQkSXHiHFefRaIkRG8WYPflpdFt0LZ/GSoVTiJiy91u0SWwkzjqMA9DdUFM13Huq67aL6JK5Gk0u5OMLWsThsjsU0t7ISQ== X-Received: by 10.66.184.15 with SMTP id eq15mr41336226pac.42.1453183701242; Mon, 18 Jan 2016 22:08:21 -0800 (PST) Received: from server_lokesh ([106.66.243.12]) by smtp.gmail.com with ESMTPSA id e14sm38405224pap.24.2016.01.18.22.08.17 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 18 Jan 2016 22:08:20 -0800 (PST) Date: Tue, 19 Jan 2016 11:38:12 +0530 From: Lokesh Jaliminche To: Andreas Dilger , Theodore Ts'o Cc: linux-ext4 Subject: Re: [PATCH v6] EXT4: optimizing group search for inode allocation Message-ID: <20160119060812.GA7158@server_lokesh> References: <9CF60D02-FF10-44FF-A31E-D4E99F627AF2@dilger.ca> <20151226084153.GA4248@server_lokesh.domain.name> <2DA2ED68-7DD4-425D-8A47-E896E9BF0F4A@dilger.ca> <20160107004639.GA3902@server_lokesh.domain.name> <687935F0-EEA5-4CB6-9E5C-43E49FBB39E2@dilger.ca> <20160116230226.GB3189@server_lokesh> <1ACAFB33-9F89-4718-99F4-CB0EE7206466@dilger.ca> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1ACAFB33-9F89-4718-99F4-CB0EE7206466@dilger.ca> User-Agent: Mutt/1.5.20 (2009-12-10) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Lokesh Nagappa Jaliminche Subject: [PATCH] ext4: optimizing group serch for inode allocation Added a check at the start of group search loop to avoid looping unecessarily in case of empty group. This also allow group search to jump directly to "found_flex_bg" with "stats" and "group" already set, so there is no need to go through the extra steps of setting "best_desc" , "best_group" and then break out of the loop just to set "stats" and "group" again. Signed-off-by: Lokesh Nagappa Jaliminche Reviewed-by: Andreas Dilger --- fs/ext4/ialloc.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c index 1b8024d..3463d30 100644 --- a/fs/ext4/ialloc.c +++ b/fs/ext4/ialloc.c @@ -477,6 +477,12 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent, (ext4_test_inode_flag(parent, EXT4_INODE_TOPDIR)))) { int best_ndir = inodes_per_group; int ret = -1; + /* Maximum usable blocks per group as some blocks are used + * for inode tables and allocation bitmaps */ + unsigned long long max_blocks_per_flex = + ((sbi->s_blocks_per_group - + (sbi->s_itb_per_group + 2)) * + flex_size) >> sbi->s_cluster_bits; if (qstr) { hinfo.hash_version = DX_HASH_HALF_MD4; @@ -489,6 +495,10 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent, for (i = 0; i < ngroups; i++) { g = (parent_group + i) % ngroups; get_orlov_stats(sb, g, flex_size, &stats); + /* can't get better group than empty group */ + if (max_blocks_per_flex == stats.free_clusters && + (inodes_per_group * flex_size) == stats.free_inodes) + goto found_flex_bg; if (!stats.free_inodes) continue; if (stats.used_dirs >= best_ndir)