Skip to contentSkip to conversation

afs: Fix partial writeback of large files on fsync and close

PATCH New Marc Dionne 1 participant 1 message Jun 4, 2021 Afs filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 afs: Fix partial writeback of large files on fsync and close

From: Marc Dionne <[email protected]>

In commit e87b03f5830e ("afs: Prepare for use of THPs"), the return value for afs_write_back_from_locked_page was changed from a number of pages to a length in bytes. The loop in afs_writepages_region uses the return value to compute the index that will be used to find dirty pages in the next iteration, but treats it as a number of pages and wrongly multiplies it by PAGE_SIZE. This gives a very large index value, potentially skipping any dirty data that was not covered in the first pass, which is limited to 256M.

This causes fsync(), and indirectly close(), to only do a partial writeback of a large file's dirty data. The rest is eventually written back by background threads after dirty_expire_centisecs.

Fixes e87b03f5830e ("afs: Prepare for use of THPs")
---
 fs/afs/write.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/afs/write.c +1 -1
index 3edb6204b937..a523bb86915d 100644
@@ -730,7 +730,7 @@ static int afs_writepages_region(struct address_space *mapping,
 			return ret;
 		}
 
-		start += ret * PAGE_SIZE;
+		start += ret;
 
 		cond_resched();
 	} while (wbc->nr_to_write > 0);
Signature · 1 line
2.31.1