Barcelona and Lionel Messi have agreed a contract renewal that will keep the Argentine at the Catalan club until June 30, 2021.