1. 02 May, 2013 40 commits
    • Alex Elder's avatar
      rbd: implement full object parent reads · 3d7efd18
      Alex Elder authored
      As a step toward implementing layered writes, implement reading the
      data for a target object from the parent image for a write request
      whose target object is known to not exist.  Add a copyup_pages field
      to an image request to track the page array used (only) for such a
      request.
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      3d7efd18
    • Laurent Barbe's avatar
      rbd: revalidate_disk upon rbd resize · d98df63e
      Laurent Barbe authored
      If rbd disk is open and rbd resize is done, new size is not
      visible by filesystem.  Like is done in virtio-blk and dm driver,
      revalidate_disk() permits to update the bd_inode size.
      Signed-off-by: default avatarLaurent Barbe <laurent@ksperis.com>
      Reviewed-by: default avatarAlex Elder <elder@inktank.com>
      d98df63e
    • Alex Elder's avatar
      rbd: support page array image requests · f1a4739f
      Alex Elder authored
      This patch adds the ability to build an image request whose data
      will be written from or read into memory described by a page array.
      (Previously only bio lists were supported.)
      
      Originally this was going to define a new function for this purpose
      but it was largely identical to the rbd_img_request_fill_bio().  So
      instead, rbd_img_request_fill_bio() has been generalized to handle
      both types of image request.
      
      For the moment we still only fill image requests with bio data.
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      f1a4739f
    • Alex Elder's avatar
      rbd: define zero_pages() · b9434c5b
      Alex Elder authored
      Define a new function zero_pages() that zeroes a range of memory
      defined by a page array, along the lines of zero_bio_chain().  It
      saves and the irq flags like bvec_kmap_irq() does, though I'm not
      sure at this point that it's necessary.
      
      Update rbd_img_obj_request_read_callback() to use the new function
      if the object request contains page rather than bio data.
      
      For the moment, only bio data is used for osd READ ops.
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      b9434c5b
    • Alex Elder's avatar
      rbd: encapsulate submission of image object requests · b454e36d
      Alex Elder authored
      Object requests that are part of an image request are subject to
      some additional handling.  Define rbd_img_obj_request_submit() to
      encapsulate that, and use it when initially submitting an image
      object request, and when re-submitting it during callback of
      an object existence check.
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      b454e36d
    • Alex Elder's avatar
      rbd: define separate read and write format funcs · 9d4df01f
      Alex Elder authored
      Separate rbd_osd_req_format() into two functions, one for read
      requests and the other for write requests.
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      9d4df01f
    • Alex Elder's avatar
      libceph: support pages for class request data · 6c57b554
      Alex Elder authored
      Add the ability to provide an array of pages as outbound request
      data for object class method calls.
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      6c57b554
    • Alex Elder's avatar
      libceph: fix two messenger bugs · a51b272e
      Alex Elder authored
      This patch makes four small changes in the ceph messenger.
      
      While getting copyup functionality working I found two bugs in the
      messenger.  Existing paths through the code did not trigger these
      problems, but they're fixed here:
          - In ceph_msg_data_pagelist_cursor_init(), the cursor's
            last_piece field was being checked against the length
            supplied.  This was OK until this commit: ccba6d98 libceph:
            implement multiple data items in a message That commit changed
            the cursor init routines to allow lengths to be supplied that
            exceeded the size of the current data item. Because of this,
            we have to use the assigned cursor resid field rather than the
            provided length in determining whether the cursor points to
            the last piece of a data item.
          - In ceph_msg_data_add_pages(), a BUG_ON() was erroneously
            catching attempts to add page data to a message if the message
            already had data assigned to it. That was OK until that same
            commit, at which point it was fine for messages to have
            multiple data items. It slipped through because that BUG_ON()
            call was present twice in that function. (You can never be too
            careful.)
      
      In addition two other minor things are changed:
          - In ceph_msg_data_cursor_init(), the local variable "data" was
            getting assigned twice.
          - In ceph_msg_data_advance(), it was assumed that the
            type-specific advance routine would set new_piece to true
            after it advanced past the last piece. That may have been
            fine, but since we check for that case we might as well set it
            explicitly in ceph_msg_data_advance().
      
      This resolves:
          http://tracker.ceph.com/issues/4762Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      a51b272e
    • Alex Elder's avatar
      rbd: issue stat request before layered write · c5b5ef6c
      Alex Elder authored
      This is a step toward fully implementing layered writes.
      
      Add checks before request submission for the object(s) associated
      with an image request.  For write requests, if we don't know that
      the target object exists, issue a STAT request to find out.  When
      that request completes, mark the known and exists flags for the
      original object request accordingly and re-submit the object
      request.  (Note that this still does the existence check only; the
      copyup operation is not yet done.)
      
      A new object request is created to perform the existence check.  A
      pointer to the original request is added to that object request to
      allow the stat request to re-issue the original request after
      updating its flags.  If there is a failure with the stat request
      the error code is stored with the original request, which is then
      completed.
      
      This resolves:
          http://tracker.ceph.com/issues/3418Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      c5b5ef6c
    • Alex Elder's avatar
      rbd: add target object existence flags · 5679c59f
      Alex Elder authored
      This creates two new flags for object requests to indicate what is
      known about the existence of the object to which a request is to be
      sent.  The KNOWN flag will be true if the the EXISTS flag is
      meaningful.  That is:
      
          KNOWN   EXISTS
          -----   ------
            0       0     don't know whether the object exists
            0       1     (not used/invalid)
            1       0     object is known to not exist
            1       0     object is known to exist
      
      This will be used in determining how to handle write requests for
      data objects for layered rbd images.
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      5679c59f
    • Alex Elder's avatar
      rbd: always check IMG_DATA flag · 57acbaa7
      Alex Elder authored
      In a few spots, whether the an object request's img_request pointer
      is null is used to determine whether an object request is being done
      as part of an image data request.
      
      Stop doing that, and instead always use the object request IMG_DATA
      flag for that purpose.  Swap the order of the definition of the
      IMG_DATA and DONE flag helpers, because obj_request_done_set() now
      refers to obj_request_img_data_set() to get its rbd_dev value.
      
      This will become important because the img_request pointer is
      about to become part of a union.
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      57acbaa7
    • Alex Elder's avatar
      rbd: adjust image object request ref counting · b155e86c
      Alex Elder authored
      An extra reference is taken when an object request is added as one
      of the requests making up an image object.  A reference is dropped
      again when the image's object requests get submitted.
      
      The original reference for the object request will remain throughout
      this period, so we don't need to add and then take away an extra
      one.
      
      This can be interpreted as the image request inheriting the original
      object request's reference.
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      b155e86c
    • Alex Elder's avatar
      libceph: support raw data requests · 49719778
      Alex Elder authored
      Allow osd request ops that aren't otherwise structured (not class,
      extent, or watch ops) to specify "raw" data to be used to hold
      incoming data for the op.  Make use of this capability for the osd
      STAT op.
      
      Prefix the name of the private function osd_req_op_init() with "_",
      and expose a new function by that (earlier) name whose purpose is to
      initialize osd ops with (only) implied data.
      
      For now we'll just support the use of a page array for an osd op
      with incoming raw data.
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      49719778
    • Alex Elder's avatar
      libceph: clean up osd data field access functions · 863c7eb5
      Alex Elder authored
      There are a bunch of functions defined to encapsulate getting the
      address of a data field for a particular op in an osd request.
      They're all defined the same way, so create a macro to take the
      place of all of them.
      
      Two of these are used outside the osd client code, so preserve them
      (but convert them to use the new macro internally).  Stop exporting
      the ones that aren't used elsewhere.
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      863c7eb5
    • Alex Elder's avatar
      libceph: kill off osd data write_request parameters · 406e2c9f
      Alex Elder authored
      In the incremental move toward supporting distinct data items in an
      osd request some of the functions had "write_request" parameters to
      indicate, basically, whether the data belonged to in_data or the
      out_data.  Now that we maintain the data fields in the op structure
      there is no need to indicate the direction, so get rid of the
      "write_request" parameters.
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      406e2c9f
    • Randy Dunlap's avatar
      ceph: fix printk format warnings in file.c · ac7f29bf
      Randy Dunlap authored
      Fix printk format warnings by using %zd for 'ssize_t' variables:
      
      fs/ceph/file.c:751:2: warning: format '%ld' expects argument of type 'long int', but argument 11 has type 'ssize_t' [-Wformat]
      fs/ceph/file.c:762:2: warning: format '%ld' expects argument of type 'long int', but argument 11 has type 'ssize_t' [-Wformat]
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Cc:	ceph-devel@vger.kernel.org
      Signed-off-by: default avatarSage Weil <sage@inktank.com>
      ac7f29bf
    • Yan, Zheng's avatar
      ceph: fix race between writepages and truncate · 1ac0fc8a
      Yan, Zheng authored
      ceph_writepages_start() reads inode->i_size in two places. It can get
      different values between successive read, because truncate can change
      inode->i_size at any time. The race can lead to mismatch between data
      length of osd request and pages marked as writeback. When osd request
      finishes, it clear writeback page according to its data length. So
      some pages can be left in writeback state forever. The fix is only
      read inode->i_size once, save its value to a local variable and use
      the local variable when i_size is needed.
      Signed-off-by: default avatarYan, Zheng <zheng.z.yan@intel.com>
      Reviewed-by: default avatarAlex Elder <elder@inktank.com>
      1ac0fc8a
    • Yan, Zheng's avatar
      ceph: apply write checks in ceph_aio_write · 03d254ed
      Yan, Zheng authored
      copy write checks in __generic_file_aio_write to ceph_aio_write.
      To make these checks cover sync write path.
      Signed-off-by: default avatarYan, Zheng <zheng.z.yan@intel.com>
      Reviewed-by: default avatarAlex Elder <elder@inktank.com>
      03d254ed
    • Yan, Zheng's avatar
      ceph: take i_mutex before getting Fw cap · 37505d57
      Yan, Zheng authored
      There is deadlock as illustrated bellow. The fix is taking i_mutex
      before getting Fw cap reference.
      
            write                    truncate                 MDS
      ---------------------     --------------------      --------------
      get Fw cap
                                lock i_mutex
      lock i_mutex (blocked)
                                request setattr.size  ->
                                                      <-   revoke Fw cap
      Signed-off-by: default avatarYan, Zheng <zheng.z.yan@intel.com>
      Reviewed-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarSage Weil <sage@inktank.com>
      37505d57
    • Alex Elder's avatar
      libceph: change how "safe" callback is used · 26be8808
      Alex Elder authored
      An osd request currently has two callbacks.  They inform the
      initiator of the request when we've received confirmation for the
      target osd that a request was received, and when the osd indicates
      all changes described by the request are durable.
      
      The only time the second callback is used is in the ceph file system
      for a synchronous write.  There's a race that makes some handling of
      this case unsafe.  This patch addresses this problem.  The error
      handling for this callback is also kind of gross, and this patch
      changes that as well.
      
      In ceph_sync_write(), if a safe callback is requested we want to add
      the request on the ceph inode's unsafe items list.  Because items on
      this list must have their tid set (by ceph_osd_start_request()), the
      request added *after* the call to that function returns.  The
      problem with this is that there's a race between starting the
      request and adding it to the unsafe items list; the request may
      already be complete before ceph_sync_write() even begins to put it
      on the list.
      
      To address this, we change the way the "safe" callback is used.
      Rather than just calling it when the request is "safe", we use it to
      notify the initiator the bounds (start and end) of the period during
      which the request is *unsafe*.  So the initiator gets notified just
      before the request gets sent to the osd (when it is "unsafe"), and
      again when it's known the results are durable (it's no longer
      unsafe).  The first call will get made in __send_request(), just
      before the request message gets sent to the messenger for the first
      time.  That function is only called by __send_queued(), which is
      always called with the osd client's request mutex held.
      
      We then have this callback function insert the request on the ceph
      inode's unsafe list when we're told the request is unsafe.  This
      will avoid the race because this call will be made under protection
      of the osd client's request mutex.  It also nicely groups the setup
      and cleanup of the state associated with managing unsafe requests.
      
      The name of the "safe" callback field is changed to "unsafe" to
      better reflect its new purpose.  It has a Boolean "unsafe" parameter
      to indicate whether the request is becoming unsafe or is now safe.
      Because the "msg" parameter wasn't used, we drop that.
      
      This resolves the original problem reportedin:
          http://tracker.ceph.com/issues/4706Reported-by: default avatarYan, Zheng <zheng.z.yan@intel.com>
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarYan, Zheng <zheng.z.yan@intel.com>
      Reviewed-by: default avatarSage Weil <sage@inktank.com>
      26be8808
    • Alex Elder's avatar
      ceph: let osd client clean up for interrupted request · 7d7d51ce
      Alex Elder authored
      In ceph_sync_write(), if a safe callback is supplied with a request,
      and an error is returned by ceph_osdc_wait_request(), a block of
      code is executed to remove the request from the unsafe writes list
      and drop references to capabilities acquired just prior to a call to
      ceph_osdc_wait_request().
      
      The only function used for this callback is sync_write_commit(),
      and it does *exactly* what that block of error handling code does.
      
      Now in ceph_osdc_wait_request(), if an error occurs (due to an
      interupt during a wait_for_completion_interruptible() call),
      complete_request() gets called, and that calls the request's
      safe_callback method if it's defined.
      
      So this means that this cleanup activity gets called twice in this
      case, which is erroneous (and in fact leads to a crash).
      
      Fix this by just letting the osd client handle the cleanup in
      the event of an interrupt.
      
      This resolves one problem mentioned in:
          http://tracker.ceph.com/issues/4706Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarYan, Zheng <zheng.z.yan@intel.com>
      7d7d51ce
    • Yan, Zheng's avatar
      ceph: fix symlink inode operations · 0b932672
      Yan, Zheng authored
      add getattr/setattr and xattrs related methods.
      Signed-off-by: default avatarYan, Zheng <zheng.z.yan@intel.com>
      Reviewed-by: default avatarGreg Farnum <greg@inktank.com>
      0b932672
    • Sam Lang's avatar
      ceph: Use pseudo-random numbers to choose mds · a84cd293
      Sam Lang authored
      We don't need to use up entropy to choose an mds,
      so use prandom_u32() to get a pseudo-random number.
      
      Also, we don't need to choose a random mds if only
      one mds is available, so add special casing for the
      common case.
      
      Fixes http://tracker.ceph.com/issues/3579Signed-off-by: default avatarSam Lang <sam.lang@inktank.com>
      Reviewed-by: default avatarGreg Farnum <greg@inktank.com>
      Reviewed-by: default avatarAlex Elder <elder@inktank.com>
      a84cd293
    • Alex Elder's avatar
      rbd: implement layered reads · 8b3e1a56
      Alex Elder authored
      Implement layered read requests for format 2 rbd images.
      
      If an rbd image is a clone of a snapshot, the snapshot will be the
      clone's "parent" image.  When an object read request on a clone
      comes back with ENOENT it indicates that the clone is not yet
      populated with that portion of the image's data, and the parent
      image should be consulted to satisfy the read.
      
      When this occurs, a new image request is created, directed to the
      parent image.  The offset and length of the image are the same as
      the image-relative offset and length of the object request that
      produced ENOENT.  Data from the parent image therefore satisfies the
      object read request for the original image request.
      
      While this code works, it will not be active until we enable the
      layering feature (by adding RBD_FEATURE_LAYERING to the value of
      RBD_FEATURES_SUPPORTED).
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      8b3e1a56
    • Alex Elder's avatar
      rbd: probe the parent of an image if present · 2f82ee54
      Alex Elder authored
      Call the probe function for the parent device if one is present.
      Since we don't formally support the layering feature we won't
      be using this functionality just yet.
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      2f82ee54
    • Alex Elder's avatar
      rbd: add an object request flag for image data objects · 6365d33a
      Alex Elder authored
      Add a flag to distinguish between object requests being done on
      standalone objects and requests being sent for objects representing
      rbd image data (i.e., object requests that are the result of image
      request).
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      6365d33a
    • Alex Elder's avatar
      rbd: define an rbd object request flags field · 926f9b3f
      Alex Elder authored
      We're going to need some more Boolean values for object requests,
      so create a flags bit field and use it to record whether the request
      is done.
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      926f9b3f
    • Alex Elder's avatar
      rbd: encapsulate image object end request handling · 1217857f
      Alex Elder authored
      Encapsulate the code that completes processing of an object request
      that's part of an image request.
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      1217857f
    • Alex Elder's avatar
      rbd: define image request layered flag · d0b2e944
      Alex Elder authored
      Define a flag indicating whether an image request is for a layered
      image (one with a parent image to which requests will be redirected
      if the target object of a request does not exist).  The code that
      checks this flag will be added shortly.
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      d0b2e944
    • Alex Elder's avatar
      rbd: define image request originator flag · 9849e986
      Alex Elder authored
      Define a flag indicating whether an image request originated from
      the Linux block layer (from blk_fetch_request()) or whether it was
      initiated in order to satisfy an object request for a child image
      of a layered rbd device.  For image requests initiated by objects of
      child images we'll save a pointer to the object request rather than
      the Linux block request.
      
      For now, only block requests are used.
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      9849e986
    • Alex Elder's avatar
      rbd: define image request flags · 0c425248
      Alex Elder authored
      There are several Boolean values we'll be maintaining for image
      requests.  Switch from the single write_request field to a
      general-purpose flags field, and use one if its bits to represent
      the direction of I/O for the image request.  Define helper functions
      for setting and testing that flag.
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      0c425248
    • Alex Elder's avatar
      rbd: record image-relative offset in object requests · 7da22d29
      Alex Elder authored
      For an image object request we will need to know what offset within
      the rbd image the request covers.  Record that when the object
      request gets created.
      
      Update the I/O error warnings so they use this so what's reported
      is more informative.
      
      Rename a local variable to fit the convention used everywhere else.
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      7da22d29
    • Alex Elder's avatar
      rbd: record aggregate image transfer count · 55f27e09
      Alex Elder authored
      Compute the total number of bytes transferred for an image
      request--the sum across each of the request's object requests.
      To avoid contention do it only when all object requests are
      complete, in rbd_img_request_complete().
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      55f27e09
    • Alex Elder's avatar
      rbd: record overall image request result · a5a337d4
      Alex Elder authored
      If any image object request produces a non-zero result, preserve
      that as the result of the overall image request.  If multiple
      objects have non-zero results, save only the first one.
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      a5a337d4
    • Alex Elder's avatar
      rbd: update feature bits · 5cbf6f12
      Alex Elder authored
      There is a new rbd feature bit defined for "fancy striping." Add
      it to the ones defined in the kernel client.
      
      Change RBD_FEATURES_ALL so it represents the set of all feature
      bits (rather than just the ones we support).  Define a new symbol
      RBD_FEATURES_SUPPORTED to indicate the supported ones.
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      5cbf6f12
    • Alex Elder's avatar
      libceph: make method call data be a separate data item · 04017e29
      Alex Elder authored
      Right now the data for a method call is specified via a pointer and
      length, and it's copied--along with the class and method name--into
      a pagelist data item to be sent to the osd.  Instead, encode the
      data in a data item separate from the class and method names.
      
      This will allow large amounts of data to be supplied to methods
      without copying.  Only rbd uses the class functionality right now,
      and when it really needs this it will probably need to use a page
      array rather than a page list.  But this simple implementation
      demonstrates the functionality on the osd client, and that's enough
      for now.
      
      This resolves:
          http://tracker.ceph.com/issues/4104Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      04017e29
    • Alex Elder's avatar
      libceph: add, don't set data for a message · 90af3602
      Alex Elder authored
      Change the names of the functions that put data on a pagelist to
      reflect that we're adding to whatever's already there rather than
      just setting it to the one thing.  Currently only one data item is
      ever added to a message, but that's about to change.
      
      This resolves:
          http://tracker.ceph.com/issues/2770Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      90af3602
    • Alex Elder's avatar
      libceph: implement multiple data items in a message · ca8b3a69
      Alex Elder authored
      This patch adds support to the messenger for more than one data item
      in its data list.
      
      A message data cursor has two more fields to support this:
          - a count of the number of bytes left to be consumed across
            all data items in the list, "total_resid"
          - a pointer to the head of the list (for validation only)
      
      The cursor initialization routine has been split into two parts: the
      outer one, which initializes the cursor for traversing the entire
      list of data items; and the inner one, which initializes the cursor
      to start processing a single data item.
      
      When a message cursor is first initialized, the outer initialization
      routine sets total_resid to the length provided.  The data pointer
      is initialized to the first data item on the list.  From there, the
      inner initialization routine finishes by setting up to process the
      data item the cursor points to.
      
      Advancing the cursor consumes bytes in total_resid.  If the resid
      field reaches zero, it means the current data item is fully
      consumed.  If total_resid indicates there is more data, the cursor
      is advanced to point to the next data item, and then the inner
      initialization routine prepares for using that.  (A check is made at
      this point to make sure we don't wrap around the front of the list.)
      
      The type-specific init routines are modified so they can be given a
      length that's larger than what the data item can support.  The resid
      field is initialized to the smaller of the provided length and the
      length of the entire data item.
      
      When total_resid reaches zero, we're done.
      
      This resolves:
          http://tracker.ceph.com/issues/3761Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      ca8b3a69
    • Alex Elder's avatar
      libceph: replace message data pointer with list · 5240d9f9
      Alex Elder authored
      In place of the message data pointer, use a list head which links
      through message data items.  For now we only support a single entry
      on that list.
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      5240d9f9
    • Alex Elder's avatar
      libceph: have cursor point to data · 8ae4f4f5
      Alex Elder authored
      Rather than having a ceph message data item point to the cursor it's
      associated with, have the cursor point to a data item.  This will
      allow a message cursor to be used for more than one data item.
      Signed-off-by: default avatarAlex Elder <elder@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      8ae4f4f5