Verification done for linux on xenial-proposed.

The inodes for file, xattr dir, and xattr child are all evicted at file
removal time, not making it to any disposal list after file removal.

So the window/scenario for the problem to occur is not present anymore.

Log
---

$ uname -rv
4.4.0-160-generic #188-Ubuntu SMP Wed Aug 14 04:21:43 UTC 2019

$ modinfo zfs | head
filename:       /lib/modules/4.4.0-160-generic/kernel/zfs/zfs/zfs.ko
version:        0.6.5.6-0ubuntu28
...
srcversion:     99F1D0FED2F291CA7AED0C6

$ sudo apt-get install zfsutils-linux attr

$ sudo ./zfs-mount.sh

$ echo 2 | sudo tee /proc/sys/vm/drop_caches
2

$ sudo ./zfs-kprobes.sh

$ sudo cat /sys/kernel/debug/tracing/trace_pipe &

$ touch /zfs/file
           touch-10656 [001] d...   359.615887: p_zfs_mknode_0: 
(zfs_mknode+0x0/0xe00 [zfs]) flag=0x0 dzp=0xffff8800b9875940
           touch-10656 [001] d...   359.616184: p_zfs_znode_alloc_0: 
(zfs_znode_alloc+0x0/0x520 [zfs]) obj=0xa
           touch-10656 [001] d...   359.616339: r_zfs_znode_alloc_0: 
(zfs_mknode+0x8a3/0xe00 [zfs] <- zfs_znode_alloc) zpp=0xffff880036f48440

$ setfattr -n user.debug -v 1 /zfs/file
        setfattr-10657 [000] d...   361.507063: p_zfs_mknode_0: 
(zfs_mknode+0x0/0xe00 [zfs]) flag=0x2 dzp=0xffff880036f48440
        setfattr-10657 [000] d...   361.507265: p_zfs_znode_alloc_0: 
(zfs_znode_alloc+0x0/0x520 [zfs]) obj=0xb
        setfattr-10657 [000] d...   361.507402: r_zfs_znode_alloc_0: 
(zfs_mknode+0x8a3/0xe00 [zfs] <- zfs_znode_alloc) zpp=0xffff880139d09980
        setfattr-10657 [000] d...   361.507665: p_zfs_zget_0: 
(zfs_zget+0x0/0x230 [zfs]) zsb=0xffff8800bb12c000 obj=0xa
        setfattr-10657 [000] d...   361.507792: r_zfs_zget_0: 
(zfs_zaccess+0x12b/0x220 [zfs] <- zfs_zget)
        setfattr-10657 [000] d...   361.507981: p_zfs_zget_0: 
(zfs_zget+0x0/0x230 [zfs]) zsb=0xffff8800bb12c000 obj=0xa
        setfattr-10657 [000] d...   361.508104: r_zfs_zget_0: 
(zfs_zaccess+0x12b/0x220 [zfs] <- zfs_zget)
        setfattr-10657 [000] d...   361.508692: p_zfs_zget_0: 
(zfs_zget+0x0/0x230 [zfs]) zsb=0xffff8800bb12c000 obj=0xa
        setfattr-10657 [000] d...   361.508821: r_zfs_zget_0: 
(zfs_zaccess+0x12b/0x220 [zfs] <- zfs_zget)
        setfattr-10657 [000] d...   361.509022: p_zfs_mknode_0: 
(zfs_mknode+0x0/0xe00 [zfs]) flag=0x0 dzp=0xffff880139d09980
        setfattr-10657 [000] d...   361.509170: p_zfs_znode_alloc_0: 
(zfs_znode_alloc+0x0/0x520 [zfs]) obj=0xc
        setfattr-10657 [000] d...   361.509302: r_zfs_znode_alloc_0: 
(zfs_mknode+0x8a3/0xe00 [zfs] <- zfs_znode_alloc) zpp=0xffff880139d09100

$ rm /zfs/file
              rm-10658 [001] d...   363.216716: p_zfs_zget_0: 
(zfs_zget+0x0/0x230 [zfs]) zsb=0xffff8800bb12c000 obj=0xa
              rm-10658 [001] d...   363.216882: r_zfs_zget_0: 
(zfs_dirent_lock+0x56c/0x6c0 [zfs] <- zfs_zget)
              rm-10658 [001] d...   363.217130: p_zfs_zget_0: 
(zfs_zget+0x0/0x230 [zfs]) zsb=0xffff8800bb12c000 obj=0xb
              rm-10658 [001] d...   363.217271: r_zfs_zget_0: 
(zfs_remove+0x22b/0x4c0 [zfs] <- zfs_zget)
              rm-10658 [001] d...   363.217567: p_zpl_evict_inode_0: 
(zpl_evict_inode+0x0/0x60 [zfs]) inode=0xffff880036f48650
              rm-10658 [001] d...   363.217715: p_zfs_inactive_0: 
(zfs_inactive+0x0/0x270 [zfs]) inode=0xffff880036f48650
              rm-10658 [001] d...   363.217835: p_zfs_zinactive_0: 
(zfs_zinactive+0x0/0xe0 [zfs]) znode=0xffff880036f48440 obj=0xa
              rm-10658 [001] d...   363.217963: p_zfs_rmnode_0: 
(zfs_rmnode+0x0/0x360 [zfs]) znode=0xffff880036f48440
              rm-10658 [001] d...   363.218102: p_zfs_zget_0: 
(zfs_zget+0x0/0x230 [zfs]) zsb=0xffff8800bb12c000 obj=0xb
              rm-10658 [001] d...   363.218232: r_zfs_zget_0: 
