:Can't you have a race condition here where you decide that you
:have enough space, and by the time you've deallocated half of the
:swapfile that's no longer the case? It seems like the correct
:thing to do in that case is abort the system call (which could be
:painful). Perhaps the best thing to do in this case is wait for
:vm_pageout_scan to kill a few pigs.
I wouldn't worry about it. Nobody turns off swap on a running system
at a whim. It just needs to prevent stupid mistakes like trying to
remove a swap device without having adequate memory + other swap to
take care of the data.