From: Olga Kornievskaia <okorniev@redhat.com>
To: chuck.lever@oracle.com, jlayton@kernel.org
Cc: linux-nfs@vger.kernel.org, Olga Kornievskaia <okorniev@redhat.com>
Subject: [PATCH 1/3] llist: add ability to remove a particular entry from the list
Date: Wed, 15 Jan 2025 18:24:04 -0500 [thread overview]
Message-ID: <20250115232406.44815-2-okorniev@redhat.com> (raw)
In-Reply-To: <20250115232406.44815-1-okorniev@redhat.com>
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 <jlayton@kernel.org>
Signed-off-by: Olga Kornievskaia <okorniev@redhat.com>
---
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
--
2.47.1
next prev parent reply other threads:[~2025-01-15 23:24 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-15 23:24 [PATCH 0/3] fix removal of nfsd listeners Olga Kornievskaia
2025-01-15 23:24 ` Olga Kornievskaia [this message]
2025-01-16 14:26 ` [PATCH 1/3] llist: add ability to remove a particular entry from the list Chuck Lever
2025-01-16 14:54 ` Olga Kornievskaia
2025-01-16 15:33 ` Chuck Lever
2025-01-16 15:42 ` Jeff Layton
2025-01-16 16:00 ` Chuck Lever
2025-01-16 16:31 ` Olga Kornievskaia
2025-01-16 16:44 ` Chuck Lever
2025-01-17 4:08 ` kernel test robot
2025-01-17 4:08 ` kernel test robot
2025-01-24 0:57 ` kernel test robot
2025-01-15 23:24 ` [PATCH 2/3] SUNRPC: add ability to remove specific server transport Olga Kornievskaia
2025-01-15 23:24 ` [PATCH 3/3] nfsd: fix management of listener transports Olga Kornievskaia
2025-01-16 14:27 ` Chuck Lever
2025-01-16 14:46 ` Jeff Layton
2025-01-16 14:55 ` Chuck Lever
2025-01-16 15:34 ` Olga Kornievskaia
2025-01-16 15:42 ` Chuck Lever
2025-01-16 11:53 ` [PATCH 0/3] fix removal of nfsd listeners Jeff Layton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250115232406.44815-2-okorniev@redhat.com \
--to=okorniev@redhat.com \
--cc=chuck.lever@oracle.com \
--cc=jlayton@kernel.org \
--cc=linux-nfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.