]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
pnfs/flexfiles: Fix misplaced barrier in nfs4_ff_layout_prepare_ds
authorBaptiste Lepers <baptiste.lepers@gmail.com>
Mon, 6 Sep 2021 01:59:24 +0000 (11:59 +1000)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Thu, 13 Jan 2022 17:42:35 +0000 (18:42 +0100)
BugLink: https://bugs.launchpad.net/bugs/1953387
[ Upstream commit a2915fa06227b056a8f9b0d79b61dca08ad5cfc6 ]

_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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
fs/nfs/flexfilelayout/flexfilelayoutdev.c
fs/nfs/pnfs_nfs.c

index 3eda40a320a53ff40a37262391c2eb75741ca8f4..1f12297109b4186d46f54031606da22e10470527 100644 (file)
@@ -378,10 +378,10 @@ nfs4_ff_layout_prepare_ds(struct pnfs_layout_segment *lseg,
                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.
index 249cf9037dbd7b952f8dfc5788446f2f0e738ca5..aff44a7b98f868c89bdb9e698585f0c6ca3e56fe 100644 (file)
@@ -641,7 +641,7 @@ static int _nfs4_pnfs_v3_ds_connect(struct nfs_server *mds_srv,
        }
 
        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;
@@ -714,7 +714,7 @@ static int _nfs4_pnfs_v4_ds_connect(struct nfs_server *mds_srv,
        }
 
        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;