quota.c (b73077eb03f510a84b102fb97640e595a958403c) quota.c (1495f230fa7750479c79e3656286b9183d662077)
1/*
2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
3 * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
4 *
5 * This copyrighted material is made available to anyone wishing to use,
6 * modify, copy, or redistribute it subject to the terms and conditions
7 * of the GNU General Public License version 2.
8 */

--- 24 unchanged lines hidden (view full) ---

33 * syncs less frequent.
34 *
35 * GFS quotas also use per-ID Lock Value Blocks (LVBs) to cache the contents of
36 * the quota file, so it is not being constantly read.
37 */
38
39#include <linux/sched.h>
40#include <linux/slab.h>
1/*
2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
3 * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
4 *
5 * This copyrighted material is made available to anyone wishing to use,
6 * modify, copy, or redistribute it subject to the terms and conditions
7 * of the GNU General Public License version 2.
8 */

--- 24 unchanged lines hidden (view full) ---

33 * syncs less frequent.
34 *
35 * GFS quotas also use per-ID Lock Value Blocks (LVBs) to cache the contents of
36 * the quota file, so it is not being constantly read.
37 */
38
39#include <linux/sched.h>
40#include <linux/slab.h>
41#include <linux/mm.h>
41#include <linux/spinlock.h>
42#include <linux/completion.h>
43#include <linux/buffer_head.h>
44#include <linux/sort.h>
45#include <linux/fs.h>
46#include <linux/bio.h>
47#include <linux/gfs2_ondisk.h>
48#include <linux/kthread.h>

--- 23 unchanged lines hidden (view full) ---

72 u32 qc_flags; /* GFS2_QCF_... */
73 u32 qc_id;
74};
75
76static LIST_HEAD(qd_lru_list);
77static atomic_t qd_lru_count = ATOMIC_INIT(0);
78static DEFINE_SPINLOCK(qd_lru_lock);
79
42#include <linux/spinlock.h>
43#include <linux/completion.h>
44#include <linux/buffer_head.h>
45#include <linux/sort.h>
46#include <linux/fs.h>
47#include <linux/bio.h>
48#include <linux/gfs2_ondisk.h>
49#include <linux/kthread.h>

--- 23 unchanged lines hidden (view full) ---

73 u32 qc_flags; /* GFS2_QCF_... */
74 u32 qc_id;
75};
76
77static LIST_HEAD(qd_lru_list);
78static atomic_t qd_lru_count = ATOMIC_INIT(0);
79static DEFINE_SPINLOCK(qd_lru_lock);
80
80int gfs2_shrink_qd_memory(struct shrinker *shrink, int nr, gfp_t gfp_mask)
81int gfs2_shrink_qd_memory(struct shrinker *shrink, struct shrink_control *sc)
81{
82 struct gfs2_quota_data *qd;
83 struct gfs2_sbd *sdp;
82{
83 struct gfs2_quota_data *qd;
84 struct gfs2_sbd *sdp;
85 int nr_to_scan = sc->nr_to_scan;
84
86
85 if (nr == 0)
87 if (nr_to_scan == 0)
86 goto out;
87
88 goto out;
89
88 if (!(gfp_mask & __GFP_FS))
90 if (!(sc->gfp_mask & __GFP_FS))
89 return -1;
90
91 spin_lock(&qd_lru_lock);
91 return -1;
92
93 spin_lock(&qd_lru_lock);
92 while (nr && !list_empty(&qd_lru_list)) {
94 while (nr_to_scan && !list_empty(&qd_lru_list)) {
93 qd = list_entry(qd_lru_list.next,
94 struct gfs2_quota_data, qd_reclaim);
95 sdp = qd->qd_gl->gl_sbd;
96
97 /* Free from the filesystem-specific list */
98 list_del(&qd->qd_list);
99
100 gfs2_assert_warn(sdp, !qd->qd_change);

--- 4 unchanged lines hidden (view full) ---

105 atomic_dec(&sdp->sd_quota_count);
106
107 /* Delete it from the common reclaim list */
108 list_del_init(&qd->qd_reclaim);
109 atomic_dec(&qd_lru_count);
110 spin_unlock(&qd_lru_lock);
111 kmem_cache_free(gfs2_quotad_cachep, qd);
112 spin_lock(&qd_lru_lock);
95 qd = list_entry(qd_lru_list.next,
96 struct gfs2_quota_data, qd_reclaim);
97 sdp = qd->qd_gl->gl_sbd;
98
99 /* Free from the filesystem-specific list */
100 list_del(&qd->qd_list);
101
102 gfs2_assert_warn(sdp, !qd->qd_change);

--- 4 unchanged lines hidden (view full) ---

107 atomic_dec(&sdp->sd_quota_count);
108
109 /* Delete it from the common reclaim list */
110 list_del_init(&qd->qd_reclaim);
111 atomic_dec(&qd_lru_count);
112 spin_unlock(&qd_lru_lock);
113 kmem_cache_free(gfs2_quotad_cachep, qd);
114 spin_lock(&qd_lru_lock);
113 nr--;
115 nr_to_scan--;
114 }
115 spin_unlock(&qd_lru_lock);
116
117out:
118 return (atomic_read(&qd_lru_count) * sysctl_vfs_cache_pressure) / 100;
119}
120
121static u64 qd2offset(struct gfs2_quota_data *qd)

--- 1521 unchanged lines hidden ---
116 }
117 spin_unlock(&qd_lru_lock);
118
119out:
120 return (atomic_read(&qd_lru_count) * sysctl_vfs_cache_pressure) / 100;
121}
122
123static u64 qd2offset(struct gfs2_quota_data *qd)

--- 1521 unchanged lines hidden ---