Skip to content

RFC bcachefs: add framework for internal Rust code

Thomas Bertschinger linux-bcachefs linux-fsdevel linux-kbuild rust-for-linux 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest3 patches 8 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3kbuild: rust: move bindgen commands to top-levelrust/Makefile scripts/Makefile.build+71 -670 replies
2/3bcachefs: create framework for Rust bindingsfs/bcachefs/.gitignore fs/bcachefs/Kconfig fs/bcachefs/Makefile +3 more+29 -00 replies
3/3bcachefs: introduce Rust module implementationfs/bcachefs/Makefile fs/bcachefs/bcachefs.h fs/bcachefs/bcachefs_module.rs +4 more+120 -42 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH RFC 0/3] bcachefs: add framework for internal Rust code

This series adds support for Rust code into bcachefs. This only enables using Rust internally within bcachefs; there are no public Rust APIs added. Rust support is hidden behind a new config option, CONFIG_BCACHEFS_RUST. It is optional and bcachefs can still be built with full functionality without rust.

I wasn't sure if this needed to be an RFC based on the current status of accepting Rust code outside of the rust/ tree, so I designated it as such to be safe. However, Kent plans to merge rust+bcachefs code in the 6.9 merge window, so I hope at least the first 2 patches in this series, the ones that actually enable Rust for bcachefs, can be accepted.

#1 is a prerequisite in KBuild. In order to call bindgen commands in the fs/bcachefs tree, the bindgen commands need to be defined in the top-level scripts/Makefile.build along with the rustc commands, instead of in rust/Makefile. This is the only patch outside of fs/bcachefs/ in this series.

#2 creates the framework to use rust-bindgen in fs/bcachefs and introduces the new config option to enable this. This patch does not actually generate any Rust bindings; it just lays the foundation for future patches to create bindings.

#3 demonstrates the new Rust functionality by implementing the module entry and exit functions for bcachefs in Rust. The current C entry and exit are retained so that bcachefs can still be built without Rust. Given Kent's goal to use Rust more in bcachefs, the C functions will presumably be dropped in the future.

Thomas Bertschinger (3):
kbuild: rust: move bindgen commands to top-level
bcachefs: create framework for Rust bindings
bcachefs: introduce Rust module implementation

 fs/bcachefs/.gitignore                 |  3 ++
 fs/bcachefs/Kconfig                    |  6 +++
 fs/bcachefs/Makefile                   | 12 +++++
 fs/bcachefs/bcachefs.h                 |  5 ++
 fs/bcachefs/bcachefs_module.rs         | 66 ++++++++++++++++++++++++
 fs/bcachefs/bindgen_parameters         | 16 ++++++
 fs/bcachefs/bindings/bindings_helper.h |  7 +++
 fs/bcachefs/bindings/mod.rs            |  5 ++
 fs/bcachefs/super.c                    | 31 +++++++++--
 rust/Makefile                          | 67 ------------------------
 scripts/Makefile.build                 | 71 ++++++++++++++++++++++++++
 11 files changed, 219 insertions(+), 70 deletions(-)
 create mode 100644 fs/bcachefs/.gitignore
 create mode 100644 fs/bcachefs/bcachefs_module.rs
 create mode 100644 fs/bcachefs/bindgen_parameters
 create mode 100644 fs/bcachefs/bindings/bindings_helper.h
 create mode 100644 fs/bcachefs/bindings/mod.rs
Signature · 1 line
2.43.0