lookup_export() claims to "Always prefer non-V4ROOT mounts" (meaning
"exports") but actually prefers V4ROOT exports - once it has 'found'
one it will never replace it.
So fix that inversion, and add code so that it proactively prefers a
non-V4ROOT whether it is found before or after a V4ROOT.
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Steve Dickson <steved@redhat.com>
                                found_type = i;
                                continue;
                        }
-
-                       /* Always prefer non-V4ROOT mounts */
-                       if (found->m_export.e_flags & NFSEXP_V4ROOT)
+                       /* Always prefer non-V4ROOT exports */
+                       if (exp->m_export.e_flags & NFSEXP_V4ROOT)
                                continue;
+                       if (found->m_export.e_flags & NFSEXP_V4ROOT) {
+                               found = exp;
+                               found_type = i;
+                               continue;
+                       }
 
                        /* If one is a CROSSMOUNT, then prefer the longest path */
                        if (((found->m_export.e_flags & NFSEXP_CROSSMOUNT) ||