Skip to content

RFC erofs: introduce Rust implementation

Yiyang Wu linux-erofs linux-fsdevel lkml rust-for-linux 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest24 patches 43 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/24erofs: lift up erofs_fill_inode to globalfs/erofs/inode.c fs/erofs/internal.h+2 -10 replies
2/24erofs: add superblock data structure in Rustfs/erofs/Kconfig fs/erofs/Makefile fs/erofs/rust/erofs_sys.rs +3 more+178 -06 replies
3/24erofs: add Errno in Rustfs/erofs/rust/erofs_sys.rs fs/erofs/rust/erofs_sys/errnos.rs+197 -028 replies
4/24erofs: add xattrs data structure in Rustfs/erofs/rust/erofs_sys.rs fs/erofs/rust/erofs_sys/xattrs.rs+136 -00 replies
5/24erofs: add inode data structure in Rustfs/erofs/rust/erofs_sys.rs fs/erofs/rust/erofs_sys/inode.rs+292 -01 reply
6/24erofs: add alloc_helper in Rustfs/erofs/rust/erofs_sys.rs fs/erofs/rust/erofs_sys/alloc_helper.rs+36 -00 replies
7/24erofs: add data abstraction in Rustfs/erofs/rust/erofs_sys.rs fs/erofs/rust/erofs_sys/data.rs fs/erofs/rust/erofs_sys/data/backends.rs +1 more+106 -00 replies
8/24erofs: add device data structure in Rustfs/erofs/rust/erofs_sys.rs fs/erofs/rust/erofs_sys/devices.rs+29 -01 reply
9/24erofs: add continuous iterators in Rustfs/erofs/rust/erofs_sys/data.rs fs/erofs/rust/erofs_sys/data/raw_iters.rs fs/erofs/rust/erofs_sys/data/raw_iters/ref_iter.rs +1 more+89 -00 replies
10/24erofs: add device_infos implementation in Rustfs/erofs/rust/erofs_sys/devices.rs+47 -01 reply
11/24erofs: add map data structure in Rustfs/erofs/rust/erofs_sys.rs fs/erofs/rust/erofs_sys/map.rs+46 -00 replies
12/24erofs: add directory entry data structure in Rustfs/erofs/rust/erofs_sys.rs fs/erofs/rust/erofs_sys/dir.rs+99 -00 replies
13/24erofs: add runtime filesystem and inode in Rustfs/erofs/rust/erofs_sys.rs fs/erofs/rust/erofs_sys/inode.rs fs/erofs/rust/erofs_sys/superblock.rs +1 more+209 -20 replies
14/24erofs: add block mapping capability in Rustfs/erofs/rust/erofs_sys/map.rs fs/erofs/rust/erofs_sys/superblock.rs+183 -00 replies
15/24erofs: add iter methods in filesystem in Rustfs/erofs/rust/erofs_sys/data.rs fs/erofs/rust/erofs_sys/data/raw_iters/ref_iter.rs fs/erofs/rust/erofs_sys/data/raw_iters/traits.rs +2 more+104 -00 replies
16/24erofs: implement dir and inode operations in Rustfs/erofs/rust/erofs_sys.rs fs/erofs/rust/erofs_sys/data.rs fs/erofs/rust/erofs_sys/operations.rs +1 more+99 -00 replies
17/24erofs: introduce Rust SBI to Cfs/erofs/Makefile fs/erofs/internal.h fs/erofs/rust/kinode.rs +8 more+285 -40 replies
18/24erofs: introduce iget alternative to Cfs/erofs/Makefile fs/erofs/inode.c fs/erofs/inode_rs.rs +6 more+220 -160 replies
19/24erofs: introduce namei alternative to Cfs/erofs/Makefile fs/erofs/internal.h fs/erofs/namei.c +3 more+66 -28 replies
20/24erofs: introduce readdir alternative to Cfs/erofs/Makefile fs/erofs/dir.c fs/erofs/dir_rs.rs +2 more+62 -10 replies
21/24erofs: introduce erofs_map_blocks alternative to Cfs/erofs/Makefile fs/erofs/data.c fs/erofs/data_rs.rs +1 more+73 -10 replies
22/24erofs: add skippable iters in Rustfs/erofs/rust/erofs_sys/data/raw_iters.rs+121 -00 replies
23/24erofs: implement xattrs operations in Rustfs/erofs/inode_rs.rs fs/erofs/rust/erofs_sys/inode.rs fs/erofs/rust/erofs_sys/operations.rs +4 more+341 -20 replies
24/24erofs: introduce xattrs replacement to Cfs/erofs/Makefile fs/erofs/rust_bindings.h fs/erofs/xattr.c +2 more+148 -70 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 00/24] erofs: introduce Rust implementation

