Skip to content

Commit

Permalink
Move object store into pager, cleanup old pager store.
Browse files Browse the repository at this point in the history
  • Loading branch information
dbittman committed Jan 9, 2025
1 parent a696e88 commit 7b29c7a
Show file tree
Hide file tree
Showing 16 changed files with 3 additions and 953 deletions.
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/bin/object-store-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ version = "0.1.0"
edition = "2021"

[dependencies]
object-store = { version = "0.1.0", path = "object-store" }
object-store = { version = "0.1.0", path = "../../srv/pager-srv/object-store" }
3 changes: 1 addition & 2 deletions src/srv/pager-srv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ twizzler-queue = { path = "../../lib/twizzler-queue" }
#twizzler-async = { path = "../../lib/twizzler-async" }
twizzler-driver = { path = "../../lib/twizzler-driver" }
twizzler-runtime = { path = "../../rt" }
nvme = { path = "../../lib/nvme-rs" }
tickv = { version = "1.0.0" }
object-store = { path = "object-store" }
async-trait = "0.1.66"
volatile = "0.5"
tracing = "0.1"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
87 changes: 0 additions & 87 deletions src/srv/pager-srv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use std::{
use async_executor::{Executor, Task};
use async_io::Timer;
use futures::executor::block_on;
use tickv::{success_codes::SuccessCode, ErrorCode};
use tracing::{debug, info, warn, Level};
use tracing_subscriber::FmtSubscriber;
use twizzler_abi::{
Expand All @@ -27,15 +26,12 @@ use crate::{
data::PagerData,
helpers::{physrange_to_pages, PAGE},
request_handle::handle_kernel_request,
store::{Key, KeyValueStore},
};

mod data;
mod helpers;
mod nvme;
mod physrw;
mod request_handle;
mod store;

pub static EXECUTOR: OnceLock<Executor> = OnceLock::new();

Expand Down Expand Up @@ -351,86 +347,3 @@ fn do_pager_start(q1: ObjID, q2: ObjID) {
pub fn pager_start(q1: ObjID, q2: ObjID) {
do_pager_start(q1, q2);
}

#[repr(C, packed)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
struct Foo {
x: u32,
}

static mut RAND_STATE: u32 = 0;
pub fn quick_random() -> u32 {
let state = unsafe { RAND_STATE };
let newstate = state.wrapping_mul(69069).wrapping_add(5);
unsafe {
RAND_STATE = newstate;
}
newstate >> 16
}

struct Tester<'a> {
kv: KeyValueStore<'a>,
truth: BTreeMap<Key, Foo>,
}

#[allow(dead_code)]
impl<'a> Tester<'a> {
fn test(&mut self) {
const TEST_ITERS: u32 = 100000;
for i in 0..TEST_ITERS {
// Every once in a while, validate some things.
if i % 2000 == 0 {
self.validate_has_all();
}
let x = i % (10001 + i / 1000);
let k = Key::new(ObjID::new(0), x, store::KeyKind::ObjectInfo);
let _ = self.get(k);
let num = quick_random() % 3;
if num == 0 || num == 2 {
let _ = self.put(k, Foo { x });
} else if num == 1 {
let _ = self.del(k);
}
}
}

fn validate_has_all(&self) {
for (key, val) in self.truth.iter() {
let res: Foo = self.kv.get(*key).unwrap();
assert_eq!(res, *val);
}
}

fn get(&self, key: Key) -> Result<Foo, ErrorCode> {
let r = self.kv.get(key);
if r.is_ok() {
assert!(self.truth.contains_key(&key));
let t = self.truth.get(&key).unwrap();
assert_eq!(t, r.as_ref().unwrap());
} else {
assert!(!self.truth.contains_key(&key));
}
r
}

fn put(&mut self, key: Key, v: Foo) -> Result<SuccessCode, ErrorCode> {
let res = self.kv.put(key, v);
if res.is_ok() {
assert!(!self.truth.contains_key(&key));
self.truth.insert(key, v);
} else {
assert!(self.truth.contains_key(&key));
}
res
}

fn del(&mut self, key: Key) -> Result<SuccessCode, ErrorCode> {
let res = self.kv.del(key);
if res.is_err() {
assert!(!self.truth.contains_key(&key));
} else {
self.truth.remove(&key).unwrap();
}
res
}
}
40 changes: 0 additions & 40 deletions src/srv/pager-srv/src/nvme.rs

This file was deleted.

Loading

0 comments on commit 7b29c7a

Please sign in to comment.