Conversation
Closes #165 ## Summary - allow `File::read_block` to accept async SMB2 responses - reuse the existing pending-response handling instead of rejecting the read immediately ## Why This fixes a real downstream problem in OpenDAL's new SMB backend draft PR: [apache/opendal#7374](apache/opendal#7374). That OpenDAL branch is intentionally **not** carrying a local `smb-rs` fork. With crates.io `smb = 0.11.1`, a real Samba behavior run still hits read-path failures like: ```text IO Error: Invalid argument: Async command is not allowed in this context. ``` OpenDAL only passes today because its retry layer reconnects and retries those reads. In other words, the downstream behavior suite is green, but only because retries are masking this `smb-rs` bug. This change makes `read_block` consistent with the existing write path, which already calls `with_allow_async(true)`. ## Public downstream reproduction The downstream reproduction is public now: - OpenDAL draft PR: [apache/opendal#7374](apache/opendal#7374) - OpenDAL commit: `41faefd11f0f76253136e6aaa610bf360342d0a2` To reproduce the bug without this fix: ```bash git clone https://github.com/apache/opendal.git cd opendal git fetch https://github.com/suyanhanx/opendal.git feat/smb-service git checkout 41faefd11f0f76253136e6aaa610bf360342d0a2 cd core RUST_LOG=debug \ OPENDAL_TEST=smb \ OPENDAL_SMB_ENDPOINT=127.0.0.1:1445 \ OPENDAL_SMB_SHARE=MyShare \ OPENDAL_SMB_ROOT=/ \ OPENDAL_SMB_USER=alice \ OPENDAL_SMB_PASSWORD=alipass \ cargo test -p opendal --features tests,services-smb behavior -- --nocapture ``` Observed downstream behavior with crates.io `smb = 0.11.1`: - final result is still `92 passed; 0 failed` - debug logs show many async pending responses - some large reads also log `Async command is not allowed in this context` - OpenDAL retry logs then show the same read being retried successfully Representative downstream log lines: ```text IO Error: Invalid argument: Async command is not allowed in this context. will retry after 1s because: Unexpected (temporary) at read ... Async command is not allowed in this context. ``` ## Validation - `cargo check -p smb` To validate this change against the public downstream repro above, temporarily point the OpenDAL checkout to this PR branch and rerun the same behavior command. For example: ```toml [patch.crates-io] smb = { git = "https://github.com/suyanhanx/smb-rs", branch = "fix/allow-async-read-response" } ``` Expected result with this PR applied: - the same OpenDAL behavior command still finishes `92 passed; 0 failed` - async pending responses are still observed in debug logs - the previous `Async command is not allowed in this context` read failures disappear - OpenDAL no longer needs retry to recover those reads
3d54dc5 to
09fd33f
Compare
|
Rebased this branch onto current
Upstream status as of 2026-04-14:
There is also a new downstream constraint: the For now I'm keeping this PR as draft and not changing the dependency spec until that release/MSRV question is resolved. |
|
Follow-up validation on 2026-04-14 after comparing the full
So the evidence now points to the read fix itself being good for OpenDAL, while |
Which issue does this PR close?
Closes #7369.
Rationale for this change
OpenDAL does not have first-class SMB support today. This change adds an SMB service backed by
smb-rssoOperator::from_uriand the service registry can open SMB shares viasmb://host/share/root.This draft is intentionally split from the dependency fix path. OpenDAL is not carrying a local fork of
smb-rs; the upstream async-read fix is proposed separately in afiffon/smb-rs#167.What changes are included in this PR?
core/services/smbservice crateservices-smbinto the workspace feature list and registry exportscreate_dir,stat,read,write,delete, andlistsmb://host/share/rootand add matching.env.exampleentriesUncPathboundaryDELETE_PENDING/ not-found races during list and delete as skips instead of hard failuresThis draft does not enable
copyorrenameyet.Are there any user-facing changes?
Yes. Users get a new
services-smbfeature and can configure SMB tests via:OPENDAL_SMB_ENDPOINTOPENDAL_SMB_SHAREOPENDAL_SMB_ROOTOPENDAL_SMB_USEROPENDAL_SMB_PASSWORDValidation run on this branch:
cargo test -p opendal-service-smbcargo check -p opendal --features services-smbcargo clippy -p opendal-service-smb --all-targets -- -D warningscargo clippy -p opendal --all-targets --features services-smb -- -D warningsOPENDAL_TEST=smb OPENDAL_SMB_ENDPOINT=127.0.0.1:1445 OPENDAL_SMB_SHARE=MyShare OPENDAL_SMB_ROOT=/ OPENDAL_SMB_USER=alice OPENDAL_SMB_PASSWORD=alipass cargo test -p opendal --features tests,services-smb behaviorOne dependency caveat remains: with crates.io
smb = 0.11.1, large reads can still logAsync command is not allowed in this contextbefore OpenDAL retries them successfully. That fix is under review upstream in afiffon/smb-rs#167.AI Usage Statement
Built with Codex / GPT-5.