24 Nov, 2013

1 commit

  • Immutable biovecs are going to require an explicit iterator. To
    implement immutable bvecs, a later patch is going to add a bi_bvec_done
    member to this struct; for now, this patch effectively just renames
    things.

    Signed-off-by: Kent Overstreet
    Cc: Jens Axboe
    Cc: Geert Uytterhoeven
    Cc: Benjamin Herrenschmidt
    Cc: Paul Mackerras
    Cc: "Ed L. Cashin"
    Cc: Nick Piggin
    Cc: Lars Ellenberg
    Cc: Jiri Kosina
    Cc: Matthew Wilcox
    Cc: Geoff Levand
    Cc: Yehuda Sadeh
    Cc: Sage Weil
    Cc: Alex Elder
    Cc: ceph-devel@vger.kernel.org
    Cc: Joshua Morris
    Cc: Philip Kelleher
    Cc: Rusty Russell
    Cc: "Michael S. Tsirkin"
    Cc: Konrad Rzeszutek Wilk
    Cc: Jeremy Fitzhardinge
    Cc: Neil Brown
    Cc: Alasdair Kergon
    Cc: Mike Snitzer
    Cc: dm-devel@redhat.com
    Cc: Martin Schwidefsky
    Cc: Heiko Carstens
    Cc: linux390@de.ibm.com
    Cc: Boaz Harrosh
    Cc: Benny Halevy
    Cc: "James E.J. Bottomley"
    Cc: Greg Kroah-Hartman
    Cc: "Nicholas A. Bellinger"
    Cc: Alexander Viro
    Cc: Chris Mason
    Cc: "Theodore Ts'o"
    Cc: Andreas Dilger
    Cc: Jaegeuk Kim
    Cc: Steven Whitehouse
    Cc: Dave Kleikamp
    Cc: Joern Engel
    Cc: Prasad Joshi
    Cc: Trond Myklebust
    Cc: KONISHI Ryusuke
    Cc: Mark Fasheh
    Cc: Joel Becker
    Cc: Ben Myers
    Cc: xfs@oss.sgi.com
    Cc: Steven Rostedt
    Cc: Frederic Weisbecker
    Cc: Ingo Molnar
    Cc: Len Brown
    Cc: Pavel Machek
    Cc: "Rafael J. Wysocki"
    Cc: Herton Ronaldo Krzesinski
    Cc: Ben Hutchings
    Cc: Andrew Morton
    Cc: Guo Chao
    Cc: Tejun Heo
    Cc: Asai Thambi S P
    Cc: Selvan Mani
    Cc: Sam Bradshaw
    Cc: Wei Yongjun
    Cc: "Roger Pau Monné"
    Cc: Jan Beulich
    Cc: Stefano Stabellini
    Cc: Ian Campbell
    Cc: Sebastian Ott
    Cc: Christian Borntraeger
    Cc: Minchan Kim
    Cc: Jiang Liu
    Cc: Nitin Gupta
    Cc: Jerome Marchand
    Cc: Joe Perches
    Cc: Peng Tao
    Cc: Andy Adamson
    Cc: fanchaoting
    Cc: Jie Liu
    Cc: Sunil Mushran
    Cc: "Martin K. Petersen"
    Cc: Namjae Jeon
    Cc: Pankaj Kumar
    Cc: Dan Magenheimer
    Cc: Mel Gorman 6

    Kent Overstreet
     

20 Jul, 2012

