14 Oct, 2013

10 commits

  • Linus Torvalds
     
  • Pull watchdog fixes from Wim Van Sebroeck:
    "This will fix a deadlock on the ts72xx_wdt driver, fix bitmasks in the
    kempld_wdt driver and fix a section mismatch in the sunxi_wdt driver"

    * git://www.linux-watchdog.org/linux-watchdog:
    watchdog: sunxi: Fix section mismatch
    watchdog: kempld_wdt: Fix bit mask definition
    watchdog: ts72xx_wdt: locking bug in ioctl

    Linus Torvalds
     
  • This driver has a section mismatch, for probe and remove functions,
    leading to the following warning during the compilation.

    WARNING: drivers/watchdog/built-in.o(.data+0x24): Section mismatch in
    reference from the variable sunxi_wdt_driver to the function
    .init.text:sunxi_wdt_probe()
    The variable sunxi_wdt_driver references
    the function __init sunxi_wdt_probe()

    Signed-off-by: Maxime Ripard
    Reviewed-by: Guenter Roeck
    Signed-off-by: Wim Van Sebroeck

    Maxime Ripard
     
  • STAGE_CFG bits are defined as [5:4] bits. However, '(((x) & 0x30) << 4)'
    handles [9:8] bits. Thus, it should be fixed in order to handle
    [5:4] bits.

    Signed-off-by: Jingoo Han
    Reviewed-by: Guenter Roeck
    Signed-off-by: Wim Van Sebroeck

    Jingoo Han
     
  • Calling the WDIOC_GETSTATUS & WDIOC_GETBOOTSTATUS and twice will cause a
    interruptible deadlock.

    Signed-off-by: Dan Carpenter
    Reviewed-by: Guenter Roeck
    Signed-off-by: Wim Van Sebroeck

    Dan Carpenter
     
  • Pull ARM SoC fixes from Olof Johansson:
    "A small batch of fixes this week, mostly OMAP related. Nothing stands
    out as particularly controversial.

    Also a fix for a 3.12-rc1 timer regression for Exynos platforms,
    including the Chromebooks"

    * tag 'fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc:
    ARM: exynos: dts: Update 5250 arch timer node with clock frequency
    ARM: OMAP2: RX-51: Add missing max_current to rx51_lp5523_led_config
    ARM: mach-omap2: board-generic: fix undefined symbol
    ARM: dts: Fix pinctrl mask for omap3
    ARM: OMAP3: Fix hardware detection for omap3630 when booted with device tree
    ARM: OMAP2: gpmc-onenand: fix sync mode setup with DT

    Linus Torvalds
     
  • Without the "clock-frequency" property in arch timer node, could able
    to see the below crash dump.

    [] (unwind_backtrace+0x0/0xf4) from [] (show_stack+0x10/0x14)
    [] (show_stack+0x10/0x14) from [] (dump_stack+0x7c/0xb0)
    [] (dump_stack+0x7c/0xb0) from [] (Ldiv0_64+0x8/0x18)
    [] (Ldiv0_64+0x8/0x18) from [] (clockevents_config.part.2+0x1c/0x74)
    [] (clockevents_config.part.2+0x1c/0x74) from [] (clockevents_config_and_register+0x20/0x2c)
    [] (clockevents_config_and_register+0x20/0x2c) from [] (arch_timer_setup+0xa8/0x134)
    [] (arch_timer_setup+0xa8/0x134) from [] (arch_timer_init+0x1f4/0x24c)
    [] (arch_timer_init+0x1f4/0x24c) from [] (clocksource_of_init+0x34/0x58)
    [] (clocksource_of_init+0x34/0x58) from [] (time_init+0x20/0x2c)
    [] (time_init+0x20/0x2c) from [] (start_kernel+0x1e0/0x39c)

    THis is because the Exynos u-boot, for example on the Chromebooks, doesn't set
    up the CNTFRQ register as expected by arch_timer. Instead, we have to specify
    the frequency in the device tree like this.

    Signed-off-by: Yuvaraj Kumar C D
    [olof: Changed subject, added comment, elaborated on commit message]
    Signed-off-by: Olof Johansson

    Yuvaraj Kumar C D
     
  • …kernel/git/tmlind/linux-omap into fixes

    From Tony Lindgren:

    Few fixes for omap3 related hangs and errors that people have
    noticed now that people are actually using the device tree
    based booting for omap3.

    Also one regression fix for timer compile for dra7xx when
    omap5 is not selected, and a LED regression fix for n900.

    * tag 'fixes-against-v3.12-rc3-take2' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap:
    ARM: OMAP2: RX-51: Add missing max_current to rx51_lp5523_led_config
    ARM: mach-omap2: board-generic: fix undefined symbol
    ARM: dts: Fix pinctrl mask for omap3
    ARM: OMAP3: Fix hardware detection for omap3630 when booted with device tree
    ARM: OMAP2: gpmc-onenand: fix sync mode setup with DT

    Signed-off-by: Olof Johansson <olof@lixom.net>

    Olof Johansson
     
  • Pull parisc fixes from Helge Deller:
    "This patchset includes a bugfix to prevent a kernel crash when memory
    in page zero is accessed by the kernel itself, e.g. via
    probe_kernel_read().

    Furthermore we now export flush_cache_page() which is needed
    (indirectly) by the lustre filesystem. The other patches remove
    unused functions and optimizes the page fault handler to only evaluate
    variables if needed, which again protects against possible kernel
    crashes"

    * 'parisc-3.12' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux:
    parisc: let probe_kernel_read() capture access to page zero
    parisc: optimize variable initialization in do_page_fault
    parisc: fix interruption handler to respect pagefault_disable()
    parisc: mark parisc_terminate() noreturn and cold.
    parisc: remove unused syscall_ipi() function.
    parisc: kill SMP single function call interrupt
    parisc: Export flush_cache_page() (needed by lustre)

    Linus Torvalds
     
  • Pull slave-dmaengine fixes from Vinod Koul:
    "Another week, time to send another fixes request taking time out of
    extended weekend for the festivities in this part of the world.

    We have two fixes from Sergei for rcar driver and one fixing memory
    leak of edma driver by Geyslan"

    * 'fixes' of git://git.infradead.org/users/vkoul/slave-dma:
    dma: edma.c: remove edma_desc leakage
    rcar-hpbdma: add parameter to set_slave() method
    rcar-hpbdma: remove shdma_free_irq() calls

    Linus Torvalds
     

