mm/gup.c: reorganize try_get_folio()
authorVishal Moola (Oracle) <vishal.moola@gmail.com>
Wed, 14 Jun 2023 02:13:11 +0000 (19:13 -0700)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 19 Jun 2023 23:19:34 +0000 (16:19 -0700)
commit503670ee6d0670e114a66b8cf2bcd3f71f53c2f7
tree082357361aabab6ca2012215da99a8a039206a96
parentc9223a4aede774b0cea2a9944bc5dac48683e802
mm/gup.c: reorganize try_get_folio()

try_get_folio() takes in a page, then chooses to do some folio operations
based on the flags (either FOLL_GET or FOLL_PIN).  We can rewrite this
function to be more purpose oriented.

After calling try_get_folio(), if neither FOLL_GET nor FOLL_PIN are set,
warn and fail.  If FOLL_GET is set we can return the result.  If FOLL_GET
is not set then FOLL_PIN is set, so we pin the folio.

This change assists with folio conversions, and makes the function more
readable.

Link: https://lkml.kernel.org/r/20230614021312.34085-5-vishal.moola@gmail.com
Signed-off-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/gup.c