Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5913564pxb; Thu, 27 Jan 2022 02:16:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJw1zlyXQb6L7vS7eXYSGAHRA5dmM39osqqX1FTaH1gFZapUgR66xMyZ6JNByazrZLc+mg12 X-Received: by 2002:a17:902:6502:: with SMTP id b2mr2458061plk.43.1643278608105; Thu, 27 Jan 2022 02:16:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643278608; cv=none; d=google.com; s=arc-20160816; b=Ql3wVzO9FdJSXbVdn9m/mmHroqdNVeuk0dMr/O+c3GkpqrvO/fwCuMd7hCcANw1E7y RLE/t4JgDscIPL/IX7knS992Tih6yAv67FhPvryGpfYxI/AcOI7+i457R94BAD+mD02g kBDspMqBChVNy7OzkAhfeuXzrdQvmy3quYX4VgmnRw52UoiZDC0/EIDw7+lX6nyNGUi8 khwFtEo4WU6FQAV8JTUxK6mPNWpFH6Xn5a7ex1KHI2rIKlPdg1/EIQE4GRrde/Amybr7 M2OxwrKb9JfUk0Tec0j6r2edWUHCB8GZiskU0CQywA/d2zky2jEdP1nOfckaIs+ZKmvM vsxw== 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=M8NYMcBcZD8GUv0cDvsP1eePtGigG8J8np/yV6nLjQQ=; b=GQLGMURKbBOae5+s/4aZoFwaVzOqa9Zgy29O29vCBFRY31oM9IXDInRSezUIPD6h9a 6QPPXlBbh6LamGPhYBYAh1HULE5KA3kAeYqw5iRU2jbBqVvZo7VEIUSWE9T8aOonFcX0 iC3mF/T7lewWZPgtolZCONBBQEhlhLHf4TRNiZpnBisCiImMeAwabYY+HdKBfJNfKD66 ESJo3hy2My/E049eafYZaL/MaWNzfUw0m4ppVhVZuz+5ISifA65x5gXVca/9B0byKlNX N+Fqx67n0spPc4PLJgHAkslpccH60nKcichuQIcWiw15EMh+mk9vW4gvqONeqtdj/LgT kjlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=lpTMtDdg; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=GajJ1CW7; 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 e68si1629554pfe.241.2022.01.27.02.16.33; Thu, 27 Jan 2022 02:16:48 -0800 (PST) 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=lpTMtDdg; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=GajJ1CW7; 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 S235285AbiA0Crw (ORCPT + 99 others); Wed, 26 Jan 2022 21:47:52 -0500 Received: from smtp-out1.suse.de ([195.135.220.28]:55138 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235311AbiA0Cru (ORCPT ); Wed, 26 Jan 2022 21:47:50 -0500 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 2D50621901; Thu, 27 Jan 2022 02:47:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1643251668; 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=M8NYMcBcZD8GUv0cDvsP1eePtGigG8J8np/yV6nLjQQ=; b=lpTMtDdgzXu6IXlWF2Cla7JZeA4O6IZP0tjrp8fZaU7ivDos+PHoL/XQMfCABF+bEfNOP4 asGZxs7WKvGfhEBJWG6JTtSILEhDDfyUZDxdz3isEFlXeNYP4t4z60IMGMWtpxXKM9DXAB qZWJthZJaYv1R8Swu1zG6SDpKtDJcMw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1643251668; 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=M8NYMcBcZD8GUv0cDvsP1eePtGigG8J8np/yV6nLjQQ=; b=GajJ1CW7bGmknt+eypyqRIr6NQ5RkVudFMz7+fbL2W6FyuUKWG82yY6INCh5zJBg+nHfCU 1tfjV2LY/eskY2DQ== 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 5662613E46; Thu, 27 Jan 2022 02:47:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 1653BcwH8mHgKwAAMHmgww (envelope-from ); Thu, 27 Jan 2022 02:47:40 +0000 Subject: [PATCH 3/9] f2fs: change retry waiting for f2fs_write_single_data_page() From: NeilBrown To: Andrew Morton , Jaegeuk Kim , Chao Yu , Jeff Layton , Ilya Dryomov , Miklos Szeredi , Trond Myklebust , Anna Schumaker , Ryusuke Konishi , "Darrick J. Wong" , Philipp Reisner , Lars Ellenberg , Paolo Valente , Jens Axboe Cc: linux-mm@kvack.org, linux-nilfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-ext4@vger.kernel.org, ceph-devel@vger.kernel.org, drbd-dev@lists.linbit.com, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org Date: Thu, 27 Jan 2022 13:46:29 +1100 Message-ID: <164325158956.29787.7016948342209980097.stgit@noble.brown> In-Reply-To: <164325106958.29787.4865219843242892726.stgit@noble.brown> References: <164325106958.29787.4865219843242892726.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 f2fs_write_single_data_page() can return -EAGAIN if it cannot get the cp_rwsem lock - it holds a page lock and so cannot wait for it. Some code which calls f2fs_write_single_data_page() use congestion_wait() and then tries again. congestion_wait() doesn't do anything useful as congestion is no longer tracked. So this is just a simple sleep. A better approach is it wait until the cp_rwsem lock can be taken - then try again. There is certainly no point trying again *before* the lock can be taken. Signed-off-by: NeilBrown --- fs/f2fs/compress.c | 6 +++--- fs/f2fs/data.c | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c index d0c3aeba5945..58ff7f4b296c 100644 --- a/fs/f2fs/compress.c +++ b/fs/f2fs/compress.c @@ -1505,9 +1505,9 @@ static int f2fs_write_raw_pages(struct compress_ctx *cc, if (IS_NOQUOTA(cc->inode)) return 0; ret = 0; - cond_resched(); - congestion_wait(BLK_RW_ASYNC, - DEFAULT_IO_TIMEOUT); + /* Wait until we can get the lock, then try again. */ + f2fs_lock_op(F2FS_I_SB(cc->inode)); + f2fs_unlock_op(F2FS_I_SB(cc->inode)); goto retry_write; } return ret; diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 8c417864c66a..1d2341163e2c 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -3047,9 +3047,12 @@ static int f2fs_write_cache_pages(struct address_space *mapping, } else if (ret == -EAGAIN) { ret = 0; if (wbc->sync_mode == WB_SYNC_ALL) { - cond_resched(); - congestion_wait(BLK_RW_ASYNC, - DEFAULT_IO_TIMEOUT); + /* Wait until we can get the + * lock, then try again. + */ + f2fs_lock_op(F2FS_I_SB(mapping->host)); + f2fs_unlock_op(F2FS_I_SB(mapping->host)); + goto retry_write; } goto next;