Skip to content

Commit

Permalink
feat: change cmd entrance
Browse files Browse the repository at this point in the history
  • Loading branch information
zjregee committed Aug 24, 2024
1 parent df82268 commit 81eb105
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 85 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/behavior_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:

- name: Run Behavior Test
env:
KIND: fs
ROOT: ${{ github.workspace }}/.github/scripts
OVFS_SOCKET_PATH: /tmp/vfsd.sock
OVFS_BACKEND: fs://?root=${{ github.workspace }}/.github/scripts
run: |
cargo run --manifest-path ../../Cargo.toml --release &
chmod +x ./install_and_run_vm.sh
Expand Down
110 changes: 79 additions & 31 deletions Cargo.lock

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

10 changes: 6 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ edition = "2021"
[dependencies]
anyhow = { version = "1.0.86", features = ["std"] }
bitflags = "1.2"
env_logger = "0.11.3"
clap = { version = "4.5.16", features = ["derive", "env"] }
env_logger = "0.11.5"
futures = "0.3.30"
libc = "0.2.139"
log = "0.4.22"
opendal = { version = "0.47.3", features = ["services-fs", "services-s3"] }
opendal = { version = "0.49.1", features = ["services-fs", "services-s3"] }
sharded-slab = "0.1.7"
snafu = "0.8.3"
tokio = { version = "1.37.0", features = ["rt-multi-thread"] }
snafu = "0.8.4"
tokio = { version = "1.39.3", features = ["rt-multi-thread"] }
url = "2.5.2"
vhost = "0.10.0"
vhost-user-backend = "0.13.1"
virtio-bindings = { version = "0.2.1", features = ["virtio-v5_0_0"] }
Expand Down
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OVFS, OpenDAL File System via Virtio

OVFS is a backend implementation of VirtioFS. It provides a filesystem interface for VMs based on [Apache OpenDAL](https://github.com/apache/opendal), aiming to accelerate VMs IO performance by VirtIO and seamlessly connect with various storage backends.
OVFS is a backend implementation of VirtioFS. It provides a filesystem interface for VMs based on [OpenDAL](https://github.com/apache/opendal), aiming to accelerate VMs IO performance by VirtIO and seamlessly connect with various storage backends.

![OVFS Architecture](./docs/proposal/media/architecture.png)

Expand All @@ -14,15 +14,15 @@ The following components are required:
### Install QEMU and VMs

```shell
sudo apt-get -y qemu # debian/ubuntu
$ sudo apt-get -y qemu # debian/ubuntu
```

Download and install the VM, taking Ubuntu as an example:

```shell
wget https://releases.ubuntu.com/20.04/ubuntu-20.04.6-live-server-amd64.iso
truncate -s 10G image.img
sudo qemu-system-x86_64 -enable-kvm -smp 2 -m 4G \
$ wget https://releases.ubuntu.com/20.04/ubuntu-20.04.6-live-server-amd64.iso
$ truncate -s 10G image.img
$ sudo qemu-system-x86_64 -enable-kvm -smp 2 -m 4G \
-cdrom ubuntu-20.04.6-live-server-amd64.iso \
-drive file=image.img,format=raw,cache=none,if=virtio \
-boot d
Expand All @@ -37,15 +37,18 @@ host# cargo run --release <socket-path> <backend-url>
```

`backend-url` is the URL that includes the scheme and parameters of the service used, in the following format:
- fs://?root=<directory>

```markdown
- fs://?root=<path>
- s3://?root=<path>&bucket=<bucket>&endpoint=<endpoint>&region=<region>&access_key_id=<access-key-id>&secret_access_key=<secret-access-key>
```

Run the VM through QEMU and create a VirtioFS device:

```shell
host# sudo qemu-system-x86_64 --enable-kvm -smp 2 \
-m 4G -object memory-backend-file,id=mem,size=4G,mem-path=/dev/shm,share=on -numa node,memdev=mem \
-chardev socket,id=char0,path=/tmp/vfsd.sock -device vhost-user-fs-pci,queue-size=1024,chardev=char0,tag=myfs \
-chardev socket,id=char0,path=<socket-path> -device vhost-user-fs-pci,queue-size=1024,chardev=char0,tag=<fs-tag> \
-drive file=image.img,format=raw,cache=none,if=virtio \
-net user,hostfwd=tcp::2222-:22 -net nic \
-nographic -boot c
Expand Down
20 changes: 18 additions & 2 deletions src/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,9 @@ impl Filesystem {
None => return Filesystem::reply_error(in_header.unique, w, libc::ENOENT),
};

let mut opened_file_writer = self.opened_files_writer.lock().unwrap();
opened_file_writer.remove(&path);
if self.rt.block_on(self.do_release_writer(&path)).is_err() {
return Filesystem::reply_error(in_header.unique, w, libc::EIO);
}

Filesystem::reply_ok(None::<u8>, None, in_header.unique, w)
}
Expand Down Expand Up @@ -792,6 +793,21 @@ impl Filesystem {
Ok(())
}

async fn do_release_writer(&self, path: &str) -> Result<()> {
let mut opened_file_writer = self.opened_files_writer.lock().unwrap();
let inner_writer = opened_file_writer
.get_mut(path)
.ok_or(Error::from(libc::EIO))?;
inner_writer
.writer
.close()
.await
.map_err(|err| Error::from(err))?;
opened_file_writer.remove(path);

Ok(())
}

async fn do_delete(&self, path: &str) -> Result<()> {
self.core
.delete(path)
Expand Down
Loading

0 comments on commit 81eb105

Please sign in to comment.