xfs: Convert filestreams code to use per-ag get/put routines
Use xfs_perag_get() and xfs_perag_put() in the filestreams code. Signed-off-by: Dave Chinner <david@fromorbit.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Alex Elder <aelder@sgi.com>
This commit is contained in:
@@ -140,6 +140,7 @@ _xfs_filestream_pick_ag(
|
|||||||
int flags,
|
int flags,
|
||||||
xfs_extlen_t minlen)
|
xfs_extlen_t minlen)
|
||||||
{
|
{
|
||||||
|
int streams, max_streams;
|
||||||
int err, trylock, nscan;
|
int err, trylock, nscan;
|
||||||
xfs_extlen_t longest, free, minfree, maxfree = 0;
|
xfs_extlen_t longest, free, minfree, maxfree = 0;
|
||||||
xfs_agnumber_t ag, max_ag = NULLAGNUMBER;
|
xfs_agnumber_t ag, max_ag = NULLAGNUMBER;
|
||||||
@@ -155,15 +156,15 @@ _xfs_filestream_pick_ag(
|
|||||||
trylock = XFS_ALLOC_FLAG_TRYLOCK;
|
trylock = XFS_ALLOC_FLAG_TRYLOCK;
|
||||||
|
|
||||||
for (nscan = 0; 1; nscan++) {
|
for (nscan = 0; 1; nscan++) {
|
||||||
|
pag = xfs_perag_get(mp, ag);
|
||||||
TRACE_AG_SCAN(mp, ag, xfs_filestream_peek_ag(mp, ag));
|
TRACE_AG_SCAN(mp, ag, atomic_read(&pag->pagf_fstrms));
|
||||||
|
|
||||||
pag = mp->m_perag + ag;
|
|
||||||
|
|
||||||
if (!pag->pagf_init) {
|
if (!pag->pagf_init) {
|
||||||
err = xfs_alloc_pagf_init(mp, NULL, ag, trylock);
|
err = xfs_alloc_pagf_init(mp, NULL, ag, trylock);
|
||||||
if (err && !trylock)
|
if (err && !trylock) {
|
||||||
|
xfs_perag_put(pag);
|
||||||
return err;
|
return err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Might fail sometimes during the 1st pass with trylock set. */
|
/* Might fail sometimes during the 1st pass with trylock set. */
|
||||||
@@ -173,6 +174,7 @@ _xfs_filestream_pick_ag(
|
|||||||
/* Keep track of the AG with the most free blocks. */
|
/* Keep track of the AG with the most free blocks. */
|
||||||
if (pag->pagf_freeblks > maxfree) {
|
if (pag->pagf_freeblks > maxfree) {
|
||||||
maxfree = pag->pagf_freeblks;
|
maxfree = pag->pagf_freeblks;
|
||||||
|
max_streams = atomic_read(&pag->pagf_fstrms);
|
||||||
max_ag = ag;
|
max_ag = ag;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,6 +197,8 @@ _xfs_filestream_pick_ag(
|
|||||||
|
|
||||||
/* Break out, retaining the reference on the AG. */
|
/* Break out, retaining the reference on the AG. */
|
||||||
free = pag->pagf_freeblks;
|
free = pag->pagf_freeblks;
|
||||||
|
streams = atomic_read(&pag->pagf_fstrms);
|
||||||
|
xfs_perag_put(pag);
|
||||||
*agp = ag;
|
*agp = ag;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -202,6 +206,7 @@ _xfs_filestream_pick_ag(
|
|||||||
/* Drop the reference on this AG, it's not usable. */
|
/* Drop the reference on this AG, it's not usable. */
|
||||||
xfs_filestream_put_ag(mp, ag);
|
xfs_filestream_put_ag(mp, ag);
|
||||||
next_ag:
|
next_ag:
|
||||||
|
xfs_perag_put(pag);
|
||||||
/* Move to the next AG, wrapping to AG 0 if necessary. */
|
/* Move to the next AG, wrapping to AG 0 if necessary. */
|
||||||
if (++ag >= mp->m_sb.sb_agcount)
|
if (++ag >= mp->m_sb.sb_agcount)
|
||||||
ag = 0;
|
ag = 0;
|
||||||
@@ -229,6 +234,7 @@ next_ag:
|
|||||||
if (max_ag != NULLAGNUMBER) {
|
if (max_ag != NULLAGNUMBER) {
|
||||||
xfs_filestream_get_ag(mp, max_ag);
|
xfs_filestream_get_ag(mp, max_ag);
|
||||||
TRACE_AG_PICK1(mp, max_ag, maxfree);
|
TRACE_AG_PICK1(mp, max_ag, maxfree);
|
||||||
|
streams = max_streams;
|
||||||
free = maxfree;
|
free = maxfree;
|
||||||
*agp = max_ag;
|
*agp = max_ag;
|
||||||
break;
|
break;
|
||||||
@@ -240,8 +246,7 @@ next_ag:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE_AG_PICK2(mp, startag, *agp, xfs_filestream_peek_ag(mp, *agp),
|
TRACE_AG_PICK2(mp, startag, *agp, streams, free, nscan, flags);
|
||||||
free, nscan, flags);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -79,12 +79,21 @@ extern ktrace_t *xfs_filestreams_trace_buf;
|
|||||||
* the cache that reference per-ag array elements that have since been
|
* the cache that reference per-ag array elements that have since been
|
||||||
* reallocated.
|
* reallocated.
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
|
* xfs_filestream_peek_ag is only used in tracing code
|
||||||
|
*/
|
||||||
static inline int
|
static inline int
|
||||||
xfs_filestream_peek_ag(
|
xfs_filestream_peek_ag(
|
||||||
xfs_mount_t *mp,
|
xfs_mount_t *mp,
|
||||||
xfs_agnumber_t agno)
|
xfs_agnumber_t agno)
|
||||||
{
|
{
|
||||||
return atomic_read(&mp->m_perag[agno].pagf_fstrms);
|
struct xfs_perag *pag;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
pag = xfs_perag_get(mp, agno);
|
||||||
|
ret = atomic_read(&pag->pagf_fstrms);
|
||||||
|
xfs_perag_put(pag);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
@@ -92,7 +101,13 @@ xfs_filestream_get_ag(
|
|||||||
xfs_mount_t *mp,
|
xfs_mount_t *mp,
|
||||||
xfs_agnumber_t agno)
|
xfs_agnumber_t agno)
|
||||||
{
|
{
|
||||||
return atomic_inc_return(&mp->m_perag[agno].pagf_fstrms);
|
struct xfs_perag *pag;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
pag = xfs_perag_get(mp, agno);
|
||||||
|
ret = atomic_inc_return(&pag->pagf_fstrms);
|
||||||
|
xfs_perag_put(pag);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
@@ -100,7 +115,13 @@ xfs_filestream_put_ag(
|
|||||||
xfs_mount_t *mp,
|
xfs_mount_t *mp,
|
||||||
xfs_agnumber_t agno)
|
xfs_agnumber_t agno)
|
||||||
{
|
{
|
||||||
return atomic_dec_return(&mp->m_perag[agno].pagf_fstrms);
|
struct xfs_perag *pag;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
pag = xfs_perag_get(mp, agno);
|
||||||
|
ret = atomic_dec_return(&pag->pagf_fstrms);
|
||||||
|
xfs_perag_put(pag);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* allocation selection flags */
|
/* allocation selection flags */
|
||||||
|
Reference in New Issue
Block a user