dm-bufio & dm-verity: use ACCESS_ONCE instead of volatile
Hi
This is a simple cleanup patch.
Mikulas
---
dm-bufio & dm-verity: use ACCESS_ONCE instead of volatile
If the variable can be asynchronously modified and we want to prevent
compiler optimizations that could assume that the variable is the same,
use ACCESS_ONCE macro, as documented in Documentation/atomic_ops.txt.
/*
* Use default if set to 0 and report the actual cache size used.
@@ -811,7 +811,7 @@ static void __get_memory_limit(struct dm
{
unsigned long buffers;
- if (*(volatile unsigned long *)&dm_bufio_cache_size != dm_bufio_cache_size_latch) {
+ if (ACCESS_ONCE(dm_bufio_cache_size) != dm_bufio_cache_size_latch) {
mutex_lock(&dm_bufio_clients_lock);
__cache_size_refresh();
mutex_unlock(&dm_bufio_clients_lock);
@@ -1589,7 +1589,7 @@ EXPORT_SYMBOL_GPL(dm_bufio_client_destro
cluster >>= v->data_dev_block_bits;
if (unlikely(!cluster))
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
09-17-2012, 07:21 PM
Mikulas Patocka
dm-bufio & dm-verity: use ACCESS_ONCE instead of volatile
dm-bufio & dm-verity: use ACCESS_ONCE instead of volatile
If the variable can be asynchronously modified and we want to prevent
compiler optimizations that could assume that the variable is the same,
use ACCESS_ONCE macro, as documented in Documentation/atomic_ops.txt.
/*
* Use default if set to 0 and report the actual cache size used.
@@ -813,7 +811,7 @@ static void __get_memory_limit(struct dm
{
unsigned long buffers;
- if (dm_bufio_cache_size != dm_bufio_cache_size_latch) {
+ if (ACCESS_ONCE(dm_bufio_cache_size) != dm_bufio_cache_size_latch) {
mutex_lock(&dm_bufio_clients_lock);
__cache_size_refresh();
mutex_unlock(&dm_bufio_clients_lock);
@@ -1591,11 +1589,9 @@ EXPORT_SYMBOL_GPL(dm_bufio_client_destro
static void cleanup_old_buffers(void)
{
- unsigned long max_age = dm_bufio_max_age;
+ unsigned long max_age = ACCESS_ONCE(dm_bufio_max_age);
struct dm_bufio_client *c;