Valuation ideals and primary w-ideals