lkml.org 
[lkml]   [2016]   [Jun]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] zram: use writer semaphores in device attributes store
Date
Since the device attributes store provides write access. This patch uses
down_write()/up_write() instead of down_read()/up_read() in
mem_used_max_store() and compact_store().

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
drivers/block/zram/zram_drv.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 7454cf1..cfed743 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -293,13 +293,13 @@ static ssize_t mem_used_max_store(struct device *dev,
if (err || val != 0)
return -EINVAL;

- down_read(&zram->init_lock);
+ down_write(&zram->init_lock);
if (init_done(zram)) {
struct zram_meta *meta = zram->meta;
atomic_long_set(&zram->stats.max_used_pages,
zs_get_total_pages(meta->mem_pool));
}
- up_read(&zram->init_lock);
+ up_write(&zram->init_lock);

return len;
}
@@ -372,15 +372,15 @@ static ssize_t compact_store(struct device *dev,
struct zram *zram = dev_to_zram(dev);
struct zram_meta *meta;

- down_read(&zram->init_lock);
+ down_write(&zram->init_lock);
if (!init_done(zram)) {
- up_read(&zram->init_lock);
+ up_write(&zram->init_lock);
return -EINVAL;
}

meta = zram->meta;
zs_compact(meta->mem_pool);
- up_read(&zram->init_lock);
+ up_write(&zram->init_lock);

return len;
}
--
1.9.1
\
 
 \ /
  Last update: 2016-06-17 06:21    [W:0.038 / U:1.228 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site