1. 28 6月, 2008 5 次提交
    • D
      md: replace R5_WantPrexor with R5_WantDrain, add 'prexor' reconstruct_states · d8ee0728
      Dan Williams 提交于
      From: Dan Williams <dan.j.williams@intel.com>
      
      Currently ops_run_biodrain and other locations have extra logic to determine
      which blocks are processed in the prexor and non-prexor cases.  This can be
      eliminated if handle_write_operations5 flags the blocks to be processed in all
      cases via R5_Wantdrain.  The presence of the prexor operation is tracked in
      sh->reconstruct_state.
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Signed-off-by: NNeil Brown <neilb@suse.de>
      d8ee0728
    • D
      md: replace STRIPE_OP_{BIODRAIN,PREXOR,POSTXOR} with 'reconstruct_states' · 600aa109
      Dan Williams 提交于
      From: Dan Williams <dan.j.williams@intel.com>
      
      Track the state of reconstruct operations (recalculating the parity block
      usually due to incoming writes, or as part of array expansion)  Reduces the
      scope of the STRIPE_OP_{BIODRAIN,PREXOR,POSTXOR} flags to only tracking whether
      a reconstruct operation has been requested via the ops_request field of struct
      stripe_head_state.
      
      This is the final step in the removal of ops.{pending,ack,complete,count}, i.e.
      the STRIPE_OP_{BIODRAIN,PREXOR,POSTXOR} flags only request an operation and do
      not track the state of the operation.
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Signed-off-by: NNeil Brown <neilb@suse.de>
      600aa109
    • D
      md: replace STRIPE_OP_CHECK with 'check_states' · ecc65c9b
      Dan Williams 提交于
      From: Dan Williams <dan.j.williams@intel.com>
      
      The STRIPE_OP_* flags record the state of stripe operations which are
      performed outside the stripe lock.  Their use in indicating which
      operations need to be run is straightforward; however, interpolating what
      the next state of the stripe should be based on a given combination of
      these flags is not straightforward, and has led to bugs.  An easier to read
      implementation with minimal degrees of freedom is needed.
      
      Towards this goal, this patch introduces explicit states to replace what was
      previously interpolated from the STRIPE_OP_* flags.  For now this only converts
      the handle_parity_checks5 path, removing a user of the
      ops.{pending,ack,complete,count} fields of struct stripe_operations.
      
      This conversion also found a remaining issue with the current code.  There is
      a small window for a drive to fail between when we schedule a repair and when
      the parity calculation for that repair completes.  When this happens we will
      writeback to 'failed_num' when we really want to write back to 'pd_idx'.
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Signed-off-by: NNeil Brown <neilb@suse.de>
      ecc65c9b
    • D
      md: kill STRIPE_OP_IO flag · 2b7497f0
      Dan Williams 提交于
      From: Dan Williams <dan.j.williams@intel.com>
      
      The R5_Want{Read,Write} flags already gate i/o.  So, this flag is
      superfluous and we can unconditionally call ops_run_io().
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Signed-off-by: NNeil Brown <neilb@suse.de>
      2b7497f0
    • D
      md: kill STRIPE_OP_MOD_DMA in raid5 offload · b203886e
      Dan Williams 提交于
      From: Dan Williams <dan.j.williams@intel.com>
      
      This micro-optimization allowed the raid code to skip a re-read of the
      parity block after checking parity.  It took advantage of the fact that
      xor-offload-engines have their own internal result buffer and can check
      parity without writing to memory.  Remove it for the following reasons:
      
      1/ It is a layering violation for MD to need to manage the DMA and
         non-DMA paths within async_xor_zero_sum
      2/ Bad precedent to toggle the 'ops' flags outside the lock
      3/ Hard to realize a performance gain as reads will not need an updated
         parity block and writes will dirty it anyways.
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Signed-off-by: NNeil Brown <neilb@suse.de>
      b203886e
  2. 28 4月, 2008 1 次提交
    • D
      md: introduce get_priority_stripe() to improve raid456 write performance · 8b3e6cdc
      Dan Williams 提交于
      Improve write performance by preventing the delayed_list from dumping all its
      stripes onto the handle_list in one shot.  Delayed stripes are now further
      delayed by being held on the 'hold_list'.  The 'hold_list' is bypassed when:
      
        * a STRIPE_IO_STARTED stripe is found at the head of 'handle_list'
        * 'handle_list' is empty and i/o is being done to satisfy full stripe-width
          write requests
        * 'bypass_count' is less than 'bypass_threshold'.  By default the threshold
          is 1, i.e. every other stripe handled is a preread stripe provided the
          top two conditions are false.
      
      Benchmark data:
      System: 2x Xeon 5150, 4x SATA, mem=1GB
      Baseline: 2.6.24-rc7
      Configuration: mdadm --create /dev/md0 /dev/sd[b-e] -n 4 -l 5 --assume-clean
      Test1: dd if=/dev/zero of=/dev/md0 bs=1024k count=2048
        * patched:  +33% (stripe_cache_size = 256), +25% (stripe_cache_size = 512)
      
      Test2: tiobench --size 2048 --numruns 5 --block 4096 --block 131072 (XFS)
        * patched: +13%
        * patched + preread_bypass_threshold = 0: +37%
      
      Changes since v1:
      * reduce bypass_threshold from (chunk_size / sectors_per_chunk) to (1) and
        make it configurable.  This defaults to fairness and modest performance
        gains out of the box.
      Changes since v2:
      * [neilb@suse.de]: kill STRIPE_PRIO_HI and preread_needed as they are not
        necessary, the important change was clearing STRIPE_DELAYED in
        add_stripe_bio and this has been moved out to make_request for the hang
        fix.
      * [neilb@suse.de]: simplify get_priority_stripe
      * [dan.j.williams@intel.com]: reset the bypass_count when ->hold_list is
        sampled empty (+11%)
      * [dan.j.williams@intel.com]: decrement the bypass_count at the detection
        of stripes being naturally promoted off of hold_list +2%.  Note, resetting
        bypass_count instead of decrementing on these events yields +4% but that is
        probably too aggressive.
      Changes since v3:
      * cosmetic fixups
      Tested-by: NJames W. Laferriere <babydr@baby-dragons.com>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Signed-off-by: NNeil Brown <neilb@suse.de>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      8b3e6cdc
  3. 13 7月, 2007 4 次提交
    • D
      md: handle_stripe5 - add request/completion logic for async read ops · b5e98d65
      Dan Williams 提交于
      When a read bio is attached to the stripe and the corresponding block is
      marked R5_UPTODATE, then a read (biofill) operation is scheduled to copy
      the data from the stripe cache to the bio buffer.  handle_stripe flags the
      blocks to be operated on with the R5_Wantfill flag.  If new read requests
      arrive while raid5_run_ops is running they will not be handled until
      handle_stripe is scheduled to run again.
      
      Changelog:
      * cleanup to_read and to_fill accounting
      * do not fail reads that have reached the cache
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Acked-By: NNeilBrown <neilb@suse.de>
      b5e98d65
    • D
      md: handle_stripe5 - add request/completion logic for async compute ops · f38e1219
      Dan Williams 提交于
      handle_stripe will compute a block when a backing disk has failed, or when
      it determines it can save a disk read by computing the block from all the
      other up-to-date blocks.
      
      Previously a block would be computed under the lock and subsequent logic in
      handle_stripe could use the newly up-to-date block.  With the raid5_run_ops
      implementation the compute operation is carried out a later time outside
      the lock.  To preserve the old functionality we take advantage of the
      dependency chain feature of async_tx to flag the block as R5_Wantcompute
      and then let other parts of handle_stripe operate on the block as if it
      were up-to-date.  raid5_run_ops guarantees that the block will be ready
      before it is used in another operation.
      
      However, this only works in cases where the compute and the dependent
      operation are scheduled at the same time.  If a previous call to
      handle_stripe sets the R5_Wantcompute flag there is no facility to pass the
      async_tx dependency chain across successive calls to raid5_run_ops.  The
      req_compute variable protects against this case.
      
      Changelog:
      * remove the req_compute BUG_ON
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Acked-By: NNeilBrown <neilb@suse.de>
      f38e1219
    • D
      md: raid5_run_ops - run stripe operations outside sh->lock · 91c00924
      Dan Williams 提交于
      When the raid acceleration work was proposed, Neil laid out the following
      attack plan:
      
      1/ move the xor and copy operations outside spin_lock(&sh->lock)
      2/ find/implement an asynchronous offload api
      
      The raid5_run_ops routine uses the asynchronous offload api (async_tx) and
      the stripe_operations member of a stripe_head to carry out xor+copy
      operations asynchronously, outside the lock.
      
      To perform operations outside the lock a new set of state flags is needed
      to track new requests, in-flight requests, and completed requests.  In this
      new model handle_stripe is tasked with scanning the stripe_head for work,
      updating the stripe_operations structure, and finally dropping the lock and
      calling raid5_run_ops for processing.  The following flags outline the
      requests that handle_stripe can make of raid5_run_ops:
      
      STRIPE_OP_BIOFILL
       - copy data into request buffers to satisfy a read request
      STRIPE_OP_COMPUTE_BLK
       - generate a missing block in the cache from the other blocks
      STRIPE_OP_PREXOR
       - subtract existing data as part of the read-modify-write process
      STRIPE_OP_BIODRAIN
       - copy data out of request buffers to satisfy a write request
      STRIPE_OP_POSTXOR
       - recalculate parity for new data that has entered the cache
      STRIPE_OP_CHECK
       - verify that the parity is correct
      STRIPE_OP_IO
       - submit i/o to the member disks (note this was already performed outside
         the stripe lock, but it made sense to add it as an operation type
      
      The flow is:
      1/ handle_stripe sets STRIPE_OP_* in sh->ops.pending
      2/ raid5_run_ops reads sh->ops.pending, sets sh->ops.ack, and submits the
         operation to the async_tx api
      3/ async_tx triggers the completion callback routine to set
         sh->ops.complete and release the stripe
      4/ handle_stripe runs again to finish the operation and optionally submit
         new operations that were previously blocked
      
      Note this patch just defines raid5_run_ops, subsequent commits (one per
      major operation type) modify handle_stripe to take advantage of this
      routine.
      
      Changelog:
      * removed ops_complete_biodrain in favor of ops_complete_postxor and
        ops_complete_write.
      * removed the raid5_run_ops workqueue
      * call bi_end_io for reads in ops_complete_biofill, saves a call to
        handle_stripe
      * explicitly handle the 2-disk raid5 case (xor becomes memcpy), Neil Brown
      * fix race between async engines and bi_end_io call for reads, Neil Brown
      * remove unnecessary spin_lock from ops_complete_biofill
      * remove test_and_set/test_and_clear BUG_ONs, Neil Brown
      * remove explicit interrupt handling for channel switching, this feature
        was absorbed (i.e. it is now implicit) by the async_tx api
      * use return_io in ops_complete_biofill
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Acked-By: NNeilBrown <neilb@suse.de>
      91c00924
    • D
      raid5: refactor handle_stripe5 and handle_stripe6 (v3) · a4456856
      Dan Williams 提交于
      handle_stripe5 and handle_stripe6 have very deep logic paths handling the
      various states of a stripe_head.  By introducing the 'stripe_head_state'
      and 'r6_state' objects, large portions of the logic can be moved to
      sub-routines.
      
      'struct stripe_head_state' consumes all of the automatic variables that previously
      stood alone in handle_stripe5,6.  'struct r6_state' contains the handle_stripe6
      specific variables like p_failed and q_failed.
      
      One of the nice side effects of the 'stripe_head_state' change is that it
      allows for further reductions in code duplication between raid5 and raid6.
      The following new routines are shared between raid5 and raid6:
      
      	handle_completed_write_requests
      	handle_requests_to_failed_array
      	handle_stripe_expansion
      
      Changes:
      * v2: fixed 'conf->raid_disk-1' for the raid6 'handle_stripe_expansion' path
      * v3: removed the unused 'dirty' field from struct stripe_head_state
      * v3: coalesced open coded bi_end_io routines into return_io()
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Acked-By: NNeilBrown <neilb@suse.de>
      a4456856
  4. 11 12月, 2006 1 次提交
    • R
      [PATCH] md: allow reads that have bypassed the cache to be retried on failure · 46031f9a
      Raz Ben-Jehuda(caro) 提交于
      If a bypass-the-cache read fails, we simply try again through the cache.  If
      it fails again it will trigger normal recovery precedures.
      
      update 1:
      
      From: NeilBrown <neilb@suse.de>
      
      1/
        chunk_aligned_read and retry_aligned_read assume that
            data_disks == raid_disks - 1
        which is not true for raid6.
        So when an aligned read request bypasses the cache, we can get the wrong data.
      
      2/ The cloned bio is being used-after-free in raid5_align_endio
         (to test BIO_UPTODATE).
      
      3/ We forgot to add rdev->data_offset when submitting
         a bio for aligned-read
      
      4/ clone_bio calls blk_recount_segments and then we change bi_bdev,
         so we need to invalidate the segment counts.
      
      5/ We don't de-reference the rdev when the read completes.
         This means we need to record the rdev to so it is still
         available in the end_io routine.  Fortunately
         bi_next in the original bio is unused at this point so
         we can stuff it in there.
      
      6/ We leak a cloned bio if the target rdev is not usable.
      
      From: NeilBrown <neilb@suse.de>
      
      update 2:
      
      1/ When aligned requests fail (read error) they need to be retried
         via the normal method (stripe cache).  As we cannot be sure that
         we can process a single read in one go (we may not be able to
         allocate all the stripes needed) we store a bio-being-retried
         and a list of bioes-that-still-need-to-be-retried.
         When find a bio that needs to be retried, we should add it to
         the list, not to single-bio...
      
      2/ We were never incrementing 'scnt' when resubmitting failed
         aligned requests.
      
      [akpm@osdl.org: build fix]
      Signed-off-by: NNeil Brown <neilb@suse.de>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      46031f9a
  5. 08 12月, 2006 1 次提交
  6. 03 10月, 2006 2 次提交
  7. 27 6月, 2006 1 次提交
  8. 28 3月, 2006 6 次提交
    • N
      [PATCH] md: Only checkpoint expansion progress occasionally · b578d55f
      NeilBrown 提交于
      Instead of checkpointing at each stripe, only checkpoint when a new write
      would overwrite uncheckpointed data.  Block any write to the uncheckpointed
      area.  Arbitrarily checkpoint at least every 3Meg.
      Signed-off-by: NNeil Brown <neilb@suse.de>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      b578d55f
    • N
      [PATCH] md: Checkpoint and allow restart of raid5 reshape · f6705578
      NeilBrown 提交于
      We allow the superblock to record an 'old' and a 'new' geometry, and a
      position where any conversion is up to.  The geometry allows for changing
      chunksize, layout and level as well as number of devices.
      
      When using verion-0.90 superblock, we convert the version to 0.91 while the
      conversion is happening so that an old kernel will refuse the assemble the
      array.  For version-1, we use a feature bit for the same effect.
      
      When starting an array we check for an incomplete reshape and restart the
      reshape process if needed.  If the reshape stopped at an awkward time (like
      when updating the first stripe) we refuse to assemble the array, and let
      user-space worry about it.
      Signed-off-by: NNeil Brown <neilb@suse.de>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      f6705578
    • N
      [PATCH] md: Core of raid5 resize process · ccfcc3c1
      NeilBrown 提交于
      This patch provides the core of the resize/expand process.
      
      sync_request notices if a 'reshape' is happening and acts accordingly.
      
      It allocated new stripe_heads for the next chunk-wide-stripe in the target
      geometry, marking them STRIPE_EXPANDING.
      
      Then it finds which stripe heads in the old geometry can provide data needed
      by these and marks them STRIPE_EXPAND_SOURCE.  This causes stripe_handle to
      read all blocks on those stripes.
      
      Once all blocks on a STRIPE_EXPAND_SOURCE stripe_head are read, any that are
      needed are copied into the corresponding STRIPE_EXPANDING stripe_head.  Once a
      STRIPE_EXPANDING stripe_head is full, it is marks STRIPE_EXPAND_READY and then
      is written out and released.
      Signed-off-by: NNeil Brown <neilb@suse.de>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      ccfcc3c1
    • N
      [PATCH] md: Infrastructure to allow normal IO to continue while array is expanding · 7ecaa1e6
      NeilBrown 提交于
      We need to allow that different stripes are of different effective sizes, and
      use the appropriate size.  Also, when a stripe is being expanded, we must
      block any IO attempts until the stripe is stable again.
      
      Key elements in this change are:
       - each stripe_head gets a 'disk' field which is part of the key,
         thus there can sometimes be two stripe heads of the same area of
         the array, but covering different numbers of devices.  One of these
         will be marked STRIPE_EXPANDING and so won't accept new requests.
       - conf->expand_progress tracks how the expansion is progressing and
         is used to determine whether the target part of the array has been
         expanded yet or not.
      Signed-off-by: NNeil Brown <neilb@suse.de>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      7ecaa1e6
    • N
      [PATCH] md: Allow stripes to be expanded in preparation for expanding an array · ad01c9e3
      NeilBrown 提交于
      Before a RAID-5 can be expanded, we need to be able to expand the stripe-cache
      data structure.
      
      This requires allocating new stripes in a new kmem_cache.  If this succeeds,
      we copy cache pages over and release the old stripes and kmem_cache.
      
      We then allocate new pages.  If that fails, we leave the stripe cache at it's
      new size.  It isn't worth the effort to shrink it back again.
      
      Unfortuanately this means we need two kmem_cache names as we, for a short
      period of time, we have two kmem_caches.  So they are raid5/%s and
      raid5/%s-alt
      Signed-off-by: NNeil Brown <neilb@suse.de>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      ad01c9e3
    • N
      [PATCH] md: Split disks array out of raid5 conf structure so it is easier to grow · b55e6bfc
      NeilBrown 提交于
      The remainder of this batch implements raid5 reshaping.  Currently the only
      shape change that is supported is added a device, but it is envisioned that
      changing the chunksize and layout will also be supported, as well as changing
      the level (e.g.  1->5, 5->6).
      
      The reshape process naturally has to move all of the data in the array, and so
      should be used with caution.  It is believed to work, and some testing does
      support this, but wider testing would be great for increasing my confidence.
      
      You will need a version of mdadm newer than 2.3.1 to make use of raid5 growth.
       This is because mdadm need to take a copy of a 'critical section' at the
      start of the array incase there is a crash at an awkward moment.  On restart,
      mdadm will restore the critical section and allow reshape to continue.
      
      I hope to release a 2.4-pre by early next week - it still needs a little more
      polishing.
      
      This patch:
      
      Previously the array of disk information was included in the raid5 'conf'
      structure which was allocated to an appropriate size.  This makes it awkward
      to change the size of that array.  So we split it off into a separate
      kmalloced array which will require a little extra indexing, but is much easier
      to grow.
      Signed-off-by: NNeil Brown <neilb@suse.de>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      b55e6bfc
  9. 07 1月, 2006 3 次提交
    • N
      [PATCH] md: tidy up raid5/6 hash table code · fccddba0
      NeilBrown 提交于
      - replace open-coded hash chain with hlist macros
      
      - Fix hash-table size at one page - it is already quite generous, so there
        will never be a need to use multiple pages, so no need for __get_free_pages
      
      No functional change.
      Signed-off-by: NNeil Brown <neilb@suse.de>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      fccddba0
    • N
      [PATCH] md: fix up some rdev rcu locking in raid5/6 · 9910f16a
      NeilBrown 提交于
      There is this "FIXME" comment with a typo in it!!  that been annoying me for
      days, so I just had to remove it.
      
      conf->disks[i].rdev should only be accessed if
        - we know we hold a reference or
        - the mddev->reconfig_sem is down or
        - we have a rcu_readlock
      
      handle_stripe was referencing rdev in three places without any of these.  For
      the first two, get an rcu_readlock.  For the last, the same access
      (md_sync_acct call) is made a little later after the rdev has been claimed
      under and rcu_readlock, if R5_Syncio is set.  So just use that access...
      However R5_Syncio isn't really needed as the 'syncing' variable contains the
      same information.  So use that instead.
      
      Issues, comment, and fix are identical in raid5 and raid6.
      Signed-off-by: NNeil Brown <neilb@suse.de>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      9910f16a
    • N
      [PATCH] md: fix raid6 resync check/repair code · ca65b73b
      NeilBrown 提交于
      raid6 currently does not check the P/Q syndromes when doing a resync, it just
      calculates the correct value and writes it.  Doing the check can reduce writes
      (often to 0) for a resync, and it is needed to properly implement the
      
        echo check > sync_action
      
      operation.
      
      This patch implements the appropriate checks and tidies up some related code.
      
      It also allows raid6 user-requested resync to bypass the intent bitmap.
      Signed-off-by: NNeil Brown <neilb@suse.de>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      ca65b73b
  10. 09 11月, 2005 3 次提交
  11. 10 9月, 2005 1 次提交
    • N
      [PATCH] md: add write-intent-bitmap support to raid5 · 72626685
      NeilBrown 提交于
      Most awkward part of this is delaying write requests until bitmap updates have
      been flushed.
      
      To achieve this, we have a sequence number (seq_flush) which is incremented
      each time the raid5 is unplugged.
      
      If the raid thread notices that this has changed, it flushes bitmap changes,
      and assigned the value of seq_flush to seq_write.
      
      When a write request arrives, it is given the number from seq_write, and that
      write request may not complete until seq_flush is larger than the saved seq
      number.
      
      We have a new queue for storing stripes which are waiting for a bitmap flush
      and an extra flag for stripes to record if the write was 'degraded' and so
      should not clear the a bit in the bitmap.
      Signed-off-by: NNeil Brown <neilb@cse.unsw.edu.au>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      72626685
  12. 17 4月, 2005 1 次提交
    • L
      Linux-2.6.12-rc2 · 1da177e4
      Linus Torvalds 提交于
      Initial git repository build. I'm not bothering with the full history,
      even though we have it. We can create a separate "historical" git
      archive of that later if we want to, and in the meantime it's about
      3.2GB when imported into git - space that would just make the early
      git days unnecessarily complicated, when we don't have a lot of good
      infrastructure for it.
      
      Let it rip!
      1da177e4