[PATCH -V3 0/5] swap: cleanup get/put_swap_device() usage
From: Huang Ying
Date: Mon May 29 2023 - 02:14:21 EST
The general rule to use a swap entry is as follows.
When we get a swap entry, if there aren't some other ways to prevent
swapoff, such as the folio in swap cache is locked, page table lock is
held, etc., the swap entry may become invalid because of swapoff.
Then, we need to enclose all swap related functions with
get_swap_device() and put_swap_device(), unless the swap functions
call get/put_swap_device() by themselves.
Based on the above rule, all get/put_swap_device() usage are checked
and cleaned up if necessary.
Changelogs:
V3:
- Fix build error in [2/5], Thanks David!
- Fix comments and patch description about the folio in swap cache, Thanks David!
- Collected reviewed-by.
V2:
- Split patch per David's comments. Thanks!
Best Regards,
Huang, Ying