diff --git a/Cargo.lock b/Cargo.lock index 990216c53..ec6c3ab3f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -665,6 +665,7 @@ dependencies = [ "futures", "ipnetwork", "once_cell", + "serde", "tokio", "tracing", ] @@ -1094,6 +1095,7 @@ name = "event-publisher" version = "0.1.0" dependencies = [ "events-api", + "serde", "serde_json", "tokio", "tracing", diff --git a/Jenkinsfile b/Jenkinsfile index acb0b6098..2a210044a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -138,9 +138,10 @@ pipeline { steps { cleanWs() unstash 'source' - sh 'nix-shell --run "./scripts/rust-style.sh" ci.nix' + sh 'nix-shell --run "FMT_OPTS=--check ./scripts/rust-style.sh" ci.nix' sh 'nix-shell --run "./scripts/rust-linter.sh" ci.nix' sh 'nix-shell --run "./scripts/js-check.sh" ci.nix' + sh 'nix-shell --run "nixpkgs-fmt --check ." ci.nix' script { if (env.BRANCH_NAME != "trying") { sh 'nix-shell --run "./scripts/check-submodule-branches.sh" ci.nix' diff --git a/ci.nix b/ci.nix index 3fa791f12..1864835b6 100644 --- a/ci.nix +++ b/ci.nix @@ -37,7 +37,10 @@ let numactl pytest_inputs udev + libnvme + nvme-cli xfsprogs + nixpkgs-fmt ]; shellEnv = with pkgs; { @@ -67,6 +70,6 @@ let }; }; in - pkgs.mkShell shellAttrs // { - name = "io-engine-dev-shell"; - } +pkgs.mkShell shellAttrs // { + name = "io-engine-dev-shell"; +} diff --git a/ide.nix b/ide.nix index 18b89c00c..13e0e1555 100644 --- a/ide.nix +++ b/ide.nix @@ -2,8 +2,8 @@ , spdk ? "develop" , spdk-path ? null } @ args: - import ./ci.nix { - inherit rust; - inherit spdk; - inherit spdk-path; - } +import ./ci.nix { + inherit rust; + inherit spdk; + inherit spdk-path; +} diff --git a/io-engine/src/bdev/nvmx/qpair.rs b/io-engine/src/bdev/nvmx/qpair.rs index 9684c2ce7..85838a770 100644 --- a/io-engine/src/bdev/nvmx/qpair.rs +++ b/io-engine/src/bdev/nvmx/qpair.rs @@ -22,9 +22,9 @@ use spdk_rs::libspdk::{ spdk_nvme_qpair_set_abort_dnr, }; +use std::mem::zeroed; #[cfg(feature = "spdk-async-qpair-connect")] use std::{os::raw::c_void, time::Duration}; -use std::mem::zeroed; #[cfg(feature = "spdk-async-qpair-connect")] use spdk_rs::{ diff --git a/io-engine/src/core/env.rs b/io-engine/src/core/env.rs index 154d8f0bf..54cbd19be 100644 --- a/io-engine/src/core/env.rs +++ b/io-engine/src/core/env.rs @@ -27,6 +27,7 @@ use spdk_rs::{ libspdk::{ spdk_app_shutdown_cb, spdk_env_dpdk_post_init, + spdk_env_dpdk_rte_eal_init, spdk_env_fini, spdk_log_close, spdk_log_level, @@ -43,7 +44,6 @@ use spdk_rs::{ spdk_thread_lib_fini, spdk_thread_send_critical_msg, spdk_trace_cleanup, - spdk_env_dpdk_rte_eal_init, SPDK_LOG_DEBUG, SPDK_LOG_INFO, SPDK_RPC_RUNTIME, diff --git a/nix/overlay.nix b/nix/overlay.nix index 2b08b995d..6d5a75df7 100644 --- a/nix/overlay.nix +++ b/nix/overlay.nix @@ -14,4 +14,4 @@ self: super: rec { nvmet-cli = super.callPackage ./pkgs/nvmet-cli { }; units = (super.callPackage ./pkgs/io-engine/units.nix { inherit tag sourcer; }); } -// (import ../spdk-rs/nix/overlay.nix { } self super) + // (import ../spdk-rs/nix/overlay.nix { } self super) diff --git a/nix/pkgs/io-engine/cargo-package.nix b/nix/pkgs/io-engine/cargo-package.nix index 47282fa32..978fcef37 100644 --- a/nix/pkgs/io-engine/cargo-package.nix +++ b/nix/pkgs/io-engine/cargo-package.nix @@ -27,6 +27,7 @@ , targetPlatform , versions , systemdMinimal +, rdma-core , cargoBuildFlags ? [ ] }: let @@ -87,6 +88,7 @@ let protobuf systemdMinimal.dev utillinux.dev + rdma-core ]; cargoLock = { lockFile = ../../../Cargo.lock; diff --git a/nix/pkgs/io-engine/default.nix b/nix/pkgs/io-engine/default.nix index 90bd6a585..cc03153a1 100644 --- a/nix/pkgs/io-engine/default.nix +++ b/nix/pkgs/io-engine/default.nix @@ -1,27 +1,5 @@ { stdenv -, clang -, dockerTools -, e2fsprogs , lib -, libaio -, libbsd -, libspdk -, libspdk-dev -, libpcap -, udev -, liburing -, makeRustPlatform -, numactl -, openssl -, pkg-config -, protobuf -, sources -, xfsprogs -, utillinux -, llvmPackages -, targetPackages -, buildPackages -, targetPlatform , pkgs , git , tag diff --git a/nix/sources.nix b/nix/sources.nix index 28a48153a..b6443cad3 100644 --- a/nix/sources.nix +++ b/nix/sources.nix @@ -1,3 +1,2 @@ - # Redirects to `spdk-rs`. import ../spdk-rs/nix/sources.nix diff --git a/scripts/rust-linter-env.sh b/scripts/rust-linter-env.sh deleted file mode 100644 index 39ce7dbc7..000000000 --- a/scripts/rust-linter-env.sh +++ /dev/null @@ -1,134 +0,0 @@ -#!/usr/bin/env bash - -MSG_PREFIX="rust linter env" -VERBOSE=0 - -err_exit() { - echo "$MSG_PREFIX error: $1" - exit 1 -} - -info() { - if [[ $VERBOSE == "1" ]]; then - echo "$MSG_PREFIX info: $1" - fi -} - -make_regex() { - local res=$1 - local res=$(echo "$res" | sed "s/\\./\\\\./g") - local res=$(echo "$res" | sed "s/(/\\\\(/g") - local res=$(echo "$res" | sed "s/)/\\\\)/g") - local res=$(echo "$res" | sed "s/\\*/.*/g") - echo "$res" -} - -echo "configuring Rust linter environment..." - -# Parse arguments -while [ "$#" -gt 0 ]; do - case $1 in - -v|--verbose) - VERBOSE=1 - shift - ;; - *) - err_exit "unknown option: $1" - ;; - esac -done - -if [[ $(uname) != "Linux" ]]; then - err_exit "must be run on Linux with Mayastor prerequisities installed" -fi - -# Rust nightly toolchain "2021-11-30" installs cargo version "2021-11-24" and -# rustfmt and clippy "2021-11-29". -# When upgrading Rust toolchain version, check 'cargo --version', -# 'cargo fmt --version', 'cargo clippy --version' and put them here. -RUST_TOOLCHAIN_VER="2023-08-25" -WANTED_CARGO_VER="cargo 1.74.0-nightly (* 2023-08-22)" -WANTED_RUSTFMT_VER="rustfmt 1.6.0-nightly (* 2023-08-24)" -WANTED_CLIPPY_VER="clippy 0.1.73 (* 2023-08-24)" -CARGO="cargo" -CARGO_MODE="system" - -CARGO_VER_RE=$(make_regex "$WANTED_CARGO_VER") -RUSTFMT_VER_RE=$(make_regex "$WANTED_RUSTFMT_VER") -CLIPPY_VER_RE=$(make_regex "$WANTED_CLIPPY_VER") - -# If RUST_NIGHTLY_PATH is defined, use it. -if [ -n "$RUST_NIGHTLY_PATH" ]; then - info "RUST_NIGHTLY_PATH is set: $RUST_NIGHTLY_PATH" - CARGO="$RUST_NIGHTLY_PATH/bin/cargo" - CARGO_MODE="explicit nightly" - - # cargo searches PATH for its subcommands (e.g. cargo fmt), so export - # PATH with RUST_NIGHTLY_PATH put before all other PATHs. - PATH=$RUST_NIGHTLY_PATH/bin:$PATH -fi - -# Try cargo from PATH. -info "using $CARGO_MODE cargo command: '$CARGO'" -CARGO_VER=$($CARGO --version 2>/dev/null) - -if [[ $? != 0 ]]; then - err_exit "'cargo' not found" -fi - -info "found 'cargo' version: $CARGO_VER" - -if ! [[ "$CARGO_VER" =~ $CARGO_VER_RE ]]; then - info "required $WANTED_CARGO_VER, trying rustup +nightly..." - - # Try +nightly option of cargo installed via rustup. - # Give up, if it fails. - CARGO="cargo +nightly-$RUST_TOOLCHAIN_VER" - CARGO_MODE="rustup nightly" - CARGO_VER=$($CARGO --version 2>/dev/null) - if [[ $? != 0 ]]; then - err_exit "'$CARGO' not found" - fi - - info "using $CARGO_MODE: $CARGO" - - if ! [[ "$CARGO_VER" =~ $CARGO_VER_RE ]]; then - err_exit "required $WANTED_CARGO_VER" - fi -fi - -# -# Check fmt version. -# -RUSTFMT_VER=$($CARGO fmt --version 2>/dev/null) -if [[ $? != 0 ]]; then - err_exit "'cargo fmt' not found" -fi - -info "found 'cargo fmt' version: $RUSTFMT_VER" - -if ! [[ "$RUSTFMT_VER" =~ $RUSTFMT_VER_RE ]]; then - err_exit "required $WANTED_RUSTFMT_VER" -fi - -# -# Check clippy version. -# -CLIPPY_VER=$($CARGO clippy --version 2>/dev/null) - -if [[ $? != 0 ]]; then - err_exit "'cargo clippy' not found" -fi - -info "found 'cargo clippy' version: $CLIPPY_VER" - -if ! [[ "$CLIPPY_VER" =~ $CLIPPY_VER_RE ]]; then - err_exit "required $WANTED_CLIPPY_VER" -fi - -echo " using cargo : $CARGO_MODE" -echo " cargo command : $CARGO" -echo " cargo version : $CARGO_VER" -echo " cargo fmt version : $RUSTFMT_VER" -echo " cargo clippy version : $CLIPPY_VER" -echo "configuration of Rust linter environment done" diff --git a/scripts/rust-linter.sh b/scripts/rust-linter.sh index bf90b8582..b93f60ab3 100755 --- a/scripts/rust-linter.sh +++ b/scripts/rust-linter.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -source ${BASH_SOURCE%/*}/rust-linter-env.sh +source ${BASH_SOURCE%/*}/../spdk-rs/scripts/rust-linter-env.sh $CARGO clippy --all --all-targets --features=io-engine-testing -- -D warnings \ -A clippy::await-holding-lock \ -A clippy::await-holding-refcell-ref \ diff --git a/scripts/rust-style.sh b/scripts/rust-style.sh index 312c48333..00620ad10 100755 --- a/scripts/rust-style.sh +++ b/scripts/rust-style.sh @@ -2,5 +2,5 @@ FMT_OPTS=${FMT_OPTS:-""} -source ${BASH_SOURCE%/*}/rust-linter-env.sh +source ${BASH_SOURCE%/*}/../spdk-rs/scripts/rust-linter-env.sh $CARGO fmt --all -- $FMT_OPTS diff --git a/shell.nix b/shell.nix index 7088c8aa2..612b4fcb3 100644 --- a/shell.nix +++ b/shell.nix @@ -2,8 +2,8 @@ , spdk ? "develop" , spdk-path ? null } @ args: - import ./ci.nix { - inherit rust; - inherit spdk; - inherit spdk-path; - } +import ./ci.nix { + inherit rust; + inherit spdk; + inherit spdk-path; +} diff --git a/spdk-rs b/spdk-rs index ea6ef4ef3..1e0f4afa6 160000 --- a/spdk-rs +++ b/spdk-rs @@ -1 +1 @@ -Subproject commit ea6ef4ef351429fd76cbaec20d0735dcfa2588e3 +Subproject commit 1e0f4afa6d5fc97317c53914017c1462b23a3e5a diff --git a/utils/dependencies b/utils/dependencies index eb9d43a61..4cee46e2c 160000 --- a/utils/dependencies +++ b/utils/dependencies @@ -1 +1 @@ -Subproject commit eb9d43a612604750de9679179d33058f2daf780b +Subproject commit 4cee46e2cc2e1b9a7016eef565c030731011dd32