Patch "pnfs/flexfiles: Fix misplaced barrier in nfs4_ff_layout_prepare_ds" has been added to the 4.14-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    pnfs/flexfiles: Fix misplaced barrier in nfs4_ff_layout_prepare_ds

to the 4.14-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     pnfs-flexfiles-fix-misplaced-barrier-in-nfs4_ff_layo.patch
and it can be found in the queue-4.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 8e0f4b65aab2c540b79ba389e8e014458ca202a0
Author: Baptiste Lepers <baptiste.lepers@xxxxxxxxx>
Date:   Mon Sep 6 11:59:24 2021 +1000

    pnfs/flexfiles: Fix misplaced barrier in nfs4_ff_layout_prepare_ds
    
    [ 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@xxxxxxxxx>
    Signed-off-by: Trond Myklebust <trond.myklebust@xxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/nfs/flexfilelayout/flexfilelayoutdev.c b/fs/nfs/flexfilelayout/flexfilelayoutdev.c
index 2464b9b806988..17dee8fd9834f 100644
--- a/fs/nfs/flexfilelayout/flexfilelayoutdev.c
+++ b/fs/nfs/flexfilelayout/flexfilelayoutdev.c
@@ -428,10 +428,10 @@ nfs4_ff_layout_prepare_ds(struct pnfs_layout_segment *lseg, u32 ds_idx,
 		goto out_fail;
 
 	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.
diff --git a/fs/nfs/pnfs_nfs.c b/fs/nfs/pnfs_nfs.c
index 29bdf1525d82b..5d7a69ffaaa29 100644
--- a/fs/nfs/pnfs_nfs.c
+++ b/fs/nfs/pnfs_nfs.c
@@ -635,7 +635,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;
@@ -708,7 +708,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;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux