Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.1/patches/2228984/?format=api
{ "id": 2228984, "url": "http://patchwork.ozlabs.org/api/1.1/patches/2228984/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-cifs-client/patch/20260427152953.180038-3-dhowells@redhat.com/", "project": { "id": 12, "url": "http://patchwork.ozlabs.org/api/1.1/projects/12/?format=api", "name": "Linux CIFS Client", "link_name": "linux-cifs-client", "list_id": "linux-cifs.vger.kernel.org", "list_email": "linux-cifs@vger.kernel.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20260427152953.180038-3-dhowells@redhat.com>", "date": "2026-04-27T15:29:29", "name": "[v4,02/22] netfs: Fix missing barriers when accessing stream->subrequests locklessly", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "7d6ccc837b1d1df3570eda0c6921e2f320b76d6e", "submitter": { "id": 59, "url": "http://patchwork.ozlabs.org/api/1.1/people/59/?format=api", "name": "David Howells", "email": "dhowells@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linux-cifs-client/patch/20260427152953.180038-3-dhowells@redhat.com/mbox/", "series": [ { "id": 501677, "url": "http://patchwork.ozlabs.org/api/1.1/series/501677/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-cifs-client/list/?series=501677", "date": "2026-04-27T15:29:27", "name": "netfs: Miscellaneous fixes", "version": 4, "mbox": "http://patchwork.ozlabs.org/series/501677/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2228984/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2228984/checks/", "tags": {}, "headers": { "Return-Path": "\n <linux-cifs+bounces-11145-incoming=patchwork.ozlabs.org@vger.kernel.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "linux-cifs@vger.kernel.org" ], "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=iV3MAveA;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.105.105.114; helo=tor.lore.kernel.org;\n envelope-from=linux-cifs+bounces-11145-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)", "smtp.subspace.kernel.org;\n\tdkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com\n header.b=\"iV3MAveA\"", "smtp.subspace.kernel.org;\n arc=none smtp.client-ip=170.10.129.124", "smtp.subspace.kernel.org;\n dmarc=pass (p=quarantine dis=none) header.from=redhat.com", "smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=redhat.com" ], "Received": [ "from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g47GF60Clz1yHX\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 01:46:29 +1000 (AEST)", "from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby tor.lore.kernel.org (Postfix) with ESMTP id E4BAE319BFA9\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 27 Apr 2026 15:34:03 +0000 (UTC)", "from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 196833DC4C6;\n\tMon, 27 Apr 2026 15:30:20 +0000 (UTC)", "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 854B73DA7C8\n\tfor <linux-cifs@vger.kernel.org>; Mon, 27 Apr 2026 15:30:17 +0000 (UTC)", "from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-423-lNYFjQwIOZ6nKI0Ty-cfcQ-1; Mon,\n 27 Apr 2026 11:30:13 -0400", "from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n\t(No client certificate requested)\n\tby mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id 145B21800648;\n\tMon, 27 Apr 2026 15:30:11 +0000 (UTC)", "from warthog.procyon.org.com (unknown [10.44.32.126])\n\tby mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id 3F9F31800906;\n\tMon, 27 Apr 2026 15:30:08 +0000 (UTC)" ], "ARC-Seal": "i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777303819; cv=none;\n b=GZ7UGwH8hZRicTS6u8nQjyBRh7oHfdkvUBci1+/BfHnSqS4O3lWPj+XlZeaglFLwRhuuaB2u4c2WYImZuCdDTRdHILQDst94NlKfYT5cSaMJjdM98ANwC3Zu3jRz3SdoxZCFAZC0zZNjT11u5yNi+OcvvBv8KXHhM6GGEC2942s=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777303819; c=relaxed/simple;\n\tbh=7FzhUf9knCCl7nFRHbgQohO+ezm/DS9Bo3Dnzsq+An4=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=pMX1y3OGRZy5ety7myv0SWhjdFAq+a4cHfc4MmCaMStWLMrSMOrCsjqZBjyTE88FYMlt+LNfVvG7X9BE+7AJsigPnHC2CK8ievxtgI+2WaBHYq6SAlnyPHYyCRMNsZCKVeR+yZYdXcBD9oP7GM6V5EGYDR7KF8Vbon1MxrhTcJs=", "ARC-Authentication-Results": "i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=quarantine dis=none) header.from=redhat.com;\n spf=pass smtp.mailfrom=redhat.com;\n dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com\n header.b=iV3MAveA; arc=none smtp.client-ip=170.10.129.124", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1777303816;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\t to:to:cc:cc:mime-version:mime-version:\n\t content-transfer-encoding:content-transfer-encoding:\n\t in-reply-to:in-reply-to:references:references;\n\tbh=UyovM53z5LrYXAn1v0rqTsjGNE7y4XtHURaRJHW+mN0=;\n\tb=iV3MAveAWt6PbBh0j3FnCksA3eHODGUDT/FonN/x6vsVc0X1Ut8iBOFCajmdnCDwHI1Oz8\n\t05Hs19BUrMv03sA++N0CWCQRWuQiZLiG7sEqmpReCZFNtMM14+V1AjRLrmDYB3d2eVzpCY\n\tRh7guufvgdrJ3F5L1PRhJwb9gxEzuAA=", "X-MC-Unique": "lNYFjQwIOZ6nKI0Ty-cfcQ-1", "X-Mimecast-MFC-AGG-ID": "lNYFjQwIOZ6nKI0Ty-cfcQ_1777303811", "From": "David Howells <dhowells@redhat.com>", "To": "Christian Brauner <christian@brauner.io>", "Cc": "David Howells <dhowells@redhat.com>,\n\tPaulo Alcantara <pc@manguebit.org>,\n\tnetfs@lists.linux.dev,\n\tlinux-afs@lists.infradead.org,\n\tlinux-cifs@vger.kernel.org,\n\tceph-devel@vger.kernel.org,\n\tlinux-fsdevel@vger.kernel.org,\n\tlinux-kernel@vger.kernel.org", "Subject": "[PATCH v4 02/22] netfs: Fix missing barriers when accessing\n stream->subrequests locklessly", "Date": "Mon, 27 Apr 2026 16:29:29 +0100", "Message-ID": "<20260427152953.180038-3-dhowells@redhat.com>", "In-Reply-To": "<20260427152953.180038-1-dhowells@redhat.com>", "References": "<20260427152953.180038-1-dhowells@redhat.com>", "Precedence": "bulk", "X-Mailing-List": "linux-cifs@vger.kernel.org", "List-Id": "<linux-cifs.vger.kernel.org>", "List-Subscribe": "<mailto:linux-cifs+subscribe@vger.kernel.org>", "List-Unsubscribe": "<mailto:linux-cifs+unsubscribe@vger.kernel.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-Scanned-By": "MIMEDefang 3.4.1 on 10.30.177.93" }, "content": "The list of subrequests attached to stream->subrequests is accessed without\nlocks by netfs_collect_read_results() and netfs_collect_write_results(),\nand then they access subreq->flags without taking a barrier after getting\nthe subreq pointer from the list. Relatedly, the functions that build the\nlist don't use any sort of write barrier when constructing the list to make\nsure that the NETFS_SREQ_IN_PROGRESS flag is perceived to be set first if\nno lock is taken.\n\nFix this by:\n\n (1) Add a new list_add_tail_release() function that uses a release barrier\n to set the pointer to the new member of the list.\n\n (2) Add a new list_first_entry_acquire() function that uses an acquire\n barrier to read the pointer to the first member in a list (or return\n NULL).\n\n (3) Use list_add_tail_release() when adding a subreq to ->subrequests.\n\n (4) Use list_first_entry_acquire() when initially accessing the front of\n the list (when an item is removed, the pointer to the new front iterm\n is obtained under the same lock).\n\nFixes: e2d46f2ec332 (\"netfs: Change the read result collector to only use one work item\")\nFixes: 288ace2f57c9 (\"netfs: New writeback implementation\")\nLink: https://sashiko.dev/#/patchset/20260326104544.509518-1-dhowells%40redhat.com\nSigned-off-by: David Howells <dhowells@redhat.com>\ncc: Paulo Alcantara <pc@manguebit.org>\ncc: netfs@lists.linux.dev\ncc: linux-fsdevel@vger.kernel.org\n---\n fs/netfs/buffered_read.c | 3 ++-\n fs/netfs/read_collect.c | 4 +++-\n fs/netfs/write_collect.c | 4 +++-\n fs/netfs/write_issue.c | 3 ++-\n include/linux/list.h | 37 +++++++++++++++++++++++++++++++++++++\n 5 files changed, 47 insertions(+), 4 deletions(-)", "diff": "diff --git a/fs/netfs/buffered_read.c b/fs/netfs/buffered_read.c\nindex 2c51c55a9b15..3bc7d0c5c3b9 100644\n--- a/fs/netfs/buffered_read.c\n+++ b/fs/netfs/buffered_read.c\n@@ -168,7 +168,8 @@ void netfs_queue_read(struct netfs_io_request *rreq,\n \t * remove entries off of the front.\n \t */\n \tspin_lock(&rreq->lock);\n-\tlist_add_tail(&subreq->rreq_link, &stream->subrequests);\n+\t/* Write IN_PROGRESS before pointer to new subreq */\n+\tlist_add_tail_release(&subreq->rreq_link, &stream->subrequests);\n \tif (list_is_first(&subreq->rreq_link, &stream->subrequests)) {\n \t\tif (!stream->active) {\n \t\t\tstream->collected_to = subreq->start;\ndiff --git a/fs/netfs/read_collect.c b/fs/netfs/read_collect.c\nindex e5f6665b3341..f6b87a22c290 100644\n--- a/fs/netfs/read_collect.c\n+++ b/fs/netfs/read_collect.c\n@@ -205,8 +205,10 @@ static void netfs_collect_read_results(struct netfs_io_request *rreq)\n \t * in progress. The issuer thread may be adding stuff to the tail\n \t * whilst we're doing this.\n \t */\n-\tfront = list_first_entry_or_null(&stream->subrequests,\n+\tfront = list_first_entry_acquire(&stream->subrequests,\n \t\t\t\t\t struct netfs_io_subrequest, rreq_link);\n+\t/* Read first subreq pointer before IN_PROGRESS flag. */\n+\n \twhile (front) {\n \t\tsize_t transferred;\n \ndiff --git a/fs/netfs/write_collect.c b/fs/netfs/write_collect.c\nindex b194447f4b11..ba4ac6993b74 100644\n--- a/fs/netfs/write_collect.c\n+++ b/fs/netfs/write_collect.c\n@@ -228,8 +228,10 @@ static void netfs_collect_write_results(struct netfs_io_request *wreq)\n \t\tif (!smp_load_acquire(&stream->active))\n \t\t\tcontinue;\n \n-\t\tfront = list_first_entry_or_null(&stream->subrequests,\n+\t\tfront = list_first_entry_acquire(&stream->subrequests,\n \t\t\t\t\t\t struct netfs_io_subrequest, rreq_link);\n+\t\t/* Read first subreq pointer before IN_PROGRESS flag. */\n+\n \t\twhile (front) {\n \t\t\ttrace_netfs_collect_sreq(wreq, front);\n \t\t\t//_debug(\"sreq [%x] %llx %zx/%zx\",\ndiff --git a/fs/netfs/write_issue.c b/fs/netfs/write_issue.c\nindex 2db688f94125..b0e9690bb90c 100644\n--- a/fs/netfs/write_issue.c\n+++ b/fs/netfs/write_issue.c\n@@ -204,7 +204,8 @@ void netfs_prepare_write(struct netfs_io_request *wreq,\n \t * remove entries off of the front.\n \t */\n \tspin_lock(&wreq->lock);\n-\tlist_add_tail(&subreq->rreq_link, &stream->subrequests);\n+\t/* Write IN_PROGRESS before pointer to new subreq */\n+\tlist_add_tail_release(&subreq->rreq_link, &stream->subrequests);\n \tif (list_is_first(&subreq->rreq_link, &stream->subrequests)) {\n \t\tif (!stream->active) {\n \t\t\tstream->collected_to = subreq->start;\ndiff --git a/include/linux/list.h b/include/linux/list.h\nindex 00ea8e5fb88b..5af356efd725 100644\n--- a/include/linux/list.h\n+++ b/include/linux/list.h\n@@ -191,6 +191,29 @@ static inline void list_add_tail(struct list_head *new, struct list_head *head)\n \t__list_add(new, head->prev, head);\n }\n \n+/**\n+ * list_add_tail_release - add a new entry with release barrier\n+ * @new: new entry to be added\n+ * @head: list head to add it before\n+ *\n+ * Insert a new entry before the specified head, using a release barrier to set\n+ * the ->next pointer that points to it. This is useful for implementing\n+ * queues, in particular one that the elements will be walked through forwards\n+ * locklessly.\n+ */\n+static inline void list_add_tail_release(struct list_head *new,\n+\t\t\t\t\t struct list_head *head)\n+{\n+\tstruct list_head *prev = head->prev;\n+\n+\tif (__list_add_valid(new, prev, head)) {\n+\t\tnew->next = head;\n+\t\tnew->prev = prev;\n+\t\thead->prev = new;\n+\t\tsmp_store_release(&prev->next, new);\n+\t}\n+}\n+\n /*\n * Delete a list entry by making the prev/next entries\n * point to each other.\n@@ -644,6 +667,20 @@ static inline void list_splice_tail_init(struct list_head *list,\n \tpos__ != head__ ? list_entry(pos__, type, member) : NULL; \\\n })\n \n+/**\n+ * list_first_entry_acquire - get the first element from a list with barrier\n+ * @ptr:\tthe list head to take the element from.\n+ * @type:\tthe type of the struct this is embedded in.\n+ * @member:\tthe name of the list_head within the struct.\n+ *\n+ * Note that if the list is empty, it returns NULL.\n+ */\n+#define list_first_entry_acquire(ptr, type, member) ({ \\\n+\tstruct list_head *head__ = (ptr); \\\n+\tstruct list_head *pos__ = smp_load_acquire(&head__->next); \\\n+\tpos__ != head__ ? list_entry(pos__, type, member) : NULL; \\\n+})\n+\n /**\n * list_last_entry_or_null - get the last element from a list\n * @ptr:\tthe list head to take the element from.\n", "prefixes": [ "v4", "02/22" ] }