aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-bufio.c
diff options
context:
space:
mode:
authorMikulas Patocka <mpatocka@redhat.com>2012-10-12 11:59:46 -0400
committerAlasdair G Kergon <agk@redhat.com>2012-10-12 11:59:46 -0400
commitfe5fe90639b62a75349dd1f1c74c4a984397171c (patch)
tree50332fca2fb4ff5851c4e1bfd8151d41ba83d781 /drivers/md/dm-bufio.c
parent54499afbb80e44ae5511984486b4b33d6229fceb (diff)
dm: use ACCESS_ONCE for sysfs values
Use the ACCESS_ONCE macro in dm-bufio and dm-verity where a variable can be modified asynchronously (through sysfs) and we want to prevent compiler optimizations that assume that the variable hasn't changed. (See Documentation/atomic_ops.txt.) Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers/md/dm-bufio.c')
-rw-r--r--drivers/md/dm-bufio.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c
index b9e006aa6062..651ca79881dd 100644
--- a/drivers/md/dm-bufio.c
+++ b/drivers/md/dm-bufio.c
@@ -280,9 +280,7 @@ static void __cache_size_refresh(void)
280 BUG_ON(!mutex_is_locked(&dm_bufio_clients_lock)); 280 BUG_ON(!mutex_is_locked(&dm_bufio_clients_lock));
281 BUG_ON(dm_bufio_client_count < 0); 281 BUG_ON(dm_bufio_client_count < 0);
282 282
283 dm_bufio_cache_size_latch = dm_bufio_cache_size; 283 dm_bufio_cache_size_latch = ACCESS_ONCE(dm_bufio_cache_size);
284
285 barrier();
286 284
287 /* 285 /*
288 * Use default if set to 0 and report the actual cache size used. 286 * Use default if set to 0 and report the actual cache size used.
@@ -812,7 +810,7 @@ static void __get_memory_limit(struct dm_bufio_client *c,
812{ 810{
813 unsigned long buffers; 811 unsigned long buffers;
814 812
815 if (dm_bufio_cache_size != dm_bufio_cache_size_latch) { 813 if (ACCESS_ONCE(dm_bufio_cache_size) != dm_bufio_cache_size_latch) {
816 mutex_lock(&dm_bufio_clients_lock); 814 mutex_lock(&dm_bufio_clients_lock);
817 __cache_size_refresh(); 815 __cache_size_refresh();
818 mutex_unlock(&dm_bufio_clients_lock); 816 mutex_unlock(&dm_bufio_clients_lock);
@@ -1590,11 +1588,9 @@ EXPORT_SYMBOL_GPL(dm_bufio_client_destroy);
1590 1588
1591static void cleanup_old_buffers(void) 1589static void cleanup_old_buffers(void)
1592{ 1590{
1593 unsigned long max_age = dm_bufio_max_age; 1591 unsigned long max_age = ACCESS_ONCE(dm_bufio_max_age);
1594 struct dm_bufio_client *c; 1592 struct dm_bufio_client *c;
1595 1593
1596 barrier();
1597
1598 if (max_age > ULONG_MAX / HZ) 1594 if (max_age > ULONG_MAX / HZ)
1599 max_age = ULONG_MAX / HZ; 1595 max_age = ULONG_MAX / HZ;
1600 1596