1 commit

  • This patch fixes a crash when a discard request is sent during mirror
    recovery.

    Firstly, some background. Generally, the following sequence happens during
    mirror synchronization:
    - function do_recovery is called
    - do_recovery calls dm_rh_recovery_prepare
    - dm_rh_recovery_prepare uses a semaphore to limit the number
    simultaneously recovered regions (by default the semaphore value is 1,
    so only one region at a time is recovered)
    - dm_rh_recovery_prepare calls __rh_recovery_prepare,
    __rh_recovery_prepare asks the log driver for the next region to
    recover. Then, it sets the region state to DM_RH_RECOVERING. If there
    are no pending I/Os on this region, the region is added to
    quiesced_regions list. If there are pending I/Os, the region is not
    added to any list. It is added to the quiesced_regions list later (by
    dm_rh_dec function) when all I/Os finish.
    - when the region is on quiesced_regions list, there are no I/Os in
    flight on this region. The region is popped from the list in
    dm_rh_recovery_start function. Then, a kcopyd job is started in the
    recover function.
    - when the kcopyd job finishes, recovery_complete is called. It calls
    dm_rh_recovery_end. dm_rh_recovery_end adds the region to
    recovered_regions or failed_recovered_regions list (depending on
    whether the copy operation was successful or not).

    The above mechanism assumes that if the region is in DM_RH_RECOVERING
    state, no new I/Os are started on this region. When I/O is started,
    dm_rh_inc_pending is called, which increases reg->pending count. When
    I/O is finished, dm_rh_dec is called. It decreases reg->pending count.
    If the count is zero and the region was in DM_RH_RECOVERING state,
    dm_rh_dec adds it to the quiesced_regions list.

    Consequently, if we call dm_rh_inc_pending/dm_rh_dec while the region is
    in DM_RH_RECOVERING state, it could be added to quiesced_regions list
    multiple times or it could be added to this list when kcopyd is copying
    data (it is assumed that the region is not on any list while kcopyd does
    its jobs). This results in memory corruption and crash.

    There already exist bypasses for REQ_FLUSH requests: REQ_FLUSH requests
    do not belong to any region, so they are always added to the sync list
    in do_writes. dm_rh_inc_pending does not increase count for REQ_FLUSH
    requests. In mirror_end_io, dm_rh_dec is never called for REQ_FLUSH
    requests. These bypasses avoid the crash possibility described above.

    These bypasses were improperly implemented for REQ_DISCARD when
    the mirror target gained discard support in commit
    5fc2ffeabb9ee0fc0e71ff16b49f34f0ed3d05b4 (dm raid1: support discard).

    In do_writes, REQ_DISCARD requests is always added to the sync queue and
    immediately dispatched (even if the region is in DM_RH_RECOVERING). However,
    dm_rh_inc and dm_rh_dec is called for REQ_DISCARD resusts. So it violates the
    rule that no I/Os are started on DM_RH_RECOVERING regions, and causes the list
    corruption described above.

    This patch changes it so that REQ_DISCARD requests follow the same path
    as REQ_FLUSH. This avoids the crash.

    Reference: https://bugzilla.redhat.com/837607

    Signed-off-by: Mikulas Patocka
    Cc: stable@kernel.org
    Signed-off-by: Alasdair G Kergon

    Mikulas Patocka
     

31 Mar, 2011

1 commit


10 Sep, 2010

