Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1541316pxm; Thu, 3 Mar 2022 21:18:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJyH+h5Vpx0prCVNdM/3qcBY/UWZqstUf4GtpAOlzgpVfFyGzBtamE0KtMWSQq4lVma5ukKE X-Received: by 2002:a50:e004:0:b0:410:a39b:e30c with SMTP id e4-20020a50e004000000b00410a39be30cmr36973231edl.198.1646371101951; Thu, 03 Mar 2022 21:18:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646371101; cv=none; d=google.com; s=arc-20160816; b=wJJvegrTCdb2z+FSTUSBtiuIijhbkEUTd/I90NI06gd+KtnxiB2Df19JAZD5qPd8Pf /3Px4G5fHBOwhZLvTQnsR1XiWusAfXE7ZqXUR62Lx3/yM+M65+LeNdMznqKTbJi64RJC 2Rimj67iW9qSPqv5Y5m5ON6c9NSXoSuRTYs2EuADxIYbQc+79vu9s/Uo4PwEczXxPe58 ueUoXfYsVH0CPmmEx6jAKGoGRjvfVO+raZQqnOw+CNJp0t95nKF321c+cJuLf1Q3I6zJ ehFriDqVUkVBON1C6nNm03+kacqDPjkJEN9GvqUDVewnZMz1TAMIHRaaKwRR7qKZENPO 5LwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:references:in-reply-to:subject :cc:to:from:mime-version:content-transfer-encoding:dkim-signature :dkim-signature; bh=E1LSsS3hFazVJuoQhofGl3WFIJIfnvw/hjoFnxzGa8Q=; b=Fb3f5ylSGS+HuidP43+0aiwJRGAUQTHbAF7OIjWb7RyuKvSTJytWooq0RN3QWIJt/n b90teK+ax4BRuy90U7k3ngPt4nnxjfewicH+DFQAmz4yqKW5/1gGVWxBOK69dX5FMres HbjjkGU8bsSgoIDUAjYklHFfsz+qZyuEAowIMQAN05J7LrmZWGcbHVz+Q28Aa0kAvcpL t2P/Sxm90xAt5Fa/pjmd6FE6L1OFhf64EdSBRyphxFAkglSKDmLtA4HbxaLxBJpFG/5J UaOOAOaGja+PCM4fbUNeAEGOSKxIbARgkQA/UMizUkmSPLjptxSZoYBfOnuAvyGpEEdc CGSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=kSHYevnI; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b="A/VT+8oY"; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id er17-20020a056402449100b00413baf80a4fsi2027190edb.532.2022.03.03.21.17.45; Thu, 03 Mar 2022 21:18:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=kSHYevnI; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b="A/VT+8oY"; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-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 S237724AbiCDCna (ORCPT + 99 others); Thu, 3 Mar 2022 21:43:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229830AbiCDCn3 (ORCPT ); Thu, 3 Mar 2022 21:43:29 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E99F3D494; Thu, 3 Mar 2022 18:42:41 -0800 (PST) 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 A0B7B218A9; Fri, 4 Mar 2022 02:42:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1646361759; 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=E1LSsS3hFazVJuoQhofGl3WFIJIfnvw/hjoFnxzGa8Q=; b=kSHYevnIlEV/nAB3Xb2sRoUgVahgqrrLpnNU/rj78jXyCzqgxhJIIbDb3QEvOcrMP7LvDe 4NFc1B3zwex4VffmlBHljE0pG1V6JbHvSSVwiwwVFrzzno61GNqQ0x09zyG9WYl/60C2Qy uRIUO2cQUjcdNbPtqxxoPSK3oNfH6hk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1646361759; 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=E1LSsS3hFazVJuoQhofGl3WFIJIfnvw/hjoFnxzGa8Q=; b=A/VT+8oYrZEqs09lFC8Pz065G6GP0zURBYxKKH1zgKh4n8fEz30Rkylz0nWBpbCLzoPCy5 SnbxIVcZ29yF5KDQ== 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 90E5A13AF7; Fri, 4 Mar 2022 02:42:32 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id P4gqE5h8IWLKfwAAMHmgww (envelope-from ); Fri, 04 Mar 2022 02:42:32 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 From: "NeilBrown" To: "Miklos Szeredi" Cc: "Andrew Morton" , "Jan Kara" , "Wu Fengguang" , "Jaegeuk Kim" , "Chao Yu" , "Jeff Layton" , "Ilya Dryomov" , "Trond Myklebust" , "Anna Schumaker" , "Ryusuke Konishi" , "Darrick J. Wong" , "Philipp Reisner" , "Lars Ellenberg" , "Paolo Valente" , "Jens Axboe" , linux-doc@vger.kernel.org, "linux-mm" , linux-nilfs@vger.kernel.org, "Linux NFS list" , linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, "Ext4" , ceph-devel@vger.kernel.org, drbd-dev@lists.linbit.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH 04/11] fuse: remove reliance on bdi congestion In-reply-to: References: <164549971112.9187.16871723439770288255.stgit@noble.brown>, <164549983737.9187.2627117501000365074.stgit@noble.brown>, Date: Fri, 04 Mar 2022 13:42:29 +1100 Message-id: <164636174972.29369.5216919060965840586@noble.neil.brown.name> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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-nfs@vger.kernel.org On Wed, 02 Mar 2022, Miklos Szeredi wrote: > On Tue, 22 Feb 2022 at 04:18, NeilBrown wrote: > > > > The bdi congestion tracking in not widely used and will be removed. > > > > Fuse is one of a small number of filesystems that uses it, setting both > > the sync (read) and async (write) congestion flags at what it determines > > are appropriate times. > > > > The only remaining effect of the sync flag is to cause read-ahead to be > > skipped. > > The only remaining effect of the async flag is to cause (some) > > WB_SYNC_NONE writes to be skipped. > > > > So instead of setting the flags, change: > > - .readahead to stop when it has submitted all non-async pages > > for read. > > - .writepages to do nothing if WB_SYNC_NONE and the flag would be set > > - .writepage to return AOP_WRITEPAGE_ACTIVATE if WB_SYNC_NONE > > and the flag would be set. > > > > The writepages change causes a behavioural change in that pageout() can > > now return PAGE_ACTIVATE instead of PAGE_KEEP, so SetPageActive() will > > be called on the page which (I think) will further delay the next attempt > > at writeout. This might be a good thing. > > > > Signed-off-by: NeilBrown > > --- > > fs/fuse/control.c | 17 ----------------- > > fs/fuse/dev.c | 8 -------- > > fs/fuse/file.c | 17 +++++++++++++++++ > > 3 files changed, 17 insertions(+), 25 deletions(-) > > > > diff --git a/fs/fuse/control.c b/fs/fuse/control.c > > index 000d2e5627e9..7cede9a3bc96 100644 > > --- a/fs/fuse/control.c > > +++ b/fs/fuse/control.c > > @@ -164,7 +164,6 @@ static ssize_t fuse_conn_congestion_threshold_write(s= truct file *file, > > { > > unsigned val; > > struct fuse_conn *fc; > > - struct fuse_mount *fm; > > ssize_t ret; > > > > ret =3D fuse_conn_limit_write(file, buf, count, ppos, &val, > > @@ -178,22 +177,6 @@ static ssize_t fuse_conn_congestion_threshold_write(= struct file *file, > > down_read(&fc->killsb); > > spin_lock(&fc->bg_lock); > > fc->congestion_threshold =3D val; > > - > > - /* > > - * Get any fuse_mount belonging to this fuse_conn; s_bdi is > > - * shared between all of them > > - */ > > - > > - if (!list_empty(&fc->mounts)) { > > - fm =3D list_first_entry(&fc->mounts, struct fuse_mount, f= c_entry); > > - if (fc->num_background < fc->congestion_threshold) { > > - clear_bdi_congested(fm->sb->s_bdi, BLK_RW_SYNC); > > - clear_bdi_congested(fm->sb->s_bdi, BLK_RW_ASYNC); > > - } else { > > - set_bdi_congested(fm->sb->s_bdi, BLK_RW_SYNC); > > - set_bdi_congested(fm->sb->s_bdi, BLK_RW_ASYNC); > > - } > > - } > > spin_unlock(&fc->bg_lock); > > up_read(&fc->killsb); > > fuse_conn_put(fc); > > diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c > > index cd54a529460d..e1b4a846c90d 100644 > > --- a/fs/fuse/dev.c > > +++ b/fs/fuse/dev.c > > @@ -315,10 +315,6 @@ void fuse_request_end(struct fuse_req *req) > > wake_up(&fc->blocked_waitq); > > } > > > > - if (fc->num_background =3D=3D fc->congestion_threshold &&= fm->sb) { > > - clear_bdi_congested(fm->sb->s_bdi, BLK_RW_SYNC); > > - clear_bdi_congested(fm->sb->s_bdi, BLK_RW_ASYNC); > > - } > > fc->num_background--; > > fc->active_background--; > > flush_bg_queue(fc); > > @@ -540,10 +536,6 @@ static bool fuse_request_queue_background(struct fus= e_req *req) > > fc->num_background++; > > if (fc->num_background =3D=3D fc->max_background) > > fc->blocked =3D 1; > > - if (fc->num_background =3D=3D fc->congestion_threshold &&= fm->sb) { > > - set_bdi_congested(fm->sb->s_bdi, BLK_RW_SYNC); > > - set_bdi_congested(fm->sb->s_bdi, BLK_RW_ASYNC); > > - } > > list_add_tail(&req->list, &fc->bg_queue); > > flush_bg_queue(fc); > > queued =3D true; > > diff --git a/fs/fuse/file.c b/fs/fuse/file.c > > index 829094451774..94747bac3489 100644 > > --- a/fs/fuse/file.c > > +++ b/fs/fuse/file.c > > @@ -966,6 +966,14 @@ static void fuse_readahead(struct readahead_control = *rac) > > struct fuse_io_args *ia; > > struct fuse_args_pages *ap; > > > > + if (fc->num_background >=3D fc->congestion_threshold && > > + rac->ra->async_size >=3D readahead_count(rac)) > > + /* > > + * Congested and only async pages left, so skip t= he > > + * rest. > > + */ > > + break; >=20 > Ah, you are taking care of it here... >=20 > Regarding the async part: a potential (corner?) case is if task A is > reading region X and triggering readahead for region Y and at the same > time task B is reading region Y. In the congestion case it can happen > that non-uptodate pages in Y are truncated off the pagecache while B > is waiting for them to become uptodate. I don't think that is a problem. If the second reader finds the non-uptodate page that is waiting for attention from the readahead of the first reader, then it will wait until the page is unlocked. Once it gets the lock, it will find that ->mapping is NULL (in the middle of filemap_update_page() for example) and so will drop the page and try again. Second time around (in e.g. filemap_get_pages()) it will find that there is no page, and so will call pagE_cache_sync_readahead() which allocates some pages as appropriate and calls ->readahead() on them. It might be best for the discarding of pages to having in reverse index order so that there is no risk of waiting and retrying a series of times, but I suspect that wouldn't happen very often. >=20 > This shouldn't be too hard to trigger, just need two sequential > readers of the same file, where one is just ahead of the other. I'll > try to do a test program for this case specifically. Thanks - I'd love to hear of any test results you can produce. Thanks, NeilBrown