set_current_state(TASK_UNINTERRUPTIBLE); schedule_timeout(1); 
schedule_timeout_uninterruptible(1); 
asmlinkage long sys_swapoff(const char __user * specialfile){	struct swap_info_struct * p = NULL;	unsigned short *swap_map;	struct file *swap_file, *victim;	struct address_space *mapping;	struct inode *inode;	char * pathname;	int i, type, prev;	int err;		if (!capable(CAP_SYS_ADMIN))		return -EPERM;	pathname = getname(specialfile);	err = PTR_ERR(pathname);	if (IS_ERR(pathname))		goto out;	victim = filp_open(pathname, O_RDWR|O_LARGEFILE, 0);	putname(pathname);	err = PTR_ERR(victim);	if (IS_ERR(victim))		goto out;	mapping = victim->f_mapping;	prev = -1;	spin_lock(&swap_lock);	for (type = swap_list.head; type >= 0; type = swap_info[type].next) {		p = swap_info + type;		if ((p->flags & SWP_ACTIVE) == SWP_ACTIVE) {			if (p->swap_file->f_mapping == mapping)				break;		}		prev = type;	}	if (type < 0) {		err = -EINVAL;		spin_unlock(&swap_lock);		goto out_dput;	}	if (!security_vm_enough_memory(p->pages))		vm_unacct_memory(p->pages);	else {		err = -ENOMEM;		spin_unlock(&swap_lock);		goto out_dput;	}	if (prev < 0) {		swap_list.head = p->next;	} else {		swap_info[prev].next = p->next;	}	if (type == swap_list.next) {		/* just pick something that's safe... */		swap_list.next = swap_list.head;	}	nr_swap_pages -= p->pages;	total_swap_pages -= p->pages;	p->flags &= ~SWP_WRITEOK;	spin_unlock(&swap_lock);	current->flags |= PF_SWAPOFF;	err = try_to_unuse(type);	current->flags &= ~PF_SWAPOFF;	if (err) {		/* re-insert swap space back into swap_list */		spin_lock(&swap_lock);		for (prev = -1, i = swap_list.head; i >= 0; prev = i, i = swap_info[i].next)			if (p->prio >= swap_info[i].prio)				break;		p->next = i;		if (prev < 0)			swap_list.head = swap_list.next = p - swap_info;		else			swap_info[prev].next = p - swap_info;		nr_swap_pages += p->pages;		total_swap_pages += p->pages;		p->flags |= SWP_WRITEOK;		spin_unlock(&swap_lock);		goto out_dput;	}	/* wait for any unplug function to finish */	down_write(&swap_unplug_sem);	up_write(&swap_unplug_sem);	destroy_swap_extents(p);	down(&swapon_sem);	spin_lock(&swap_lock);	drain_mmlist();	/* wait for anyone still in scan_swap_map */	p->highest_bit = 0;		/* cuts scans short */	while (p->flags >= SWP_SCANNING) {		spin_unlock(&swap_lock);		set_current_state(TASK_UNINTERRUPTIBLE);		schedule_timeout(1);		spin_lock(&swap_lock);	}	swap_file = p->swap_file;	p->swap_file = NULL;	p->max = 0;	swap_map = p->swap_map;	p->swap_map = NULL;	p->flags = 0;	spin_unlock(&swap_lock);	up(&swapon_sem);	vfree(swap_map);	inode = mapping->host;	if (S_ISBLK(inode->i_mode)) {		struct block_device *bdev = I_BDEV(inode);		set_blocksize(bdev, p->old_block_size);		bd_release(bdev);	} else {		down(&inode->i_sem);		inode->i_flags &= ~S_SWAPFILE;		up(&inode->i_sem);	}	filp_close(swap_file, NULL);	err = 0;out_dput:	filp_close(victim, NULL);out:	return err;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/13e4b57f6a4e23ceb99794a650d777e74831f4a6/swapfile.c/buggy/mm/swapfile.c