Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5689571pxb; Wed, 26 Jan 2022 18:56:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJwHO3ODLAeGAZJfxR+4bu7aNggIxi9YceoUAImKKNX5hHPwsp9uZ3z3o2Fj8CHtvtt5lJNl X-Received: by 2002:a17:907:97c9:: with SMTP id js9mr1354705ejc.216.1643252191742; Wed, 26 Jan 2022 18:56:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643252191; cv=none; d=google.com; s=arc-20160816; b=HHSIbBf2Z3FXvL2xv1v4PzKN05j3DfDfUeaEm10bNkxoSxoqJhzFjpGlZTRin9lCYI sFEeweeJPBxPYCJ0ZRybKZcNpxNRjWRe0N/1aYnWPAyllsb///2uUtirtFv/EK+bcrrl HUsP91Ty7qJJnMcSzKTR2Upf9gMxsILlwk8HXfLIzlqIdV0+ClC6HTPeDRHMA10EGHnA 4oo1Tw6ZMu6UkClFYe7U6/SZVBDZ5WejB3kVoEF1pkDIPiUkE9qHKt7yLIMzS2uYTF2u /u9hBDUzW7c7vDl5wdTSeoSSBrmNpGhSqLML7x/sCmbw5Ee8eiy2QTL0eV3irUkfqZQl vPNw== 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=UrpK9gFVFFc3QEQ0Z3ktR9+zqmiOMW06uKnM7Gq/rtU=; b=gUvk5JyC60mcgAIl4479l7bslqYrBPu3V1sF38jXhRGm6dWqc/lciE2RpYtPq49M6V 8pJciShL+WY3WFda91fN3xFwg3rmJQPHdzUIuFrm+XYIxM+uNimLqKGh5PKRhkOvGxNN LqHVXOqwcyleN8l5gdRXz2c8it88rdxCi1uSXeSCD+qzH8YGD66FplYi8fDotdW9gtSW L4hcGaJGZWtpBFe9HccdIwpKKxtqm6CpJhPT3+Sh9y2Eu3HjC3LEmdRZiS0jY2fhkR15 XuilyCrCmZpe6eJduaVlFJe4sCbqfaur2iQjy2oXtz8fnPNSJxL+0BDT+Gru0etXQqfG 3SAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=pAyw+3sw; dkim=neutral (no key) header.i=@suse.de header.b=g6oTCe+T; 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 u7si586879eju.675.2022.01.26.18.56.08; Wed, 26 Jan 2022 18:56:31 -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=pAyw+3sw; dkim=neutral (no key) header.i=@suse.de header.b=g6oTCe+T; 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 S230110AbiAZWvt (ORCPT + 99 others); Wed, 26 Jan 2022 17:51:49 -0500 Received: from smtp-out1.suse.de ([195.135.220.28]:42266 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229742AbiAZWvt (ORCPT ); Wed, 26 Jan 2022 17:51:49 -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 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> Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org 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