freebsd-dev/sys/gnu/fs/xfs
Konstantin Belousov c1d8b5e82c Fix two issues with bufdaemon, often causing the processes to hang in
the "nbufkv" sleep.

First, ffs background cg group block write requests a new buffer for
the shadow copy. When ffs_bufwrite() is called from the bufdaemon due
to buffers shortage, requesting the buffer deadlock bufdaemon.
Introduce a new flag for getnewbuf(), GB_NOWAIT_BD, to request getblk
to not block while allocating the buffer, and return failure
instead. Add a flag argument to the geteblk to allow to pass the flags
to getblk(). Do not repeat the getnewbuf() call from geteblk if buffer
allocation failed and either GB_NOWAIT_BD is specified, or geteblk()
is called from bufdaemon (or its helper, see below). In
ffs_bufwrite(), fall back to synchronous cg block write if shadow
block allocation failed.

Since r107847, buffer write assumes that vnode owning the buffer is
locked. The second problem is that buffer cache may accumulate many
buffers belonging to limited number of vnodes. With such workload,
quite often threads that own the mentioned vnodes locks are trying to
read another block from the vnodes, and, due to buffer cache
exhaustion, are asking bufdaemon for help. Bufdaemon is unable to make
any substantial progress because the vnodes are locked.

Allow the threads owning vnode locks to help the bufdaemon by doing
the flush pass over the buffer cache before getnewbuf() is going to
uninterruptible sleep. Move the flushing code from buf_daemon() to new
helper function buf_do_flush(), that is called from getnewbuf().  The
number of buffers flushed by single call to buf_do_flush() from
getnewbuf() is limited by new sysctl vfs.flushbufqtarget.  Prevent
recursive calls to buf_do_flush() by marking the bufdaemon and threads
that temporarily help bufdaemon by TDP_BUFNEED flag.

In collaboration with:	pho
Reviewed by:	 tegge (previous version)
Tested by:	 glebius, yandex ...
MFC after:	 3 weeks
2009-03-16 15:39:46 +00:00
..
FreeBSD Fix two issues with bufdaemon, often causing the processes to hang in 2009-03-16 15:39:46 +00:00
xfs_acl.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_acl.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_ag.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_alloc_btree.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_alloc_btree.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_alloc.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_alloc.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_arch.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_attr_leaf.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_attr_leaf.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_attr_sf.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_attr.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_attr.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_behavior.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_behavior.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_bit.c Bow to incomplete GCC 4. constant propagation optimizations and 2007-05-30 03:03:06 +00:00
xfs_bit.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_bmap_btree.c Bow to incomplete GCC 4. constant propagation optimizations and 2007-05-30 03:03:06 +00:00
xfs_bmap_btree.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_bmap.c Bow to incomplete GCC 4. constant propagation optimizations and 2007-05-30 03:03:06 +00:00
xfs_bmap.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_btree.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_btree.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_buf_item.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_buf_item.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_cap.c
xfs_cap.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_clnt.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_da_btree.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_da_btree.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_dfrag.c Adapt to accmode_t changes. 2008-11-14 09:58:16 +00:00
xfs_dfrag.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_dinode.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_dir2_block.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_dir2_block.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_dir2_data.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_dir2_data.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_dir2_leaf.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_dir2_leaf.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_dir2_node.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_dir2_node.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_dir2_sf.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_dir2_sf.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_dir2_trace.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_dir2_trace.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_dir2.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_dir2.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_dir_leaf.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_dir_leaf.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_dir_sf.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_dir.c Bow to incomplete GCC 4. constant propagation optimizations and 2007-05-30 03:03:06 +00:00
xfs_dir.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_dmapi.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_dmops.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_error.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_error.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_extfree_item.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_extfree_item.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_fs.h Change %llx to %jx in printf() to eliminate warnings on 64-bit platforms. 2006-06-09 06:57:00 +00:00
xfs_fsops.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_fsops.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_ialloc_btree.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_ialloc_btree.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_ialloc.c Bow to incomplete GCC 4. constant propagation optimizations and 2007-05-30 03:03:06 +00:00
xfs_ialloc.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_iget.c More changes due to latest XFS import. 2006-06-09 06:07:42 +00:00
xfs_imap.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_inode_item.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_inode_item.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_inode.c Adapt to accmode_t changes. 2008-11-14 09:58:16 +00:00
xfs_inode.h Adapt to accmode_t changes. 2008-11-14 09:58:16 +00:00
xfs_inum.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_iocore.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_iomap.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_iomap.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_itable.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_itable.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_log_priv.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_log_recover.c Bow to incomplete GCC 4. constant propagation optimizations and 2007-05-30 03:03:06 +00:00
xfs_log_recover.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_log.c Bow to incomplete GCC 4. constant propagation optimizations and 2007-05-30 03:03:06 +00:00
xfs_log.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_mac.c
xfs_mac.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_mount.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_mount.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_qmops.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_quota.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_refcache.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_refcache.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_rename.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_rtalloc.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_rtalloc.h Bow to incomplete GCC 4. constant propagation optimizations and 2007-05-30 03:03:06 +00:00
xfs_rw.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_rw.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_sb.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_trans_ail.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_trans_buf.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_trans_extfree.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_trans_inode.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_trans_item.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_trans_priv.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_trans_space.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_trans.c Remove debugging printf 2006-06-11 00:19:00 +00:00
xfs_trans.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_types.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_utils.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_utils.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_vfsops.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfs_vnodeops.c Adapt to accmode_t changes. 2008-11-14 09:58:16 +00:00
xfs.h Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00
xfsidbg.c Sync XFS for FreeBSD tree with newer changes from SGI XFS for Linux tree. 2006-06-09 06:04:06 +00:00