13 Oct, 2013

16 commits

  • Signed-off-by: Helge Deller

    Helge Deller
     
  • The attached change defers the initialization of the variables tsk, mm
    and flags until they are needed. As a result, the code won't crash if a
    kernel probe is done with a corrupt context and the code will be better
    optimized.

    Signed-off-by: John David Anglin
    Signed-off-by: Helge Deller

    John David Anglin
     
  • Running an "echo t > /proc/sysrq-trigger" crashes the parisc kernel. The
    problem is, that in print_worker_info() we try to read the workqueue info via
    the probe_kernel_read() functions which use pagefault_disable() to avoid
    crashes like this:
    probe_kernel_read(&pwq, &worker->current_pwq, sizeof(pwq));
    probe_kernel_read(&wq, &pwq->wq, sizeof(wq));
    probe_kernel_read(name, wq->name, sizeof(name) - 1);

    The problem here is, that the first probe_kernel_read(&pwq) might return zero
    in pwq and as such the following probe_kernel_reads() try to access contents of
    the page zero which is read protected and generate a kernel segfault.

    With this patch we fix the interruption handler to call parisc_terminate()
    directly only if pagefault_disable() was not called (in which case
    preempt_count()==0). Otherwise we hand over to the pagefault handler which
    will try to look up the faulting address in the fixup tables.

    Signed-off-by: Helge Deller
    Cc: # v3.0+
    Signed-off-by: John David Anglin
    Signed-off-by: Helge Deller

    Helge Deller
     
  • Signed-off-by: Helge Deller

    Helge Deller
     
  • Signed-off-by: Helge Deller

    Helge Deller
     
  • Commit 9a46ad6d6df3b54 "smp: make smp_call_function_many() use logic
    similar to smp_call_function_single()" has unified the way to handle
    single and multiple cross-CPU function calls. Now only one interrupt
    is needed for architecture specific code to support generic SMP function
    call interfaces, so kill the redundant single function call interrupt.

    Signed-off-by: Jiang Liu
    Cc: Jiang Liu
    Signed-off-by: Helge Deller

    Jiang Liu
     
  • ERROR: "flush_cache_page" [drivers/staging/lustre/lustre/libcfs/libcfs.ko] undefined!

    Signed-off-by: Geert Uytterhoeven
    Signed-off-by: Helge Deller

    Geert Uytterhoeven
     
  • Olga reported that file descriptors opened with O_PATH do not work with
    fstatfs(), found during further development of ksh93's thread support.

    There is no reason to not allow O_PATH file descriptors here (fstatfs is
    very much a path operation), so use "fdget_raw()". See commit
    55815f70147d ("vfs: make O_PATH file descriptors usable for 'fstat()'")
    for a very similar issue reported for fstat() by the same team.

    Reported-and-tested-by: ольга крыжановская
    Acked-by: Al Viro
    Cc: stable@kernel.org # O_PATH introduced in 3.0+
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     
  • Pull ext4 bugfixes from Ted Ts'o:
    "A bug fix and performance regression fix for ext4"

    * tag 'ext4_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4:
    ext4: fix memory leak in xattr
    ext4: fix performance regression in writeback of random writes

    Linus Torvalds
     
  • Pull btrfs fixes from Chris Mason:
    "We've got more bug fixes in my for-linus branch:

    One of these fixes another corner of the compression oops from last
    time. Miao nailed down some problems with concurrent snapshot
    deletion and drive balancing.

    I kept out one of his patches for more testing, but these are all
    stable"

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs:
    Btrfs: fix oops caused by the space balance and dead roots
    Btrfs: insert orphan roots into fs radix tree
    Btrfs: limit delalloc pages outside of find_delalloc_range
    Btrfs: use right root when checking for hash collision

    Linus Torvalds
     
  • Pull sound fixes from Takashi Iwai:
    "All stable fixes except for a trivial headset mic fixup: the removal
    of bogus frame checks in snd-usb-usx2y driver that have regressed in
    the recent kernel versions, the HD-audio HDMI channel map fix, and a
    few HD-audio device-specific fixes"

    * tag 'sound-3.12' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound:
    ALSA: hda - Sony VAIO Pro 13 (haswell) now has a working headset jack
    ALSA: hda - Add a headset mic model for ALC269 and friends
    ALSA: hda - Fix microphone for Sony VAIO Pro 13 (Haswell model)
    ALSA: hda - Add fixup for ASUS N56VZ
    ALSA: hda - hdmi: Fix channel map switch not taking effect
    ALSA: hda - Fix mono speakers and headset mic on Dell Vostro 5470
    ALSA: snd-usb-usx2y: remove bogus frame checks

    Linus Torvalds
     
  • Pull i2c fixes from Wolfram Sang:
    "We had various reports of problems with deferred probing in the I2C
    subsystem, so this pull requst is a little bigger than usual.

    Most issues should be addressed now so devices will be found
    correctly. A few ususal driver bugfixes are in here, too"

    * 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
    i2c: i2c-mux-pinctrl: use deferred probe when adapter not found
    i2c: i2c-arb-gpio-challenge: use deferred probe when adapter not found
    i2c: i2c-mux-gpio: use deferred probing
    i2c: i2c-mux-gpio: don't ignore of_get_named_gpio errors
    i2c: omap: Clear ARDY bit twice
    i2c: Not all adapters have a parent
    i2c: i2c-stu300: replace platform_driver_probe to support deferred probing
    i2c: i2c-mxs: replace platform_driver_probe to support deferred probing
    i2c: i2c-imx: replace platform_driver_probe to support deferred probing
    i2c: i2c-designware-platdrv: replace platform_driver_probe to support deferred probing

    Linus Torvalds
     
  • If we take the 2nd retry path in ext4_expand_extra_isize_ea, we
    potentionally return from the function without having freed these
    allocations. If we don't do the return, we over-write the previous
    allocation pointers, so we leak either way.

    Spotted with Coverity.

    [ Fixed by tytso to set is and bs to NULL after freeing these
    pointers, in case in the retry loop we later end up triggering an
    error causing a jump to cleanup, at which point we could have a double
    free bug. -- Ted ]

    Signed-off-by: Dave Jones
    Signed-off-by: "Theodore Ts'o"
    Reviewed-by: Eric Sandeen
    Cc: stable@vger.kernel.org

    Dave Jones
     
  • Pull gcc "asm goto" miscompilation workaround from Ingo Molnar:
    "This is the fix for the GCC miscompilation discussed in the following
    lkml thread:

    [x86] BUG: unable to handle kernel paging request at 00740060

    The bug in GCC has been fixed by Jakub and the fix will be part of the
    GCC 4.8.2 release expected to be released next week - so the quirk's
    version test checks for miscompilation bug

    Linus Torvalds
     
  • Pull x86 fixes from Ingo Molnar:
    "A build fix and a reboot quirk"

    * 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
    x86/reboot: Add reboot quirk for Dell Latitude E5410
    x86, build, pci: Fix PCI_MSI build on !SMP

    Linus Torvalds
     
  • Pull ARC fix from Vineet Gupta:
    "Fix for broken gdb 'jump'"

    * tag 'arc-fixes-for-3.12-part3' of git://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc:
    ARC: Ignore ptrace SETREGSET request for synthetic register "stop_pc"

    Linus Torvalds
     

