Cavity cooling of a mechanical resonator in the presence of two-level-system defects