Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement dm-sworndisk with core crate #35

Merged
merged 3 commits into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ edition = "2021"

[dependencies]
bindings = { path = "../linux/bindings", optional = true }
btree = { git = "https://github.com/asterinas/btree.git", rev = "8583630", optional = true }
inherit-methods-macro = {git = "https://github.com/asterinas/inherit-methods-macro", rev = "98f7e3e"}
pod = { git = "https://github.com/asterinas/pod", rev = "d7dba56" }

Expand All @@ -30,7 +31,7 @@ sgx_types = { git = "https://github.com/apache/teaclave-sgx-sdk.git", optional =
[features]
default = ["std"]
std = ["spin", "openssl", "log"]
linux = ["bindings"]
linux = ["bindings", "btree"]
occlum = ["sgx_tstd", "sgx_rand", "sgx_tcrypto", "sgx_types", "spin", "log"]
jinux = []

Expand Down
7 changes: 1 addition & 6 deletions core/src/layers/4-lsm/mem_table.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
//! MemTable.
use super::{AsKV, RangeQueryCtx, RecordKey, RecordValue, SyncId};
use crate::os::{BTreeMap, Mutex, RwLock, RwLockReadGuard};
use crate::os::{BTreeMap, Condvar, CvarMutex, Mutex, RwLock, RwLockReadGuard};
use crate::prelude::*;

use core::ops::Range;
// TODO: Put them into os module
#[cfg(feature = "occlum")]
use sgx_tstd::sync::{SgxCondvar as Condvar, SgxMutex as CvarMutex};
#[cfg(feature = "std")]
use std::sync::{Condvar, Mutex as CvarMutex};

/// Manager for an mutable `MemTable` and an immutable `MemTable`
/// in a `TxLsmTree`.
Expand Down
8 changes: 1 addition & 7 deletions core/src/layers/5-disk/block_alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use super::sworndisk::Hba;
use crate::layers::bio::{BlockSet, Buf, BufRef, BID_SIZE};
use crate::layers::log::{TxLog, TxLogStore};
use crate::os::{BTreeMap, Mutex};
use crate::os::{BTreeMap, Condvar, CvarMutex, Mutex};
use crate::prelude::*;
use crate::util::BitMap;

Expand All @@ -12,12 +12,6 @@ use core::sync::atomic::{AtomicUsize, Ordering};
use pod::Pod;
use serde::{Deserialize, Serialize};

// TODO: Put them into os module
#[cfg(feature = "occlum")]
use sgx_tstd::sync::{SgxCondvar as Condvar, SgxMutex as CvarMutex};
#[cfg(feature = "std")]
use std::sync::{Condvar, Mutex as CvarMutex};

/// The bucket name of block validity table.
const BUCKET_BLOCK_VALIDITY_TABLE: &str = "BVT";
/// The bucket name of block alloc/dealloc log.
Expand Down
8 changes: 1 addition & 7 deletions core/src/layers/5-disk/data_buf.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
//! Data buffering.
use super::sworndisk::RecordKey;
use crate::layers::bio::{BufMut, BufRef};
use crate::os::{BTreeMap, Mutex};
use crate::os::{BTreeMap, Condvar, CvarMutex, Mutex};
use crate::prelude::*;

use core::ops::RangeInclusive;

// TODO: Put them into os module
#[cfg(feature = "occlum")]
use sgx_tstd::sync::{SgxCondvar as Condvar, SgxMutex as CvarMutex};
#[cfg(feature = "std")]
use std::sync::{Condvar, Mutex as CvarMutex};

/// A buffer to cache data blocks before they are written to disk.
#[derive(Debug)]
pub(super) struct DataBuf {
Expand Down
12 changes: 10 additions & 2 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,20 @@
#![feature(negative_impls)]
#![feature(new_uninit)]
#![feature(receiver_trait)]
#![feature(sized_type_properties)]
#![feature(slice_concat_trait)]
#![feature(slice_group_by)]
#![feature(slice_internals)]
#![feature(tuple_trait)]
#![feature(unboxed_closures)]
#![feature(unsize)]
#![allow(dead_code, stable_features, unknown_lints, unused_imports)]
#![allow(
dead_code,
internal_features,
stable_features,
unknown_lints,
unused_imports
)]

mod error;
mod layers;
Expand All @@ -29,7 +37,7 @@ mod util;
extern crate alloc;

#[cfg(feature = "linux")]
pub use self::os::{Arc, Mutex};
pub use self::os::{Arc, Mutex, Vec};

#[cfg(feature = "occlum")]
#[macro_use]
Expand Down
Loading
Loading