[RFC PATCH 0/3] erofs: add rust support
Yiyang Wu
toolmanp at tlmp.cc
Thu Aug 8 04:47:00 AEST 2024
This is a patchset to add rust skeleton codes to the current Extended
Read-Only File System (erofs) implementation suggested by a recent OSPP
Project[1]. The implementation is deeply inspired by the current C implementation,
and it's based on a generic erofs_sys crate[2] written by me.
The purpose of this patchset is to provide infrastructure to potentially
replace all of C codes with rust with better maintainability and
performance with the help of Rust's safety features and better
optimization capabilities.
This patchset implements basic I/O operations and it's generally
functional, however i haven't tested all possible testcases (some of
them are chunk-based image files) yet. So it's
welcome to be tested and given supportive reviews.
Many of the "extended" features are disabled by default and still not
implemented yet but some of them have been already implemented in the
crate but kernel-side trait implementations are not ready yet. I'm
considering implementing it in the near future.
Note that, currently Rust VFS patches are still not merged because of the
previous rejections suggested by fs-devel team[3]. So this patch set only
uses C bindings internally and each unsafe operation is examined. This
implementation only offers functions impls and gets its exposed to
original C implementation as hooks. Only some of super operations are
modified slightly to make sure memory allocation and deallocation are
done correctly. Other changes to C are basically importing bindings from
rust. Besides, A new erofs_rust_helper.c file is introduced to help rust to deal
with folio, iomap and inode internal initializations.
Though it may violate some of the Rust-For-Linux principles,
i deem it's still ok to at least give it a try by using the Bindgen C
bindings since this work does not affect other Kernel APIs or the
current Rust For Linux Kernel crate designs.
This patchset is baed on the latest erofs-linux dev tree. And the
corresponding code can also be found on my github repo[4].
[1]: https://summer-ospp.ac.cn/org/prodetail/241920019?list=org&navpage=org
[2]: https://github.com/ToolmanP/erofs-rs
[3]: https://lore.kernel.org/rust-for-linux/ZZWhQGkl0xPiBD5%2F@casper.infradead.org/
[4]: https://github.com/ToolmanP/erofs-rs-linux
Yiyang Wu (3):
erofs: add erofs_sys crate
erofs: add implementation for erofs_sys
erofs: add rust options
fs/erofs/Kconfig | 11 +
fs/erofs/Makefile | 1 +
fs/erofs/data.c | 83 ++-
fs/erofs/dir.c | 20 +-
fs/erofs/erofs_rust.rs | 294 +++++++++
fs/erofs/erofs_rust_bindings.h | 47 ++
fs/erofs/erofs_rust_helper.c | 107 ++++
fs/erofs/erofs_rust_helper.h | 40 ++
fs/erofs/inode.c | 51 +-
fs/erofs/internal.h | 3 +
fs/erofs/namei.c | 30 +-
fs/erofs/rust/erofs_sys.rs | 67 ++
fs/erofs/rust/erofs_sys/alloc_helper.rs | 57 ++
fs/erofs/rust/erofs_sys/compression.rs | 18 +
fs/erofs/rust/erofs_sys/data.rs | 640 +++++++++++++++++++
fs/erofs/rust/erofs_sys/data/uncompressed.rs | 61 ++
fs/erofs/rust/erofs_sys/devices.rs | 53 ++
fs/erofs/rust/erofs_sys/dir.rs | 83 +++
fs/erofs/rust/erofs_sys/inode.rs | 407 ++++++++++++
fs/erofs/rust/erofs_sys/map.rs | 28 +
fs/erofs/rust/erofs_sys/operations.rs | 96 +++
fs/erofs/rust/erofs_sys/superblock.rs | 554 ++++++++++++++++
fs/erofs/rust/erofs_sys/superblock/file.rs | 114 ++++
fs/erofs/rust/erofs_sys/superblock/mem.rs | 156 +++++
fs/erofs/rust/erofs_sys/xattrs.rs | 175 +++++
fs/erofs/rust/kinode.rs | 103 +++
fs/erofs/rust/kinode/kinode_helper.rs | 26 +
fs/erofs/rust/mod.rs | 6 +
fs/erofs/rust/sources.rs | 5 +
fs/erofs/rust/sources/mm.rs | 62 ++
fs/erofs/rust/sources/page_helper.rs | 12 +
fs/erofs/super.c | 223 +++++--
32 files changed, 3523 insertions(+), 110 deletions(-)
create mode 100644 fs/erofs/erofs_rust.rs
create mode 100644 fs/erofs/erofs_rust_bindings.h
create mode 100644 fs/erofs/erofs_rust_helper.c
create mode 100644 fs/erofs/erofs_rust_helper.h
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/compression.rs
create mode 100644 fs/erofs/rust/erofs_sys/data.rs
create mode 100644 fs/erofs/rust/erofs_sys/data/uncompressed.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/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/file.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/kinode/kinode_helper.rs
create mode 100644 fs/erofs/rust/mod.rs
create mode 100644 fs/erofs/rust/sources.rs
create mode 100644 fs/erofs/rust/sources/mm.rs
create mode 100644 fs/erofs/rust/sources/page_helper.rs
--
2.45.2
More information about the Linux-erofs
mailing list