76
76
#include <linux/buffer_head.h>
77
77
#include <linux/capability.h>
78
78
#include <linux/quotaops.h>
79
#include <linux/writeback.h> /* for inode_lock, oddly enough.. */
79
#include "../internal.h" /* ugh */
81
81
#include <asm/uaccess.h>
691
691
* This is called from kswapd when we think we need some
694
static int shrink_dqcache_memory(struct shrinker *shrink, int nr, gfp_t gfp_mask)
694
static int shrink_dqcache_memory(struct shrinker *shrink,
695
struct shrink_control *sc)
697
int nr = sc->nr_to_scan;
697
700
spin_lock(&dq_list_lock);
698
701
prune_dqcache(nr);
895
898
int reserved = 0;
898
spin_lock(&inode_lock);
901
spin_lock(&inode_sb_list_lock);
899
902
list_for_each_entry(inode, &sb->s_inodes, i_sb_list) {
900
if (inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW))
903
spin_lock(&inode->i_lock);
904
if ((inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) ||
905
!atomic_read(&inode->i_writecount) ||
906
!dqinit_needed(inode, type)) {
907
spin_unlock(&inode->i_lock);
902
910
#ifdef CONFIG_QUOTA_DEBUG
903
911
if (unlikely(inode_get_rsv_space(inode) > 0))
906
if (!atomic_read(&inode->i_writecount))
908
if (!dqinit_needed(inode, type))
912
spin_unlock(&inode_lock);
915
spin_unlock(&inode->i_lock);
916
spin_unlock(&inode_sb_list_lock);
915
919
__dquot_initialize(inode, type);
916
/* We hold a reference to 'inode' so it couldn't have been
917
* removed from s_inodes list while we dropped the inode_lock.
918
* We cannot iput the inode now as we can be holding the last
919
* reference and we cannot iput it under inode_lock. So we
920
* keep the reference and iput it later. */
922
* We hold a reference to 'inode' so it couldn't have been
923
* removed from s_inodes list while we dropped the
924
* inode_sb_list_lock We cannot iput the inode now as we can be
925
* holding the last reference and we cannot iput it under
926
* inode_sb_list_lock. So we keep the reference and iput it
921
929
old_inode = inode;
922
spin_lock(&inode_lock);
930
spin_lock(&inode_sb_list_lock);
924
spin_unlock(&inode_lock);
932
spin_unlock(&inode_sb_list_lock);
927
935
#ifdef CONFIG_QUOTA_DEBUG
948
956
* Remove references to dquots from inode and add dquot to list for freeing
949
* if we have the last referece to dquot
957
* if we have the last reference to dquot
950
958
* We can't race with anybody because we hold dqptr_sem for writing...
952
960
static int remove_inode_dquot_ref(struct inode *inode, int type,
1016
1024
remove_inode_dquot_ref(inode, type, tofree_head);
1019
spin_unlock(&inode_lock);
1027
spin_unlock(&inode_sb_list_lock);
1020
1028
#ifdef CONFIG_QUOTA_DEBUG
1021
1029
if (reserved) {
1022
1030
printk(KERN_WARNING "VFS (%s): Writes happened after quota"