_nfs4_pnfs_v3/v4_ds_connect do
   some work
   smp_wmb
   ds->ds_clp = clp;
And nfs4_ff_layout_prepare_ds currently does
   smp_rmb
   if(ds->ds_clp)
      ...
This patch places the smp_rmb after the if. This ensures that following
reads only happen once nfs4_ff_layout_prepare_ds has checked that data
has been properly initialized.
Fixes: d67ae825a59d6 ("pnfs/flexfiles: Add the FlexFile Layout Driver")
Signed-off-by: Baptiste Lepers <baptiste.lepers@gmail.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
                goto noconnect;
 
        ds = mirror->mirror_ds->ds;
+       if (READ_ONCE(ds->ds_clp))
+               goto out;
        /* matching smp_wmb() in _nfs4_pnfs_v3/4_ds_connect */
        smp_rmb();
-       if (ds->ds_clp)
-               goto out;
 
        /* FIXME: For now we assume the server sent only one version of NFS
         * to use for the DS.
 
        }
 
        smp_wmb();
-       ds->ds_clp = clp;
+       WRITE_ONCE(ds->ds_clp, clp);
        dprintk("%s [new] addr: %s\n", __func__, ds->ds_remotestr);
 out:
        return status;
        }
 
        smp_wmb();
-       ds->ds_clp = clp;
+       WRITE_ONCE(ds->ds_clp, clp);
        dprintk("%s [new] addr: %s\n", __func__, ds->ds_remotestr);
 out:
        return status;