From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A44C3C433EF for ; Tue, 21 Jun 2022 21:03:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356006AbiFUVDS (ORCPT ); Tue, 21 Jun 2022 17:03:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356047AbiFUU7W (ORCPT ); Tue, 21 Jun 2022 16:59:22 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9704D33A23; Tue, 21 Jun 2022 13:52:06 -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 283D8B81B54; Tue, 21 Jun 2022 20:51:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B3F1C385A2; Tue, 21 Jun 2022 20:51:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1655844686; bh=H6NX6TEs9CnviYhtTRgOsgwttRWDweRhN6SXPMBDYes=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nN5J4cbtb66UVVIdu7qdwyCHgnXsqvYki8NHI+QVcfMOcOhFG87tPBVK23ZDPb1Gw OYu4FubjNgjJWH/Di2qKzOpCfkyMrmYoGl+q2txQ/V9oto7vcA4hdl8Pb+25n47Jy8 1GEmEg/VHHNHf4WVKK4hK5PGjI4RV8fMO6uDHY1UbZ76wpilwYCpHzvWdt242gBzUM 2VaAgkJhFlp/fNn6tsHYROKVzD0pHRKtH9KNA6tau5/w8V82sAxrBMz0vsk/UInN2v iUZXFGTajGauNuMIABVnbyk6zo2rt8w6uwOKiKojMF69AsuyMVQQI6xawbNyYfaq6P rlCcDJGvjCT/w== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jan Kara , Theodore Ts'o , Sasha Levin , adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 5/7] ext4: improve write performance with disabled delalloc Date: Tue, 21 Jun 2022 16:51:17 -0400 Message-Id: <20220621205120.250779-5-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220621205120.250779-1-sashal@kernel.org> References: <20220621205120.250779-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jan Kara [ Upstream commit 8d5459c11f548131ce48b2fbf45cccc5c382558f ] When delayed allocation is disabled (either through mount option or because we are running low on free space), ext4_write_begin() allocates blocks with EXT4_GET_BLOCKS_IO_CREATE_EXT flag. With this flag extent merging is disabled and since ext4_write_begin() is called for each page separately, we end up with a *lot* of 1 block extents in the extent tree and following writeback is writing 1 block at a time which results in very poor write throughput (4 MB/s instead of 200 MB/s). These days when ext4_get_block_unwritten() is used only by ext4_write_begin(), ext4_page_mkwrite() and inline data conversion, we can safely allow extent merging to happen from these paths since following writeback will happen on different boundaries anyway. So use EXT4_GET_BLOCKS_CREATE_UNRIT_EXT instead which restores the performance. Signed-off-by: Jan Kara Link: https://lore.kernel.org/r/20220520111402.4252-1-jack@suse.cz Signed-off-by: Theodore Ts'o Signed-off-by: Sasha Levin --- fs/ext4/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 1cac574911a7..a19243971e89 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -838,7 +838,7 @@ int ext4_get_block_unwritten(struct inode *inode, sector_t iblock, ext4_debug("ext4_get_block_unwritten: inode %lu, create flag %d\n", inode->i_ino, create); return _ext4_get_block(inode, iblock, bh_result, - EXT4_GET_BLOCKS_IO_CREATE_EXT); + EXT4_GET_BLOCKS_CREATE_UNWRIT_EXT); } /* Maximum number of blocks we map for direct IO at once. */ -- 2.35.1