Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp1076894lqt; Fri, 7 Jun 2024 07:27:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXW1y02jBjgj5hxL+0002nbPJ4WocBKbmoOJK2/Yk/mzZDGuwiaTPemIvbCAO080JZues/MuFUHGmEKtpeAHs+iDoVuAIXRs9YKF7tI6w== X-Google-Smtp-Source: AGHT+IER8n12OCkXYD07uvFstxTutu6TGDoRZuR4KjyU0tDOiJ0J4Zy22KywTGw9Xe5JMWNX+5UH X-Received: by 2002:a05:620a:198c:b0:795:484a:7f05 with SMTP id af79cd13be357-795484a8051mr208408285a.1.1717770452401; Fri, 07 Jun 2024 07:27:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717770452; cv=pass; d=google.com; s=arc-20160816; b=uqGKro1VACJKgQOZT7OOif/y7Y/p3GgEcQE3Y2InjO4e2NH1UPqlwjaNmpsPeb9yZ3 b5AwbDwOOZInQxta3pm3avncCGs97t54w3qCvTHcprnUvFnggPI3jHZDR0FG1ytaRwCq OfRKxJ31pwLSBTOPd5CeneH3P5Sn0ghzHPcqcQ+5JEc3oZN5gq1CXpn8xoce7ec7jjZO UcspogumLAD1Bb+qKGy/C0yry2q+IH8rI1fQjU9mFGWRREGzgjPzPX53KkKgJ6P5IMnR WdJ8hrNtaP+bo9sZlpdbgPxCyi1hv1nTwbbMwiH6xzHo5dc13zkx5SaZ9zuMUaQpvvzR +jrQ== 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; bh=/Aq7tdWcYM5gnb5sx8vyvI27WmyADYKfh1wRJYWT1fc=; fh=OUKZWod6C22emJS3X689dwhO5bDgGbDS06P/Z6+EGqk=; b=w513glzETkxFm3ksUOxW38oBLEaGBSdaTbgvQPgVp8uRfti5m0TE2i3kfAkYpGYgMN 5S4BU9U1WAd6ai3vgAhonMQ1LyeJHTndEleKxGvE55vJ/8lEhylvMBQq8AvspouJHBH3 oY30pmURggybKbqzhRxa8tyUMVEott1oGBKrbZWhuWAGI7XgekZESO/BrdXRn4WipuSh 5xodsEWtPPSHgRdn56dQS/EqJAWtdSfnB7nc947ZMLPr8QstcwOhTjVlEfe2TuvaOCfS 6WxcyYOUFzDUdk0I5RgkpwD0ikqf6ZS4kSqJtp7a+WklV3g5dNoBI40yWDVbPeo5EQna Ye6g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-nfs+bounces-3596-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3596-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-44042afadcfsi5747421cf.428.2024.06.07.07.27.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 07:27:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs+bounces-3596-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-nfs+bounces-3596-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3596-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 1EFC11C22DE1 for ; Fri, 7 Jun 2024 14:27:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8E9D0197521; Fri, 7 Jun 2024 14:27:09 +0000 (UTC) X-Original-To: linux-nfs@vger.kernel.org Received: from mail-qt1-f182.google.com (mail-qt1-f182.google.com [209.85.160.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2DFFF197548 for ; Fri, 7 Jun 2024 14:27:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717770429; cv=none; b=JhHrJEhCMTrk2rJ74ZUto53v61LK7LtQ3uNRZcMXwfDrGq94Cc2D+FC8uuqELKsR5kEan+iROCFYIYegf1sO6/WxxjEl9Bmdq+8APgEYZRZ4pTDXFJj7qLvbUVBoyhcs7cBAA939ZJ1qKhzvaegZhSVZR5WVnv1P+uSQ6JP65jc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717770429; c=relaxed/simple; bh=a6zvs9e7qnjaqwLeRfDsRQX81N4Dwl9FIabubDCuzuE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fV4uByImq27YZ5fCSGIe05vIDl9hoLLW5SJPMgyQbDk0PqLlLvUauuAARkAG8E3vc7cojCThHMkfue0zGQPewKiXZ0q7WI5mZSnFaKUakoN1ual7jtXtOm2C+bmL/wpn3BiylA2zN5OYMMBuUtJz5Rsx3KVw6ibkubPhtAOoTa4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=none smtp.mailfrom=snitzer.net; arc=none smtp.client-ip=209.85.160.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=snitzer.net Received: by mail-qt1-f182.google.com with SMTP id d75a77b69052e-4402066471cso18264671cf.0 for ; Fri, 07 Jun 2024 07:27:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717770427; x=1718375227; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/Aq7tdWcYM5gnb5sx8vyvI27WmyADYKfh1wRJYWT1fc=; b=hV/TNTYtwj9SWr8A9ARVBda0NdccUuqzyH11ve0soEB96AzlpFPhUgi/tHxE1FHXsH 14eq1Ny+ED8fg8wTnH455Gq7HceoBA33H5YD9bs7AIH6VYUQmPCf557bJjsAmbN4nJNZ cWf1GuZsWydOOjlBjCzSnUdFd5UexBQN/739OLRX7JA8twjxx12kqp7X7dzAgMuNX5vt zIjwY6F/+sD3S9MFg1d63PcrzZI2DOI+sEhSdpl0+z7zLAtv9VTeVRbaVqqgBXsyReDX fP4k2AWC7s2kW427H4X0UCNh2n6T/OGTl9zxx2Aid31ybQSORA07Yl+n+VZbufoLWCYf rAww== X-Gm-Message-State: AOJu0YxZePQOezWEAMcz4hbanY3EpvY5nuhSd6VTtdqxBf8M0xxViahP AL+cU9Ie1xhqOiK+O3NlS/PyjLHkcyZs6yMIjrfvkiSvLC75utaZbM5fcMXJ6EwsRJ1cYIcO91I oiF4ulQ== X-Received: by 2002:a05:622a:13cc:b0:440:2f78:37dd with SMTP id d75a77b69052e-440360f6dd5mr111523421cf.0.1717770426721; Fri, 07 Jun 2024 07:27:06 -0700 (PDT) Received: from localhost (pool-68-160-141-91.bstnma.fios.verizon.net. [68.160.141.91]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7953286e1c1sm169556885a.53.2024.06.07.07.27.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 07:27:06 -0700 (PDT) From: Mike Snitzer To: linux-nfs@vger.kernel.org Cc: Jeff Layton , Chuck Lever , Trond Myklebust , snitzer@hammerspace.com Subject: [for-6.11 PATCH 12/29] nfs/flexfiles: check local DS when making DS connections Date: Fri, 7 Jun 2024 10:26:29 -0400 Message-ID: <20240607142646.20924-13-snitzer@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240607142646.20924-1-snitzer@kernel.org> References: <20240607142646.20924-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: Peng Tao Do this by creating DS connection and check local IP address. If it matches DS address (ignoring port), mark mirror_ds->local_ds as true so that later we know if local DS IO is possible. Signed-off-by: Peng Tao Signed-off-by: Lance Shelton Signed-off-by: Trond Myklebust Signed-off-by: Mike Snitzer --- fs/nfs/flexfilelayout/flexfilelayoutdev.c | 25 +++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/fs/nfs/flexfilelayout/flexfilelayoutdev.c b/fs/nfs/flexfilelayout/flexfilelayoutdev.c index e028f5a0ef5f..af329d9b7d1e 100644 --- a/fs/nfs/flexfilelayout/flexfilelayoutdev.c +++ b/fs/nfs/flexfilelayout/flexfilelayoutdev.c @@ -348,6 +348,22 @@ ff_layout_init_mirror_ds(struct pnfs_layout_hdr *lo, return false; } +static bool ff_layout_ds_is_local(struct nfs4_pnfs_ds *ds) +{ + struct nfs_local_addr *addr; + struct sockaddr *sap; + struct nfs4_pnfs_ds_addr *da; + + list_for_each_entry(da, &ds->ds_addrs, da_node) { + sap = (struct sockaddr *)&da->da_addr; + list_for_each_entry(addr, &ds->ds_clp->cl_local_addrs, cl_addrs) + if (rpc_cmp_addr((struct sockaddr *)&addr->address, sap)) + return true; + } + + return false; +} + /** * nfs4_ff_layout_prepare_ds - prepare a DS connection for an RPC call * @lseg: the layout segment we're operating on @@ -395,6 +411,15 @@ nfs4_ff_layout_prepare_ds(struct pnfs_layout_segment *lseg, /* connect success, check rsize/wsize limit */ if (!status) { + /* + * ds_clp is put in destroy_ds(). + * keep ds_clp even if DS is local, so that if local IO cannot + * proceed somehow, we can fall back to NFS whenever we want. + */ + if (ff_layout_ds_is_local(ds)) { + dprintk("%s: found local DS\n", __func__); + nfs_local_enable(ds->ds_clp); + } max_payload = nfs_block_size(rpc_max_payload(ds->ds_clp->cl_rpcclient), NULL); -- 2.44.0