(zfs_rmnode+0x25b/0x360 [zfs] <- zfs_zget)
              rm-10658 [001] d...   363.218464: p_zfs_iput_async_0: 
(zfs_iput_async+0x0/0x60 [zfs]) inode=0xffff880139d09b90 obj=0x0
           <...>-10308 [003] d...   363.218496: p_zpl_evict_inode_0: 
(zpl_evict_inode+0x0/0x60 [zfs]) inode=0xffff880139d09b90
          z_iput-10308 [003] d...   363.218503: p_zfs_inactive_0: 
(zfs_inactive+0x0/0x270 [zfs]) inode=0xffff880139d09b90
          z_iput-10308 [003] d...   363.218505: p_zfs_zinactive_0: 
(zfs_zinactive+0x0/0xe0 [zfs]) znode=0xffff880139d09980 obj=0xb
          z_iput-10308 [003] d...   363.218509: p_zfs_rmnode_0: 
(zfs_rmnode+0x0/0x360 [zfs]) znode=0xffff880139d09980
          z_iput-10308 [003] d...   363.218512: p_zfs_purgedir_0: 
(zfs_purgedir+0x0/0x230 [zfs]) znode=0xffff880139d09980
          z_iput-10308 [003] d...   363.218560: p_zfs_zget_0: 
(zfs_zget+0x0/0x230 [zfs]) zsb=0xffff8800bb12c000 obj=0xc
          z_iput-10308 [003] d...   363.218566: r_zfs_zget_0: 
(zfs_purgedir+0xb4/0x230 [zfs] <- zfs_zget)
          z_iput-10308 [003] d...   363.218606: p_zfs_iput_async_0: 
(zfs_iput_async+0x0/0x60 [zfs]) inode=0xffff880139d09310 obj=0x0
          z_iput-10308 [003] d...   363.218626: r_zfs_purgedir_0: 
(zfs_rmnode+0x272/0x360 [zfs] <- zfs_purgedir)
          z_iput-10308 [003] d...   363.218663: p_zpl_evict_inode_0: 
(zpl_evict_inode+0x0/0x60 [zfs]) inode=0xffff880139d09310
          z_iput-10308 [003] d...   363.218665: p_zfs_inactive_0: 
(zfs_inactive+0x0/0x270 [zfs]) inode=0xffff880139d09310
          z_iput-10308 [003] d...   363.218665: p_zfs_zinactive_0: 
(zfs_zinactive+0x0/0xe0 [zfs]) znode=0xffff880139d09100 obj=0xc
          z_iput-10308 [003] d...   363.218667: p_zfs_rmnode_0: 
(zfs_rmnode+0x0/0x360 [zfs]) znode=0xffff880139d09100

$ echo 2 | sudo tee /proc/sys/vm/drop_caches
2
           <...>-10661 [003] d...   372.513411: p_dispose_list_0: 
(dispose_list+0x0/0x50)
             tee-10661 [003] d...   372.513525: p_dispose_list_0: 
(dispose_list+0x0/0x50)
             tee-10661 [003] d...   372.513836: p_dispose_list_0: 
(dispose_list+0x0/0x50)
             tee-10661 [003] d...   372.514065: p_dispose_list_0: 
(dispose_list+0x0/0x50)
             tee-10661 [003] d...   372.516630: p_dispose_list_0: 
(dispose_list+0x0/0x50)
             tee-10661 [003] d...   372.516691: p_dispose_list_0: 
(dispose_list+0x0/0x50)
             tee-10661 [003] d...   372.516830: p_dispose_list_0: 
(dispose_list+0x0/0x50)

-- 
You received this bug notification because you are a member of Kernel
Packages, which is subscribed to zfs-linux in Ubuntu.
https://bugs.launchpad.net/bugs/1839521

Title:
  Xenial: ZFS deadlock in shrinker path with xattrs

Status in zfs-linux package in Ubuntu:
  Fix Released
Status in zfs-linux source package in Xenial:
  Fix Committed

Bug description:
  [Impact]

   * Xenial's ZFS can deadlock in the memory shrinker path
     after removing files with extended attributes (xattr).

   * Extended attributes are enabled by default, but are
     _not_ used by default, which reduces the likelyhood.

   * It's very difficult/rare to reproduce this problem,
     due to file/xattr/remove/shrinker/lru order/timing
     circumstances required. (weeks for a reporter user)
     but a synthetic test-case has been found for tests.

  [Test Case]

   * A synthetic reproducer is available for this LP,
     with a few steps to touch/setfattr/rm/drop_caches
     plus a kernel module to massage the disposal list.
     (comment #8)

   * In the original ZFS module:
     the xattr dir inode is not purged immediately on
     file removal, but possibly purged _two_ shrinker
     invocations later.  This allows for other thread
     started before file remove to call zfs_zget() on
     the xattr child inode and iput() it, so it makes
     to the same disposal list as the xattr dir inode.
     (comment #3)

   * In the modified ZFS module:
     the xattr dir inode is purged immediately on file
     removal not possibly later on shrinker invocation,
     so the problem window above doesn't exist anymore.
     (comment #12)

  [Regression Potential]

   * Low. The patches are confined to extended attributes
     in ZFS, specifically node removal/purge, and another
     change how an xattr child inode tracks its xattr dir
     (parent) inode, so that it can be purged immediately
     on removal.

   * The ZFS test-suite has been run on original/modified
     zfs-dkms package/kernel modules, with no regressions.
     (comment #11)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/zfs-linux/+bug/1839521/+subscriptions

-- 
Mailing list: https://launchpad.net/~kernel-packages
Post to     : kernel-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kernel-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to