25 Sep, 2007

1 commit

  • 1/ ops_complete_biofill tried to avoid calling handle_stripe since all the
    state necessary to return read completions is available. However the
    process of determining whether more read requests are pending requires
    locking the stripe (to block add_stripe_bio from updating dev->toead).
    ops_complete_biofill can run in tasklet context, so rather than upgrading
    all the stripe locks from spin_lock to spin_lock_bh this patch just
    unconditionally reschedules handle_stripe after completing the read
    request.

    2/ ops_complete_biofill needlessly qualified processing R5_Wantfill with
    dev->toread. The result being that the 'biofill' pending bit is cleared
    before handling the pending read-completions on dev->read. R5_Wantfill can
    be unconditionally handled because the 'biofill' pending bit prevents new
    R5_Wantfill requests from being seen by ops_run_biofill and
    ops_complete_biofill.

    Found-by: Yuri Tikhonov
    [neilb@suse.de: simpler fix for bug 1 than moving code]
    Signed-off-by: NeilBrown
    Signed-off-by: Dan Williams

    Dan Williams
     

15 Sep, 2007

1 commit

  • Commit 02a5e0acb3cb85d80d0fe834e366d38a92bbaa22 ("BLOCK: Hide the
    contents of linux/bio.h if CONFIG_BLOCK=n") broke the kernel build for
    the CONFIG_COMPAT && !CONFIG_BLOCK case:

    CC fs/compat_ioctl.o
    In file included from include/linux/raid/md_k.h:19,
    from include/linux/raid/md.h:54,
    from fs/compat_ioctl.c:25:
    include/linux/raid/../../../drivers/md/dm-bio-list.h: In bio_list_:
    include/linux/raid/../../../drivers/md/dm-bio-list.h:40: error: dereferencing pointer to incomplete type
    include/linux/raid/../../../drivers/md/dm-bio-list.h: In bio_list_:
    include/linux/raid/../../../drivers/md/dm-bio-list.h:48: error: dereferencing pointer to incomplete type
    include/linux/raid/../../../drivers/md/dm-bio-list.h:51: error: dereferencing pointer to incomplete type
    include/linux/raid/../../../drivers/md/dm-bio-list.h: In bio_list_:
    include/linux/raid/../../../drivers/md/dm-bio-list.h:64: error: dereferencing pointer to incomplete type
    include/linux/raid/../../../drivers/md/dm-bio-list.h: In bio_list_merge_:
    include/linux/raid/../../../drivers/md/dm-bio-list.h:78: error: dereferencing pointer to incomplete type
    include/linux/raid/../../../drivers/md/dm-bio-list.h: In bio_list_:
    include/linux/raid/../../../drivers/md/dm-bio-list.h:90: error: dereferencing pointer to incomplete type
    include/linux/raid/../../../drivers/md/dm-bio-list.h:94: error: dereferencing pointer to incomplete type
    make[1]: *** [fs/compat_ioctl.o] Error 1
    make: *** [fs] Error 2

    Signed-off-by: Andreas Herrmann
    Acked-By: David Howells
    Signed-off-by: Linus Torvalds

    aherrman@arcor.de
     

12 Sep, 2007

1 commit

  • The recent changed to raid5 to allow offload of parity calculation etc
    introduced some bugs in the code for growing (i.e. adding a disk to) raid5
    and raid6. This fixes them

    Acked-by: Dan Williams
    Signed-off-by: Neil Brown
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    NeilBrown
     

28 Aug, 2007

1 commit

  • Without this, we get qla2xxx complaining about "ISP System Error".

    What's happening here is the firmware is detecting a Xfer-ready from the
    storage when in fact the data-direction for a mode-select should be a
    write (DATA_OUT).

    The following patch fixes the problem (typo). Verified by Brian, as
    well.

    Signed-off-by: Andrew Vasquez
    Verified-by: Brian De Wolf
    Signed-off-by: Chandra Seetharaman
    Signed-off-by: Linus Torvalds

    Andrew Vasquez
     

25 Aug, 2007

1 commit


23 Aug, 2007

2 commits

  • When a raid1 array is reshaped (number of drives changed), the list of devices
    is compacted, so that slots for missing devices are filled with working
    devices from later slots. This requires the "rd%d" symlinks in sysfs to be
    updated.

    Signed-off-by: Neil Brown
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    NeilBrown
     
  • Commit 1757128438d41670ded8bc3bc735325cc07dc8f9 was slightly bad. If an array
    has a write-intent bitmap, and you remove a drive, then readd it, only the
    changed parts should be resynced. However after the above commit, this only
    works if the array has not been shut down and restarted.

    This is because it sets 'fullsync' at little more often than it should. This
    patch is more careful.

    Signed-off-by: Neil Brown
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    NeilBrown
     

12 Aug, 2007

1 commit

  • This patch provides more information concerning REMAP operations on block
    IOs. The additional information provides clearer details at the user level,
    and supports post-processing analysis in btt.

    o Adds in partition remaps on the same device.
    o Fixed up the remap information in DM to be in the right order
    o Sent up mapped-from and mapped-to device information

    Signed-off-by: Alan D. Brunelle
    Signed-off-by: Jens Axboe

    Alan D. Brunelle
     

01 Aug, 2007

2 commits


24 Jul, 2007

1 commit

  • Some of the code has been gradually transitioned to using the proper
    struct request_queue, but there's lots left. So do a full sweet of
    the kernel and get rid of this typedef and replace its uses with
    the proper type.

    Signed-off-by: Jens Axboe

    Jens Axboe
     

22 Jul, 2007

1 commit

  • Flush workqueue before releasing bioset and mopools in dm-crypt. There can
    be finished but not yet released request.

    Call chain causing oops:
    run workqueue
    dec_pending
    bio_endio(...);

    mempool_free(io, cc->io_pool);

    This usually happens when cryptsetup create temporary
    luks mapping in the beggining of crypt device activation.

    When dm-core calls destructor crypt_dtr, no new request
    are possible.

    Signed-off-by: Milan Broz
    Cc: Chuck Ebbert
    Cc: Patrick McHardy
    Acked-by: Alasdair G Kergon
    Cc: Christophe Saout
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Milan Broz
     

20 Jul, 2007

3 commits

  • Andrew Morton:
    [async_memcpy] is very wrong if both ASYNC_TX_KMAP_DST and
    ASYNC_TX_KMAP_SRC can ever be set. We'll end up using the same kmap
    slot for both src add dest and we get either corrupted data or a BUG.

    Evgeniy Polyakov:
    Btw, shouldn't it always be kmap_atomic() even if flag is not set.
    That pages are usual one returned by alloc_page().

    So fix the usage of kmap_atomic and kill the ASYNC_TX_KMAP_DST and
    ASYNC_TX_KMAP_SRC flags.

    Cc: Andrew Morton
    Cc: Evgeniy Polyakov
    Signed-off-by: Dan Williams
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Dan Williams
     
  • Slab destructors were no longer supported after Christoph's
    c59def9f222d44bb7e2f0a559f2906191a0862d7 change. They've been
    BUGs for both slab and slub, and slob never supported them
    either.

    This rips out support for the dtor pointer from kmem_cache_create()
    completely and fixes up every single callsite in the kernel (there were
    about 224, not including the slab allocator definitions themselves,
    or the documentation references).

    Signed-off-by: Paul Mundt

    Paul Mundt
     
  • Transform some calls to kmalloc/memset to a single kzalloc (or kcalloc).

    Here is a short excerpt of the semantic patch performing
    this transformation:

    @@
    type T2;
    expression x;
    identifier f,fld;
    expression E;
    expression E1,E2;
    expression e1,e2,e3,y;
    statement S;
    @@

    x =
    - kmalloc
    + kzalloc
    (E1,E2)
    ... when != \(x->fld=E;\|y=f(...,x,...);\|f(...,x,...);\|x=E;\|while(...) S\|for(e1;e2;e3) S\)
    - memset((T2)x,0,E1);

    @@
    expression E1,E2,E3;
    @@

    - kzalloc(E1 * E2,E3)
    + kcalloc(E1,E2,E3)

    [akpm@linux-foundation.org: get kcalloc args the right way around]
    Signed-off-by: Yoann Padioleau
    Cc: Richard Henderson
    Cc: Ivan Kokshaysky
    Acked-by: Russell King
    Cc: Bryan Wu
    Acked-by: Jiri Slaby
    Cc: Dave Airlie
    Acked-by: Roland Dreier
    Cc: Jiri Kosina
    Acked-by: Dmitry Torokhov
    Cc: Benjamin Herrenschmidt
    Acked-by: Mauro Carvalho Chehab
    Acked-by: Pierre Ossman
    Cc: Jeff Garzik
    Cc: "David S. Miller"
    Acked-by: Greg KH
    Cc: James Bottomley
    Cc: "Antonino A. Daplas"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Yoann Padioleau
     

18 Jul, 2007

8 commits

  • If, in dm_create_persistent(), the call to create_singlethread_workqueue()
    fails then we'll return without freeing the memory allocated to 'ps', thus
    leaking sizeof(struct pstore) bytes. This patch fixes the leak.

    Signed-off-by: Jesper Juhl
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jesper Juhl
     
  • bitmap_unplug only ever returns 0, so it may as well be void. Two callers try
    to print a message if it returns non-zero, but that message is already printed
    by bitmap_file_kick.

    write_page returns an error which is not consistently checked. It always
    causes BITMAP_WRITE_ERROR to be set on an error, and that can more
    conveniently be checked.

    When the return of write_page is checked, an error causes bitmap_file_kick to
    be called - so move that call into write_page - and protect against recursive
    calls into bitmap_file_kick.

    bitmap_update_sb returns an error that is never checked.

    So make these 'void' and be consistent about checking the bit.

    Signed-off-by: Neil Brown
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    NeilBrown
     
  • We current completely trust user-space to set up metadata describing an
    consistant array. In particlar, that the metadata, data, and bitmap do not
    overlap.

    But userspace can be buggy, and it is better to report an error than corrupt
    data. So put in some appropriate checks.

    Signed-off-by: Neil Brown
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    NeilBrown
     
  • Don't use 'unsigned' variable to track sync vs non-sync IO, as the only thing
    we want to do with them is a signed comparison, and fix up the comment which
    had become quite wrong.

    Signed-off-by: Neil Brown
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    NeilBrown
     
  • People try to use raid auto-detect with version-1 superblocks (which is not
    supported) and get confused when they are told they have an invalid
    superblock.

    So be more explicit, and say it it is not a valid v0.90 superblock.

    Signed-off-by: Neil Brown
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    NeilBrown
     
  • Change Kconfig objects from "menu, config" into "menuconfig" so
    that the user can disable the whole feature without having to
    enter the menu first.

    Signed-off-by: Jan Engelhardt
    Acked-by: Neil Brown
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jan Engelhardt
     
  • No need to warn unregister_blkdev() failure by the callers. (The previous
    patch makes unregister_blkdev() print error message in error case)

    Signed-off-by: Akinobu Mita
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Akinobu Mita
     
  • Currently, the freezer treats all tasks as freezable, except for the kernel
    threads that explicitly set the PF_NOFREEZE flag for themselves. This
    approach is problematic, since it requires every kernel thread to either
    set PF_NOFREEZE explicitly, or call try_to_freeze(), even if it doesn't
    care for the freezing of tasks at all.

    It seems better to only require the kernel threads that want to or need to
    be frozen to use some freezer-related code and to remove any
    freezer-related code from the other (nonfreezable) kernel threads, which is
    done in this patch.

    The patch causes all kernel threads to be nonfreezable by default (ie. to
    have PF_NOFREEZE set by default) and introduces the set_freezable()
    function that should be called by the freezable kernel threads in order to
    unset PF_NOFREEZE. It also makes all of the currently freezable kernel
    threads call set_freezable(), so it shouldn't cause any (intentional)
    change of behaviour to appear. Additionally, it updates documentation to
    describe the freezing of tasks more accurately.

    [akpm@linux-foundation.org: build fixes]
    Signed-off-by: Rafael J. Wysocki
    Acked-by: Nigel Cunningham
    Cc: Pavel Machek
    Cc: Oleg Nesterov
    Cc: Gautham R Shenoy
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     

14 Jul, 2007

1 commit

  • * 'ioat-md-accel-for-linus' of git://lost.foo-projects.org/~dwillia2/git/iop: (28 commits)
    ioatdma: add the unisys "i/oat" pci vendor/device id
    ARM: Add drivers/dma to arch/arm/Kconfig
    iop3xx: surface the iop3xx DMA and AAU units to the iop-adma driver
    iop13xx: surface the iop13xx adma units to the iop-adma driver
    dmaengine: driver for the iop32x, iop33x, and iop13xx raid engines
    md: remove raid5 compute_block and compute_parity5
    md: handle_stripe5 - request io processing in raid5_run_ops
    md: handle_stripe5 - add request/completion logic for async expand ops
    md: handle_stripe5 - add request/completion logic for async read ops
    md: handle_stripe5 - add request/completion logic for async check ops
    md: handle_stripe5 - add request/completion logic for async compute ops
    md: handle_stripe5 - add request/completion logic for async write ops
    md: common infrastructure for running operations with raid5_run_ops
    md: raid5_run_ops - run stripe operations outside sh->lock
    raid5: replace custom debug PRINTKs with standard pr_debug
    raid5: refactor handle_stripe5 and handle_stripe6 (v3)
    async_tx: add the async_tx api
    xor: make 'xor_blocks' a library routine for use with async_tx
    dmaengine: make clients responsible for managing channels
    dmaengine: refactor dmaengine around dma_async_tx_descriptor
    ...

    Linus Torvalds
     

13 Jul, 2007

16 commits

  • replaced by raid5_run_ops

    Signed-off-by: Dan Williams
    Acked-By: NeilBrown

    Dan Williams
     
  • I/O submission requests were already handled outside of the stripe lock in
    handle_stripe. Now that handle_stripe is only tasked with finding work,
    this logic belongs in raid5_run_ops.

    Signed-off-by: Dan Williams
    Acked-By: NeilBrown

    Dan Williams
     
  • When a stripe is being expanded bulk copying takes place to move the data
    from the old stripe to the new. Since raid5_run_ops only operates on one
    stripe at a time these bulk copies are handled in-line under the stripe
    lock. In the dma offload case we poll for the completion of the operation.

    After the data has been copied into the new stripe the parity needs to be
    recalculated across the new disks. We reuse the existing postxor
    functionality to carry out this calculation. By setting STRIPE_OP_POSTXOR
    without setting STRIPE_OP_BIODRAIN the completion path in handle stripe
    can differentiate expand operations from normal write operations.

    Signed-off-by: Dan Williams
    Acked-By: NeilBrown

    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: Dan Williams
    Acked-By: NeilBrown

    Dan Williams
     
  • Check operations are scheduled when the array is being resynced or an
    explicit 'check/repair' command was sent to the array. Previously check
    operations would destroy the parity block in the cache such that even if
    parity turned out to be correct the parity block would be marked
    !R5_UPTODATE at the completion of the check. When the operation can be
    carried out by a dma engine the assumption is that it can check parity as a
    read-only operation. If raid5_run_ops notices that the check was handled
    by hardware it will preserve the R5_UPTODATE status of the parity disk.

    When a check operation determines that the parity needs to be repaired we
    reuse the existing compute block infrastructure to carry out the operation.
    Repair operations imply an immediate write back of the data, so to
    differentiate a repair from a normal compute operation the
    STRIPE_OP_MOD_REPAIR_PD flag is added.

    Changelog:
    * remove test_and_set/test_and_clear BUG_ONs, Neil Brown

    Signed-off-by: Dan Williams
    Acked-By: NeilBrown

    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: Dan Williams
    Acked-By: NeilBrown

    Dan Williams
     
  • After handle_stripe5 decides whether it wants to perform a
    read-modify-write, or a reconstruct write it calls
    handle_write_operations5. A read-modify-write operation will perform an
    xor subtraction of the blocks marked with the R5_Wantprexor flag, copy the
    new data into the stripe (biodrain) and perform a postxor operation across
    all up-to-date blocks to generate the new parity. A reconstruct write is run
    when all blocks are already up-to-date in the cache so all that is needed
    is a biodrain and postxor.

    On the completion path STRIPE_OP_PREXOR will be set if the operation was a
    read-modify-write. The STRIPE_OP_BIODRAIN flag is used in the completion
    path to differentiate write-initiated postxor operations versus
    expansion-initiated postxor operations. Completion of a write triggers i/o
    to the drives.

    Changelog:
    * make the 'rcw' parameter to handle_write_operations5 a simple flag, Neil Brown
    * remove test_and_set/test_and_clear BUG_ONs, Neil Brown

    Signed-off-by: Dan Williams
    Acked-By: NeilBrown

    Dan Williams
     
  • All the handle_stripe operations that are to be transitioned to use
    raid5_run_ops need a method to coherently gather work under the stripe-lock
    and hand that work off to raid5_run_ops. The 'get_stripe_work' routine
    runs under the lock to read all the bits in sh->ops.pending that do not
    have the corresponding bit set in sh->ops.ack. This modified 'pending'
    bitmap is then passed to raid5_run_ops for processing.

    The transition from 'ack' to 'completion' does not need similar protection
    as the existing release_stripe infrastructure will guarantee that
    handle_stripe will run again after a completion bit is set, and
    handle_stripe can tolerate a sh->ops.completed bit being set while the lock
    is held.

    A call to async_tx_issue_pending_all() is added to raid5d to kick the
    offload engines once all pending stripe operations work has been submitted.
    This enables batching of the submission and completion of operations.

    Signed-off-by: Dan Williams
    Acked-By: NeilBrown

    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: Dan Williams
    Acked-By: NeilBrown

    Dan Williams
     
  • Replaces PRINTK with pr_debug, and kills the RAID5_DEBUG definition in
    favor of the global DEBUG definition. To get local debug messages just add
    '#define DEBUG' to the top of the file.

    Signed-off-by: Dan Williams
    Acked-By: NeilBrown

    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: Dan Williams
    Acked-By: NeilBrown

    Dan Williams
     
  • The async_tx api provides methods for describing a chain of asynchronous
    bulk memory transfers/transforms with support for inter-transactional
    dependencies. It is implemented as a dmaengine client that smooths over
    the details of different hardware offload engine implementations. Code
    that is written to the api can optimize for asynchronous operation and the
    api will fit the chain of operations to the available offload resources.

    I imagine that any piece of ADMA hardware would register with the
    'async_*' subsystem, and a call to async_X would be routed as
    appropriate, or be run in-line. - Neil Brown

    async_tx exploits the capabilities of struct dma_async_tx_descriptor to
    provide an api of the following general format:

    struct dma_async_tx_descriptor *
    async_(..., struct dma_async_tx_descriptor *depend_tx,
    dma_async_tx_callback cb_fn, void *cb_param)
    {
    struct dma_chan *chan = async_tx_find_channel(depend_tx, );
    struct dma_device *device = chan ? chan->device : NULL;
    int int_en = cb_fn ? 1 : 0;
    struct dma_async_tx_descriptor *tx = device ?
    device->device_prep_dma_(chan, len, int_en) : NULL;

    if (tx) { /* run asynchronously */
    ...
    tx->tx_set_dest(addr, tx, index);
    ...
    tx->tx_set_src(addr, tx, index);
    ...
    async_tx_submit(chan, tx, flags, depend_tx, cb_fn, cb_param);
    } else { /* run synchronously */
    ...

    ...
    async_tx_sync_epilog(flags, depend_tx, cb_fn, cb_param);
    }

    return tx;
    }

    async_tx_find_channel() returns a capable channel from its pool. The
    channel pool is organized as a per-cpu array of channel pointers. The
    async_tx_rebalance() routine is tasked with managing these arrays. In the
    uniprocessor case async_tx_rebalance() tries to spread responsibility
    evenly over channels of similar capabilities. For example if there are two
    copy+xor channels, one will handle copy operations and the other will
    handle xor. In the SMP case async_tx_rebalance() attempts to spread the
    operations evenly over the cpus, e.g. cpu0 gets copy channel0 and xor
    channel0 while cpu1 gets copy channel 1 and xor channel 1. When a
    dependency is specified async_tx_find_channel defaults to keeping the
    operation on the same channel. A xor->copy->xor chain will stay on one
    channel if it supports both operation types, otherwise the transaction will
    transition between a copy and a xor resource.

    Currently the raid5 implementation in the MD raid456 driver has been
    converted to the async_tx api. A driver for the offload engines on the
    Intel Xscale series of I/O processors, iop-adma, is provided in a later
    commit. With the iop-adma driver and async_tx, raid456 is able to offload
    copy, xor, and xor-zero-sum operations to hardware engines.

    On iop342 tiobench showed higher throughput for sequential writes (20 - 30%
    improvement) and sequential reads to a degraded array (40 - 55%
    improvement). For the other cases performance was roughly equal, +/- a few
    percentage points. On a x86-smp platform the performance of the async_tx
    implementation (in synchronous mode) was also +/- a few percentage points
    of the original implementation. According to 'top' on iop342 CPU
    utilization drops from ~50% to ~15% during a 'resync' while the speed
    according to /proc/mdstat doubles from ~25 MB/s to ~50 MB/s.

    The tiobench command line used for testing was: tiobench --size 2048
    --block 4096 --block 131072 --dir /mnt/raid --numruns 5
    * iop342 had 1GB of memory available

    Details:
    * if CONFIG_DMA_ENGINE=n the asynchronous path is compiled away by making
    async_tx_find_channel a static inline routine that always returns NULL
    * when a callback is specified for a given transaction an interrupt will
    fire at operation completion time and the callback will occur in a
    tasklet. if the the channel does not support interrupts then a live
    polling wait will be performed
    * the api is written as a dmaengine client that requests all available
    channels
    * In support of dependencies the api implicitly schedules channel-switch
    interrupts. The interrupt triggers the cleanup tasklet which causes
    pending operations to be scheduled on the next channel
    * Xor engines treat an xor destination address differently than a software
    xor routine. To the software routine the destination address is an implied
    source, whereas engines treat it as a write-only destination. This patch
    modifies the xor_blocks routine to take a an explicit destination address
    to mirror the hardware.

    Changelog:
    * fixed a leftover debug print
    * don't allow callbacks in async_interrupt_cond
    * fixed xor_block changes
    * fixed usage of ASYNC_TX_XOR_DROP_DEST
    * drop dma mapping methods, suggested by Chris Leech
    * printk warning fixups from Andrew Morton
    * don't use inline in C files, Adrian Bunk
    * select the API when MD is enabled
    * BUG_ON xor source counts
    Signed-off-by: Dan Williams
    Acked-By: NeilBrown

    Dan Williams
     
  • The async_tx api tries to use a dma engine for an operation, but will fall
    back to an optimized software routine otherwise. Xor support is
    implemented using the raid5 xor routines. For organizational purposes this
    routine is moved to a common area.

    The following fixes are also made:
    * rename xor_block => xor_blocks, suggested by Adrian Bunk
    * ensure that xor.o initializes before md.o in the built-in case
    * checkpatch.pl fixes
    * mark calibrate_xor_blocks __init, Adrian Bunk

    Cc: Adrian Bunk
    Cc: NeilBrown
    Cc: Herbert Xu
    Signed-off-by: Dan Williams

    Dan Williams
     
  • This patch supports LSI/Engenio devices in RDAC mode. Like dm-emc
    it requires userspace support. In your multipath.conf file you must have:

    path_checker rdac
    hardware_handler "1 rdac"
    prio_callout "/sbin/mpath_prio_tpc /dev/%n"

    And you also then must have a updated multipath tools release which
    has rdac support.

    Signed-off-by: Chandra Seetharaman
    Signed-off-by: Mike Christie
    Signed-off-by: Alasdair G Kergon
    Signed-off-by: Linus Torvalds

    Chandra Seetharaman
     
  • When writing to a mirror, the log must be updated first. Failure
    to update the log could result in the log not properly reflecting
    the state of the mirror if the machine should crash.

    We change the return type of the rh_flush function to give us
    the ability to check if a log write was successful. If the
    log write was unsuccessful, we fail the writes to avoid the
    case where the log does not properly reflect the state of the
    mirror.

    A follow-up patch - which is dependent on the ability to
    requeue I/O's to core device-mapper - will requeue the I/O's
    for retry (allowing the mirror to be reconfigured.)

    Signed-off-by: Jonathan Brassow
    Signed-off-by: Alasdair G Kergon
    Signed-off-by: Linus Torvalds

    Jonathan Brassow
     
  • Device-mapper mirroring currently takes a best effort approach to
    recovery - failures during mirror synchronization are completely ignored.
    This means that regions are marked 'in-sync' and 'clean' and removed
    from the hash list. Future reads and writes that query the region
    will incorrectly interpret the region as in-sync.

    This patch handles failures during the recovery process. If a failure
    occurs, the region is marked as 'not-in-sync' (aka RH_NOSYNC) and added
    to a new list 'failed_recovered_regions'.

    Regions on the 'failed_recovered_regions' list are not marked as 'clean'
    upon removal from the list. Furthermore, if the DM_RAID1_HANDLE_ERRORS
    flag is set, the region is marked as 'not-in-sync'. This action prevents
    any future read-balancing from choosing an invalid device because of the
    'not-in-sync' status.

    If "handle_errors" is not specified when creating a mirror (leaving the
    DM_RAID1_HANDLE_ERRORS flag unset), failures will be ignored exactly as they
    would be without this patch. This is to preserve backwards compatibility with
    user-space tools, such as 'pvmove'. However, since future read-balancing
    policies will rely on the correct sync status of a region, a user must choose
    "handle_errors" when using read-balancing.

    Signed-off-by: Jonathan Brassow
    Signed-off-by: Alasdair G Kergon
    Signed-off-by: Linus Torvalds

    Jonathan Brassow