https://bugzilla.kernel.org/show_bug.cgi?id=103111 --- Comment #10 from Eric Sandeen <sandeen@xxxxxxxxxx> --- Ok, so there are 2 basic heuristics here. One is that if we call ext4_truncate to size 0, we set the AUTO_DA_ALLOC flag so that it'll call ext4_alloc_da_blocks in ext4_release_file (essentially on close). The other is that if we call rename, and we're overwriting an existing file, we call ext4_alloc_da_blocks. ext4_alloc_da_blocks will start writeback on the file (i.e. the file which was truncated, or the new file overwriting the old file) if there are any delayed allocations still pending; if not, it does nothing. Note, we don't get to ext4_truncate if the file is already zero length when you open it O_TRUNC. Also, notice that if we strace your c++ program (with the rename call included), we see: open("example.txt", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3 rename("example.txt", "example.txt1") = 0 write(3, "Writing this to a file.\n", 24) = 24 close(3) = 0 so the rename happens before the write; even if that is overwriting an existing file, there are no delalloc blocks on the new file yet, so the rename heuristic does nothing in this case. So there are a few prerequisites to make your c++ test work -- You are receiving this mail because: You are watching the assignee of the bug. -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html