Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2223034/?format=api
{ "id": 2223034, "url": "http://patchwork.ozlabs.org/api/patches/2223034/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-cifs-client/patch/20260414082004.3756080-5-dhowells@redhat.com/", "project": { "id": 12, "url": "http://patchwork.ozlabs.org/api/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": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260414082004.3756080-5-dhowells@redhat.com>", "list_archive_url": null, "date": "2026-04-14T08:20:00", "name": "[v2,4/7] netfs: Fix streaming write being overwritten", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "384154e61ed14827738af7d107c6dfb65bc23b88", "submitter": { "id": 59, "url": "http://patchwork.ozlabs.org/api/people/59/?format=api", "name": "David Howells", "email": "dhowells@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linux-cifs-client/patch/20260414082004.3756080-5-dhowells@redhat.com/mbox/", "series": [ { "id": 499799, "url": "http://patchwork.ozlabs.org/api/series/499799/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-cifs-client/list/?series=499799", "date": "2026-04-14T08:19:56", "name": "netfs: Miscellaneous fixes", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/499799/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2223034/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2223034/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "\n <linux-cifs+bounces-10797-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=F/8zzzXG;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-cifs+bounces-10797-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=\"F/8zzzXG\"", "smtp.subspace.kernel.org;\n arc=none smtp.client-ip=170.10.133.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 sea.lore.kernel.org (sea.lore.kernel.org\n [IPv6:2600:3c0a:e001:db::12fc:5321])\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 4fvy9R037tz1xtJ\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 14 Apr 2026 18:28:59 +1000 (AEST)", "from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 75C5930EB755\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 14 Apr 2026 08:21:30 +0000 (UTC)", "from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 0BCAB3A8735;\n\tTue, 14 Apr 2026 08:20:48 +0000 (UTC)", "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.133.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 5974D3A6EEC\n\tfor <linux-cifs@vger.kernel.org>; Tue, 14 Apr 2026 08:20:42 +0000 (UTC)", "from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-650-ts9cqkY6Op-t9d0YRDzrWw-1; Tue,\n 14 Apr 2026 04:20:35 -0400", "from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111])\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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id 7562D19560A7;\n\tTue, 14 Apr 2026 08:20:33 +0000 (UTC)", "from warthog.procyon.org.com (unknown [10.44.34.160])\n\tby mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id 1F6AB1800B7F;\n\tTue, 14 Apr 2026 08:20:29 +0000 (UTC)" ], "ARC-Seal": "i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776154847; cv=none;\n b=Km+kQ1/01e03mctX7rl7RKlrWROlP2h9lh8edum4aj5gF13mZIJGwRKtVRZoQkREdNUHf+oy+mWA7yJX+U942aMul0mRM5PvDY5BP3yoSH6cBwVR5zx3TtqCQNSGSLzEncgNUE4iK3x2ZozQmjo5q420MUOSgwgovQ5Etsw2A54=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776154847; c=relaxed/simple;\n\tbh=PRopKs/FT3nkkdMATgLJWk4AoF7GfLfM0RyRT2gJIBI=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=DMwD8A5mqdpwek+v34/mYK7y/gY9bUfrCpE7o725jQaTFUq4Tdltsnn47H8SXabUo2qCoGzBXbCyhrkeon7NVw4w4DUYbs14qBi/Rc10UCbuA9w+6JJ+MEq0I2W2MTZGUl2ji2SHXMkG54GkBTgRFXTiyvwf/5RqmoR26UAPoIU=", "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=F/8zzzXG; arc=none smtp.client-ip=170.10.133.124", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1776154841;\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=dDZpiVNLePhW4nt96um0+f3XwBnHWbaZ7t0vp4dXfAg=;\n\tb=F/8zzzXGcULnWOGPROkUOff/mcP1rmWyB/jaz7ljdsvn9d3OqRmxpxKWg83bGwcmom/JaC\n\tqLIIrxUxLLmv8Swab0DbnPtwVVVO8oP+g8wbVqw05SLX8uTswWvk77cbNbiTMJRr304kPK\n\txNFxrI4YoHAEFWTiYOhT6hyva/L9fC4=", "X-MC-Unique": "ts9cqkY6Op-t9d0YRDzrWw-1", "X-Mimecast-MFC-AGG-ID": "ts9cqkY6Op-t9d0YRDzrWw_1776154834", "From": "David Howells <dhowells@redhat.com>", "To": "Christian Brauner <christian@brauner.io>", "Cc": "David Howells <dhowells@redhat.com>,\n\tPaulo Alcantara <pc@manguebit.com>,\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,\n\tPaulo Alcantara <pc@manguebit.org>,\n\tMatthew Wilcox <willy@infradead.org>", "Subject": "[PATCH v2 4/7] netfs: Fix streaming write being overwritten", "Date": "Tue, 14 Apr 2026 09:20:00 +0100", "Message-ID": "<20260414082004.3756080-5-dhowells@redhat.com>", "In-Reply-To": "<20260414082004.3756080-1-dhowells@redhat.com>", "References": "<20260414082004.3756080-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.111" }, "content": "In order to avoid reading whilst writing, netfslib will allow \"streaming\nwrites\" in which dirty data is stored directly into folios without reading\nthem first. Such folios are marked dirty but may not be marked uptodate.\nIf a folio is entirely written by a streaming write, uptodate will be set,\notherwise it will have a netfs_folio struct attached to ->private recording\nthe dirty region.\n\nIn the event that a partially written streaming write page is to be\noverwritten entirely by a single write(), netfs_perform_write() will try to\ncopy over it, but doesn't discard the netfs_folio if it succeeds; further,\nit doesn't correctly handle a partial copy that overwrites some of the\ndirty data.\n\nFix this by the following:\n\n (1) If the folio is successfully overwritten, free the netfs_folio struct\n before marking the page uptodate.\n\n (2) If the copy to the folio partially fails, but short of the dirty data,\n just ignore the copy.\n\n (3) If the copy partially fails and overwrites some of the dirty data,\n accept the copy, update the netfs_folio struct to record the new data.\n If the folio is now filled, free the netfs_folio and set uptodate,\n otherwise return a partial write.\n\nFound with:\n\n\tfsx -q -N 1000000 -p 10000 -o 128000 -l 600000 \\\n\t /xfstest.test/junk --replay-ops=junk.fsxops\n\nusing the following as junk.fsxops:\n\n\ttruncate 0x0 0 0x927c0\n\twrite 0x63fb8 0x53c8 0\n\tcopy_range 0xb704 0x19b9 0x24429 0x79380\n\twrite 0x2402b 0x144a2 0x90660 *\n\twrite 0x204d5 0x140a0 0x927c0 *\n\tcopy_range 0x1f72c 0x137d0 0x7a906 0x927c0 *\n\tread 0x00000 0x20000 0x9157c\n\tread 0x20000 0x20000 0x9157c\n\tread 0x40000 0x20000 0x9157c\n\tread 0x60000 0x20000 0x9157c\n\tread 0x7e1a0 0xcfb9 0x9157c\n\non cifs with the default cache option.\n\nIt shows folio 0x24 misbehaving if the FMODE_READ check is commented out in\nnetfs_perform_write():\n\n\t\tif (//(file->f_mode & FMODE_READ) ||\n\t\t netfs_is_cache_enabled(ctx)) {\n\nand no fscache. This was initially found with the generic/522 xfstest.\n\nSigned-off-by: David Howells <dhowells@redhat.com>\ncc: Paulo Alcantara <pc@manguebit.org>\ncc: Matthew Wilcox <willy@infradead.org>\ncc: netfs@lists.linux.dev\ncc: linux-fsdevel@vger.kernel.org\n---\n fs/netfs/buffered_write.c | 48 ++++++++++++++++++++++++------------\n include/trace/events/netfs.h | 1 +\n 2 files changed, 33 insertions(+), 16 deletions(-)", "diff": "diff --git a/fs/netfs/buffered_write.c b/fs/netfs/buffered_write.c\nindex 22a4d61631c9..830f1603478e 100644\n--- a/fs/netfs/buffered_write.c\n+++ b/fs/netfs/buffered_write.c\n@@ -246,18 +246,34 @@ ssize_t netfs_perform_write(struct kiocb *iocb, struct iov_iter *iter,\n \t\t/* See if we can write a whole folio in one go. */\n \t\tif (!maybe_trouble && offset == 0 && part >= flen) {\n \t\t\tcopied = copy_folio_from_iter_atomic(folio, offset, part, iter);\n-\t\t\tif (unlikely(copied == 0))\n+\t\t\tif (likely(copied == part)) {\n+\t\t\t\tif (finfo)\n+\t\t\t\t\tgoto folio_now_filled;\n+\t\t\t\t__netfs_set_group(folio, netfs_group);\n+\t\t\t\tfolio_mark_uptodate(folio);\n+\t\t\t\ttrace_netfs_folio(folio, netfs_whole_folio_modify);\n+\t\t\t\tgoto copied;\n+\t\t\t}\n+\t\t\tif (copied == 0)\n \t\t\t\tgoto copy_failed;\n-\t\t\tif (unlikely(copied < part)) {\n+\t\t\tif (!finfo || copied <= finfo->dirty_offset) {\n \t\t\t\tmaybe_trouble = true;\n \t\t\t\tiov_iter_revert(iter, copied);\n \t\t\t\tcopied = 0;\n \t\t\t\tfolio_unlock(folio);\n \t\t\t\tgoto retry;\n \t\t\t}\n-\t\t\t__netfs_set_group(folio, netfs_group);\n-\t\t\tfolio_mark_uptodate(folio);\n-\t\t\ttrace_netfs_folio(folio, netfs_whole_folio_modify);\n+\n+\t\t\t/* We overwrote some existing dirty data, so we have to\n+\t\t\t * accept the partial write.\n+\t\t\t */\n+\t\t\tfinfo->dirty_len += finfo->dirty_offset;\n+\t\t\tif (finfo->dirty_len == flen)\n+\t\t\t\tgoto folio_now_filled;\n+\t\t\tif (copied > finfo->dirty_len)\n+\t\t\t\tfinfo->dirty_len = copied;\n+\t\t\tfinfo->dirty_offset = 0;\n+\t\t\ttrace_netfs_folio(folio, netfs_whole_folio_modify_efault);\n \t\t\tgoto copied;\n \t\t}\n \n@@ -326,17 +342,9 @@ ssize_t netfs_perform_write(struct kiocb *iocb, struct iov_iter *iter,\n \t\t\tif (unlikely(copied == 0))\n \t\t\t\tgoto copy_failed;\n \t\t\tfinfo->dirty_len += copied;\n-\t\t\tif (finfo->dirty_offset == 0 && finfo->dirty_len == flen) {\n-\t\t\t\tif (finfo->netfs_group)\n-\t\t\t\t\tfolio_change_private(folio, finfo->netfs_group);\n-\t\t\t\telse\n-\t\t\t\t\tfolio_detach_private(folio);\n-\t\t\t\tfolio_mark_uptodate(folio);\n-\t\t\t\tkfree(finfo);\n-\t\t\t\ttrace_netfs_folio(folio, netfs_streaming_cont_filled_page);\n-\t\t\t} else {\n-\t\t\t\ttrace_netfs_folio(folio, netfs_streaming_write_cont);\n-\t\t\t}\n+\t\t\tif (finfo->dirty_offset == 0 && finfo->dirty_len == flen)\n+\t\t\t\tgoto folio_now_filled;\n+\t\t\ttrace_netfs_folio(folio, netfs_streaming_write_cont);\n \t\t\tgoto copied;\n \t\t}\n \n@@ -350,6 +358,14 @@ ssize_t netfs_perform_write(struct kiocb *iocb, struct iov_iter *iter,\n \t\t\tgoto out;\n \t\tcontinue;\n \n+\tfolio_now_filled:\n+\t\tif (finfo->netfs_group)\n+\t\t\tfolio_change_private(folio, finfo->netfs_group);\n+\t\telse\n+\t\t\tfolio_detach_private(folio);\n+\t\tfolio_mark_uptodate(folio);\n+\t\tkfree(finfo);\n+\t\ttrace_netfs_folio(folio, netfs_streaming_cont_filled_page);\n \tcopied:\n \t\tflush_dcache_folio(folio);\n \ndiff --git a/include/trace/events/netfs.h b/include/trace/events/netfs.h\nindex 88d814ba1e69..1dc1688edc19 100644\n--- a/include/trace/events/netfs.h\n+++ b/include/trace/events/netfs.h\n@@ -177,6 +177,7 @@\n \tEM(netfs_folio_is_uptodate,\t\t\"mod-uptodate\")\t\\\n \tEM(netfs_just_prefetch,\t\t\t\"mod-prefetch\")\t\\\n \tEM(netfs_whole_folio_modify,\t\t\"mod-whole-f\")\t\\\n+\tEM(netfs_whole_folio_modify_efault,\t\"mod-whole-f!\")\t\\\n \tEM(netfs_modify_and_clear,\t\t\"mod-n-clear\")\t\\\n \tEM(netfs_streaming_write,\t\t\"mod-streamw\")\t\\\n \tEM(netfs_streaming_write_cont,\t\t\"mod-streamw+\")\t\\\n", "prefixes": [ "v2", "4/7" ] }