1. 30 Dec, 2015 3 commits
    • Filipe Manana's avatar
      Btrfs: fix race between free space endio workers and space cache writeout · 2bc0bb5f
      Filipe Manana authored
      While running a stress test I ran into the following trace/transaction
      abort:
      
      [471626.672243] ------------[ cut here ]------------
      [471626.673322] WARNING: CPU: 9 PID: 19107 at fs/btrfs/extent-tree.c:3740 btrfs_write_dirty_block_groups+0x17c/0x214 [btrfs]()
      [471626.675492] BTRFS: Transaction aborted (error -2)
      [471626.676748] Modules linked in: btrfs dm_flakey dm_mod crc32c_generic xor raid6_pq nfsd auth_rpcgss oid_registry nfs_acl nfs lockd grace fscache sunrpc loop fuse parport_pc i2c_piix
      [471626.688802] CPU: 14 PID: 19107 Comm: fsstress Tainted: G        W       4.3.0-rc5-btrfs-next-17+ #1
      [471626.690148] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.8.1-0-g4adadbd-20150316_085822-nilsson.home.kraxel.org 04/01/2014
      [471626.691901]  0000000000000000 ffff880016037cf0 ffffffff812566f4 ffff880016037d38
      [471626.695009]  ffff880016037d28 ffffffff8104d0a6 ffffffffa040c84e 00000000fffffffe
      [471626.697490]  ffff88011fe855f8 ffff88000c484cb0 ffff88000d195000 ffff880016037d90
      [471626.699201] Call Trace:
      [471626.699804]  [<ffffffff812566f4>] dump_stack+0x4e/0x79
      [471626.701049]  [<ffffffff8104d0a6>] warn_slowpath_common+0x9f/0xb8
      [471626.702542]  [<ffffffffa040c84e>] ? btrfs_write_dirty_block_groups+0x17c/0x214 [btrfs]
      [471626.704326]  [<ffffffff8104d107>] warn_slowpath_fmt+0x48/0x50
      [471626.705636]  [<ffffffffa0403717>] ? write_one_cache_group.isra.32+0x77/0x82 [btrfs]
      [471626.707048]  [<ffffffffa040c84e>] btrfs_write_dirty_block_groups+0x17c/0x214 [btrfs]
      [471626.708616]  [<ffffffffa048a50a>] commit_cowonly_roots+0x1d7/0x25a [btrfs]
      [471626.709950]  [<ffffffffa041e34a>] btrfs_commit_transaction+0x4c4/0x991 [btrfs]
      [471626.711286]  [<ffffffff81081c61>] ? signal_pending_state+0x31/0x31
      [471626.712611]  [<ffffffffa03f6df4>] btrfs_sync_fs+0x145/0x1ad [btrfs]
      [471626.715610]  [<ffffffff811962a2>] ? SyS_tee+0x226/0x226
      [471626.716718]  [<ffffffff811962c2>] sync_fs_one_sb+0x20/0x22
      [471626.717672]  [<ffffffff8116fc01>] iterate_supers+0x75/0xc2
      [471626.718800]  [<ffffffff8119669a>] sys_sync+0x52/0x80
      [471626.719990]  [<ffffffff8147cd97>] entry_SYSCALL_64_fastpath+0x12/0x6f
      [471626.721835] ---[ end trace baf57f43d76693f4 ]---
      [471626.722954] BTRFS: error (device sdc) in btrfs_write_dirty_block_groups:3740: errno=-2 No such entry
      
      This is a very rare situation and it happened due to a race between a free
      space endio worker and writing the space caches for dirty block groups at
      a transaction's commit critical section. The steps leading to this are:
      
      1) A task calls btrfs_commit_transaction() and starts the writeout of the
         space caches for all currently dirty block groups (i.e. it calls
         btrfs_start_dirty_block_groups());
      
      2) The previous step starts writeback for space caches;
      
      3) When the writeback finishes it queues jobs for free space endio work
         queue (fs_info->endio_freespace_worker) that execute
         btrfs_finish_ordered_io();
      
      4) The task committing the transaction sets the transaction's state
         to TRANS_STATE_COMMIT_DOING and shortly after calls
         btrfs_write_dirty_block_groups();
      
      5) A free space endio job joins the transaction, through
         btrfs_join_transaction_nolock(), and updates a free space inode item
         in the root tree through btrfs_update_inode_fallback();
      
      6) Updating the free space inode item resulted in COWing one or more
         nodes/leaves of the root tree, and that resulted in creating a new
         metadata block group, which gets added to the transaction's list
         of dirty block groups (this is a very rare case);
      
      7) The free space endio job has not released yet its transaction handle
         at this point, so the new metadata block group was not yet fully
         created (didn't go through btrfs_create_pending_block_groups() yet);
      
      8) The transaction commit task sees the new metadata block group in
         the transaction's list of dirty block groups and processes it.
         When it attempts to update the block group's block group item in
         the extent tree, through write_one_cache_group(), it isn't able
         to find it and aborts the transaction with error -ENOENT - this
         is because the free space endio job hasn't yet released its
         transaction handle (which calls btrfs_create_pending_block_groups())
         and therefore the block group item was not yet added to the extent
         tree.
      
      Fix this waiting for free space endio jobs if we fail to find a block
      group item in the extent tree and then retry once updating the block
      group item.
      Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
      2bc0bb5f
    • Chris Mason's avatar
      btrfs: don't run delayed references while we are creating the free space tree · 511711af
      Chris Mason authored
      This is a short term solution to make sure btrfs_run_delayed_refs()
      doesn't change the extent tree while we are scanning it to create the
      free space tree.
      
      Longer term we need to synchronize scanning the block groups one by one,
      similar to what happens during a balance.
      Signed-off-by: default avatarChris Mason <clm@fb.com>
      511711af
    • Chris Mason's avatar
      btrfs: fix compiling with CONFIG_BTRFS_DEBUG enabled. · b4570aa9
      Chris Mason authored
      Merging in the free space tree deleted a variable needed when
      CONFIG_BTRFS_DEBUG=y
      Signed-off-by: default avatarChris Mason <clm@fb.com>
      b4570aa9
  2. 23 Dec, 2015 6 commits
  3. 21 Dec, 2015 2 commits
    • Filipe Manana's avatar
      Btrfs: fix unprotected list operations at btrfs_write_dirty_block_groups · e44081ef
      Filipe Manana authored
      We call btrfs_write_dirty_block_groups() in the critical section of a
      transaction's commit, when no other tasks can join the transaction and
      add more block groups to the transaction's list of dirty block groups,
      so we not taking the dirty block groups spinlock when checking for the
      list's emptyness, grabbing its first element or deleting elements from
      it.
      
      However there's a special and rare case where we can have a concurrent
      task adding elements to this list. We trigger writeback for space
      caches before at btrfs_start_dirty_block_groups() and in past iterations
      of the loop at btrfs_write_dirty_block_groups(), this means that when
      the writeback finishes (which happens asynchronously) it creates a
      task for the endio free space work queue that executes
      btrfs_finish_ordered_io() - this function is able to join the transaction,
      through btrfs_join_transaction_nolock(), and update the free space cache's
      inode item in the root tree, which can result in COWing nodes of this tree
      and therefore allocation of a new block group can happen, which gets added
      to the transaction's list of dirty block groups while the transaction
      commit task is operating on it concurrently.
      
      So fix this by taking the dirty block groups spinlock before doing
      operations on the dirty block groups list at
      btrfs_write_dirty_block_groups().
      Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
      e44081ef
    • Linus Torvalds's avatar
      Linux 4.4-rc6 · 4ef76753
      Linus Torvalds authored
      4ef76753
  4. 20 Dec, 2015 7 commits
    • Linus Torvalds's avatar
      Merge tag 'rtc-4.4-3' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux · 9f7e4327
      Linus Torvalds authored
      Pull RTC fixes from Alexandre Belloni:
       "Late fixes for the RTC subsystem for 4.4:
      
        A fix for a nasty hardware bug in rk808 and an initialization
        reordering in da9063 to fix a possible crash"
      
      * tag 'rtc-4.4-3' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux:
        rtc: da9063: fix access ordering error during RTC interrupt at system power on
        rtc: rk808: Compensate for Rockchip calendar deviation on November 31st
      9f7e4327
    • Steve Twiss's avatar
      rtc: da9063: fix access ordering error during RTC interrupt at system power on · 77535ace
      Steve Twiss authored
      This fix alters the ordering of the IRQ and device registrations in the RTC
      driver probe function. This change will apply to the RTC driver that supports
      both DA9063 and DA9062 PMICs.
      
      A problem could occur with the existing RTC driver if:
      
      A system is started from a cold boot using the PMIC RTC IRQ to initiate a
      power on operation. For instance, if an RTC alarm is used to start a
      platform from power off.
      The existing driver IRQ is requested before the device has been properly
      registered.
      i.e.
          ret = devm_request_threaded_irq()
      comes before
          rtc->rtc_dev = devm_rtc_device_register();
      
      In this case, the interrupt can be called before the device has been
      registered and the handler can be called immediately. The IRQ handler
      da9063_alarm_event() contains the function call
      
          rtc_update_irq(rtc->rtc_dev, 1, RTC_IRQF | RTC_AF);
      
      which in turn tries to access the unavailable rtc->rtc_dev.
      
      The fix is to reorder the functions inside the RTC probe. The IRQ is
      requested after the RTC device resource has been registered so that
      get_irq_byname is the last thing to happen.
      Signed-off-by: default avatarSteve Twiss <stwiss.opensource@diasemi.com>
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@free-electrons.com>
      77535ace
    • Julius Werner's avatar
      rtc: rk808: Compensate for Rockchip calendar deviation on November 31st · f076ef44
      Julius Werner authored
      In A.D. 1582 Pope Gregory XIII found that the existing Julian calendar
      insufficiently represented reality, and changed the rules about
      calculating leap years to account for this. Similarly, in A.D. 2013
      Rockchip hardware engineers found that the new Gregorian calendar still
      contained flaws, and that the month of November should be counted up to
      31 days instead. Unfortunately it takes a long time for calendar changes
      to gain widespread adoption, and just like more than 300 years went by
      before the last Protestant nation implemented Greg's proposal, we will
      have to wait a while until all religions and operating system kernels
      acknowledge the inherent advantages of the Rockchip system. Until then
      we need to translate dates read from (and written to) Rockchip hardware
      back to the Gregorian format.
      
      This patch works by defining Jan 1st, 2016 as the arbitrary anchor date
      on which Rockchip and Gregorian calendars are in sync. From that we can
      translate arbitrary later dates back and forth by counting the number
      of November/December transitons since the anchor date to determine the
      offset between the calendars. We choose this method (rather than trying
      to regularly "correct" the date stored in hardware) since it's the only
      way to ensure perfect time-keeping even if the system may be shut down
      for an unknown number of years. The drawback is that other software
      reading the same hardware (e.g. mainboard firmware) must use the same
      translation convention (including the same anchor date) to be able to
      read and write correct timestamps from/to the RTC.
      Signed-off-by: default avatarJulius Werner <jwerner@chromium.org>
      Reviewed-by: default avatarDouglas Anderson <dianders@chromium.org>
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@free-electrons.com>
      f076ef44
    • Linus Torvalds's avatar
      Merge tag 'tty-4.4-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty · 69c37a92
      Linus Torvalds authored
      Pull tty/serial fixes from Greg KH:
       "Here are some tty/serial driver fixes for 4.4-rc6 that resolve some
        reported problems.  All of these have been in linux-next.  The details
        are in the shortlog"
      
      * tag 'tty-4.4-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty:
        tty: Fix GPF in flush_to_ldisc()
        serial: earlycon: Add missing spinlock initialization
        serial: sh-sci: Fix length of scatterlist
        n_tty: Fix poll() after buffer-limited eof push read
        serial: 8250_uniphier: fix dl_read and dl_write functions
      69c37a92
    • Linus Torvalds's avatar
      Merge tag 'usb-4.4-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb · 24b0d5e7
      Linus Torvalds authored
      Pull USB fixes from Greg KH:
       "Here are some USB and PHY fixes for 4.4-rc6.  All of them resolve some
        reported problems.  Full details in the shortlog"
      
      * tag 'usb-4.4-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb:
        USB: fix invalid memory access in hub_activate()
        USB: ipaq.c: fix a timeout loop
        phy: core: Get a refcount to phy in devm_of_phy_get_by_index()
        phy: cygnus: pcie: add missing of_node_put
        phy: miphy365x: add missing of_node_put
        phy: miphy28lp: add missing of_node_put
        phy: rockchip-usb: add missing of_node_put
        phy: berlin-sata: add missing of_node_put
        phy: mt65xx-usb3: add missing of_node_put
        phy: brcmstb-sata: add missing of_node_put
        phy: sun9i-usb: add USB dependency
      24b0d5e7
    • Linus Torvalds's avatar
      Merge tag 'md/4.4-rc5-fixes' of git://neil.brown.name/md · 3a87711e
      Linus Torvalds authored
      Pull md fixes from Neil Brown:
       "Four fixes for md:
      
         - two recently introduced regressions fixed.
         - one older bug in RAID10 - tagged for -stable since 4.2
         - one minor sysfs api improvement"
      
      * tag 'md/4.4-rc5-fixes' of git://neil.brown.name/md:
        Fix remove_and_add_spares removes drive added as spare in slot_store
        md: fix bug due to nested suspend
        MD: change journal disk role to disk 0
        md/raid10: fix data corruption and crash during resync
      3a87711e
    • Linus Torvalds's avatar
      Merge tag 'powerpc-4.4-5' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux · 35b3154e
      Linus Torvalds authored
      Pull powerpc fixes from Michael Ellerman:
       - Partial revert of "powerpc: Individual System V IPC system calls"
       - pr_warn_once on unsupported OPAL_MSG type from Stewart
       - Fix deadlock in opal-irqchip introduced by "Fix double endian
         conversion" from Alistair
      
      * tag 'powerpc-4.4-5' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux:
        powerpc/opal-irqchip: Fix deadlock introduced by "Fix double endian conversion"
        powerpc/powernv: pr_warn_once on unsupported OPAL_MSG type
        Partial revert of "powerpc: Individual System V IPC system calls"
      35b3154e
  5. 19 Dec, 2015 9 commits
    • Linus Torvalds's avatar
      Merge tag 'spi-fix-v4.4-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi · 3c73a2dd
      Linus Torvalds authored
      Pull spi fixes from Mark Brown:
       "A couple of reference counting bugs here, one in spidev and one with
        holding an extra reference in the core that we never freed if we
        removed a device, plus a driver specific fix.  Both of the refcounting
        bugs are very old but they've only been found by observation so
        hopefully their impact has been low"
      
      * tag 'spi-fix-v4.4-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi:
        spi: fix parent-device reference leak
        spi: spidev: Hold spi_lock over all defererences of spi in release()
        spi-fsl-dspi: Fix CTAR Register access
      3c73a2dd
    • Linus Torvalds's avatar
      Merge tag 'gpio-v4.4-3' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio · d525c13e
      Linus Torvalds authored
      Pull GPIO fixes from Linus Walleij:
       "Some GPIO fixes for the v4.4 series.  Most prominent: I revert the
        error propagation from the .get() function until we can fix up all the
        drivers properly for v4.5.
      
         - Revert the error number propagation from the .get() vtable entry
           temporarily, until we make the proper fixes to all drivers.
         - Fix the clamping behaviour in the generic GPIO driver.
         - Driver fix for the ath79 driver"
      
      * tag 'gpio-v4.4-3' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio:
        gpio: revert get() to non-errorprogating behaviour
        gpio: generic: clamp values from bgpio_get_set()
        gpio: ath79: Fix the logic to clear offset bit of AR71XX_GPIO_REG_OE register
      d525c13e
    • Linus Torvalds's avatar
      Merge tag 'pinctrl-v4.4-3' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl · 38beb96e
      Linus Torvalds authored
      Pull pin control fixes from Linus Walleij:
       - Driver fixes for Freescale i.MX7D, Intel, Broadcom 2835
       - One MAINTAINERS entry
      
      * tag 'pinctrl-v4.4-3' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl:
        MAINTAINERS: pinctrl: Add maintainers for pinctrl-single
        pinctrl: bcm2835: Fix initial value for direction_output
        pinctrl: intel: fix offset calculation issue of register PAD_OWN
        pinctrl: intel: fix bug of register offset calculation
        pinctrl: freescale: add ZERO_OFFSET_VALID flag for vf610 pinctrl
      38beb96e
    • Linus Torvalds's avatar
      Merge branch 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux · d7d3d841
      Linus Torvalds authored
      Pull i2c fixes from Wolfram Sang:
       "A set of 'usual' driver bugfixes for the I2C subsystem"
      
      * 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
        i2c: rcar: disable runtime PM correctly in slave mode
        i2c: designware: Keep pm_runtime_enable/_disable calls in sync
        i2c: designware: fix IO timeout issue for AMD controller
        i2c: imx: init bus recovery info before adding i2c adapter
        i2c: do not use 0x in front of %pa
        i2c: davinci: Increase module clock frequency
        i2c: mv64xxx: The n clockdiv factor is 0 based on sunxi SoCs
        i2c: rk3x: populate correct variable for sda_falling_time
      d7d3d841
    • Linus Torvalds's avatar
      Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input · 632f8577
      Linus Torvalds authored
      Pull input fixes from Dmitry Torokhov:
       "Just a few assorted driver fixes"
      
      * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input:
        Input: elants_i2c - fix wake-on-touch
        Input: elan_i2c - set input device's vendor and product IDs
        Input: sun4i-lradc-keys - fix typo in binding documentation
        Input: atmel_mxt_ts - add maxtouch to I2C table for module autoload
        Input: arizona-haptic - fix disabling of haptics device
        Input: aiptek - fix crash on detecting device without endpoints
        Input: atmel_mxt_ts - add generic platform data for Chromebooks
        Input: parkbd - clear unused function pointers
        Input: walkera0701 - clear unused function pointers
        Input: turbografx - clear unused function pointers
        Input: gamecon - clear unused function pointers
        Input: db9 - clear unused function pointers
      632f8577
    • Wolfram Sang's avatar
      i2c: rcar: disable runtime PM correctly in slave mode · b4cd08aa
      Wolfram Sang authored
      When we also are I2C slave, we need to disable runtime PM because the
      address detection mechanism needs to be active all the time. However, we
      can reenable runtime PM once the slave instance was unregistered. So,
      use pm_runtime_get_sync/put to achieve this, since it has proper
      refcounting. pm_runtime_allow/forbid is like a global knob controllable
      from userspace which is unsuitable here.
      Signed-off-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
      Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
      Cc: stable@kernel.org
      b4cd08aa
    • Linus Torvalds's avatar
      Merge tag 'pm+acpi-4.4-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm · 1eab0e42
      Linus Torvalds authored
      Pull power management fixes from Rafael Wysocki:
       "These fix a potential regression introduced during the 4.3 cycle
        (generic power domains framework), a nasty bug that has been present
        forever (power capping RAPL driver), a build issue (Tegra cpufreq
        driver) and a minor ugliness introduced recently (intel_pstate).
      
        Specifics:
      
         - Fix a potential regression in the generic power domains framework
           introduced during the 4.3 development cycle that may lead to
           spurious failures of system suspend in certain situations (Ulf
           Hansson).
      
         - Fix a problem in the power capping RAPL (Running Average Power
           Limits) driver that causes it to initialize successfully on some
           systems where it is not supposed to do that which is due to an
           incorrect check in an initialization routine (Prarit Bhargava).
      
         - Fix a build problem in the cpufreq Tegra driver that depends on the
           regulator framework, but that dependency is not reflected in
           Kconfig (Arnd Bergmann).
      
         - Fix a recent mistake in the intel_pstate driver where a numeric
           constant is used directly instead of a symbol defined specifically
           for the case in question (Prarit Bhargava)"
      
      * tag 'pm+acpi-4.4-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
        powercap / RAPL: fix BIOS lock check
        cpufreq: intel_pstate: Minor cleanup for FRAC_BITS
        cpufreq: tegra: add regulator dependency for T124
        PM / Domains: Allow runtime PM callbacks to be re-used during system PM
      1eab0e42
    • Linus Torvalds's avatar
      Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi · 4fee35a3
      Linus Torvalds authored
      Pull SCSI fixes from James Bottomley:
       "Three fixes this time, two in SES picked up by KASAN for various types
        of buffer overrun.  The first is a USB array which returns page 8
        whatever is asked for and causes us to overrun with incorrect data
        format assumptions and the second is an invalid iteration of page 10
        (the additional information page).
      
        The final fix is a reversion of a NULL deref fix which caused
        suspend/resume not to be called in pairs leading to incorrect device
        operation (Jens has queued a more proper fix for the problem in
        block)"
      
      * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
        ses: fix additional element traversal bug
        Revert "SCSI: Fix NULL pointer dereference in runtime PM"
        ses: Fix problems with simple enclosures
      4fee35a3
    • James Chen's avatar
      Input: elants_i2c - fix wake-on-touch · 478e5ed1
      James Chen authored
      When sending "SLEEP" command to the controller it ceases scanning
      completely and is unable to wake the system up from sleep, so if it is
      configured as a wakeup source we should simply configure interrupt for
      wakeup and rely on idle logic within the controller to reduce power
      consumption while it is not used.
      Signed-off-by: default avatarJames Chen <james.chen@emc.com.tw>
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      478e5ed1
  6. 18 Dec, 2015 13 commits