Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7af9cce8 authored by Dmitry Monakhov's avatar Dmitry Monakhov Committed by Jan Kara
Browse files

quota: check quota reservation on remove_dquot_ref



Reserved space must being claimed before remove_dquot_ref() for a
given inode. Filesystem is responsible for performing force blocks
allocation in case of dealloc in ->quota_off. Let's add sanity check
for that case. Do it similar to add_dquot_ref().

Signed-off-by: default avatarDmitry Monakhov <dmonakhov@openvz.org>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
parent a9f7f2e7
Loading
Loading
Loading
Loading
+12 −1
Original line number Original line Diff line number Diff line
@@ -986,6 +986,7 @@ static void remove_dquot_ref(struct super_block *sb, int type,
		struct list_head *tofree_head)
		struct list_head *tofree_head)
{
{
	struct inode *inode;
	struct inode *inode;
	int reserved = 0;


	spin_lock(&inode_lock);
	spin_lock(&inode_lock);
	list_for_each_entry(inode, &sb->s_inodes, i_sb_list) {
	list_for_each_entry(inode, &sb->s_inodes, i_sb_list) {
@@ -995,10 +996,20 @@ static void remove_dquot_ref(struct super_block *sb, int type,
		 *  only quota pointers and these have separate locking
		 *  only quota pointers and these have separate locking
		 *  (dqptr_sem).
		 *  (dqptr_sem).
		 */
		 */
		if (!IS_NOQUOTA(inode))
		if (!IS_NOQUOTA(inode)) {
			if (unlikely(inode_get_rsv_space(inode) > 0))
				reserved = 1;
			remove_inode_dquot_ref(inode, type, tofree_head);
			remove_inode_dquot_ref(inode, type, tofree_head);
		}
		}
	}
	spin_unlock(&inode_lock);
	spin_unlock(&inode_lock);
#ifdef CONFIG_QUOTA_DEBUG
	if (reserved) {
		printk(KERN_WARNING "VFS (%s): Writes happened after quota"
			" was disabled thus quota information is probably "
			"inconsistent. Please run quotacheck(8).\n", sb->s_id);
	}
#endif
}
}


/* Gather all references from inodes and drop them */
/* Gather all references from inodes and drop them */