Implement FLUSH command and honour FUA flag

I changed the request struct to break the 32 bits reserved for the
request type into two.  The first part of this is used for the flags
(such as FUA), and the second part for the command type.  Previously
we'd masked the top two bytes, thus ignoring any flags.
This commit is contained in:
Patrick J Cherry
2018-02-01 22:13:59 +00:00
parent 25cc084108
commit 1f0ef0aad6
4 changed files with 50 additions and 23 deletions

View File

@@ -305,7 +305,7 @@ int proxy_prefetch_for_request( struct proxier* proxy, int state )
struct nbd_request_raw* req_raw = (struct nbd_request_raw*) proxy->req.buf;
struct nbd_reply_raw *rsp_raw = (struct nbd_reply_raw*) proxy->rsp.buf;
int is_read = ( req->type & REQUEST_MASK ) == REQUEST_READ;
int is_read = req->type == REQUEST_READ;
if ( is_read ) {
/* See if we can respond with what's in our prefetch
@@ -435,19 +435,19 @@ int proxy_read_from_downstream( struct proxier *proxy, int state )
if ( proxy->req.needle == NBD_REQUEST_SIZE ) {
nbd_r2h_request( request_raw, request );
if ( ( request->type & REQUEST_MASK ) == REQUEST_DISCONNECT ) {
if ( request->type == REQUEST_DISCONNECT ) {
info( "Received disconnect request from client" );
return EXIT;
}
/* Simple validations */
if ( ( request->type & REQUEST_MASK ) == REQUEST_READ ) {
if ( request->type == REQUEST_READ ) {
if (request->len > ( NBD_MAX_SIZE - NBD_REPLY_SIZE ) ) {
warn( "NBD read request size %"PRIu32" too large", request->len );
return EXIT;
}
}
if ( (request->type & REQUEST_MASK ) == REQUEST_WRITE ) {
if ( request->type == REQUEST_WRITE ) {
if (request->len > ( NBD_MAX_SIZE - NBD_REQUEST_SIZE ) ) {
warn( "NBD write request size %"PRIu32" too large", request->len );
return EXIT;
@@ -607,7 +607,7 @@ int proxy_read_from_upstream( struct proxier* proxy, int state )
goto disconnect;
}
if ( ( proxy->req_hdr.type & REQUEST_MASK ) == REQUEST_READ ) {
if ( proxy->req_hdr.type == REQUEST_READ ) {
/* Get the read reply data too. */
proxy->rsp.size += proxy->req_hdr.len;
}