1. 28 May, 2015 8 commits
    • NeilBrown's avatar
      md/raid5: call break_stripe_batch_list from handle_stripe_clean_event · 787b76fa
      NeilBrown authored
      Now that the code in break_stripe_batch_list() is nearly identical
      to the end of handle_stripe_clean_event, replace the later
      with a function call.
      
      The only remaining difference of any interest is the masking that is
      applieds to dev[i].flags copied from head_sh.
      R5_WriteError certainly isn't wanted as it is set per-stripe, not
      per-patch.  R5_Overlap isn't wanted as it is explicitly handled.
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      787b76fa
    • NeilBrown's avatar
      md/raid5: be more selective about distributing flags across batch. · 1b956f7a
      NeilBrown authored
      When a batch of stripes is broken up, we keep some of the flags
      that were per-stripe, and copy other flags from the head to all
      others.
      
      This only happens while a stripe is being handled, so many of the
      flags are irrelevant.
      
      The "SYNC_FLAGS" (which I've renamed to make it clear there are
      several) and STRIPE_DEGRADED are set per-stripe and so need to be
      preserved.  STRIPE_INSYNC is the only flag that is set on the head
      that needs to be propagated to all others.
      
      For safety, add a WARN_ON if others are set, except:
       STRIPE_HANDLE - this is safe and per-stripe and we are going to set
            in several cases anyway
       STRIPE_INSYNC
       STRIPE_IO_STARTED - this is just a hint and doesn't hurt.
       STRIPE_ON_PLUG_LIST
       STRIPE_ON_RELEASE_LIST - It is a point pointless for a batched
                 stripe to be on one of these lists, but it can happen
                 as can be safely ignored.
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      1b956f7a
    • NeilBrown's avatar
      md/raid5: add handle_flags arg to break_stripe_batch_list. · 3960ce79
      NeilBrown authored
      When we break a stripe_batch_list we sometimes want to set
      STRIPE_HANDLE on the individual stripes, and sometimes not.
      
      So pass a 'handle_flags' arg.  If it is zero, always set STRIPE_HANDLE
      (on non-head stripes).  If not zero, only set it if any of the given
      flags are present.
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      3960ce79
    • NeilBrown's avatar
      md/raid5: duplicate some more handle_stripe_clean_event code in break_stripe_batch_list · fb642b92
      NeilBrown authored
      break_stripe_batch list didn't clear head_sh->batch_head.
      This was probably a bug.
      
      Also clear all R5_Overlap flags and if any were cleared, wake up
      'wait_for_overlap'.
      This isn't always necessary but the worst effect is a little
      extra checking for code that is waiting on wait_for_overlap.
      
      Also, don't use wake_up_nr() because that does the wrong thing
      if 'nr' is zero, and it number of flags cleared doesn't
      strongly correlate with the number of threads to wake.
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      fb642b92
    • NeilBrown's avatar
      md/raid5: remove condition test from check_break_stripe_batch_list. · 4e3d62ff
      NeilBrown authored
      handle_stripe_clean_event() contains a chunk of code very
      similar to check_break_stripe_batch_list().
      If we make the latter more like the former, we can end up
      with just one copy of this code.
      
      This  first step removed the condition (and the 'check_') part
      of the name.  This has the added advantage of making it clear
      what check is being performed at the point where the function is
      called.
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      4e3d62ff
    • NeilBrown's avatar
      md/raid5: Ensure a batch member is not handled prematurely. · b15a9dbd
      NeilBrown authored
      If a stripe is a member of a batch, but not the head, it must
      not be handled separately from the rest of the batch.
      
      'clear_batch_ready()' handles this requirement to some
      extent but not completely.  If a member is passed to handle_stripe()
      a second time it returns '0' indicating the stripe can be handled,
      which is wrong.
      So add an extra test.
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      b15a9dbd
    • NeilBrown's avatar
      md/raid5: close race between STRIPE_BIT_DELAY and batching. · d0852df5
      NeilBrown authored
      When we add a write to a stripe we need to make sure the bitmap
      bit is set.  While doing that the stripe is not locked so it could
      be added to a batch after which further changes to STRIPE_BIT_DELAY
      and ->bm_seq are ineffective.
      
      So we need to hold off adding to a stripe until bitmap_startwrite has
      completed at least once, and we need to avoid further changes to
      STRIPE_BIT_DELAY once the stripe has been added to a batch.
      
      If a bitmap_startwrite() completes after the stripe was added to a
      batch, it will not have set the bit, only incremented a counter, so no
      extra delay of the stripe is needed.
      Reported-by: default avatarShaohua Li <shli@kernel.org>
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      d0852df5
    • NeilBrown's avatar
      md/raid5: ensure whole batch is delayed for all required bitmap updates. · 2b6b2457
      NeilBrown authored
      When we add a stripe to a batch, we need to be sure that
      head stripe will wait for the bitmap update required for the new
      stripe.
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      2b6b2457
  2. 20 May, 2015 3 commits
  3. 08 May, 2015 7 commits
    • NeilBrown's avatar
      md/raid5: fix handling of degraded stripes in batches. · bb27051f
      NeilBrown authored
      There is no need for special handling of stripe-batches when the array
      is degraded.
      
      There may be if there is a failure in the batch, but STRIPE_DEGRADED
      does not imply an error.
      
      So don't set STRIPE_BATCH_ERR in ops_run_io just because the array is
      degraded.
      This actually causes a bug: the STRIPE_DEGRADED flag gets cleared in
      check_break_stripe_batch_list() and so the bitmap bit gets cleared
      when it shouldn't.
      
      So in check_break_stripe_batch_list(), split the batch up completely -
      again STRIPE_DEGRADED isn't meaningful.
      
      Also don't set STRIPE_BATCH_ERR when there is a write error to a
      replacement device.  This simply removes the replacement device and
      requires no extra handling.
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      bb27051f
    • NeilBrown's avatar
      md/raid5: fix allocation of 'scribble' array. · 738a2738
      NeilBrown authored
      As the new 'scribble' array is sized based on chunk size,
      we need to make sure the size matches the largest of 'old'
      and 'new' chunk sizes when the array is undergoing reshape.
      
      We also potentially need to resize it even when not resizing
      the stripe cache, as chunk size can change without changing
      number of devices.
      
      So move the 'resize' code into a separate function, and
      consider old and new sizes when allocating.
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      Fixes: 46d5b785 ("raid5: use flex_array for scribble data")
      738a2738
    • NeilBrown's avatar
      md/raid5: don't record new size if resize_stripes fails. · 6e9eac2d
      NeilBrown authored
      If any memory allocation in resize_stripes fails we will return
      -ENOMEM, but in some cases we update conf->pool_size anyway.
      
      This means that if we try again, the allocations will be assumed
      to be larger than they are, and badness results.
      
      So only update pool_size if there is no error.
      
      This bug was introduced in 2.6.17 and the patch is suitable for
      -stable.
      
      Fixes: ad01c9e3 ("[PATCH] md: Allow stripes to be expanded in preparation for expanding an array")
      Cc: stable@vger.kernel.org (v2.6.17+)
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      6e9eac2d
    • NeilBrown's avatar
      md/raid5: avoid reading parity blocks for full-stripe write to degraded array · 10d82c5f
      NeilBrown authored
      When performing a reconstruct write, we need to read all blocks
      that are not being over-written .. except the parity (P and Q) blocks.
      
      The code currently reads these (as they are not being over-written!)
      unnecessarily.
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      Fixes: ea664c82 ("md/raid5: need_this_block: tidy/fix last condition.")
      10d82c5f
    • NeilBrown's avatar
      md/raid5: more incorrect BUG_ON in handle_stripe_fill. · b0c783b3
      NeilBrown authored
      It is not incorrect to call handle_stripe_fill() when
      a batch of full-stripe writes is active.
      It is, however, a BUG if fetch_block() then decides
      it needs to actually fetch anything.
      
      So move the 'BUG_ON' to where it belongs.
      Signed-off-by: default avatarNeilBrown  <neilb@suse.de>
      Fixes: 59fc630b ("RAID5: batch adjacent full stripe write")
      b0c783b3
    • NeilBrown's avatar
      md/raid5: new alloc_stripe() to allocate an initialize a stripe. · f18c1a35
      NeilBrown authored
      The new batch_lock and batch_list fields are being initialized in
      grow_one_stripe() but not in resize_stripes().  This causes a crash
      on resize.
      
      So separate the core initialization into a new function and call it
      from both allocation sites.
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      Fixes: 59fc630b ("RAID5: batch adjacent full stripe write")
      f18c1a35
    • Heinz Mauelshagen's avatar
      md-raid0: conditional mddev->queue access to suit dm-raid · b6538fe3
      Heinz Mauelshagen authored
      This patch is a prerequisite for dm-raid "raid0" support to allow
      dm-raid to access the MD RAID0 personality doing unconditional
      accesses to mddev->queue, which is NULL in case of dm-raid stacked on
      top of MD.
      
      Most of the conditional mddev->queue accesses made it to upstream but
      this missing one, which prohibits md raid0 to set disk stack limits
      (being done in dm core in case of md underneath dm).
      Signed-off-by: default avatarHeinz Mauelshagen <heinzm@redhat.com>
      Tested-by: default avatarHeinz Mauelshagen <heinzm@redhat.com>
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      b6538fe3
  4. 04 May, 2015 3 commits
    • Linus Torvalds's avatar
      Linux 4.1-rc2 · 5ebe6afa
      Linus Torvalds authored
      5ebe6afa
    • Linus Torvalds's avatar
      Merge tag 'for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4 · 8663da2c
      Linus Torvalds authored
      Pull ext4 fixes from Ted Ts'o:
       "Some miscellaneous bug fixes and some final on-disk and ABI changes
        for ext4 encryption which provide better security and performance"
      
      * tag 'for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4:
        ext4: fix growing of tiny filesystems
        ext4: move check under lock scope to close a race.
        ext4: fix data corruption caused by unwritten and delayed extents
        ext4 crypto: remove duplicated encryption mode definitions
        ext4 crypto: do not select from EXT4_FS_ENCRYPTION
        ext4 crypto: add padding to filenames before encrypting
        ext4 crypto: simplify and speed up filename encryption
      8663da2c
    • Linus Torvalds's avatar
      Merge branch 'drm-fixes' of git://people.freedesktop.org/~airlied/linux · 101a6fd3
      Linus Torvalds authored
      Pull drm fixes from Dave Airlie:
       "One intel fix, one rockchip fix, and a bunch of radeon fixes for some
        regressions from audio rework and vm stability"
      
      * 'drm-fixes' of git://people.freedesktop.org/~airlied/linux:
        drm/i915/chv: Implement WaDisableShadowRegForCpd
        drm/radeon: fix userptr return value checking (v2)
        drm/radeon: check new address before removing old one
        drm/radeon: reset BOs address after clearing it.
        drm/radeon: fix lockup when BOs aren't part of the VM on release
        drm/radeon: add SI DPM quirk for Sapphire R9 270 Dual-X 2G GDDR5
        drm/radeon: adjust pll when audio is not enabled
        drm/radeon: only enable audio streams if the monitor supports it
        drm/radeon: only mark audio as connected if the monitor supports it (v3)
        drm/radeon/audio: don't enable packets until the end
        drm/radeon: drop dce6_dp_enable
        drm/radeon: fix ordering of AVI packet setup
        drm/radeon: Use drm_calloc_ab for CS relocs
        drm/rockchip: fix error check when getting irq
        MAINTAINERS: add entry for Rockchip drm drivers
      101a6fd3
  5. 03 May, 2015 8 commits
    • Dave Airlie's avatar
      Merge tag 'drm-intel-fixes-2015-04-30' of git://anongit.freedesktop.org/drm-intel into drm-fixes · 71aee819
      Dave Airlie authored
      Just a single intel fix
      * tag 'drm-intel-fixes-2015-04-30' of git://anongit.freedesktop.org/drm-intel:
        drm/i915/chv: Implement WaDisableShadowRegForCpd
      71aee819
    • Dave Airlie's avatar
      Merge branch 'drm-next0420' of https://github.com/markyzq/kernel-drm-rockchip into drm-fixes · df9ebeb2
      Dave Airlie authored
      one fix and maintainers update
      * 'drm-next0420' of https://github.com/markyzq/kernel-drm-rockchip:
        drm/rockchip: fix error check when getting irq
        MAINTAINERS: add entry for Rockchip drm drivers
      df9ebeb2
    • Linus Torvalds's avatar
      Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi · 61f06db0
      Linus Torvalds authored
      Pull SCSI fixes from James Bottomley:
       "This is three logical fixes (as 5 patches).
      
        The 3ware class of drivers were causing an oops with multiqueue by
        tearing down the command mappings after completing the command (where
        the variables in the command used to tear down the mapping were
        no-longer valid).  There's also a fix for the qnap iscsi target which
        was choking on us sending it commands that were too long and a fix for
        the reworked aha1542 allocating GFP_KERNEL under a lock"
      
      * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
        3w-9xxx: fix command completion race
        3w-xxxx: fix command completion race
        3w-sas: fix command completion race
        aha1542: Allocate memory before taking a lock
        SCSI: add 1024 max sectors black list flag
      61f06db0
    • Linus Torvalds's avatar
      Merge branch 'next' of git://git.infradead.org/users/vkoul/slave-dma · 33332224
      Linus Torvalds authored
      Pull slave dmaengine fixes from Vinod Koul:
       "Here are the fixes in dmaengine subsystem for rc2:
      
         - privatecnt fix for slave dma request API by Christopher
      
         - warn fix for PM ifdef in usb-dmac by Geert
      
         - fix hardware dependency for xgene by Jean"
      
      * 'next' of git://git.infradead.org/users/vkoul/slave-dma:
        dmaengine: increment privatecnt when using dma_get_any_slave_channel
        dmaengine: xgene: Set hardware dependency
        dmaengine: usb-dmac: Protect PM-only functions to kill warning
      33332224
    • Linus Torvalds's avatar
      Merge tag 'powerpc-4.1-3' of git://git.kernel.org/pub/scm/linux/kernel/git/mpe/linux · 180d89f6
      Linus Torvalds authored
      Pull powerpc fixes from Michael Ellerman:
       - build fix for SMP=n in book3s_xics.c
       - fix for Daniel's pci_controller_ops on powernv.
       - revert the TM syscall abort patch for now.
       - CPU affinity fix from Nathan.
       - two EEH fixes from Gavin.
       - fix for CR corruption from Sam.
       - selftest build fix.
      
      * tag 'powerpc-4.1-3' of git://git.kernel.org/pub/scm/linux/kernel/git/mpe/linux:
        powerpc/powernv: Restore non-volatile CRs after nap
        powerpc/eeh: Delay probing EEH device during hotplug
        powerpc/eeh: Fix race condition in pcibios_set_pcie_reset_state()
        powerpc/pseries: Correct cpu affinity for dlpar added cpus
        selftests/powerpc: Fix the pmu install rule
        Revert "powerpc/tm: Abort syscalls in active transactions"
        powerpc/powernv: Fix early pci_controller_ops loading.
        powerpc/kvm: Fix SMP=n build error in book3s_xics.c
      180d89f6
    • Jan Kara's avatar
      ext4: fix growing of tiny filesystems · 2c869b26
      Jan Kara authored
      The estimate of necessary transaction credits in ext4_flex_group_add()
      is too pessimistic. It reserves credit for sb, resize inode, and resize
      inode dindirect block for each group added in a flex group although they
      are always the same block and thus it is enough to account them only
      once. Also the number of modified GDT block is overestimated since we
      fit EXT4_DESC_PER_BLOCK(sb) descriptors in one block.
      
      Make the estimation more precise. That reduces number of requested
      credits enough that we can grow 20 MB filesystem (which has 1 MB
      journal, 79 reserved GDT blocks, and flex group size 16 by default).
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Reviewed-by: default avatarEric Sandeen <sandeen@redhat.com>
      2c869b26
    • Davide Italiano's avatar
      ext4: move check under lock scope to close a race. · 280227a7
      Davide Italiano authored
      fallocate() checks that the file is extent-based and returns
      EOPNOTSUPP in case is not. Other tasks can convert from and to
      indirect and extent so it's safe to check only after grabbing
      the inode mutex.
      Signed-off-by: default avatarDavide Italiano <dccitaliano@gmail.com>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Cc: stable@vger.kernel.org
      280227a7
    • Lukas Czerner's avatar
      ext4: fix data corruption caused by unwritten and delayed extents · d2dc317d
      Lukas Czerner authored
      Currently it is possible to lose whole file system block worth of data
      when we hit the specific interaction with unwritten and delayed extents
      in status extent tree.
      
      The problem is that when we insert delayed extent into extent status
      tree the only way to get rid of it is when we write out delayed buffer.
      However there is a limitation in the extent status tree implementation
      so that when inserting unwritten extent should there be even a single
      delayed block the whole unwritten extent would be marked as delayed.
      
      At this point, there is no way to get rid of the delayed extents,
      because there are no delayed buffers to write out. So when a we write
      into said unwritten extent we will convert it to written, but it still
      remains delayed.
      
      When we try to write into that block later ext4_da_map_blocks() will set
      the buffer new and delayed and map it to invalid block which causes
      the rest of the block to be zeroed loosing already written data.
      
      For now we can fix this by simply not allowing to set delayed status on
      written extent in the extent status tree. Also add WARN_ON() to make
      sure that we notice if this happens in the future.
      
      This problem can be easily reproduced by running the following xfs_io.
      
      xfs_io -f -c "pwrite -S 0xaa 4096 2048" \
                -c "falloc 0 131072" \
                -c "pwrite -S 0xbb 65536 2048" \
                -c "fsync" /mnt/test/fff
      
      echo 3 > /proc/sys/vm/drop_caches
      xfs_io -c "pwrite -S 0xdd 67584 2048" /mnt/test/fff
      
      This can be theoretically also reproduced by at random by running fsx,
      but it's not very reliable, though on machines with bigger page size
      (like ppc) this can be seen more often (especially xfstest generic/127)
      Signed-off-by: default avatarLukas Czerner <lczerner@redhat.com>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Cc: stable@vger.kernel.org
      d2dc317d
  6. 02 May, 2015 7 commits
  7. 01 May, 2015 4 commits
    • Ilya Dryomov's avatar
      rbd: end I/O the entire obj_request on error · 082a75da
      Ilya Dryomov authored
      When we end I/O struct request with error, we need to pass
      obj_request->length as @nr_bytes so that the entire obj_request worth
      of bytes is completed.  Otherwise block layer ends up confused and we
      trip on
      
          rbd_assert(more ^ (which == img_request->obj_request_count));
      
      in rbd_img_obj_callback() due to more being true no matter what.  We
      already do it in most cases but we are missing some, in particular
      those where we don't even get a chance to submit any obj_requests, due
      to an early -ENOMEM for example.
      
      A number of obj_request->xferred assignments seem to be redundant but
      I haven't touched any of obj_request->xferred stuff to keep this small
      and isolated.
      
      Cc: Alex Elder <elder@linaro.org>
      Cc: stable@vger.kernel.org # 3.10+
      Reported-by: default avatarShawn Edwards <lesser.evil@gmail.com>
      Reviewed-by: default avatarSage Weil <sage@redhat.com>
      Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
      082a75da
    • Theodore Ts'o's avatar
      ext4 crypto: add padding to filenames before encrypting · a44cd7a0
      Theodore Ts'o authored
      This obscures the length of the filenames, to decrease the amount of
      information leakage.  By default, we pad the filenames to the next 4
      byte boundaries.  This costs nothing, since the directory entries are
      aligned to 4 byte boundaries anyway.  Filenames can also be padded to
      8, 16, or 32 bytes, which will consume more directory space.
      
      Change-Id: Ibb7a0fb76d2c48e2061240a709358ff40b14f322
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      a44cd7a0
    • Theodore Ts'o's avatar
      ext4 crypto: simplify and speed up filename encryption · 5de0b4d0
      Theodore Ts'o authored
      Avoid using SHA-1 when calculating the user-visible filename when the
      encryption key is available, and avoid decrypting lots of filenames
      when searching for a directory entry in a directory block.
      
      Change-Id: If4655f144784978ba0305b597bfa1c8d7bb69e63
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      5de0b4d0
    • Linus Torvalds's avatar
      Merge branch 'for-linus-4.1' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs · 64887b68
      Linus Torvalds authored
      Pull btrfs fixes from Chris Mason:
       "A few more btrfs fixes.
      
        These range from corners Filipe found in the new free space cache
        writeback to a grab bag of fixes from the list"
      
      * 'for-linus-4.1' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs:
        Btrfs: btrfs_release_extent_buffer_page didn't free pages of dummy extent
        Btrfs: fill ->last_trans for delayed inode in btrfs_fill_inode.
        btrfs: unlock i_mutex after attempting to delete subvolume during send
        btrfs: check io_ctl_prepare_pages return in __btrfs_write_out_cache
        btrfs: fix race on ENOMEM in alloc_extent_buffer
        btrfs: handle ENOMEM in btrfs_alloc_tree_block
        Btrfs: fix find_free_dev_extent() malfunction in case device tree has hole
        Btrfs: don't check for delalloc_bytes in cache_save_setup
        Btrfs: fix deadlock when starting writeback of bg caches
        Btrfs: fix race between start dirty bg cache writeout and bg deletion
      64887b68