summaryrefslogtreecommitdiff
path: root/drivers/staging/zram/zram_drv.h
diff options
context:
space:
mode:
authorJerome Marchand <jmarchan@redhat.com>2011-06-10 13:28:49 (GMT)
committerGreg Kroah-Hartman <gregkh@suse.de>2011-07-05 17:07:13 (GMT)
commitc5bde2388e5b77b39db1b615e2deda2c535f6f60 (patch)
tree41ac3693f6dc9ea0f789a81b6d0ca3f4c57516a2 /drivers/staging/zram/zram_drv.h
parent924bd88d703e53d30f393fac6117f8f1bc79aab6 (diff)
downloadlinux-fsl-qoriq-c5bde2388e5b77b39db1b615e2deda2c535f6f60.tar.xz
Staging: zram: Replace mutex lock by a R/W semaphore
Currently, nothing protects zram table from concurrent access. For instance, ZRAM_UNCOMPRESSED bit can be cleared by zram_free_page() called from a concurrent write between the time ZRAM_UNCOMPRESSED has been set and the time it is tested to unmap KM_USER0 in zram_bvec_write(). This ultimately leads to kernel panic. Also, a read request can occurs when the page has been freed by a running write request and before it has been updated, leading to zero filled block being incorrectly read and "Read before write" error message. This patch replace the current mutex by a rw_semaphore. It extends the protection to zram table (currently, only compression buffers are protected) and read requests (currently, only write requests are protected). Signed-off-by: Jerome Marchand <jmarchan@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/zram/zram_drv.h')
-rw-r--r--drivers/staging/zram/zram_drv.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/staging/zram/zram_drv.h b/drivers/staging/zram/zram_drv.h
index 8acf9eb..abe5221 100644
--- a/drivers/staging/zram/zram_drv.h
+++ b/drivers/staging/zram/zram_drv.h
@@ -107,8 +107,8 @@ struct zram {
void *compress_buffer;
struct table *table;
spinlock_t stat64_lock; /* protect 64-bit stats */
- struct mutex lock; /* protect compression buffers against
- * concurrent writes */
+ struct rw_semaphore lock; /* protect compression buffers and table
+ * against concurrent read and writes */
struct request_queue *queue;
struct gendisk *disk;
int init_done;