Fix erasure and cuda related compilation errors
This commit is contained in:
parent
e10574c64d
commit
55a542bff0
|
@ -246,7 +246,7 @@ pub fn generate_coding(
|
||||||
trace!("{} window[{}] = {:?}", id, n, window[n].data);
|
trace!("{} window[{}] = {:?}", id, n, window[n].data);
|
||||||
|
|
||||||
if let Some(b) = &window[n].data {
|
if let Some(b) = &window[n].data {
|
||||||
max_data_size = cmp::max(b.read().meta.size, max_data_size);
|
max_data_size = cmp::max(b.read().unwrap().meta.size, max_data_size);
|
||||||
} else {
|
} else {
|
||||||
trace!("{} data block is null @ {}", id, n);
|
trace!("{} data block is null @ {}", id, n);
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
@ -265,7 +265,7 @@ pub fn generate_coding(
|
||||||
if let Some(b) = &window[n].data {
|
if let Some(b) = &window[n].data {
|
||||||
// make sure extra bytes in each blob are zero-d out for generation of
|
// make sure extra bytes in each blob are zero-d out for generation of
|
||||||
// coding blobs
|
// coding blobs
|
||||||
let mut b_wl = b.write();
|
let mut b_wl = b.write().unwrap();
|
||||||
for i in b_wl.meta.size..max_data_size {
|
for i in b_wl.meta.size..max_data_size {
|
||||||
b_wl.data[i] = 0;
|
b_wl.data[i] = 0;
|
||||||
}
|
}
|
||||||
|
@ -287,13 +287,13 @@ pub fn generate_coding(
|
||||||
window[n].coding = Some(SharedBlob::default());
|
window[n].coding = Some(SharedBlob::default());
|
||||||
|
|
||||||
let coding = window[n].coding.clone().unwrap();
|
let coding = window[n].coding.clone().unwrap();
|
||||||
let mut coding_wl = coding.write();
|
let mut coding_wl = coding.write().unwrap();
|
||||||
for i in 0..max_data_size {
|
for i in 0..max_data_size {
|
||||||
coding_wl.data[i] = 0;
|
coding_wl.data[i] = 0;
|
||||||
}
|
}
|
||||||
// copy index and id from the data blob
|
// copy index and id from the data blob
|
||||||
if let Some(data) = &window[n].data {
|
if let Some(data) = &window[n].data {
|
||||||
let data_rl = data.read();
|
let data_rl = data.read().unwrap();
|
||||||
|
|
||||||
let index = data_rl.get_index().unwrap();
|
let index = data_rl.get_index().unwrap();
|
||||||
let id = data_rl.get_id().unwrap();
|
let id = data_rl.get_id().unwrap();
|
||||||
|
@ -315,7 +315,7 @@ pub fn generate_coding(
|
||||||
coding_blobs.push(coding.clone());
|
coding_blobs.push(coding.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
let data_locks: Vec<_> = data_blobs.iter().map(|b| b.read()).collect();
|
let data_locks: Vec<_> = data_blobs.iter().map(|b| b.read().unwrap()).collect();
|
||||||
|
|
||||||
let data_ptrs: Vec<_> = data_locks
|
let data_ptrs: Vec<_> = data_locks
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -325,7 +325,7 @@ pub fn generate_coding(
|
||||||
&l.data[..max_data_size]
|
&l.data[..max_data_size]
|
||||||
}).collect();
|
}).collect();
|
||||||
|
|
||||||
let mut coding_locks: Vec<_> = coding_blobs.iter().map(|b| b.write()).collect();
|
let mut coding_locks: Vec<_> = coding_blobs.iter().map(|b| b.write().unwrap()).collect();
|
||||||
|
|
||||||
let mut coding_ptrs: Vec<_> = coding_locks
|
let mut coding_ptrs: Vec<_> = coding_locks
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
|
@ -351,7 +351,7 @@ pub fn generate_coding(
|
||||||
// false if slot has a blob with the right index
|
// false if slot has a blob with the right index
|
||||||
fn is_missing(id: &Pubkey, idx: u64, window_slot: &mut Option<SharedBlob>, c_or_d: &str) -> bool {
|
fn is_missing(id: &Pubkey, idx: u64, window_slot: &mut Option<SharedBlob>, c_or_d: &str) -> bool {
|
||||||
if let Some(blob) = window_slot.take() {
|
if let Some(blob) = window_slot.take() {
|
||||||
let blob_idx = blob.read().get_index().unwrap();
|
let blob_idx = blob.read().unwrap().get_index().unwrap();
|
||||||
if blob_idx == idx {
|
if blob_idx == idx {
|
||||||
trace!("recover {}: idx: {} good {}", id, idx, c_or_d);
|
trace!("recover {}: idx: {} good {}", id, idx, c_or_d);
|
||||||
// put it back
|
// put it back
|
||||||
|
@ -465,7 +465,7 @@ pub fn recover(id: &Pubkey, window: &mut [WindowSlot], start_idx: u64, start: us
|
||||||
|
|
||||||
if let Some(b) = window[j].data.clone() {
|
if let Some(b) = window[j].data.clone() {
|
||||||
if meta.is_none() {
|
if meta.is_none() {
|
||||||
meta = Some(b.read().meta.clone());
|
meta = Some(b.read().unwrap().meta.clone());
|
||||||
trace!("recover {} meta at {} {:?}", id, j, meta);
|
trace!("recover {} meta at {} {:?}", id, j, meta);
|
||||||
}
|
}
|
||||||
blobs.push(b);
|
blobs.push(b);
|
||||||
|
@ -481,7 +481,7 @@ pub fn recover(id: &Pubkey, window: &mut [WindowSlot], start_idx: u64, start: us
|
||||||
let j = i % window.len();
|
let j = i % window.len();
|
||||||
if let Some(b) = window[j].coding.clone() {
|
if let Some(b) = window[j].coding.clone() {
|
||||||
if size.is_none() {
|
if size.is_none() {
|
||||||
size = Some(b.read().meta.size - BLOB_HEADER_SIZE);
|
size = Some(b.read().unwrap().meta.size - BLOB_HEADER_SIZE);
|
||||||
trace!(
|
trace!(
|
||||||
"{} recover size {} from {}",
|
"{} recover size {} from {}",
|
||||||
id,
|
id,
|
||||||
|
@ -505,7 +505,7 @@ pub fn recover(id: &Pubkey, window: &mut [WindowSlot], start_idx: u64, start: us
|
||||||
let j = i % window.len();
|
let j = i % window.len();
|
||||||
|
|
||||||
if let Some(b) = &window[j].data {
|
if let Some(b) = &window[j].data {
|
||||||
let mut b_wl = b.write();
|
let mut b_wl = b.write().unwrap();
|
||||||
for i in b_wl.meta.size..size {
|
for i in b_wl.meta.size..size {
|
||||||
b_wl.data[i] = 0;
|
b_wl.data[i] = 0;
|
||||||
}
|
}
|
||||||
|
@ -517,7 +517,7 @@ pub fn recover(id: &Pubkey, window: &mut [WindowSlot], start_idx: u64, start: us
|
||||||
trace!("erasures[]: {} {:?} data_size: {}", id, erasures, size,);
|
trace!("erasures[]: {} {:?} data_size: {}", id, erasures, size,);
|
||||||
//lock everything for write
|
//lock everything for write
|
||||||
for b in &blobs {
|
for b in &blobs {
|
||||||
locks.push(b.write());
|
locks.push(b.write().unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -657,7 +657,7 @@ mod test {
|
||||||
print!("window({:>w$}): ", i, w = 2);
|
print!("window({:>w$}): ", i, w = 2);
|
||||||
if w.data.is_some() {
|
if w.data.is_some() {
|
||||||
let window_l1 = w.data.clone().unwrap();
|
let window_l1 = w.data.clone().unwrap();
|
||||||
let window_l2 = window_l1.read();
|
let window_l2 = window_l1.read().unwrap();
|
||||||
print!(
|
print!(
|
||||||
"data index: {:?} meta.size: {} data: ",
|
"data index: {:?} meta.size: {} data: ",
|
||||||
window_l2.get_index(),
|
window_l2.get_index(),
|
||||||
|
@ -673,7 +673,7 @@ mod test {
|
||||||
print!("window({:>w$}): ", i, w = 2);
|
print!("window({:>w$}): ", i, w = 2);
|
||||||
if w.coding.is_some() {
|
if w.coding.is_some() {
|
||||||
let window_l1 = w.coding.clone().unwrap();
|
let window_l1 = w.coding.clone().unwrap();
|
||||||
let window_l2 = window_l1.read();
|
let window_l2 = window_l1.read().unwrap();
|
||||||
print!(
|
print!(
|
||||||
"coding index: {:?} meta.size: {} data: ",
|
"coding index: {:?} meta.size: {} data: ",
|
||||||
window_l2.get_index(),
|
window_l2.get_index(),
|
||||||
|
@ -703,7 +703,7 @@ mod test {
|
||||||
for i in 0..num_blobs {
|
for i in 0..num_blobs {
|
||||||
let b = SharedBlob::default();
|
let b = SharedBlob::default();
|
||||||
let b_ = b.clone();
|
let b_ = b.clone();
|
||||||
let mut w = b.write();
|
let mut w = b.write().unwrap();
|
||||||
// generate a random length, multiple of 4 between 8 and 32
|
// generate a random length, multiple of 4 between 8 and 32
|
||||||
let data_len = if i == 3 {
|
let data_len = if i == 3 {
|
||||||
BLOB_DATA_SIZE
|
BLOB_DATA_SIZE
|
||||||
|
@ -729,7 +729,7 @@ mod test {
|
||||||
let d = crdt::NodeInfo::new_localhost(Keypair::new().pubkey());
|
let d = crdt::NodeInfo::new_localhost(Keypair::new().pubkey());
|
||||||
assert!(index_blobs(&d, &blobs, &mut (offset as u64)).is_ok());
|
assert!(index_blobs(&d, &blobs, &mut (offset as u64)).is_ok());
|
||||||
for b in blobs {
|
for b in blobs {
|
||||||
let idx = b.read().get_index().unwrap() as usize % WINDOW_SIZE;
|
let idx = b.read().unwrap().get_index().unwrap() as usize % WINDOW_SIZE;
|
||||||
|
|
||||||
window[idx].data = Some(b);
|
window[idx].data = Some(b);
|
||||||
}
|
}
|
||||||
|
@ -740,11 +740,11 @@ mod test {
|
||||||
for i in 0..num_blobs {
|
for i in 0..num_blobs {
|
||||||
if let Some(b) = &window[i].data {
|
if let Some(b) = &window[i].data {
|
||||||
let size = {
|
let size = {
|
||||||
let b_l = b.read();
|
let b_l = b.read().unwrap();
|
||||||
b_l.meta.size
|
b_l.meta.size
|
||||||
} as usize;
|
} as usize;
|
||||||
|
|
||||||
let mut b_l = b.write();
|
let mut b_l = b.write().unwrap();
|
||||||
for i in size..BLOB_SIZE {
|
for i in size..BLOB_SIZE {
|
||||||
b_l.data[i] = thread_rng().gen();
|
b_l.data[i] = thread_rng().gen();
|
||||||
}
|
}
|
||||||
|
@ -762,7 +762,7 @@ mod test {
|
||||||
|
|
||||||
for slot in &window {
|
for slot in &window {
|
||||||
if let Some(blob) = &slot.data {
|
if let Some(blob) = &slot.data {
|
||||||
let blob_r = blob.read();
|
let blob_r = blob.read().unwrap();
|
||||||
assert!(!blob_r.is_coding());
|
assert!(!blob_r.is_coding());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -802,9 +802,9 @@ mod test {
|
||||||
// Check the result, block is here to drop locks
|
// Check the result, block is here to drop locks
|
||||||
|
|
||||||
let window_l = window[erase_offset].data.clone().unwrap();
|
let window_l = window[erase_offset].data.clone().unwrap();
|
||||||
let window_l2 = window_l.read();
|
let window_l2 = window_l.read().unwrap();
|
||||||
let ref_l = refwindow.clone().unwrap();
|
let ref_l = refwindow.clone().unwrap();
|
||||||
let ref_l2 = ref_l.read();
|
let ref_l2 = ref_l.read().unwrap();
|
||||||
|
|
||||||
assert_eq!(window_l2.meta.size, ref_l2.meta.size);
|
assert_eq!(window_l2.meta.size, ref_l2.meta.size);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -838,9 +838,9 @@ mod test {
|
||||||
{
|
{
|
||||||
// Check the result, block is here to drop locks
|
// Check the result, block is here to drop locks
|
||||||
let window_l = window[erase_offset].data.clone().unwrap();
|
let window_l = window[erase_offset].data.clone().unwrap();
|
||||||
let window_l2 = window_l.read();
|
let window_l2 = window_l.read().unwrap();
|
||||||
let ref_l = refwindow.clone().unwrap();
|
let ref_l = refwindow.clone().unwrap();
|
||||||
let ref_l2 = ref_l.read();
|
let ref_l2 = ref_l.read().unwrap();
|
||||||
assert_eq!(window_l2.meta.size, ref_l2.meta.size);
|
assert_eq!(window_l2.meta.size, ref_l2.meta.size);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
window_l2.data[..window_l2.meta.size],
|
window_l2.data[..window_l2.meta.size],
|
||||||
|
@ -861,7 +861,10 @@ mod test {
|
||||||
// Create a hole in the window by making the blob's index stale
|
// Create a hole in the window by making the blob's index stale
|
||||||
let refwindow = window[offset].data.clone();
|
let refwindow = window[offset].data.clone();
|
||||||
if let Some(blob) = &window[erase_offset].data {
|
if let Some(blob) = &window[erase_offset].data {
|
||||||
blob.write().set_index(erase_offset as u64).unwrap(); // this also writes to refwindow...
|
blob.write()
|
||||||
|
.unwrap()
|
||||||
|
.set_index(erase_offset as u64)
|
||||||
|
.unwrap(); // this also writes to refwindow...
|
||||||
}
|
}
|
||||||
print_window(&window);
|
print_window(&window);
|
||||||
|
|
||||||
|
@ -873,6 +876,7 @@ mod test {
|
||||||
// fix refwindow, we wrote to it above...
|
// fix refwindow, we wrote to it above...
|
||||||
if let Some(blob) = &refwindow {
|
if let Some(blob) = &refwindow {
|
||||||
blob.write()
|
blob.write()
|
||||||
|
.unwrap()
|
||||||
.set_index((erase_offset + WINDOW_SIZE) as u64)
|
.set_index((erase_offset + WINDOW_SIZE) as u64)
|
||||||
.unwrap(); // this also writes to refwindow...
|
.unwrap(); // this also writes to refwindow...
|
||||||
}
|
}
|
||||||
|
@ -880,9 +884,9 @@ mod test {
|
||||||
{
|
{
|
||||||
// Check the result, block is here to drop locks
|
// Check the result, block is here to drop locks
|
||||||
let window_l = window[erase_offset].data.clone().unwrap();
|
let window_l = window[erase_offset].data.clone().unwrap();
|
||||||
let window_l2 = window_l.read();
|
let window_l2 = window_l.read().unwrap();
|
||||||
let ref_l = refwindow.clone().unwrap();
|
let ref_l = refwindow.clone().unwrap();
|
||||||
let ref_l2 = ref_l.read();
|
let ref_l2 = ref_l.read().unwrap();
|
||||||
assert_eq!(window_l2.meta.size, ref_l2.meta.size);
|
assert_eq!(window_l2.meta.size, ref_l2.meta.size);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
window_l2.data[..window_l2.meta.size],
|
window_l2.data[..window_l2.meta.size],
|
||||||
|
|
|
@ -152,7 +152,7 @@ pub fn ed25519_verify(batches: &[SharedPackets]) -> Vec<Vec<u8>> {
|
||||||
let mut rvs = Vec::new();
|
let mut rvs = Vec::new();
|
||||||
|
|
||||||
for packets in batches {
|
for packets in batches {
|
||||||
locks.push(packets.read());
|
locks.push(packets.read().unwrap());
|
||||||
}
|
}
|
||||||
let mut num = 0;
|
let mut num = 0;
|
||||||
for p in locks {
|
for p in locks {
|
||||||
|
|
Loading…
Reference in New Issue