Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796136582; b=iSCO2rEgPS6cRiYs5pCbHHFmeN4QW+wEFWTHHyZN7kwxASeVwwcoIUw+TCp4jpeO8Qrb kpZHCTJFhSkoWN56miw3Sa5NSKfUfHghzKkqSfe1SlHRgXMHoHpZQz2QlCKIX1Zth+jCZ MTSBhBbfX17PNmOc34YBSVbVwfOcQbKSbuchBnWb+Kt4sLbqGxq/dy/H0KoP9NdpaBcFF cMrpSDoAw1LWrcPmEetofwMAegXBjGQ7fe2l+af4lr9x1hHJQDqRaBWFfLBL1ECzpPPrz 9QcxuWUMHRBFi6jqQ/oBdNg45he1T+eRZgALhLX29Req46DowSZ0PYftujL8Lu+pwuw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796136582; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:Received:Received:From:To:Cc:Subject: Date:Message-ID:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Scanned-By; bh=pZIOAjPi8gPgJb4GivfKJFFW5PUr2N+hHwZx8Wwj3CU=; b=gjsrTXc+Vn3LMd4jiplZcSq7wzOxHs9bPueSJlUt/9uKQaaHwqqTx65C/KXzZQw1u813 bd3W3BlauMmRJmyJUISjk1SRzdb/wuOZRA6UqG33d8mkQAYpOM+40yoMPSprFVMb+kOEB c8kAyrNujIYPo9DvIJyl60CwJSX5dKg1hSLssutLhGjpfOrwYSjt5EXZ+KcyCxODEmndo 8L8o3gf8unoSAWhF3AU+QDbMB5YkZm2y4T3EiDoXL4stSJBgHXfDczleEZc93muoBjPjG 6HO7knmPEb925aNZO/8J0hyEkkUEUYww0JJpaZxunTo3O5QVlDgDEqXDDsC0Tw5vwuw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=OmYVLwcy; arc=none smtp.remote-ip=170.10.133.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C7440606A31A for ; Tue, 1 Dec 2026 14:49:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C7440606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=OmYVLwcy DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796136581; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pZIOAjPi8gPgJb4GivfKJFFW5PUr2N+hHwZx8Wwj3CU=; b=OmYVLwcySb2WBoxJx5nr3dKzorQj++q4vVjd7hT1rWZ1viZD5ANZR/m4zz74GgZhrmRi1e mZAOXGcV9YTUYrY3s7t1T+xnHy3t4o929k7gE6BD5UgvmlGA5fV9YtHk9L4dKnHu6GgwTv 9wixZsf0CSCoVZEmu5+8tkrRMEZkDJQ= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-484-3aHfUlczPUyLX1GOIZge8w-1; Tue, 1 Dec 2026 14:49:37 +0000 X-MC-Unique: 3aHfUlczPUyLX1GOIZge8w-1 X-Mimecast-MFC-AGG-ID: 3aHfUlczPUyLX1GOIZge8w_1796136576 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B13FE19344B7; Tue, 1 Dec 2026 14:49:36 +0000 (UTC) Received: from smayhew-thinkpadp1gen4i.remote.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 66C191803AFE; Tue, 1 Dec 2026 14:49:36 +0000 (UTC) Received: from smayhew-thinkpadp1gen4i.redhat.corp (localhost [IPv6:::1]) by smayhew-thinkpadp1gen4i.remote.csb (Postfix) with ESMTP id 0A3095D1DBBF; Tue, 01 Dec 2026 09:49:31 -0500 (EST) From: Scott Mayhew To: steved@redhat.com Cc: jlayton@kernel.org, linux-nfs@vger.kernel.org Subject: [nfs-utils PATCH 3/6] Revert "sm-notify: fix multihomed address rotation and first-attempt address choice" Date: Tue, 1 Dec 2026 09:49:27 -0500 Message-ID: <20261201144930.369297-4-smayhew@redhat.com> In-Reply-To: <20261201144930.369297-1-smayhew@redhat.com> References: <20261201144930.369297-1-smayhew@redhat.com> X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 This reverts commit 62ece1e9f935bf8d96d00d3bd0d35b02a4ed82ce. Commit 62ece1e9f935bf8d96d00d3bd0d35b02a4ed82ce included unrelated changes from the v1 posting of "mountd: fetch root filehandles over netlink" posted by Jeff Layton on 10/20/26. Revert it so the patches can be committed properly. Note that the value used to check for the latest netlink features has moved on since this commit was committed, so the configure.ac change is not included in the revert. Signed-off-by: Scott Mayhew --- support/export/cache.c | 168 +++----------------------------- support/include/lockd_netlink.h | 1 - support/include/nfsd_netlink.h | 15 +-- utils/statd/sm-notify.c | 8 +- 4 files changed, 21 insertions(+), 171 deletions(-) diff --git a/support/export/cache.c b/support/export/cache.c index cc327452..65a59b2a 100644 --- a/support/export/cache.c +++ b/support/export/cache.c @@ -4292,135 +4292,30 @@ int cache_export(nfs_export *exp, char *path) return cache_export_ent(buf, sizeof(buf), domain, &exp->m_export, path); } -struct filehandle_get_data { - struct nfs_fh_len *fh; - int got_reply; - int kern_err; - int done; -}; - -static int filehandle_get_valid_cb(struct nl_msg *msg, void *arg) -{ - struct filehandle_get_data *data = arg; - struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); - struct nlattr *tb[NFSD_A_FILEHANDLE_MAX + 1]; - int len; - - if (nla_parse(tb, NFSD_A_FILEHANDLE_MAX, - genlmsg_attrdata(gnlh, 0), - genlmsg_attrlen(gnlh, 0), NULL) < 0 || - !tb[NFSD_A_FILEHANDLE_HANDLE]) { - data->kern_err = -EBADMSG; - return NL_SKIP; - } - - len = nla_len(tb[NFSD_A_FILEHANDLE_HANDLE]); - if (len <= 0 || len > NFS3_FHSIZE) { - data->kern_err = -EBADMSG; - return NL_SKIP; - } - - memset(data->fh->fh_handle, 0, sizeof(data->fh->fh_handle)); - memcpy(data->fh->fh_handle, - nla_data(tb[NFSD_A_FILEHANDLE_HANDLE]), len); - data->fh->fh_size = len; - data->got_reply = 1; - return NL_SKIP; -} - -static int filehandle_get_ack_cb(struct nl_msg *UNUSED(msg), void *arg) -{ - struct filehandle_get_data *data = arg; - - data->done = 1; - return NL_STOP; -} - -static int filehandle_get_error_cb(struct sockaddr_nl *UNUSED(nla), - struct nlmsgerr *nlerr, void *arg) -{ - struct filehandle_get_data *data = arg; - - data->kern_err = nlerr->error; - data->done = 1; - return NL_STOP; -} - -/* - * Fetch an export's root filehandle over netlink. +/** + * cache_get_filehandle - given an nfs_export, get its root filehandle + * @exp: target nfs_export + * @len: length of requested file handle + * @p: NUL-terminated C string containing export path * - * Returns 0 with @fh filled in, -EOPNOTSUPP when the running kernel - * does not implement FILEHANDLE_GET, or another negative errno. - */ -static int nl_cache_filehandle(char *domain, char *path, int len, - struct nfs_fh_len *fh) -{ - struct filehandle_get_data data = { .fh = fh }; - struct nl_msg *msg; - struct nl_cb *cb; - int ret; - - msg = cache_nl_new_msg(nfsd_nl_family, NFSD_CMD_FILEHANDLE_GET, 0); - if (!msg) - return -ENOMEM; - - if (nla_put_string(msg, NFSD_A_FILEHANDLE_DOMAIN, domain) < 0 || - nla_put_string(msg, NFSD_A_FILEHANDLE_PATH, path) < 0 || - nla_put_u32(msg, NFSD_A_FILEHANDLE_MAXSIZE, len) < 0) { - nlmsg_free(msg); - return -ENOMEM; - } - - cb = nl_cb_alloc(NL_CB_DEFAULT); - if (!cb) { - nlmsg_free(msg); - return -ENOMEM; - } - - nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, filehandle_get_valid_cb, &data); - nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, filehandle_get_ack_cb, &data); - nl_cb_err(cb, NL_CB_CUSTOM, filehandle_get_error_cb, &data); - - ret = nl_send_auto(nfsd_nl_cmd_sock, msg); - nlmsg_free(msg); - if (ret < 0) { - nl_cb_put(cb); - return ret; - } - - while (!data.done) { - ret = nl_recvmsgs(nfsd_nl_cmd_sock, cb); - if (ret < 0) - break; - } - nl_cb_put(cb); - - if (data.kern_err) - return data.kern_err; - if (!data.got_reply) - return ret < 0 ? ret : -EIO; - return 0; -} - -/* - * Fetch an export's root filehandle via /proc, for kernels that predate - * FILEHANDLE_GET. + * Returns pointer to NFS file handle of root directory of export * - * { - * echo $domain $path $length + * { + * echo $domain $path $length * read filehandle <&0 * } <> /proc/fs/nfsd/filehandle */ -static int proc_cache_filehandle(nfs_export *exp, int len, char *p, - struct nfs_fh_len *fh) +struct nfs_fh_len * +cache_get_filehandle(nfs_export *exp, int len, char *p) { + static struct nfs_fh_len fh; char buf[RPC_CHAN_BUF_SIZE], *bp; int blen, f; f = open("/proc/fs/nfsd/filehandle", O_RDWR); if (f < 0) { f = open("/proc/fs/nfs/filehandle", O_RDWR); - if (f < 0) return -1; + if (f < 0) return NULL; } bp = buf, blen = sizeof(buf); @@ -4430,49 +4325,18 @@ static int proc_cache_filehandle(nfs_export *exp, int len, char *p, qword_addeol(&bp, &blen); if (blen <= 0 || cache_write(f, buf, bp - buf) != bp - buf) { close(f); - return -1; + return NULL; } bp = buf; blen = cache_read(f, buf, sizeof(buf)); close(f); if (blen <= 0 || buf[blen-1] != '\n') - return -1; + return NULL; buf[blen-1] = 0; - memset(fh->fh_handle, 0, sizeof(fh->fh_handle)); - fh->fh_size = qword_get(&bp, (char *)fh->fh_handle, NFS3_FHSIZE); - return 0; -} - -/** - * cache_get_filehandle - given an nfs_export, get its root filehandle - * @exp: target nfs_export - * @len: length of requested file handle - * @p: NUL-terminated C string containing export path - * - * Returns pointer to NFS file handle of root directory of export - * - * The handle is fetched over netlink whenever the command socket is up - * and the kernel implements FILEHANDLE_GET, and via /proc otherwise. - */ -struct nfs_fh_len * -cache_get_filehandle(nfs_export *exp, int len, char *p) -{ - static struct nfs_fh_len fh; - int err; - - if (nfsd_nl_cmd_sock) { - err = nl_cache_filehandle(exp->m_client->m_hostname, p, - len, &fh); - if (!err) - return &fh; - if (err != -EOPNOTSUPP) - return NULL; - } - - if (proc_cache_filehandle(exp, len, p, &fh) < 0) - return NULL; + memset(fh.fh_handle, 0, sizeof(fh.fh_handle)); + fh.fh_size = qword_get(&bp, (char *)fh.fh_handle, NFS3_FHSIZE); return &fh; } diff --git a/support/include/lockd_netlink.h b/support/include/lockd_netlink.h index 2d766a0f..21c65aec 100644 --- a/support/include/lockd_netlink.h +++ b/support/include/lockd_netlink.h @@ -2,7 +2,6 @@ /* Do not edit directly, auto-generated from: */ /* Documentation/netlink/specs/lockd.yaml */ /* YNL-GEN uapi header */ -/* To regenerate run: tools/net/ynl/ynl-regen.sh */ #ifndef _UAPI_LINUX_LOCKD_NETLINK_H #define _UAPI_LINUX_LOCKD_NETLINK_H diff --git a/support/include/nfsd_netlink.h b/support/include/nfsd_netlink.h index f67efa23..942a1c6b 100644 --- a/support/include/nfsd_netlink.h +++ b/support/include/nfsd_netlink.h @@ -51,9 +51,7 @@ enum nfsd_xprtsec_mode { }; /* - * Constraints that apply to an rpcbind registration. no-udp means the kernel - * would not have registered this program and version over UDP, so the caller - * must skip the udp and udp6 netids for it. + * Constraints that apply to an rpcbind registration. */ enum nfsd_rpcbind_flags { NFSD_RPCBIND_FLAGS_NO_UDP = 1, @@ -292,16 +290,6 @@ enum { NFSD_A_SERVER_STATS_MAX = (__NFSD_A_SERVER_STATS_MAX - 1) }; -enum { - NFSD_A_FILEHANDLE_DOMAIN = 1, - NFSD_A_FILEHANDLE_PATH, - NFSD_A_FILEHANDLE_MAXSIZE, - NFSD_A_FILEHANDLE_HANDLE, - - __NFSD_A_FILEHANDLE_MAX, - NFSD_A_FILEHANDLE_MAX = (__NFSD_A_FILEHANDLE_MAX - 1) -}; - enum { NFSD_CMD_RPC_STATUS_GET = 1, NFSD_CMD_THREADS_SET, @@ -322,7 +310,6 @@ enum { NFSD_CMD_UNLOCK_FILESYSTEM, NFSD_CMD_UNLOCK_EXPORT, NFSD_CMD_SERVER_STATS_GET, - NFSD_CMD_FILEHANDLE_GET, __NFSD_CMD_MAX, NFSD_CMD_MAX = (__NFSD_CMD_MAX - 1) diff --git a/utils/statd/sm-notify.c b/utils/statd/sm-notify.c index affaea28..ed82b8f2 100644 --- a/utils/statd/sm-notify.c +++ b/utils/statd/sm-notify.c @@ -235,7 +235,7 @@ smn_alloc_host(const char *hostname, const char *mon_name, host->last_used = timestamp; host->timeout = NSM_TIMEOUT; - host->retries = 0; + host->retries = 100; /* force address retry */ return host; @@ -722,13 +722,13 @@ notify_host(int sock, struct nsm_host *host) /* don't rotate if there is only one addrinfo */ if (host->ai->ai_next != NULL) { struct addrinfo *first = host->ai; - struct addrinfo **next; + struct addrinfo **next = &host->ai; /* remove the first entry from the list */ host->ai = first->ai_next; first->ai_next = NULL; - /* find the end of the (new) list */ - next = &host->ai; + /* find the end of the list */ + next = &first->ai_next; while ( *next ) next = & (*next)->ai_next; /* put first entry at end */ -- 2.56.1