Ferrofluid dynamics, magnetic relaxation, and irreversible thermodynamics