1. 13 6月, 2013 1 次提交
  2. 30 4月, 2013 1 次提交
    • N
      md: bad block list should default to disabled. · 486adf72
      NeilBrown 提交于
      Maintenance of a bad-block-list currently defaults to 'enabled'
      and is then disabled when it cannot be supported.
      This is backwards and causes problem for dm-raid which didn't know
      to disable it.
      
      So fix the defaults, and only enabled for v1.x metadata which
      explicitly has bad blocks enabled.
      
      The problem with dm-raid has been present since badblock support was
      added in v3.1, so this patch is suitable for any -stable from 3.1
      onwards.
      
      Cc: stable@vger.kernel.org (3.1+)
      Reported-by: NJonathan Brassow <jbrassow@redhat.com>
      Signed-off-by: NNeilBrown <neilb@suse.de>
      486adf72
  3. 24 4月, 2013 6 次提交
    • J
      MD: Export 'md_reap_sync_thread' function · a91d5ac0
      Jonathan Brassow 提交于
      MD: Export 'md_reap_sync_thread' function
      
      Make 'md_reap_sync_thread' available to other files, specifically dm-raid.c.
      - rename reap_sync_thread to md_reap_sync_thread
      - move the fn after md_check_recovery to match md.h declaration placement
      - export md_reap_sync_thread
      Signed-off-by: NJonathan Brassow <jbrassow@redhat.com>
      Signed-off-by: NNeilBrown <neilb@suse.de>
      a91d5ac0
    • N
      md: don't update metadata when stopping a read-only array. · b6d428c6
      NeilBrown 提交于
      read-only arrays should stay that way as much as possible.
      Updating the metadata - which could be triggered by a re-add
      while assembling the array metadata - should be avoided.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      b6d428c6
    • N
      md: Allow devices to be re-added to a read-only array. · 7ceb17e8
      NeilBrown 提交于
      When assembling an array incrementally we might want to make
      it device available when "enough" devices are present, but maybe
      not "all" devices are present.
      If the remaining devices appear before the array is actually used,
      they should be added transparently.
      
      We do this by using the "read-auto" mode where the array acts like
      it is read-only until a write request arrives.
      
      Current an add-device request switches a read-auto array to active.
      This means that only one device can be added after the array is first
      made read-auto.  This isn't a problem for RAID5, but is not ideal for
      RAID6 or RAID10.
      Also we don't really want to switch the array to read-auto at all
      when re-adding a device as this doesn't really imply any change.
      
      So:
       - remove the "md_update_sb()" call from add_new_disk().  This isn't
         really needed as just adding a disk doesn't require a metadata
         update.  Instead, just set MD_CHANGE_DEVS.  This will effect a
         metadata update soon enough, once the array is not read-only.
      
       - Allow the ADD_NEW_DISK ioctl to succeed without activating a
         read-auto array, providing the MD_DISK_SYNC flag is set.
         In this case, the device will be rejected if it cannot be added
         with the correct device number, or has an incorrect event count.
      
       - Teach remove_and_add_spares() to be careful about adding spares
         when the array is read-only (or read-mostly) - only add devices
         that are thought to be in-sync, and only do it if the array is
         in-sync itself.
      
       - In md_check_recovery, use remove_and_add_spares in the read-only
         case, rather than open coding just the 'remove' part of it.
      Reported-by: NMartin Wilck <mwilck@arcor.de>
      Signed-off-by: NNeilBrown <neilb@suse.de>
      7ceb17e8
    • N
      md: HOT_DISK_REMOVE shouldn't make a read-auto device active. · 3ea8929d
      NeilBrown 提交于
      If a fail device or a spare is removed from an array, there is
      not need to make the array 'active'.  If/when the array does become
      active for some other reason the metadata will be update to reflect
      the removal.
      If that never happens and the array is stopped while still read-auto,
      then there is no loss in forgetting the that the device had 'failed'.
      
      A read-only array will leave failed devices attached to
      the array personality, so we need to explicitly call
      remove_and_add_spares() to free it (clearing Blocked just
      like we do in store_slot()).
      Signed-off-by: NNeilBrown <neilb@suse.de>
      3ea8929d
    • N
      md: use common code for all calls to ->hot_remove_disk() · 746d3207
      NeilBrown 提交于
      slot_store and remove_and_add_spares both call ->hot_remove_disk(),
      but with slightly different tests and consequences, which is
      at least untidy and might be buggy.
      
      So modify remove_and_add_spaces() so that it can be asked
      to remove a specific device, and call it from slot_store().
      
      We also clear the Blocked flag to ensure that doesn't prevent
      removal.  The purpose of Blocked is to prevent automatic removal
      by the kernel before an error is acknowledged.
      If the array is read/write then user-space would have not reason
      to remove a device unless it was known to be 'spare' or 'faulty' in
      which it would have already cleared the Blocked flag.
      If the array is read-only, the flag might still be blocked, but
      there is no harm in clearing the flag for read-only arrays.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      746d3207
    • N
      md: never update metadata when array is read-only. · d87f064f
      NeilBrown 提交于
      Normally we don't even try to update the metadata if
      the array is read-only.  However future patches
      will increase the number of things that can happen on a read-only
      array, so it is safest to explicitly disable this.
      
      Every time that mddev->ro is set to 0, either
       - md_update_sb will be called again (at least if MD_CHANGE_DEVS
         is set) or
       - the mddev->thread is scheduled, which will also run
         md_update_sb if needed.
      
      So this is safe: if the array ever become read-write the
      metadata will be updated.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      d87f064f
  4. 20 3月, 2013 1 次提交
    • J
      MD: Prevent sysfs operations on uninitialized kobjects · 90584fc9
      Jonathan Brassow 提交于
      MD: Prevent sysfs operations on uninitialized kobjects
      
      Device-mapper does not use sysfs; but when device-mapper is leveraging
      MD's RAID personalities, MD sometimes attempts to update sysfs.  This
      patch adds checks for 'mddev-kobj.sd' in sysfs_[un]link_rdev to ensure
      it is about to operate on something valid.  This patch also checks for
      'mddev->kobj.sd' before calling 'sysfs_notify' in 'remove_and_add_spares'.
      Although 'sysfs_notify' already makes this check, doing so in
      'remove_and_add_spares' prevents an additional mutex operation.
      Signed-off-by: NJonathan Brassow <jbrassow@redhat.com>
      Signed-off-by: NNeilBrown <neilb@suse.de>
      90584fc9
  5. 28 2月, 2013 1 次提交
  6. 26 2月, 2013 1 次提交
    • N
      md: fix two bugs when attempting to resize RAID0 array. · a6468539
      NeilBrown 提交于
      You cannot resize a RAID0 array (in terms of making the devices
      bigger), but the code doesn't entirely stop you.
      So:
      
       disable setting of the available size on each device for
       RAID0 and Linear devices.  This must not change as doing so
       can change the effective layout of data.
      
       Make sure that the size that raid0_size() reports is accurate,
       but rounding devices sizes to chunk sizes.  As the device sizes
       cannot change now, this isn't so important, but it is best to be
       safe.
      
      Without this change:
        mdadm --grow /dev/md0 -z max
        mdadm --grow /dev/md0 -Z max
        then read to the end of the array
      
      can cause a BUG in a RAID0 array.
      
      These bugs have been present ever since it became possible
      to resize any device, which is a long time.  So the fix is
      suitable for any -stable kerenl.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NNeilBrown <neilb@suse.de>
      a6468539
  7. 21 2月, 2013 1 次提交
  8. 13 12月, 2012 3 次提交
  9. 11 12月, 2012 3 次提交
  10. 30 11月, 2012 1 次提交
    • L
      wait: add wait_event_lock_irq() interface · eed8c02e
      Lukas Czerner 提交于
      New wait_event{_interruptible}_lock_irq{_cmd} macros added. This commit
      moves the private wait_event_lock_irq() macro from MD to regular wait
      includes, introduces new macro wait_event_lock_irq_cmd() instead of using
      the old method with omitting cmd parameter which is ugly and makes a use
      of new macros in the MD. It also introduces the _interruptible_ variant.
      
      The use of new interface is when one have a special lock to protect data
      structures used in the condition, or one also needs to invoke "cmd"
      before putting it to sleep.
      
      All new macros are expected to be called with the lock taken. The lock
      is released before sleep and is reacquired afterwards. We will leave the
      macro with the lock held.
      
      Note to DM: IMO this should also fix theoretical race on waitqueue while
      using simultaneously wait_event_lock_irq() and wait_event() because of
      lack of locking around current state setting and wait queue removal.
      Signed-off-by: NLukas Czerner <lczerner@redhat.com>
      Cc: Neil Brown <neilb@suse.de>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      eed8c02e
  11. 20 11月, 2012 3 次提交
  12. 30 10月, 2012 1 次提交
  13. 11 10月, 2012 7 次提交
  14. 19 9月, 2012 1 次提交
    • N
      md: make sure metadata is updated when spares are activated or removed. · 6dafab6b
      NeilBrown 提交于
      It isn't always necessary to update the metadata when spares are
      removed as the presence-or-not of a spare isn't really important to
      the integrity of an array.
      Also activating a spare doesn't always require updating the metadata
      as the update on 'recovery-completed' is usually sufficient.
      
      However the introduction of 'replacement' devices have made these
      transitions sometimes more important.  For example the 'Replacement'
      flag isn't cleared until the original device is removed, so we need
      to ensure a metadata update after that 'spare' is removed.
      
      So set MD_CHANGE_DEVS whenever a spare is activated or removed, to
      complement the current situation where it is set when a spare is added
      or a device is failed (or a number of other less common situations).
      
      This is suitable for -stable as out-of-data metadata could lead
      to data corruption.
      This is only relevant for 3.3 and later 9when 'replacement' as
      introduced.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NNeilBrown <neilb@suse.de>
      6dafab6b
  15. 09 9月, 2012 3 次提交
  16. 16 8月, 2012 1 次提交
    • N
      md: Don't truncate size at 4TB for RAID0 and Linear · 667a5313
      NeilBrown 提交于
      commit 27a7b260
         md: Fix handling for devices from 2TB to 4TB in 0.90 metadata.
      
      changed 0.90 metadata handling to truncated size to 4TB as that is
      all that 0.90 can record.
      However for RAID0 and Linear, 0.90 doesn't need to record the size, so
      this truncation is not needed and causes working arrays to become too small.
      
      So avoid the truncation for RAID0 and Linear
      
      This bug was introduced in 3.1 and is suitable for any stable kernels
      from then onwards.
      As the offending commit was tagged for 'stable', any stable kernel
      that it was applied to should also get this patch.  That includes
      at least 2.6.32, 2.6.33 and 3.0. (Thanks to Ben Hutchings for
      providing that list).
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NNeil Brown <neilb@suse.de>
      667a5313
  17. 31 7月, 2012 4 次提交
    • N
      blk: pass from_schedule to non-request unplug functions. · 74018dc3
      NeilBrown 提交于
      This will allow md/raid to know why the unplug was called,
      and will be able to act according - if !from_schedule it
      is safe to perform tasks which could themselves schedule.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      74018dc3
    • N
      blk: centralize non-request unplug handling. · 9cbb1750
      NeilBrown 提交于
      Both md and umem has similar code for getting notified on an
      blk_finish_plug event.
      Centralize this code in block/ and allow each driver to
      provide its distinctive difference.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      9cbb1750
    • N
      md: remove plug_cnt feature of plugging. · 0021b7bc
      NeilBrown 提交于
      This seemed like a good idea at the time, but after further thought I
      cannot see it making a difference other than very occasionally and
      testing to try to exercise the case it is most likely to help did not
      show any performance difference by removing it.
      
      So remove the counting of active plugs and allow 'pending writes' to
      be activated at any time, not just when no plugs are active.
      
      This is only relevant when there is a write-intent bitmap, and the
      updating of the bitmap will likely introduce enough delay that
      the single-threading of bitmap updates will be enough to collect large
      numbers of updates together.
      
      Removing this will make it easier to centralise the unplug code, and
      will clear the other for other unplug enhancements which have a
      measurable effect.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      0021b7bc
    • N
      md: remove duplicated test on ->openers when calling do_md_stop() · 90cf195d
      NeilBrown 提交于
      do_md_stop tests mddev->openers while holding ->open_mutex,
      and fails if this count is too high.
      So callers do not need to check mddev->openers and doing so isn't
      very meaningful as they don't hold ->open_mutex so the number could
      change.
      
      So remove the unnecessary tests on mddev->openers.
      These are not called often enough for there to be any gain in
      an early test on ->open_mutex to avoid the need for a slightly more
      costly mutex_lock call.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      90cf195d
  18. 19 7月, 2012 1 次提交
    • N
      md: avoid crash when stopping md array races with closing other open fds. · a05b7ea0
      NeilBrown 提交于
      md will refuse to stop an array if any other fd (or mounted fs) is
      using it.
      When any fs is unmounted of when the last open fd is closed all
      pending IO will be flushed (e.g. sync_blockdev call in __blkdev_put)
      so there will be no pending IO to worry about when the array is
      stopped.
      
      However in order to send the STOP_ARRAY ioctl to stop the array one
      must first get and open fd on the block device.
      If some fd is being used to write to the block device and it is closed
      after mdadm open the block device, but before mdadm issues the
      STOP_ARRAY ioctl, then there will be no last-close on the md device so
      __blkdev_put will not call sync_blockdev.
      
      If this happens, then IO can still be in-flight while md tears down
      the array and bad things can happen (use-after-free and subsequent
      havoc).
      
      So in the case where do_md_stop is being called from an open file
      descriptor, call sync_block after taking the mutex to ensure there
      will be no new openers.
      
      This is needed when setting a read-write device to read-only too.
      
      Cc: stable@vger.kernel.org
      Reported-by: Nmajianpeng <majianpeng@gmail.com>
      Signed-off-by: NNeilBrown <neilb@suse.de>
      a05b7ea0