mbox series

[-V3,0/5] swap: cleanup get/put_swap_device() usage

Message ID 20230529061355.125791-1-ying.huang@intel.com (mailing list archive)
Headers show
Series swap: cleanup get/put_swap_device() usage | expand

Message

Huang, Ying May 29, 2023, 6:13 a.m. UTC
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