12 Oct, 2013

3 commits

  • ARCompact TRAP_S insn used for breakpoints, commits before exception is
    taken (updating architectural PC). So ptregs->ret contains next-PC and
    not the breakpoint PC itself. This is different from other restartable
    exceptions such as TLB Miss where ptregs->ret has exact faulting PC.
    gdb needs to know exact-PC hence ARC ptrace GETREGSET provides for
    @stop_pc which returns ptregs->ret vs. EFA depending on the
    situation.

    However, writing stop_pc (SETREGSET request), which updates ptregs->ret
    doesn't makes sense stop_pc doesn't always correspond to that reg as
    described above.

    This was not an issue so far since user_regs->ret / user_regs->stop_pc
    had same value and both writing to ptregs->ret was OK, needless, but NOT
    broken, hence not observed.

    With gdb "jump", they diverge, and user_regs->ret updating ptregs is
    overwritten immediately with stop_pc, which this patch fixes.

    Reported-by: Anton Kolesov
    Signed-off-by: Vineet Gupta

    Vineet Gupta
     
  • Pull MIPS fix from Ralf Baechle:
    "Just one fix. The stack protector was loading the value of the canary
    instead of its address"

    * 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus:
    MIPS: stack protector: Fix per-task canary switch

    Linus Torvalds
     
  • Pull drm fixes from Dave Airlie:
    "All over the map..

    - nouveau:
    disable MSI, needs more work, will try again next merge window
    - radeon:
    audio + uvd regression fixes, dpm fixes, reset fixes
    - i915:
    the dpms fix might fix your haswell

    And one pain in the ass revert, so we have VGA arbitration that when
    implemented 4-5 years ago really hoped that GPUs could remove
    themselves from arbitration completely once they had a kernel driver.

    It seems Intel hw designers decided that was too nice a facility to
    allow us to have so they removed it when they went on-die (so since
    Ironlake at least). Now Alex Williamson added support for VGA
    arbitration for newer GPUs however this now exposes itself to
    userspace as requireing arbitration of GPU VGA regions and the X
    server gets involved and disables things that it can't handle when VGA
    access is possibly required around every operation.

    So in order to not break userspace we just reverted things back to the
    old known broken status so maybe we can try and design out way out.

    Ville also had a patch to use stop machine for the two times Intel
    needs to access VGA space, that might be acceptable with some rework,
    but for now myself and Daniel agreed to just go back"

    * 'drm-fixes' of git://people.freedesktop.org/~airlied/linux: (23 commits)
    Revert "i915: Update VGA arbiter support for newer devices"
    Revert "drm/i915: Delay disabling of VGA memory until vgacon->fbcon handoff is done"
    drm/radeon: re-enable sw ACR support on pre-DCE4
    drm/radeon/dpm: disable bapm on TN asics
    drm/radeon: improve soft reset on CIK
    drm/radeon: improve soft reset on SI
    drm/radeon/dpm: off by one in si_set_mc_special_registers()
    drm/radeon/dpm/btc: off by one in btc_set_mc_special_registers()
    drm/radeon: forever loop on error in radeon_do_test_moves()
    drm/radeon: fix hw contexts for SUMO2 asics
    drm/radeon: fix typo in CP DMA register headers
    drm/radeon/dpm: disable multiple UVD states
    drm/radeon: use hw generated CTS/N values for audio
    drm/radeon: fix N/CTS clock matching for audio
    drm/radeon: use 64-bit math to calculate CTS values for audio (v2)
    drm/edid: catch kmalloc failure in drm_edid_to_speaker_allocation
    Revert "drm/fb-helper: don't sleep for screen unblank when an oops is in progress"
    drm/gma500: fix things after get/put page helpers
    drm/nouveau/mc: disable msi support by default, it's busted in tons of places
    drm/i915: Only apply DPMS to the encoder if enabled
    ...

    Linus Torvalds
     

