Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp561948lqs; Thu, 13 Jun 2024 20:44:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU5N897eSuXzP5nfY8ZikJGx4Gnf6nxmD38PXgqHdL+9KiXiVi13a/X0pz204zIMwsz9aKU6XRe8EmsmwEtHvYYxSYeT/T/xIqqTPBI2A== X-Google-Smtp-Source: AGHT+IEL6XjoUWNrA37wsxZjzm3Uyzr3HcCSinC+dTZGuj++cyc5/3thFmAzx7sF8gjrHbFWOw7p X-Received: by 2002:a19:f618:0:b0:52c:896f:bc3c with SMTP id 2adb3069b0e04-52ca6e9d7c6mr887865e87.67.1718336689230; Thu, 13 Jun 2024 20:44:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718336689; cv=pass; d=google.com; s=arc-20160816; b=LlLiohkzm6Wb7www727hEHLYYwH1XnPs53a6DwHk7YuUKPmN4wjA655Q/v44FX84ng GkEO4Czf10G9xbcmCZNIDHogHBVBJc8xLea80Sm1vmmXLMWgJqvAXODz85LI23par4ep ECfDh8fp4jT7XPGNF+CCkMrWsV1ez//w4B/VFx5jq0G/Lr9xdaLTQjzDhlbRVmlWyPYr Bp45VVfNiUX6cCODbp7iM/XABOvOEO5R2E/FYGf/t94YdTSSmFS0rCXO+wsgxxvSixlT 9/8fZtb36zOpgYbH63rEWLPGqzihbjLsTxYBmXpn7xYRlJw1yGOyP+lTTsBmUvTq+Tqd rMig== 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=o4OK/n8Mns9qWA97MzaS56FcLrGF6aAOpWiKnMh0IpA1F3jinnxc3JMAZ7MB36tK9z 7PIX7LLQKzKdoKnnY6iYBaaoiS0iIf49OFjdWki+7pihpsruGCoW1fKxSdebjLC2rB8h //Fz44SXuoQYwAQUyZLnbGFwjimVFNvEK1+yx7XnkEtzkUtOpZdjQHcfv0ihuvpbYlRo cTe8cjGQmXTF/jYTdg4yLSScP/heZQEvoQZlZq/y+vG2tNUHPexGSzCNURmITM5WJazZ W9tFmJ6Ur6aH+9s0pB0pBqHRtlEy70LeqnRgHYMEiY7ryLQyH+psnim85CrTdc4s24p6 cusQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=g4rZ2wgh; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-nfs+bounces-3808-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3808-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-a6f573d96c3si130311466b.650.2024.06.13.20.44.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 20:44:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs+bounces-3808-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=g4rZ2wgh; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-nfs+bounces-3808-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3808-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 EBBAE1F24115 for ; Fri, 14 Jun 2024 03:44:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 55D5B146A87; Fri, 14 Jun 2024 03:44:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="g4rZ2wgh" 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 32807ECC for ; Fri, 14 Jun 2024 03:44:38 +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=1718336679; cv=none; b=sOXt17IOx/sxkBfAzaYUH4RJ31z1qkVf29WwWIsXy5kg9GMxbW8jGRAjTOsJo/AzVmP0/iA0AWJhPH7UIylDvv6s/lrHxDhs8ZJmIutkPuFfl6wc4+o9QMTpRaisZPbUVwGzkRPA57dA5fZ5BGKaD9n8BJiF2LnHEmUrrfJsEdw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718336679; c=relaxed/simple; bh=X3eeEYlS9YLp7iD3PjCjsrl81HV+UMdSCrHhb+Bvz6Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CYicmrTrIOjPJnMvwQgqysshDjJV8Adwk/npQZzLkFQl7vJihlEDq6FPNxRI92UuenQg1Pbv6bAcLYyHWsI8cHhdS1C3xD8EAWx5oOT1gsErzBB50v61ijjw3wIB1GJYNYA+xI+cgMbM/wgUei9HStqyjnfbuMvdPh1TSfSjQLc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=g4rZ2wgh; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 918B0C2BBFC; Fri, 14 Jun 2024 03:44:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718336678; bh=X3eeEYlS9YLp7iD3PjCjsrl81HV+UMdSCrHhb+Bvz6Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g4rZ2wghFddpF4zZd1Yk1Ef/Wz7kzuXSfAhT9pe7k56yyV2Nqpv7MJtKokpHpRbgj 3Tw3po7U+2LRFEeNeVp4+tT4XsJLIXUusWpHYHpLD2XkIj+Z3DRP4vJjwR0N4RiFDN R4AEvpQOV7AUIHdCIuUgBCpB1XYD5EY1v/KAcLK7Y9vgDwlwTD63eRGTW3/i2Vg54u pK0D1omTrbkTa8OVuZPeclLIHYS6+LK1z6LWROWIm53C+MpS3metsCRQvvWILvtkRI +rTQ9bMjwGuQhhE4NixJNGzkLnYZlUaeT87A/UrLPcegsLfgtnaQ3Q/OkiZcOtwfV+ XcT7fAx7PyNNQ== From: Mike Snitzer To: linux-nfs@vger.kernel.org Cc: Jeff Layton , Chuck Lever , Trond Myklebust , NeilBrown , snitzer@hammerspace.com Subject: [PATCH v3 08/18] NFS: Enable localio for non-pNFS I/O Date: Thu, 13 Jun 2024 23:44:16 -0400 Message-ID: <20240614034426.31043-9-snitzer@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240614034426.31043-1-snitzer@kernel.org> References: <20240614034426.31043-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