Greetings,

So here is a patchset to add Rust skeleton codes to the current EROFS implementation. The implementation is deeply inspired by the current C implementation, and it's based on a generic erofs_sys crate[1] written by me. The purpose is to potentially replace some of C codes to make to make full use of Rust's safety features and better optimization guarantees.

Many of the features (like compression inodes) still
fall back to C implementation because of my limited time and lack of Rust counterparts. However, the Extended Attributes work purely in Rust.

Some changes are done to the original C code.
1) Some of superblock operations are modified slightly to make sure memory allocation and deallocation are done correctly when interacting with Rust.
2) A new rust_helpers.c file is introduced to help Rust to deal with self-included EROFS API without exporting types that are not interpreted in Rust.
3) A new rust_bindings.h is introduced to provide Rust functions externs with the same function signature as Rust side so that C-side code can use the bindings easily.
4) CONFIG_EROFS_FS_RUST is added in dir.c, inode.c, super.c, data.c, and xattr.c to allow C code to be opt out and uses Rust implementation.
5) Some macros and function signatures are tweaked in internal.h with the compilation options.

Note that, since currently there is no mature Rust VFS implementation landed upstream, this patchset only uses C bindings internally and each unsafe operation is examined. This implementation only offers C-ABI-compatible functions impls and gets its exposed to original C implementation as either hooks or function pointers.

Also note that, this patchset only uses already-present self-included EROFS API and it uses as few C bindings generated from bindgen as possible, only inode, dentry, file and dir_context related are used, to be precise.

Since the EROFS community is pretty interested in giving Rust a try, I think this patchset will be a good start for Rust EROFS.

This patchset is based on the latest EROFS development tree. And the current codebase can also be found on my github repo[2].

[1]: https://github.com/ToolmanP/erofs-rs
[2]: https://github.com/ToolmanP/erofs-rs-linux

