zfsonlinux/zfs — pull request #883 by behlendorf (2012-08-23 04:41:34+00:00)
Title: zvol swap devices

The patch stack updates the ZFS code to handle ZVOL based swap devices. For example:

$ zfs create -V 2G tank/swap
$ mkswap /dev/zvol/tank/swap
$ swapon /dev/zvol/tank/swap

Filename	Type	Size	Used	Priority
/dev/zvol/tank/swap partition	2097144	1006944	-1

This was accomplished by:

* Reverting all use of PF_MEMALLOC and relying instead of the improve SPL slab behavior.

* Preallocating vdev aggregate I/O buffers.

* Using the PF_NOFS flag to detect all instances of KM_SLEEP in critical I/O paths and changing them to KM_PUSHPAGE.

* Changing one instance of vmem_alloc() to kmem_alloc() in mzap_update() to ensure the gfp flags are honored.

With these changes in place I am now able to execute 10 concurrent instances of `python -c print 2**10**10`. Once the swap device is fully consumed these processes will be cleanly killed by the OOM killer as expected.

The system may appear to hang for 10-15 seconds once it starts swapping heavily but it will improve. This appears to be due to a sudden need for 8k ARC buffer which be quickly allocated. Once those buffers get allocated the system is once again responsive. So while this is a step in the right direction there is still room for improvement.