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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6E2DC4332F for ; Wed, 26 Jan 2022 21:42:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2C4666B0071; Wed, 26 Jan 2022 16:42:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 272E86B0072; Wed, 26 Jan 2022 16:42:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 13B3D6B0073; Wed, 26 Jan 2022 16:42:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0247.hostedemail.com [216.40.44.247]) by kanga.kvack.org (Postfix) with ESMTP id 0593F6B0071 for ; Wed, 26 Jan 2022 16:42:58 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id B4ED6944E4 for ; Wed, 26 Jan 2022 21:42:57 +0000 (UTC) X-FDA: 79073763594.04.9C74136 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf25.hostedemail.com (Postfix) with ESMTP id 517AAA000E for ; Wed, 26 Jan 2022 21:42:57 +0000 (UTC) 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 D8054218E8; Wed, 26 Jan 2022 21:42:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1643233375; 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=j8D3/iSgudTfOpodQ4uNAeH04etbukj0qfZT65VmtRY=; b=O77jZ50FJkC7iNzTXGMDV2hNmUTIPLrSyjOFTujn+j9nacM71F+7k27HTvyaeMEKkwzru+ 2Mbd4AF5ug1FWf9/Vx/2VBe49pXR9L+CVG86KHUcw7kIEUsfCudpe5UgY4o/DinWN4/tZb pYsAHN+VjSqUL6htxeDYd5g9NSlfX9c= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1643233375; 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=j8D3/iSgudTfOpodQ4uNAeH04etbukj0qfZT65VmtRY=; b=dqNYRcFwnQNpOkMjkxCrgrcqfv6bp+DnkNy/sKad0ob00MRP4UtF3/ApM09Uktzou9AKH2 URcoL9hBtUB7e6AA== 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 0089B13E3C; Wed, 26 Jan 2022 21:42:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id hRo/LFzA8WFDQgAAMHmgww (envelope-from ); Wed, 26 Jan 2022 21:42:52 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 From: "NeilBrown" To: "Trond Myklebust" Cc: "mgorman@suse.de" , "dhowells@redhat.com" , "hch@infradead.org" , "anna.schumaker@netapp.com" , "chuck.lever@oracle.com" , "akpm@linux-foundation.org" , "linux-mm@kvack.org" , "linux-nfs@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 22/23] NFS: swap-out must always use STABLE writes. In-reply-to: References: <164299573337.26253.7538614611220034049.stgit@noble.brown>, <164299611287.26253.13462969110743208198.stgit@noble.brown>, Date: Thu, 27 Jan 2022 08:42:49 +1100 Message-id: <164323336953.5493.18342144609889647048@noble.neil.brown.name> X-Rspamd-Queue-Id: 517AAA000E X-Rspam-User: nil Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=O77jZ50F; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=dqNYRcFw; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf25.hostedemail.com: domain of neilb@suse.de designates 195.135.220.28 as permitted sender) smtp.mailfrom=neilb@suse.de X-Stat-Signature: zrbuou3jxxsekpdp8q7ea9hc5beqhk4n X-Rspamd-Server: rspam08 X-HE-Tag: 1643233377-782765 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, 26 Jan 2022, Trond Myklebust wrote: > On Mon, 2022-01-24 at 14:48 +1100, NeilBrown wrote: > > The commit handling code is not safe against memory-pressure > > deadlocks > > when writing to swap.=C2=A0 In particular, nfs_commitdata_alloc() blocks > > indefinitely waiting for memory, and this can consume all available > > workqueue threads. > >=20 > > swap-out most likely uses STABLE writes anyway as COND_STABLE > > indicates > > that a stable write should be used if the write fits in a single > > request, and it normally does.=C2=A0 However if we ever swap with a small > > wsize, or gather unusually large numbers of pages for a single write, > > this might change. > >=20 > > For safety, make it explicit in the code that direct writes used for > > swap > > must always use FLUSH_COND_STABLE. >=20 > OK. Your explanation above has me extremely confused. >=20 > If you want to avoid commit, then you should be using FLUSH_STABLE, > since that forces the writes to be synchronous. FLUSH_COND_STABLE can > and will use unstable writes if it sees that there are more writes to > come. >=20 > >=20 > > Signed-off-by: NeilBrown > > --- > > =C2=A0fs/nfs/direct.c |=C2=A0=C2=A0=C2=A0 7 ++++--- > > =C2=A01 file changed, 4 insertions(+), 3 deletions(-) > >=20 > > diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c > > index 43a956d7fd62..29c007b2a17a 100644 > > --- a/fs/nfs/direct.c > > +++ b/fs/nfs/direct.c > > @@ -791,7 +791,7 @@ static const struct nfs_pgio_completion_ops > > nfs_direct_write_completion_ops =3D { > > =C2=A0 */ > > =C2=A0static ssize_t nfs_direct_write_schedule_iovec(struct nfs_direct_req > > *dreq, > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct iov_iter *iter, > > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 loff_t pos) > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 loff_t pos, int > > ioflags) > > =C2=A0{ > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0struct nfs_pageio_descrip= tor desc; > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0struct inode *inode =3D d= req->inode; > > @@ -799,7 +799,7 @@ static ssize_t > > nfs_direct_write_schedule_iovec(struct nfs_direct_req *dreq, > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0size_t requested_bytes = =3D 0; > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0size_t wsize =3D max_t(si= ze_t, NFS_SERVER(inode)->wsize, > > PAGE_SIZE); > > =C2=A0 > > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0nfs_pageio_init_write(&desc, i= node, FLUSH_COND_STABLE, false, > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0nfs_pageio_init_write(&desc, i= node, ioflags, false, > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 &nfs_direct_write_completion_ops); > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0desc.pg_dreq =3D dreq; > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0get_dreq(dreq); > > @@ -905,6 +905,7 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, > > struct iov_iter *iter, > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0struct nfs_direct_req *dr= eq; > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0struct nfs_lock_context *= l_ctx; > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0loff_t pos, end; > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0int ioflags =3D swap ? FLUSH_C= OND_STABLE : FLUSH_STABLE; >=20 > This is an unacceptable change in behaviour for the non-swap case, so > NACK. >=20 Hi Trond, thanks for the review. You are right - I had that test exactly backwards. I've fixed for the next version. Thanks, NeilBrown