From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 03B11181B87; Sun, 1 Sep 2024 16:33:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725208396; cv=none; b=VRCOx4BW1owEvLilBm9tQvQIbK0ah/kk66R7vDUqS/ER6VdjHaNIWsiqb6L9Ra+Grmh8qoY8TYyb12Urwld4c9mV0MvIdcGTi0FwL6z83ElE65nZYZ12jaBtFb3rvzHfuvuU6sK/yBXZqQdTH8sI4p1MjJQYswgzbR4sWACtzaI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725208396; c=relaxed/simple; bh=mL4t1330ZVJydAYtzT9QEIsfT+natLABjBqOK5ayafU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BgtFww8K7A4eC/Q3Ya/fQf6lc3Cjomo0/vEH1oedA/QHPlQ+R5EOueD5kL4jyovQshchQFqisfSTA8X3smI75cnxb1n4XLtery8SpqnFYBuxpEiJjAo22II56pxC7NxU6rwc894K1zPLNmXI/pr760ELiMdgEqIPF4hkhofDPKU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=kuBrMipr; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="kuBrMipr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D0F0C4CEC3; Sun, 1 Sep 2024 16:33:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1725208395; bh=mL4t1330ZVJydAYtzT9QEIsfT+natLABjBqOK5ayafU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kuBrMipr2QUZ++oX9/HkbCpJppkHrJt51yyYVGF3YO1VM3ozXLCoB/dlYpA5Oe3wn Qey7TXBkxDYKEVIJKwPx1U9JyPPOK3fHVziVOM7R3T3XFlax1hDpkpEiFK8esogK9w W9p7Wz6ge9AxkGVLt5UR1fM+gD3GU+8jt0NpX7uw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, David Howells , Steve French , Paulo Alcantara , Jeff Layton , linux-cifs@vger.kernel.org, netfs@lists.linux.dev, linux-fsdevel@vger.kernel.org, Christian Brauner , Sasha Levin Subject: [PATCH 6.10 070/149] netfs: Fix interaction of streaming writes with zero-point tracker Date: Sun, 1 Sep 2024 18:16:21 +0200 Message-ID: <20240901160820.098239104@linuxfoundation.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240901160817.461957599@linuxfoundation.org> References: <20240901160817.461957599@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: David Howells [ Upstream commit e00e99ba6c6b8e5239e75cd6684a6827d93c39a2 ] When a folio that is marked for streaming write (dirty, but not uptodate, with partial content specified in the private data) is written back, the folio is effectively switched to the blank state upon completion of the write. This means that if we want to read it in future, we need to reread the whole folio. However, if the folio is above the zero_point position, when it is read back, it will just be cleared and the read skipped, leading to apparent local corruption. Fix this by increasing the zero_point to the end of the dirty data in the folio when clearing the folio state after writeback. This is analogous to the folio having ->release_folio() called upon it. This was causing the config.log generated by configuring a cpython tree on a cifs share to get corrupted because the scripts involved were appending text to the file in small pieces. Fixes: 288ace2f57c9 ("netfs: New writeback implementation") Signed-off-by: David Howells Link: https://lore.kernel.org/r/563286.1724500613@warthog.procyon.org.uk cc: Steve French cc: Paulo Alcantara cc: Jeff Layton cc: linux-cifs@vger.kernel.org cc: netfs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org Signed-off-by: Christian Brauner Signed-off-by: Sasha Levin --- fs/netfs/write_collect.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/netfs/write_collect.c b/fs/netfs/write_collect.c index 488147439fe0f..a2b697b4aa401 100644 --- a/fs/netfs/write_collect.c +++ b/fs/netfs/write_collect.c @@ -33,6 +33,7 @@ int netfs_folio_written_back(struct folio *folio) { enum netfs_folio_trace why = netfs_folio_trace_clear; + struct netfs_inode *ictx = netfs_inode(folio->mapping->host); struct netfs_folio *finfo; struct netfs_group *group = NULL; int gcount = 0; @@ -41,6 +42,12 @@ int netfs_folio_written_back(struct folio *folio) /* Streaming writes cannot be redirtied whilst under writeback, * so discard the streaming record. */ + unsigned long long fend; + + fend = folio_pos(folio) + finfo->dirty_offset + finfo->dirty_len; + if (fend > ictx->zero_point) + ictx->zero_point = fend; + folio_detach_private(folio); group = finfo->netfs_group; gcount++; -- 2.43.0