1. 17 2月, 2010 7 次提交
    • A
      dm: sysfs revert add empty release function to avoid debug warning · 9307f6b1
      Alasdair G Kergon 提交于
      Revert commit d2bb7df8 at Greg's request.
      
          Author: Milan Broz <mbroz@redhat.com>
          Date:   Thu Dec 10 23:51:53 2009 +0000
      
          dm: sysfs add empty release function to avoid debug warning
      
          This patch just removes an unnecessary warning:
           kobject: 'dm': does not have a release() function,
           it is broken and must be fixed.
      
          The kobject is embedded in mapped device struct, so
          code does not need to release memory explicitly here.
      
      Cc: Greg KH <gregkh@suse.de>
      Signed-off-by: NAlasdair G Kergon <agk@redhat.com>
      9307f6b1
    • K
      dm mpath: fix stall when requeueing io · 9eef87da
      Kiyoshi Ueda 提交于
      This patch fixes the problem that system may stall if target's ->map_rq
      returns DM_MAPIO_REQUEUE in map_request().
      E.g. stall happens on 1 CPU box when a dm-mpath device with queue_if_no_path
           bounces between all-paths-down and paths-up on I/O load.
      
      When target's ->map_rq returns DM_MAPIO_REQUEUE, map_request() requeues
      the request and returns to dm_request_fn().  Then, dm_request_fn()
      doesn't exit the I/O dispatching loop and continues processing
      the requeued request again.
      This map and requeue loop can be done with interrupt disabled,
      so 1 CPU system can be stalled if this situation happens.
      
      For example, commands below can stall my 1 CPU box within 1 minute or so:
        # dmsetup table mp
        mp: 0 2097152 multipath 1 queue_if_no_path 0 1 1 service-time 0 1 2 8:144 1 1
        # while true; do dd if=/dev/mapper/mp of=/dev/null bs=1M count=100; done &
        # while true; do \
        > dmsetup message mp 0 "fail_path 8:144" \
        > dmsetup suspend --noflush mp \
        > dmsetup resume mp \
        > dmsetup message mp 0 "reinstate_path 8:144" \
        > done
      
      To fix the problem above, this patch changes dm_request_fn() to exit
      the I/O dispatching loop once if a request is requeued in map_request().
      Signed-off-by: NKiyoshi Ueda <k-ueda@ct.jp.nec.com>
      Signed-off-by: NJun'ichi Nomura <j-nomura@ce.jp.nec.com>
      Cc: stable@kernel.org
      Signed-off-by: NAlasdair G Kergon <agk@redhat.com>
      9eef87da
    • T
      dm raid1: fix null pointer dereference in suspend · 558569aa
      Takahiro Yasui 提交于
      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: [<f94f38e2>] dm_rh_dec+0x35/0xa1 [dm_region_hash]
      ...
      EIP: 0060:[<f94f38e2>] 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:
       [<f9530af6>] ? mirror_end_io+0x53/0x1b1 [dm_mirror]
       [<f9413104>] ? clone_endio+0x4d/0xa2 [dm_mod]
       [<f9530aa3>] ? mirror_end_io+0x0/0x1b1 [dm_mirror]
       [<f94130b7>] ? clone_endio+0x0/0xa2 [dm_mod]
       [<c02d6bcb>] ? bio_endio+0x28/0x2b
       [<f952f303>] ? hold_bio+0x2d/0x62 [dm_mirror]
       [<f952f942>] ? mirror_presuspend+0xeb/0xf7 [dm_mirror]
       [<c02aa3e2>] ? vmap_page_range+0xb/0xd
       [<f9414c8d>] ? suspend_targets+0x2d/0x3b [dm_mod]
       [<f9414ca9>] ? dm_table_presuspend_targets+0xe/0x10 [dm_mod]
       [<f941456f>] ? dm_suspend+0x4d/0x150 [dm_mod]
       [<f941767d>] ? dev_suspend+0x55/0x18a [dm_mod]
       [<c0343762>] ? _copy_from_user+0x42/0x56
       [<f9417fb0>] ? dm_ctl_ioctl+0x22c/0x281 [dm_mod]
       [<f9417628>] ? dev_suspend+0x0/0x18a [dm_mod]
       [<f9417d84>] ? dm_ctl_ioctl+0x0/0x281 [dm_mod]
       [<c02c3c4b>] ? vfs_ioctl+0x22/0x85
       [<c02c422c>] ? do_vfs_ioctl+0x4cb/0x516
       [<c02c42b7>] ? sys_ioctl+0x40/0x5a
       [<c0202858>] ? 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 <jbrassow@redhat.com>
          Thu, 12 Jul 2007 16:29:04 +0000 (17:29 +0100)
        http://git.kernel.org/linus/f44db678edcc6f4c2779ac43f63f0b9dfa28b724Signed-off-by: NTakahiro Yasui <tyasui@redhat.com>
      Reviewed-by: NMikulas Patocka <mpatocka@redhat.com>
      Signed-off-by: NAlasdair G Kergon <agk@redhat.com>
      558569aa
    • M
      dm raid1: fail writes if errors are not handled and log fails · 5528d17d
      Mikulas Patocka 提交于
      If the mirror log fails when the handle_errors option was not selected
      and there is no remaining valid mirror leg, writes return success even
      though they weren't actually written to any device.  This patch
      completes them with EIO instead.
      
      This code path is taken:
      do_writes:
      	bio_list_merge(&ms->failures, &sync);
      do_failures:
      	if (!get_valid_mirror(ms)) (false)
      	else if (errors_handled(ms)) (false)
      	else bio_endio(bio, 0);
      
      The logic in do_failures is based on presuming that the write was already
      tried: if it succeeded at least on one leg (without handle_errors) it
      is reported as success.
      
      Reference: https://bugzilla.redhat.com/show_bug.cgi?id=555197Signed-off-by: NMikulas Patocka <mpatocka@redhat.com>
      Signed-off-by: NAlasdair G Kergon <agk@redhat.com>
      5528d17d
    • J
      dm log: userspace fix overhead_size calcuations · ebfd32bb
      Jonathan Brassow 提交于
      This patch fixes two bugs that revolve around the miscalculation and
      misuse of the variable 'overhead_size'.  'overhead_size' is the size of
      the various header structures used during communication.
      
      The first bug is the use of 'sizeof' with the pointer of a structure
      instead of the structure itself - resulting in the wrong size being
      computed.  This is then used in a check to see if the payload
      (data_size) would be to large for the preallocated structure.  Since the
      bug produces a smaller value for the overhead, it was possible for the
      structure to be breached.  (Although the current users of the code do
      not currently send enough data to trigger this bug.)
      
      The second bug is that the 'overhead_size' value is used to compute how
      much of the preallocated space should be cleared before populating it
      with fresh data.  This should have simply been 'sizeof(struct cn_msg)'
      not overhead_size.  The fact that 'overhead_size' was computed
      incorrectly made this problem "less bad" - leaving only a pointer's
      worth of space at the end uncleared.  Thus, this bug was never producing
      a bad result, but still needs to be fixed - especially now that the
      value is computed correctly.
      
      Cc: stable@kernel.org
      Signed-off-by: Jonathan Brassow <jbrassow@redhat.com
      Signed-off-by: NAlasdair G Kergon <agk@redhat.com>
      ebfd32bb
    • M
      dm snapshot: persistent annotate work_queue as on stack · 55f67f2d
      Mike Snitzer 提交于
      chunk_io() declares its 'struct mdata_req' on the stack and then
      initializes its 'struct work_struct' member.  Annotate the
      initialization of this workqueue with INIT_WORK_ON_STACK to suppress a
      debugobjects warning seen when CONFIG_DEBUG_OBJECTS_WORK is enabled.
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      Signed-off-by: NAlasdair G Kergon <agk@redhat.com>
      55f67f2d
    • N
      dm stripe: avoid divide by zero with invalid stripe count · 781248c1
      Nikanth Karthikesan 提交于
      If a table containing zero as stripe count is passed into stripe_ctr
      the code attempts to divide by zero.
      
      This patch changes DM_TABLE_LOAD to return -EINVAL if the stripe count
      is zero.
      
      We now get the following error messages:
        device-mapper: table: 253:0: striped: Invalid stripe count
        device-mapper: ioctl: error adding target to table
      Signed-off-by: NNikanth Karthikesan <knikanth@suse.de>
      Cc: stable@kernel.org
      Signed-off-by: NAlasdair G Kergon <agk@redhat.com>
      781248c1
  2. 10 2月, 2010 1 次提交
    • N
      md: fix some lockdep issues between md and sysfs. · ef286f6f
      NeilBrown 提交于
      ======
      This fix is related to
          http://bugzilla.kernel.org/show_bug.cgi?id=15142
      but does not address that exact issue.
      ======
      
      sysfs does like attributes being removed while they are being accessed
      (i.e. read or written) and waits for the access to complete.
      
      As accessing some md attributes takes the same lock that is held while
      removing those attributes a deadlock can occur.
      
      This patch addresses 3 issues in md that could lead to this deadlock.
      
      Two relate to calling flush_scheduled_work while the lock is held.
      This is probably a bad idea in general and as we use schedule_work to
      delete various sysfs objects it is particularly bad.
      
      In one case flush_scheduled_work is called from md_alloc (called by
      md_probe) called from do_md_run which holds the lock.  This call is
      only present to ensure that ->gendisk is set.  However we can be sure
      that gendisk is always set (though possibly we couldn't when that code
      was originally written.  This is because do_md_run is called in three
      different contexts:
        1/ from md_ioctl.  This requires that md_open has succeeded, and it
           fails if ->gendisk is not set.
        2/ from writing a sysfs attribute.  This can only happen if the
           mddev has been registered in sysfs which happens in md_alloc
           after ->gendisk has been set.
        3/ from autorun_array which is only called by autorun_devices, which
           checks for ->gendisk to be set before calling autorun_array.
      So the call to md_probe in do_md_run can be removed, and the check on
      ->gendisk can also go.
      
      
      In the other case flush_scheduled_work is being called in do_md_stop,
      purportedly to wait for all md_delayed_delete calls (which delete the
      component rdevs) to complete.  However there really isn't any need to
      wait for them - they have already been disconnected in all important
      ways.
      
      The third issue is that raid5->stop() removes some attribute names
      while the lock is held.  There is already some infrastructure in place
      to delay attribute removal until after the lock is released (using
      schedule_work).  So extend that infrastructure to remove the
      raid5_attrs_group.
      
      This does not address all lockdep issues related to the sysfs
      "s_active" lock.  The rest can be address by splitting that lockdep
      context between symlinks and non-symlinks which hopefully will happen.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      ef286f6f
  3. 09 2月, 2010 1 次提交
    • N
      md: fix 'degraded' calculation when starting a reshape. · 9eb07c25
      NeilBrown 提交于
      This code was written long ago when it was not possible to
      reshape a degraded array.  Now it is so the current level of
      degraded-ness needs to be taken in to account.  Also newly addded
      devices should only reduce degradedness if they are deemed to be
      in-sync.
      
      In particular, if you convert a RAID5 to a RAID6, and increase the
      number of devices at the same time, then the 5->6 conversion will
      make the array degraded so the current code will produce a wrong
      value for 'degraded' - "-1" to be precise.
      
      If the reshape runs to completion end_reshape will calculate a correct
      new value for 'degraded', but if a device fails during the reshape an
      incorrect decision might be made based on the incorrect value of
      "degraded".
      
      This patch is suitable for 2.6.32-stable and if they are still open,
      2.6.31-stable and 2.6.30-stable as well.
      
      Cc: stable@kernel.org
      Reported-by: NMichael Evans <mjevans1983@gmail.com>
      Signed-off-by: NNeilBrown <neilb@suse.de>
      9eb07c25
  4. 11 1月, 2010 1 次提交
  5. 30 12月, 2009 5 次提交
    • N
      md: allow a resync that is waiting for other resync to complete, to be aborted. · 404e4b43
      NeilBrown 提交于
      If two arrays share a device, then they will not both resync at the
      same time.  One will wait for the other to complete.
      While waiting, the MD_RECOVERY_INTR flag is not checked so a device
      failure, which would make the resync pointless, does not cause the
      resync to abort, so the failed device cannot be removed (as it cannot
      be remove while a resync is happening).
      
      So add a test for MD_RECOVERY_INTR.
      Reported-by: NBrett Russ <bruss@netezza.com>
      Signed-off-by: NNeilBrown <neilb@suse.de>
      404e4b43
    • N
      md: remove unnecessary code from do_md_run · 7fb9dadc
      NeilBrown 提交于
      Since commit dfc70645,
      ->hot_remove_disks has not removed non-failed devices from
      an array until recovery is no longer possible.
      So the code in do_md_run to get around the fact that
      md_check_recovery (which calls ->hot_remove_disks) would
      remove partially-in-sync devices is no longer needed.
      
      So remove it.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      7fb9dadc
    • D
      md: make recovery started by do_md_run() visible via sync_action · a2d79c32
      Dan Williams 提交于
      By default md_do_sync() will perform recovery if no other actions are
      specified.  However, action_show() relies on MD_RECOVERY_RECOVER to be
      set otherwise it returns 'idle'.  So, add a missing set
      MD_RECOVERY_RECOVER when starting recovery.
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Signed-off-by: NNeilBrown <neilb@suse.de>
      a2d79c32
    • N
      md: fix small irregularity with start_ro module parameter · 0f9552b5
      NeilBrown 提交于
      The start_ro modules parameter can be used to force arrays to be
      started in 'auto-readonly' in which they are read-only until the first
      write.  This ensures that no resync/recovery happens until something
      else writes to the device.  This is important for resume-from-disk
      off an md array.
      
      However if an array is started 'readonly' (by writing 'readonly' to
      the 'array_state' sysfs attribute) we want it to be really 'readonly',
      not 'auto-readonly'.
      
      So strengthen the condition to only set auto-readonly if the
      array is not already read-only.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      0f9552b5
    • N
      md: Fix unfortunate interaction with evms · cbd19983
      NeilBrown 提交于
      evms configures md arrays by:
        open device
        send ioctl
        close device
      
      for each different ioctl needed.
      Since 2.6.29, the device can disappear after the 'close'
      unless a significant configuration has happened to the device.
      The change made by "SET_ARRAY_INFO" can too minor to stop the device
      from disappearing, but important enough that losing the change is bad.
      
      So: make sure SET_ARRAY_INFO sets mddev->ctime, and keep the device
      active as long as ctime is non-zero (it gets zeroed with lots of other
      things when the array is stopped).
      
      This is suitable for -stable kernels since 2.6.29.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      Cc: stable@kernel.org
      cbd19983
  6. 16 12月, 2009 2 次提交
    • J
      drivers/md/md.c: use %pU to print UUIDs · 7b75c2f8
      Joe Perches 提交于
      Signed-off-by: NJoe Perches <joe@perches.com>
      Cc: Neil Brown <neilb@suse.de>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      7b75c2f8
    • A
      tree-wide: convert open calls to remove spaces to skip_spaces() lib function · e7d2860b
      André Goddard Rosa 提交于
      Makes use of skip_spaces() defined in lib/string.c for removing leading
      spaces from strings all over the tree.
      
      It decreases lib.a code size by 47 bytes and reuses the function tree-wide:
         text    data     bss     dec     hex filename
        64688     584     592   65864   10148 (TOTALS-BEFORE)
        64641     584     592   65817   10119 (TOTALS-AFTER)
      
      Also, while at it, if we see (*str && isspace(*str)), we can be sure to
      remove the first condition (*str) as the second one (isspace(*str)) also
      evaluates to 0 whenever *str == 0, making it redundant. In other words,
      "a char equals zero is never a space".
      
      Julia Lawall tried the semantic patch (http://coccinelle.lip6.fr) below,
      and found occurrences of this pattern on 3 more files:
          drivers/leds/led-class.c
          drivers/leds/ledtrig-timer.c
          drivers/video/output.c
      
      @@
      expression str;
      @@
      
      ( // ignore skip_spaces cases
      while (*str &&  isspace(*str)) { \(str++;\|++str;\) }
      |
      - *str &&
      isspace(*str)
      )
      Signed-off-by: NAndré Goddard Rosa <andre.goddard@gmail.com>
      Cc: Julia Lawall <julia@diku.dk>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Jeff Dike <jdike@addtoit.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Richard Purdie <rpurdie@rpsys.net>
      Cc: Neil Brown <neilb@suse.de>
      Cc: Kyle McMartin <kyle@mcmartin.ca>
      Cc: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
      Cc: David Howells <dhowells@redhat.com>
      Cc: <linux-ext4@vger.kernel.org>
      Cc: Samuel Ortiz <samuel@sortiz.org>
      Cc: Patrick McHardy <kaber@trash.net>
      Cc: Takashi Iwai <tiwai@suse.de>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      e7d2860b
  7. 14 12月, 2009 23 次提交
    • D
      md: add 'recovery_start' per-device sysfs attribute · 06e3c817
      Dan Williams 提交于
      Enable external metadata arrays to manage rebuild checkpointing via a
      md/dev-XXX/recovery_start attribute which reflects rdev->recovery_offset
      
      Also update resync_start_store to allow 'none' to be written, for
      consistency.
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Signed-off-by: NNeilBrown <neilb@suse.de>
      06e3c817
    • D
      md: rcu_read_lock() walk of mddev->disks in md_do_sync() · 4e59ca7d
      Dan Williams 提交于
      Other walks of this list are either under rcu_read_lock() or the list
      mutation lock (mddev_lock()).  This protects against the improbable case of a
      disk being removed from the array at the start of md_do_sync().
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      4e59ca7d
    • N
      md: integrate spares into array at earliest opportunity. · 93be75ff
      NeilBrown 提交于
      As v1.x metadata can record that a member of the array is
      not completely recovered, it make sense to record that a
      spare has become a regular member of the array at the earliest
      opportunity.
      So remove the tests on "recovery_offset > 0" in super_1_sync
      as they really aren't needed, and schedule a metadata update
      immediately after adding spares to a degraded array.
      
      This means that if a crash happens immediately after a recovery
      starts, the new device will be included in the array and recovery will
      continue from wherever it was up to.  Previously this didn't happen
      unless recovery was at least 1/16 of the way through.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      93be75ff
    • A
      md: move compat_ioctl handling into md.c · aa98aa31
      Arnd Bergmann 提交于
      The RAID ioctls are only implemented in md.c, so the
      handling for them should also be moved there from
      fs/compat_ioctl.c.
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Cc: Neil Brown <neilb@suse.de>
      Cc: Andre Noll <maan@systemlinux.org>
      Cc: linux-raid@vger.kernel.org
      Signed-off-by: NNeilBrown <neilb@suse.de>
      aa98aa31
    • N
      md: revise Kconfig help for MD_MULTIPATH · 93bd89a6
      NeilBrown 提交于
      Make it clear in the config message that MD_MULTIPATH is not under
      active development.
      
      Cc: Oren Held <orenhe@il.ibm.com>
      Signed-off-by: NNeilBrown <neilb@suse.de>
      93bd89a6
    • N
      md: add MODULE_DESCRIPTION for all md related modules. · 0efb9e61
      NeilBrown 提交于
      Suggested by  Oren Held <orenhe@il.ibm.com>
      Signed-off-by: NNeilBrown <neilb@suse.de>
      0efb9e61
    • R
      raid: improve MD/raid10 handling of correctable read errors. · 1e50915f
      Robert Becker 提交于
      We've noticed severe lasting performance degradation of our raid
      arrays when we have drives that yield large amounts of media errors.
      The raid10 module will queue each failed read for retry, and also
      will attempt call fix_read_error() to perform the read recovery.
      Read recovery is performed while the array is frozen, so repeated
      recovery attempts can degrade the performance of the array for
      extended periods of time.
      
      With this patch I propose adding a per md device max number of
      corrected read attempts.  Each rdev will maintain a count of
      read correction attempts in the rdev->read_errors field (not
      used currently for raid10). When we enter fix_read_error()
      we'll check to see when the last read error occurred, and
      divide the read error count by 2 for every hour since the
      last read error. If at that point our read error count
      exceeds the read error threshold, we'll fail the raid device.
      
      In addition in this patch I add sysfs nodes (get/set) for
      the per md max_read_errors attribute, the rdev->read_errors
      attribute, and added some printk's to indicate when
      fix_read_error fails to repair an rdev.
      
      For testing I used debugfs->fail_make_request to inject
      IO errors to the rdev while doing IO to the raid array.
      Signed-off-by: NRobert Becker <Rob.Becker@riverbed.com>
      Signed-off-by: NNeilBrown <neilb@suse.de>
      1e50915f
    • R
      md/raid10: print more useful messages on device failure. · 67b8dc4b
      Robert Becker 提交于
      When we get a read error on a device in a RAID10, and attempting to
      repair the error fails, print more useful messages about why it
      failed.
      Signed-off-by: NRobert Becker <Rob.Becker@riverbed.com>
      Signed-off-by: NNeilBrown <neilb@suse.de>
      67b8dc4b
    • N
      md/bitmap: update dirty flag when bitmap bits are explicitly set. · ffa23322
      NeilBrown 提交于
      There is a sysfs file which allows bits in the write-intent
      bitmap to be explicit set - indicating that the block is thought
      to be 'dirty'.
      When this happens we should really set recovery_cp backwards
      to include the block to reflect this dirtiness.
      
      In particular, a 'resync' process will refuse to start if
      recovery_cp is beyond the end of the array, so this is needed
      to allow a resync to be triggered.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      ffa23322
    • N
      md: Support write-intent bitmaps with externally managed metadata. · ece5cff0
      NeilBrown 提交于
      In this case, the metadata needs to not be in the same
      sector as the bitmap.
      md will not read/write any bitmap metadata.  Config must be
      done via sysfs and when a recovery makes the array non-degraded
      again, writing 'true' to 'bitmap/can_clear' will allow bits in
      the bitmap to be cleared again.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      ece5cff0
    • N
      md/bitmap: move setting of daemon_lastrun out of bitmap_read_sb · 624ce4f5
      NeilBrown 提交于
      Setting daemon_lastrun really has nothing to do with reading
      the bitmap superblock, it just happens to be needed at the same time.
      bitmap_read_sb is about to become options, so move that code out
      to after the call to bitmap_read_sb.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      624ce4f5
    • N
      md: support updating bitmap parameters via sysfs. · 43a70507
      NeilBrown 提交于
      A new attribute directory 'bitmap' in 'md' is created which
      contains files for configuring the bitmap.
      'location' identifies where the bitmap is, either 'none',
      or 'file' or 'sector offset from metadata'.
      Writing 'location' can create or remove a bitmap.
      Adding a 'file' bitmap this way is not yet supported.
      'chunksize' and 'time_base' must be set before 'location'
      can be set.
      
      'chunksize' can be set before creating a bitmap, but is
      currently always over-ridden by the bitmap superblock.
      
      'time_base' and 'backlog' can be updated at any time.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      Reviewed-by: NAndre Noll <maan@systemlinux.org>
      43a70507
    • N
      md: factor out parsing of fixed-point numbers · 72e02075
      NeilBrown 提交于
      safe_delay_store can parse fixed point numbers (for fractions
      of a second).  We will want to do that for another sysfs
      file soon, so factor out the code.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      72e02075
    • N
      md: support bitmap offset appropriate for external-metadata arrays. · f6af949c
      NeilBrown 提交于
      For md arrays were metadata is managed externally, the kernel does not
      know about a superblock so the superblock offset is 0.
      If we want to have a write-intent-bitmap near the end of the
      devices of such an array, we should support sector_t sized offset.
      We need offset be possibly negative for when the bitmap is before
      the metadata, so use loff_t instead.
      
      Also add sanity check that bitmap does not overlap with data.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      f6af949c
    • N
      md: remove needless setting of thread->timeout in raid10_quiesce · 9cd30fdc
      NeilBrown 提交于
      As bitmap_create and bitmap_destroy already set thread->timeout
      as appropriate, there is no need to do it in raid10_quiesce.
      There is a possible need to wake the thread after the timeout
      has been set low, but it is better to do that where the timeout
      is actually set low, in bitmap_create.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      9cd30fdc
    • N
      md: change daemon_sleep to be in 'jiffies' rather than 'seconds'. · 1b04be96
      NeilBrown 提交于
      This removes a lot of multiplications by HZ.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      1b04be96
    • N
      md: move offset, daemon_sleep and chunksize out of bitmap structure · 42a04b50
      NeilBrown 提交于
      ... and into bitmap_info.  These are all configuration parameters
      that need to be set before the bitmap is created.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      42a04b50
    • N
      md: collect bitmap-specific fields into one structure. · c3d9714e
      NeilBrown 提交于
      In preparation for making bitmap fields configurable via sysfs,
      start tidying up by making a single structure to contain the
      configuration fields.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      c3d9714e
    • N
      md/raid1: add takeover support for raid5->raid1 · 709ae487
      NeilBrown 提交于
      A 2-device raid5 array can now be converted to raid1.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      709ae487
    • N
      md: add honouring of suspend_{lo,hi} to raid1. · 6eef4b21
      NeilBrown 提交于
      This will allow us to stop writeout to portions of the array
      while  they are resynced by someone else - e.g. another node in
      a cluster.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      6eef4b21
    • N
      md/raid5: don't complete make_request on barrier until writes are scheduled · 729a1866
      NeilBrown 提交于
      The post-barrier-flush is sent by md as soon as make_request on the
      barrier write completes.  For raid5, the data might not be in the
      per-device queues yet.  So for barrier requests, wait for any
      pre-reading to be done so that the request will be in the per-device
      queues.
      
      We use the 'preread_active' count to check that nothing is still in
      the preread phase, and delay the decrement of this count until after
      write requests have been submitted to the underlying devices.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      729a1866
    • N
      md: support barrier requests on all personalities. · a2826aa9
      NeilBrown 提交于
      Previously barriers were only supported on RAID1.  This is because
      other levels requires synchronisation across all devices and so needed
      a different approach.
      Here is that approach.
      
      When a barrier arrives, we send a zero-length barrier to every active
      device.  When that completes - and if the original request was not
      empty -  we submit the barrier request itself (with the barrier flag
      cleared) and then submit a fresh load of zero length barriers.
      
      The barrier request itself is asynchronous, but any subsequent
      request will block until the barrier completes.
      
      The reason for clearing the barrier flag is that a barrier request is
      allowed to fail.  If we pass a non-empty barrier through a striping
      raid level it is conceivable that part of it could succeed and part
      could fail.  That would be way too hard to deal with.
      So if the first run of zero length barriers succeed, we assume all is
      sufficiently well that we send the request and ignore errors in the
      second run of barriers.
      
      RAID5 needs extra care as write requests may not have been submitted
      to the underlying devices yet.  So we flush the stripe cache before
      proceeding with the barrier.
      
      Note that the second set of zero-length barriers are submitted
      immediately after the original request is submitted.  Thus when
      a personality finds mddev->barrier to be set during make_request,
      it should not return from make_request until the corresponding
      per-device request(s) have been queued.
      
      That will be done in later patches.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      Reviewed-by: NAndre Noll <maan@systemlinux.org>
      a2826aa9
    • N
      md: don't reset curr_resync_completed after an interrupted resync · efa59339
      NeilBrown 提交于
      If a resync/recovery/check/repair is interrupted for some reason, it
      can be useful to know exactly where it got up to.
      So in that case, do not clear curr_resync_completed.
      Initialise it when starting a resync/recovery/... instead.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      efa59339