Yiyang Wu (24):
erofs: lift up erofs_fill_inode to global
erofs: add superblock data structure in Rust
erofs: add Errno in Rust
erofs: add xattrs data structure in Rust
erofs: add inode data structure in Rust
erofs: add alloc_helper in Rust
erofs: add data abstraction in Rust
erofs: add device data structure in Rust
erofs: add continuous iterators in Rust
erofs: add device_infos implementation in Rust
erofs: add map data structure in Rust
erofs: add directory entry data structure in Rust
erofs: add runtime filesystem and inode in Rust
erofs: add block mapping capability in Rust
erofs: add iter methods in filesystem in Rust
erofs: implement dir and inode operations in Rust
erofs: introduce Rust SBI to C
erofs: introduce iget alternative to C
erofs: introduce namei alternative to C
erofs: introduce readdir alternative to C
erofs: introduce erofs_map_blocks alternative to C
erofs: add skippable iters in Rust
erofs: implement xattrs operations in Rust
erofs: introduce xattrs replacement to C

 fs/erofs/Kconfig                              |  10 +
 fs/erofs/Makefile                             |   4 +
 fs/erofs/data.c                               |   5 +
 fs/erofs/data_rs.rs                           |  63 +++
 fs/erofs/dir.c                                |   2 +
 fs/erofs/dir_rs.rs                            |  57 ++
 fs/erofs/inode.c                              |  10 +-
 fs/erofs/inode_rs.rs                          |  64 +++
 fs/erofs/internal.h                           |  47 ++
 fs/erofs/namei.c                              |   2 +
 fs/erofs/namei_rs.rs                          |  56 ++
 fs/erofs/rust/erofs_sys.rs                    |  47 ++
 fs/erofs/rust/erofs_sys/alloc_helper.rs       |  35 ++
 fs/erofs/rust/erofs_sys/data.rs               |  70 +++
 fs/erofs/rust/erofs_sys/data/backends.rs      |   4 +
 .../erofs_sys/data/backends/uncompressed.rs   |  39 ++
 fs/erofs/rust/erofs_sys/data/raw_iters.rs     | 127 +++++
 .../rust/erofs_sys/data/raw_iters/ref_iter.rs | 131 +++++
 .../rust/erofs_sys/data/raw_iters/traits.rs   |  17 +
 fs/erofs/rust/erofs_sys/devices.rs            |  75 +++
 fs/erofs/rust/erofs_sys/dir.rs                |  98 ++++
 fs/erofs/rust/erofs_sys/errnos.rs             | 191 +++++++
 fs/erofs/rust/erofs_sys/inode.rs              | 398 ++++++++++++++
 fs/erofs/rust/erofs_sys/map.rs                |  99 ++++
 fs/erofs/rust/erofs_sys/operations.rs         |  62 +++
 fs/erofs/rust/erofs_sys/superblock.rs         | 514 ++++++++++++++++++
 fs/erofs/rust/erofs_sys/superblock/mem.rs     |  94 ++++
 fs/erofs/rust/erofs_sys/xattrs.rs             | 272 +++++++++
 fs/erofs/rust/kinode.rs                       |  76 +++
 fs/erofs/rust/ksources.rs                     |  66 +++
 fs/erofs/rust/ksuperblock.rs                  |  30 +
 fs/erofs/rust/mod.rs                          |   7 +
 fs/erofs/rust_bindings.h                      |  39 ++
 fs/erofs/rust_helpers.c                       |  86 +++
 fs/erofs/rust_helpers.h                       |  23 +
 fs/erofs/super.c                              |  51 +-
 fs/erofs/super_rs.rs                          |  59 ++
 fs/erofs/xattr.c                              |  31 +-
 fs/erofs/xattr.h                              |   7 +
 fs/erofs/xattr_rs.rs                          | 106 ++++
 40 files changed, 3153 insertions(+), 21 deletions(-)
 create mode 100644 fs/erofs/data_rs.rs
 create mode 100644 fs/erofs/dir_rs.rs
 create mode 100644 fs/erofs/inode_rs.rs
 create mode 100644 fs/erofs/namei_rs.rs
 create mode 100644 fs/erofs/rust/erofs_sys.rs
 create mode 100644 fs/erofs/rust/erofs_sys/alloc_helper.rs
 create mode 100644 fs/erofs/rust/erofs_sys/data.rs
 create mode 100644 fs/erofs/rust/erofs_sys/data/backends.rs
 create mode 100644 fs/erofs/rust/erofs_sys/data/backends/uncompressed.rs
 create mode 100644 fs/erofs/rust/erofs_sys/data/raw_iters.rs
 create mode 100644 fs/erofs/rust/erofs_sys/data/raw_iters/ref_iter.rs
 create mode 100644 fs/erofs/rust/erofs_sys/data/raw_iters/traits.rs
 create mode 100644 fs/erofs/rust/erofs_sys/devices.rs
 create mode 100644 fs/erofs/rust/erofs_sys/dir.rs
 create mode 100644 fs/erofs/rust/erofs_sys/errnos.rs
 create mode 100644 fs/erofs/rust/erofs_sys/inode.rs
 create mode 100644 fs/erofs/rust/erofs_sys/map.rs
 create mode 100644 fs/erofs/rust/erofs_sys/operations.rs
 create mode 100644 fs/erofs/rust/erofs_sys/superblock.rs
 create mode 100644 fs/erofs/rust/erofs_sys/superblock/mem.rs
 create mode 100644 fs/erofs/rust/erofs_sys/xattrs.rs
 create mode 100644 fs/erofs/rust/kinode.rs
 create mode 100644 fs/erofs/rust/ksources.rs
 create mode 100644 fs/erofs/rust/ksuperblock.rs
 create mode 100644 fs/erofs/rust/mod.rs
 create mode 100644 fs/erofs/rust_bindings.h
 create mode 100644 fs/erofs/rust_helpers.c
 create mode 100644 fs/erofs/rust_helpers.h
 create mode 100644 fs/erofs/super_rs.rs
 create mode 100644 fs/erofs/xattr_rs.rs
Signature · 1 line
2.46.0