Reflow setup_swap_extents so that the flag checking is not conditional on
a swap_activate method.  This is currently a no-op because the swapoff
code still checks the presence of a swap_deactivate method, but it
simplifies adding a new check, and also makes the SWP_ACTIVATED flag
more consistent.

Signed-off-by: Christoph Hellwig <[email protected]>
---
 mm/swapfile.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/mm/swapfile.c b/mm/swapfile.c
index 651c1b59ff9f..1b7fc03612f4 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -2783,25 +2783,24 @@ static int setup_swap_extents(struct swap_info_struct 
*sis,
 {
        struct address_space *mapping = swap_file->f_mapping;
        struct inode *inode = mapping->host;
-       int ret;
+       int ret, error = 0;
 
        if (S_ISBLK(inode->i_mode))
                return add_swap_extent(sis, sis->max, 0);
 
-       if (swap_file->f_op->swap_activate) {
+       if (swap_file->f_op->swap_activate)
                ret = swap_file->f_op->swap_activate(swap_file, sis);
-               if (ret < 0)
-                       return ret;
-               sis->flags |= SWP_ACTIVATED;
-               if ((sis->flags & SWP_FS_OPS) &&
-                   sio_pool_init() != 0) {
-                       destroy_swap_extents(sis, swap_file);
-                       return -ENOMEM;
-               }
+       else
+               ret = generic_swap_activate(swap_file, sis);
+       if (ret < 0)
                return ret;
-       }
 
-       return generic_swap_activate(swap_file, sis);
+       sis->flags |= SWP_ACTIVATED;
+       if (sis->flags & SWP_FS_OPS)
+               error = sio_pool_init();
+       if (error)
+               destroy_swap_extents(sis, swap_file);
+       return error;
 }
 
 static void _enable_swap_info(struct swap_info_struct *si)
-- 
2.53.0



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to