We proposed and demonstrated a novel, simple, and low cost method for all-optical clock recovery based on the switching between two injection-locked longitudinal modes in a dc-biased multi-quantum-well Fabry-Perot laser diode (FP-LD). The dc biased FP-LD is simultaneously injection-locked by a return-to-zero data signal at one of the longitudinal modes of the FP-LD and self-seeded at another longitudinal mode by using a uniform fiber Bragg grating as a feedback component. The powers and detunes of the data signal and self-seeding signal are chosen such that self-seeding is realized in the FP-LD only when data signal power is low. Clock signals of data streams at different data rates can be obtained by tuning the optical delay line in the external self-seeding loop. We have demonstrated all-optical clock recovery at 10 GHz. The pulse width, time-bandwidth product, side mode suppression ration, root mean square timing jitter, and average power of the recovered clock signals are 50 ps, 0.5, 50 dB, 248 fs, and 3.6 dBm, respectively. Clock recovery is possible at wavelength within the gain band of the FP-LD. We also find and explore in the experiment the influence of detune between the external data signal and the nearest FP-LD longitudinal mode to the recovered clock.