1 commit

  • This patch converts bio-based dm to support REQ_FLUSH/FUA instead of
    now deprecated REQ_HARDBARRIER.

    * -EOPNOTSUPP handling logic dropped.

    * Preflush is handled as before but postflush is dropped and replaced
    with passing down REQ_FUA to member request_queues. This replaces
    one array wide cache flush w/ member specific FUA writes.

    * __split_and_process_bio() now calls __clone_and_map_flush() directly
    for flushes and guarantees all FLUSH bio's going to targets are zero
    ` length.

    * It's now guaranteed that all FLUSH bio's which are passed onto dm
    targets are zero length. bio_empty_barrier() tests are replaced
    with REQ_FLUSH tests.

    * Empty WRITE_BARRIERs are replaced with WRITE_FLUSHes.

    * Dropped unlikely() around REQ_FLUSH tests. Flushes are not unlikely
    enough to be marked with unlikely().

    * Block layer now filters out REQ_FLUSH/FUA bio's if the request_queue
    doesn't support cache flushing. Advertise REQ_FLUSH | REQ_FUA
    capability.

    * Request based dm isn't converted yet. dm_init_request_based_queue()
    resets flush support to 0 for now. To avoid disturbing request
    based dm code, dm->flush_error is added for bio based dm while
    requested based dm continues to use dm->barrier_error.

    Lightly tested linear, stripe, raid1, snap and crypt targets. Please
    proceed with caution as I'm not familiar with the code base.

    Signed-off-by: Tejun Heo
    Cc: dm-devel@redhat.com
    Cc: Christoph Hellwig
    Signed-off-by: Jens Axboe

    Tejun Heo
     

30 Mar, 2010

1 commit

  • …it slab.h inclusion from percpu.h

    percpu.h is included by sched.h and module.h and thus ends up being
    included when building most .c files. percpu.h includes slab.h which
    in turn includes gfp.h making everything defined by the two files
    universally available and complicating inclusion dependencies.

    percpu.h -> slab.h dependency is about to be removed. Prepare for
    this change by updating users of gfp and slab facilities include those
    headers directly instead of assuming availability. As this conversion
    needs to touch large number of source files, the following script is
    used as the basis of conversion.

    http://userweb.kernel.org/~tj/misc/slabh-sweep.py

    The script does the followings.

    * Scan files for gfp and slab usages and update includes such that
    only the necessary includes are there. ie. if only gfp is used,
    gfp.h, if slab is used, slab.h.

    * When the script inserts a new include, it looks at the include
    blocks and try to put the new include such that its order conforms
    to its surrounding. It's put in the include block which contains
    core kernel includes, in the same order that the rest are ordered -
    alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
    doesn't seem to be any matching order.

    * If the script can't find a place to put a new include (mostly
    because the file doesn't have fitting include block), it prints out
    an error message indicating which .h file needs to be added to the
    file.

    The conversion was done in the following steps.

    1. The initial automatic conversion of all .c files updated slightly
    over 4000 files, deleting around 700 includes and adding ~480 gfp.h
    and ~3000 slab.h inclusions. The script emitted errors for ~400
    files.

    2. Each error was manually checked. Some didn't need the inclusion,
    some needed manual addition while adding it to implementation .h or
    embedding .c file was more appropriate for others. This step added
    inclusions to around 150 files.

    3. The script was run again and the output was compared to the edits
    from #2 to make sure no file was left behind.

    4. Several build tests were done and a couple of problems were fixed.
    e.g. lib/decompress_*.c used malloc/free() wrappers around slab
    APIs requiring slab.h to be added manually.

    5. The script was run on all .h files but without automatically
    editing them as sprinkling gfp.h and slab.h inclusions around .h
    files could easily lead to inclusion dependency hell. Most gfp.h
    inclusion directives were ignored as stuff from gfp.h was usually
    wildly available and often used in preprocessor macros. Each
    slab.h inclusion directive was examined and added manually as
    necessary.

    6. percpu.h was updated not to include slab.h.

    7. Build test were done on the following configurations and failures
    were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
    distributed build env didn't work with gcov compiles) and a few
    more options had to be turned off depending on archs to make things
    build (like ipr on powerpc/64 which failed due to missing writeq).

    * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
    * powerpc and powerpc64 SMP allmodconfig
    * sparc and sparc64 SMP allmodconfig
    * ia64 SMP allmodconfig
    * s390 SMP allmodconfig
    * alpha SMP allmodconfig
    * um on x86_64 SMP allmodconfig

    8. percpu.h modifications were reverted so that it could be applied as
    a separate patch and serve as bisection point.

    Given the fact that I had only a couple of failures from tests on step
    6, I'm fairly confident about the coverage of this conversion patch.
    If there is a breakage, it's likely to be something in one of the arch
    headers which should be easily discoverable easily on most builds of
    the specific arch.

    Signed-off-by: Tejun Heo <tj@kernel.org>
    Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>

    Tejun Heo
     

17 Feb, 2010

1 commit

  • When suspending a failed mirror, bios are completed by mirror_end_io() and
    __rh_lookup() in dm_rh_dec() returns NULL where a non-NULL return value is
    required by design. Fix this by not changing the state of the recovery failed
    region from DM_RH_RECOVERING to DM_RH_NOSYNC in dm_rh_recovery_end().

    Issue

    On 2.6.33-rc1 kernel, I hit the bug when I suspended the failed
    mirror by dmsetup command.

    BUG: unable to handle kernel NULL pointer dereference at 00000020
    IP: [] dm_rh_dec+0x35/0xa1 [dm_region_hash]
    ...
    EIP: 0060:[] EFLAGS: 00010046 CPU: 0
    EIP is at dm_rh_dec+0x35/0xa1 [dm_region_hash]
    EAX: 00000286 EBX: 00000000 ECX: 00000286 EDX: 00000000
    ESI: eff79eac EDI: eff79e80 EBP: f6915cd4 ESP: f6915cc4
    DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
    Process dmsetup (pid: 2849, ti=f6914000 task=eff03e80 task.ti=f6914000)
    ...
    Call Trace:
    [] ? mirror_end_io+0x53/0x1b1 [dm_mirror]
    [] ? clone_endio+0x4d/0xa2 [dm_mod]
    [] ? mirror_end_io+0x0/0x1b1 [dm_mirror]
    [] ? clone_endio+0x0/0xa2 [dm_mod]
    [] ? bio_endio+0x28/0x2b
    [] ? hold_bio+0x2d/0x62 [dm_mirror]
    [] ? mirror_presuspend+0xeb/0xf7 [dm_mirror]
    [] ? vmap_page_range+0xb/0xd
    [] ? suspend_targets+0x2d/0x3b [dm_mod]
    [] ? dm_table_presuspend_targets+0xe/0x10 [dm_mod]
    [] ? dm_suspend+0x4d/0x150 [dm_mod]
    [] ? dev_suspend+0x55/0x18a [dm_mod]
    [] ? _copy_from_user+0x42/0x56
    [] ? dm_ctl_ioctl+0x22c/0x281 [dm_mod]
    [] ? dev_suspend+0x0/0x18a [dm_mod]
    [] ? dm_ctl_ioctl+0x0/0x281 [dm_mod]
    [] ? vfs_ioctl+0x22/0x85
    [] ? do_vfs_ioctl+0x4cb/0x516
    [] ? sys_ioctl+0x40/0x5a
    [] ? sysenter_do_call+0x12/0x28

    Analysis

    When recovery process of a region failed, dm_rh_recovery_end() function
    changes the state of the region from RM_RH_RECOVERING to DM_RH_NOSYNC.
    When recovery_complete() is executed between dm_rh_update_states() and
    dm_writes() in do_mirror(), bios are processed with the region state,
    DM_RH_NOSYNC. However, the region data is freed without checking its
    pending count when dm_rh_update_states() is called next time.

    When bios are finished by mirror_end_io(), __rh_lookup() in dm_rh_dec()
    returns NULL even though a valid return value are expected.

    Solution

    Remove the state change of the recovery failed region from DM_RH_RECOVERING
    to DM_RH_NOSYNC in dm_rh_recovery_end(). We can remove the state change
    because:

    - If the region data has been released by dm_rh_update_states(),
    a new region data is created with the state of DM_RH_NOSYNC, and
    bios are processed according to the DM_RH_NOSYNC state.

    - If the region data has not been released by dm_rh_update_states(),
    a state of the region is DM_RH_RECOVERING and bios are put in the
    delayed_bio list.

    The flag change from DM_RH_RECOVERING to DM_RH_NOSYNC in dm_rh_recovery_end()
    was added in the following commit:
    dm raid1: handle resync failures
    author Jonathan Brassow
    Thu, 12 Jul 2007 16:29:04 +0000 (17:29 +0100)
    http://git.kernel.org/linus/f44db678edcc6f4c2779ac43f63f0b9dfa28b724

    Signed-off-by: Takahiro Yasui
    Reviewed-by: Mikulas Patocka
    Signed-off-by: Alasdair G Kergon

    Takahiro Yasui
     

11 Dec, 2009

2 commits


22 Jun, 2009

1 commit

  • If the code can't handle allocation failures, use __GFP_NOFAIL so that
    in case of memory pressure the allocator will retry indefinitely and
    won't return NULL which would cause a crash in the function.

    This is still not a correct fix, it may cause a classic deadlock when
    memory manager waits for I/O being done and I/O waits for some free memory.
    I/O code shouldn't allocate any memory. But in this case it probably
    doesn't matter much in practice, people usually do not swap on RAID.

    Signed-off-by: Mikulas Patocka
    Signed-off-by: Alasdair G Kergon

    Mikulas Patocka
     

15 Apr, 2009

1 commit


22 Oct, 2008

1 commit