Add more locking stuff to I/O ops