11 Oct, 2013

11 commits

  • Just got the positive confirmation from a tester:
    https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1227093/comments/28

    Signed-off-by: David Henningsson
    Signed-off-by: Takashi Iwai

    David Henningsson
     
  • Using the headset mic model will cause the headset mic to be labeled
    "headset mic" instead of just "mic".

    Signed-off-by: David Henningsson
    Signed-off-by: Takashi Iwai

    David Henningsson
     
  • The external mic showed up with a precense detect of "always present",
    essentially disabling the internal mic. Therefore turn off presence
    detection for this pin.

    Note: The external mic seems not yet working, but an internal mic is
    certainly better than no mic at all.

    Cc: stable@vger.kernel.org
    BugLink: https://bugs.launchpad.net/bugs/1227093
    Signed-off-by: David Henningsson
    Signed-off-by: Takashi Iwai

    David Henningsson
     
  • Fengguang Wu, Oleg Nesterov and Peter Zijlstra tracked down
    a kernel crash to a GCC bug: GCC miscompiles certain 'asm goto'
    constructs, as outlined here:

    http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670

    Implement a workaround suggested by Jakub Jelinek.

    Reported-and-tested-by: Fengguang Wu
    Reported-by: Oleg Nesterov
    Reported-by: Peter Zijlstra
    Suggested-by: Jakub Jelinek
    Reviewed-by: Richard Henderson
    Cc: Linus Torvalds
    Cc: Andrew Morton
    Cc:
    Signed-off-by: Ingo Molnar

    Ingo Molnar
     
  • This reverts commit 81b5c7bc8de3e6f63419139c2fc91bf81dea8a7d.

    Adding drm/i915 into the vga arbiter chain means that X (in a piece of
    well-meant paranoia) will do a get/put on the vga decoding around
    _every_ accel call down into the ddx. Which results in some nice
    performance disasters [1]. This really breaks userspace, by disabling
    DRI for everyone, and stops OpenGL from working, this isn't limited
    to just the i915 but both the integrated and discrete GPUs on
    multi-gpu systems, in other words this causes untold worlds of pain,

    Ville tried to come up with a Great Hack to fiddle the required VGA
    I/O ops behind everyone's back using stop_machine, but that didn't
    really work out [2]. Given that we're fairly late in the -rc stage for
    such games let's just revert this all.

    One thing we might want to keep is to delay the disabling of the vga
    decoding until the fbdev emulation and the fbcon screen is set up. If
    we kill vga mem decoding beforehand fbcon can end up with a white
    square in the top-left corner it tried to save from the vga memory for
    a seamless transition. And we have bug reports on older platforms
    which seem to match these symptoms.

    But again that's something to play around with in -next.

    References: [1] http://lists.x.org/archives/xorg-devel/2013-September/037763.html
    References: [2] http://www.spinics.net/lists/intel-gfx/msg34062.html
    Cc: Alex Williamson
    Cc: Ville Syrjälä
    Cc: Chris Wilson
    Signed-off-by: Daniel Vetter
    Signed-off-by: Dave Airlie

    Dave Airlie
     
  • This reverts commit 6e1b4fdad5157bb9e88777d525704aba24389bee.

    This is part of a revert due to a userspace breakage, better explained in the revert of 1a1a4cbf4906a13c0c377f708df5d94168e7b582.

    Signed-off-by: Daniel Vetter
    Signed-off-by: Dave Airlie

    Dave Airlie
     
  • Regression fixes for audio and UVD, several hang fixes,
    some DPM fixes.

    * 'drm-fixes-3.12' of git://people.freedesktop.org/~agd5f/linux:
    drm/radeon: re-enable sw ACR support on pre-DCE4
    drm/radeon/dpm: disable bapm on TN asics
    drm/radeon: improve soft reset on CIK
    drm/radeon: improve soft reset on SI
    drm/radeon/dpm: off by one in si_set_mc_special_registers()
    drm/radeon/dpm/btc: off by one in btc_set_mc_special_registers()
    drm/radeon: forever loop on error in radeon_do_test_moves()
    drm/radeon: fix hw contexts for SUMO2 asics
    drm/radeon: fix typo in CP DMA register headers
    drm/radeon/dpm: disable multiple UVD states
    drm/radeon: use hw generated CTS/N values for audio
    drm/radeon: fix N/CTS clock matching for audio
    drm/radeon: use 64-bit math to calculate CTS values for audio (v2)
    drm/edid: catch kmalloc failure in drm_edid_to_speaker_allocation

    Dave Airlie
     
  • Free memory allocated to edma_desc when failing to allocate slot.

    Signed-off-by: Geyslan G. Bem
    Signed-off-by: Vinod Koul

    Geyslan G. Bem
     
  • Commit 4981c4dc194efb18f0e9a02f1b43e926f2f0d2bb (DMA: shdma: switch DT mode to
    use configuration data from a match table) added a new parameter to set_slave()
    method but unfortunately got merged later than commit c4f6c41ba790bbbfcebb4c47a
    (dma: add driver for R-Car HPB-DMAC), so that the HPB-DMAC driver retained the
    old prototype which caused this warning:

    drivers/dma/sh/rcar-hpbdma.c:485: warning: initialization from incompatible
    pointer type

    The newly added parameter is used to override DMA slave address from 'struct
    hpb_dmae_slave_config', so we have to add the 'slave_addr' field to 'struct
    hpb_dmae_chan', conditionally assign it in set_slave() method, and return in
    slave_addr() method.

    Signed-off-by: Sergei Shtylyov
    Tested-by: Simon Horman
    Signed-off-by: Vinod Koul

    Sergei Shtylyov
     
  • Commit c1c63a14f4f2419d093acd7164eccdff315baa86 (DMA: shdma: switch to managed
    resource allocation) got rid of shdma_free_irq() but unfortunately got merged
    later than commit c4f6c41ba790bbbfcebb4c47a709ac8ff1fe1af9 (dma: add driver for
    R-Car HPB-DMAC), so that the HPB-DMAC driver retained the calls and got broken:

    drivers/dma/sh/rcar-hpbdma.c: In function `hpb_dmae_alloc_chan_resources':
    drivers/dma/sh/rcar-hpbdma.c:435: error: implicit declaration of function
    `shdma_free_irq'

    Fix this compilation error by removing the remaining shdma_free_irq() calls.

    Reported-by: Simon Horman
    Signed-off-by: Sergei Shtylyov
    Tested-by: Simon Horman
    Signed-off-by: Vinod Koul

    Sergei Shtylyov
     
  • When doing space balance and subvolume destroy at the same time, we met
    the following oops:

    kernel BUG at fs/btrfs/relocation.c:2247!
    RIP: 0010: [] prepare_to_merge+0x154/0x1f0 [btrfs]
    Call Trace:
    [] relocate_block_group+0x466/0x4e6 [btrfs]
    [] btrfs_relocate_block_group+0x143/0x275 [btrfs]
    [] btrfs_relocate_chunk.isra.27+0x5c/0x5a2 [btrfs]
    [] ? btrfs_item_key_to_cpu+0x15/0x31 [btrfs]
    [] ? btrfs_get_token_64+0x7e/0xcd [btrfs]
    [] ? btrfs_tree_read_unlock_blocking+0xb2/0xb7 [btrfs]
    [] btrfs_balance+0x9c7/0xb6f [btrfs]
    [] btrfs_ioctl_balance+0x234/0x2ac [btrfs]
    [] btrfs_ioctl+0xd87/0x1ef9 [btrfs]
    [] ? path_openat+0x234/0x4db
    [] ? __do_page_fault+0x31d/0x391
    [] ? vma_link+0x74/0x94
    [] vfs_ioctl+0x1d/0x39
    [] do_vfs_ioctl+0x32d/0x3e2
    [] SyS_ioctl+0x57/0x83
    [] ? do_page_fault+0xe/0x10
    [] system_call_fastpath+0x16/0x1b

    It is because we returned the error number if the reference of the root was 0
    when doing space relocation. It was not right here, because though the root
    was dead(refs == 0), but the space it held still need be relocated, or we
    could not remove the block group. So in this case, we should return the root
    no matter it is dead or not.

    Signed-off-by: Miao Xie
    Signed-off-by: Josef Bacik
    Signed-off-by: Chris Mason

    Miao Xie