  Context. The chemistry of the diffuse interstellar medium rests upon three
pillars: exothermic ion-neutral reactions (" cold chemistry "), endothermic
neutral-neutral reactions with significant activation barriers (" warm
chemistry "), and reactions on the surfaces of dust grains. While warm
chemistry becomes important in the shocks associated with turbulent dissipation
regions, the main path for the formation of interstellar OH and H2O is that of
cold chemistry. Aims. The aim of this study is to observationally confirm the
association of atomic oxygen with both atomic and molecular gas phases, and to
understand the measured abundances of OH and OH + as a function of the
available reservoir of H2. Methods. We obtained absorption spectra of the
ground states of OH, OH+ and OI with high-velocity resolution, with GREAT
on-board SOFIA, and with the THz receiver at the APEX. We analyzed them along
with ancillary spectra of HF and CH from HIFI. To deconvolve them from the
hyperfine structure and to separate the blend that is due to various velocity
components on the sightline, we fit model spectra consisting of an appropriate
number of Gaussian profiles using a method combining simulated annealing with
downhill simplex minimization. Together with HF and/or CH as a surrogate for
H2, and HI $\lambda$21 cm data, the molecular hydrogen fraction f^N\_H2 = N(H
2)/(N(H) + 2N(H 2)) can be determined. We then investigated abundance ratios as
a function of f^N\_H2. Results. The column density of OI is correlated at a
high significance with the amount of available molecular and atomic hydrogen,
with an atomic oxygen abundance of $3 \times 10 ^{-4}$ relative to H nuclei.
While the velocities of the absorption features of OH and OH+ are loosely
correlated and reflect the spiral arm crossings on the sightline, upon closer
inspection they display an anticorrespondence. The arm-to-interarm density
contrast is found to be higher in OH than in OH+. While both species can
coexist, with a higher abundance in OH than in OH+, the latter is found less
frequently in absence of OH than the other way around, which is a direct
consequence of the rapid destruction of OH+ by dissociative recombination when
not enough H2 is available. This conjecture has been substantiated by a
comparison between the OH/OH+ ratio with f^N\_H2, showing a clear correlation.
The hydrogen abstraction reaction chain OH+ (H2,H) H2O+ (H2,H)H3O+ is confirmed
as the pathway for the production of OH and H 2 O. Our estimate of the
branching ratio of the dissociative recombination of H3O+ to OH and H2O is
confined within the interval of 84 to 91%, which matches laboratory
measurements (74 to 83%). -- A correlation between the linewidths and column
densities of OH+ features is found to be significant with a false-alarm
probability below 5%. Such a correlation is predicted by models of interstellar
MHD turbulence. For OH the same correlation is found to be insignificant
because there are more narrow absorption features. Conclusions. While it is
difficult to assess the contributions of warm neutral-neutral chemistry to the
observed abundances, it seems fair to conclude that the predictions of cold
ion-neutral chemistry match the abundance patterns we observed.
