1. 20 6月, 2013 1 次提交
  2. 13 6月, 2013 1 次提交
    • S
      cciss: fix broken mutex usage in ioctl · 03f47e88
      Stephen M. Cameron 提交于
      If a new logical drive is added and the CCISS_REGNEWD ioctl is invoked
      (as is normal with the Array Configuration Utility) the process will
      hang as below.  It attempts to acquire the same mutex twice, once in
      do_ioctl() and once in cciss_unlocked_open().  The BKL was recursive,
      the mutex isn't.
      
        Linux version 3.10.0-rc2 (scameron@localhost.localdomain) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) ) #1 SMP Fri May 24 14:32:12 CDT 2013
        [...]
        acu             D 0000000000000001     0  3246   3191 0x00000080
        Call Trace:
          schedule+0x29/0x70
          schedule_preempt_disabled+0xe/0x10
          __mutex_lock_slowpath+0x17b/0x220
          mutex_lock+0x2b/0x50
          cciss_unlocked_open+0x2f/0x110 [cciss]
          __blkdev_get+0xd3/0x470
          blkdev_get+0x5c/0x1e0
          register_disk+0x182/0x1a0
          add_disk+0x17c/0x310
          cciss_add_disk+0x13a/0x170 [cciss]
          cciss_update_drive_info+0x39b/0x480 [cciss]
          rebuild_lun_table+0x258/0x370 [cciss]
          cciss_ioctl+0x34f/0x470 [cciss]
          do_ioctl+0x49/0x70 [cciss]
          __blkdev_driver_ioctl+0x28/0x30
          blkdev_ioctl+0x200/0x7b0
          block_ioctl+0x3c/0x40
          do_vfs_ioctl+0x89/0x350
          SyS_ioctl+0xa1/0xb0
          system_call_fastpath+0x16/0x1b
      
      This mutex usage was added into the ioctl path when the big kernel lock
      was removed.  As it turns out, these paths are all thread safe anyway
      (or can easily be made so) and we don't want ioctl() to be single
      threaded in any case.
      Signed-off-by: NStephen M. Cameron <scameron@beardog.cce.hp.com>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Mike Miller <mike.miller@hp.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      03f47e88
  3. 31 5月, 2013 1 次提交
  4. 29 5月, 2013 2 次提交
  5. 25 5月, 2013 2 次提交
  6. 24 5月, 2013 1 次提交
  7. 18 5月, 2013 2 次提交
    • A
      rbd: fix cleanup in rbd_add() · 3abef3b3
      Alex Elder 提交于
      Bjorn Helgaas pointed out that a recent commit introduced a
      use-after-free condition in an error path for rbd_add().
      He correctly stated:
      
          I think b536f69a "rbd: set up devices only for mapped images"
          introduced a use-after-free error in rbd_add():
      	...
          If rbd_dev_device_setup() returns an error, we call
          rbd_dev_image_release(), which ultimately kfrees rbd_dev.
          Then we call rbd_dev_destroy(), which references fields in
          the already-freed rbd_dev struct before kfreeing it again.
      
      The simple fix is to return the error code after the call to
      rbd_dev_image_release().
      
      Closer examination revealed that there's no need to clean up
      rbd_opts in that function, so fix that too.
      
      Update some other comments that have also become out of date.
      Reported-by: NBjorn Helgaas <bhelgaas@google.com>
      Signed-off-by: NAlex Elder <elder@inktank.com>
      Reviewed-by: NJosh Durgin <josh.durgin@inktank.com>
      3abef3b3
    • A
      rbd: don't destroy ceph_opts in rbd_add() · 7262cfca
      Alex Elder 提交于
      Whether rbd_client_create() successfully creates a new client or
      not, it takes responsibility for getting the ceph_opts structure
      it's passed destroyed.  If successful, the structure becomes
      associated with the created client; if not, rbd_client_create()
      will destroy it.
      
      Previously, rbd_get_client() would call ceph_destroy_options()
      if rbd_get_client() failed, and that meant it got called twice.
      That led freeing various pointers more than once, which is never a
      good idea.
      
      This resolves:
          http://tracker.ceph.com/issues/4559
      
      Cc: stable@vger.kernel.org # 3.8+
      Reported-by: NDan van der Ster <dan@vanderster.com>
      Signed-off-by: NAlex Elder <elder@inktank.com>
      Reviewed-by: NJosh Durgin <josh.durgin@inktank.com>
      7262cfca
  8. 17 5月, 2013 5 次提交
  9. 15 5月, 2013 2 次提交
  10. 14 5月, 2013 12 次提交
    • A
      rbd: re-submit flattened write request (part 2) · 638f5abe
      Alex Elder 提交于
      Add code to rbd_img_obj_exists_callback() to detect when a clone's
      parent image has disappeared, and re-submit the original write
      request in that case.
      
      Kill off some redundant assertions.
      
      This completes the resolution for:
          http://tracker.ceph.com/issues/3763Signed-off-by: NAlex Elder <elder@inktank.com>
      Reviewed-by: NJosh Durgin <josh.durgin@inktank.com>
      638f5abe
    • A
      rbd: re-submit write request for flattened clone · bbea1c1a
      Alex Elder 提交于
      Add code to rbd_img_parent_read_full_callback() to detect when a
      clone's parent image has disappeared, and re-submit the original
      write request in that case.  (See the previous commit for more
      reasoning about why this is appropriate.)
      
      Rename some variables in rbd_img_obj_parent_read_full_callback()
      to match the convention used in the previous patch.
      Signed-off-by: NAlex Elder <elder@inktank.com>
      Reviewed-by: NJosh Durgin <josh.durgin@inktank.com>
      bbea1c1a
    • A
      rbd: re-submit read request for flattened clone · 02c74fba
      Alex Elder 提交于
      If a clone image gets flattened while a parent read request is
      underway, the original rbd object request needs to be resubmitted.
      
      The reason is that by the time we get the response to the parent
      read request, the data read from the parent may be out of date.
      In other words, we could see this sequence of events:
      
          rbd client                      parent image/osd
          ----------                      ----------------
          original object ENOENT;
              issue parent read
                                          respond to parent read
                                          child image flattened
          original image header refresh
                   <--- original object written independently here
          parent read response received
      
      Add code to rbd_img_parent_read_callback() to detect when a clone's
      parent image has disappeared (as evidenced by its parent overlap
      becoming 0), and re-submit the original read request in that case.
      Signed-off-by: NAlex Elder <elder@inktank.com>
      Reviewed-by: NJosh Durgin <josh.durgin@inktank.com>
      02c74fba
    • A
      rbd: detect when clone image is flattened · 392a9dad
      Alex Elder 提交于
      A format 2 clone image can be the subject of a "flatten" operation,
      during which all of its data gets "copied up" from its parent image,
      leaving the image fully populated.  Once this is complete, the
      clone's association with the parent is abolished.
      
      Since this can occur when a clone is mapped, we need to detect when
      it has occurred and handle it accordingly.  We know an image has
      been flattened when we know it at one time had a parent, but we have
      learned (via a "get_parent" object class method call) it no longer
      has one.
      
      There might be in-flight requests at the point we learn an image has
      been flattened, so we can't simply clean up parent data structures
      right away.  Instead, we'll drop the initial parent reference when
      the parent has disappeared (rather than when the image gets
      destroyed), which will allow the last in-flight reference to clean
      things up when it's complete.
      
      We leverage the fact that a zero parent overlap renders an image
      effectively unlayered.  We set the overlap to 0 at the point we
      detect the clone image has flattened, which allows the unlayered
      behavior to take effect immediately, while keeping other parent
      structures in place until in-flight requests to complete.
      
      This and the next few patches resolve:
          http://tracker.ceph.com/issues/3763Signed-off-by: NAlex Elder <elder@inktank.com>
      Reviewed-by: NJosh Durgin <josh.durgin@inktank.com>
      392a9dad
    • A
      rbd: reference count parent requests · a2acd00e
      Alex Elder 提交于
      Keep a reference count for uses of the parent information for an rbd
      device.
      
      An initial reference is set in rbd_img_request_create() if the
      target image has a parent (with non-zero overlap).  Each image
      request for an image with a non-zero parent overlap gets another
      reference when it's created, and that reference is dropped when the
      request is destroyed.
      
      The initial reference is dropped when the image gets torn down.
      Signed-off-by: NAlex Elder <elder@inktank.com>
      Reviewed-by: NJosh Durgin <josh.durgin@inktank.com>
      a2acd00e
    • A
      rbd: define parent image request routines · e93f3152
      Alex Elder 提交于
      Define rbd_parent_request_create() and rbd_parent_request_destroy()
      to handle the creation of parent image requests submitted for
      layered image objects.  For simplicity, let rbd_img_request_put()
      handle dropping the reference to any image request (parent or not),
      and call whichever destructor is appropriate on the last put.
      Signed-off-by: NAlex Elder <elder@inktank.com>
      Reviewed-by: NJosh Durgin <josh.durgin@inktank.com>
      e93f3152
    • A
      rbd: define rbd_dev_unparent() · fb65d228
      Alex Elder 提交于
      Define rbd_dev_unparent() to encapsulate cleaning up parent data
      structures from a layered rbd image.
      Signed-off-by: NAlex Elder <elder@inktank.com>
      Reviewed-by: NJosh Durgin <josh.durgin@inktank.com>
      fb65d228
    • A
      rbd: don't release write request until necessary · 8785b1d4
      Alex Elder 提交于
      Previously when a layered write was going to involve a copyup
      request, the original osd request was released before submitting the
      parent full-object read.  The osd request for the copyup would then
      be allocated in rbd_img_obj_parent_read_full_callback().
      
      Shortly we will be handling the event of mapped layered images
      getting flattened, and when that occurs we need to resubmit the
      original request.  We therefore don't want to release the osd
      request until we really konw we're going to replace it--in the
      callback function.
      Signed-off-by: NAlex Elder <elder@inktank.com>
      Reviewed-by: NJosh Durgin <josh.durgin@inktank.com>
      8785b1d4
    • A
      rbd: get parent info on refresh · 642a2537
      Alex Elder 提交于
      Get parent info for format 2 images on every refresh (rather than
      just during the initial probe).  This will be needed to detect the
      disappearance of the parent image in the event a mapped image
      becomes unlayered (i.e., flattened).  Avoid leaking the previous
      parent spec on the second and subsequent times this information is
      requested by dropping the previous one (if any) before updating it.
      (Also, extract the pool id into a local variable before assigning
      it into the parent spec.)
      
      Switch to using a non-zero parent overlap value rather than the
      existence of a parent (a non-null parent_spec pointer) to determine
      whether to mark a request layered.  It will soon be possible for
      a layered image to become unlayered while a request is in flight.
      
      This means that the layered flag for an image request indicates that
      there was a non-zero parent overlap at the time the image request
      was created.  The parent overlap can change thereafter, which may
      lead to special handling at request submission or completion time.
      
      This and the next several patches are related to:
          http://tracker.ceph.com/issues/3763
      
      NOTE:
      If an error occurs while refreshing the parent info (i.e.,
      requesting it after initial probe), the old parent info will
      persist.  This is not really correct, and is a scenario that needs
      to be addressed.  For now we'll assert that the failure mode is
      unlikely, but the issue has been documented in tracker issue 5040.
      Signed-off-by: NAlex Elder <elder@inktank.com>
      Reviewed-by: NJosh Durgin <josh.durgin@inktank.com>
      642a2537
    • A
      rbd: ignore zero-overlap parent · 70cf49cf
      Alex Elder 提交于
      An rbd clone image that has an overlap with its parent of 0 is
      effectively not a layered image at all.  Detect this case and treat
      such an image as non-layered.  Issue a warning to be sure the user
      knows what's going on.
      
      This resolves:
          http://tracker.ceph.com/issues/5028Signed-off-by: NAlex Elder <elder@inktank.com>
      Reviewed-by: NJosh Durgin <josh.durgin@inktank.com>
      70cf49cf
    • A
      rbd: support reading parent page data for writes · b91f09f1
      Alex Elder 提交于
      Currently, rbd_img_obj_parent_read_full() assumes the incoming
      object request contains bio data.  But if a layered image is part of
      a multi-layer stack of images it will result in read requests of
      page data to parent images.
      
      This is handling the same kind of issue as was resolved by this
      commit:
          5b2ab72d  rbd: support reading parent page data
      
      This resolves:
          http://tracker.ceph.com/issues/5027Signed-off-by: NAlex Elder <elder@inktank.com>
      Reviewed-by: NJosh Durgin <josh.durgin@inktank.com>
      b91f09f1
    • A
      rbd: fix parent request size assumption · ebda6408
      Alex Elder 提交于
      The code that reads object data from the parent for a copyup on
      write request currently assumes that the size of that request is the
      size of a "full" object from the original target image.
      
      That is not necessarily the case.  The parent overlap could reduce
      the request size below that.  To fix that assumption we need to
      record the number of pages in the copyup_pages array, for both an
      image request and an object request.  Rename a local variable in
      rbd_img_obj_parent_read_full_callback() to reflect we're recording
      the length of the parent read request, not the size of the target
      object.
      
      This resolves:
          http://tracker.ceph.com/issues/5038Signed-off-by: NAlex Elder <elder@inktank.com>
      Reviewed-by: NJosh Durgin <josh.durgin@inktank.com>
      ebda6408
  11. 10 5月, 2013 1 次提交
  12. 09 5月, 2013 10 次提交
    • A
      rbd: kill rbd_img_request_get() · c48f3f86
      Alex Elder 提交于
      Get rid of rbd_img_request_get(), because it isn't used, and maybe
      won't ever be needed.
      Signed-off-by: NAlex Elder <elder@inktank.com>
      Reviewed-by: NJosh Durgin <josh.durgin@inktank.com>
      c48f3f86
    • A
      rbd: only set up watch for mapped images · 1f3ef788
      Alex Elder 提交于
      Any changes to parent images are immaterial to any mapped clone.
      So there is no need to have a watch event registered on header
      objects except for the header object of an image that is mapped.
      In fact, a watch request is a write operation, and we may only
      have read access to a parent image.
      
      We can't set up the watch request until we know the name of the
      header object though.  So pass a flag to rbd_dev_image_probe() to
      indicate whether this probe is for a mapping or for a parent image.
      
      Change the second parameter to rbd_dev_header_watch_sync() be
      Boolean while we're at it.
      
      This resolves:
          http://tracker.ceph.com/issues/4941Signed-off-by: NAlex Elder <elder@inktank.com>
      Reviewed-by: NJosh Durgin <josh.durgin@inktank.com>
      1f3ef788
    • A
      rbd: set mapping read-only flag in rbd_add() · 7ce4eef7
      Alex Elder 提交于
      The rbd_dev->mapping field for a parent image is not meaningful.
      Since rbd_image_probe() is used both for images being mapped and
      their parents, it doesn't make sense to set that flag in that
      function.
      
      So move the setting of the mapping.read_only flag out of
      rbd_dev_image_probe() and into rbd_add() instead.
      
      This resolves:
          http://tracker.ceph.com/issues/4940Signed-off-by: NAlex Elder <elder@inktank.com>
      Reviewed-by: NJosh Durgin <josh.durgin@inktank.com>
      7ce4eef7
    • A
      rbd: support reading parent page data · 5b2ab72d
      Alex Elder 提交于
      Currently, rbd_img_parent_read() assumes the incoming object request
      contains bio data.  But if a layered image is part of a multi-layer
      stack of images it will result in read requests of page data to parent
      images.
      
      Fortunately, it's not hard to add support for page data.
      
      This resolves:
          http://tracker.ceph.com/issues/4939Signed-off-by: NAlex Elder <elder@inktank.com>
      Reviewed-by: NJosh Durgin <josh.durgin@inktank.com>
      5b2ab72d
    • A
      rbd: fix an incorrect assertion condition · 91c6febb
      Alex Elder 提交于
      In rbd_img_obj_parent_read_full_callback() there is an assertion
      intended to verify the size of the image request for a full parent
      read was the size of the original request's target object.  But
      assertion was looking at the parent image order rather than the
      original one, and these values can differ.
      
      Fix that.
      
      This resolves:
          http://tracker.ceph.com/issues/4938Signed-off-by: NAlex Elder <elder@inktank.com>
      Reviewed-by: NJosh Durgin <josh.durgin@inktank.com>
      91c6febb
    • A
      rbd: define rbd_dev_v2_header_info() · 2df3fac7
      Alex Elder 提交于
      This rearranges rbd_dev_v2_refresh() so it works more like
      rbd_dev_v1_header_info().  While format 1 images need to read the
      whole header object to get any information, format 2 can collect
      almost all information selectively.  So the one-time initialization
      will remain in a separate function--based on rbd_dev_v2_probe().
      
      Rename rbd_dev_v2_refresh() to be rbd_dev_v2_header_info(), and have
      it call rbd_dev_v2_header_onetime() if it's being called for the
      first time for the given rbd device.
      
      Rename rbd_dev_v2_probe() to be rbd_dev_v2_header_onetime() and
      remove the image size and snapshot context calls it held in
      common with the refresh function.
      Signed-off-by: NAlex Elder <elder@inktank.com>
      Reviewed-by: NJosh Durgin <josh.durgin@inktank.com>
      2df3fac7
    • A
      rbd: get rid of trivial v1 header wrappers · 99a41ebc
      Alex Elder 提交于
      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: NAlex Elder <elder@inktank.com>
      Reviewed-by: NJosh Durgin <josh.durgin@inktank.com>
      99a41ebc
    • A
      rbd: simplify rbd_dev_v1_probe() · 30d60ba2
      Alex Elder 提交于
      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: NAlex Elder <elder@inktank.com>
      Reviewed-by: NJosh Durgin <josh.durgin@inktank.com>
      30d60ba2
    • A
      rbd: update in-core header directly · 662518b1
      Alex Elder 提交于
      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: NAlex Elder <elder@inktank.com>
      Reviewed-by: NJosh Durgin <josh.durgin@inktank.com>
      662518b1
    • A
      rbd: refactor rbd_header_from_disk() · bb23e37a
      Alex Elder 提交于
      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: NAlex Elder <elder@inktank.com>
      Reviewed-by: NJosh Durgin <josh.durgin@inktank.com>
      bb23e37a