aboutsummaryrefslogtreecommitdiffstats
path: root/mm/swapfile.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/swapfile.c')
-rw-r--r--mm/swapfile.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c
index a15def63f28f..8e206cea0f5e 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -1274,10 +1274,13 @@ static void *swap_start(struct seq_file *swap, loff_t *pos)
1274 1274
1275 mutex_lock(&swapon_mutex); 1275 mutex_lock(&swapon_mutex);
1276 1276
1277 if (!l)
1278 return SEQ_START_TOKEN;
1279
1277 for (i = 0; i < nr_swapfiles; i++, ptr++) { 1280 for (i = 0; i < nr_swapfiles; i++, ptr++) {
1278 if (!(ptr->flags & SWP_USED) || !ptr->swap_map) 1281 if (!(ptr->flags & SWP_USED) || !ptr->swap_map)
1279 continue; 1282 continue;
1280 if (!l--) 1283 if (!--l)
1281 return ptr; 1284 return ptr;
1282 } 1285 }
1283 1286
@@ -1286,10 +1289,17 @@ static void *swap_start(struct seq_file *swap, loff_t *pos)
1286 1289
1287static void *swap_next(struct seq_file *swap, void *v, loff_t *pos) 1290static void *swap_next(struct seq_file *swap, void *v, loff_t *pos)
1288{ 1291{
1289 struct swap_info_struct *ptr = v; 1292 struct swap_info_struct *ptr;
1290 struct swap_info_struct *endptr = swap_info + nr_swapfiles; 1293 struct swap_info_struct *endptr = swap_info + nr_swapfiles;
1291 1294
1292 for (++ptr; ptr < endptr; ptr++) { 1295 if (v == SEQ_START_TOKEN)
1296 ptr = swap_info;
1297 else {
1298 ptr = v;
1299 ptr++;
1300 }
1301
1302 for (; ptr < endptr; ptr++) {
1293 if (!(ptr->flags & SWP_USED) || !ptr->swap_map) 1303 if (!(ptr->flags & SWP_USED) || !ptr->swap_map)
1294 continue; 1304 continue;
1295 ++*pos; 1305 ++*pos;
@@ -1310,8 +1320,10 @@ static int swap_show(struct seq_file *swap, void *v)
1310 struct file *file; 1320 struct file *file;
1311 int len; 1321 int len;
1312 1322
1313 if (v == swap_info) 1323 if (ptr == SEQ_START_TOKEN) {
1314 seq_puts(swap, "Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n"); 1324 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
1325 return 0;
1326 }
1315 1327
1316 file = ptr->swap_file; 1328 file = ptr->swap_file;
1317 len = seq_path(swap, file->f_vfsmnt, file->f_dentry, " \t\n\\"); 1329 len = seq_path(swap, file->f_vfsmnt, file->f_dentry, " \t\n\\");