Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2213843pxb; Fri, 17 Sep 2021 05:03:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDZHlZLEtXXskRhIo7zhPf2ST5AMjvPF12ybFgLWH36eh7Xe2H2HzREp7GYHJvNapAD/pj X-Received: by 2002:a05:6e02:dd4:: with SMTP id l20mr7664624ilj.256.1631880236058; Fri, 17 Sep 2021 05:03:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631880236; cv=none; d=google.com; s=arc-20160816; b=cP6/NCPfFDkgiaKYCKQYRrUFIOgUZ9tQzg5U7W59movuNz9dB+n6q2WwjZzqx2HFbO ARx64HGhHFkncDMmhPmDd0MignF9k8kCWuZAU68ZNzqKT58n+yrSuDiw8NvsfB1S13Aw bEE7MCTuWIhW6OhqEGjdBFfttrBdw8hU2G9p/OJzYaexRWDPDIxbNJkVrTXM9EovY+Oz PgREziuJ+GZMsfuGmvCTDyNNRGCD1gQ608gON8j+L4kKk3GD8TdXGwkRnl88RFj13a96 HB8aE0ZyTmqu7DxULiRKdYPyRMhcxG6NjDH3OGIYGIz33Xnr29jODuQaWdoZmw9PYztV RMvA== 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:cc:to:from :subject:dkim-signature:dkim-signature; bh=K2Rgi41wxZueRRJfJ3e7t139IMXGOwOFm/IW/86sxa8=; b=kYQ/IdxNUL/0KweLrZkXpgMHmg2maHpExLuDkZeT4Y4D/XtbdiRePcbLuszxmNe7au L0VaqeLwKGoteBWiQFoSeCdmjUFmVQ9FKIpaofBgCdplWU39mVkDcxGY94xa/jv/ZgJF U8GkDi3IcVeVzpW1CpOhKw9NCzRIJshHnBetbvgBbp+7t/zXktFAMcGefnxB52/w3NvI Ig+XGJYq4jdWGIcNMoAzmU8rUWJQ/NX7/iI4hrQl5ywitja0aTYDtmZS5eASvE1wuXIw NJRCaUvMknEhcBN0cxU2RSrcYqlbjDEnnfkFBTyCsv2cKb2FfcFr6LEnXjWd5/LVjCq7 I2wA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=TN9g57Jh; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d7si5728663ila.10.2021.09.17.05.03.42; Fri, 17 Sep 2021 05:03:56 -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; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=TN9g57Jh; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243393AbhIQDBT (ORCPT + 99 others); Thu, 16 Sep 2021 23:01:19 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:56580 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243481AbhIQDBR (ORCPT ); Thu, 16 Sep 2021 23:01:17 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id D0018223BD; Fri, 17 Sep 2021 02:59:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1631847594; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=K2Rgi41wxZueRRJfJ3e7t139IMXGOwOFm/IW/86sxa8=; b=TN9g57JhoeeQCj56ZDT1Z5eH8c3azHNFurn6Qcu8WtVKUJyL+7juZYOKl1ThupKPKuR9Zk wrwCImtWXdb8m2WpjzERGLTMfrZEvG2PAT+/nYm6aGTE1kEUhzGQxoTgg4GRVdjak/X352 u75+NChOvjnDYseuYUWwfwRfaQ3y4LU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1631847594; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=K2Rgi41wxZueRRJfJ3e7t139IMXGOwOFm/IW/86sxa8=; b=wTggxCx6C/rUpvp5f5bdxeTCzPFiiQYeoHK1ofO3v0pxvISag8G6Kmr6h1TGJJjXk9dWpv DMvK0w6KJxde2nCw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8AC2A13D0B; Fri, 17 Sep 2021 02:59:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id OQR+EqQERGGWMwAAMHmgww (envelope-from ); Fri, 17 Sep 2021 02:59:48 +0000 Subject: [PATCH 4/6] EXT4: remove congestion_wait from ext4_bio_write_page, and simplify From: NeilBrown To: Andrew Morton , Theodore Ts'o , Andreas Dilger , "Darrick J. Wong" , Matthew Wilcox , Mel Gorman , Michal Hocko , ". Dave Chinner" , Jonathan Corbet Cc: linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Date: Fri, 17 Sep 2021 12:56:57 +1000 Message-ID: <163184741781.29351.8660877195340279243.stgit@noble.brown> In-Reply-To: <163184698512.29351.4735492251524335974.stgit@noble.brown> References: <163184698512.29351.4735492251524335974.stgit@noble.brown> User-Agent: StGit/0.23 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org congestion_wait() is indistinguishable from schedule_timeout_uninterruptible(). It is best avoided and should be deprecated. It is not needed in ext4_bio_write_page(). There are two cases. If there are no ->io_bio yet, then it is appropriate to use __GFP_NOFAIL which does the waiting in a better place. The code already uses this flag on the second attempt. This patch changes to it always use that flag for this case. If there *are* ->io_bio (in which case the allocation was non-blocking) we submit the io and return the first case. No waiting is needed in this case. So remove the congestion_wait() call, and simplify the code so that the two cases are somewhat clearer. Remove the "if (io->io_bio)" before calling ext4_io_submit() as that test is performed internally by that function. Signed-off-by: NeilBrown --- fs/ext4/page-io.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c index f038d578d8d8..3b6ece0d3ad6 100644 --- a/fs/ext4/page-io.c +++ b/fs/ext4/page-io.c @@ -506,7 +506,7 @@ int ext4_bio_write_page(struct ext4_io_submit *io, * can't happen in the common case of blocksize == PAGE_SIZE. */ if (fscrypt_inode_uses_fs_layer_crypto(inode) && nr_to_submit) { - gfp_t gfp_flags = GFP_NOFS; + gfp_t gfp_flags; unsigned int enc_bytes = round_up(len, i_blocksize(inode)); /* @@ -514,21 +514,18 @@ int ext4_bio_write_page(struct ext4_io_submit *io, * a waiting mask (i.e. request guaranteed allocation) on the * first page of the bio. Otherwise it can deadlock. */ + retry_encrypt: if (io->io_bio) gfp_flags = GFP_NOWAIT | __GFP_NOWARN; - retry_encrypt: + else + gfp_flags = GFP_NOFS | __GFP_NOFAIL; bounce_page = fscrypt_encrypt_pagecache_blocks(page, enc_bytes, 0, gfp_flags); if (IS_ERR(bounce_page)) { ret = PTR_ERR(bounce_page); if (ret == -ENOMEM && (io->io_bio || wbc->sync_mode == WB_SYNC_ALL)) { - gfp_flags = GFP_NOFS; - if (io->io_bio) - ext4_io_submit(io); - else - gfp_flags |= __GFP_NOFAIL; - congestion_wait(BLK_RW_ASYNC, HZ/50); + ext4_io_submit(io); goto retry_encrypt; }