Skip to contentSkip to conversation

staging: erofs: introduce .migratepage for managed cache

PATCH Superseded Gao Xiang 1 participant 1 message Dec 6, 2018 Staging

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Gao Xiang

author
#0 lore raw

PATCH 1/1 staging: erofs: introduce .migratepage for managed cache

It's awkward for managed cache to use the default migration path since the default approach will fall back to try_to_release_page for all PG_private pages.

Let's create a customized method to handle this more effectively.

Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>
---
 drivers/staging/erofs/internal.h  |   7 +++
 drivers/staging/erofs/super.c     |   3 ++
 drivers/staging/erofs/unzip_vle.c | 107 ++++++++++++++++++++++++++++++++++++++
 drivers/staging/erofs/unzip_vle.h |   4 ++
 4 files changed, 121 insertions(+)
drivers/staging/erofs/internal.h +7 -0
index 892944355867..4b3b686c3569 100644
@@ -295,6 +295,13 @@ extern int erofs_try_to_free_all_cached_pages(struct erofs_sb_info *sbi,
 	struct erofs_workgroup *egrp);
 extern int erofs_try_to_free_cached_page(struct address_space *mapping,
 	struct page *page);
+
+#ifdef CONFIG_MIGRATION
+int erofs_migrate_cached_page(struct address_space *mapping,
+			      struct page *newpage,
+			      struct page *page,
+			      enum migrate_mode mode);
+#endif
 #endif
 
 #define DEFAULT_MAX_SYNC_DECOMPRESS_PAGES	3
drivers/staging/erofs/super.c +3 -0
index 1c2eb69682ef..354671496971 100644
@@ -329,6 +329,9 @@ static void managed_cache_invalidatepage(struct page *page,
 static const struct address_space_operations managed_cache_aops = {
 	.releasepage = managed_cache_releasepage,
 	.invalidatepage = managed_cache_invalidatepage,
+#ifdef CONFIG_MIGRATION
+	.migratepage = erofs_migrate_cached_page,
+#endif
 };
 
 static struct inode *erofs_init_managed_cache(struct super_block *sb)
drivers/staging/erofs/unzip_vle.c +107 -0

125 lines not on this page · raw message

drivers/staging/erofs/unzip_vle.h +4 -0
index 3316bc36965d..71cf4839897b 100644
@@ -67,6 +67,10 @@ struct z_erofs_vle_work {
 #define Z_EROFS_VLE_WORKGRP_FMT_LZ4          1
 #define Z_EROFS_VLE_WORKGRP_FMT_MASK         1
 
+/* used to wait decompression for this workgroup */
+#define Z_EROFS_WG_WAIT_COMPLETION_BIT  3
+#define Z_EROFS_WG_WAIT_COMPLETION      BIT(Z_EROFS_WG_WAIT_COMPLETION_BIT)
+
 typedef struct z_erofs_vle_workgroup *z_erofs_vle_owned_workgrp_t;
 
 struct z_erofs_vle_workgroup {
Signature · 1 line
2.14.4