Fix erasure and cuda related compilation errors

This commit is contained in:
Pankaj Garg 2018-09-26 22:47:44 +00:00 committed by Greg Fitzgerald
parent e10574c64d
commit 55a542bff0
2 changed files with 30 additions and 26 deletions

View File

@ -246,7 +246,7 @@ pub fn generate_coding(
trace!("{} window[{}] = {:?}", id, n, 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 {
trace!("{} data block is null @ {}", id, n);
return Ok(());
@ -265,7 +265,7 @@ pub fn generate_coding(
if let Some(b) = &window[n].data {
// make sure extra bytes in each blob are zero-d out for generation of
// 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 {
b_wl.data[i] = 0;
}
@ -287,13 +287,13 @@ pub fn generate_coding(
window[n].coding = Some(SharedBlob::default());
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 {
coding_wl.data[i] = 0;
}
// copy index and id from the data blob
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 id = data_rl.get_id().unwrap();
@ -315,7 +315,7 @@ pub fn generate_coding(
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
.iter()
@ -325,7 +325,7 @@ pub fn generate_coding(
&l.data[..max_data_size]
}).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
.iter_mut()
@ -351,7 +351,7 @@ pub fn generate_coding(
// 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 {
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 {
trace!("recover {}: idx: {} good {}", id, idx, c_or_d);
// 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 meta.is_none() {
meta = Some(b.read().meta.clone());
meta = Some(b.read().unwrap().meta.clone());
trace!("recover {} meta at {} {:?}", id, j, meta);
}
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();
if let Some(b) = window[j].coding.clone() {
if size.is_none() {
size = Some(b.read().meta.size - BLOB_HEADER_SIZE);
size = Some(b.read().unwrap().meta.size - BLOB_HEADER_SIZE);
trace!(
"{} recover size {} from {}",
id,
@ -505,7 +505,7 @@ pub fn recover(id: &Pubkey, window: &mut [WindowSlot], start_idx: u64, start: us
let j = i % window.len();
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 {
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,);
//lock everything for write
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);
if w.data.is_some() {
let window_l1 = w.data.clone().unwrap();
let window_l2 = window_l1.read();
let window_l2 = window_l1.read().unwrap();
print!(
"data index: {:?} meta.size: {} data: ",
window_l2.get_index(),
@ -673,7 +673,7 @@ mod test {
print!("window({:>w$}): ", i, w = 2);
if w.coding.is_some() {
let window_l1 = w.coding.clone().unwrap();
let window_l2 = window_l1.read();
let window_l2 = window_l1.read().unwrap();
print!(
"coding index: {:?} meta.size: {} data: ",
window_l2.get_index(),
@ -703,7 +703,7 @@ mod test {
for i in 0..num_blobs {
let b = SharedBlob::default();
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
let data_len = if i == 3 {
BLOB_DATA_SIZE
@ -729,7 +729,7 @@ mod test {
let d = crdt::NodeInfo::new_localhost(Keypair::new().pubkey());
assert!(index_blobs(&d, &blobs, &mut (offset as u64)).is_ok());
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);
}
@ -740,11 +740,11 @@ mod test {
for i in 0..num_blobs {
if let Some(b) = &window[i].data {
let size = {
let b_l = b.read();
let b_l = b.read().unwrap();
b_l.meta.size
} as usize;
let mut b_l = b.write();
let mut b_l = b.write().unwrap();
for i in size..BLOB_SIZE {
b_l.data[i] = thread_rng().gen();
}
@ -762,7 +762,7 @@ mod test {
for slot in &window {
if let Some(blob) = &slot.data {
let blob_r = blob.read();
let blob_r = blob.read().unwrap();
assert!(!blob_r.is_coding());
}
}
@ -802,9 +802,9 @@ mod test {
// Check the result, block is here to drop locks
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_l2 = ref_l.read();
let ref_l2 = ref_l.read().unwrap();
assert_eq!(window_l2.meta.size, ref_l2.meta.size);
assert_eq!(
@ -838,9 +838,9 @@ mod test {
{
// Check the result, block is here to drop locks
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_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.data[..window_l2.meta.size],
@ -861,7 +861,10 @@ mod test {
// Create a hole in the window by making the blob's index stale
let refwindow = window[offset].data.clone();
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);
@ -873,6 +876,7 @@ mod test {
// fix refwindow, we wrote to it above...
if let Some(blob) = &refwindow {
blob.write()
.unwrap()
.set_index((erase_offset + WINDOW_SIZE) as u64)
.unwrap(); // this also writes to refwindow...
}
@ -880,9 +884,9 @@ mod test {
{
// Check the result, block is here to drop locks
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_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.data[..window_l2.meta.size],

View File

@ -152,7 +152,7 @@ pub fn ed25519_verify(batches: &[SharedPackets]) -> Vec<Vec<u8>> {
let mut rvs = Vec::new();
for packets in batches {
locks.push(packets.read());
locks.push(packets.read().unwrap());
}
let mut num = 0;
for p in locks {