Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2083747ybh; Fri, 17 Jul 2020 08:54:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNOF41UOeGZNJJnqn3Fbz2wMrHVbfcowRKCTogICN9zvDMpTPX0eF7Ae8DCZ/OoAOAVrGq X-Received: by 2002:a17:906:1697:: with SMTP id s23mr9662657ejd.166.1595001279397; Fri, 17 Jul 2020 08:54:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595001279; cv=none; d=google.com; s=arc-20160816; b=k1cTQERlatSZo62RSDZYSpB6MI9Zn69yXKn5uDguphRcaC8vsvbnkXhJaE+XphIrUd 2NqCn6bdhhCwmXIw8t0g/ykGrPwIxYe3HDm+8GT8HXaBHdhWW5olYHAoKR3jobszvNh5 7swcJ5Qfavlo9a9yveAujveoR2NjsOiAuW3WiE1s255n2Zye6v/57nMpkSEqX0rti4jh zSQJmcCzmsML/nbcTYIrAQ6lbXtlxRJfnHDh+IH5LpB4X4tc8XdMpCRXi6b8gfn2+4Fx jRSlrpYgdvvC92l85oGODqoD0QJv3LEsweA/lPkaieIyoOwasIRndbtXxsnRkffCVPr0 NeUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=iPdgtSMhhOtyD/rVpdKYp3EjPeNzrzmDdwtpfAyv61c=; b=c0pHcrgDoyrI6Q5l8P8lnl2R/Rcf8bJOIp507KgL+5RoOkm5nV+FpIKpWrs+5uySk+ TDfcLIRYvjhbUmLMoXoPvibGCm7Jw4smVpJVo6f++r6QjDwS1lDmM9gl2rcUGuMrvRfu Xgu0ZeXPl8re3fyJdH9bou7kgXjTYldbSGrLA4fhDjM++CIQpCnbx4L6rb/gzu2xX8u/ mgMZyidXbHHj9711zaZ0+8HHtoQ75rEH1DOXUX8l4UKu+6Jphc4t39XnM2/Crexxpr/J XcpUDtNzB+JSZRRR0P2oKGIQcgl2mgZAfbCvgVltP3XXP7UsMg+4I1DKRBqDvShsW37o Nfig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u18si5664854ejz.388.2020.07.17.08.54.05; Fri, 17 Jul 2020 08:54:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726351AbgGQPyB (ORCPT + 99 others); Fri, 17 Jul 2020 11:54:01 -0400 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:54463 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726344AbgGQPyA (ORCPT ); Fri, 17 Jul 2020 11:54:00 -0400 Received: from callcc.thunk.org (pool-96-230-252-158.bstnma.fios.verizon.net [96.230.252.158]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 06HFrxBQ029543 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 17 Jul 2020 11:53:59 -0400 Received: by callcc.thunk.org (Postfix, from userid 15806) id CD1D2420478; Fri, 17 Jul 2020 11:53:58 -0400 (EDT) From: "Theodore Ts'o" To: Ext4 Developers List Cc: Alex Zhuravlev , Alex Zhuravlev , Andreas Dilger Subject: [PATCH 2/4] ext4: skip non-loaded groups at cr=0/1 when scanning for good groups Date: Fri, 17 Jul 2020 11:53:50 -0400 Message-Id: <20200717155352.1053040-3-tytso@mit.edu> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200717155352.1053040-1-tytso@mit.edu> References: <20200717155352.1053040-1-tytso@mit.edu> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Alex Zhuravlev cr=0 is supposed to be an optimization to save CPU cycles, but if buddy data (in memory) is not initialized then all this makes no sense as we have to do sync IO taking a lot of cycles. also, at cr=0 mballoc doesn't store any avaibale chunk. cr=1 also skips groups using heuristic based on avg. fragment size. it's more useful to skip such groups and switch to cr=2 where groups will be scanned for available chunks. using sparse image and dm-slow virtual device of 120TB was simulated. then the image was formatted and filled using debugfs to mark ~85% of available space as busy. mount process w/o the patch couldn't complete in half an hour (according to vmstat it would take ~10-11 hours). With the patch applied mount took ~20 seconds. Lustre-bug-id: https://jira.whamcloud.com/browse/LU-12988 Signed-off-by: Alex Zhuravlev Reviewed-by: Andreas Dilger --- fs/ext4/mballoc.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 8a1e6e03c088..172994349bf6 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -2195,7 +2195,18 @@ static int ext4_mb_good_group_nolock(struct ext4_allocation_context *ac, /* We only do this if the grp has never been initialized */ if (unlikely(EXT4_MB_GRP_NEED_INIT(grp))) { - ret = ext4_mb_init_group(ac->ac_sb, group, GFP_NOFS); + struct ext4_group_desc *gdp = ext4_get_group_desc(sb, group, + NULL); + int ret; + + /* cr=0/1 is a very optimistic search to find large + * good chunks almost for free. if buddy data is + * not ready, then this optimization makes no sense */ + if (cr < 2 && + !(ext4_has_group_desc_csum(sb) && + (gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)))) + return 0; + ret = ext4_mb_init_group(sb, group, GFP_NOFS); if (ret) return ret; } -- 2.24.1