Fix Change Details
------------------

(Compare with comment #3)

The xattr dir/child inodes are evicted/disposed 
immediately on file removal, not on shrinker.

$ touch /zfs/file
           <...>-23940 [006] d... 10808.746798: p_zfs_mknode_0: 
(zfs_mknode+0x0/0xe00 [zfs]) flag=0x0 dzp=0xffff88011aa94400
           <...>-23940 [006] d... 10808.746925: p_zfs_znode_alloc_0: 
(zfs_znode_alloc+0x0/0x520 [zfs]) obj=0xa
           <...>-23940 [006] d... 10808.746938: r_zfs_znode_alloc_0: 
(zfs_mknode+0x8a3/0xe00 [zfs] <- zfs_znode_alloc) zpp=0xffff88011aa90880

$ setfattr -n user.debug -v 1 /zfs/file
           <...>-23941 [006] d... 10818.945733: p_zfs_mknode_0: 
(zfs_mknode+0x0/0xe00 [zfs]) flag=0x2 dzp=0xffff88011aa90880
           <...>-23941 [006] d... 10818.945892: p_zfs_znode_alloc_0: 
(zfs_znode_alloc+0x0/0x520 [zfs]) obj=0xb
           <...>-23941 [006] d... 10818.945905: r_zfs_znode_alloc_0: 
(zfs_mknode+0x8a3/0xe00 [zfs] <- zfs_znode_alloc) zpp=0xffff88011aa961c0
           <...>-23941 [006] d... 10818.945925: p_zfs_zget_0: 
(zfs_zget+0x0/0x230 [zfs]) zsb=0xffff880016f00000 obj=0xa
        setfattr-23941 [006] d... 10818.945929: r_zfs_zget_0: 
(zfs_zaccess+0x12b/0x220 [zfs] <- zfs_zget)
        setfattr-23941 [006] d... 10818.945933: p_zfs_zget_0: 
(zfs_zget+0x0/0x230 [zfs]) zsb=0xffff880016f00000 obj=0xa
        setfattr-23941 [006] d... 10818.945936: r_zfs_zget_0: 
(zfs_zaccess+0x12b/0x220 [zfs] <- zfs_zget)
        setfattr-23941 [006] d... 10818.945948: p_zfs_zget_0: 
(zfs_zget+0x0/0x230 [zfs]) zsb=0xffff880016f00000 obj=0xa
        setfattr-23941 [006] d... 10818.945951: r_zfs_zget_0: 
(zfs_zaccess+0x12b/0x220 [zfs] <- zfs_zget)
        setfattr-23941 [006] d... 10818.945966: p_zfs_mknode_0: 
(zfs_mknode+0x0/0xe00 [zfs]) flag=0x0 dzp=0xffff88011aa961c0
        setfattr-23941 [006] d... 10818.945990: p_zfs_znode_alloc_0: 
(zfs_znode_alloc+0x0/0x520 [zfs]) obj=0xc
        setfattr-23941 [006] d... 10818.945996: r_zfs_znode_alloc_0: 
(zfs_mknode+0x8a3/0xe00 [zfs] <- zfs_znode_alloc) zpp=0xffff88011aa90440

$ rm /zfs/file
           <...>-23942 [006] d... 10822.453456: p_zfs_zget_0: 
(zfs_zget+0x0/0x230 [zfs]) zsb=0xffff880016f00000 obj=0xa
           <...>-23942 [006] d... 10822.453469: r_zfs_zget_0: 
(zfs_dirent_lock+0x56c/0x6c0 [zfs] <- zfs_zget)
              rm-23942 [006] d... 10822.453494: p_zfs_zget_0: 
(zfs_zget+0x0/0x230 [zfs]) zsb=0xffff880016f00000 obj=0xb
              rm-23942 [006] d... 10822.453498: r_zfs_zget_0: 
(zfs_remove+0x22b/0x4c0 [zfs] <- zfs_zget)
              rm-23942 [006] d... 10822.453597: p_zpl_evict_inode_0: 
(zpl_evict_inode+0x0/0x60 [zfs]) inode=0xffff88011aa90a90
              rm-23942 [006] d... 10822.453602: p_zfs_inactive_0: 
(zfs_inactive+0x0/0x270 [zfs]) inode=0xffff88011aa90a90
              rm-23942 [006] d... 10822.453603: p_zfs_zinactive_0: 
(zfs_zinactive+0x0/0xe0 [zfs]) znode=0xffff88011aa90880 obj=0xa
              rm-23942 [006] d... 10822.453607: p_zfs_rmnode_0: 
(zfs_rmnode+0x0/0x360 [zfs]) znode=0xffff88011aa90880
              rm-23942 [006] d... 10822.453619: p_zfs_zget_0: 
(zfs_zget+0x0/0x230 [zfs]) zsb=0xffff880016f00000 obj=0xb
              rm-23942 [006] d... 10822.453623: r_zfs_zget_0: 
(zfs_rmnode+0x25b/0x360 [zfs] <- zfs_zget)
              rm-23942 [006] d... 10822.453656: p_zfs_iput_async_0: 
(zfs_iput_async+0x0/0x60 [zfs]) inode=0xffff88011aa963d0 obj=0x0
          z_iput-23904 [006] d... 10822.453675: p_zpl_evict_inode_0: 
(zpl_evict_inode+0x0/0x60 [zfs]) inode=0xffff88011aa963d0
          z_iput-23904 [006] d... 10822.453676: p_zfs_inactive_0: 
(zfs_inactive+0x0/0x270 [zfs]) inode=0xffff88011aa963d0
          z_iput-23904 [006] d... 10822.453677: p_zfs_zinactive_0: 
(zfs_zinactive+0x0/0xe0 [zfs]) znode=0xffff88011aa961c0 obj=0xb
          z_iput-23904 [006] d... 10822.453679: p_zfs_rmnode_0: 
(zfs_rmnode+0x0/0x360 [zfs]) znode=0xffff88011aa961c0
          z_iput-23904 [006] d... 10822.453681: p_zfs_purgedir_0: 
(zfs_purgedir+0x0/0x230 [zfs]) znode=0xffff88011aa961c0
          z_iput-23904 [006] d... 10822.453686: p_zfs_zget_0: 
(zfs_zget+0x0/0x230 [zfs]) zsb=0xffff880016f00000 obj=0xc
          z_iput-23904 [006] d... 10822.453690: r_zfs_zget_0: 
(zfs_purgedir+0xb4/0x230 [zfs] <- zfs_zget)
          z_iput-23904 [006] d... 10822.453713: p_zfs_iput_async_0: 
(zfs_iput_async+0x0/0x60 [zfs]) inode=0xffff88011aa90650 obj=0x0
          z_iput-23904 [006] d... 10822.453719: r_zfs_purgedir_0: 
(zfs_rmnode+0x272/0x360 [zfs] <- zfs_purgedir)
          z_iput-23904 [006] d... 10822.453755: p_zpl_evict_inode_0: 
(zpl_evict_inode+0x0/0x60 [zfs]) inode=0xffff88011aa90650
          z_iput-23904 [006] d... 10822.453756: p_zfs_inactive_0: 
(zfs_inactive+0x0/0x270 [zfs]) inode=0xffff88011aa90650
          z_iput-23904 [006] d... 10822.453757: p_zfs_zinactive_0: 
(zfs_zinactive+0x0/0xe0 [zfs]) znode=0xffff88011aa90440 obj=0xc
          z_iput-23904 [006] d... 10822.453759: p_zfs_rmnode_0: 
(zfs_rmnode+0x0/0x360 [zfs]) znode=0xffff88011aa90440

$ echo 2 | sudo tee /proc/sys/vm/drop_caches
2
           <...>-23945 [005] d... 10836.555639: p_dispose_list_0: 
(dispose_list+0x0/0x50)
           <...>-23945 [005] d... 10836.555775: p_dispose_list_0: 
(dispose_list+0x0/0x50)
           <...>-23945 [005] d... 10836.560865: p_dispose_list_0: 
(dispose_list+0x0/0x50)
           <...>-23945 [005] d... 10836.560993: p_dispose_list_0: 
(dispose_list+0x0/0x50)
           <...>-23945 [005] d... 10836.567297: p_dispose_list_0: 
(dispose_list+0x0/0x50)
           <...>-23945 [005] d... 10836.567371: 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:
  Invalid
Status in zfs-linux source package in Xenial:
  In Progress
Status in zfs-linux source package in Bionic:
  Invalid
Status in zfs-linux source package in Disco:
  Invalid
Status in zfs-linux source package in Eoan:
  Invalid

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.

   * 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.

   * 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.

  [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.

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