dquot.c (55f841ce9395a72c6285fbcc4c403c0c786e1c74) | dquot.c (1ab6c4997e04a00c50c6d786c2f046adc0d1f5de) |
---|---|
1/* 2 * Implementation of the diskquota system for the LINUX operating system. QUOTA 3 * is implemented using the BSD system call interface as the means of 4 * communication with the user level. This file contains the generic routines 5 * called by the different filesystems on allocation of an inode or block. 6 * These routines take care of the administration needed to have a consistent 7 * diskquota tracking system. The ideas of both user and group quotas are based 8 * on the Melbourne quota system as used on BSD derived systems. The internal --- 673 unchanged lines hidden (view full) --- 682 mutex_unlock(&dqopt->files[cnt]->i_mutex); 683 } 684 mutex_unlock(&dqopt->dqonoff_mutex); 685 686 return 0; 687} 688EXPORT_SYMBOL(dquot_quota_sync); 689 | 1/* 2 * Implementation of the diskquota system for the LINUX operating system. QUOTA 3 * is implemented using the BSD system call interface as the means of 4 * communication with the user level. This file contains the generic routines 5 * called by the different filesystems on allocation of an inode or block. 6 * These routines take care of the administration needed to have a consistent 7 * diskquota tracking system. The ideas of both user and group quotas are based 8 * on the Melbourne quota system as used on BSD derived systems. The internal --- 673 unchanged lines hidden (view full) --- 682 mutex_unlock(&dqopt->files[cnt]->i_mutex); 683 } 684 mutex_unlock(&dqopt->dqonoff_mutex); 685 686 return 0; 687} 688EXPORT_SYMBOL(dquot_quota_sync); 689 |
690/* Free unused dquots from cache */ 691static void prune_dqcache(int count) | 690static unsigned long 691dqcache_shrink_scan(struct shrinker *shrink, struct shrink_control *sc) |
692{ 693 struct list_head *head; 694 struct dquot *dquot; | 692{ 693 struct list_head *head; 694 struct dquot *dquot; |
695 unsigned long freed = 0; |
|
695 696 head = free_dquots.prev; | 696 697 head = free_dquots.prev; |
697 while (head != &free_dquots && count) { | 698 while (head != &free_dquots && sc->nr_to_scan) { |
698 dquot = list_entry(head, struct dquot, dq_free); 699 remove_dquot_hash(dquot); 700 remove_free_dquot(dquot); 701 remove_inuse(dquot); 702 do_destroy_dquot(dquot); | 699 dquot = list_entry(head, struct dquot, dq_free); 700 remove_dquot_hash(dquot); 701 remove_free_dquot(dquot); 702 remove_inuse(dquot); 703 do_destroy_dquot(dquot); |
703 count--; | 704 sc->nr_to_scan--; 705 freed++; |
704 head = free_dquots.prev; 705 } | 706 head = free_dquots.prev; 707 } |
708 return freed; |
|
706} 707 | 709} 710 |
708/* 709 * This is called from kswapd when we think we need some 710 * more memory 711 */ 712static int shrink_dqcache_memory(struct shrinker *shrink, 713 struct shrink_control *sc) | 711static unsigned long 712dqcache_shrink_count(struct shrinker *shrink, struct shrink_control *sc) |
714{ | 713{ |
715 int nr = sc->nr_to_scan; 716 717 if (nr) { 718 spin_lock(&dq_list_lock); 719 prune_dqcache(nr); 720 spin_unlock(&dq_list_lock); 721 } | |
722 return vfs_pressure_ratio( 723 percpu_counter_read_positive(&dqstats.counter[DQST_FREE_DQUOTS])); 724} 725 726static struct shrinker dqcache_shrinker = { | 714 return vfs_pressure_ratio( 715 percpu_counter_read_positive(&dqstats.counter[DQST_FREE_DQUOTS])); 716} 717 718static struct shrinker dqcache_shrinker = { |
727 .shrink = shrink_dqcache_memory, | 719 .count_objects = dqcache_shrink_count, 720 .scan_objects = dqcache_shrink_scan, |
728 .seeks = DEFAULT_SEEKS, 729}; 730 731/* 732 * Put reference to dquot 733 * NOTE: If you change this function please check whether dqput_blocks() works right... 734 */ 735void dqput(struct dquot *dquot) --- 2031 unchanged lines hidden --- | 721 .seeks = DEFAULT_SEEKS, 722}; 723 724/* 725 * Put reference to dquot 726 * NOTE: If you change this function please check whether dqput_blocks() works right... 727 */ 728void dqput(struct dquot *dquot) --- 2031 unchanged lines hidden --- |