mm: split SWP_FILE into SWP_ACTIVATED and SWP_FS
The SWP_FILE flag serves two purposes: to make swap_{read,write}page() go through the filesystem, and to make swapoff() call ->swap_deactivate(). For Btrfs, we want the latter but not the former, so split this flag into two. This makes us always call ->swap_deactivate() if ->swap_activate() succeeded, not just if it didn't add any swap extents itself. This also resolves the issue of the very misleading name of SWP_FILE, which is only used for swap files over NFS. Link: http://lkml.kernel.org/r/6d63d8668c4287a4f6d203d65696e96f80abdfc7.1536704650.git.osandov@fb.com Signed-off-by: Omar Sandoval <osandov@fb.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Andrew Morton <akpm@linux-foundation.org> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: David Sterba <dsterba@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Цей коміт міститься в:

зафіксовано
Linus Torvalds

джерело
91cbacc345
коміт
bc4ae27d81
@@ -1003,7 +1003,7 @@ start_over:
|
||||
goto nextsi;
|
||||
}
|
||||
if (size == SWAPFILE_CLUSTER) {
|
||||
if (!(si->flags & SWP_FILE))
|
||||
if (!(si->flags & SWP_FS))
|
||||
n_ret = swap_alloc_cluster(si, swp_entries);
|
||||
} else
|
||||
n_ret = scan_swap_map_slots(si, SWAP_HAS_CACHE,
|
||||
@@ -2299,12 +2299,13 @@ static void destroy_swap_extents(struct swap_info_struct *sis)
|
||||
kfree(se);
|
||||
}
|
||||
|
||||
if (sis->flags & SWP_FILE) {
|
||||
if (sis->flags & SWP_ACTIVATED) {
|
||||
struct file *swap_file = sis->swap_file;
|
||||
struct address_space *mapping = swap_file->f_mapping;
|
||||
|
||||
sis->flags &= ~SWP_FILE;
|
||||
mapping->a_ops->swap_deactivate(swap_file);
|
||||
sis->flags &= ~SWP_ACTIVATED;
|
||||
if (mapping->a_ops->swap_deactivate)
|
||||
mapping->a_ops->swap_deactivate(swap_file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2400,8 +2401,10 @@ static int setup_swap_extents(struct swap_info_struct *sis, sector_t *span)
|
||||
|
||||
if (mapping->a_ops->swap_activate) {
|
||||
ret = mapping->a_ops->swap_activate(sis, swap_file, span);
|
||||
if (ret >= 0)
|
||||
sis->flags |= SWP_ACTIVATED;
|
||||
if (!ret) {
|
||||
sis->flags |= SWP_FILE;
|
||||
sis->flags |= SWP_FS;
|
||||
ret = add_swap_extent(sis, 0, sis->max, 0);
|
||||
*span = sis->pages;
|
||||
}
|
||||
|
Посилання в новій задачі
Заблокувати користувача