oll3 / nbd-async

Block device driver in userspace!
https://crates.io/crates/nbd-async
MIT License
8 stars 7 forks source link

Error handling in Command::Read #9

Closed Emm54321 closed 2 years ago

Emm54321 commented 3 years ago

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.

oll3 commented 3 years ago

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.

Yes, seems correct. I guess the client could also ensure this behavior but it is probably appropriate to enforce it here too. Is it something like #10 you have in mind @Emm54321 ?

Emm54321 commented 3 years ago

Yes, seems correct. I guess the client could also ensure this behavior but it is probably appropriate to enforce it here too. Is it something like #10 you have in mind @Emm54321 ?

Yes, this would fix problem.

oll3 commented 2 years ago

Closing since fixed with the merge of #10 .