Skip to content
  1. Mar 01, 2015
    • Joonsoo Kim's avatar
      mm/nommu: fix memory leak · da616534
      Joonsoo Kim authored
      Maxime reported the following memory leak regression due to commit
      dbc8358c ("mm/nommu: use alloc_pages_exact() rather than its own
      implementation").
      
      On v3.19, I am facing a memory leak.  Each time I run a command one page
      is lost.  Here an example with busybox's free command:
      
        / # free
                     total       used       free     shared    buffers     cached
        Mem:          7928       1972       5956          0          0        492
        -/+ buffers/cache:       1480       6448
        / # free
                     total       used       free     shared    buffers     cached
        Mem:          7928       1976       5952          0          0        492
        -/+ buffers/cache:       1484       6444
        / # free
                     total       used       free     shared    buffers     cached
        Mem:          7928       1980       5948          0          0        492
        -/+ buffers/cache:       1488       6440
        / # free
                     total       used       free     shared    buffers     cached
        Mem:          7928       1984       5944          0          0        492
        -/+ buffers/cache:       1492       6436
        / # free
                     total       used       free     shared    buffers     cached
        Mem:          7928       1988       5940          0          0        492
        -/+ buffers/cache:       1496       6432
      
      At some point, the system fails to sastisfy 256KB allocations:
      
        free: page allocation failure: order:6, mode:0xd0
        CPU: 0 PID: 67 Comm: free Not tainted 3.19.0-05389-gacf2cf1-dirty #64
        Hardware name: STM32 (Device Tree Support)
          show_stack+0xb/0xc
          warn_alloc_failed+0x97/0xbc
          __alloc_pages_nodemask+0x295/0x35c
          __get_free_pages+0xb/0x24
          alloc_pages_exact+0x19/0x24
          do_mmap_pgoff+0x423/0x658
          vm_mmap_pgoff+0x3f/0x4e
          load_flat_file+0x20d/0x4f8
          load_flat_binary+0x3f/0x26c
          search_binary_handler+0x51/0xe4
          do_execveat_common+0x271/0x35c
          do_execve+0x19/0x1c
          ret_fast_syscall+0x1/0x4a
        Mem-info:
        Normal per-cpu:
        CPU    0: hi:    0, btch:   1 usd:   0
        active_anon:0 inactive_anon:0 isolated_anon:0
         active_file:0 inactive_file:0 isolated_file:0
         unevictable:123 dirty:0 writeback:0 unstable:0
         free:1515 slab_reclaimable:17 slab_unreclaimable:139
         mapped:0 shmem:0 pagetables:0 bounce:0
         free_cma:0
        Normal free:6060kB min:352kB low:440kB high:528kB active_anon:0kB inactive_anon:0kB active_file:0kB inactive_file:0kB unevictable:492kB isolated(anon):0ks
        lowmem_reserve[]: 0 0
        Normal: 23*4kB (U) 22*8kB (U) 24*16kB (U) 23*32kB (U) 23*64kB (U) 23*128kB (U) 1*256kB (U) 0*512kB 0*1024kB 0*2048kB 0*4096kB = 6060kB
        123 total pagecache pages
        2048 pages of RAM
        1538 free pages
        66 reserved pages
        109 slab pages
        -46 pages shared
        0 pages swap cached
        nommu: Allocation of length 221184 from process 67 (free) failed
        Normal per-cpu:
        CPU    0: hi:    0, btch:   1 usd:   0
        active_anon:0 inactive_anon:0 isolated_anon:0
         active_file:0 inactive_file:0 isolated_file:0
         unevictable:123 dirty:0 writeback:0 unstable:0
         free:1515 slab_reclaimable:17 slab_unreclaimable:139
         mapped:0 shmem:0 pagetables:0 bounce:0
         free_cma:0
        Normal free:6060kB min:352kB low:440kB high:528kB active_anon:0kB inactive_anon:0kB active_file:0kB inactive_file:0kB unevictable:492kB isolated(anon):0ks
        lowmem_reserve[]: 0 0
        Normal: 23*4kB (U) 22*8kB (U) 24*16kB (U) 23*32kB (U) 23*64kB (U) 23*128kB (U) 1*256kB (U) 0*512kB 0*1024kB 0*2048kB 0*4096kB = 6060kB
        123 total pagecache pages
        Unable to allocate RAM for process text/data, errno 12 SEGV
      
      This problem happens because we allocate ordered page through
      __get_free_pages() in do_mmap_private() in some cases and we try to free
      individual pages rather than ordered page in free_page_series().  In
      this case, freeing pages whose refcount is not 0 won't be freed to the
      page allocator so memory leak happens.
      
      To fix the problem, this patch changes __get_free_pages() to
      alloc_pages_exact() since alloc_pages_exact() returns
      physically-contiguous pages but each pages are refcounted.
      
      Fixes: dbc8358c
      
       ("mm/nommu: use alloc_pages_exact() rather than its own implementation").
      Reported-by: default avatarMaxime Coquelin <mcoquelin.stm32@gmail.com>
      Tested-by: default avatarMaxime Coquelin <mcoquelin.stm32@gmail.com>
      Signed-off-by: default avatarJoonsoo Kim <iamjoonsoo.kim@lge.com>
      Cc: <stable@vger.kernel.org>	[3.19]
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      da616534
    • Mark Fasheh's avatar
      ocfs2: update web page + git tree in documentation · 01945fa2
      Mark Fasheh authored
      We (the Ocfs2 project) recently moved the location of our ocfs2-tools
      git tree and project web page.  The pertinent discussion can be seen
      here:
      
        https://oss.oracle.com/pipermail/ocfs2-devel/2015-February/010579.html
      
      
      
      The following patch updates the Ocfs2 documentation in MAINTAINERS,
      ocfs2.txt, and dlmfs.txt.  I added our new official web page, changed
      the location of our tools git tree and removed the link to Joel's
      ancient kernel git tree - Andrew has handled our patches for a while
      now.
      
      Signed-off-by: default avatarMark Fasheh <mfasheh@suse.de>
      Cc: Joel Becker <jlbec@evilplan.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      01945fa2
  2. Feb 27, 2015
  3. Feb 25, 2015
  4. Feb 24, 2015
  5. Feb 23, 2015
    • Takashi Iwai's avatar
      ALSA: pcm: Don't leave PREPARED state after draining · 70372a75
      Takashi Iwai authored
      
      
      When a PCM draining is performed to an empty stream that has been
      already in PREPARED state, the current code just ignores and leaves as
      it is, although the drain is supposed to set all such streams to SETUP
      state.  This patch covers that overlooked case.
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      70372a75
    • Jakub Sitnicki's avatar
      HID: microsoft: Add ID for NE7K wireless keyboard · ef567cf9
      Jakub Sitnicki authored
      Microsoft Natural Wireless Ergonomic Keyboard 7000 has special My
      Favorites 1..5 keys which are handled through a vendor-defined usage
      page (0xff05).
      
      Apply MS_ERGONOMY quirks handling to USB PID 0x071d (Microsoft Microsoft
      2.4GHz Transceiver V1.0) so that the My Favorites 1..5 keys are reported
      as KEY_F14..18 events.
      
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=52841
      
      
      Signed-off-by: default avatarJakub Sitnicki <jsitnicki@gmail.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      ef567cf9
    • Seth Forshee's avatar
      HID: i2c-hid: Limit reads to wMaxInputLength bytes for input events · 6d00f37e
      Seth Forshee authored
      d1c7e29e (HID: i2c-hid: prevent buffer overflow in early IRQ)
      changed hid_get_input() to read ihid->bufsize bytes, which can be
      more than wMaxInputLength. This is the case with the Dell XPS 13
      9343, and it is causing events to be missed. In some cases the
      missed events are releases, which can cause the cursor to jump or
      freeze, among other problems. Limit the number of bytes read to
      min(wMaxInputLength, ihid->bufsize) to prevent such problems.
      
      Fixes: d1c7e29e
      
       "HID: i2c-hid: prevent buffer overflow in early IRQ"
      Signed-off-by: default avatarSeth Forshee <seth.forshee@canonical.com>
      Reviewed-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      6d00f37e
    • Frank Praznik's avatar
      HID: sony: fix uninitialized per-controller spinlock · b94993f6
      Frank Praznik authored
      
      
      Per-controller spinlock needs to be properly initialized during device probe.
      
      [jkosina@suse.cz: massage changelog]
      [jkosina@suse.cz: drop hunk that has already been applied by previous
       patch]
      Signed-off-by: default avatarFrank Praznik <frank.praznik@oh.rr.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      b94993f6
    • Jiri Kosina's avatar
      HID: sony: initialize sony_dev_list_lock properly · 8b402c92
      Jiri Kosina authored
      sony_dev_list_lock spinlock (which was introduced in d2d782fc
      
       ("HID: sony:
      Prevent duplicate controller connections") is not being initialized properly.
      Fix that.
      
      Reported-by: default avatarPavel Machek <pavel@ucw.cz>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      8b402c92
    • Takashi Sakamoto's avatar
      ALSA: fireworks/bebob/dice/oxfw: make it possible to shutdown safely · dec84316
      Takashi Sakamoto authored
      
      
      A part of these drivers, especially BeBoB driver, are programmed to wait
      some events. Thus the drivers should not destroy any data in .remove()
      context.
      
      This commit moves some destructors from 'struct fw_driver.remove()' to
      'struct snd_card.private_free()' to shutdown safely.
      
      Signed-off-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
      Cc: <stable@vger.kernel.org> # 3.19+
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      dec84316
    • Takashi Sakamoto's avatar
      ALSA: fireworks/bebob/dice/oxfw: allow stream destructor after releasing runtime · d23c2cc4
      Takashi Sakamoto authored
      
      
      Currently stream destructor in each driver has a problem to be called in
      a context in which sound card object is released, because the destructors
      call amdtp_stream_pcm_abort() and touch PCM runtime data.
      
      The PCM runtime data is destroyed in application's context with
      snd_pcm_close(), on the other hand PCM substream data is destroyed after
      sound card object is released, in most case after all of ALSA character
      devices are released. When PCM runtime is destroyed and PCM substream is
      remained, amdtp_stream_pcm_abort() touches PCM runtime data and causes
      Null-pointer-dereference.
      
      This commit changes stream destructors and allows each driver to call
      it after releasing runtime.
      
      Signed-off-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
      Cc: <stable@vger.kernel.org> # 3.19+
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      d23c2cc4
    • Takashi Sakamoto's avatar
      ALSA: firewire-lib: remove reference counting · c6f224dc
      Takashi Sakamoto authored
      
      
      AMDTP helper functions increment/decrement reference counter for an
      instance of FireWire unit, while it's complicated for each driver to
      process error state.
      
      In previous commit, each driver has the role of reference counting. This
      commit removes this role from the helper function.
      
      Signed-off-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
      Cc: <stable@vger.kernel.org> # 3.19+
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      c6f224dc
    • Takashi Sakamoto's avatar
      ALSA: fireworks/bebob/dice/oxfw: add reference-counting for FireWire unit · 12ed7192
      Takashi Sakamoto authored
      
      
      Fireworks and Dice drivers try to touch instances of FireWire unit after
      sound card object is released, while references to the unit is decremented
      in .remove(). When unplugging during streaming, sound card object is
      released after .remove(), thus Fireworks and Dice drivers causes GPF or
      Null-pointer-dereferencing to application processes because an instance of
      FireWire unit was already released.
      
      This commit adds reference-counting for FireWire unit in drivers to allow
      them to touch an instance of FireWire unit after .remove(). In most case,
      any operations after .remove() may be failed safely.
      
      Signed-off-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
      Cc: <stable@vger.kernel.org> # 3.19+
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      12ed7192
    • Takashi Iwai's avatar
      ALSA: hda - Add pin configs for ASUS mobo with IDT 92HD73XX codec · 6426460e
      Takashi Iwai authored
      
      
      BIOS doesn't seem to set up pins for 5.1 and the SPDIF out, so we need
      to give explicitly here.
      
      Reported-and-tested-by: default avatarMisan Thropos <misanthropos@gmx.de>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      6426460e
    • Takashi Sakamoto's avatar
      ALSA: firewire-lib: fix an unexpected byte sequence for micro sign · ca5b5050
      Takashi Sakamoto authored
      The sign for microsecond (U+0085, MICRO SIGN) was encoded to '0x c2 b5'
      by UTF-8 character encoding scheme. But the byte sequence was converted
      to '0x c3 82 c2 b5' in a previous commit. As a result, the byte
      sequence cannot represent microsecond sign in UTF-8 or ASCII. This
      may confuse developers.
      
      This commit replaces the sign to string expression with 'microseconds'
      to purge superfluous troubles.
      
      Fixes: 5c697e5b
      
      ("ALSA: firewire-lib: remove rx_blocks_for_midi quirk")
      Signed-off-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      ca5b5050
    • Axel Lin's avatar
      hwmon: (ads7828) Check return value of devm_regmap_init_i2c · d9ef72cd
      Axel Lin authored
      
      
      devm_regmap_init_i2c() can fail, thus add return value checking.
      
      Signed-off-by: default avatarAxel Lin <axel.lin@ingics.com>
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      d9ef72cd
    • Linus Torvalds's avatar
      Linux 4.0-rc1 · c517d838
      Linus Torvalds authored
      .. after extensive statistical analysis of my G+ polling, I've come to
      the inescapable conclusion that internet polls are bad.
      
      Big surprise.
      
      But "Hurr durr I'ma sheep" trounced "I like online polls" by a 62-to-38%
      margin, in a poll that people weren't even supposed to participate in.
      Who can argue with solid numbers like that? 5,796 votes from people who
      can't even follow the most basic directions?
      
      In contrast, "v4.0" beat out "v3.20" by a slimmer margin of 56-to-44%,
      but with a total of 29,110 votes right now.
      
      Now, arguably, that vote spread is only about 3,200 votes, which is less
      than the almost six thousand votes that the "please ignore" poll got, so
      it could be considered noise.
      
      But hey, I asked, so I'll honor the votes.
      c517d838
    • Linus Torvalds's avatar
      Merge tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4 · feaf2229
      Linus Torvalds authored
      Pull ext4 fixes from Ted Ts'o:
       "Ext4 bug fixes.
      
        We also reserved code points for encryption and read-only images (for
        which the implementation is mostly just the reserved code point for a
        read-only feature :-)"
      
      * tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4:
        ext4: fix indirect punch hole corruption
        ext4: ignore journal checksum on remount; don't fail
        ext4: remove duplicate remount check for JOURNAL_CHECKSUM change
        ext4: fix mmap data corruption in nodelalloc mode when blocksize < pagesize
        ext4: support read-only images
        ext4: change to use setup_timer() instead of init_timer()
        ext4: reserve codepoints used by the ext4 encryption feature
        jbd2: complain about descriptor block checksum errors
      feaf2229
    • Linus Torvalds's avatar
      Merge branch 'for-linus-2' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs · be5e6616
      Linus Torvalds authored
      Pull more vfs updates from Al Viro:
       "Assorted stuff from this cycle.  The big ones here are multilayer
        overlayfs from Miklos and beginning of sorting ->d_inode accesses out
        from David"
      
      * 'for-linus-2' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (51 commits)
        autofs4 copy_dev_ioctl(): keep the value of ->size we'd used for allocation
        procfs: fix race between symlink removals and traversals
        debugfs: leave freeing a symlink body until inode eviction
        Documentation/filesystems/Locking: ->get_sb() is long gone
        trylock_super(): replacement for grab_super_passive()
        fanotify: Fix up scripted S_ISDIR/S_ISREG/S_ISLNK conversions
        Cachefiles: Fix up scripted S_ISDIR/S_ISREG/S_ISLNK conversions
        VFS: (Scripted) Convert S_ISLNK/DIR/REG(dentry->d_inode) to d_is_*(dentry)
        SELinux: Use d_is_positive() rather than testing dentry->d_inode
        Smack: Use d_is_positive() rather than testing dentry->d_inode
        TOMOYO: Use d_is_dir() rather than d_inode and S_ISDIR()
        Apparmor: Use d_is_positive/negative() rather than testing dentry->d_inode
        Apparmor: mediated_filesystem() should use dentry->d_sb not inode->i_sb
        VFS: Split DCACHE_FILE_TYPE into regular and special types
        VFS: Add a fallthrough flag for marking virtual dentries
        VFS: Add a whiteout dentry type
        VFS: Introduce inode-getting helpers for layered/unioned fs environments
        Infiniband: Fix potential NULL d_inode dereference
        posix_acl: fix reference leaks in posix_acl_create
        autofs4: Wrong format for printing dentry
        ...
      be5e6616
    • Petr Mladek's avatar
      livepatch: RCU protect struct klp_func all the time when used in klp_ftrace_handler() · c4ce0da8
      Petr Mladek authored
      
      
      func->new_func has been accessed after rcu_read_unlock() in klp_ftrace_handler()
      and therefore the access was not protected.
      
      Signed-off-by: default avatarPetr Mladek <pmladek@suse.cz>
      Acked-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      c4ce0da8
    • Linus Torvalds's avatar
      Merge branch 'fixes' of git://ftp.arm.linux.org.uk/~rmk/linux-arm · 90c453ca
      Linus Torvalds authored
      Pull ARM fix from Russell King:
       "Just one fix this time around.  __iommu_alloc_buffer() can cause a
        BUG() if dma_alloc_coherent() is called with either __GFP_DMA32 or
        __GFP_HIGHMEM set.  The patch from Alexandre addresses this"
      
      * 'fixes' of git://ftp.arm.linux.org.uk/~rmk/linux-arm:
        ARM: 8305/1: DMA: Fix kzalloc flags in __iommu_alloc_buffer()
      90c453ca
    • Al Viro's avatar
      autofs4 copy_dev_ioctl(): keep the value of ->size we'd used for allocation · 0a280962
      Al Viro authored
      
      
      X-Coverup: just ask spender
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      0a280962
    • Al Viro's avatar
      procfs: fix race between symlink removals and traversals · 7e0e953b
      Al Viro authored
      
      
      use_pde()/unuse_pde() in ->follow_link()/->put_link() resp.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      7e0e953b
    • Al Viro's avatar
      debugfs: leave freeing a symlink body until inode eviction · 0db59e59
      Al Viro authored
      
      
      As it is, we have debugfs_remove() racing with symlink traversals.
      Supply ->evict_inode() and do freeing there - inode will remain
      pinned until we are done with the symlink body.
      
      And rip the idiocy with checking if dentry is positive right after
      we'd verified debugfs_positive(), which is a stronger check...
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      0db59e59
    • Al Viro's avatar
      dca11178
    • Konstantin Khlebnikov's avatar
      trylock_super(): replacement for grab_super_passive() · eb6ef3df
      Konstantin Khlebnikov authored
      
      
      I've noticed significant locking contention in memory reclaimer around
      sb_lock inside grab_super_passive(). Grab_super_passive() is called from
      two places: in icache/dcache shrinkers (function super_cache_scan) and
      from writeback (function __writeback_inodes_wb). Both are required for
      progress in memory allocator.
      
      Grab_super_passive() acquires sb_lock to increment sb->s_count and check
      sb->s_instances. It seems sb->s_umount locked for read is enough here:
      super-block deactivation always runs under sb->s_umount locked for write.
      Protecting super-block itself isn't a problem: in super_cache_scan() sb
      is protected by shrinker_rwsem: it cannot be freed if its slab shrinkers
      are still active. Inside writeback super-block comes from inode from bdi
      writeback list under wb->list_lock.
      
      This patch removes locking sb_lock and checks s_instances under s_umount:
      generic_shutdown_super() unlinks it under sb->s_umount locked for write.
      New variant is called trylock_super() and since it only locks semaphore,
      callers must call up_read(&sb->s_umount) instead of drop_super(sb) when
      they're done.
      
      Signed-off-by: default avatarKonstantin Khlebnikov <khlebnikov@yandex-team.ru>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      eb6ef3df
    • David Howells's avatar
      fanotify: Fix up scripted S_ISDIR/S_ISREG/S_ISLNK conversions · 54f2a2f4
      David Howells authored
      
      
      Fanotify probably doesn't want to watch autodirs so make it use d_can_lookup()
      rather than d_is_dir() when checking a dir watch and give an error on fake
      directories.
      
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      54f2a2f4
    • David Howells's avatar
      Cachefiles: Fix up scripted S_ISDIR/S_ISREG/S_ISLNK conversions · ce40fa78
      David Howells authored
      
      
      Fix up the following scripted S_ISDIR/S_ISREG/S_ISLNK conversions (or lack
      thereof) in cachefiles:
      
       (1) Cachefiles mostly wants to use d_can_lookup() rather than d_is_dir() as
           it doesn't want to deal with automounts in its cache.
      
       (2) Coccinelle didn't find S_IS* expressions in ASSERT() statements in
           cachefiles.
      
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      ce40fa78
    • David Howells's avatar
      VFS: (Scripted) Convert S_ISLNK/DIR/REG(dentry->d_inode) to d_is_*(dentry) · e36cb0b8
      David Howells authored
      
      
      Convert the following where appropriate:
      
       (1) S_ISLNK(dentry->d_inode) to d_is_symlink(dentry).
      
       (2) S_ISREG(dentry->d_inode) to d_is_reg(dentry).
      
       (3) S_ISDIR(dentry->d_inode) to d_is_dir(dentry).  This is actually more
           complicated than it appears as some calls should be converted to
           d_can_lookup() instead.  The difference is whether the directory in
           question is a real dir with a ->lookup op or whether it's a fake dir with
           a ->d_automount op.
      
      In some circumstances, we can subsume checks for dentry->d_inode not being
      NULL into this, provided we the code isn't in a filesystem that expects
      d_inode to be NULL if the dirent really *is* negative (ie. if we're going to
      use d_inode() rather than d_backing_inode() to get the inode pointer).
      
      Note that the dentry type field may be set to something other than
      DCACHE_MISS_TYPE when d_inode is NULL in the case of unionmount, where the VFS
      manages the fall-through from a negative dentry to a lower layer.  In such a
      case, the dentry type of the negative union dentry is set to the same as the
      type of the lower dentry.
      
      However, if you know d_inode is not NULL at the call site, then you can use
      the d_is_xxx() functions even in a filesystem.
      
      There is one further complication: a 0,0 chardev dentry may be labelled
      DCACHE_WHITEOUT_TYPE rather than DCACHE_SPECIAL_TYPE.  Strictly, this was
      intended for special directory entry types that don't have attached inodes.
      
      The following perl+coccinelle script was used:
      
      use strict;
      
      my @callers;
      open($fd, 'git grep -l \'S_IS[A-Z].*->d_inode\' |') ||
          die "Can't grep for S_ISDIR and co. callers";
      @callers = <$fd>;
      close($fd);
      unless (@callers) {
          print "No matches\n";
          exit(0);
      }
      
      my @cocci = (
          '@@',
          'expression E;',
          '@@',
          '',
          '- S_ISLNK(E->d_inode->i_mode)',
          '+ d_is_symlink(E)',
          '',
          '@@',
          'expression E;',
          '@@',
          '',
          '- S_ISDIR(E->d_inode->i_mode)',
          '+ d_is_dir(E)',
          '',
          '@@',
          'expression E;',
          '@@',
          '',
          '- S_ISREG(E->d_inode->i_mode)',
          '+ d_is_reg(E)' );
      
      my $coccifile = "tmp.sp.cocci";
      open($fd, ">$coccifile") || die $coccifile;
      print($fd "$_\n") || die $coccifile foreach (@cocci);
      close($fd);
      
      foreach my $file (@callers) {
          chomp $file;
          print "Processing ", $file, "\n";
          system("spatch", "--sp-file", $coccifile, $file, "--in-place", "--no-show-diff") == 0 ||
      	die "spatch failed";
      }
      
      [AV: overlayfs parts skipped]
      
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      e36cb0b8