• Alex Elder's avatar
    libceph: always allow trail in osd request · c885837f
    Alex Elder authored
    An osd request structure contains an optional trail portion, which
    if present will contain data to be passed in the payload portion of
    the message containing the request.  The trail field is a
    ceph_pagelist pointer, and if null it indicates there is no trail.
    
    A ceph_pagelist structure contains a length field, and it can
    legitimately hold value 0.  Make use of this to change the
    interpretation of the "trail" of an osd request so that every osd
    request has trailing data, it just might have length 0.
    
    This means we change the r_trail field in a ceph_osd_request
    structure from a pointer to a structure that is always initialized.
    
    Note that in ceph_osdc_start_request(), the trail pointer (or now
    address of that structure) is assigned to a ceph message's trail
    field.  Here's why that's still OK (looking at net/ceph/messenger.c):
        - What would have resulted in a null pointer previously will now
          refer to a 0-length page list.  That message trail pointer
          is used in two functions, write_partial_msg_pages() and
          out_msg_pos_next().
        - In write_partial_msg_pages(), a null page list pointer is
          handled the same as a message with 0-length trail, and both
          result in a "in_trail" variable set to false.  The trail
          pointer is only used if in_trail is true.
        - The only other place the message trail pointer is used is
          out_msg_pos_next().  That function is only called by
          write_partial_msg_pages() and only touches the trail pointer
          if the in_trail value it is passed is true.
    Therefore a null ceph_msg->trail pointer is equivalent to a non-null
    pointer referring to a 0-length page list structure.
    Signed-off-by: default avatarAlex Elder <elder@inktank.com>
    Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
    c885837f
osd_client.c 55.6 KB