1. 08 May, 2013 8 commits
    • 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 32 commits