Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp181266lqp; Tue, 11 Jun 2024 20:08:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXA5AOZV3GF3H/7oOdkrHPePKgzWOxM535Mrsumy5T1JoTrpAVJU760t3B23s1Ha42dZfzE5hhZFAxdcyypLimDM3owUcP89jw+SIIvBg== X-Google-Smtp-Source: AGHT+IF/bzHwYkhGD/klEs+XHnBWefpI4DU9KMvpPyFjKW0CJiQyFgdq/NNcAmVVzeTp/XRN18gc X-Received: by 2002:a17:906:4099:b0:a6e:fad2:971 with SMTP id a640c23a62f3a-a6f47f9c4f7mr26487466b.40.1718161696359; Tue, 11 Jun 2024 20:08:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718161696; cv=pass; d=google.com; s=arc-20160816; b=XPKPMkUHZieeE+UtHW+8Z4uoRE4IVOxzgwHUVbt39rGC1QK9qOOkQGGvjTuxYC+4Zb qcRIbxLlFYC0L/ndBv2BHv2aokb4rROrguDqS9+P7BAhTlxaae3oPgMvx5HcxpuYSSOH cmE/zCWZ0/6s2Q4DPAvpOogK5/VKL9+x11Vr1fcHi3s48RM9ErMEOuTNMqnK/2MpmgbB cFLpVAAM6MD6UdloYQTUP1O5ovNqAcQ0IdLf5qK2asapuqBwuFqkmCcu3RvA0goVrBKn U1/mev/Bsrp3ncABV3dYMew6jUiarCBf7JkbOyK7zIh6W8eZAoAk1p9GO8Ad0hnWE/J4 xm+g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=B+lFVtt7CUlG+pgwMyd2Tqt0hK+nhWzaPneVyciCSzg=; fh=+HdF1SWcNPggmowVZtzfZ2+SYSXLLgvZBECjaw6UQek=; b=h5NrK40U3ShvRqpOuzE7Li69/GF/wjbVtiXu+6iCX93ATiL7nz786p8OACiRwpDJ1Y 9gE0FnM0dufjFDcwVAtzYmL8PkxiHIV3F9wTI97hiATUZn5NqeW8dbDiAIyjVyXbzgxN B4zL1yPoDDSq0w/7R9JEblw/iOex7RFIrpbWwYXYBwl80AjimBFtXEaoY+oXVtIUEwz1 JxOV9Y6wOPuUu6G5aEUaQehlAUEgfcqxOyyfOAfa5W6xhQtOuLHqR77LTvAk/2bNKktj bje7QKh2id0bNQG40qd2YZ2a/brcYqc0DfB7N4T794CvKxoVTPR9dKEeUNdm8gQTOCT/ xZiQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=llmGiqKz; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-nfs+bounces-3665-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3665-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a6ef915cb24si435878666b.411.2024.06.11.20.08.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 20:08:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs+bounces-3665-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=llmGiqKz; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-nfs+bounces-3665-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3665-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id D26BD1F22760 for ; Wed, 12 Jun 2024 03:08:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3E46D22F03; Wed, 12 Jun 2024 03:08:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="llmGiqKz" X-Original-To: linux-nfs@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A46522EF3 for ; Wed, 12 Jun 2024 03:08:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718161687; cv=none; b=sCxIGztxxgzQShNPZTzJMr28+zfZpJohQIBacoJoSWf1uScLQTeRNxFuA6I493LUj1cyaVkcD0hJAyTaC8SY83E0Z7LWJ/JzBfbJTp/uqr58v29LyEG3Qj0o/UWqP88UzBG9ZBVFy1yoVnQ+zh2eqETTqjKHtKEYZWQ9P1Tqt8s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718161687; c=relaxed/simple; bh=X3eeEYlS9YLp7iD3PjCjsrl81HV+UMdSCrHhb+Bvz6Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lN/2Vxe8qZbZJeHutg7yXQEzotpibazL+xRsklQUr90il2JV3g21GEqONIlZFjskWPVNYBlLKmaKgkowuWoClv2ZuafybTkyYnu727a0lucFMPZsUa8KP5cVhrtQ2LAoLmeLufMXWVxipZyLTmQUCdTtf0UN50VunHDHoa1KtGw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=llmGiqKz; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7E39C2BD10; Wed, 12 Jun 2024 03:08:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718161687; bh=X3eeEYlS9YLp7iD3PjCjsrl81HV+UMdSCrHhb+Bvz6Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=llmGiqKzW5BkE2K2eysMNYdI2RtF0vl6Ht4MFFlapuygJeFhUwkAt/zomAW1kW0jd uTn86D9ocYNFfSB2qXatqTAifFA1RH90wwCQRW8ruJDLqRLOOd0ycjfF7ae9OVG9Lu jvryH+BvSGSPr9UDxNmIdBIpafS+5CJbHFf1LxQ8JgxCcZmM8Pd4Q7CMtVnfS4uOEh KJTqIx3OD9ZN6oMUxtv69iyVnb9F5+b0LT81aQRC2TQha/TM8PlmFbZsXyFZRpILbs vPUpKzGOvwoDm4Ld7FZccy1SshH1nChdxr1J8mO9IoHLOCSZdSyW48G6m6eDvKPk5P e1JQGhwO9Lm4w== From: Mike Snitzer To: linux-nfs@vger.kernel.org Cc: Jeff Layton , Chuck Lever , Trond Myklebust , NeilBrown , snitzer@hammerspace.com Subject: [RFC PATCH v2 09/15] NFS: Enable localio for non-pNFS I/O Date: Tue, 11 Jun 2024 23:07:46 -0400 Message-ID: <20240612030752.31754-10-snitzer@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240612030752.31754-1-snitzer@kernel.org> References: <20240612030752.31754-1-snitzer@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Trond Myklebust Try a local open of the file we're writing to, and if it succeeds, then do local I/O. Signed-off-by: Trond Myklebust Signed-off-by: Mike Snitzer --- fs/nfs/pagelist.c | 19 ++++++++++--------- fs/nfs/write.c | 7 ++++++- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c index b08420b8e664..3ee78da5ebc4 100644 --- a/fs/nfs/pagelist.c +++ b/fs/nfs/pagelist.c @@ -1063,6 +1063,7 @@ EXPORT_SYMBOL_GPL(nfs_generic_pgio); static int nfs_generic_pg_pgios(struct nfs_pageio_descriptor *desc) { struct nfs_pgio_header *hdr; + struct file *filp; int ret; unsigned short task_flags = 0; @@ -1074,18 +1075,18 @@ static int nfs_generic_pg_pgios(struct nfs_pageio_descriptor *desc) nfs_pgheader_init(desc, hdr, nfs_pgio_header_free); ret = nfs_generic_pgio(desc, hdr); if (ret == 0) { + struct nfs_client *clp = NFS_SERVER(hdr->inode)->nfs_client; + + filp = nfs_local_file_open(clp, hdr->cred, hdr->args.fh, + hdr->args.context); + if (NFS_SERVER(hdr->inode)->nfs_client->cl_minorversion) task_flags = RPC_TASK_MOVEABLE; - ret = nfs_initiate_pgio(desc, - NFS_SERVER(hdr->inode)->nfs_client, - NFS_CLIENT(hdr->inode), - hdr, - hdr->cred, - NFS_PROTO(hdr->inode), - desc->pg_rpc_callops, - desc->pg_ioflags, + ret = nfs_initiate_pgio(desc, clp, NFS_CLIENT(hdr->inode), + hdr, hdr->cred, NFS_PROTO(hdr->inode), + desc->pg_rpc_callops, desc->pg_ioflags, RPC_TASK_CRED_NOREF | task_flags, - NULL); + filp); } return ret; } diff --git a/fs/nfs/write.c b/fs/nfs/write.c index b29b0fd5431f..b2c06b8b88cd 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -1802,6 +1802,8 @@ nfs_commit_list(struct inode *inode, struct list_head *head, int how, struct nfs_commit_info *cinfo) { struct nfs_commit_data *data; + struct nfs_client *clp = NFS_SERVER(inode)->nfs_client; + struct file *filp; unsigned short task_flags = 0; /* another commit raced with us */ @@ -1818,9 +1820,12 @@ nfs_commit_list(struct inode *inode, struct list_head *head, int how, nfs_init_commit(data, head, NULL, cinfo); if (NFS_SERVER(inode)->nfs_client->cl_minorversion) task_flags = RPC_TASK_MOVEABLE; + + filp = nfs_local_file_open(clp, data->cred, data->args.fh, + data->context); return nfs_initiate_commit(NFS_CLIENT(inode), data, NFS_PROTO(inode), data->mds_ops, how, - RPC_TASK_CRED_NOREF | task_flags, NULL); + RPC_TASK_CRED_NOREF | task_flags, filp); } /* -- 2.44.0