swap: fix races exposed by swap discard