Commit 7af9cce8ae467bb2fcf3b0b6be3898835bdb984c

Authored by Dmitry Monakhov
Committed by Jan Kara
1 parent a9f7f2e74a

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>

Showing 1 changed file with 12 additions and 1 deletions Side-by-side Diff

... ... @@ -986,6 +986,7 @@
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) {
992 993  
993 994  
... ... @@ -995,10 +996,20 @@
995 996 * only quota pointers and these have separate locking
996 997 * (dqptr_sem).
997 998 */
998   - if (!IS_NOQUOTA(inode))
  999 + if (!IS_NOQUOTA(inode)) {
  1000 + if (unlikely(inode_get_rsv_space(inode) > 0))
  1001 + reserved = 1;
999 1002 remove_inode_dquot_ref(inode, type, tofree_head);
  1003 + }
1000 1004 }
1001 1005 spin_unlock(&inode_lock);
  1006 +#ifdef CONFIG_QUOTA_DEBUG
  1007 + if (reserved) {
  1008 + printk(KERN_WARNING "VFS (%s): Writes happened after quota"
  1009 + " was disabled thus quota information is probably "
  1010 + "inconsistent. Please run quotacheck(8).\n", sb->s_id);
  1011 + }
  1012 +#endif
1002 1013 }
1003 1014  
1004 1015 /* Gather all references from inodes and drop them */