linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] swap: rename SWP_FS to SWAP_FS_OPS to avoid ambiguity
@ 2020-08-22  9:02 Gao Xiang
  2020-08-22 11:30 ` [PATCH v2 rebased] " Gao Xiang
  0 siblings, 1 reply; 2+ messages in thread
From: Gao Xiang @ 2020-08-22  9:02 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, linux-kernel, Matthew Wilcox, Gao Xiang

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.org
Suggested-by: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
---
A follow-on thread / patch here.

 include/linux/swap.h | 2 +-
 mm/page_io.c         | 6 +++---
 mm/swap_state.c      | 2 +-
 mm/swapfile.c        | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/linux/swap.h b/include/linux/swap.h
index 7eb59bc552a5..51029a5f57be 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -170,7 +170,7 @@ enum {
 	SWP_CONTINUED	= (1 << 5),	/* swap_map has count continuation */
 	SWP_BLKDEV	= (1 << 6),	/* its a block device */
 	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_PAGE_DISCARD = (1 << 10),	/* freed swap page-cluster discards */
 	SWP_STABLE_WRITES = (1 << 11),	/* no overwrite PG_writeback pages */
diff --git a/mm/page_io.c b/mm/page_io.c
index 9e362567d454..72e0b5a5a41f 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -302,7 +302,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
 	struct swap_info_struct *sis = page_swap_info(page);
 
 	VM_BUG_ON_PAGE(!PageSwapCache(page), page);
-	if (sis->flags & SWP_FS) {
+	if (sis->flags & SWP_FS_OPS) {
 		struct kiocb kiocb;
 		struct file *swap_file = sis->swap_file;
 		struct address_space *mapping = swap_file->f_mapping;
@@ -393,7 +393,7 @@ int swap_readpage(struct page *page, bool synchronous)
 		goto out;
 	}
 
-	if (sis->flags & SWP_FS) {
+	if (sis->flags & SWP_FS_OPS) {
 		struct file *swap_file = sis->swap_file;
 		struct address_space *mapping = swap_file->f_mapping;
 
@@ -455,7 +455,7 @@ int swap_set_page_dirty(struct page *page)
 {
 	struct swap_info_struct *sis = page_swap_info(page);
 
-	if (sis->flags & SWP_FS) {
+	if (sis->flags & SWP_FS_OPS) {
 		struct address_space *mapping = sis->swap_file->f_mapping;
 
 		VM_BUG_ON_PAGE(!PageSwapCache(page), page);
diff --git a/mm/swap_state.c b/mm/swap_state.c
index e82f4f8b1f63..135a5d9fad5d 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -573,7 +573,7 @@ struct page *swap_cluster_readahead(swp_entry_t entry, gfp_t gfp_mask,
 		goto skip;
 
 	/* 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;
 		if (inode_read_congested(inode))
 			goto skip;
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 2937daf3ca02..75681682bec8 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -2426,7 +2426,7 @@ static int setup_swap_extents(struct swap_info_struct *sis, sector_t *span)
 		if (ret >= 0)
 			sis->flags |= SWP_ACTIVATED;
 		if (!ret) {
-			sis->flags |= SWP_FS;
+			sis->flags |= SWP_FS_OPS;
 			ret = add_swap_extent(sis, 0, sis->max, 0);
 			*span = sis->pages;
 		}
-- 
2.18.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH v2 rebased] swap: rename SWP_FS to SWAP_FS_OPS to avoid ambiguity
  2020-08-22  9:02 [PATCH] swap: rename SWP_FS to SWAP_FS_OPS to avoid ambiguity Gao Xiang
@ 2020-08-22 11:30 ` Gao Xiang
  0 siblings, 0 replies; 2+ messages in thread
From: Gao Xiang @ 2020-08-22 11:30 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, linux-kernel, Matthew Wilcox, Gao Xiang

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.org
Suggested-by: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
---
v2: resolve conflicts with recent merged:
commit 7b37e22675df ("mm/page_io: mark various intentional data races")

 include/linux/swap.h | 2 +-
 mm/page_io.c         | 6 +++---
 mm/swap_state.c      | 2 +-
 mm/swapfile.c        | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/linux/swap.h b/include/linux/swap.h
index 661046994db4..df7ce24bbd8f 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -170,7 +170,7 @@ enum {
 	SWP_CONTINUED	= (1 << 5),	/* swap_map has count continuation */
 	SWP_BLKDEV	= (1 << 6),	/* its a block device */
 	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_PAGE_DISCARD = (1 << 10),	/* freed swap page-cluster discards */
 	SWP_STABLE_WRITES = (1 << 11),	/* no overwrite PG_writeback pages */
diff --git a/mm/page_io.c b/mm/page_io.c
index e485a6e8a6cd..dc6de6962612 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -302,7 +302,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
 	struct swap_info_struct *sis = page_swap_info(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 file *swap_file = sis->swap_file;
 		struct address_space *mapping = swap_file->f_mapping;
@@ -393,7 +393,7 @@ int swap_readpage(struct page *page, bool synchronous)
 		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 address_space *mapping = swap_file->f_mapping;
 
@@ -455,7 +455,7 @@ int swap_set_page_dirty(struct page *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;
 
 		VM_BUG_ON_PAGE(!PageSwapCache(page), page);
diff --git a/mm/swap_state.c b/mm/swap_state.c
index c16eebb81d8b..7f9449bbffdb 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -631,7 +631,7 @@ struct page *swap_cluster_readahead(swp_entry_t entry, gfp_t gfp_mask,
 		goto skip;
 
 	/* 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;
 		if (inode_read_congested(inode))
 			goto skip;
diff --git a/mm/swapfile.c b/mm/swapfile.c
index debc94155f74..5ba58ee1b378 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -2433,7 +2433,7 @@ static int setup_swap_extents(struct swap_info_struct *sis, sector_t *span)
 		if (ret >= 0)
 			sis->flags |= SWP_ACTIVATED;
 		if (!ret) {
-			sis->flags |= SWP_FS;
+			sis->flags |= SWP_FS_OPS;
 			ret = add_swap_extent(sis, 0, sis->max, 0);
 			*span = sis->pages;
 		}
-- 
2.18.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-08-22 11:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-22  9:02 [PATCH] swap: rename SWP_FS to SWAP_FS_OPS to avoid ambiguity Gao Xiang
2020-08-22 11:30 ` [PATCH v2 rebased] " Gao Xiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).