Up to a fifth of the Amazon rainforest has become a net source of CO2, research suggests.