[XFS] split xfs_icsb_balance_counter
Add an xfs_icsb_balance_counter_locked for the case where mp->m_sb_lock is already locked. SGI-PV: 976035 SGI-Modid: xfs-linux-melb:xfs-kern:30918a Signed-off-by: Christoph Hellwig <hch@infradead.org> Signed-off-by: David Chinner <dgc@sgi.com> Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
This commit is contained in:
parent
d4d90b577e
commit
45af6c6de6
|
@ -54,7 +54,9 @@ STATIC void xfs_unmountfs_wait(xfs_mount_t *);
|
||||||
#ifdef HAVE_PERCPU_SB
|
#ifdef HAVE_PERCPU_SB
|
||||||
STATIC void xfs_icsb_destroy_counters(xfs_mount_t *);
|
STATIC void xfs_icsb_destroy_counters(xfs_mount_t *);
|
||||||
STATIC void xfs_icsb_balance_counter(xfs_mount_t *, xfs_sb_field_t,
|
STATIC void xfs_icsb_balance_counter(xfs_mount_t *, xfs_sb_field_t,
|
||||||
int, int);
|
int);
|
||||||
|
STATIC void xfs_icsb_balance_counter_locked(xfs_mount_t *, xfs_sb_field_t,
|
||||||
|
int);
|
||||||
STATIC int xfs_icsb_modify_counters(xfs_mount_t *, xfs_sb_field_t,
|
STATIC int xfs_icsb_modify_counters(xfs_mount_t *, xfs_sb_field_t,
|
||||||
int64_t, int);
|
int64_t, int);
|
||||||
STATIC void xfs_icsb_disable_counter(xfs_mount_t *, xfs_sb_field_t);
|
STATIC void xfs_icsb_disable_counter(xfs_mount_t *, xfs_sb_field_t);
|
||||||
|
@ -62,7 +64,8 @@ STATIC void xfs_icsb_disable_counter(xfs_mount_t *, xfs_sb_field_t);
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define xfs_icsb_destroy_counters(mp) do { } while (0)
|
#define xfs_icsb_destroy_counters(mp) do { } while (0)
|
||||||
#define xfs_icsb_balance_counter(mp, a, b, c) do { } while (0)
|
#define xfs_icsb_balance_counter(mp, a, b) do { } while (0)
|
||||||
|
#define xfs_icsb_balance_counter_locked(mp, a, b) do { } while (0)
|
||||||
#define xfs_icsb_modify_counters(mp, a, b, c) do { } while (0)
|
#define xfs_icsb_modify_counters(mp, a, b, c) do { } while (0)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -2024,9 +2027,9 @@ xfs_icsb_cpu_notify(
|
||||||
case CPU_ONLINE:
|
case CPU_ONLINE:
|
||||||
case CPU_ONLINE_FROZEN:
|
case CPU_ONLINE_FROZEN:
|
||||||
xfs_icsb_lock(mp);
|
xfs_icsb_lock(mp);
|
||||||
xfs_icsb_balance_counter(mp, XFS_SBS_ICOUNT, 0, 0);
|
xfs_icsb_balance_counter(mp, XFS_SBS_ICOUNT, 0);
|
||||||
xfs_icsb_balance_counter(mp, XFS_SBS_IFREE, 0, 0);
|
xfs_icsb_balance_counter(mp, XFS_SBS_IFREE, 0);
|
||||||
xfs_icsb_balance_counter(mp, XFS_SBS_FDBLOCKS, 0, 0);
|
xfs_icsb_balance_counter(mp, XFS_SBS_FDBLOCKS, 0);
|
||||||
xfs_icsb_unlock(mp);
|
xfs_icsb_unlock(mp);
|
||||||
break;
|
break;
|
||||||
case CPU_DEAD:
|
case CPU_DEAD:
|
||||||
|
@ -2046,12 +2049,9 @@ xfs_icsb_cpu_notify(
|
||||||
|
|
||||||
memset(cntp, 0, sizeof(xfs_icsb_cnts_t));
|
memset(cntp, 0, sizeof(xfs_icsb_cnts_t));
|
||||||
|
|
||||||
xfs_icsb_balance_counter(mp, XFS_SBS_ICOUNT,
|
xfs_icsb_balance_counter_locked(mp, XFS_SBS_ICOUNT, 0);
|
||||||
XFS_ICSB_SB_LOCKED, 0);
|
xfs_icsb_balance_counter_locked(mp, XFS_SBS_IFREE, 0);
|
||||||
xfs_icsb_balance_counter(mp, XFS_SBS_IFREE,
|
xfs_icsb_balance_counter_locked(mp, XFS_SBS_FDBLOCKS, 0);
|
||||||
XFS_ICSB_SB_LOCKED, 0);
|
|
||||||
xfs_icsb_balance_counter(mp, XFS_SBS_FDBLOCKS,
|
|
||||||
XFS_ICSB_SB_LOCKED, 0);
|
|
||||||
spin_unlock(&mp->m_sb_lock);
|
spin_unlock(&mp->m_sb_lock);
|
||||||
xfs_icsb_unlock(mp);
|
xfs_icsb_unlock(mp);
|
||||||
break;
|
break;
|
||||||
|
@ -2103,9 +2103,9 @@ xfs_icsb_reinit_counters(
|
||||||
* initial balance kicks us off correctly
|
* initial balance kicks us off correctly
|
||||||
*/
|
*/
|
||||||
mp->m_icsb_counters = -1;
|
mp->m_icsb_counters = -1;
|
||||||
xfs_icsb_balance_counter(mp, XFS_SBS_ICOUNT, 0, 0);
|
xfs_icsb_balance_counter(mp, XFS_SBS_ICOUNT, 0);
|
||||||
xfs_icsb_balance_counter(mp, XFS_SBS_IFREE, 0, 0);
|
xfs_icsb_balance_counter(mp, XFS_SBS_IFREE, 0);
|
||||||
xfs_icsb_balance_counter(mp, XFS_SBS_FDBLOCKS, 0, 0);
|
xfs_icsb_balance_counter(mp, XFS_SBS_FDBLOCKS, 0);
|
||||||
xfs_icsb_unlock(mp);
|
xfs_icsb_unlock(mp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2325,19 +2325,15 @@ xfs_icsb_sync_counters(
|
||||||
#define XFS_ICSB_FDBLK_CNTR_REENABLE(mp) \
|
#define XFS_ICSB_FDBLK_CNTR_REENABLE(mp) \
|
||||||
(uint64_t)(512 + XFS_ALLOC_SET_ASIDE(mp))
|
(uint64_t)(512 + XFS_ALLOC_SET_ASIDE(mp))
|
||||||
STATIC void
|
STATIC void
|
||||||
xfs_icsb_balance_counter(
|
xfs_icsb_balance_counter_locked(
|
||||||
xfs_mount_t *mp,
|
xfs_mount_t *mp,
|
||||||
xfs_sb_field_t field,
|
xfs_sb_field_t field,
|
||||||
int flags,
|
|
||||||
int min_per_cpu)
|
int min_per_cpu)
|
||||||
{
|
{
|
||||||
uint64_t count, resid;
|
uint64_t count, resid;
|
||||||
int weight = num_online_cpus();
|
int weight = num_online_cpus();
|
||||||
uint64_t min = (uint64_t)min_per_cpu;
|
uint64_t min = (uint64_t)min_per_cpu;
|
||||||
|
|
||||||
if (!(flags & XFS_ICSB_SB_LOCKED))
|
|
||||||
spin_lock(&mp->m_sb_lock);
|
|
||||||
|
|
||||||
/* disable counter and sync counter */
|
/* disable counter and sync counter */
|
||||||
xfs_icsb_disable_counter(mp, field);
|
xfs_icsb_disable_counter(mp, field);
|
||||||
|
|
||||||
|
@ -2347,19 +2343,19 @@ xfs_icsb_balance_counter(
|
||||||
count = mp->m_sb.sb_icount;
|
count = mp->m_sb.sb_icount;
|
||||||
resid = do_div(count, weight);
|
resid = do_div(count, weight);
|
||||||
if (count < max(min, XFS_ICSB_INO_CNTR_REENABLE))
|
if (count < max(min, XFS_ICSB_INO_CNTR_REENABLE))
|
||||||
goto out;
|
return;
|
||||||
break;
|
break;
|
||||||
case XFS_SBS_IFREE:
|
case XFS_SBS_IFREE:
|
||||||
count = mp->m_sb.sb_ifree;
|
count = mp->m_sb.sb_ifree;
|
||||||
resid = do_div(count, weight);
|
resid = do_div(count, weight);
|
||||||
if (count < max(min, XFS_ICSB_INO_CNTR_REENABLE))
|
if (count < max(min, XFS_ICSB_INO_CNTR_REENABLE))
|
||||||
goto out;
|
return;
|
||||||
break;
|
break;
|
||||||
case XFS_SBS_FDBLOCKS:
|
case XFS_SBS_FDBLOCKS:
|
||||||
count = mp->m_sb.sb_fdblocks;
|
count = mp->m_sb.sb_fdblocks;
|
||||||
resid = do_div(count, weight);
|
resid = do_div(count, weight);
|
||||||
if (count < max(min, XFS_ICSB_FDBLK_CNTR_REENABLE(mp)))
|
if (count < max(min, XFS_ICSB_FDBLK_CNTR_REENABLE(mp)))
|
||||||
goto out;
|
return;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
BUG();
|
BUG();
|
||||||
|
@ -2368,9 +2364,17 @@ xfs_icsb_balance_counter(
|
||||||
}
|
}
|
||||||
|
|
||||||
xfs_icsb_enable_counter(mp, field, count, resid);
|
xfs_icsb_enable_counter(mp, field, count, resid);
|
||||||
out:
|
}
|
||||||
if (!(flags & XFS_ICSB_SB_LOCKED))
|
|
||||||
spin_unlock(&mp->m_sb_lock);
|
STATIC void
|
||||||
|
xfs_icsb_balance_counter(
|
||||||
|
xfs_mount_t *mp,
|
||||||
|
xfs_sb_field_t fields,
|
||||||
|
int min_per_cpu)
|
||||||
|
{
|
||||||
|
spin_lock(&mp->m_sb_lock);
|
||||||
|
xfs_icsb_balance_counter_locked(mp, fields, min_per_cpu);
|
||||||
|
spin_unlock(&mp->m_sb_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC int
|
STATIC int
|
||||||
|
@ -2477,7 +2481,7 @@ slow_path:
|
||||||
* we are done.
|
* we are done.
|
||||||
*/
|
*/
|
||||||
if (ret != ENOSPC)
|
if (ret != ENOSPC)
|
||||||
xfs_icsb_balance_counter(mp, field, 0, 0);
|
xfs_icsb_balance_counter(mp, field, 0);
|
||||||
xfs_icsb_unlock(mp);
|
xfs_icsb_unlock(mp);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
@ -2501,7 +2505,7 @@ balance_counter:
|
||||||
* will either succeed through the fast path or slow path without
|
* will either succeed through the fast path or slow path without
|
||||||
* another balance operation being required.
|
* another balance operation being required.
|
||||||
*/
|
*/
|
||||||
xfs_icsb_balance_counter(mp, field, 0, delta);
|
xfs_icsb_balance_counter(mp, field, delta);
|
||||||
xfs_icsb_unlock(mp);
|
xfs_icsb_unlock(mp);
|
||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue