Commit 828cfcb3 authored by Nathan Scott's avatar Nathan Scott

[XFS] Make kmem shaking interface consistent between kernel versions. No code...

[XFS] Make kmem shaking interface consistent between kernel versions.  No code change here, mainly symbol names.

SGI Modid: 2.5.x-xfs:slinx:162379a
parent ea7de3cf
...@@ -82,6 +82,7 @@ EXPORT_SYMBOL(xfs_Gqm); /* used by xfsidbg */ ...@@ -82,6 +82,7 @@ EXPORT_SYMBOL(xfs_Gqm); /* used by xfsidbg */
kmem_zone_t *qm_dqzone; kmem_zone_t *qm_dqzone;
kmem_zone_t *qm_dqtrxzone; kmem_zone_t *qm_dqtrxzone;
kmem_shaker_t xfs_qm_shaker;
STATIC void xfs_qm_list_init(xfs_dqlist_t *, char *, int); STATIC void xfs_qm_list_init(xfs_dqlist_t *, char *, int);
STATIC void xfs_qm_list_destroy(xfs_dqlist_t *); STATIC void xfs_qm_list_destroy(xfs_dqlist_t *);
...@@ -112,8 +113,6 @@ extern mutex_t qcheck_lock; ...@@ -112,8 +113,6 @@ extern mutex_t qcheck_lock;
#define XQM_LIST_PRINT(l, NXT, title) do { } while (0) #define XQM_LIST_PRINT(l, NXT, title) do { } while (0)
#endif #endif
struct shrinker *xfs_qm_shrinker;
/* /*
* Initialize the XQM structure. * Initialize the XQM structure.
* Note that there is not one quota manager per file system. * Note that there is not one quota manager per file system.
...@@ -163,7 +162,7 @@ xfs_Gqm_init(void) ...@@ -163,7 +162,7 @@ xfs_Gqm_init(void)
} else } else
xqm->qm_dqzone = qm_dqzone; xqm->qm_dqzone = qm_dqzone;
xfs_qm_shrinker = set_shrinker(DEFAULT_SEEKS, xfs_qm_shake); xfs_qm_shaker = kmem_shake_register(xfs_qm_shake);
/* /*
* The t_dqinfo portion of transactions. * The t_dqinfo portion of transactions.
...@@ -195,8 +194,7 @@ xfs_qm_destroy( ...@@ -195,8 +194,7 @@ xfs_qm_destroy(
ASSERT(xqm != NULL); ASSERT(xqm != NULL);
ASSERT(xqm->qm_nrefs == 0); ASSERT(xqm->qm_nrefs == 0);
kmem_shake_deregister(xfs_qm_shaker);
remove_shrinker(xfs_qm_shrinker);
hsize = xqm->qm_dqhashmask + 1; hsize = xqm->qm_dqhashmask + 1;
for (i = 0; i < hsize; i++) { for (i = 0; i < hsize; i++) {
xfs_qm_list_destroy(&(xqm->qm_usr_dqhtable[i])); xfs_qm_list_destroy(&(xqm->qm_usr_dqhtable[i]));
...@@ -2078,7 +2076,7 @@ xfs_qm_shake_freelist( ...@@ -2078,7 +2076,7 @@ xfs_qm_shake_freelist(
xfs_dqunlock(dqp); xfs_dqunlock(dqp);
xfs_qm_freelist_unlock(xfs_Gqm); xfs_qm_freelist_unlock(xfs_Gqm);
if (++restarts >= XFS_QM_RECLAIM_MAX_RESTARTS) if (++restarts >= XFS_QM_RECLAIM_MAX_RESTARTS)
goto out; return (nreclaimed);
XQM_STATS_INC(xqmstats.xs_qm_dqwants); XQM_STATS_INC(xqmstats.xs_qm_dqwants);
goto tryagain; goto tryagain;
} }
...@@ -2153,7 +2151,7 @@ xfs_qm_shake_freelist( ...@@ -2153,7 +2151,7 @@ xfs_qm_shake_freelist(
XFS_DQ_HASH_UNLOCK(hash); XFS_DQ_HASH_UNLOCK(hash);
xfs_qm_freelist_unlock(xfs_Gqm); xfs_qm_freelist_unlock(xfs_Gqm);
if (++restarts >= XFS_QM_RECLAIM_MAX_RESTARTS) if (++restarts >= XFS_QM_RECLAIM_MAX_RESTARTS)
goto out; return (nreclaimed);
goto tryagain; goto tryagain;
} }
xfs_dqtrace_entry(dqp, "DQSHAKE: UNLINKING"); xfs_dqtrace_entry(dqp, "DQSHAKE: UNLINKING");
...@@ -2178,14 +2176,12 @@ xfs_qm_shake_freelist( ...@@ -2178,14 +2176,12 @@ xfs_qm_shake_freelist(
dqp = nextdqp; dqp = nextdqp;
} }
xfs_qm_freelist_unlock(xfs_Gqm); xfs_qm_freelist_unlock(xfs_Gqm);
out: return (nreclaimed);
return nreclaimed;
} }
/* /*
* The shake manager routine called by shaked() when memory is * The kmem_shake interface is invoked when memory is running low.
* running low.
*/ */
/* ARGSUSED */ /* ARGSUSED */
STATIC int STATIC int
...@@ -2193,10 +2189,10 @@ xfs_qm_shake(int nr_to_scan, unsigned int gfp_mask) ...@@ -2193,10 +2189,10 @@ xfs_qm_shake(int nr_to_scan, unsigned int gfp_mask)
{ {
int ndqused, nfree, n; int ndqused, nfree, n;
if (!(gfp_mask & __GFP_WAIT)) if (!kmem_shake_allow(gfp_mask))
return 0; return (0);
if (!xfs_Gqm) if (!xfs_Gqm)
return 0; return (0);
nfree = xfs_Gqm->qm_dqfreelist.qh_nelems; /* free dquots */ nfree = xfs_Gqm->qm_dqfreelist.qh_nelems; /* free dquots */
/* incore dquots in all f/s's */ /* incore dquots in all f/s's */
...@@ -2205,7 +2201,7 @@ xfs_qm_shake(int nr_to_scan, unsigned int gfp_mask) ...@@ -2205,7 +2201,7 @@ xfs_qm_shake(int nr_to_scan, unsigned int gfp_mask)
ASSERT(ndqused >= 0); ASSERT(ndqused >= 0);
if (nfree <= ndqused && nfree < ndquot) if (nfree <= ndqused && nfree < ndquot)
return 0; return (0);
ndqused *= xfs_Gqm->qm_dqfree_ratio; /* target # of free dquots */ ndqused *= xfs_Gqm->qm_dqfree_ratio; /* target # of free dquots */
n = nfree - ndqused - ndquot; /* # over target */ n = nfree - ndqused - ndquot; /* # over target */
......
...@@ -165,4 +165,25 @@ kmem_zone_free(kmem_zone_t *zone, void *ptr) ...@@ -165,4 +165,25 @@ kmem_zone_free(kmem_zone_t *zone, void *ptr)
kmem_cache_free(zone, ptr); kmem_cache_free(zone, ptr);
} }
typedef struct shrinker *kmem_shaker_t;
typedef int (*kmem_shake_func_t)(int, unsigned int);
static __inline kmem_shaker_t
kmem_shake_register(kmem_shake_func_t sfunc)
{
return set_shrinker(DEFAULT_SEEKS, sfunc);
}
static __inline void
kmem_shake_deregister(kmem_shaker_t shrinker)
{
remove_shrinker(shrinker);
}
static __inline int
kmem_shake_allow(unsigned int gfp_mask)
{
return (gfp_mask & __GFP_WAIT);
}
#endif /* __XFS_SUPPORT_KMEM_H__ */ #endif /* __XFS_SUPPORT_KMEM_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment