Commit 32646315 authored by Gao Xiang's avatar Gao Xiang Committed by Linus Torvalds

swap: rename SWP_FS to SWAP_FS_OPS to avoid ambiguity

SWP_FS is used to make swap_{read,write}page() go through the filesystem,
and it's only used for swap files over NFS for now.  Otherwise it will
directly submit IO to blockdev according to swapfile extents reported by
filesystems in advance.

As Matthew pointed out [1], SWP_FS naming is somewhat confusing, so let's
rename to SWP_FS_OPS.

[1] https://lore.kernel.org/r/20200820113448.GM17456@casper.infradead.orgSuggested-by: default avatarMatthew Wilcox <willy@infradead.org>
Signed-off-by: default avatarGao Xiang <hsiangkao@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Link: https://lkml.kernel.org/r/20200822113019.11319-1-hsiangkao@redhat.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 146608bb
...@@ -170,7 +170,7 @@ enum { ...@@ -170,7 +170,7 @@ enum {
SWP_CONTINUED = (1 << 5), /* swap_map has count continuation */ SWP_CONTINUED = (1 << 5), /* swap_map has count continuation */
SWP_BLKDEV = (1 << 6), /* its a block device */ SWP_BLKDEV = (1 << 6), /* its a block device */
SWP_ACTIVATED = (1 << 7), /* set after swap_activate success */ SWP_ACTIVATED = (1 << 7), /* set after swap_activate success */
SWP_FS = (1 << 8), /* swap file goes through fs */ SWP_FS_OPS = (1 << 8), /* swapfile operations go through fs */
SWP_AREA_DISCARD = (1 << 9), /* single-time swap area discards */ SWP_AREA_DISCARD = (1 << 9), /* single-time swap area discards */
SWP_PAGE_DISCARD = (1 << 10), /* freed swap page-cluster discards */ SWP_PAGE_DISCARD = (1 << 10), /* freed swap page-cluster discards */
SWP_STABLE_WRITES = (1 << 11), /* no overwrite PG_writeback pages */ SWP_STABLE_WRITES = (1 << 11), /* no overwrite PG_writeback pages */
......
...@@ -312,7 +312,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc, ...@@ -312,7 +312,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
struct swap_info_struct *sis = page_swap_info(page); struct swap_info_struct *sis = page_swap_info(page);
VM_BUG_ON_PAGE(!PageSwapCache(page), page); VM_BUG_ON_PAGE(!PageSwapCache(page), page);
if (data_race(sis->flags & SWP_FS)) { if (data_race(sis->flags & SWP_FS_OPS)) {
struct kiocb kiocb; struct kiocb kiocb;
struct file *swap_file = sis->swap_file; struct file *swap_file = sis->swap_file;
struct address_space *mapping = swap_file->f_mapping; struct address_space *mapping = swap_file->f_mapping;
...@@ -403,7 +403,7 @@ int swap_readpage(struct page *page, bool synchronous) ...@@ -403,7 +403,7 @@ int swap_readpage(struct page *page, bool synchronous)
goto out; goto out;
} }
if (data_race(sis->flags & SWP_FS)) { if (data_race(sis->flags & SWP_FS_OPS)) {
struct file *swap_file = sis->swap_file; struct file *swap_file = sis->swap_file;
struct address_space *mapping = swap_file->f_mapping; struct address_space *mapping = swap_file->f_mapping;
...@@ -467,7 +467,7 @@ int swap_set_page_dirty(struct page *page) ...@@ -467,7 +467,7 @@ int swap_set_page_dirty(struct page *page)
{ {
struct swap_info_struct *sis = page_swap_info(page); struct swap_info_struct *sis = page_swap_info(page);
if (data_race(sis->flags & SWP_FS)) { if (data_race(sis->flags & SWP_FS_OPS)) {
struct address_space *mapping = sis->swap_file->f_mapping; struct address_space *mapping = sis->swap_file->f_mapping;
VM_BUG_ON_PAGE(!PageSwapCache(page), page); VM_BUG_ON_PAGE(!PageSwapCache(page), page);
......
...@@ -665,7 +665,7 @@ struct page *swap_cluster_readahead(swp_entry_t entry, gfp_t gfp_mask, ...@@ -665,7 +665,7 @@ struct page *swap_cluster_readahead(swp_entry_t entry, gfp_t gfp_mask,
goto skip; goto skip;
/* Test swap type to make sure the dereference is safe */ /* Test swap type to make sure the dereference is safe */
if (likely(si->flags & (SWP_BLKDEV | SWP_FS))) { if (likely(si->flags & (SWP_BLKDEV | SWP_FS_OPS))) {
struct inode *inode = si->swap_file->f_mapping->host; struct inode *inode = si->swap_file->f_mapping->host;
if (inode_read_congested(inode)) if (inode_read_congested(inode))
goto skip; goto skip;
......
...@@ -2437,7 +2437,7 @@ static int setup_swap_extents(struct swap_info_struct *sis, sector_t *span) ...@@ -2437,7 +2437,7 @@ static int setup_swap_extents(struct swap_info_struct *sis, sector_t *span)
if (ret >= 0) if (ret >= 0)
sis->flags |= SWP_ACTIVATED; sis->flags |= SWP_ACTIVATED;
if (!ret) { if (!ret) {
sis->flags |= SWP_FS; sis->flags |= SWP_FS_OPS;
ret = add_swap_extent(sis, 0, sis->max, 0); ret = add_swap_extent(sis, 0, sis->max, 0);
*span = sis->pages; *span = sis->pages;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment