Commit 40198cf1 authored by Christoph Hellwig's avatar Christoph Hellwig

[XFS] remove atomicIncWithWrap

SGI Modid: 2.5.x-xfs:slinx:143647a
parent 8f7d3b53
......@@ -48,11 +48,6 @@ unsigned long xfs_physmem;
*/
xfs_param_t xfs_params = { 0, 1, 0, 0, 0, 3 };
/*
* Used to serialize atomicIncWithWrap.
*/
spinlock_t xfs_atomic_spin = SPIN_LOCK_UNLOCKED;
/*
* Global system credential structure.
*/
......
......@@ -38,11 +38,7 @@
*/
extern uint64_t xfs_panic_mask; /* set to cause more panics */
extern unsigned long xfs_physmem;
extern spinlock_t xfs_atomic_spin;
extern struct cred *sys_cred;
#endif /* __XFS_GLOBALS_H__ */
......@@ -37,7 +37,6 @@
#include "kmem.h"
#include "spin.h"
#include "debug.h"
#include "atomic.h"
#include "ktrace.h"
#if (defined(DEBUG) || defined(CONFIG_XFS_VNODE_TRACING))
......@@ -181,6 +180,7 @@ ktrace_enter(
void *val14,
void *val15)
{
static lock_t wrap_lock = SPIN_LOCK_UNLOCKED;
int index;
ktrace_entry_t *ktep;
......@@ -189,7 +189,11 @@ ktrace_enter(
/*
* Grab an entry by pushing the index up to the next one.
*/
index = atomicIncWithWrap(&ktp->kt_index, ktp->kt_nentries);
spin_lock(&wrap_lock);
index = ktp->kt_index;
if (++ktp->kt_index == ktp->kt_nentries)
ktp->kt_index = 0;
spin_unlock(&wrap_lock);
if (!ktp->kt_rollover && index == ktp->kt_nentries - 1)
ktp->kt_rollover = 1;
......
......@@ -46,7 +46,6 @@
#include <support/ktrace.h>
#include <support/mutex.h>
#include <support/sema.h>
#include <support/atomic.h>
#include <support/debug.h>
#include <support/move.h>
#include <support/uuid.h>
......
......@@ -336,6 +336,21 @@ xfs_ialloc_ag_alloc(
return 0;
}
STATIC __inline xfs_agnumber_t
xfs_ialloc_next_ag(
xfs_mount_t *mp)
{
xfs_agnumber_t agno;
spin_lock(&mp->m_agirotor_lock);
agno = mp->m_agirotor;
if (++mp->m_agirotor == mp->m_maxagi)
mp->m_agirotor = 0;
spin_unlock(&mp->m_agirotor_lock);
return agno;
}
/*
* Select an allocation group to look for a free inode in, based on the parent
* inode and then mode. Return the allocation group buffer.
......@@ -366,7 +381,7 @@ xfs_ialloc_ag_select(
mp = tp->t_mountp;
agcount = mp->m_maxagi;
if (S_ISDIR(mode))
pagno = atomicIncWithWrap((int *)&mp->m_agirotor, agcount);
pagno = xfs_ialloc_next_ag(mp);
else {
pagno = XFS_INO_TO_AGNO(mp, parent);
if (pagno >= agcount)
......@@ -394,7 +409,7 @@ xfs_ialloc_ag_select(
agbp = NULL;
if (!pag->pagi_inodeok) {
atomicIncWithWrap((int *)&mp->m_agirotor, agcount);
xfs_ialloc_next_ag(mp);
goto unlock_nextag;
}
......
......@@ -509,6 +509,7 @@ xfs_mount_common(xfs_mount_t *mp, xfs_sb_t *sbp)
int i;
mp->m_agfrotor = mp->m_agirotor = 0;
spinlock_init(&mp->m_agirotor_lock, "m_agirotor_lock");
mp->m_maxagi = mp->m_sb.sb_agcount;
mp->m_blkbit_log = sbp->sb_blocklog + XFS_NBBYLOG;
mp->m_blkbb_log = sbp->sb_blocklog - BBSHIFT;
......
......@@ -291,6 +291,7 @@ typedef struct xfs_mount {
int m_bsize; /* fs logical block size */
xfs_agnumber_t m_agfrotor; /* last ag where space found */
xfs_agnumber_t m_agirotor; /* last ag dir inode alloced */
lock_t m_agirotor_lock;/* .. and lock protecting it */
xfs_agnumber_t m_maxagi; /* highest inode alloc group */
int m_ihsize; /* size of next field */
struct xfs_ihash *m_ihash; /* fs private inode hash table*/
......
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