Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5662440pxb; Wed, 26 Jan 2022 18:00:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJz6cVaBIIpI7QPQs2fC8gGTxvAUk63ZX4f/uzU7q/PZV/tzu4iRdjzFVFsO+9MnTAiGh7n2 X-Received: by 2002:a17:906:c10d:: with SMTP id do13mr1294839ejc.428.1643248846669; Wed, 26 Jan 2022 18:00:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643248846; cv=none; d=google.com; s=arc-20160816; b=WMMMIb6YVHZuNNE4T9sGzbSfTIuwlt0UlQvkC7oouN0BNrgAmiaYUEcVDSUZ9kW6i4 Z/6eG0wNYoX7e4DV+viFC5ePT76dHo2OZFTZVj+OexhZBckQ2YK/iUkCMnBwt+4efFbT HQYiE3CUMyfKoaZVL+uP0vmnozUvknlJRjWC9ssUOSmWkChRRTRK1JS6T++h/xlTOn+h qKMnLjCzHxvAGyPmlfcIUXV2nU/JCy3KTnk5vDc8pHeWcBfl1kbbCAoFY86vHbGkG77L J5GW5YsYFC0juN4exO6KzP8MsTjAqu9iI11nmPevL+OyDIpj0rGkzK245R3wT3Av+r6/ 2J3g== 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=j8D3/iSgudTfOpodQ4uNAeH04etbukj0qfZT65VmtRY=; b=UchI43FMFqynDIwlAVcjC8r5EdFKmaLPwdFOpudgcRseXEDJts5XvHGkvo/Lq7FCX3 qY4z58o2s9B/WUg2NFKTzFDrUlQDCSMLNtCCEmkvFXYAWmhe6AnkhEZCx9wgytiR/W11 bYSVwdB0yee0E17i6rNqhd5hWm/nRcWvkyvCxhaLPh4kFdTGYZk96H4+DOnq7zBVQcCS PtGF30eDkkKLhKm25scKY/PeFnFmkMxsQqqkqn/yQmQvqiyKaD5Ee6ZMVA0J82fHlbqb Q/c/N2Bq1kHj1kxW1YFDO1ZFYeeJ7AN8InZg4oo1ahDhN0QcMK4nUzPoOOTwVUlmt1TI mx/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=O77jZ50F; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hj1si592306ejc.843.2022.01.26.18.00.07; Wed, 26 Jan 2022 18:00:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-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=O77jZ50F; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 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 S232697AbiAZVm5 (ORCPT + 99 others); Wed, 26 Jan 2022 16:42:57 -0500 Received: from smtp-out1.suse.de ([195.135.220.28]:39174 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232672AbiAZVm5 (ORCPT ); Wed, 26 Jan 2022 16:42:57 -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 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> Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org 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