Do not skip RMW at the end of the file - skipping it may lead to data corruption (fix #116)

This commit is contained in:
Vitaliy Filippov
2025-12-20 18:34:20 +03:00
parent 8b7fa3d3bc
commit 9a02a592e3
-8
View File
@@ -505,13 +505,6 @@ static void nfs_do_align_write(nfs_kv_write_state *st, uint64_t ino, uint64_t of
{ {
// Requires read-modify-write in the end // Requires read-modify-write in the end
assert(st->offset+st->size <= st->new_size); assert(st->offset+st->size <= st->new_size);
if (st->offset+st->size == st->new_size)
{
// rmw can be skipped at end - we can just zero pad the request
end_pad = alignment - (end % alignment);
}
else
{
auto s = (end % alignment); auto s = (end % alignment);
if (good_size > s) if (good_size > s)
good_size -= s; good_size -= s;
@@ -533,7 +526,6 @@ static void nfs_do_align_write(nfs_kv_write_state *st, uint64_t ino, uint64_t of
st->waiting++; st->waiting++;
nfs_do_rmw(&st->rmw[1]); nfs_do_rmw(&st->rmw[1]);
} }
}
if (good_size > 0 || end_pad > 0 || begin_shdr) if (good_size > 0 || end_pad > 0 || begin_shdr)
{ {
// Normal write // Normal write