1. 03 Jun, 2015 10 commits
    • Filipe Manana's avatar
      Btrfs: incremental send, fix clone operations for compressed extents · 619d8c4e
      Filipe Manana authored
      Marc reported a problem where the receiving end of an incremental send
      was performing clone operations that failed with -EINVAL. This happened
      because, unlike for uncompressed extents, we were not checking if the
      source clone offset and length, after summing the data offset, falls
      within the source file's boundaries.
      
      So make sure we do such checks when attempting to issue clone operations
      for compressed extents.
      
      Problem reproducible with the following steps:
      
        $ mkfs.btrfs -f /dev/sdb
        $ mount -o compress /dev/sdb /mnt
        $ mkfs.btrfs -f /dev/sdc
        $ mount -o compress /dev/sdc /mnt2
      
        # Create the file with a single extent of 128K. This creates a metadata file
        # extent item with a data start offset of 0 and a logical length of 128K.
        $ xfs_io -f -c "pwrite -S 0xaa 64K 128K" -c "fsync" /mnt/foo
      
        # Now rewrite the range 64K to 112K of our file. This will make the inode's
        # metadata continue to point to the 128K extent we created before, but now
        # with an extent item that points to the extent with a data start offset of
        # 112K and a logical length of 16K.
        # That metadata file extent item is associated with the logical file offset
        # at 176K and covers the logical file range 176K to 192K.
        $ xfs_io -c "pwrite -S 0xbb 64K 112K" -c "fsync" /mnt/foo
      
        # Now rewrite the range 180K to 12K. This will make the inode's metadata
        # continue to point the the 128K extent we created earlier, with a single
        # extent item that points to it with a start offset of 112K and a logical
        # length of 4K.
        # That metadata file extent item is associated with the logical file offset
        # at 176K and covers the logical file range 176K to 180K.
        $ xfs_io -c "pwrite -S 0xcc 180K 12K" -c "fsync" /mnt/foo
      
        $ btrfs subvolume snapshot -r /mnt /mnt/snap1
      
        $ touch /mnt/bar
        # Calls the btrfs clone ioctl.
        $ ~/xfstests/src/cloner -s $((176 * 1024)) -d $((176 * 1024)) \
          -l $((4 * 1024)) /mnt/foo /mnt/bar
      
        $ btrfs subvolume snapshot -r /mnt /mnt/snap2
      
        $ btrfs send /mnt/snap1 | btrfs receive /mnt2
        At subvol /mnt/snap1
        At subvol snap1
      
        $ btrfs send -p /mnt/snap1 /mnt/snap2 | btrfs receive /mnt2
        At subvol /mnt/snap2
        At snapshot snap2
        ERROR: failed to clone extents to bar
        Invalid argument
      
      A test case for fstests follows soon.
      Reported-by: default avatarMarc MERLIN <marc@merlins.org>
      Tested-by: default avatarMarc MERLIN <marc@merlins.org>
      Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
      Tested-by: default avatarDavid Sterba <dsterba@suse.cz>
      Tested-by: default avatarJan Alexander Steffens (heftig) <jan.steffens@gmail.com>
      Signed-off-by: default avatarChris Mason <clm@fb.com>
      619d8c4e
    • Christian Engelmayer's avatar
      btrfs: qgroup: Fix possible leak in btrfs_add_qgroup_relation() · ab3680dd
      Christian Engelmayer authored
      Commit 9c8b35b1 ("btrfs: quota: Automatically update related qgroups or
      mark INCONSISTENT flags when assigning/deleting a qgroup relations.")
      introduced the allocation of a temporary ulist in function
      btrfs_add_qgroup_relation() and added the corresponding cleanup to the out
      path. However, the allocation was introduced before the src/dst level check
      that directly returns. Fix the possible leakage of the ulist by moving the
      allocation after the input validation. Detected by Coverity CID 1295988.
      Signed-off-by: default avatarChristian Engelmayer <cengelma@gmx.at>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.cz>
      Signed-off-by: default avatarChris Mason <clm@fb.com>
      ab3680dd
    • Filipe Manana's avatar
      Btrfs: fix mutex unlock without prior lock on space cache truncation · 35c76642
      Filipe Manana authored
      If the call to btrfs_truncate_inode_items() failed and we don't have a block
      group, we were unlocking the cache_write_mutex without having locked it (we
      do it only if we have a block group).
      
      Fixes: 1bbc621e ("Btrfs: allow block group cache writeout
                            outside critical section in commit")
      Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.cz>
      Signed-off-by: default avatarChris Mason <clm@fb.com>
      35c76642
    • Anand Jain's avatar
      Btrfs: log when missing device is created · 816fcebe
      Anand Jain authored
      Signed-off-by: default avatarAnand Jain <anand.jain@oracle.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.cz>
      Signed-off-by: default avatarChris Mason <clm@fb.com>
      816fcebe
    • David Sterba's avatar
      btrfs: fix warnings after changes in btrfs_abort_transaction · 6d13f549
      David Sterba authored
      fs/btrfs/volumes.c: In function ‘btrfs_create_uuid_tree’:
      fs/btrfs/volumes.c:3909:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘long int’ [-Wformat=]
         btrfs_abort_transaction(trans, tree_root,
         ^
        CC [M]  fs/btrfs/ioctl.o
      fs/btrfs/ioctl.c: In function ‘create_subvol’:
      fs/btrfs/ioctl.c:549:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘long int’ [-Wformat=]
         btrfs_abort_transaction(trans, root, PTR_ERR(new_root));
      
      PTR_ERR returns long, but we're really using 'int' for the error codes
      everywhere so just set and use the local variable.
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.cz>
      Signed-off-by: default avatarChris Mason <clm@fb.com>
      6d13f549
    • David Sterba's avatar
      btrfs: add 'cold' compiler annotations to all error handling functions · c0d19e2b
      David Sterba authored
      The annotated functios will be placed into .text.unlikely section. The
      annotation also hints compiler to move the code out of the hot paths,
      and may implicitly mark if-statement leading to that block as unlikely.
      
      This is a heuristic, the impact on the generated code is not
      significant.
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.cz>
      Signed-off-by: default avatarChris Mason <clm@fb.com>
      c0d19e2b
    • David Sterba's avatar
      btrfs: report exact callsite where transaction abort occurs · 1a9a8a71
      David Sterba authored
      WARN is called from a single location and all bugreports say that's in
      super.c __btrfs_abort_transaction. This is slightly confusing as we'd
      rather want to know the exact callsite. Whereas this information is
      printed in the syslog below the stacktrace, this requires further look
      and we usually see only the headline from WARNING.
      
      Moving the WARN into the macro has to inline some code and increases
      code by a few kilobytes:
      
        text    data     bss     dec     hex filename
      835481   20305   14120  869906   d4612 btrfs.ko.before
      842883   20305   14120  877308   d62fc btrfs.ko.after
      
      The delta is +7k (130+ calls), measured on 3.19 x86_64, distro config.
      The increase is not small and could lead to worse icache use. The code
      is on error/exit paths that can be recognized by compiler as cold and
      moved out of the way so the impact is speculated to be low, if
      measurable at all.
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.cz>
      Signed-off-by: default avatarChris Mason <clm@fb.com>
      1a9a8a71
    • David Sterba's avatar
      btrfs: let tree defrag work in SSD mode · 13028901
      David Sterba authored
      Long time ago (2008) the defrag was automatic for new b-tree writes but
      has been disabled after performance problems. There was a leftover in
      tree-defrag.c that effectively stops any defragmentation on b-trees.
      This is a bit unexpected and IMHO undesired. The SSD mode is an
      optimization and defrag is supposed to work if the users asks for it.
      
      Related commits:
      
      6702ed49
      Btrfs: Add run time btree defrag, and an ioctl to force btree defrag
      
      e18e4809
      Btrfs: Add mount -o ssd, which includes optimizations for seek free
      storage
      
      b3236e68
      Btrfs: Leave on the tree defragger in mount -o ssd, it still helps there
      
      9afbb0b7
      Btrfs: Disable tree defrag in SSD mode
      
      The last three commits switch the defrag+ssd off/on/off and the last one
      
      3f157a2f
      Btrfs: Online btree defragmentation fixes
      
      misses the bits from tree-defrag.c to revert to the behaviour introduced
      in e18e4809.
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.cz>
      Signed-off-by: default avatarChris Mason <clm@fb.com>
      13028901
    • Filipe Manana's avatar
      Btrfs: check pending chunks when shrinking fs to avoid corruption · 53e489bc
      Filipe Manana authored
      When we shrink the usable size of a device (its total_bytes), we go over
      all the device extent items in the device tree and attempt to relocate
      the chunk of any device extent that goes beyond the new usable size for
      the device. We do that after setting the new usable size (total_bytes) in
      the device object, so that all new allocations (and reallocations) don't
      use areas of the device that go beyond the new (shorter) size. However we
      were not considering that before setting the new size in the device,
      pending chunks might have been created that use device extents that go
      beyond the new size, and those device extents are not yet in the device
      tree after we search the device tree - they are still attached to the
      list of new block group for some ongoing transaction handle, and they are
      only added to the device tree when the transaction handle is ended (via
      btrfs_create_pending_block_groups()).
      
      So check for pending chunks with device extents that go beyond the new
      size and if any exists, commit the current transaction and repeat the
      search in the device tree.
      
      Not doing this it would mean we would return success to user space while
      still having extents that go beyond the new size, and later user space
      could override those locations on the device while the fs still references
      them, causing all sorts of corruption and unexpected events.
      Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
      Signed-off-by: default avatarChris Mason <clm@fb.com>
      53e489bc
    • Omar Sandoval's avatar
      Btrfs: don't invalidate root dentry when subvolume deletion fails · 64ad6c48
      Omar Sandoval authored
      Since commit bafc9b75 ("vfs: More precise tests in d_invalidate"),
      mounted subvolumes can be deleted because d_invalidate() won't fail.
      However, we run into problems when we attempt to delete the default
      subvolume while it is mounted as the root filesystem:
      
      	# btrfs subvol list /
      	ID 257 gen 306 top level 5 path rootvol
      	ID 267 gen 334 top level 5 path snap1
      	# btrfs subvol get-default /
      	ID 267 gen 334 top level 5 path snap1
      	# btrfs inspect-internal rootid /
      	267
      	# mount -o subvol=/ /dev/vda1 /mnt
      	# btrfs subvol del /mnt/snap1
      	Delete subvolume (no-commit): '/mnt/snap1'
      	ERROR: cannot delete '/mnt/snap1' - Operation not permitted
      	# findmnt /
      	findmnt: can't read /proc/mounts: No such file or directory
      	# ls /proc
      	#
      
      Markus reported that this same scenario simply led to a kernel oops.
      
      This happens because in btrfs_ioctl_snap_destroy(), we call
      d_invalidate() before we check may_destroy_subvol(), which means that we
      detach the submounts and drop the dentry before erroring out. Instead,
      we should only invalidate the dentry once the deletion has succeeded.
      Additionally, the shrink_dcache_sb() isn't necessary; d_invalidate()
      will prune the dcache for the deleted subvolume.
      
      Cc: <stable@vger.kernel.org>
      Fixes: bafc9b75 ("vfs: More precise tests in d_invalidate")
      Reported-by: default avatarMarkus Schauler <mschauler@gmail.com>
      Signed-off-by: default avatarOmar Sandoval <osandov@osandov.com>
      Signed-off-by: default avatarChris Mason <clm@fb.com>
      64ad6c48
  2. 01 Jun, 2015 1 commit
  3. 31 May, 2015 13 commits
  4. 30 May, 2015 3 commits
  5. 29 May, 2015 13 commits
    • Linus Torvalds's avatar
      Merge tag 'xfs-for-linus-4.1-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/dgc/linux-xfs · 1be44e23
      Linus Torvalds authored
      Pull xfs fixes from Dave Chinner:
       "This is a little larger than I'd like late in the release cycle, but
        all the fixes are for regressions introduced in the 4.1-rc1 merge, or
        are needed back in -stable kernels fairly quickly as they are
        filesystem corruption or userspace visible correctness issues.
      
        Changes in this update:
      
         - regression fix for new rename whiteout code
      
         - regression fixes for new superblock generic per-cpu counter code
      
         - fix for incorrect error return sign introduced in 3.17
      
         - metadata corruption fixes that need to go back to -stable kernels"
      
      * tag 'xfs-for-linus-4.1-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/dgc/linux-xfs:
        xfs: fix broken i_nlink accounting for whiteout tmpfile inode
        xfs: xfs_iozero can return positive errno
        xfs: xfs_attr_inactive leaves inconsistent attr fork state behind
        xfs: extent size hints can round up extents past MAXEXTLEN
        xfs: inode and free block counters need to use __percpu_counter_compare
        percpu_counter: batch size aware __percpu_counter_compare()
        xfs: use percpu_counter_read_positive for mp->m_icount
      1be44e23
    • Linus Torvalds's avatar
      Merge tag 'fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc · 2a645171
      Linus Torvalds authored
      Pull ARM SoC fixes from Arnd Bergmann:
       "Two weeks worth of small bug fixes this time, nothing sticking out
        this time:
      
         - one defconfig change to adapt to a modified Kconfig symbol
      
         - two fixes for i.MX for backwards compatibility with older DT files
           that was accidentally broken
      
         - one regression fix for irq handling on pxa
      
         - three small dt files on omap, and one each for imx and exynos"
      
      * tag 'fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc:
        ARM: multi_v7_defconfig: Replace CONFIG_USB_ISP1760_HCD by CONFIG_USB_ISP1760
        ARM: imx6: gpc: don't register power domain if DT data is missing
        ARM: imx6: allow booting with old DT
        ARM: dts: set display clock correctly for exynos4412-trats2
        ARM: pxa: pxa_cplds: signedness bug in probe
        ARM: dts: Fix WLAN interrupt line for AM335x EVM-SK
        ARM: dts: omap3-devkit8000: Fix NAND DT node
        ARM: dts: am335x-boneblack: disable RTC-only sleep
        ARM: dts: fix imx27 dtb build rule
        ARM: dts: imx27: only map 4 Kbyte for fec registers
      2a645171
    • Linus Torvalds's avatar
      Merge tag 'dm-4.1-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm · 0f1e5b5d
      Linus Torvalds authored
      Pull device-mapper fixes from Mike Snitzer:
       "Quite a few fixes for DM's blk-mq support thanks to extra DM multipath
        testing from Junichi Nomura and Bart Van Assche.
      
        Also fix a casting bug in dm_merge_bvec() that could cause only a
        single page to be added to a bio (Joe identified this while testing
        dm-cache writeback)"
      
      * tag 'dm-4.1-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm:
        dm: fix casting bug in dm_merge_bvec()
        dm: fix reload failure of 0 path multipath mapping on blk-mq devices
        dm: fix false warning in free_rq_clone() for unmapped requests
        dm: requeue from blk-mq dm_mq_queue_rq() using BLK_MQ_RQ_QUEUE_BUSY
        dm mpath: fix leak of dm_mpath_io structure in blk-mq .queue_rq error path
        dm: fix NULL pointer when clone_and_map_rq returns !DM_MAPIO_REMAPPED
        dm: run queue on re-queue
      0f1e5b5d
    • Guenter Roeck's avatar
      hwmon: (tmp401) Do not auto-detect chip on I2C address 0x37 · 9aecac04
      Guenter Roeck authored
      I2C address 0x37 may be used by EEPROMs, which can result in false
      positives. Do not attempt to detect a chip at this address.
      Reviewed-by: default avatarJean Delvare <jdelvare@suse.de>
      Cc: stable@vger.kernel.org # v4.0+
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      9aecac04
    • Linus Torvalds's avatar
      Merge branch 'akpm' (patches from Andrew) · c2102f3d
      Linus Torvalds authored
      Merge misc fixes from Andrew Morton:
       "10 fixes"
      
      * emailed patches from Andrew Morton <akpm@linux-foundation.org>:
        scripts/gdb: fix lx-lsmod refcnt
        omfs: fix potential integer overflow in allocator
        omfs: fix sign confusion for bitmap loop counter
        omfs: set error return when d_make_root() fails
        fs, omfs: add NULL terminator in the end up the token list
        MAINTAINERS: update CAPABILITIES pattern
        fs/binfmt_elf.c:load_elf_binary(): return -EINVAL on zero-length mappings
        tracing/mm: don't trace mm_page_pcpu_drain on offline cpus
        tracing/mm: don't trace mm_page_free on offline cpus
        tracing/mm: don't trace kmem_cache_free on offline cpus
      c2102f3d
    • Linus Torvalds's avatar
      Merge tag 'fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux · 6e49ba1b
      Linus Torvalds authored
      Pull fixes for cpumask and modules from Rusty Russell:
       "** NOW WITH TESTING! **
      
        Two fixes which got lost in my recent distraction.  One is a weird
        cpumask function which needed to be rewritten, the other is a module
        bug which is cc:stable"
      
      * tag 'fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux:
        cpumask_set_cpu_local_first => cpumask_local_spread, lament
        module: Call module notifier on failure after complete_formation()
      6e49ba1b
    • Maciej W. Rozycki's avatar
      MIPS: strnlen_user.S: Fix a CPU_DADDI_WORKAROUNDS regression · c4fca4fd
      Maciej W. Rozycki authored
      Correct a regression introduced with 8453eebd [MIPS: Fix strnlen_user()
      return value in case of overlong strings.] causing assembler warnings
      and broken code generated in __strnlen_kernel_nocheck_asm:
      
      arch/mips/lib/strnlen_user.S: Assembler messages:
      arch/mips/lib/strnlen_user.S:64: Warning: Macro instruction expanded into multiple instructions in a branch delay slot
      
      with the CPU_DADDI_WORKAROUNDS option set, resulting in the function
      looping indefinitely upon mounting NFS root.
      
      Use conditional assembly to avoid a microMIPS code size regression.
      Using $at unconditionally would cause such a regression as there are no
      16-bit instruction encodings available for ALU operations using this
      register.  Using $v1 unconditionally would produce short microMIPS
      encodings, but would prevent this register from being used across calls
      to this function.
      
      The extra LI operation introduced is free, replacing a NOP originally
      scheduled into the delay slot of the branch that follows.
      Signed-off-by: default avatarMaciej W. Rozycki <macro@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/10205/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      c4fca4fd
    • Petri Gynther's avatar
      MIPS: BMIPS: Fix bmips_wr_vec() · 57b41758
      Petri Gynther authored
      bmips_wr_vec() copies exception vector code from start to dst.
      
      The call to dma_cache_wback() needs to flush (end-start) bytes,
      starting at dst, from write-back cache to memory.
      Signed-off-by: default avatarPetri Gynther <pgynther@google.com>
      Acked-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Reviewed-by: default avatarKevin Cernekee <cernekee@gmail.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/10193/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      57b41758
    • Laurent Fasnacht's avatar
      MIPS: ath79: fix build problem if CONFIG_BLK_DEV_INITRD is not set · 556b6629
      Laurent Fasnacht authored
      initrd_start is defined in init/do_mounts_initrd.c, which is only
      included in kernel if CONFIG_BLK_DEV_INITRD=y.
      Signed-off-by: default avatarLaurent Fasnacht <l@libres.ch>
      Cc: linux-mips@linux-mips.org
      Cc: trivial@kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/10198/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      556b6629
    • Linus Torvalds's avatar
      Merge branch 'drm-fixes' of git://people.freedesktop.org/~airlied/linux · d0af6988
      Linus Torvalds authored
      Pull drm fixes from Dave Airlie:
       "This is made up 4 groups of fixes detailed below.
      
        vgem:
            Due to some misgivings about possible bad use cases this allow,
            backout a chunk of the interface to stop those use cases for now.
      
        radeon:
            Fix for an oops regression in the audio code, and a partial revert
            for a fix that was cauing problems.
      
        nouveau:
            regression fix for Fermi, and display-less Maxwell boot fixes.
      
        drm core:
            a fix for i915 cursor vblank waiting in the atomic helpers"
      
      * 'drm-fixes' of git://people.freedesktop.org/~airlied/linux:
        drm/nouveau/gr/gm204: remove a stray printk
        drm/nouveau/devinit/gm100-: force devinit table execution on boards without PDISP
        drm/nouveau/devinit/gf100: make the force-post condition more obvious
        drm/nouveau/gr/gf100-: fix wrong constant definition
        drm/radeon: partially revert "fix VM_CONTEXT*_PAGE_TABLE_END_ADDR handling"
        drm/radeon/audio: make sure connector is valid in hotplug case
        Revert "drm/radeon: only mark audio as connected if the monitor supports it (v3)"
        drm/radeon: don't share plls if monitors differ in audio support
        drm/vgem: drop DRIVER_PRIME (v2)
        drm/plane-helper: Adapt cursor hack to transitional helpers
      d0af6988
    • Linus Torvalds's avatar
      Merge tag 'sound-4.1-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound · 70946b5d
      Linus Torvalds authored
      Pull sound fixes from Takashi Iwai:
       "No big surprise here, just a bunch of small fixes for HD-audio and
        USB-audio:
      
         - partial revert of widget power-saving for IDT codecs
         - revert mute-LED enum ctl for Thinkpads due to confusion
         - a quirk for a new Radeon HDMI controller
         - Realtek codec name fix for Dell
         - a workaround for headphone mic boost on some laptops
         - stream_pm ops setup (and its fix for regression)
         - another quirk for MS LifeCam USB-audio"
      
      * tag 'sound-4.1-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound:
        ALSA: hda - Fix lost sound due to stream_pm ops cleanup
        ALSA: hda - Disable Headphone Mic boost for ALC662
        ALSA: hda - Disable power_save_node for IDT92HD71bxx
        ALSA: hda - Fix noise on AMD radeon 290x controller
        ALSA: hda - Set stream_pm ops automatically by generic parser
        ALSA: hda/realtek - Add ALC256 alias name for Dell
        Revert "ALSA: hda - Add mute-LED mode control to Thinkpad"
        ALSA: usb-audio: Add quirk for MS LifeCam HD-3000
      70946b5d
    • Joe Thornber's avatar
      dm: fix casting bug in dm_merge_bvec() · 1c220c69
      Joe Thornber authored
      dm_merge_bvec() was originally added in f6fccb ("dm: introduce
      merge_bvec_fn").  In that commit a value in sectors is converted to
      bytes using << 9, and then assigned to an int.  This code made
      assumptions about the value of BIO_MAX_SECTORS.
      
      A later commit 148e51 ("dm: improve documentation and code clarity in
      dm_merge_bvec") was meant to have no functional change but it removed
      the use of BIO_MAX_SECTORS in favor of using queue_max_sectors().  At
      this point the cast from sector_t to int resulted in a zero value.  The
      fallout being dm_merge_bvec() would only allow a single page to be added
      to a bio.
      
      This interim fix is minimal for the benefit of stable@ because the more
      comprehensive cleanup of passing a sector_t to all DM targets' merge
      function will impact quite a few DM targets.
      Signed-off-by: default avatarJoe Thornber <ejt@redhat.com>
      Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
      Cc: stable@vger.kernel.org # 3.19+
      1c220c69
    • Junichi Nomura's avatar
      dm: fix reload failure of 0 path multipath mapping on blk-mq devices · 15b94a69
      Junichi Nomura authored
      dm-multipath accepts 0 path mapping.
      
        # echo '0 2097152 multipath 0 0 0 0' | dmsetup create newdev
      
      Such a mapping can be used to release underlying devices while still
      holding requests in its queue until working paths come back.
      
      However, once the multipath device is created over blk-mq devices,
      it rejects reloading of 0 path mapping:
      
        # echo '0 2097152 multipath 0 0 1 1 queue-length 0 1 1 /dev/sda 1' \
            | dmsetup create mpath1
        # echo '0 2097152 multipath 0 0 0 0' | dmsetup load mpath1
        device-mapper: reload ioctl on mpath1 failed: Invalid argument
        Command failed
      
      With following kernel message:
        device-mapper: ioctl: can't change device type after initial table load.
      
      DM tries to inherit the current table type using dm_table_set_type()
      but it doesn't work as expected because of unnecessary check about
      whether the target type is hybrid or not.
      
      Hybrid type is for targets that work as either request-based or bio-based
      and not required for blk-mq or non blk-mq checking.
      
      Fixes: 65803c20 ("dm table: train hybrid target type detection to select blk-mq if appropriate")
      Signed-off-by: default avatarJun'ichi Nomura <j-nomura@ce.jp.nec.com>
      Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
      15b94a69