Solves issue #201. I am still a bit unsure about locking - what if 3 threads are writing to the same block and
Thread 1 - partial write, enters if (block_was_zeros), then is interrupted by the OS
Thread 2 writes the whole block, all zeros
Thread 3 - partial write, after thread 2 flags the block as all-zeros in zero_cache bitmap
Thread 1 - continues and overwrites data written by thread 3
But I fear locking can hurt performance...
Tested both by creating a small (64M) filesystem (did ext4 and ZFS) and writing some files and reading and comparing. And tested in production, 12 GB ZFS (RAID1, one vdev local and another one s3backer), writing 5 MB/s on average, for a day at least, and then zfs scrub did not report any errors.
…lock, thus avoiding read-modify-write cycle
Solves issue #201. I am still a bit unsure about locking - what if 3 threads are writing to the same block and Thread 1 - partial write, enters
if (block_was_zeros)
, then is interrupted by the OS Thread 2 writes the whole block, all zeros Thread 3 - partial write, after thread 2 flags the block as all-zeros in zero_cache bitmap Thread 1 - continues and overwrites data written by thread 3 But I fear locking can hurt performance...Tested both by creating a small (64M) filesystem (did ext4 and ZFS) and writing some files and reading and comparing. And tested in production, 12 GB ZFS (RAID1, one vdev local and another one s3backer), writing 5 MB/s on average, for a day at least, and then zfs scrub did not report any errors.