Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp637083pxb; Tue, 5 Apr 2022 16:50:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTl1EjPGqhVnGVyb0RFms1EnbguVtllK0uMyZqAJ5BSG1cM7if8A6x6l3xwLs8d8+TWuy5 X-Received: by 2002:a17:90a:cf94:b0:1ca:7ff9:73eb with SMTP id i20-20020a17090acf9400b001ca7ff973ebmr6840430pju.173.1649202606747; Tue, 05 Apr 2022 16:50:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649202606; cv=none; d=google.com; s=arc-20160816; b=RU6Atg4eVtWOKtqM4MFEkKTRWyTPb4zu5/7vHE0/tDXBF+9R5e5euJLxetySOzsOkw ijw82o+xkR3C3Wubl7m0exYn6CE65GkUN7xtlv/D+kIymz8Hii8TR6hLF2aOmmBwCYGf ZFemg6CmHH5wPee3FpkKk9CcFaXu+enVEWmnMEe81JaK3OkXeL4Tzs023XIaJiFtpEuM G9NNo1iSE09ZgKX4vq/a8g5XJYOqdwY0vU2ig608vuM48pJg9ztZBUim5O8YGZkuDFLB xv+92529xpTbZwwxe4aNE5yonkrB/OMPu2iLDmQC4jr6GqUNHKO//BHqa+HQBkFf15Js So7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ejtI1PTdf9ZgIPA8uxAxVhEBINAvQ9RkffwHtH54u00=; b=ku565cnaupgVYHw2Uftmxm+cOtXTLhuOiVhZ/zPkHlJXEtNDWeV2BfeATUhgwIrnNf JyG6fbhzZA81VOH71POGaLuFOAx+lQPN1I1xpa5TcvTZFN8Wufc52EMCFLrjyZRctveb 1XI7tMDPkf5XWqqTYzdYt0r+4cOgEFjMBafSBzIh5f6zKFO3McUAQeI8/nK3BD37ZjkF XBJ8HtpFZPNGJMbyDwx7lWs674p95UcrXmOjT67N9A1/dfJRrShMpxpNTIKh+0nd3xA2 GXdOrxzfCE5aGI6PE+D309QPu9axWsQtSvEf0J6vpeNTX+S6S2iUAwbtNlA6i5ZEhtN7 MTSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iUGpGwxX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id y5-20020a170902700500b00153b2d16592si12883286plk.410.2022.04.05.16.50.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 16:50:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iUGpGwxX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 94C71114DF3; Tue, 5 Apr 2022 16:34:26 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352393AbiDEOhY (ORCPT + 99 others); Tue, 5 Apr 2022 10:37:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241524AbiDEJgD (ORCPT ); Tue, 5 Apr 2022 05:36:03 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9A5392850; Tue, 5 Apr 2022 02:24:19 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 609B9B81C85; Tue, 5 Apr 2022 09:24:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6157C385C1; Tue, 5 Apr 2022 09:24:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649150657; bh=lzO+z6AoVIcvFgn8IXdAdIOaIsz6Yqp+xI/H9kDkdZA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iUGpGwxXCADKA1vPHlfXm6X2qeG6J0GhgTmPYqfBB9KaFW1X+0KiiViTNyqalmgZX PLEWTcG8WBFfYhAKnTAeDyfqQgJcqMKmkXJ17jaW5wdCOwMrrq2PXX3VR1v06ruEwS +yz+09dPLiW2XlX+3xo2rZfqTvLJlAD9ROWcrPb4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable@kernel.org, Geetika Moolchandani , Nageswara R Sastry , Ritesh Harjani , Ojaswin Mujoo , Theodore Tso Subject: [PATCH 5.15 134/913] ext4: make mb_optimize_scan performance mount option work with extents Date: Tue, 5 Apr 2022 09:19:56 +0200 Message-Id: <20220405070343.847448731@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ojaswin Mujoo commit 077d0c2c78df6f7260cdd015a991327efa44d8ad upstream. Currently mb_optimize_scan scan feature which improves filesystem performance heavily (when FS is fragmented), seems to be not working with files with extents (ext4 by default has files with extents). This patch fixes that and makes mb_optimize_scan feature work for files with extents. Below are some performance numbers obtained when allocating a 10M and 100M file with and w/o this patch on a filesytem with no 1M contiguous block. =============== Workload: dd if=/dev/urandom of=test conv=fsync bs=1M count=10/100 Time taken ===================================================== no. Size without-patch with-patch Diff(%) 1 10M 0m8.401s 0m5.623s 33.06% 2 100M 1m40.465s 1m14.737s 25.6% ============= w/o patch: mballoc: reqs: 17056 success: 11407 groups_scanned: 13643 cr0_stats: hits: 37 groups_considered: 9472 useless_loops: 36 bad_suggestions: 0 cr1_stats: hits: 11418 groups_considered: 908560 useless_loops: 1894 bad_suggestions: 0 cr2_stats: hits: 1873 groups_considered: 6913 useless_loops: 21 cr3_stats: hits: 21 groups_considered: 5040 useless_loops: 21 extents_scanned: 417364 goal_hits: 3707 2^n_hits: 37 breaks: 1873 lost: 0 buddies_generated: 239/240 buddies_time_used: 651080 preallocated: 705 discarded: 478 with patch: mballoc: reqs: 12768 success: 11305 groups_scanned: 12768 cr0_stats: hits: 1 groups_considered: 18 useless_loops: 0 bad_suggestions: 0 cr1_stats: hits: 5829 groups_considered: 50626 useless_loops: 0 bad_suggestions: 0 cr2_stats: hits: 6938 groups_considered: 580363 useless_loops: 0 cr3_stats: hits: 0 groups_considered: 0 useless_loops: 0 extents_scanned: 309059 goal_hits: 0 2^n_hits: 1 breaks: 1463 lost: 0 buddies_generated: 239/240 buddies_time_used: 791392 preallocated: 673 discarded: 446 Fixes: 196e402 (ext4: improve cr 0 / cr 1 group scanning) Cc: stable@kernel.org Reported-by: Geetika Moolchandani Reported-by: Nageswara R Sastry Suggested-by: Ritesh Harjani Signed-off-by: Ojaswin Mujoo Link: https://lore.kernel.org/r/fc9a48f7f8dcfc83891a8b21f6dd8cdf056ed810.1646732698.git.ojaswin@linux.ibm.com Signed-off-by: Theodore Ts'o Signed-off-by: Greg Kroah-Hartman --- fs/ext4/mballoc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -1000,7 +1000,7 @@ static inline int should_optimize_scan(s return 0; if (ac->ac_criteria >= 2) return 0; - if (ext4_test_inode_flag(ac->ac_inode, EXT4_INODE_EXTENTS)) + if (!ext4_test_inode_flag(ac->ac_inode, EXT4_INODE_EXTENTS)) return 0; return 1; }