linux/drivers
Kiyoshi Ueda cec47e3d4a dm: prepare for request based option
This patch adds core functions for request-based dm.

When struct mapped device (md) is initialized, md->queue has
an I/O scheduler and the following functions are used for
request-based dm as the queue functions:
    make_request_fn: dm_make_request()
    pref_fn:         dm_prep_fn()
    request_fn:      dm_request_fn()
    softirq_done_fn: dm_softirq_done()
    lld_busy_fn:     dm_lld_busy()
Actual initializations are done in another patch (PATCH 2).

Below is a brief summary of how request-based dm behaves, including:
  - making request from bio
  - cloning, mapping and dispatching request
  - completing request and bio
  - suspending md
  - resuming md

  bio to request
  ==============
  md->queue->make_request_fn() (dm_make_request()) calls __make_request()
  for a bio submitted to the md.
  Then, the bio is kept in the queue as a new request or merged into
  another request in the queue if possible.

  Cloning and Mapping
  ===================
  Cloning and mapping are done in md->queue->request_fn() (dm_request_fn()),
  when requests are dispatched after they are sorted by the I/O scheduler.

  dm_request_fn() checks busy state of underlying devices using
  target's busy() function and stops dispatching requests to keep them
  on the dm device's queue if busy.
  It helps better I/O merging, since no merge is done for a request
  once it is dispatched to underlying devices.

  Actual cloning and mapping are done in dm_prep_fn() and map_request()
  called from dm_request_fn().
  dm_prep_fn() clones not only request but also bios of the request
  so that dm can hold bio completion in error cases and prevent
  the bio submitter from noticing the error.
  (See the "Completion" section below for details.)

  After the cloning, the clone is mapped by target's map_rq() function
    and inserted to underlying device's queue using
    blk_insert_cloned_request().

  Completion
  ==========
  Request completion can be hooked by rq->end_io(), but then, all bios
  in the request will have been completed even error cases, and the bio
  submitter will have noticed the error.
  To prevent the bio completion in error cases, request-based dm clones
  both bio and request and hooks both bio->bi_end_io() and rq->end_io():
      bio->bi_end_io(): end_clone_bio()
      rq->end_io():     end_clone_request()

  Summary of the request completion flow is below:
  blk_end_request() for a clone request
    => blk_update_request()
       => bio->bi_end_io() == end_clone_bio() for each clone bio
          => Free the clone bio
          => Success: Complete the original bio (blk_update_request())
             Error:   Don't complete the original bio
    => blk_finish_request()
       => rq->end_io() == end_clone_request()
          => blk_complete_request()
             => dm_softirq_done()
                => Free the clone request
                => Success: Complete the original request (blk_end_request())
                   Error:   Requeue the original request

  end_clone_bio() completes the original request on the size of
  the original bio in successful cases.
  Even if all bios in the original request are completed by that
  completion, the original request must not be completed yet to keep
  the ordering of request completion for the stacking.
  So end_clone_bio() uses blk_update_request() instead of
  blk_end_request().
  In error cases, end_clone_bio() doesn't complete the original bio.
  It just frees the cloned bio and gives over the error handling to
  end_clone_request().

  end_clone_request(), which is called with queue lock held, completes
  the clone request and the original request in a softirq context
  (dm_softirq_done()), which has no queue lock, to avoid a deadlock
  issue on submission of another request during the completion:
      - The submitted request may be mapped to the same device
      - Request submission requires queue lock, but the queue lock
        has been held by itself and it doesn't know that

  The clone request has no clone bio when dm_softirq_done() is called.
  So target drivers can't resubmit it again even error cases.
  Instead, they can ask dm core for requeueing and remapping
  the original request in that cases.

  suspend
  =======
  Request-based dm uses stopping md->queue as suspend of the md.
  For noflush suspend, just stops md->queue.

  For flush suspend, inserts a marker request to the tail of md->queue.
  And dispatches all requests in md->queue until the marker comes to
  the front of md->queue.  Then, stops dispatching request and waits
  for the all dispatched requests to complete.
  After that, completes the marker request, stops md->queue and
  wake up the waiter on the suspend queue, md->wait.

  resume
  ======
  Starts md->queue.

