Skip to content
  1. Jul 31, 2021
    • Linus Torvalds's avatar
      Merge tag 'block-5.14-2021-07-30' of git://git.kernel.dk/linux-block · 4669e13c
      Linus Torvalds authored
      Pull block fixes from Jens Axboe:
      
       - gendisk freeing fix (Christoph)
      
       - blk-iocost wake ordering fix (Tejun)
      
       - tag allocation error handling fix (John)
      
       - loop locking fix. While this isn't the prettiest fix in the world,
         nobody has any good alternatives for 5.14. Something to likely
         revisit for 5.15. (Tetsuo)
      
      * tag 'block-5.14-2021-07-30' of git://git.kernel.dk/linux-block:
        block: delay freeing the gendisk
        blk-iocost: fix operation ordering in iocg_wake_fn()
        blk-mq-sched: Fix blk_mq_sched_alloc_tags() error handling
        loop: reintroduce global lock for safe loop_validate_file() traversal
      4669e13c
    • Linus Torvalds's avatar
      Merge tag 'io_uring-5.14-2021-07-30' of git://git.kernel.dk/linux-block · 27eb687b
      Linus Torvalds authored
      Pull io_uring fixes from Jens Axboe:
      
       - A fix for block backed reissue (me)
      
       - Reissue context hardening (me)
      
       - Async link locking fix (Pavel)
      
      * tag 'io_uring-5.14-2021-07-30' of git://git.kernel.dk/linux-block:
        io_uring: fix poll requests leaking second poll entries
        io_uring: don't block level reissue off completion path
        io_uring: always reissue from task_work context
        io_uring: fix race in unified task_work running
        io_uring: fix io_prep_async_link locking
      27eb687b
    • Linus Torvalds's avatar
      Merge tag 'libata-5.14-2021-07-30' of git://git.kernel.dk/linux-block · f6c5971b
      Linus Torvalds authored
      Pull libata fixlets from Jens Axboe:
      
       - A fix for PIO highmem (Christoph)
      
       - Kill HAVE_IDE as it's now unused (Lukas)
      
      * tag 'libata-5.14-2021-07-30' of git://git.kernel.dk/linux-block:
        arch: Kconfig: clean up obsolete use of HAVE_IDE
        libata: fix ata_pio_sector for CONFIG_HIGHMEM
      f6c5971b
    • Linus Torvalds's avatar
      Merge tag 'for-5.14-rc3-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux · 051df241
      Linus Torvalds authored
      Pull btrfs fixes from David Sterba:
      
       - fix -Warray-bounds warning, to help external patchset to make it
         default treewide
      
       - fix writeable device accounting (syzbot report)
      
       - fix fsync and log replay after a rename and inode eviction
      
       - fix potentially lost error code when submitting multiple bios for
         compressed range
      
      * tag 'for-5.14-rc3-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
        btrfs: calculate number of eb pages properly in csum_tree_block
        btrfs: fix rw device counting in __btrfs_free_extra_devids
        btrfs: fix lost inode on log replay after mix of fsync, rename and inode eviction
        btrfs: mark compressed range uptodate only if all bio succeed
      051df241
    • Linus Torvalds's avatar
      Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid · 8723bc8f
      Linus Torvalds authored
      Pull HID fixes from Jiri Kosina:
      
       - resume timing fix for intel-ish driver (Ye Xiang)
      
       - fix for using incorrect MMIO register in amd_sfh driver (Dylan
         MacKenzie)
      
       - Cintiq 24HDT / 27QHDT regression fix and touch processing fix for
         Wacom driver (Jason Gerecke)
      
       - device removal bugfix for ft260 driver (Michael Zaidman)
      
       - other small assorted fixes
      
      * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid:
        HID: ft260: fix device removal due to USB disconnect
        HID: wacom: Skip processing of touches with negative slot values
        HID: wacom: Re-enable touch by default for Cintiq 24HDT / 27QHDT
        HID: Kconfig: Fix spelling mistake "Uninterruptable" -> "Uninterruptible"
        HID: apple: Add support for Keychron K1 wireless keyboard
        HID: fix typo in Kconfig
        HID: ft260: fix format type warning in ft260_word_show()
        HID: amd_sfh: Use correct MMIO register for DMA address
        HID: asus: Remove check for same LED brightness on set
        HID: intel-ish-hid: use async resume function
      8723bc8f
    • Linus Torvalds's avatar
      Merge branch 'akpm' (patches from Andrew) · ad6ec09d
      Linus Torvalds authored
      Merge misc fixes from Andrew Morton:
       "7 patches.
      
        Subsystems affected by this patch series: lib, ocfs2, and mm (slub,
        migration, and memcg)"
      
      * emailed patches from Andrew Morton <akpm@linux-foundation.org>:
        mm/memcg: fix NULL pointer dereference in memcg_slab_free_hook()
        slub: fix unreclaimable slab stat for bulk free
        mm/migrate: fix NR_ISOLATED corruption on 64-bit
        mm: memcontrol: fix blocking rstat function called from atomic cgroup1 thresholding code
        ocfs2: issue zeroout to EOF blocks
        ocfs2: fix zero out valid data
        lib/test_string.c: move string selftest in the Runtime Testing menu
      ad6ec09d
    • Wang Hai's avatar
      mm/memcg: fix NULL pointer dereference in memcg_slab_free_hook() · 121dffe2
      Wang Hai authored
      When I use kfree_rcu() to free a large memory allocated by kmalloc_node(),
      the following dump occurs.
      
        BUG: kernel NULL pointer dereference, address: 0000000000000020
        [...]
        Oops: 0000 [#1] SMP
        [...]
        Workqueue: events kfree_rcu_work
        RIP: 0010:__obj_to_index include/linux/slub_def.h:182 [inline]
        RIP: 0010:obj_to_index include/linux/slub_def.h:191 [inline]
        RIP: 0010:memcg_slab_free_hook+0x120/0x260 mm/slab.h:363
        [...]
        Call Trace:
          kmem_cache_free_bulk+0x58/0x630 mm/slub.c:3293
          kfree_bulk include/linux/slab.h:413 [inline]
          kfree_rcu_work+0x1ab/0x200 kernel/rcu/tree.c:3300
          process_one_work+0x207/0x530 kernel/workqueue.c:2276
          worker_thread+0x320/0x610 kernel/workqueue.c:2422
          kthread+0x13d/0x160 kernel/kthread.c:313
          ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294
      
      When kmalloc_node() a large memory, page is allocated, not slab, so when
      freeing memory via kfree_rcu(), this large memory should not be used by
      memcg_slab_free_hook(), because memcg_slab_free_hook() is is used for
      slab.
      
      Using page_objcgs_check() instead of page_objcgs() in
      memcg_slab_free_hook() to fix this bug.
      
      Link: https://lkml.kernel.org/r/20210728145655.274476-1-wanghai38@huawei.com
      Fixes: 270c6a71
      
       ("mm: memcontrol/slab: Use helpers to access slab page's memcg_data")
      Signed-off-by: default avatarWang Hai <wanghai38@huawei.com>
      Reviewed-by: default avatarShakeel Butt <shakeelb@google.com>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Acked-by: default avatarRoman Gushchin <guro@fb.com>
      Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
      Reviewed-by: default avatarMuchun Song <songmuchun@bytedance.com>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      121dffe2
    • Shakeel Butt's avatar
      slub: fix unreclaimable slab stat for bulk free · f227f0fa
      Shakeel Butt authored
      SLUB uses page allocator for higher order allocations and update
      unreclaimable slab stat for such allocations.  At the moment, the bulk
      free for SLUB does not share code with normal free code path for these
      type of allocations and have missed the stat update.  So, fix the stat
      update by common code.  The user visible impact of the bug is the
      potential of inconsistent unreclaimable slab stat visible through
      meminfo and vmstat.
      
      Link: https://lkml.kernel.org/r/20210728155354.3440560-1-shakeelb@google.com
      Fixes: 6a486c0a
      
       ("mm, sl[ou]b: improve memory accounting")
      Signed-off-by: default avatarShakeel Butt <shakeelb@google.com>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Acked-by: default avatarRoman Gushchin <guro@fb.com>
      Reviewed-by: default avatarMuchun Song <songmuchun@bytedance.com>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      f227f0fa
    • Aneesh Kumar K.V's avatar
      mm/migrate: fix NR_ISOLATED corruption on 64-bit · b5916c02
      Aneesh Kumar K.V authored
      Similar to commit 2da9f630 ("mm/vmscan: fix NR_ISOLATED_FILE
      corruption on 64-bit") avoid using unsigned int for nr_pages.  With
      unsigned int type the large unsigned int converts to a large positive
      signed long.
      
      Symptoms include CMA allocations hanging forever due to
      alloc_contig_range->...->isolate_migratepages_block waiting forever in
      "while (unlikely(too_many_isolated(pgdat)))".
      
      Link: https://lkml.kernel.org/r/20210728042531.359409-1-aneesh.kumar@linux.ibm.com
      Fixes: c5fc5c3a
      
       ("mm: migrate: account THP NUMA migration counters correctly")
      Signed-off-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
      Reported-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Reported-by: default avatarAlexey Kardashevskiy <aik@ozlabs.ru>
      Reviewed-by: default avatarYang Shi <shy828301@gmail.com>
      Cc: Mel Gorman <mgorman@suse.de>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: David Hildenbrand <david@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      b5916c02
    • Johannes Weiner's avatar
      mm: memcontrol: fix blocking rstat function called from atomic cgroup1 thresholding code · 30def935
      Johannes Weiner authored
      Dan Carpenter reports:
      
          The patch 2d146aa3: "mm: memcontrol: switch to rstat" from Apr
          29, 2021, leads to the following static checker warning:
      
      	    kernel/cgroup/rstat.c:200 cgroup_rstat_flush()
      	    warn: sleeping in atomic context
      
          mm/memcontrol.c
            3572  static unsigned long mem_cgroup_usage(struct mem_cgroup *memcg, bool swap)
            3573  {
            3574          unsigned long val;
            3575
            3576          if (mem_cgroup_is_root(memcg)) {
            3577                  cgroup_rstat_flush(memcg->css.cgroup);
      			    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      
          This is from static analysis and potentially a false positive.  The
          problem is that mem_cgroup_usage() is called from __mem_cgroup_threshold()
          which holds an rcu_read_lock().  And the cgroup_rstat_flush() function
          can sleep.
      
            3578                  val = memcg_page_state(memcg, NR_FILE_PAGES) +
            3579                          memcg_page_state(memcg, NR_ANON_MAPPED);
            3580                  if (swap)
            3581                          val += memcg_page_state(memcg, MEMCG_SWAP);
            3582          } else {
            3583                  if (!swap)
            3584                          val = page_counter_read(&memcg->memory);
            3585                  else
            3586                          val = page_counter_read(&memcg->memsw);
            3587          }
            3588          return val;
            3589  }
      
      __mem_cgroup_threshold() indeed holds the rcu lock.  In addition, the
      thresholding code is invoked during stat changes, and those contexts
      have irqs disabled as well.  If the lock breaking occurs inside the
      flush function, it will result in a sleep from an atomic context.
      
      Use the irqsafe flushing variant in mem_cgroup_usage() to fix this.
      
      Link: https://lkml.kernel.org/r/20210726150019.251820-1-hannes@cmpxchg.org
      Fixes: 2d146aa3
      
       ("mm: memcontrol: switch to rstat")
      Signed-off-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
      Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Acked-by: default avatarChris Down <chris@chrisdown.name>
      Reviewed-by: default avatarRik van Riel <riel@surriel.com>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Reviewed-by: default avatarShakeel Butt <shakeelb@google.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      30def935
    • Junxiao Bi's avatar
      ocfs2: issue zeroout to EOF blocks · 9449ad33
      Junxiao Bi authored
      For punch holes in EOF blocks, fallocate used buffer write to zero the
      EOF blocks in last cluster.  But since ->writepage will ignore EOF
      pages, those zeros will not be flushed.
      
      This "looks" ok as commit 6bba4471
      
       ("ocfs2: fix data corruption by
      fallocate") will zero the EOF blocks when extend the file size, but it
      isn't.  The problem happened on those EOF pages, before writeback, those
      pages had DIRTY flag set and all buffer_head in them also had DIRTY flag
      set, when writeback run by write_cache_pages(), DIRTY flag on the page
      was cleared, but DIRTY flag on the buffer_head not.
      
      When next write happened to those EOF pages, since buffer_head already
      had DIRTY flag set, it would not mark page DIRTY again.  That made
      writeback ignore them forever.  That will cause data corruption.  Even
      directio write can't work because it will fail when trying to drop pages
      caches before direct io, as it found the buffer_head for those pages
      still had DIRTY flag set, then it will fall back to buffer io mode.
      
      To make a summary of the issue, as writeback ingores EOF pages, once any
      EOF page is generated, any write to it will only go to the page cache,
      it will never be flushed to disk even file size extends and that page is
      not EOF page any more.  The fix is to avoid zero EOF blocks with buffer
      write.
      
      The following code snippet from qemu-img could trigger the corruption.
      
        656   open("6b3711ae-3306-4bdd-823c-cf1c0060a095.conv.2", O_RDWR|O_DIRECT|O_CLOEXEC) = 11
        ...
        660   fallocate(11, FALLOC_FL_KEEP_SIZE|FALLOC_FL_PUNCH_HOLE, 2275868672, 327680 <unfinished ...>
        660   fallocate(11, 0, 2275868672, 327680) = 0
        658   pwrite64(11, "
      
      Link: https://lkml.kernel.org/r/20210722054923.24389-2-junxiao.bi@oracle.com
      Signed-off-by: default avatarJunxiao Bi <junxiao.bi@oracle.com>
      Reviewed-by: default avatarJoseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Changwei Ge <gechangwei@live.cn>
      Cc: Gang He <ghe@suse.com>
      Cc: Jun Piao <piaojun@huawei.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      9449ad33
    • Junxiao Bi's avatar
      ocfs2: fix zero out valid data · f267aeb6
      Junxiao Bi authored
      If append-dio feature is enabled, direct-io write and fallocate could
      run in parallel to extend file size, fallocate used "orig_isize" to
      record i_size before taking "ip_alloc_sem", when
      ocfs2_zeroout_partial_cluster() zeroout EOF blocks, i_size maybe already
      extended by ocfs2_dio_end_io_write(), that will cause valid data zeroed
      out.
      
      Link: https://lkml.kernel.org/r/20210722054923.24389-1-junxiao.bi@oracle.com
      Fixes: 6bba4471
      
       ("ocfs2: fix data corruption by fallocate")
      Signed-off-by: default avatarJunxiao Bi <junxiao.bi@oracle.com>
      Reviewed-by: default avatarJoseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Changwei Ge <gechangwei@live.cn>
      Cc: Gang He <ghe@suse.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Jun Piao <piaojun@huawei.com>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      f267aeb6
    • Matteo Croce's avatar
      lib/test_string.c: move string selftest in the Runtime Testing menu · b2ff70a0
      Matteo Croce authored
      
      
      STRING_SELFTEST is presented in the "Library routines" menu.  Move it in
      Kernel hacking > Kernel Testing and Coverage > Runtime Testing together
      with other similar tests found in lib/
      
      	--- Runtime Testing
      	<*>   Test functions located in the hexdump module at runtime
      	<*>   Test string functions (NEW)
      	<*>   Test functions located in the string_helpers module at runtime
      	<*>   Test strscpy*() family of functions at runtime
      	<*>   Test kstrto*() family of functions at runtime
      	<*>   Test printf() family of functions at runtime
      	<*>   Test scanf() family of functions at runtime
      
      Link: https://lkml.kernel.org/r/20210719185158.190371-1-mcroce@linux.microsoft.com
      Signed-off-by: default avatarMatteo Croce <mcroce@microsoft.com>
      Cc: Peter Rosin <peda@axentia.se>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      b2ff70a0
  2. Jul 30, 2021
    • Lukas Bulwahn's avatar
      arch: Kconfig: clean up obsolete use of HAVE_IDE · 094121ef
      Lukas Bulwahn authored
      The arch-specific Kconfig files use HAVE_IDE to indicate if IDE is
      supported.
      
      As IDE support and the HAVE_IDE config vanishes with commit b7fb14d3
      ("ide: remove the legacy ide driver"), there is no need to mention
      HAVE_IDE in all those arch-specific Kconfig files.
      
      The issue was identified with ./scripts/checkkconfigsymbols.py.
      
      Fixes: b7fb14d3
      
       ("ide: remove the legacy ide driver")
      Suggested-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Signed-off-by: default avatarLukas Bulwahn <lukas.bulwahn@gmail.com>
      Acked-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Link: https://lore.kernel.org/r/20210728182115.4401-1-lukas.bulwahn@gmail.com
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Acked-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      094121ef
    • Linus Torvalds's avatar
      Merge tag 'drm-fixes-2021-07-30' of git://anongit.freedesktop.org/drm/drm · 764a5bc8
      Linus Torvalds authored
      Pull drm fixes from Dave Airlie:
       "Regular drm fixes pull, seems about the right size, lots of small
        fixes across the board, mostly amdgpu, but msm and i915 are in there
        along with panel and ttm.
      
        amdgpu:
         - Fix resource leak in an error path
         - Avoid stack contents exposure in error path
         - pmops check fix for S0ix vs S3
         - DCN 2.1 display fixes
         - DCN 2.0 display fix
         - Backlight control fix for laptops with HDR panels
         - Maintainers updates
      
        i915:
         - Fix vbt port mask
         - Fix around reading the right DSC disable fuse in display_ver 10
         - Split display version 9 and 10 in intel_setup_outputs
      
        msm:
         - iommu fault display fix
         - misc dp compliance fixes
         - dpu reg sizing fix
      
        panel:
         - Fix bpc for ytc700tlag_05_201c
      
        ttm:
         - debugfs init fixes"
      
      * tag 'drm-fixes-2021-07-30' of git://anongit.freedesktop.org/drm/drm:
        maintainers: add bugs and chat URLs for amdgpu
        drm/amdgpu/display: only enable aux backlight control for OLED panels
        drm/amd/display: ensure dentist display clock update finished in DCN20
        drm/amd/display: Add missing DCN21 IP parameter
        drm/amd/display: Guard DST_Y_PREFETCH register overflow in DCN21
        drm/amdgpu: Check pmops for desired suspend state
        drm/msm/dp: Initialize dp->aux->drm_dev before registration
        drm/msm/dp: signal audio plugged change at dp_pm_resume
        drm/msm/dp: Initialize the INTF_CONFIG register
        drm/msm/dp: use dp_ctrl_off_link_stream during PHY compliance test run
        drm/msm: Fix display fault handling
        drm/msm/dpu: Fix sm8250_mdp register length
        drm/amdgpu: Avoid printing of stack contents on firmware load error
        drm/amdgpu: Fix resource leak on probe error path
        drm/i915/display: split DISPLAY_VER 9 and 10 in intel_setup_outputs()
        drm/i915: fix not reading DSC disable fuse in GLK
        drm/i915/bios: Fix ports mask
        drm/panel: panel-simple: Fix proper bpc for ytc700tlag_05_201c
        drm/ttm: Initialize debugfs from ttm_global_init()
      764a5bc8
    • Linus Torvalds's avatar
      Merge tag 'fallthrough-fixes-clang-5.14-rc4' of... · c71a2f65
      Linus Torvalds authored
      Merge tag 'fallthrough-fixes-clang-5.14-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux
      
      Pull fallthrough fixes from Gustavo Silva:
       "Fix some fall-through warnings when building with Clang and
        '-Wimplicit-fallthrough' on ARM"
      
      * tag 'fallthrough-fixes-clang-5.14-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux:
        scsi: fas216: Fix fall-through warning for Clang
        scsi: acornscsi: Fix fall-through warning for clang
        ARM: riscpc: Fix fall-through warning for Clang
      c71a2f65
    • Linus Torvalds's avatar
      Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mattst88/alpha · cade08a5
      Linus Torvalds authored
      Pull alpha updates from Matt Turner:
       "They're mostly small janitorial fixes but there's also more important
        ones:
      
         - drop the alpha-specific x86 binary loader (David Hildenbrand)
      
         - regression fix for at least Marvel platforms (Mike Rapoport)
      
         - fix for a scary-looking typo (Zheng Yongjun)"
      
      * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mattst88/alpha:
        alpha: register early reserved memory in memblock
        alpha: fix spelling mistakes
        alpha: Remove space between * and parameter name
        alpha: fp_emul: avoid init/cleanup_module names
        alpha: Add syscall_get_return_value()
        binfmt: remove support for em86 (alpha only)
        alpha: fix typos in a comment
        alpha: defconfig: add necessary configs for boot testing
        alpha: Send stop IPI to send to online CPUs
        alpha: convert comma to semicolon
        alpha: remove undef inline in compiler.h
        alpha: Kconfig: Replace HTTP links with HTTPS ones
        alpha: __udiv_qrnnd should be exported
      cade08a5
    • Gustavo A. R. Silva's avatar
      scsi: fas216: Fix fall-through warning for Clang · cb163627
      Gustavo A. R. Silva authored
      
      
      Fix the following fallthrough warning (on ARM):
      
      drivers/scsi/arm/fas216.c:1379:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
                 default:
                 ^
         drivers/scsi/arm/fas216.c:1379:2: note: insert 'break;' to avoid fall-through
                 default:
                 ^
                 break;
      
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Link: https://lore.kernel.org/lkml/202107260355.bF00i5bi-lkp@intel.com/
      Signed-off-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
      cb163627
    • Gustavo A. R. Silva's avatar
      scsi: acornscsi: Fix fall-through warning for clang · eb4f520c
      Gustavo A. R. Silva authored
      
      
      Fix the following fallthrough warning (on ARM):
      
      drivers/scsi/arm/acornscsi.c:2651:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
                 case res_success:
                 ^
         drivers/scsi/arm/acornscsi.c:2651:2: note: insert '__attribute__((fallthrough));' to silence this warning
                 case res_success:
                 ^
                 __attribute__((fallthrough));
         drivers/scsi/arm/acornscsi.c:2651:2: note: insert 'break;' to avoid fall-through
                 case res_success:
                 ^
                 break;
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Link: https://lore.kernel.org/lkml/202107260355.bF00i5bi-lkp@intel.com/
      Signed-off-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
      eb4f520c
    • Gustavo A. R. Silva's avatar
      ARM: riscpc: Fix fall-through warning for Clang · 696e572d
      Gustavo A. R. Silva authored
      
      
      Fix the following fallthrough warning:
      
      arch/arm/mach-rpc/riscpc.c:52:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
                 default:
                 ^
      arch/arm/mach-rpc/riscpc.c:52:2: note: insert 'break;' to avoid fall-through
                 default:
                 ^
                 break;
      
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Link: https://lore.kernel.org/lkml/202107260355.bF00i5bi-lkp@intel.com/
      Signed-off-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
      696e572d
    • Linus Torvalds's avatar
      Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm · 7e96bf47
      Linus Torvalds authored
      Pull kvm fixes from Paolo Bonzini:
       "ARM:
      
         - Fix MTE shared page detection
      
         - Enable selftest's use of PMU registers when asked to
      
        s390:
      
         - restore 5.13 debugfs names
      
        x86:
      
         - fix sizes for vcpu-id indexed arrays
      
         - fixes for AMD virtualized LAPIC (AVIC)
      
         - other small bugfixes
      
        Generic:
      
         - access tracking performance test
      
         - dirty_log_perf_test command line parsing fix
      
         - Fix selftest use of obsolete pthread_yield() in favour of
           sched_yield()
      
         - use cpu_relax when halt polling
      
         - fixed missing KVM_CLEAR_DIRTY_LOG compat ioctl"
      
      * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
        KVM: add missing compat KVM_CLEAR_DIRTY_LOG
        KVM: use cpu_relax when halt polling
        KVM: SVM: use vmcb01 in svm_refresh_apicv_exec_ctrl
        KVM: SVM: tweak warning about enabled AVIC on nested entry
        KVM: SVM: svm_set_vintr don't warn if AVIC is active but is about to be deactivated
        KVM: s390: restore old debugfs names
        KVM: SVM: delay svm_vcpu_init_msrpm after svm->vmcb is initialized
        KVM: selftests: Introduce access_tracking_perf_test
        KVM: selftests: Fix missing break in dirty_log_perf_test arg parsing
        x86/kvm: fix vcpu-id indexed array sizes
        KVM: x86: Check the right feature bit for MSR_KVM_ASYNC_PF_ACK access
        docs: virt: kvm: api.rst: replace some characters
        KVM: Documentation: Fix KVM_CAP_ENFORCE_PV_FEATURE_CPUID name
        KVM: nSVM: Swap the parameter order for svm_copy_vmrun_state()/svm_copy_vmloadsave_state()
        KVM: nSVM: Rename nested_svm_vmloadsave() to svm_copy_vmloadsave_state()
        KVM: arm64: selftests: get-reg-list: actually enable pmu regs in pmu sublist
        KVM: selftests: change pthread_yield to sched_yield
        KVM: arm64: Fix detection of shared VMAs on guest fault
      7e96bf47
    • Linus Torvalds's avatar
      Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/gerg/m68knommu · 2b99c470
      Linus Torvalds authored
      Pull m68knommu fix from Greg Ungerer:
       "A single compile time fix"
      
      * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/gerg/m68knommu:
        m68k/coldfire: change pll var. to clk_pll
      2b99c470
  3. Jul 29, 2021
    • David Sterba's avatar
      btrfs: calculate number of eb pages properly in csum_tree_block · 7280305e
      David Sterba authored
      
      
      Building with -Warray-bounds on systems with 64K pages there's a
      warning:
      
        fs/btrfs/disk-io.c: In function ‘csum_tree_block’:
        fs/btrfs/disk-io.c:226:34: warning: array subscript 1 is above array bounds of ‘struct page *[1]’ [-Warray-bounds]
          226 |   kaddr = page_address(buf->pages[i]);
              |                        ~~~~~~~~~~^~~
        ./include/linux/mm.h:1630:48: note: in definition of macro ‘page_address’
         1630 | #define page_address(page) lowmem_page_address(page)
              |                                                ^~~~
        In file included from fs/btrfs/ctree.h:32,
                         from fs/btrfs/disk-io.c:23:
        fs/btrfs/extent_io.h:98:15: note: while referencing ‘pages’
           98 |  struct page *pages[1];
              |               ^~~~~
      
      The compiler has no way to know that in that case the nodesize is exactly
      PAGE_SIZE, so the resulting number of pages will be correct (1).
      
      Let's use num_extent_pages that makes the case nodesize == PAGE_SIZE
      explicitly 1.
      
      Reported-by: default avatarGustavo A. R. Silva <gustavo@embeddedor.com>
      Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      7280305e
    • Michael Zaidman's avatar
      HID: ft260: fix device removal due to USB disconnect · db8d3a21
      Michael Zaidman authored
      This commit fixes a functional regression introduced by the commit 82f09a63
      ("HID: ft260: improve error handling of ft260_hid_feature_report_get()")
      when upon USB disconnect, the FTDI FT260 i2c device is still available within
      the /dev folder.
      
      In my company's product, where the host USB to FT260 USB connection is
      hard-wired in the PCB, the issue is not reproducible. To reproduce it, I used
      the VirtualBox Ubuntu 20.04 VM and the UMFT260EV1A development module for the
      FTDI FT260 chip:
      
      Plug the UMFT260EV1A module into a USB port and attach it to VM.
      
      The VM shows 2 i2c devices under the /dev:
          michael@michael-VirtualBox:~$ ls /dev/i2c-*
          /dev/i2c-0  /dev/i2c-1
      
      The i2c-0 is not related to the FTDI FT260:
          michael@michael-VirtualBox:~$ cat /sys/bus/i2c/devices/i2c-0/name
          SMBus PIIX4 adapter at 4100
      
      The i2c-1 is created by hid-ft260.ko:
          michael@michael-VirtualBox:~$ cat /sys/bus/i2c/devices/i2c-1/name
          FT260 usb-i2c bridge on hidraw1
      
      Now, detach the FTDI FT260 USB device from VM. We expect the /dev/i2c-1
      to disappear, but it's still here:
          michael@michael-VirtualBox:~$ ls /dev/i2c-*
          /dev/i2c-0  /dev/i2c-1
      
      And the kernel log shows:
          [  +0.001202] usb 2-2: USB disconnect, device number 3
          [  +0.000109] ft260 0003:0403:6030.0002: failed to retrieve system status
          [  +0.000316] ft260 0003:0403:6030.0003: failed to retrieve system status
      
      It happens because the commit 82f09a63
      
       changed the ft260_get_system_config()
      return logic. This caused the ft260_is_interface_enabled() to exit with error
      upon the FT260 device USB disconnect, which in turn, aborted the ft260_remove()
      before deleting the FT260 i2c device and cleaning its sysfs stuff.
      
      This commit restores the FT260 USB removal functionality and improves the
      ft260_is_interface_enabled() code to handle correctly all chip modes defined
      by the device interface configuration pins DCNF0 and DCNF1.
      
      Signed-off-by: default avatarMichael Zaidman <michael.zaidman@gmail.com>
      Acked-by: default avatarAaron Jones (FTDI-UK) <aaron.jones@ftdichip.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      db8d3a21
    • Dave Airlie's avatar
      Merge tag 'amd-drm-fixes-5.14-2021-07-28' of... · d28e2568
      Dave Airlie authored
      
      Merge tag 'amd-drm-fixes-5.14-2021-07-28' of https://gitlab.freedesktop.org/agd5f/linux into drm-fixes
      
      amd-drm-fixes-5.14-2021-07-28:
      
      amdgpu:
      - Fix resource leak in an error path
      - Avoid stack contents exposure in error path
      - pmops check fix for S0ix vs S3
      - DCN 2.1 display fixes
      - DCN 2.0 display fix
      - Backlight control fix for laptops with HDR panels
      - Maintainers updates
      
      Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
      From: Alex Deucher <alexander.deucher@amd.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20210729025817.4145-1-alexander.deucher@amd.com
      d28e2568
    • Mike Rapoport's avatar
      alpha: register early reserved memory in memblock · 640b7ea5
      Mike Rapoport authored
      The memory reserved by console/PALcode or non-volatile memory is not added
      to memblock.memory.
      
      Since commit fa3354e4 (mm: free_area_init: use maximal zone PFNs rather
      than zone sizes) the initialization of the memory map relies on the
      accuracy of memblock.memory to properly calculate zone sizes. The holes in
      memblock.memory caused by absent regions reserved by the firmware cause
      incorrect initialization of struct pages which leads to BUG() during the
      initial page freeing:
      
      BUG: Bad page state in process swapper  pfn:2ffc53
      page:fffffc000ecf14c0 refcount:0 mapcount:1 mapping:0000000000000000 index:0x0
      flags: 0x0()
      raw: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
      raw: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
      page dumped because: nonzero mapcount
      Modules linked in:
      CPU: 0 PID: 0 Comm: swapper Not tainted 5.7.0-03841-gfa3354e4ea39-dirty #26
             fffffc0001b5bd68 fffffc0001b5be80 fffffc00011cd148 fffffc000ecf14c0
             fffffc00019803df fffffc0001b5be80 fffffc00011ce340 fffffc000ecf14c0
             0000000000000000 fffffc0001b5be80 fffffc0001b482c0 fffffc00027d6618
             fffffc00027da7d0 00000000002ff97a 0000000000000000 fffffc0001b5be80
             fffffc00011d1abc fffffc000ecf14c0 fffffc0002d00000 fffffc0001b5be80
             fffffc0001b2350c 0000000000300000 fffffc0001b48298 fffffc0001b482c0
      Trace:
      [<fffffc00011cd148>] bad_page+0x168/0x1b0
      [<fffffc00011ce340>] free_pcp_prepare+0x1e0/0x290
      [<fffffc00011d1abc>] free_unref_page+0x2c/0xa0
      [<fffffc00014ee5f0>] cmp_ex_sort+0x0/0x30
      [<fffffc00014ee5f0>] cmp_ex_sort+0x0/0x30
      [<fffffc000101001c>] _stext+0x1c/0x20
      
      Fix this by registering the reserved ranges in memblock.memory.
      
      Link: https://lore.kernel.org/lkml/20210726192311.uffqnanxw3ac5wwi@ivybridge
      Fixes: fa3354e4
      
       ("mm: free_area_init: use maximal zone PFNs rather than zone sizes")
      Reported-by: default avatarMatt Turner <mattst88@gmail.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarMike Rapoport <rppt@linux.ibm.com>
      Signed-off-by: default avatarMatt Turner <mattst88@gmail.com>
      640b7ea5
    • Dave Airlie's avatar
      Merge tag 'drm-intel-fixes-2021-07-28' of... · 80c7917d
      Dave Airlie authored
      
      Merge tag 'drm-intel-fixes-2021-07-28' of git://anongit.freedesktop.org/drm/drm-intel into drm-fixes
      
      Display related fixes:
      - Fix vbt port mask
      - Fix around reading the right DSC disable fuse in display_ver 10
      - Split display version 9 and 10 in intel_setup_outputs
      
      Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
      
      From: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/YQF63ruuE72x2T45@intel.com
      80c7917d
    • Dave Airlie's avatar
      Merge tag 'drm-misc-fixes-2021-07-28' of git://anongit.freedesktop.org/drm/drm-misc into drm-fixes · 89e7ffd3
      Dave Airlie authored
      
      
      Short summary of fixes pull:
      
       * panel: Fix bpc for ytc700tlag_05_201c
       * ttm: debugfs init fixes
      
      Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
      
      From: Thomas Zimmermann <tzimmermann@suse.de>
      Link: https://patchwork.freedesktop.org/patch/msgid/YQFTESngqkeqzlhN@linux-uq9g.fritz.box
      89e7ffd3
    • Dave Airlie's avatar
      Merge tag 'drm-msm-fixes-2021-07-27' of https://gitlab.freedesktop.org/drm/msm into drm-fixes · 792ca7e3
      Dave Airlie authored
      
      
      A few fixes for v5.14, including a fix for a crash if display triggers
      an iommu fault (which tends to happen at probe time on devices with
      bootloader fw that leaves display enabled as kernel starts)
      
      Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
      From: Rob Clark <robdclark@gmail.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/CAF6AEGubeV_uzWhsqp_+EmQmPcPatnqWOQnARoing2YvQOHbyg@mail.gmail.com
      792ca7e3
    • Linus Torvalds's avatar
      Merge tag 'fixes_for_v5.14-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs · 4010a528
      Linus Torvalds authored
      Pull ext2 and reiserfs fixes from Jan Kara:
       "A fix for the ext2 conversion to kmap_local() and two reiserfs
        hardening fixes"
      
      * tag 'fixes_for_v5.14-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs:
        reiserfs: check directory items on read from disk
        fs/ext2: Avoid page_address on pages returned by ext2_get_page
        reiserfs: add check for root_inode in reiserfs_fill_super
      4010a528
    • Linus Torvalds's avatar
      Merge tag 'platform-drivers-x86-v5.14-2' of... · dfe49536
      Linus Torvalds authored
      Merge tag 'platform-drivers-x86-v5.14-2' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86
      
      Pull x86 platform driver fixes from Hans de Goede:
       "A set of bug-fixes and new hardware ids.
      
        Highlights:
      
         - amd-pmc fixes
      
         - think-lmi fixes
      
         - various new hardware-ids"
      
      * tag 'platform-drivers-x86-v5.14-2' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86:
        platform/x86: gigabyte-wmi: add support for B550 Aorus Elite V2
        platform/x86: intel-hid: add Alder Lake ACPI device ID
        platform/x86: think-lmi: Fix possible mem-leaks on tlmi_analyze() error-exit
        platform/x86: think-lmi: Split kobject_init() and kobject_add() calls
        platform/x86: think-lmi: Move pending_reboot_attr to the attributes sysfs dir
        platform/x86: amd-pmc: Fix undefined reference to __udivdi3
        platform/x86: amd-pmc: Fix missing unlock on error in amd_pmc_send_cmd()
        platform/x86: wireless-hotkey: remove hardcoded "hp" from the error message
        platform/x86: amd-pmc: Use return code on suspend
        platform/x86: amd-pmc: Add new acpi id for future PMC controllers
        platform/x86: amd-pmc: Add support for ACPI ID AMDI0006
        platform/x86: amd-pmc: Add support for logging s0ix counters
        platform/x86: amd-pmc: Add support for logging SMU metrics
        platform/x86: amd-pmc: call dump registers only once
        platform/x86: amd-pmc: Fix SMU firmware reporting mechanism
        platform/x86: amd-pmc: Fix command completion code
        platform/x86: think-lmi: Add pending_reboot support
      dfe49536
    • Tony Luck's avatar
      dmaengine: idxd: Change license on idxd.h to LGPL · 25905f60
      Tony Luck authored
      
      
      This file was given GPL-2.0 license. But LGPL-2.1 makes more sense
      as it needs to be used by libraries outside of the kernel source tree.
      
      Signed-off-by: default avatarTony Luck <tony.luck@intel.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      25905f60
    • Miklos Szeredi's avatar
      af_unix: fix garbage collect vs MSG_PEEK · cbcf0112
      Miklos Szeredi authored
      
      
      unix_gc() assumes that candidate sockets can never gain an external
      reference (i.e.  be installed into an fd) while the unix_gc_lock is
      held.  Except for MSG_PEEK this is guaranteed by modifying inflight
      count under the unix_gc_lock.
      
      MSG_PEEK does not touch any variable protected by unix_gc_lock (file
      count is not), yet it needs to be serialized with garbage collection.
      Do this by locking/unlocking unix_gc_lock:
      
       1) increment file count
      
       2) lock/unlock barrier to make sure incremented file count is visible
          to garbage collection
      
       3) install file into fd
      
      This is a lock barrier (unlike smp_mb()) that ensures that garbage
      collection is run completely before or completely after the barrier.
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      cbcf0112
    • Desmond Cheong Zhi Xi's avatar
      btrfs: fix rw device counting in __btrfs_free_extra_devids · b2a61667
      Desmond Cheong Zhi Xi authored
      When removing a writeable device in __btrfs_free_extra_devids, the rw
      device count should be decremented.
      
      This error was caught by Syzbot which reported a warning in
      close_fs_devices:
      
        WARNING: CPU: 1 PID: 9355 at fs/btrfs/volumes.c:1168 close_fs_devices+0x763/0x880 fs/btrfs/volumes.c:1168
        Modules linked in:
        CPU: 0 PID: 9355 Comm: syz-executor552 Not tainted 5.13.0-rc1-syzkaller #0
        Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
        RIP: 0010:close_fs_devices+0x763/0x880 fs/btrfs/volumes.c:1168
        RSP: 0018:ffffc9000333f2f0 EFLAGS: 00010293
        RAX: ffffffff8365f5c3 RBX: 0000000000000001 RCX: ffff888029afd4c0
        RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000000
        RBP: ffff88802846f508 R08: ffffffff8365f525 R09: ffffed100337d128
        R10: ffffed100337d128 R11: 0000000000000000 R12: dffffc0000000000
        R13: ffff888019be8868 R14: 1ffff1100337d10d R15: 1ffff1100337d10a
        FS:  00007f6f53828700(0000) GS:ffff8880b9a00000(0000) knlGS:0000000000000000
        CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: 000000000047c410 CR3: 00000000302a6000 CR4: 00000000001506f0
        DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
        DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
        Call Trace:
         btrfs_close_devices+0xc9/0x450 fs/btrfs/volumes.c:1180
         open_ctree+0x8e1/0x3968 fs/btrfs/disk-io.c:3693
         btrfs_fill_super fs/btrfs/super.c:1382 [inline]
         btrfs_mount_root+0xac5/0xc60 fs/btrfs/super.c:1749
         legacy_get_tree+0xea/0x180 fs/fs_context.c:592
         vfs_get_tree+0x86/0x270 fs/super.c:1498
         fc_mount fs/namespace.c:993 [inline]
         vfs_kern_mount+0xc9/0x160 fs/namespace.c:1023
         btrfs_mount+0x3d3/0xb50 fs/btrfs/super.c:1809
         legacy_get_tree+0xea/0x180 fs/fs_context.c:592
         vfs_get_tree+0x86/0x270 fs/super.c:1498
         do_new_mount fs/namespace.c:2905 [inline]
         path_mount+0x196f/0x2be0 fs/namespace.c:3235
         do_mount fs/namespace.c:3248 [inline]
         __do_sys_mount fs/namespace.c:3456 [inline]
         __se_sys_mount+0x2f9/0x3b0 fs/namespace.c:3433
         do_syscall_64+0x3f/0xb0 arch/x86/entry/common.c:47
         entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      Because fs_devices->rw_devices was not 0 after
      closing all devices. Here is the call trace that was observed:
      
        btrfs_mount_root():
          btrfs_scan_one_device():
            device_list_add();   <---------------- device added
          btrfs_open_devices():
            open_fs_devices():
              btrfs_open_one_device();   <-------- writable device opened,
      	                                     rw device count ++
          btrfs_fill_super():
            open_ctree():
              btrfs_free_extra_devids():
      	  __btrfs_free_extra_devids();  <--- writable device removed,
      	                              rw device count not decremented
      	  fail_tree_roots:
      	    btrfs_close_devices():
      	      close_fs_devices();   <------- rw device count off by 1
      
      As a note, prior to commit cf89af14 ("btrfs: dev-replace: fail
      mount if we don't have replace item with target device"), rw_devices
      was decremented on removing a writable device in
      __btrfs_free_extra_devids only if the BTRFS_DEV_STATE_REPLACE_TGT bit
      was not set for the device. However, this check does not need to be
      reinstated as it is now redundant and incorrect.
      
      In __btrfs_free_extra_devids, we skip removing the device if it is the
      target for replacement. This is done by checking whether device->devid
      == BTRFS_DEV_REPLACE_DEVID. Since BTRFS_DEV_STATE_REPLACE_TGT is set
      only on the device with devid BTRFS_DEV_REPLACE_DEVID, no devices
      should have the BTRFS_DEV_STATE_REPLACE_TGT bit set after the check,
      and so it's redundant to test for that bit.
      
      Additionally, following commit 82372bc8
      
       ("Btrfs: make
      the logic of source device removing more clear"), rw_devices is
      incremented whenever a writeable device is added to the alloc
      list (including the target device in btrfs_dev_replace_finishing), so
      all removals of writable devices from the alloc list should also be
      accompanied by a decrement to rw_devices.
      
      Reported-by: default avatar <syzbot+a70e2ad0879f160b9217@syzkaller.appspotmail.com>
      Fixes: cf89af14
      
       ("btrfs: dev-replace: fail mount if we don't have replace item with target device")
      CC: stable@vger.kernel.org # 5.10+
      Tested-by: default avatar <syzbot+a70e2ad0879f160b9217@syzkaller.appspotmail.com>
      Reviewed-by: default avatarAnand Jain <anand.jain@oracle.com>
      Signed-off-by: default avatarDesmond Cheong Zhi Xi <desmondcheongzx@gmail.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      b2a61667
    • Filipe Manana's avatar
      btrfs: fix lost inode on log replay after mix of fsync, rename and inode eviction · ecc64fab
      Filipe Manana authored
      
      
      When checking if we need to log the new name of a renamed inode, we are
      checking if the inode and its parent inode have been logged before, and if
      not we don't log the new name. The check however is buggy, as it directly
      compares the logged_trans field of the inodes versus the ID of the current
      transaction. The problem is that logged_trans is a transient field, only
      stored in memory and never persisted in the inode item, so if an inode
      was logged before, evicted and reloaded, its logged_trans field is set to
      a value of 0, meaning the check will return false and the new name of the
      renamed inode is not logged. If the old parent directory was previously
      fsynced and we deleted the logged directory entries corresponding to the
      old name, we end up with a log that when replayed will delete the renamed
      inode.
      
      The following example triggers the problem:
      
        $ mkfs.btrfs -f /dev/sdc
        $ mount /dev/sdc /mnt
      
        $ mkdir /mnt/A
        $ mkdir /mnt/B
        $ echo -n "hello world" > /mnt/A/foo
      
        $ sync
      
        # Add some new file to A and fsync directory A.
        $ touch /mnt/A/bar
        $ xfs_io -c "fsync" /mnt/A
      
        # Now trigger inode eviction. We are only interested in triggering
        # eviction for the inode of directory A.
        $ echo 2 > /proc/sys/vm/drop_caches
      
        # Move foo from directory A to directory B.
        # This deletes the directory entries for foo in A from the log, and
        # does not add the new name for foo in directory B to the log, because
        # logged_trans of A is 0, which is less than the current transaction ID.
        $ mv /mnt/A/foo /mnt/B/foo
      
        # Now make an fsync to anything except A, B or any file inside them,
        # like for example create a file at the root directory and fsync this
        # new file. This syncs the log that contains all the changes done by
        # previous rename operation.
        $ touch /mnt/baz
        $ xfs_io -c "fsync" /mnt/baz
      
        <power fail>
      
        # Mount the filesystem and replay the log.
        $ mount /dev/sdc /mnt
      
        # Check the filesystem content.
        $ ls -1R /mnt
        /mnt/:
        A
        B
        baz
      
        /mnt/A:
        bar
      
        /mnt/B:
        $
      
        # File foo is gone, it's neither in A/ nor in B/.
      
      Fix this by using the inode_logged() helper at btrfs_log_new_name(), which
      safely checks if an inode was logged before in the current transaction.
      
      A test case for fstests will follow soon.
      
      CC: stable@vger.kernel.org # 4.14+
      Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      ecc64fab
    • Goldwyn Rodrigues's avatar
      btrfs: mark compressed range uptodate only if all bio succeed · 240246f6
      Goldwyn Rodrigues authored
      
      
      In compression write endio sequence, the range which the compressed_bio
      writes is marked as uptodate if the last bio of the compressed (sub)bios
      is completed successfully. There could be previous bio which may
      have failed which is recorded in cb->errors.
      
      Set the writeback range as uptodate only if cb->errors is zero, as opposed
      to checking only the last bio's status.
      
      Backporting notes: in all versions up to 4.4 the last argument is always
      replaced by "!cb->errors".
      
      CC: stable@vger.kernel.org # 4.4+
      Signed-off-by: default avatarGoldwyn Rodrigues <rgoldwyn@suse.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      240246f6
  4. Jul 28, 2021