Skip to content

Commit

Permalink
fix bug in AggregatingWriter::write() (openzfs#480)
Browse files Browse the repository at this point in the history
If `AggregatingWriter::write()` is passed a slice that's larger than the
buffer capacity, it will panic.  This normally doesn't happen, since the
BlockBasedLogChunk is designed to be small (a few KB).

This commit changes `Aggregatingwriter::Write()` to allocate a larger
buffer if necessary.
  • Loading branch information
ahrens authored Jun 13, 2022
1 parent 75c74ba commit 4869939
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cmd/zfs_object_agent/zettacache/src/aggregating_writer.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::cmp::max;
use std::sync::Arc;

use tokio::sync::RwLock;
Expand Down Expand Up @@ -40,7 +41,7 @@ impl AggregatingWriter {
None => {
let mut vec = with_alloctag("AggregatingWriter PendingWrite", || {
AlignedVec::with_capacity(
self.capacity,
max(self.capacity, data.len()),
self.block_access.round_up_to_sector(1),
)
});
Expand Down

0 comments on commit 4869939

Please sign in to comment.