{"id":2228989,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2228989/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-cifs-client/patch/20260427152953.180038-7-dhowells@redhat.com/","project":{"id":12,"url":"http://patchwork.ozlabs.org/api/1.1/projects/12/?format=json","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-7-dhowells@redhat.com>","date":"2026-04-27T15:29:33","name":"[v4,06/22] netfs: Fix zeropoint update where i_size > remote_i_size","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"402f8a47f538dc9ea2ef50eff01841489e5008f2","submitter":{"id":59,"url":"http://patchwork.ozlabs.org/api/1.1/people/59/?format=json","name":"David Howells","email":"dhowells@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-cifs-client/patch/20260427152953.180038-7-dhowells@redhat.com/mbox/","series":[{"id":501677,"url":"http://patchwork.ozlabs.org/api/1.1/series/501677/?format=json","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/2228989/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2228989/checks/","tags":{},"headers":{"Return-Path":"\n <linux-cifs+bounces-11149-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=TtibyKQa;\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-11149-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=\"TtibyKQa\"","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 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 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g47LV3NDWz1xvV\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 01:50:10 +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 7AD4E318D19E\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 27 Apr 2026 15:35:20 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 1D41F34C139;\n\tMon, 27 Apr 2026 15:30:43 +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 50DD834AAE3\n\tfor <linux-cifs@vger.kernel.org>; Mon, 27 Apr 2026 15:30:41 +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-647-fGjFsSZnM_6IA_Ug3IaImg-1; Mon,\n 27 Apr 2026 11:30:35 -0400","from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12])\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 9ADD31800464;\n\tMon, 27 Apr 2026 15:30:30 +0000 (UTC)","from warthog.procyon.org.com (unknown [10.44.32.126])\n\tby mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id C698A19560AB;\n\tMon, 27 Apr 2026 15:30:26 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777303843; cv=none;\n b=DpnaY3ne/4k/BKu6R/bGuc+mdqHc2gZBIJdgJtIg/EPbzKnvnBcsvjQxUJ5omXPlorM7R24mK6GdJFdkHpG7JwOmJrq7/bSSTuphFWZYAWI4LZCKM3HMPQASjPn4rTmOolZEHvoPP2+3xcxGJvL1t6CbfOaZ/OEsgX6aUdOMonY=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777303843; c=relaxed/simple;\n\tbh=o05Io1xRtBayWGYR2oc3Xg7A3FtUEcWOi0kE+EBlUgg=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=X2Z2gBNee+OZKdWUeyZLQWUZaumYO66S2N8T9P74utolgEPH48YKjD/g03YzIemC7SX4FwONhDV+CNjIdGXRZYDfXmfZ6Tm6kWsQ0SQ5do3F2sAi3k4XMDJz1qAe5EnbwVtjcCmv416gVtG2sevrsTDXMFbh7Ae47Wfp5AJTElA=","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=TtibyKQa; 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=1777303840;\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=47TW6xAuGaXgyo+FT4sWhE5OZ+F3gm9XYQOGltuTIYQ=;\n\tb=TtibyKQacpyqnurVak8k+SJ2yvToKr/eBg29DVfO7RFAPvFgnYe+IEqE5yspyNplyTegEq\n\tylycGDvXxMhqjj7IEPPOV+ChVRkq4Xw9D/5Z+LObce19RX1zkB16kVcyyfdcUkeJxD4F6r\n\tBI1hrRcEh/CAk7eaKo/UkS/rA7SvRTU=","X-MC-Unique":"fGjFsSZnM_6IA_Ug3IaImg-1","X-Mimecast-MFC-AGG-ID":"fGjFsSZnM_6IA_Ug3IaImg_1777303830","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,\n\tMatthew Wilcox <willy@infradead.org>","Subject":"[PATCH v4 06/22] netfs: Fix zeropoint update where i_size >\n remote_i_size","Date":"Mon, 27 Apr 2026 16:29:33 +0100","Message-ID":"<20260427152953.180038-7-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.0 on 10.30.177.12"},"content":"Fix the update of the zero point[*] by netfs_release_folio() when there is\nuncommitted data in the pagecache beyond the folio being released but the\non-server EOF is in this folio (ie. i_size > remote_i_size).  The update\nneeds to limit zero_point to remote_i_size, not i_size as i_size is a local\nphenomenon reflecting updates made locally to the pagecache, not stuff\nwritten to the server.  remote_i_size tracks the server's i_size.\n\n[*] The zero point is the file position from which we can assume that the\n    server will just return zeros, so we can avoid generating reads.\n\nNote that netfs_invalidate_folio() probably doesn't need fixing as\nzero_point should be updated by setattr after truncation or fallocate.\n\nFound with:\n\n    fsx -q -N 1000000 -p 10000 -o 128000 -l 600000 \\\n        /xfstest.test/junk --replay-ops=junk.fsxops\n\nusing the following as junk.fsxops:\n\n    truncate 0x0 0x1bbae 0x82864\n    write 0x3ef2e 0xf9c8 0x1bbae\n    write 0x67e05 0xcb5a 0x4e8f6\n    mapread 0x57781 0x85b6 0x7495f\n    copy_range 0x5d3d 0x10329 0x54fac 0x7495f\n    write 0x64710 0x1c2b 0x7495f\n    mapread 0x64000 0x1000 0x7495f\n\non cifs with the default cache option.\n\nIt shows read-gaps on folio 0x64 failing with a short read (ie. it hits\nEOF) if the FMODE_READ check is commented out in netfs_perform_write():\n\n                if (//(file->f_mode & FMODE_READ) ||\n                    netfs_is_cache_enabled(ctx)) {\n\nand no fscache.  This was initially found with the generic/522 xfstest.\n\nFixes: cce6bfa6ca0e (\"netfs: Fix trimming of streaming-write folios in netfs_inval_folio()\")\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/misc.c       |  4 ++--\n include/linux/netfs.h | 35 +++++++++++++++++++++++++++--------\n 2 files changed, 29 insertions(+), 10 deletions(-)","diff":"diff --git a/fs/netfs/misc.c b/fs/netfs/misc.c\nindex 9d92d068f1da..37d9651078e6 100644\n--- a/fs/netfs/misc.c\n+++ b/fs/netfs/misc.c\n@@ -299,9 +299,9 @@ bool netfs_release_folio(struct folio *folio, gfp_t gfp)\n \t\treturn false;\n \n \tnetfs_read_sizes(ctx, &i_size, &remote_i_size, &zero_point);\n-\tend = umin(folio_next_pos(folio), i_size);\n+\tend = folio_next_pos(folio);\n \tif (end > zero_point)\n-\t\tnetfs_write_zero_point(ctx, end);\n+\t\tnetfs_push_back_zero_point(ctx, umin(end, remote_i_size));\n \n \tif (folio_test_private(folio))\n \t\treturn false;\ndiff --git a/include/linux/netfs.h b/include/linux/netfs.h\nindex 90e061e444ce..59f35d2eeb2e 100644\n--- a/include/linux/netfs.h\n+++ b/include/linux/netfs.h\n@@ -530,11 +530,11 @@ static inline void netfs_write_remote_i_size(struct netfs_inode *ictx,\n #if BITS_PER_LONG==32 && defined(CONFIG_SMP)\n \tstruct inode *inode = &ictx->inode;\n \n-\tpreempt_disable();\n+\tspin_lock(&inode->i_lock);\n \twrite_seqcount_begin(&inode->i_size_seqcount);\n \tictx->_remote_i_size = remote_i_size;\n \twrite_seqcount_end(&inode->i_size_seqcount);\n-\tpreempt_enable();\n+\tspin_unlock(&inode->i_lock);\n #elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPTION)\n \tpreempt_disable();\n \tictx->_remote_i_size = remote_i_size;\n@@ -605,11 +605,11 @@ static inline void netfs_write_zero_point(struct netfs_inode *ictx,\n #if BITS_PER_LONG==32 && defined(CONFIG_SMP)\n \tstruct inode *inode = &ictx->inode;\n \n-\tpreempt_disable();\n+\tspin_lock(&inode->i_lock);\n \twrite_seqcount_begin(&inode->i_size_seqcount);\n \tictx->_zero_point = zero_point;\n \twrite_seqcount_end(&inode->i_size_seqcount);\n-\tpreempt_enable();\n+\tspin_unlock(&inode->i_lock);\n #elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPTION)\n \tpreempt_disable();\n \tictx->_zero_point = zero_point;\n@@ -635,8 +635,27 @@ static inline void netfs_write_zero_point(struct netfs_inode *ictx,\n static inline void netfs_push_back_zero_point(struct netfs_inode *ictx,\n \t\t\t\t\t      unsigned long long to)\n {\n-\tif (to > netfs_read_zero_point(ictx))\n-\t\tnetfs_write_zero_point(ictx, to);\n+#if BITS_PER_LONG==32 && defined(CONFIG_SMP)\n+\tstruct inode *inode = &ictx->inode;\n+\n+\tspin_lock(&inode->i_lock);\n+\twrite_seqcount_begin(&inode->i_size_seqcount);\n+\tif (to > ictx->_zero_point)\n+\t\tictx->_zero_point = to;\n+\twrite_seqcount_end(&inode->i_size_seqcount);\n+\tspin_unlock(&inode->i_lock);\n+#elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPTION)\n+\tpreempt_disable();\n+\tif (to > ictx->_zero_point)\n+\t\tictx->_zero_point = to;\n+\tpreempt_enable();\n+#else\n+\tunsigned long long old = ictx->_zero_point;\n+\n+\twhile (to > old) {\n+\t\told = cmpxchg_release(&ictx->_zero_point, old, to);\n+\t}\n+#endif\n }\n \n /**\n@@ -709,12 +728,12 @@ static inline void netfs_write_sizes(struct netfs_inode *ictx,\n #if BITS_PER_LONG==32 && defined(CONFIG_SMP)\n \tstruct inode *inode = &ictx->inode;\n \n-\tpreempt_disable();\n+\tspin_lock(&inode->i_lock);\n \twrite_seqcount_begin(&inode->i_size_seqcount);\n \tictx->_remote_i_size = remote_i_size;\n \tictx->_zero_point = zero_point;\n \twrite_seqcount_end(&inode->i_size_seqcount);\n-\tpreempt_enable();\n+\tspin_unlock(&inode->i_lock);\n #elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPTION)\n \tpreempt_disable();\n \tictx->_remote_i_size = remote_i_size;\n","prefixes":["v4","06/22"]}