diff options
author | Jerome Marchand <jmarchan@redhat.com> | 2012-05-14 11:46:34 -0500 |
---|---|---|
committer | Simon Shields <keepcalm444@gmail.com> | 2016-06-12 21:19:24 +1000 |
commit | 828121d02455e8c6c4574a7ff4d9ac8f803dcc17 (patch) | |
tree | ab47c9e3f5aaf0dde5c175eeafee06cd438b2934 /drivers/staging/zram/zram_drv.h | |
parent | f526a35a01423d3760e773604b763e8a7aeeb6c1 (diff) | |
download | kernel_samsung_smdk4412-828121d02455e8c6c4574a7ff4d9ac8f803dcc17.zip kernel_samsung_smdk4412-828121d02455e8c6c4574a7ff4d9ac8f803dcc17.tar.gz kernel_samsung_smdk4412-828121d02455e8c6c4574a7ff4d9ac8f803dcc17.tar.bz2 |
staging: zram: fix zram locking
Currently init_lock only prevents concurrent execution of zram_init_device()
and zram_reset_device() but not zram_make_request() nor sysfs store functions.
This patch changes init_lock into a rw_semaphore. A write lock is taken by
init, reset and store functions, a read lock is taken by zram_make_request().
Also, avoids to release the lock before calling __zram_reset_device() for
cleaning after a failed init, thus preventing any concurrent task to see an
inconsistent state of zram.
Change-Id: Ia74662a6d25ed280438a7c726005c17ebd3f7ff9
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Jason Hrycay <jason.hrycay@motorola.com>
Reviewed-on: http://gerrit.pcs.mot.com/414993
Tested-by: Jira Key <JIRAKEY@motorola.com>
Reviewed-by: Christopher Fries <C.Fries@motorola.com>
Reviewed-by: Neil Patel <NPATEL@motorola.com>
Reviewed-by: David Ding <dding@motorola.com>
Diffstat (limited to 'drivers/staging/zram/zram_drv.h')
-rw-r--r-- | drivers/staging/zram/zram_drv.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/staging/zram/zram_drv.h b/drivers/staging/zram/zram_drv.h index 1db8f19..f8e2654 100644 --- a/drivers/staging/zram/zram_drv.h +++ b/drivers/staging/zram/zram_drv.h @@ -109,8 +109,8 @@ struct zram { struct request_queue *queue; struct gendisk *disk; int init_done; - /* Prevent concurrent execution of device init and reset */ - struct mutex init_lock; + /* Prevent concurrent execution of device init, reset and R/W request */ + struct rw_semaphore init_lock; /* * This is the limit on amount of *uncompressed* worth of data * we can store in a disk. @@ -127,6 +127,6 @@ extern struct attribute_group zram_disk_attr_group; #endif extern int zram_init_device(struct zram *zram); -extern void zram_reset_device(struct zram *zram); +extern void __zram_reset_device(struct zram *zram); #endif |