Giter VIP home page Giter VIP logo

nbd-async's People

Contributors

darkkirb avatar joshtriplett avatar oll3 avatar pimaker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

nbd-async's Issues

The result of serve_nbd is never Send

#4's first commit removed the Send requirement on BlockDevice. This makes sense, because there's no real reason it needs to be send...but it also has a very unfortunate consequence: BlockDevice can never be Send.

As a result, serve_nbd's returned Future isn't Send, which heavily limits where it can be used. In particular, I was trying to do this:

tokio::spawn(start_nbd(...));

But, because start_nbd's result isn't Send, it's not possible without resorting to using a LocalSet, which is...well, pretty ugly.

Unfortunately, I'm not sure if there's a particularly "clean" way to solve this. I think if send is a crate-level feature, then you could do:

#[cfg_attr(feature = "send", async_trait)]
#[cfg_attr(not(feature = "send")), async_trait(?Send))]
trait BlockDevice { ... }

i.e. BlockDevice is only Send if the corresponding feature is active. This does make it a workspace-wide control, but it's the only non-insane option I can think of. EDIT: well turns out you need to copy the entire BlockDevice definition, with one behind cfg(feature = "send") that's trait BlockDevice: Send, didn't notice before because rust-analyzer wasn't communicating the errors to me ๐Ÿ˜…

Error handling in Command::Read

From the documentation for NBD_CMD_READ:

If an error occurs, the server SHOULD set the appropriate error code
in the error field. The server MAY then initiate a hard disconnect.
If it chooses not to, it MUST NOT send any payload for this request.

So it seems to me that after setting reply.error, the reply_buf should be resized back to nbd::SIZE_OF_REPLY before sending the reply.

Separate providing NBD from attaching NBD?

Thank you for building this, it looks great!

One request: would you consider separating the interface for responding to NBD requests given a BlockDevice implementation from the interface for attaching an NBD socket to the local system? That would make it easy to hook the former up to a server socket, and to use the latter to attach a remote socket to a local NBD device.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.