Skip to content
  1. Nov 21, 2013
    • Linus Torvalds's avatar
      Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs · b5898cd0
      Linus Torvalds authored
      Pull vfs bits and pieces from Al Viro:
       "Assorted bits that got missed in the first pull request + fixes for a
        couple of coredump regressions"
      
      * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
        fold try_to_ascend() into the sole remaining caller
        dcache.c: get rid of pointless macros
        take read_seqbegin_or_lock() and friends to seqlock.h
        consolidate simple ->d_delete() instances
        gfs2: endianness misannotations
        dump_emit(): use __kernel_write(), not vfs_write()
        dump_align(): fix the dumb braino
      b5898cd0
    • Al Viro's avatar
      Wrong page freed on preallocate_pmds() failure exit · 2a46eed5
      Al Viro authored
      Note that pmds[i] is simply uninitialized at that point...
      
      Granted, it's very hard to hit (you need split page locks *and*
      kmalloc(sizeof(spinlock_t), GFP_KERNEL) failing), but the code is
      obviously bogus.
      
      Introduced by commit 09ef4939
      
       ("x86: add missed
      pgtable_pmd_page_ctor/dtor calls for preallocated pmds")
      
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      2a46eed5
    • Linus Torvalds's avatar
      Merge tag 'pm+acpi-2-3.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm · 82023bb7
      Linus Torvalds authored
      Pull more ACPI and power management updates from Rafael Wysocki:
      
       - ACPI-based device hotplug fixes for issues introduced recently and a
         fix for an older error code path bug in the ACPI PCI host bridge
         driver
      
       - Fix for recently broken OMAP cpufreq build from Viresh Kumar
      
       - Fix for a recent hibernation regression related to s2disk
      
       - Fix for a locking-related regression in the ACPI EC driver from
         Puneet Kumar
      
       - System suspend error code path fix related to runtime PM and runtime
         PM documentation update from Ulf Hansson
      
       - cpufreq's conservative governor fix from Xiaoguang Chen
      
       - New processor IDs for intel_idle and turbostat and removal of an
         obsolete Kconfig option from Len Brown
      
       - New device IDs for the ACPI LPSS (Low-Power Subsystem) driver and
         ACPI-based PCI hotplug (ACPIPHP) cleanup from Mika Westerberg
      
       - Removal of several ACPI video DMI blacklist entries that are not
         necessary any more from Aaron Lu
      
       - Rework of the ACPI companion representation in struct device and code
         cleanup related to that change from Rafael J Wysocki, Lan Tianyu and
         Jarkko Nikula
      
       - Fixes for assigning names to ACPI-enumerated I2C and SPI devices from
         Jarkko Nikula
      
      * tag 'pm+acpi-2-3.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (24 commits)
        PCI / hotplug / ACPI: Drop unused acpiphp_debug declaration
        ACPI / scan: Set flags.match_driver in acpi_bus_scan_fixed()
        ACPI / PCI root: Clear driver_data before failing enumeration
        ACPI / hotplug: Fix PCI host bridge hot removal
        ACPI / hotplug: Fix acpi_bus_get_device() return value check
        cpufreq: governor: Remove fossil comment in the cpufreq_governor_dbs()
        ACPI / video: clean up DMI table for initial black screen problem
        ACPI / EC: Ensure lock is acquired before accessing ec struct members
        PM / Hibernate: Do not crash kernel in free_basic_memory_bitmaps()
        ACPI / AC: Remove struct acpi_device pointer from struct acpi_ac
        spi: Use stable dev_name for ACPI enumerated SPI slaves
        i2c: Use stable dev_name for ACPI enumerated I2C slaves
        ACPI: Provide acpi_dev_name accessor for struct acpi_device device name
        ACPI / bind: Use (put|get)_device() on ACPI device objects too
        ACPI: Eliminate the DEVICE_ACPI_HANDLE() macro
        ACPI / driver core: Store an ACPI device pointer in struct acpi_dev_node
        cpufreq: OMAP: Fix compilation error 'r & ret undeclared'
        PM / Runtime: Fix error path for prepare
        PM / Runtime: Update documentation around probe|remove|suspend
        cpufreq: conservative: set requested_freq to policy max when it is over policy max
        ...
      82023bb7
    • Linus Torvalds's avatar
      Merge branch 'next' of git://git.infradead.org/users/vkoul/slave-dma · e6d69a60
      Linus Torvalds authored
      Pull slave-dmaengine changes from Vinod Koul:
       "This brings for slave dmaengine:
      
         - Change dma notification flag to DMA_COMPLETE from DMA_SUCCESS as
           dmaengine can only transfer and not verify validaty of dma
           transfers
      
         - Bunch of fixes across drivers:
      
            - cppi41 driver fixes from Daniel
      
            - 8 channel freescale dma engine support and updated bindings from
              Hongbo
      
            - msx-dma fixes and cleanup by Markus
      
         - DMAengine updates from Dan:
      
            - Bartlomiej and Dan finalized a rework of the dma address unmap
              implementation.
      
            - In the course of testing 1/ a collection of enhancements to
              dmatest fell out.  Notably basic performance statistics, and
              fixed / enhanced test control through new module parameters
              'run', 'wait', 'noverify', and 'verbose'.  Thanks to Andriy and
              Linus [Walleij] for their review.
      
            - Testing the raid related corner cases of 1/ triggered bugs in
              the recently added 16-source operation support in the ioatdma
              driver.
      
            - Some minor fixes / cleanups to mv_xor and ioatdma"
      
      * 'next' of git://git.infradead.org/users/vkoul/slave-dma: (99 commits)
        dma: mv_xor: Fix mis-usage of mmio 'base' and 'high_base' registers
        dma: mv_xor: Remove unneeded NULL address check
        ioat: fix ioat3_irq_reinit
        ioat: kill msix_single_vector support
        raid6test: add new corner case for ioatdma driver
        ioatdma: clean up sed pool kmem_cache
        ioatdma: fix selection of 16 vs 8 source path
        ioatdma: fix sed pool selection
        ioatdma: Fix bug in selftest after removal of DMA_MEMSET.
        dmatest: verbose mode
        dmatest: convert to dmaengine_unmap_data
        dmatest: add a 'wait' parameter
        dmatest: add basic performance metrics
        dmatest: add support for skipping verification and random data setup
        dmatest: use pseudo random numbers
        dmatest: support xor-only, or pq-only channels in tests
        dmatest: restore ability to start test at module load and init
        dmatest: cleanup redundant "dmatest: " prefixes
        dmatest: replace stored results mechanism, with uniform messages
        Revert "dmatest: append verify result to results"
        ...
      e6d69a60
    • Linus Torvalds's avatar
      Merge branch 'for-linus' of git://git.kernel.dk/linux-block · 5a1efc6e
      Linus Torvalds authored
      Pull block IO fixes from Jens Axboe:
       "Normally I'd defer my initial for-linus pull request until after the
        merge window, but a race was uncovered in the virtio-blk conversion to
        blk-mq that could cause hangs.  So here's a small collection of fixes
        for you to pull:
      
         - The fix for the virtio-blk IO hang reported by Dave Chinner, from
           Shaohua and myself.
      
         - Add the Insert blktrace event for blk-mq.  This makes 'btt' happy
           when it is doing it's state transition analysis.
      
         - Ensure that blk-mq has disk/partition stats enabled by default,
           instead of making it opt-in.
      
         - A fix for __bio_add_page() and large sector counts"
      
      * 'for-linus' of git://git.kernel.dk/linux-block:
        blk-mq: add blktrace insert event trace
        virtio-blk: virtqueue_kick() must be ordered with other virtqueue operations
        blk-mq: ensure that we set REQ_IO_STAT so diskstats work
        bio: fix argument of __bio_add_page() for max_sectors > 0xffff
      5a1efc6e
    • Linus Torvalds's avatar
      Merge tag 'md/3.13' of git://neil.brown.name/md · 6d6e352c
      Linus Torvalds authored
      Pull md update from Neil Brown:
       "Mostly optimisations and obscure bug fixes.
         - raid5 gets less lock contention
         - raid1 gets less contention between normal-io and resync-io during
           resync"
      
      * tag 'md/3.13' of git://neil.brown.name/md:
        md/raid5: Use conf->device_lock protect changing of multi-thread resources.
        md/raid5: Before freeing old multi-thread worker, it should flush them.
        md/raid5: For stripe with R5_ReadNoMerge, we replace REQ_FLUSH with REQ_NOMERGE.
        UAPI: include <asm/byteorder.h> in linux/raid/md_p.h
        raid1: Rewrite the implementation of iobarrier.
        raid1: Add some macros to make code clearly.
        raid1: Replace raise_barrier/lower_barrier with freeze_array/unfreeze_array when reconfiguring the array.
        raid1: Add a field array_frozen to indicate whether raid in freeze state.
        md: Convert use of typedef ctl_table to struct ctl_table
        md/raid5: avoid deadlock when raid5 array has unack badblocks during md_stop_writes.
        md: use MD_RECOVERY_INTR instead of kthread_should_stop in resync thread.
        md: fix some places where mddev_lock return value is not checked.
        raid5: Retry R5_ReadNoMerge flag when hit a read error.
        raid5: relieve lock contention in get_active_stripe()
        raid5: relieve lock contention in get_active_stripe()
        wait: add wait_event_cmd()
        md/raid5.c: add proper locking to error path of raid5_start_reshape.
        md: fix calculation of stacking limits on level change.
        raid5: Use slow_path to release stripe when mddev->thread is null
      6d6e352c
  2. Nov 20, 2013
  3. Nov 19, 2013
    • majianpeng's avatar
      md/raid5: Use conf->device_lock protect changing of multi-thread resources. · 60aaf933
      majianpeng authored
      When we change group_thread_cnt from sysfs entry, it can OOPS.
      
      The kernel messages are:
      [  135.299021] BUG: unable to handle kernel NULL pointer dereference at           (null)
      [  135.299073] IP: [<ffffffff815188ab>] handle_active_stripes+0x32b/0x440
      [  135.299107] PGD 0
      [  135.299122] Oops: 0000 [#1] SMP
      [  135.299144] Modules linked in: netconsole e1000e ptp pps_core
      [  135.299188] CPU: 3 PID: 2225 Comm: md0_raid5 Not tainted 3.12.0+ #24
      [  135.299214] Hardware name: To Be Filled By O.E.M. To Be Filled By O.E.M./To be filled by O.E.M., BIOS 080015  11/09/2011
      [  135.299255] task: ffff8800b9638f80 ti: ffff8800b77a4000 task.ti: ffff8800b77a4000
      [  135.299283] RIP: 0010:[<ffffffff815188ab>]  [<ffffffff815188ab>] handle_active_stripes+0x32b/0x440
      [  135.299323] RSP: 0018:ffff8800b77a5c48  EFLAGS: 00010002
      [  135.299344] RAX: ffff880037bb5c70 RBX: 0000000000000000 RCX: 0000000000000008
      [  135.299371] RDX: ffff880037bb5cb8 RSI: 0000000000000001 RDI: ffff880037bb5c00
      [  135.299398] RBP: ffff8800b77a5d08 R08: 0000000000000001 R09: 0000000000000000
      [  135.299425] R10: ffff8800b77a5c98 R11: 00000000ffffffff R12: ffff880037bb5c00
      [  135.299452] R13: 0000000000000000 R14: 0000000000000000 R15: ffff880037bb5c70
      [  135.299479] FS:  0000000000000000(0000) GS:ffff88013fd80000(0000) knlGS:0000000000000000
      [  135.299510] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
      [  135.299532] CR2: 0000000000000000 CR3: 0000000001c0b000 CR4: 00000000000407e0
      [  135.299559] Stack:
      [  135.299570]  ffff8800b77a5c88 ffffffff8107383e ffff8800b77a5c88 ffff880037a64300
      [  135.299611]  000000000000ec08 ffff880037bb5cb8 ffff8800b77a5c98 ffffffffffffffd8
      [  135.299654]  000000000000ec08 ffff880037bb5c60 ffff8800b77a5c98 ffff8800b77a5c98
      [  135.299696] Call Trace:
      [  135.299711]  [<ffffffff8107383e>] ? __wake_up+0x4e/0x70
      [  135.299733]  [<ffffffff81518f88>] raid5d+0x4c8/0x680
      [  135.299756]  [<ffffffff817174ed>] ? schedule_timeout+0x15d/0x1f0
      [  135.299781]  [<ffffffff81524c9f>] md_thread+0x11f/0x170
      [  135.299804]  [<ffffffff81069cd0>] ? wake_up_bit+0x40/0x40
      [  135.299826]  [<ffffffff81524b80>] ? md_rdev_init+0x110/0x110
      [  135.299850]  [<ffffffff81069656>] kthread+0xc6/0xd0
      [  135.299871]  [<ffffffff81069590>] ? kthread_freezable_should_stop+0x70/0x70
      [  135.299899]  [<ffffffff81722ffc>] ret_from_fork+0x7c/0xb0
      [  135.299923]  [<ffffffff81069590>] ? kthread_freezable_should_stop+0x70/0x70
      [  135.299951] Code: ff ff ff 0f 84 d7 fe ff ff e9 5c fe ff ff 66 90 41 8b b4 24 d8 01 00 00 45 31 ed 85 f6 0f 8e 7b fd ff ff 49 8b 9c 24 d0 01 00 00 <48> 3b 1b 49 89 dd 0f 85 67 fd ff ff 48 8d 43 28 31 d2 eb 17 90
      [  135.300005] RIP  [<ffffffff815188ab>] handle_active_stripes+0x32b/0x440
      [  135.300005]  RSP <ffff8800b77a5c48>
      [  135.300005] CR2: 0000000000000000
      [  135.300005] ---[ end trace 504854e5bb7562ed ]---
      [  135.300005] Kernel panic - not syncing: Fatal exception
      
      This is because raid5d() can be running when the multi-thread
      resources are changed via system. We see need to provide locking.
      
      mddev->device_lock is suitable, but we cannot simple call
      alloc_thread_groups under this lock as we cannot allocate memory
      while holding a spinlock.
      So change alloc_thread_groups() to allocate and return the data
      structures, then raid5_store_group_thread_cnt() can take the lock
      while updating the pointers to the data structures.
      
      This fixes a bug introduced in 3.12 and so is suitable for the 3.12.x
      stable series.
      
      Fixes: b721420e
      
      
      Cc: stable@vger.kernel.org (3.12)
      Signed-off-by: default avatarJianpeng Ma <majianpeng@gmail.com>
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      Reviewed-by: default avatarShaohua Li <shli@kernel.org>
      60aaf933
    • majianpeng's avatar
      md/raid5: Before freeing old multi-thread worker, it should flush them. · d206dcfa
      majianpeng authored
      When changing group_thread_cnt from sysfs entry, the kernel can oops.
      
      The kernel messages are:
      [  740.961389] BUG: unable to handle kernel NULL pointer dereference at 0000000000000008
      [  740.961444] IP: [<ffffffff81062570>] process_one_work+0x30/0x500
      [  740.961476] PGD b9013067 PUD b651e067 PMD 0
      [  740.961503] Oops: 0000 [#1] SMP
      [  740.961525] Modules linked in: netconsole e1000e ptp pps_core
      [  740.961577] CPU: 0 PID: 3683 Comm: kworker/u8:5 Not tainted 3.12.0+ #23
      [  740.961602] Hardware name: To Be Filled By O.E.M. To Be Filled By O.E.M./To be filled by O.E.M., BIOS 080015  11/09/2011
      [  740.961646] task: ffff88013abe0000 ti: ffff88013a246000 task.ti: ffff88013a246000
      [  740.961673] RIP: 0010:[<ffffffff81062570>]  [<ffffffff81062570>] process_one_work+0x30/0x500
      [  740.961708] RSP: 0018:ffff88013a247e08  EFLAGS: 00010086
      [  740.961730] RAX: ffff8800b912b400 RBX: ffff88013a61e680 RCX: ffff8800b912b400
      [  740.961757] RDX: ffff8800b912b600 RSI: ffff8800b912b600 RDI: ffff88013a61e680
      [  740.961782] RBP: ffff88013a247e48 R08: ffff88013a246000 R09: 000000000002c09d
      [  740.961808] R10: 000000000000010f R11: 0000000000000000 R12: ffff88013b00cc00
      [  740.961833] R13: 0000000000000000 R14: ffff88013b00cf80 R15: ffff88013a61e6b0
      [  740.961861] FS:  0000000000000000(0000) GS:ffff88013fc00000(0000) knlGS:0000000000000000
      [  740.961893] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
      [  740.962001] CR2: 00000000000000b8 CR3: 00000000b24fe000 CR4: 00000000000407f0
      [  740.962001] Stack:
      [  740.962001]  0000000000000008 ffff8800b912b600 ffff88013b00cc00 ffff88013a61e680
      [  740.962001]  ffff88013b00cc00 ffff88013b00cc18 ffff88013b00cf80 ffff88013a61e6b0
      [  740.962001]  ffff88013a247eb8 ffffffff810639c6 0000000000012a80 ffff88013a247fd8
      [  740.962001] Call Trace:
      [  740.962001]  [<ffffffff810639c6>] worker_thread+0x206/0x3f0
      [  740.962001]  [<ffffffff810637c0>] ? manage_workers+0x2c0/0x2c0
      [  740.962001]  [<ffffffff81069656>] kthread+0xc6/0xd0
      [  740.962001]  [<ffffffff81069590>] ? kthread_freezable_should_stop+0x70/0x70
      [  740.962001]  [<ffffffff81722ffc>] ret_from_fork+0x7c/0xb0
      [  740.962001]  [<ffffffff81069590>] ? kthread_freezable_should_stop+0x70/0x70
      [  740.962001] Code: 89 e5 41 57 41 56 41 55 45 31 ed 41 54 53 48 89 fb 48 83 ec 18 48 8b 06 4c 8b 67 48 48 89 c1 30 c9 a8 04 4c 0f 45 e9 80 7f 58 00 <49> 8b 45 08 44 8b b0 00 01 00 00 78 0c 41 f6 44 24 10 04 0f 84
      [  740.962001] RIP  [<ffffffff81062570>] process_one_work+0x30/0x500
      [  740.962001]  RSP <ffff88013a247e08>
      [  740.962001] CR2: 0000000000000008
      [  740.962001] ---[ end trace 39181460000748de ]---
      [  740.962001] Kernel panic - not syncing: Fatal exception
      
      This can happen if there are some stripes left, fewer than MAX_STRIPE_BATCH.
      A worker is queued to handle them.
      But before calling raid5_do_work, raid5d handles those
      stripes making conf->active_stripe = 0.
      So mddev_suspend() can return.
      We might then free old worker resources before the queued
      raid5_do_work() handled them.  When it runs, it crashes.
      
      	raid5d()		raid5_store_group_thread_cnt()
      	queue_work		mddev_suspend()
      				handle_strips
      				active_stripe=0
      				free(old worker resources)
      	process_one_work
      	raid5_do_work
      
      To avoid this, we should only flush the worker resources before freeing them.
      
      This fixes a bug introduced in 3.12 so is suitable for the 3.12.x
      stable series.
      
      Cc: stable@vger.kernel.org (3.12)
      Fixes: b721420e
      
      
      Signed-off-by: default avatarJianpeng Ma <majianpeng@gmail.com>
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      Reviewed-by: default avatarShaohua Li <shli@kernel.org>
      d206dcfa
    • majianpeng's avatar
      md/raid5: For stripe with R5_ReadNoMerge, we replace REQ_FLUSH with REQ_NOMERGE. · e59aa23f
      majianpeng authored
      
      
      For R5_ReadNoMerge,it mean this bio can't merge with other bios or
      request.It used REQ_FLUSH to achieve this. But REQ_NOMERGE can do the
      same work.
      
      Signed-off-by: default avatarJianpeng Ma <majianpeng@gmail.com>
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      e59aa23f
    • Aurelien Jarno's avatar
      UAPI: include <asm/byteorder.h> in linux/raid/md_p.h · c0f8bd14
      Aurelien Jarno authored
      
      
      linux/raid/md_p.h is using conditionals depending on endianess and fails
      with an error if neither of __BIG_ENDIAN, __LITTLE_ENDIAN or
      __BYTE_ORDER are defined, but it doesn't include any header which can
      define these constants. This make this header unusable alone.
      
      This patch adds a #include <asm/byteorder.h> at the beginning of this
      header to make it usable alone. This is needed to compile klibc on MIPS.
      
      Signed-off-by: default avatarAurelien Jarno <aurelien@aurel32.net>
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      c0f8bd14
    • majianpeng's avatar
      raid1: Rewrite the implementation of iobarrier. · 79ef3a8a
      majianpeng authored
      
      
      There is an iobarrier in raid1 because of contention between normal IO and
      resync IO.  It suspends all normal IO when resync/recovery happens.
      
      However if normal IO is out side the resync window, there is no contention.
      So this patch changes the barrier mechanism to only block IO that
      could contend with the resync that is currently happening.
      
      We partition the whole space into five parts.
      |---------|-----------|------------|----------------|-------|
              start   next_resync   start_next_window    end_window
      
      start + RESYNC_WINDOW = next_resync
      next_resync + NEXT_NORMALIO_DISTANCE = start_next_window
      start_next_window + NEXT_NORMALIO_DISTANCE = end_window
      
      Firstly we introduce some concepts:
      
      1 - RESYNC_WINDOW: For resync, there are 32 resync requests at most at the
            same time. A sync request is RESYNC_BLOCK_SIZE(64*1024).
            So the RESYNC_WINDOW is 32 * RESYNC_BLOCK_SIZE, that is 2MB.
      2 - NEXT_NORMALIO_DISTANCE: the distance between next_resync
            and start_next_window.  It also indicates the distance between
            start_next_window and end_window.
            It is currently 3 * RESYNC_WINDOW_SIZE but could be tuned if
            this turned out not to be optimal.
      3 - next_resync: the next sector at which we will do sync IO.
      4 - start: a position which is at most RESYNC_WINDOW before
            next_resync.
      5 - start_next_window:  a position which is NEXT_NORMALIO_DISTANCE
            beyond next_resync.  Normal-io after this position doesn't need to
            wait for resync-io to complete.
      6 - end_window:  a position which is 2 * NEXT_NORMALIO_DISTANCE beyond
            next_resync.  This also doesn't need to wait, but is counted
            differently.
      7 - current_window_requests:  the count of normalIO between
            start_next_window and end_window.
      8 - next_window_requests: the count of normalIO after end_window.
      
      NormalIO will be partitioned into four types:
      
      NormIO1:  the end sector of bio is smaller or equal the start
      NormIO2:  the start sector of bio larger or equal to end_window
      NormIO3:  the start sector of bio larger or equal to
                start_next_window.
      NormIO4:  the location between start_next_window and end_window
      
      |--------|-----------|--------------------|----------------|-------------|
          | start   |   next_resync   |  start_next_window   |  end_window |
       NormIO1   NormIO4            NormIO4                NormIO3      NormIO2
      
      For NormIO1, we don't need any io barrier.
      For NormIO4, we used a similar approach to the original iobarrier
          mechanism.  The normalIO and resyncIO must be kept separate.
      For NormIO2/3, we add two fields to struct r1conf: "current_window_requests"
          and "next_window_requests". They indicate the count of active
          requests in the two window.
          For these, we don't wait for resync io to complete.
      
      For resync action, if there are NormIO4s, we must wait for it.
      If not, we can proceed.
      But if resync action reaches start_next_window and
      current_window_requests > 0 (that is there are NormIO3s), we must
      wait until the current_window_requests becomes zero.
      When current_window_requests becomes zero,  start_next_window also
      moves forward. Then current_window_requests will replaced by
      next_window_requests.
      
      There is a problem which when and how to change from NormIO2 to
      NormIO3.  Only then can sync action progress.
      
      We add a field in struct r1conf "start_next_window".
      
      A: if start_next_window == MaxSector, it means there are no NormIO2/3.
         So start_next_window = next_resync + NEXT_NORMALIO_DISTANCE
      B: if current_window_requests == 0 && next_window_requests != 0, it
         means start_next_window move to end_window
      
      There is another problem which how to differentiate between
      old NormIO2(now it is NormIO3) and NormIO2.
      For example, there are many bios which are NormIO2 and a bio which is
      NormIO3. NormIO3 firstly completed, so the bios of NormIO2 became NormIO3.
      
      We add a field in struct r1bio "start_next_window".
      This is used to record the position conf->start_next_window when the call
      to wait_barrier() is made in make_request().
      
      In allow_barrier(), we check the conf->start_next_window.
      If r1bio->stat_next_window == conf->start_next_window, it means
      there is no transition between NormIO2 and NormIO3.
      If r1bio->start_next_window != conf->start_next_window, it mean
      there was a transition between NormIO2 and NormIO3.  There can only
      have been one transition.  So it only means the bio is old NormIO2.
      
      For one bio, there may be many r1bio's. So we make sure
      all the r1bio->start_next_window are the same value.
      If we met blocked_dev in make_request(), it must call allow_barrier
      and wait_barrier. So the former and the later value of
      conf->start_next_window will be change.
      If there are many r1bio's with differnet start_next_window,
      for the relevant bio, it depend on the last value of r1bio.
      It will cause error. To avoid this, we must wait for previous r1bios
      to complete.
      
      Signed-off-by: default avatarJianpeng Ma <majianpeng@gmail.com>
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      79ef3a8a