Some ZFS locks and their purposes


z_teardown_lock is used to suspend all filesystem operations during forceful unmount and during rollback (receive -F being another subcase of it). z_teardown_lock is a special read-write lock that allows recursive readers while not starving writers. z_teardown_lock doesn't allow recursive writers or mixing read and write acquisitions. It doesn't provide for lock upgrade/downgrade either.

All ZFS vnops (except one) and vfsops take z_teardown_lock as a a reader. Only special management code takes it as a writer.


z_teardown_inactive_lock is intended to allow vnode reclamation/destruction while all other vnode operations are suspended. Solaris zfs_inactive takes z_teardown_inactive_lock (as opposed to z_teardown_lock for all other vnops) as a reader. The ZFS management code may take z_teardown_lock to suspend all normal fs operations and it still can do manipulations that may lead to VOP_INACTIVE without running into any locking issues. For example, Solaris code calls dnlc_purge_vfsp (a cumulative effect of which is similar to that of FreeBSD vflush) while holding z_teardown_lock.

z_teardown_inactive_lock is always taken after z_teardown_lock. Their combined effect is to suspend all fs operations including zfs_inactive.

z_hold_mtx / ZFS_OBJ_MUTEX / ZFS_OBJ_HOLD_*

This pool of mutexes protects concurrent creation / deletion and lookup of znodes by object id.


AndriyGapon/AvgZfsLocks (last edited 2018-03-12 02:54:32 by MarkLinimon)