Skip to content

Commit e00e99b

Browse files
dhowellsbrauner
authored andcommitted
netfs: Fix interaction of streaming writes with zero-point tracker
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: 288ace2 ("netfs: New writeback implementation") Signed-off-by: David Howells <[email protected]> Link: https://lore.kernel.org/r/[email protected] cc: Steve French <[email protected]> cc: Paulo Alcantara <[email protected]> cc: Jeff Layton <[email protected]> cc: [email protected] cc: [email protected] cc: [email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent 950b03d commit e00e99b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

fs/netfs/write_collect.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
int netfs_folio_written_back(struct folio *folio)
3434
{
3535
enum netfs_folio_trace why = netfs_folio_trace_clear;
36+
struct netfs_inode *ictx = netfs_inode(folio->mapping->host);
3637
struct netfs_folio *finfo;
3738
struct netfs_group *group = NULL;
3839
int gcount = 0;
@@ -41,6 +42,12 @@ int netfs_folio_written_back(struct folio *folio)
4142
/* Streaming writes cannot be redirtied whilst under writeback,
4243
* so discard the streaming record.
4344
*/
45+
unsigned long long fend;
46+
47+
fend = folio_pos(folio) + finfo->dirty_offset + finfo->dirty_len;
48+
if (fend > ictx->zero_point)
49+
ictx->zero_point = fend;
50+
4451
folio_detach_private(folio);
4552
group = finfo->netfs_group;
4653
gcount++;

0 commit comments

Comments
 (0)