archiecobbs / s3backer

FUSE/NBD single file backing store via Amazon S3
Other
538 stars 77 forks source link

zero_cache handles partial write to zero block by writing the whole b… #202

Closed xmrk-btc closed 1 year ago

xmrk-btc commented 1 year ago

…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.

archiecobbs commented 1 year ago

Implemented as e0d21a9f.