aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc/array.c
diff options
context:
space:
mode:
authorSergey Senozhatsky <[email protected]>2015-02-12 23:00:39 +0000
committerLinus Torvalds <[email protected]>2015-02-13 02:54:11 +0000
commita096cafc31862c54da0b56c8441dc14023437008 (patch)
treee79e5326429f2c91b180091e114b11ec8f2eaf39 /fs/proc/array.c
parentzram: fix umount-reset_store-mount race condition (diff)
downloadkernel-a096cafc31862c54da0b56c8441dc14023437008.tar.gz
kernel-a096cafc31862c54da0b56c8441dc14023437008.zip
zram: rework reset and destroy path
We need to return set_capacity(disk, 0) from reset_store() back to zram_reset_device(), a catch by Ganesh Mahendran. Potentially, we can race set_capacity() calls from init and reset paths. The problem is that zram_reset_device() is also getting called from zram_exit(), which performs operations in misleading reversed order -- we first create_device() and then init it, while zram_exit() perform destroy_device() first and then does zram_reset_device(). This is done to remove sysfs group before we reset device, so we can continue with device reset/destruction not being raced by sysfs attr write (f.e. disksize). Apart from that, destroy_device() releases zram->disk (but we still have ->disk pointer), so we cannot acces zram->disk in later zram_reset_device() call, which may cause additional errors in the future. So, this patch rework and cleanup destroy path. 1) remove several unneeded goto labels in zram_init() 2) factor out zram_init() error path and zram_exit() into destroy_devices() function, which takes the number of devices to destroy as its argument. 3) remove sysfs group in destroy_devices() first, so we can reorder operations -- reset device (as expected) goes before disk destroy and queue cleanup. So we can always access ->disk in zram_reset_device(). 4) and, finally, return set_capacity() back under ->init_lock. [[email protected]: tweak comment] Signed-off-by: Sergey Senozhatsky <[email protected]> Reported-by: Ganesh Mahendran <[email protected]> Cc: Minchan Kim <[email protected]> Cc: Jerome Marchand <[email protected]> Cc: Nitin Gupta <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
Diffstat (limited to 'fs/proc/array.c')
0 files changed, 0 insertions, 0 deletions