From 40198cf1716155f25cc8c78579e966da955dceeb Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 7 Apr 2003 23:36:15 +0200 Subject: [PATCH] [XFS] remove atomicIncWithWrap SGI Modid: 2.5.x-xfs:slinx:143647a --- fs/xfs/linux/xfs_globals.c | 5 ----- fs/xfs/linux/xfs_globals.h | 4 ---- fs/xfs/support/ktrace.c | 8 ++++++-- fs/xfs/xfs.h | 1 - fs/xfs/xfs_ialloc.c | 19 +++++++++++++++++-- fs/xfs/xfs_mount.c | 1 + fs/xfs/xfs_mount.h | 1 + 7 files changed, 25 insertions(+), 14 deletions(-) diff --git a/fs/xfs/linux/xfs_globals.c b/fs/xfs/linux/xfs_globals.c index 21ac11aecd993..da5d0fe00b630 100644 --- a/fs/xfs/linux/xfs_globals.c +++ b/fs/xfs/linux/xfs_globals.c @@ -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. */ diff --git a/fs/xfs/linux/xfs_globals.h b/fs/xfs/linux/xfs_globals.h index 190e0717617ce..42d9f3ac180aa 100644 --- a/fs/xfs/linux/xfs_globals.h +++ b/fs/xfs/linux/xfs_globals.h @@ -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__ */ diff --git a/fs/xfs/support/ktrace.c b/fs/xfs/support/ktrace.c index 99743764a5033..35fdea9d0305d 100644 --- a/fs/xfs/support/ktrace.c +++ b/fs/xfs/support/ktrace.c @@ -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; diff --git a/fs/xfs/xfs.h b/fs/xfs/xfs.h index 0c869d102fd0b..5b9cbb8b50268 100644 --- a/fs/xfs/xfs.h +++ b/fs/xfs/xfs.h @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c index ff6f1d982b9cd..405f2e7132fe5 100644 --- a/fs/xfs/xfs_ialloc.c +++ b/fs/xfs/xfs_ialloc.c @@ -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; } diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index c3f64fb7711f4..22d497b2b898f 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c @@ -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; diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index 62f598e4d5333..ca274d6e242fb 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h @@ -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*/ -- 2.53.0