Skip to contentSkip to conversation

erofs: allow large folios for compressed files

PATCH In review Gao Xiang 2 participants 3 messages Aug 19, 2024 – Aug 20, 2024

Subsystems (2)
lore
Share & tools
lore

Gao Xiang

author
#0 lore raw

PATCH 1/1 erofs: allow large folios for compressed files

As commit 2e6506e1c4ee ("mm/migrate: fix deadlock in migrate_pages_batch() on large folios") already landed upstream, large folios can be safely enabled for compressed inodes since all prerequisites already landed in 6.11-rc1.

Stress tests has been working on my fleet for > 20 days without any regression. Besides, users [1] has requested it for months. Let's allow large folios for EROFS full cases upstream now for wider testing.

[1] https://lore.kernel.org/r/CAGsJ_4wtE8OcpinuqVwG4jtdx6Qh5f+TON6wz+4HMCq=A2qFcA@mail.gmail.com

Cc Barry Song <[email protected]>
Cc Matthew Wilcox (Oracle) <[email protected]>
---
 Documentation/filesystems/erofs.rst |  2 +-
 fs/erofs/inode.c                    | 18 ++++++++----------
 2 files changed, 9 insertions(+), 11 deletions(-)
Documentation/filesystems/erofs.rst +1 -1
index cc4626d6ee4f..c293f8e37468 100644
@@ -75,7 +75,7 @@ Here are the main features of EROFS:
 
  - Support merging tail-end data into a special inode as fragments.
 
- - Support large folios for uncompressed files.
+ - Support large folios to make use of THPs (Transparent Hugepages);
 
  - Support direct I/O on uncompressed files to avoid double caching for loop
    devices;
fs/erofs/inode.c +8 -10
index 43c09aae2afc..419432be3223 100644
@@ -257,25 +257,23 @@ static int erofs_fill_inode(struct inode *inode)
 		goto out_unlock;
 	}
 
+	mapping_set_large_folios(inode->i_mapping);
 	if (erofs_inode_is_data_compressed(vi->datalayout)) {
 #ifdef CONFIG_EROFS_FS_ZIP
 		DO_ONCE_LITE_IF(inode->i_blkbits != PAGE_SHIFT,
 			  erofs_info, inode->i_sb,
 			  "EXPERIMENTAL EROFS subpage compressed block support in use. Use at your own risk!");
 		inode->i_mapping->a_ops = &z_erofs_aops;
-		err = 0;
-		goto out_unlock;
-#endif
+#else
 		err = -EOPNOTSUPP;
-		goto out_unlock;
-	}
-	inode->i_mapping->a_ops = &erofs_raw_access_aops;
-	mapping_set_large_folios(inode->i_mapping);
+#endif
+	} else {
+		inode->i_mapping->a_ops = &erofs_raw_access_aops;
 #ifdef CONFIG_EROFS_FS_ONDEMAND
-	if (erofs_is_fscache_mode(inode->i_sb))
-		inode->i_mapping->a_ops = &erofs_fscache_access_aops;
+		if (erofs_is_fscache_mode(inode->i_sb))
+			inode->i_mapping->a_ops = &erofs_fscache_access_aops;
 #endif
-
+	}
 out_unlock:
 	erofs_put_metabuf(&buf);
 	return err;
Signature · 1 line
2.43.5
#1 lore raw
Quoted 6 lines · Gao Xiang

As commit 2e6506e1c4ee ("mm/migrate: fix deadlock in migrate_pages_batch() on large folios") already landed upstream, large folios can be safely enabled for compressed inodes since all prerequisites already landed in 6.11-rc1.

Quoted 8 lines

Stress tests has been working on my fleet for > 20 days without any regression. Besides, users [1] has requested it for months. Let's allow large folios for EROFS full cases upstream now for wider testing.

[1] https://lore.kernel.org/r/CAGsJ_4wtE8OcpinuqVwG4jtdx6Qh5f+TON6wz+4HMCq=A2qFcA@mail.gmail.com

Cc Barry Song <[email protected]>
Cc Matthew Wilcox (Oracle) <[email protected]>

Thank you, Xiang! We'll run some tests and update you with our findings.

Quoted 57 lines
---
 Documentation/filesystems/erofs.rst |  2 +-
 fs/erofs/inode.c                    | 18 ++++++++----------
 2 files changed, 9 insertions(+), 11 deletions(-)
Documentation/filesystems/erofs.rst +1 -1
index cc4626d6ee4f..c293f8e37468 100644
@@ -75,7 +75,7 @@ Here are the main features of EROFS:
 
  - Support merging tail-end data into a special inode as fragments.
 
- - Support large folios for uncompressed files.
+ - Support large folios to make use of THPs (Transparent Hugepages);
 
  - Support direct I/O on uncompressed files to avoid double caching for loop
    devices;
fs/erofs/inode.c +8 -11
index 43c09aae2afc..419432be3223 100644
@@ -257,25 +257,23 @@ static int erofs_fill_inode(struct inode *inode)
                goto out_unlock;
        }
 
+       mapping_set_large_folios(inode->i_mapping);
        if (erofs_inode_is_data_compressed(vi->datalayout)) {
 #ifdef CONFIG_EROFS_FS_ZIP
                DO_ONCE_LITE_IF(inode->i_blkbits != PAGE_SHIFT,
                          erofs_info, inode->i_sb,
                          "EXPERIMENTAL EROFS subpage compressed block support in use. Use at your own risk!");
                inode->i_mapping->a_ops = &z_erofs_aops;
-               err = 0;
-               goto out_unlock;
-#endif
+#else
                err = -EOPNOTSUPP;
-               goto out_unlock;
-       }
-       inode->i_mapping->a_ops = &erofs_raw_access_aops;
-       mapping_set_large_folios(inode->i_mapping);
+#endif
+       } else {
+               inode->i_mapping->a_ops = &erofs_raw_access_aops;
 #ifdef CONFIG_EROFS_FS_ONDEMAND
-       if (erofs_is_fscache_mode(inode->i_sb))
-               inode->i_mapping->a_ops = &erofs_fscache_access_aops;
+               if (erofs_is_fscache_mode(inode->i_sb))
+                       inode->i_mapping->a_ops = &erofs_fscache_access_aops;
 #endif
-
+       }
 out_unlock:
        erofs_put_metabuf(&buf);
        return err;
--
Quoted 2 lines

2.43.5

Thanks
Barry

author
#2 lore raw
Quoted 11 lines · Barry Song
Quoted 10 lines · Gao Xiang

As commit 2e6506e1c4ee ("mm/migrate: fix deadlock in migrate_pages_batch() on large folios") already landed upstream, large folios can be safely enabled for compressed inodes since all prerequisites already landed in 6.11-rc1.

Stress tests has been working on my fleet for > 20 days without any regression. Besides, users [1] has requested it for months. Let's allow large folios for EROFS full cases upstream now for wider testing.

Quoted 6 lines
Quoted 4 lines

[1] https://lore.kernel.org/r/CAGsJ_4wtE8OcpinuqVwG4jtdx6Qh5f+TON6wz+4HMCq=A2qFcA@mail.gmail.com

Cc Barry Song <[email protected]>
Cc Matthew Wilcox (Oracle) <[email protected]>

Thank you, Xiang! We'll run some tests and update you with our findings.

Yeah, findings and patches are welcome as always.

Thanks,
Gao Xiang