summaryrefslogtreecommitdiffstats
path: root/mm/frontswap.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/frontswap.c')
-rw-r--r--mm/frontswap.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/mm/frontswap.c b/mm/frontswap.c
index 2760b0f98822..538367ef1372 100644
--- a/mm/frontswap.c
+++ b/mm/frontswap.c
@@ -121,8 +121,13 @@ struct frontswap_ops *frontswap_register_ops(struct frontswap_ops *ops)
121 int i; 121 int i;
122 122
123 for (i = 0; i < MAX_SWAPFILES; i++) { 123 for (i = 0; i < MAX_SWAPFILES; i++) {
124 if (test_and_clear_bit(i, need_init)) 124 if (test_and_clear_bit(i, need_init)) {
125 struct swap_info_struct *sis = swap_info[i];
126 /* __frontswap_init _should_ have set it! */
127 if (!sis->frontswap_map)
128 return ERR_PTR(-EINVAL);
125 ops->init(i); 129 ops->init(i);
130 }
126 } 131 }
127 /* 132 /*
128 * We MUST have frontswap_ops set _after_ the frontswap_init's 133 * We MUST have frontswap_ops set _after_ the frontswap_init's
@@ -156,20 +161,30 @@ EXPORT_SYMBOL(frontswap_tmem_exclusive_gets);
156/* 161/*
157 * Called when a swap device is swapon'd. 162 * Called when a swap device is swapon'd.
158 */ 163 */
159void __frontswap_init(unsigned type) 164void __frontswap_init(unsigned type, unsigned long *map)
160{ 165{
161 struct swap_info_struct *sis = swap_info[type]; 166 struct swap_info_struct *sis = swap_info[type];
162 167
163 if (frontswap_ops) { 168 BUG_ON(sis == NULL);
164 BUG_ON(sis == NULL); 169
165 if (sis->frontswap_map == NULL) 170 /*
166 return; 171 * p->frontswap is a bitmap that we MUST have to figure out which page
172 * has gone in frontswap. Without it there is no point of continuing.
173 */
174 if (WARN_ON(!map))
175 return;
176 /*
177 * Irregardless of whether the frontswap backend has been loaded
178 * before this function or it will be later, we _MUST_ have the
179 * p->frontswap set to something valid to work properly.
180 */
181 frontswap_map_set(sis, map);
182 if (frontswap_ops)
167 frontswap_ops->init(type); 183 frontswap_ops->init(type);
168 } else { 184 else {
169 BUG_ON(type > MAX_SWAPFILES); 185 BUG_ON(type > MAX_SWAPFILES);
170 set_bit(type, need_init); 186 set_bit(type, need_init);
171 } 187 }
172
173} 188}
174EXPORT_SYMBOL(__frontswap_init); 189EXPORT_SYMBOL(__frontswap_init);
175 190