Prior to this patch, we allocated swap as we were writing the image.This patch changes things so that we instead allocate all the swapwe'll need prior to starting to write the image. It lays groundworkfor later patches that switch from doing I/O in batches.