A disk drive having a head and a recording surface, wherein the recording surface includes a track having a user data segment and a periodic reference segment, wherein the head flies above the recording surface at a fly height that varies as the head flies, wherein during a write operation the head writes data in the user data segment, and wherein during the write operation the head produces a reference signal when reading the periodic reference segment, wherein the disk drive comprises:
- integrator means, responsive to the reference signal, for integrating the reference signal to generate an area signal;
- peak detector means for detecting a peak in the reference signal to generate a peak signal;
- and
- means, responsive to the area signal and the peak signal, for generating a write condition signal that indicates that writing of data in the user data segment during the write operation is unsafe.