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 3B864C433EF for ; Wed, 26 Jan 2022 22:51:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 97BA36B0071; Wed, 26 Jan 2022 17:51:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 92BA26B0072; Wed, 26 Jan 2022 17:51:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7A5A26B0073; Wed, 26 Jan 2022 17:51:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0130.hostedemail.com [216.40.44.130]) by kanga.kvack.org (Postfix) with ESMTP id 67CFF6B0071 for ; Wed, 26 Jan 2022 17:51:50 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 2939491AD1 for ; Wed, 26 Jan 2022 22:51:50 +0000 (UTC) X-FDA: 79073937180.19.24063C3 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf23.hostedemail.com (Postfix) with ESMTP id A93CA140003 for ; Wed, 26 Jan 2022 22:51:49 +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 49CB321136; Wed, 26 Jan 2022 22:51:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1643237508; 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=UrpK9gFVFFc3QEQ0Z3ktR9+zqmiOMW06uKnM7Gq/rtU=; b=pAyw+3sw1FfhAD1ZWWHHuEeStuC30D7GteS6mR1nWLYRZ64TTpPAphVnQOaLSJqyyxPaIH O72QLqPlvAxrwC4B02VEC/Cha98JW9DMqBNKT3e0UXQaoV5YsnvDbgV6sLpuxkuBXKVzaa +2jaoKmu038KUFc/OApkq5FBZFhW+44= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1643237508; 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=UrpK9gFVFFc3QEQ0Z3ktR9+zqmiOMW06uKnM7Gq/rtU=; b=g6oTCe+TW9F8H+pLJP+hn85cjDcYsDtLn7iJPBKjmCxLVTb/PrZ/k4QHNmgMH+7RBJLcoD Cm5Et4QDp6ahfCDg== 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 242ED13E40; Wed, 26 Jan 2022 22:51:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id Btj7NIDQ8WG/WgAAMHmgww (envelope-from ); Wed, 26 Jan 2022 22:51:44 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 From: "NeilBrown" To: "Mark Hemment" Cc: "Trond Myklebust" , "Anna Schumaker" , "Chuck Lever" , "Andrew Morton" , "Mel Gorman" , "Christoph Hellwig" , "David Howells" , linux-nfs@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 14/23] NFS: swap IO handling is slightly different for O_DIRECT IO In-reply-to: References: <164299573337.26253.7538614611220034049.stgit@noble.brown>, <164299611281.26253.15560926531007295753.stgit@noble.brown>, Date: Thu, 27 Jan 2022 09:51:41 +1100 Message-id: <164323750168.5493.12090358551960276049@noble.neil.brown.name> X-Stat-Signature: q3cpopnzzxa5wh9sjtu5egbpprbxcpqf X-Rspam-User: nil Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=pAyw+3sw; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=g6oTCe+T; spf=pass (imf23.hostedemail.com: domain of neilb@suse.de designates 195.135.220.28 as permitted sender) smtp.mailfrom=neilb@suse.de; dmarc=pass (policy=none) header.from=suse.de X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: A93CA140003 X-HE-Tag: 1643237509-756256 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 Tue, 25 Jan 2022, Mark Hemment wrote: > On Mon, 24 Jan 2022 at 03:53, NeilBrown wrote: > > > > 1/ Taking the i_rwsem for swap IO triggers lockdep warnings regarding > > possible deadlocks with "fs_reclaim". These deadlocks could, I believ= e, > > eventuate if a buffered read on the swapfile was attempted. > > > > We don't need coherence with the page cache for a swap file, and > > buffered writes are forbidden anyway. There is no other need for > > i_rwsem during direct IO. So never take it for swap_rw() > > > > 2/ generic_write_checks() explicitly forbids writes to swap, and > > performs checks that are not needed for swap. So bypass it > > for swap_rw(). > > > > Signed-off-by: NeilBrown > > --- > > fs/nfs/direct.c | 30 +++++++++++++++++++++--------- > > fs/nfs/file.c | 4 ++-- > > include/linux/nfs_fs.h | 4 ++-- > > 3 files changed, 25 insertions(+), 13 deletions(-) > > > ... > > @@ -943,7 +954,8 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, str= uct iov_iter *iter) > > pos >> PAGE_SHIFT, end); > > } > > > > - nfs_end_io_direct(inode); > > + if (!swap) > > + nfs_end_io_direct(inode); >=20 > Just above this code diff, there is; > if (mapping->nrpages) { > invalidate_inode_pages2_range(mapping, > pos >> PAGE_SHIFT, end); > } >=20 > This invalidation looks strange/wrong for a NFS swap write. Should it > be disabled for the swap case? Yes, I think it should - particularly as we don't take the mutex in the swap case. Thanks! This change improves the look of the code too :-) Thanks, NeilBrown