View | Details | Raw Unified | Return to bug 9520 | Differences between
and this patch

Collapse All | Expand All

(-)fs/dquot.c.orig (-11 / +53 lines)
Lines 27-33 Link Here
27
 *		Fixed deadlock in write_dquot() - we no longer account quotas on
27
 *		Fixed deadlock in write_dquot() - we no longer account quotas on
28
 *		quota files
28
 *		quota files
29
 *		remove_dquot_ref() moved to inode.c - it now traverses through inodes
29
 *		remove_dquot_ref() moved to inode.c - it now traverses through inodes
30
 *		add_dquot_ref() restarts after blocking
31
 *		Added check for bogus uid and fixed check for group in quotactl.
30
 *		Added check for bogus uid and fixed check for group in quotactl.
32
 *		Jan Kara, <jack@suse.cz>, sponsored by SuSE CR, 10-11/99
31
 *		Jan Kara, <jack@suse.cz>, sponsored by SuSE CR, 10-11/99
33
 *
32
 *
Lines 694-704 Link Here
694
}
693
}
695
694
696
/* This routine is guarded by dqonoff_mutex mutex */
695
/* This routine is guarded by dqonoff_mutex mutex */
697
static void add_dquot_ref(struct super_block *sb, int type)
696
static int add_dquot_ref(struct super_block *sb, int type)
698
{
697
{
698
	int error = 0;
699
	struct inode *inode;
699
	struct inode *inode;
700
	struct init_inodes_struct {
701
		struct inode *inode;
702
		struct list_head i_list;
703
	} l_head, *l_entry, *tmp;
704
705
	INIT_LIST_HEAD(&l_head.i_list);
706
	l_head.inode = NULL;
700
707
701
restart:
702
	spin_lock(&inode_lock);
708
	spin_lock(&inode_lock);
703
	list_for_each_entry(inode, &sb->s_inodes, i_sb_list) {
709
	list_for_each_entry(inode, &sb->s_inodes, i_sb_list) {
704
		if (!atomic_read(&inode->i_writecount))
710
		if (!atomic_read(&inode->i_writecount))
Lines 708-722 Link Here
708
		if (inode->i_state & (I_FREEING|I_WILL_FREE))
714
		if (inode->i_state & (I_FREEING|I_WILL_FREE))
709
			continue;
715
			continue;
710
716
711
		__iget(inode);
717
		l_entry = kmalloc(sizeof(struct init_inodes_struct), GFP_ATOMIC);
712
		spin_unlock(&inode_lock);
718
		if(!l_entry) {
719
			printk(KERN_ERR "VFS: ERROR: quota init: can't allocate entry\n");
720
			error = -ENOMEM;
721
			spin_unlock(&inode_lock);
713
722
714
		sb->dq_op->initialize(inode, type);
723
			goto fail_point;
715
		iput(inode);
724
		}
716
		/* As we may have blocked we had better restart... */
725
717
		goto restart;
726
		__iget(inode);
727
		l_entry->inode = inode;
728
		list_add(&l_entry->i_list, &l_head.i_list);
718
	}
729
	}
719
	spin_unlock(&inode_lock);
730
	spin_unlock(&inode_lock);
731
732
	list_for_each_entry(l_entry, &l_head.i_list, i_list) {
733
		if (unlikely(!l_entry || !l_entry->inode)) {
734
			printk(KERN_ERR "VFS: ERROR: quota init: it's a BUG, quota is not consistent\n");
735
			error = -EINVAL;
736
			goto fail_point;
737
		}
738
		sb->dq_op->initialize(l_entry->inode, type);
739
	}
740
741
fail_point:
742
/* on error we have to put already added inodes and free the list */
743
744
	list_for_each_entry(l_entry, &l_head.i_list, i_list) {
745
		if (unlikely(!l_entry || !l_entry->inode))
746
			continue;
747
		iput(l_entry->inode);
748
	}
749
750
	list_for_each_entry_safe(l_entry, tmp, &l_head.i_list, i_list) {
751
		if (unlikely(!l_entry || !l_entry->inode))
752
			continue;
753
754
		list_del(&l_entry->i_list);
755
		kfree(l_entry);
756
	}
757
758
	return error;
720
}
759
}
721
760
722
/* Return 0 if dqput() won't block (note that 1 doesn't necessarily mean blocking) */
761
/* Return 0 if dqput() won't block (note that 1 doesn't necessarily mean blocking) */
Lines 1586-1595 Link Here
1586
	mutex_unlock(&inode->i_mutex);
1625
	mutex_unlock(&inode->i_mutex);
1587
	set_enable_flags(dqopt, type);
1626
	set_enable_flags(dqopt, type);
1588
1627
1589
	add_dquot_ref(sb, type);
1628
	error = add_dquot_ref(sb, type);
1629
	if (error) {
1630
		;//TODO: handle errors
1631
	}
1590
	mutex_unlock(&dqopt->dqonoff_mutex);
1632
	mutex_unlock(&dqopt->dqonoff_mutex);
1591
1633
1592
	return 0;
1634
	return error;
1593
1635
1594
out_file_init:
1636
out_file_init:
1595
	dqopt->files[type] = NULL;
1637
	dqopt->files[type] = NULL;

Return to bug 9520