]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
staging: zram: fix zram locking
authorJerome Marchand <jmarchan@redhat.com>
Tue, 6 Sep 2011 13:02:11 +0000 (15:02 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 6 Sep 2011 23:56:15 +0000 (16:56 -0700)
commit0900beae178a84e653d9088979cf3014babc097e
treec2ddc5d26f4f97e5406fede5cb391ec1296a1e62
parenta1c821ae6c63d9ac648374f4953295e350572d3c
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.

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/zram/zram_drv.c
drivers/staging/zram/zram_drv.h
drivers/staging/zram/zram_sysfs.c