si->highest_bit = 0;
}
si->swap_map[offset] = 1;
+ si->inuse_pages++;
nr_swap_pages--;
si->cluster_next = offset+1;
return offset;
if (offset > p->highest_bit)
p->highest_bit = offset;
nr_swap_pages++;
+ p->inuse_pages--;
}
}
return count;
static int swap_show(struct seq_file *swap, void *v)
{
struct swap_info_struct *ptr = v;
- int j, usedswap;
struct file *file;
char *path;
file = ptr->swap_file;
path = d_path(file->f_dentry, file->f_vfsmnt, swap->private, PAGE_SIZE);
- for (j = 0, usedswap = 0; j < ptr->max; ++j)
- switch (ptr->swap_map[j]) {
- case SWAP_MAP_BAD:
- case 0:
- continue;
- default:
- usedswap++;
- }
- seq_printf(swap, "%-39s %s\t%d\t%d\t%d\n",
+ seq_printf(swap, "%-39s %s\t%d\t%ld\t%d\n",
path,
S_ISBLK(file->f_dentry->d_inode->i_mode) ?
"partition" : "file\t",
ptr->pages << (PAGE_SHIFT - 10),
- usedswap << (PAGE_SHIFT - 10),
+ ptr->inuse_pages << (PAGE_SHIFT - 10),
ptr->prio);
return 0;
}
p->lowest_bit = 0;
p->highest_bit = 0;
p->cluster_nr = 0;
+ p->inuse_pages = 0;
p->sdev_lock = SPIN_LOCK_UNLOCKED;
p->next = -1;
if (swap_flags & SWAP_FLAG_PREFER) {
swap_list_lock();
for (i = 0; i < nr_swapfiles; i++) {
- unsigned int j;
if (!(swap_info[i].flags & SWP_USED) ||
(swap_info[i].flags & SWP_WRITEOK))
continue;
- for (j = 0; j < swap_info[i].max; ++j) {
- switch (swap_info[i].swap_map[j]) {
- case 0:
- case SWAP_MAP_BAD:
- continue;
- default:
- nr_to_be_unused++;
- }
- }
+ nr_to_be_unused += swap_info[i].inuse_pages;
}
val->freeswap = nr_swap_pages + nr_to_be_unused;
val->totalswap = total_swap_pages + nr_to_be_unused;