Skip to content
  • Eric Blake's avatar
    ebd57062
    nbd: Simplify meta-context parsing · ebd57062
    Eric Blake authored
    
    
    We had a premature optimization of trying to read as little from the
    wire as possible while handling NBD_OPT_SET_META_CONTEXT in phases.
    But in reality, we HAVE to read the entire string from the client
    before we can get to the next command, and it is easier to just read
    it all at once than it is to read it in pieces.  And once we do that,
    several functions end up no longer performing I/O, so they can drop
    length and errp parameters, and just return a bool instead of
    modifying through a pointer.
    
    Our iotests still pass; I also checked that libnbd's testsuite (which
    covers more corner cases of odd meta context requests) still passes.
    There are cases where the sequence of trace messages produced differs
    (for example, when no bitmap is exported, a query for "qemu:" now
    produces two trace lines instead of one), but trace points are for
    debug and have no effect on what the client sees.
    
    Signed-off-by: default avatarEric Blake <eblake@redhat.com>
    Message-Id: <20200930121105.667049-4-eblake@redhat.com>
    Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
    [eblake: enhance commit message]
    Signed-off-by: default avatarEric Blake <eblake@redhat.com>
    ebd57062
    nbd: Simplify meta-context parsing
    Eric Blake authored
    
    
    We had a premature optimization of trying to read as little from the
    wire as possible while handling NBD_OPT_SET_META_CONTEXT in phases.
    But in reality, we HAVE to read the entire string from the client
    before we can get to the next command, and it is easier to just read
    it all at once than it is to read it in pieces.  And once we do that,
    several functions end up no longer performing I/O, so they can drop
    length and errp parameters, and just return a bool instead of
    modifying through a pointer.
    
    Our iotests still pass; I also checked that libnbd's testsuite (which
    covers more corner cases of odd meta context requests) still passes.
    There are cases where the sequence of trace messages produced differs
    (for example, when no bitmap is exported, a query for "qemu:" now
    produces two trace lines instead of one), but trace points are for
    debug and have no effect on what the client sees.
    
    Signed-off-by: default avatarEric Blake <eblake@redhat.com>
    Message-Id: <20200930121105.667049-4-eblake@redhat.com>
    Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
    [eblake: enhance commit message]
    Signed-off-by: default avatarEric Blake <eblake@redhat.com>
Loading