~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to fs/quota/dquot.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
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 */
80
80
 
81
81
#include <asm/uaccess.h>
82
82
 
691
691
 * This is called from kswapd when we think we need some
692
692
 * more memory
693
693
 */
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)
695
696
{
 
697
        int nr = sc->nr_to_scan;
 
698
 
696
699
        if (nr) {
697
700
                spin_lock(&dq_list_lock);
698
701
                prune_dqcache(nr);
895
898
        int reserved = 0;
896
899
#endif
897
900
 
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);
901
908
                        continue;
 
909
                }
902
910
#ifdef CONFIG_QUOTA_DEBUG
903
911
                if (unlikely(inode_get_rsv_space(inode) > 0))
904
912
                        reserved = 1;
905
913
#endif
906
 
                if (!atomic_read(&inode->i_writecount))
907
 
                        continue;
908
 
                if (!dqinit_needed(inode, type))
909
 
                        continue;
910
 
 
911
914
                __iget(inode);
912
 
                spin_unlock(&inode_lock);
 
915
                spin_unlock(&inode->i_lock);
 
916
                spin_unlock(&inode_sb_list_lock);
913
917
 
914
918
                iput(old_inode);
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. */
 
920
 
 
921
                /*
 
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
 
927
                 * later.
 
928
                 */
921
929
                old_inode = inode;
922
 
                spin_lock(&inode_lock);
 
930
                spin_lock(&inode_sb_list_lock);
923
931
        }
924
 
        spin_unlock(&inode_lock);
 
932
        spin_unlock(&inode_sb_list_lock);
925
933
        iput(old_inode);
926
934
 
927
935
#ifdef CONFIG_QUOTA_DEBUG
946
954
 
947
955
/*
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...
951
959
 */
952
960
static int remove_inode_dquot_ref(struct inode *inode, int type,
1002
1010
        struct inode *inode;
1003
1011
        int reserved = 0;
1004
1012
 
1005
 
        spin_lock(&inode_lock);
 
1013
        spin_lock(&inode_sb_list_lock);
1006
1014
        list_for_each_entry(inode, &sb->s_inodes, i_sb_list) {
1007
1015
                /*
1008
1016
                 *  We have to scan also I_NEW inodes because they can already
1016
1024
                        remove_inode_dquot_ref(inode, type, tofree_head);
1017
1025
                }
1018
1026
        }
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"