1. 08 May, 2013 14 commits
    • Alex Elder's avatar
      rbd: get rid of trivial v1 header wrappers · 99a41ebc
      Alex Elder authored
      Get rid of the trivial wrapper functions rbd_dev_v1_refresh() and
      rbd_dev_v1_probe(), substituting rbd_dev_v1_header_read() calls
      in their place.
      
      Rename rbd_dev_v1_header_read() to be rbd_dev_v1_header_info(), to
      be more generic (it will better reflect what happens with format 2
      images).
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      99a41ebc
    • Alex Elder's avatar
      rbd: simplify rbd_dev_v1_probe() · 30d60ba2
      Alex Elder authored
      An rbd_dev structure's fields are all zero-filled for an initial
      probe, so there's no need to explicitly zero the parent_spec
      and parent_overlap fields in rbd_dev_v1_probe().  Removing these
      assignments makes rbd_dev_v1_probe() *almost* trivial.
      
      Move the dout() message that announces discovery of an image into
      rbd_dev_image_probe(), generalize to support images in either format
      and only show it if an image is fully discovered.
      
      This highlights that are some unnecessary cleanups in the error
      path for rbd_dev_v1_probe(), so they can be removed.
      
      Now rbd_dev_v1_probe() *is* a trivial wrapper function.
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      30d60ba2
    • Alex Elder's avatar
      rbd: update in-core header directly · 662518b1
      Alex Elder authored
      Now that rbd_header_from_disk() only fills in one-time fields once,
      we can extend it slightly so it releases the other fields before
      replacing their values.  This way there's no need to pass a
      temporary buffer and then copy all the results in.  Just use the rbd
      device header structure in rbd_header_from_disk() so its values get
      updated directly.
      
      Note that this means we need to take the header semaphore at the
      point we update things.  So pass the rbd_dev rather than the address
      of its header as its first argument to rbd_header_from_disk(), and
      have it return an error code.
      
      As a result, rbd_dev_v1_header_read() does all the work,
      rbd_read_header() becomes unnecessary, and rbd_dev_v1_refresh()
      becomes a very simple wrapper.
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      662518b1
    • Alex Elder's avatar
      rbd: refactor rbd_header_from_disk() · bb23e37a
      Alex Elder authored
      This rearranges rbd_header_from_disk so that it:
          - allocates the snapshot context right away
          - keeps results in local variables, not changing the passed-in
            header until it's known we'll succeed
          - does initialization of set-once fields in a header only if
            they have not already been set
      
      The last point is moot at the moment, because rbd_read_header()
      (the only caller) always supplies a zero-filled header buffer.
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      bb23e37a
    • Alex Elder's avatar
      rbd: zero format 1 header structure earlier · 46578dcd
      Alex Elder authored
      The passed-in header structure is zeroed in rbd_header_from_disk().
      Instead, have the caller do it.  Note that there are two callers,
      rbd_dev_v1_refresh() and rbd_dev_v1_probe().  The latter already has
      a zeroed header structure so zeroing it isn't necessary there.
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      46578dcd
    • Alex Elder's avatar
      rbd: set the mapping size and features later · f35a4dee
      Alex Elder authored
      Defer setting the size and features fields of a mapped image until
      after the Linux disk structure is set up.  Set the capacity of the
      disk after that.
      
      Rearrange the definition of rbd_image_header, separating the fields
      that are set only once from those that can be updated.
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      f35a4dee
    • Alex Elder's avatar
      rbd: always set read-only flag in rbd_add() · 51344a38
      Alex Elder authored
      Hold off setting the read-only flag in rbd_add() for an image being
      mapped until we have successfully probed the image.  At that point
      we know whether it's a snapshot mapping or not, so we can set the
      read-only flag in that one place rather than doing so (for
      snapshots) in rbd_dev_mapping_set().  To do this, pass a flag to the
      image probe routine indicating whether we want a read-only mapping.
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      51344a38
    • Alex Elder's avatar
      rbd: kill rbd_dev_clear_mapping() · 6d80b130
      Alex Elder authored
      This function is a duplicate of rbd_dev_mapping_clear(), and was
      added by mistake.
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      6d80b130
    • Alex Elder's avatar
      rbd: don't look up snapshot id in rbd_dev_mapping_set() · 8f4b7d98
      Alex Elder authored
      Currently rbd_dev_mapping_set() looks up the snapshot id for the
      snapshot whose name is found in the rbd device's spec structure.
      
      That function gets called by rbd_dev_device_setup(), which is
      called by rbd_add() *after* rbd_dev_image_probe().  If the
      image probe succeeds, the rbd device's spec will already have
      been updated to include names and ids for all fields.
      
      Therefore there's no need to look up the snapshot id in
      rbd_dev_mapping_set().
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      8f4b7d98
    • Alex Elder's avatar
      rbd: don't print warning if not mapping a parent · c734b796
      Alex Elder authored
      The presence of the LAYERING bit in an rbd image's feature mask does
      not guarantee the image actually has a parent image.  Currently that
      bit is set only when a clone (i.e., image with a parent) is created,
      but it is (currently) not cleared if that clone gets flattened back
      into a "normal" image.  A "parent_id" query will leave the
      parent_spec for the image being mapped a null pointer, but will not
      return an error.
      
      Currently, whenever an image with the LAYERED feature gets mapped, a
      warning about the use of layered images gets printed.  But we don't
      want to do this for a flattened image, so print the warning only
      if we find there is a parent spec after the probe.
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      c734b796
    • Alex Elder's avatar
      rbd: kill rbd_update_mapping_size() · 29334ba4
      Alex Elder authored
      Since rbd_update_mapping_size() is now a trivial wrapper, just open
      code it in its two callers.
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      29334ba4
    • Alex Elder's avatar
      rbd: update capacity in rbd_dev_refresh() · 00a653e2
      Alex Elder authored
      When a mapped image changes size, we change the capacity recorded
      for the Linux disk associated with it, in rbd_update_mapping_size().
      That function is called in two places--the format 1 and format 2
      refresh routines.
      
      There is no need to set the capacity while holding the header
      semaphore.  Instead, do it in the common rbd_dev_refresh(), using
      the logic that's already there to initiate disk revalidation.
      
      Add handling in the request function, just in case a request
      that exceeds the capacity of the device comes in (perhaps one
      that was started before a refresh shrunk the device).
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      00a653e2
    • Alex Elder's avatar
      rbd: revalidate only for mapping size changes · e627db08
      Alex Elder authored
      This commit:
          d98df63e rbd: revalidate_disk upon rbd resize
      instituted a call to revalidate_disk() to notify interested parties
      that a mapped image has changed size.  This works well, as long as
      the the rbd device doesn't map a snapshot.
      
      A snapshot will never change size.  However, the base image the
      snapshot is associated with can, and it can do so while the snapshot
      is mapped.
      
      The problem is that the test for the size is looking at the size of
      the base image, not the size of the mapped snapshot.  This patch
      corrects that.
      
      Update the warning message shown in the event of error, and move
      it into the callers.
      
      This resolves:
          http://tracker.ceph.com/issues/4911Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      e627db08
    • Alex Elder's avatar
      rbd: fix leak of format 2 snapshot context · 49ece554
      Alex Elder authored
      When rbd_dev_v2_refresh() is called, the rbd device already has a
      snapshot context associated with it.  But that never gets freed,
      the pointer just gets overwritten.
      
      Fix this by dropping the rbd device's reference to the snapshot
      context before overwriting the pointer.
      
      Because ceph_put_snap_context() already handles for a null pointer
      we don't need to check for that (for the probe case, where no
      context has yet been assigned).
      
      This resolves:
          http://tracker.ceph.com/issues/4912Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      49ece554
  2. 02 May, 2013 26 commits