I don't know if this code path needs to be optimized but your effectively blocking usedSpace here... I would do this in parallel.