Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Dmitry Monakhov <dmonakhov@openvz.org>
Signed-off-by: Jan Kara <jack@suse.cz>

authored by

Dmitry Monakhov and committed by
Jan Kara
7af9cce8 a9f7f2e7

+12 -1
+12 -1
fs/quota/dquot.c
··· 986 986 struct list_head *tofree_head) 987 987 { 988 988 struct inode *inode; 989 + int reserved = 0; 989 990 990 991 spin_lock(&inode_lock); 991 992 list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { ··· 996 995 * only quota pointers and these have separate locking 997 996 * (dqptr_sem). 998 997 */ 999 - if (!IS_NOQUOTA(inode)) 998 + if (!IS_NOQUOTA(inode)) { 999 + if (unlikely(inode_get_rsv_space(inode) > 0)) 1000 + reserved = 1; 1000 1001 remove_inode_dquot_ref(inode, type, tofree_head); 1002 + } 1001 1003 } 1002 1004 spin_unlock(&inode_lock); 1005 + #ifdef CONFIG_QUOTA_DEBUG 1006 + if (reserved) { 1007 + printk(KERN_WARNING "VFS (%s): Writes happened after quota" 1008 + " was disabled thus quota information is probably " 1009 + "inconsistent. Please run quotacheck(8).\n", sb->s_id); 1010 + } 1011 + #endif 1003 1012 } 1004 1013 1005 1014 /* Gather all references from inodes and drop them */