Port 2f203c2bd9d4b8949e79e670e34691d3a2566c47 from upstream.