• Alex Elder's avatar
    rbd: don't allocate mon_addrs buffer in rbd_add() · 7ef3214a
    Alex Elder authored
    The mon_addrs buffer in rbd_add is used to hold a copy of the
    monitor IP addresses supplied via /sys/bus/rbd/add.  That is
    passed to rbd_get_client(), which never modifies it (nor do
    any of the functions it gets passed to thereafter)--the mon_addr
    parameter to rbd_get_client() is a pointer to constant data, so it
    can't be modifed.  Furthermore, rbd_get_client() has the length of
    the mon_addrs buffer and that is used to ensure nothing goes beyond
    its end.
    
    Based on all this, there is no reason that a buffer needs to
    be used to hold a copy of the mon_addrs provided via
    /sys/bus/rbd/add.   Instead, the location within that passed-in
    buffer can be provided, along with the length of the "token"
    therein which represents the monitor IP's.
    
    A small change to rbd_add_parse_args() allows the address within the
    buffer to be passed back, and the length is already returned.  This
    now means that, at least from the perspective of this interface,
    there is no such thing as a list of monitor addresses that is too
    long.
    Signed-off-by: default avatarAlex Elder <elder@dreamhost.com>
    7ef3214a
rbd.c 57.6 KB