From patchwork Wed Jan 15 23:24:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 13941039 X-Patchwork-Delegate: cel@kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 C246C1D89F1 for ; Wed, 15 Jan 2025 23:24:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736983458; cv=none; b=Un8xVz43ZEo9p/O0cEDdD5JM3FBLdD5mGkJyi6Y0dcIKWxwm00IQmvSoiSwR6VJlR5AnIXnkUTWsk3rUZDMwDpqYTc3qrlg3uQjs3zWUBfIMci50vyWMrqgXffmIym5lEM9IVludm0uxE+qwHAe2Xi7gC/+6MUUZjuY1grMDhVo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736983458; c=relaxed/simple; bh=wdAL3AmdxgQyk4/kkFdGs2uiFSmUu0ohUcOvOppAhgY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VYMWjCe3FUtCMmGCSwGZIua3x0RhLxmvbXM1m/R/nSLV6N6/w/PA9D22mcUbWMm8+ZeFixhaygDNcy2xhIvqnhNkq4oyTlHMZYTpGY0RMmeyyqjINkqeMK26+pth3sSfuW0qSngGFBOns+K/a4gS+D/zsf0+Avmplt5G+KYfXPg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=LlDhPfDL; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none 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.b="LlDhPfDL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736983455; 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=okJ2iBJnvdGXT865beEMteDRB0jkKmfgn98JZvOqWS8=; b=LlDhPfDLTJdjbhL3vx8lLuCDO8Ya+hFXgHq1DDJyOhz8LnsfWidQJJGTKtOBgWvQvv1I3i lboSCNeohQmaxQ99/R0BEfU/u0+upsYlPiCyBt7iATu/SNNfZdl3tKd+srM2ZNEeiUl851 OQv+bMfAnQxIT0iRA/xqh/0N9fIUZMQ= Received: from mx-prod-mc-04.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-333-Ha82_0aONy6MS7CbtthNTQ-1; Wed, 15 Jan 2025 18:24:14 -0500 X-MC-Unique: Ha82_0aONy6MS7CbtthNTQ-1 X-Mimecast-MFC-AGG-ID: Ha82_0aONy6MS7CbtthNTQ Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2A6BB19560BB; Wed, 15 Jan 2025 23:24:13 +0000 (UTC) Received: from okorniev-mac.redhat.com (unknown [10.22.64.125]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 246B030001BE; Wed, 15 Jan 2025 23:24:11 +0000 (UTC) From: Olga Kornievskaia To: chuck.lever@oracle.com, jlayton@kernel.org Cc: linux-nfs@vger.kernel.org, Olga Kornievskaia Subject: [PATCH 1/3] llist: add ability to remove a particular entry from the list Date: Wed, 15 Jan 2025 18:24:04 -0500 Message-Id: <20250115232406.44815-2-okorniev@redhat.com> In-Reply-To: <20250115232406.44815-1-okorniev@redhat.com> References: <20250115232406.44815-1-okorniev@redhat.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 nfsd stores its network transports in a lwq (which is a lockless list) llist has no ability to remove a particular entry which nfsd needs to remove a listener thread. Suggested-by: Jeff Layton Signed-off-by: Olga Kornievskaia --- include/linux/llist.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/include/linux/llist.h b/include/linux/llist.h index 2c982ff7475a..fe6be21897d9 100644 --- a/include/linux/llist.h +++ b/include/linux/llist.h @@ -253,6 +253,42 @@ static inline bool __llist_add(struct llist_node *new, struct llist_head *head) return __llist_add_batch(new, new, head); } +/** + * llist_del_entry - remove a particular entry from a lock-less list + * @head: head of the list to remove the entry from + * @entry: entry to be removed from the list + * + * Walk the list, find the given entry and remove it from the list. + * The caller must ensure that nothing can race in and change the + * list while this is running. + * + * Returns true if the entry was found and removed. + */ +static inline bool llist_del_entry(struct llist_head *head, struct llist_node *entry) +{ + struct llist_node *pos; + + if (!head->first) + return false; + + /* Is it the first entry? */ + if (head->first == entry) { + head->first = entry->next; + entry->next = entry; + return true; + } + + /* Find it in the list */ + llist_for_each(head->first, pos) { + if (pos->next == entry) { + pos->next = entry->next; + entry->next = entry; + return true; + } + } + return false; +} + /** * llist_del_all - delete all entries from lock-less list * @head: the head of lock-less list to delete all entries From patchwork Wed Jan 15 23:24:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 13941040 X-Patchwork-Delegate: cel@kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 6138C1D89F1 for ; Wed, 15 Jan 2025 23:24:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736983463; cv=none; b=Hl7EioGUiciiXD5W9IqE6Xx0rVV1DUOvmuJQWFrWaHHYdhkJsqeESC1WN7QcGzsVSVUTCDuIf/sdLD5imtxCSRaVm/UYXKMZlsFxu+8aEDjwdrv4UBnH3281mzWAx3UaOfwfsj7M21GEypc/9iNrnTXDbWPIZUIMAryPDLxnUU8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736983463; c=relaxed/simple; bh=6XMHvA7bWJ+5KMjowJSYSM7XUMxY+f4NokUmlPRSWsc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Qa+09sxJy7EAD403oyphQf2sZH+YETxYqfFX8TTSLVO5Z3pf/cpQa9lMT90R6joYj4Vz6RGTh0ZBNWKrY0QIVMRSHdcu5WlwZLK+oTlQETAO2FY+0m+xDqiBJQ9ubAuijN1nUROjEj4UEE2BBP2BTCZQRgt2oKIrYDWlDY5Ey18= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=eHUaucqH; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none 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.b="eHUaucqH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736983460; 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=wcc1iXrXnOAI1URoxvbkRKg9RnwG7NwYxCMxo0zHmBM=; b=eHUaucqHjG3W2okqe/PuZltP7Mrk9E4Mnq+RZLeJo0XkOL4Ko9/Km/ZC5LA1SDHK3CohPb LX7N2h1bquznJX/3l9CCUUhSd24Tr7v1OWQk/3/kbePO0qWYhbrtBOs+d9Z/J53NQRka72 C9/Ic5gOHjsH9UZUuX2gNoPVI+opJU4= Received: from mx-prod-mc-02.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-481-jZtdHp4gOWieHa0btSKVqA-1; Wed, 15 Jan 2025 18:24:16 -0500 X-MC-Unique: jZtdHp4gOWieHa0btSKVqA-1 X-Mimecast-MFC-AGG-ID: jZtdHp4gOWieHa0btSKVqA Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 07C141955DC8; Wed, 15 Jan 2025 23:24:16 +0000 (UTC) Received: from okorniev-mac.redhat.com (unknown [10.22.64.125]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 089FA30001BE; Wed, 15 Jan 2025 23:24:14 +0000 (UTC) From: Olga Kornievskaia To: chuck.lever@oracle.com, jlayton@kernel.org Cc: linux-nfs@vger.kernel.org, Olga Kornievskaia Subject: [PATCH 2/3] SUNRPC: add ability to remove specific server transport Date: Wed, 15 Jan 2025 18:24:05 -0500 Message-Id: <20250115232406.44815-3-okorniev@redhat.com> In-Reply-To: <20250115232406.44815-1-okorniev@redhat.com> References: <20250115232406.44815-1-okorniev@redhat.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 nfsd needs to be able to remove a particular entry from its list of transports. Suggested-by: Jeff Layton Signed-off-by: Olga Kornievskaia --- include/linux/sunrpc/svc.h | 1 + net/sunrpc/svc_xprt.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h index 74658cca0f38..0bc0b9ead01e 100644 --- a/include/linux/sunrpc/svc.h +++ b/include/linux/sunrpc/svc.h @@ -444,6 +444,7 @@ int svc_register(const struct svc_serv *, struct net *, const int, const unsigned short, const unsigned short); void svc_wake_up(struct svc_serv *); +void svc_xprt_dequeue_entry(struct svc_xprt *xprt); void svc_reserve(struct svc_rqst *rqstp, int space); void svc_pool_wake_idle_thread(struct svc_pool *pool); struct svc_pool *svc_pool_for_cpu(struct svc_serv *serv); diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c index 06779b4cdd0a..7b86e69df08b 100644 --- a/net/sunrpc/svc_xprt.c +++ b/net/sunrpc/svc_xprt.c @@ -507,6 +507,17 @@ static struct svc_xprt *svc_xprt_dequeue(struct svc_pool *pool) return xprt; } +void svc_xprt_dequeue_entry(struct svc_xprt *xprt) +{ + struct svc_pool *pool; + + pool = svc_pool_for_cpu(xprt->xpt_server); + + WARN_ON_ONCE(pool->sp_xprts.ready); + llist_del_entry(&pool->sp_xprts.new, &xprt->xpt_ready.node); +} +EXPORT_SYMBOL_GPL(svc_xprt_dequeue_entry); + /** * svc_reserve - change the space reserved for the reply to a request. * @rqstp: The request in question From patchwork Wed Jan 15 23:24:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 13941041 X-Patchwork-Delegate: cel@kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 C0F801DCB2D for ; Wed, 15 Jan 2025 23:24:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736983470; cv=none; b=GMxU92RLQwBgtvoSJlgxz4XPaf+ZuyKcaswhLWOLkzx3x70loIHGMiA6GfNmoXfiIWWWILvWmLO3orA8t0REX8Rw5IvAYhzu+gqC8oyahJlgaXz0CGCh0wNEez/mP8TdSpUCnn1DgfcVZiUzQCuG3nok9SuYqSkkdIw38zanz/k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736983470; c=relaxed/simple; bh=9vyHE5S4wVP78C6HbXA8y6BWDRF7T2odFtUMEaRASlQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=E3Cww7DxxJLBOcYI528Vo1D/E4DilIGINvW/eudoA4twAgfVNdjz8schkJz9YD4gUTAnio3xl9tP+0vLIso++N3xvN2vMzlIByW8mGRACX4bXhTeoVA4F8lvlrg/qsBb+S4j0rPByoO1mKLcuF9uVdkRzcm+Da1NcNkJ3f/PdtQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=U3ve9l5q; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none 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.b="U3ve9l5q" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736983467; 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=w5Qlm+ZqzRrVU13FRsZgqwth1mTjN8qNZrRGAH7Gb2U=; b=U3ve9l5qLXYdabyr+X4TqyjQoIc6IXPaK3iO5dY5Isnpl2aQ6H4jJ/TkA4W0nBfB6au0HB N8GlUSSyY8h/mZPzaKdiLRA8a1TGewfYJdDVUtu4GdBwxkAt4hHp2Yq9tbqQfcyVFFn5qo L7tCxRKiAe5Nd2aLBomAFRXFLoumkMY= 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-401-CjyKejWrMj-bcSh7_DqLNA-1; Wed, 15 Jan 2025 18:24:26 -0500 X-MC-Unique: CjyKejWrMj-bcSh7_DqLNA-1 X-Mimecast-MFC-AGG-ID: CjyKejWrMj-bcSh7_DqLNA Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 3CC11195608B; Wed, 15 Jan 2025 23:24:25 +0000 (UTC) Received: from okorniev-mac.redhat.com (unknown [10.22.64.125]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3D2FD3003E7F; Wed, 15 Jan 2025 23:24:24 +0000 (UTC) From: Olga Kornievskaia To: chuck.lever@oracle.com, jlayton@kernel.org Cc: linux-nfs@vger.kernel.org, Olga Kornievskaia Subject: [PATCH 3/3] nfsd: fix management of listener transports Date: Wed, 15 Jan 2025 18:24:06 -0500 Message-Id: <20250115232406.44815-4-okorniev@redhat.com> In-Reply-To: <20250115232406.44815-1-okorniev@redhat.com> References: <20250115232406.44815-1-okorniev@redhat.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 When a particular listener is being removed we need to make sure that we delete the entry from the list of permanent sockets (sv_permsocks) as well as remove it from the listener transports (sp_xprts). When adding back the leftover transports not being removed we need to clear XPT_BUSY flag so that it can be used. Fixes: 16a471177496 ("NFSD: add listener-{set,get} netlink command") Signed-off-by: Olga Kornievskaia --- fs/nfsd/nfsctl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index 95ea4393305b..3deedd511e83 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c @@ -1988,7 +1988,7 @@ int nfsd_nl_listener_set_doit(struct sk_buff *skb, struct genl_info *info) /* Close the remaining sockets on the permsocks list */ while (!list_empty(&permsocks)) { xprt = list_first_entry(&permsocks, struct svc_xprt, xpt_list); - list_move(&xprt->xpt_list, &serv->sv_permsocks); + list_del_init(&xprt->xpt_list); /* * Newly-created sockets are born with the BUSY bit set. Clear @@ -2000,6 +2000,7 @@ int nfsd_nl_listener_set_doit(struct sk_buff *skb, struct genl_info *info) set_bit(XPT_CLOSE, &xprt->xpt_flags); spin_unlock_bh(&serv->sv_lock); + svc_xprt_dequeue_entry(xprt); svc_xprt_close(xprt); spin_lock_bh(&serv->sv_lock); } @@ -2031,6 +2032,7 @@ int nfsd_nl_listener_set_doit(struct sk_buff *skb, struct genl_info *info) xprt = svc_find_listener(serv, xcl_name, net, sa); if (xprt) { + clear_bit(XPT_BUSY, &xprt->xpt_flags); svc_xprt_put(xprt); continue; }