[PATCH] lightnvm: pblk: Add read memory barrier when reading from rb

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

 



READ_ONCE does not imply a read memory barrier in the presence of control
dependencies between two separate memory locations (flags and data). On x86
TSO, reading from the data page might be reordered before the flags read.
See chapter CONTROL DEPENDENCIES in
https://www.kernel.org/doc/Documentation/memory-barriers.txt

Signed-off-by: Heiner Litz <hlitz@xxxxxxxx>
---
 drivers/lightnvm/pblk-rb.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/lightnvm/pblk-rb.c b/drivers/lightnvm/pblk-rb.c
index a81a97e..5f09983 100644
--- a/drivers/lightnvm/pblk-rb.c
+++ b/drivers/lightnvm/pblk-rb.c
@@ -545,6 +545,9 @@ unsigned int pblk_rb_read_to_bio(struct pblk_rb *rb, struct nvm_rq *rqd,
 			goto try;
 		}
 
+		/* Observe control dependency between flags and data read */
+		smp_rmb();
+
 		page = virt_to_page(entry->data);
 		if (!page) {
 			pr_err("pblk: could not allocate write bio page\n");
-- 
2.7.4




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux