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