summaryrefslogtreecommitdiff
path: root/fs/super.c
diff options
context:
space:
mode:
authorMinchan Kim <minchan@kernel.org>2013-08-12 06:13:56 (GMT)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-08-12 22:25:00 (GMT)
commita0c516cbfc7452c8cbd564525fef66d9f20b46d1 (patch)
tree089d5d22a2ba534707b6b47eb9015158e323e7e5 /fs/super.c
parent2b86ab9cc29fcd435cde9378c3b9ffe8b5c76128 (diff)
downloadlinux-fsl-qoriq-a0c516cbfc7452c8cbd564525fef66d9f20b46d1.tar.xz
zram: don't grab mutex in zram_slot_free_noity
[1] introduced down_write in zram_slot_free_notify to prevent race between zram_slot_free_notify and zram_bvec_[read|write]. The race could happen if somebody who has right permission to open swap device is reading swap device while it is used by swap in parallel. However, zram_slot_free_notify is called with holding spin_lock of swap layer so we shouldn't avoid holing mutex. Otherwise, lockdep warns it. This patch adds new list to handle free slot and workqueue so zram_slot_free_notify just registers slot index to be freed and registers the request to workqueue. If workqueue is expired, it holds mutex_lock so there is no problem any more. If any I/O is issued, zram handles pending slot-free request caused by zram_slot_free_notify right before handling issued request because workqueue wouldn't be expired yet so zram I/O request handling function can miss it. Lastly, when zram is reset, flush_work could handle all of pending free request so we shouldn't have memory leak. NOTE: If zram_slot_free_notify's kmalloc with GFP_ATOMIC would be failed, the slot will be freed when next write I/O write the slot. [1] [57ab0485, zram: use zram->lock to protect zram_free_page() in swap free notify path] * from v2 * refactoring * from v1 * totally redesign Cc: Nitin Gupta <ngupta@vflare.org> Cc: Jiang Liu <jiang.liu@huawei.com> Cc: stable@vger.kernel.org Signed-off-by: Minchan Kim <minchan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/super.c')
0 files changed, 0 insertions, 0 deletions