Signed-off-by: Kiyoshi Ueda <k-ueda@ct.jp.nec.com>
Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
2009-06-22 10:12:35 +01:00
..
accessibility
acpi Merge branch 'acpica' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6 2009-06-16 11:24:23 -07:00
amba
ata powerpc/5xxx: Add common mpc5xxx_get_bus_frequency() function 2009-06-17 00:30:22 -06:00
atm Replace all DMA_nBIT_MASK macro with DMA_BIT_MASK(n) 2009-04-13 15:04:33 -07:00
auxdisplay
base Merge branch 'akpm' 2009-06-16 19:50:13 -07:00
block hd: stop defining MAJOR_NR 2009-06-18 09:56:20 +02:00
bluetooth Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6 2009-06-15 03:02:23 -07:00
cdrom block: Use accessor functions for queue limits 2009-05-22 23:22:54 +02:00
char Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input 2009-06-20 10:17:02 -07:00
clocksource Merge branches 'sh/pci-express-integration', 'sh/rsk-updates', 'sh/platform-updates' and 'sh/perf_counter' 2009-06-17 16:37:26 +09:00
connector trivial: Kconfig: .ko is normally not included in module names 2009-06-12 18:01:50 +02:00
cpufreq [CPUFREQ] Only set sampling_rate_max deprecated, sampling_rate_min is useful 2009-06-15 11:49:41 -04:00
cpuidle
crypto crypto: padlock-aes - work around Nano CPU errata in CBC mode 2009-06-18 19:31:09 +08:00
dca
dio
dma DMA: TXx9 Soc DMA Controller driver 2009-06-17 11:06:25 +01:00
edac edac: Kconfig: fix the meaning of EDAC abbreviation 2009-06-18 13:03:57 -07:00
eisa Merge branch 'akpm' 2009-06-16 19:50:13 -07:00
firewire Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6 2009-06-16 14:29:46 -07:00
firmware Pull for-2.6.31 into release 2009-06-17 09:35:24 -07:00
gpio gpio: driver for PrimeCell PL061 GPIO controller 2009-06-19 16:46:03 -07:00
gpu drm/i915: enable GEM on PAE. 2009-06-19 10:29:20 +10:00
hid Driver Core: usb: add nodename support for usb drivers. 2009-06-15 21:30:25 -07:00
hwmon Merge branch 'akpm' 2009-06-16 19:50:13 -07:00
i2c Merge branch 'i2c-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging 2009-06-19 17:45:51 -07:00
ide Merge branch 'for-2.6.31' of git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6 2009-06-20 10:11:11 -07:00
idle i7300_idle: allow testing on i5000-series hardware w/o re-compile 2009-05-28 20:52:40 -04:00
ieee1394 Merge branch 'for-linus2' of git://git.kernel.org/pub/scm/linux/kernel/git/vegard/kmemcheck 2009-06-16 13:09:51 -07:00
ieee802154 ieee802154: fix kconfig bool/tristate muckup 2009-06-13 23:36:29 -07:00
infiniband infiniband: ehca: remove driver_data direct access of struct device 2009-06-15 21:30:27 -07:00
input Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input 2009-06-20 10:17:02 -07:00
isdn net: fix network drivers ndo_start_xmit() return values 2009-06-17 04:31:16 -07:00
leds [ARM] S3C24XX: GPIO: Move gpio functions out of <mach/hardware.h> 2009-05-18 16:25:40 +01:00
lguest Merge git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-lguest 2009-06-12 09:32:26 -07:00
macintosh Merge branch 'i2c-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging 2009-06-16 11:29:17 -07:00
mca
md dm: prepare for request based option 2009-06-22 10:12:35 +01:00
media soc-camera: unify i2c camera device platform data 2009-06-17 16:22:34 +09:00
memstick block: Do away with the notion of hardsect_size 2009-05-22 23:22:54 +02:00
message convert some DMA_nnBIT_MASK() callers 2009-06-19 16:46:06 -07:00
mfd Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input 2009-06-20 10:17:02 -07:00
misc gru: copyright fixes 2009-06-18 13:04:04 -07:00
mmc sdhci: remove needless double parenthesis 2009-06-21 21:01:00 +02:00
mtd Merge branch 'linux-next' of git://git.infradead.org/ubi-2.6 2009-06-17 09:48:30 -07:00
net Merge branch 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc 2009-06-19 17:40:40 -07:00
nubus
of Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6 2009-06-15 09:40:05 -07:00
oprofile oprofile: fix cpu buffer size 2009-05-07 17:28:59 +02:00
parisc parisc: remove driver_data direct access of struct device 2009-06-15 21:30:28 -07:00
parport parport: remove driver_data direct access of struct device 2009-06-15 21:30:28 -07:00
pci Fix pci_claim_resource 2009-06-17 14:04:42 -07:00
pcmcia Merge branch 'akpm' 2009-06-16 19:50:13 -07:00
platform dell-laptop: fix rfkill conversion 2009-06-15 15:05:58 -04:00
pnp Merge branch 'drm-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied/drm-2.6 2009-06-12 18:09:18 -07:00
power Merge git://git.infradead.org/battery-2.6 2009-04-08 17:45:02 -07:00
pps LinuxPPS: core support 2009-06-18 13:04:04 -07:00
ps3 drivers/ps3: Add missing annotations 2009-06-15 16:47:25 +10:00
rapidio rio: warn_unused_result warnings fix 2009-06-15 21:45:32 -05:00
regulator regulator/max1586: fix V3 gain calculation integer overflow 2009-06-15 11:18:27 +01:00
rtc rtc: make rtc_update_irq callable with irqs enabled 2009-06-19 16:46:05 -07:00
s390 Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6 2009-06-18 14:07:15 -07:00
sbus openprom: Squelch useless GCC warning. 2009-06-16 04:56:57 -07:00
scsi Merge commit 'origin/master' into next 2009-06-18 11:16:55 +10:00
serial Merge branch 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc 2009-06-19 17:40:40 -07:00
sh sh: intc: alloc_bootmem() -> kzalloc() conversion. 2009-06-12 01:34:12 +03:00
sn dma-mapping: replace all DMA_64BIT_MASK macro with DMA_BIT_MASK(64) 2009-04-07 08:31:10 -07:00
spi spi_mpc8xxx: s/83xx/8xxx/g 2009-06-19 16:46:05 -07:00
ssb SSB: BCM47xx: Export ssb_watchdog_timer_set 2009-06-08 16:57:50 +01:00
staging Staging: comedi: fix build errors 2009-06-19 11:04:32 -07:00
tc
telephony
thermal thermal: remove driver_data direct access of struct device 2009-06-15 21:30:27 -07:00
uio UIO: fix specific device driver missing statement for depmod 2009-04-16 16:17:11 -07:00
usb Merge commit 'origin/master' into next 2009-06-18 11:16:55 +10:00
uwb dma-mapping: replace all DMA_32BIT_MASK macro with DMA_BIT_MASK(32) 2009-04-07 08:31:11 -07:00
video Merge branch 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc 2009-06-19 17:40:40 -07:00
virtio virtio: enhance id_matching for virtio drivers 2009-06-12 22:16:40 +09:30
vlynq drivers: add support for the TI VLYNQ bus 2009-06-16 19:47:52 -07:00
w1 w1-gpio: add external pull-up enable callback 2009-06-18 13:03:58 -07:00
watchdog Merge branch 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc 2009-06-19 17:40:40 -07:00
xen PM core: rename suspend and resume functions 2009-06-12 21:32:31 +02:00
zorro
Kconfig LinuxPPS: core support 2009-06-18 13:04:04 -07:00
Makefile LinuxPPS: core support 2009-06-18 13:04:04 -07:00