[PATCH] md: Factor out part of raid1d into a separate function