aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_mount.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2008-04-22 03:34:44 -0400
committerLachlan McIlroy <lachlan@redback.melbourne.sgi.com>2008-04-29 01:57:28 -0400
commit45af6c6de6453b385c80555c0ee40ab5fc4a033b (patch)
tree713d4b2c291f5a5d9751416bf8bd3ba51be920b6 /fs/xfs/xfs_mount.c
parentd4d90b577ee5af5c1b29bd693aca026a77a1a2f1 (diff)
[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>
Diffstat (limited to 'fs/xfs/xfs_mount.c')
-rw-r--r--fs/xfs/xfs_mount.c58
1 files changed, 31 insertions, 27 deletions
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index a2fad07fd844..8bdc16381bc5 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -54,7 +54,9 @@ STATIC void xfs_unmountfs_wait(xfs_mount_t *);
54#ifdef HAVE_PERCPU_SB 54#ifdef HAVE_PERCPU_SB
55STATIC void xfs_icsb_destroy_counters(xfs_mount_t *); 55STATIC void xfs_icsb_destroy_counters(xfs_mount_t *);
56STATIC void xfs_icsb_balance_counter(xfs_mount_t *, xfs_sb_field_t, 56STATIC void xfs_icsb_balance_counter(xfs_mount_t *, xfs_sb_field_t,
57 int, int); 57 int);
58STATIC void xfs_icsb_balance_counter_locked(xfs_mount_t *, xfs_sb_field_t,
59 int);
58STATIC int xfs_icsb_modify_counters(xfs_mount_t *, xfs_sb_field_t, 60STATIC int xfs_icsb_modify_counters(xfs_mount_t *, xfs_sb_field_t,
59 int64_t, int); 61 int64_t, int);
60STATIC void xfs_icsb_disable_counter(xfs_mount_t *, xfs_sb_field_t); 62STATIC 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);
62#else 64#else
63 65
64#define xfs_icsb_destroy_counters(mp) do { } while (0) 66#define xfs_icsb_destroy_counters(mp) do { } while (0)
65#define xfs_icsb_balance_counter(mp, a, b, c) do { } while (0) 67#define xfs_icsb_balance_counter(mp, a, b) do { } while (0)
68#define xfs_icsb_balance_counter_locked(mp, a, b) do { } while (0)
66#define xfs_icsb_modify_counters(mp, a, b, c) do { } while (0) 69#define xfs_icsb_modify_counters(mp, a, b, c) do { } while (0)
67 70
68#endif 71#endif
@@ -2024,9 +2027,9 @@ xfs_icsb_cpu_notify(
2024 case CPU_ONLINE: 2027 case CPU_ONLINE:
2025 case CPU_ONLINE_FROZEN: 2028 case CPU_ONLINE_FROZEN:
2026 xfs_icsb_lock(mp); 2029 xfs_icsb_lock(mp);
2027 xfs_icsb_balance_counter(mp, XFS_SBS_ICOUNT, 0, 0); 2030 xfs_icsb_balance_counter(mp, XFS_SBS_ICOUNT, 0);
2028 xfs_icsb_balance_counter(mp, XFS_SBS_IFREE, 0, 0); 2031 xfs_icsb_balance_counter(mp, XFS_SBS_IFREE, 0);
2029 xfs_icsb_balance_counter(mp, XFS_SBS_FDBLOCKS, 0, 0); 2032 xfs_icsb_balance_counter(mp, XFS_SBS_FDBLOCKS, 0);
2030 xfs_icsb_unlock(mp); 2033 xfs_icsb_unlock(mp);
2031 break; 2034 break;
2032 case CPU_DEAD: 2035 case CPU_DEAD:
@@ -2046,12 +2049,9 @@ xfs_icsb_cpu_notify(
2046 2049
2047 memset(cntp, 0, sizeof(xfs_icsb_cnts_t)); 2050 memset(cntp, 0, sizeof(xfs_icsb_cnts_t));
2048 2051
2049 xfs_icsb_balance_counter(mp, XFS_SBS_ICOUNT, 2052 xfs_icsb_balance_counter_locked(mp, XFS_SBS_ICOUNT, 0);
2050 XFS_ICSB_SB_LOCKED, 0); 2053 xfs_icsb_balance_counter_locked(mp, XFS_SBS_IFREE, 0);
2051 xfs_icsb_balance_counter(mp, XFS_SBS_IFREE, 2054 xfs_icsb_balance_counter_locked(mp, XFS_SBS_FDBLOCKS, 0);
2052 XFS_ICSB_SB_LOCKED, 0);
2053 xfs_icsb_balance_counter(mp, XFS_SBS_FDBLOCKS,
2054 XFS_ICSB_SB_LOCKED, 0);
2055 spin_unlock(&mp->m_sb_lock); 2055 spin_unlock(&mp->m_sb_lock);
2056 xfs_icsb_unlock(mp); 2056 xfs_icsb_unlock(mp);
2057 break; 2057 break;
@@ -2103,9 +2103,9 @@ xfs_icsb_reinit_counters(
2103 * initial balance kicks us off correctly 2103 * initial balance kicks us off correctly
2104 */ 2104 */
2105 mp->m_icsb_counters = -1; 2105 mp->m_icsb_counters = -1;
2106 xfs_icsb_balance_counter(mp, XFS_SBS_ICOUNT, 0, 0); 2106 xfs_icsb_balance_counter(mp, XFS_SBS_ICOUNT, 0);
2107 xfs_icsb_balance_counter(mp, XFS_SBS_IFREE, 0, 0); 2107 xfs_icsb_balance_counter(mp, XFS_SBS_IFREE, 0);
2108 xfs_icsb_balance_counter(mp, XFS_SBS_FDBLOCKS, 0, 0); 2108 xfs_icsb_balance_counter(mp, XFS_SBS_FDBLOCKS, 0);
2109 xfs_icsb_unlock(mp); 2109 xfs_icsb_unlock(mp);
2110} 2110}
2111 2111
@@ -2325,19 +2325,15 @@ xfs_icsb_sync_counters(
2325#define XFS_ICSB_FDBLK_CNTR_REENABLE(mp) \ 2325#define XFS_ICSB_FDBLK_CNTR_REENABLE(mp) \
2326 (uint64_t)(512 + XFS_ALLOC_SET_ASIDE(mp)) 2326 (uint64_t)(512 + XFS_ALLOC_SET_ASIDE(mp))
2327STATIC void 2327STATIC void
2328xfs_icsb_balance_counter( 2328xfs_icsb_balance_counter_locked(
2329 xfs_mount_t *mp, 2329 xfs_mount_t *mp,
2330 xfs_sb_field_t field, 2330 xfs_sb_field_t field,
2331 int flags,
2332 int min_per_cpu) 2331 int min_per_cpu)
2333{ 2332{
2334 uint64_t count, resid; 2333 uint64_t count, resid;
2335 int weight = num_online_cpus(); 2334 int weight = num_online_cpus();
2336 uint64_t min = (uint64_t)min_per_cpu; 2335 uint64_t min = (uint64_t)min_per_cpu;
2337 2336
2338 if (!(flags & XFS_ICSB_SB_LOCKED))
2339 spin_lock(&mp->m_sb_lock);
2340
2341 /* disable counter and sync counter */ 2337 /* disable counter and sync counter */
2342 xfs_icsb_disable_counter(mp, field); 2338 xfs_icsb_disable_counter(mp, field);
2343 2339
@@ -2347,19 +2343,19 @@ xfs_icsb_balance_counter(
2347 count = mp->m_sb.sb_icount; 2343 count = mp->m_sb.sb_icount;
2348 resid = do_div(count, weight); 2344 resid = do_div(count, weight);
2349 if (count < max(min, XFS_ICSB_INO_CNTR_REENABLE)) 2345 if (count < max(min, XFS_ICSB_INO_CNTR_REENABLE))
2350 goto out; 2346 return;
2351 break; 2347 break;
2352 case XFS_SBS_IFREE: 2348 case XFS_SBS_IFREE:
2353 count = mp->m_sb.sb_ifree; 2349 count = mp->m_sb.sb_ifree;
2354 resid = do_div(count, weight); 2350 resid = do_div(count, weight);
2355 if (count < max(min, XFS_ICSB_INO_CNTR_REENABLE)) 2351 if (count < max(min, XFS_ICSB_INO_CNTR_REENABLE))
2356 goto out; 2352 return;
2357 break; 2353 break;
2358 case XFS_SBS_FDBLOCKS: 2354 case XFS_SBS_FDBLOCKS:
2359 count = mp->m_sb.sb_fdblocks; 2355 count = mp->m_sb.sb_fdblocks;
2360 resid = do_div(count, weight); 2356 resid = do_div(count, weight);
2361 if (count < max(min, XFS_ICSB_FDBLK_CNTR_REENABLE(mp))) 2357 if (count < max(min, XFS_ICSB_FDBLK_CNTR_REENABLE(mp)))
2362 goto out; 2358 return;
2363 break; 2359 break;
2364 default: 2360 default:
2365 BUG(); 2361 BUG();
@@ -2368,9 +2364,17 @@ xfs_icsb_balance_counter(
2368 } 2364 }
2369 2365
2370 xfs_icsb_enable_counter(mp, field, count, resid); 2366 xfs_icsb_enable_counter(mp, field, count, resid);
2371out: 2367}
2372 if (!(flags & XFS_ICSB_SB_LOCKED)) 2368
2373 spin_unlock(&mp->m_sb_lock); 2369STATIC void
2370xfs_icsb_balance_counter(
2371 xfs_mount_t *mp,
2372 xfs_sb_field_t fields,
2373 int min_per_cpu)
2374{
2375 spin_lock(&mp->m_sb_lock);
2376 xfs_icsb_balance_counter_locked(mp, fields, min_per_cpu);
2377 spin_unlock(&mp->m_sb_lock);
2374} 2378}
2375 2379
2376STATIC int 2380STATIC int
@@ -2477,7 +2481,7 @@ slow_path:
2477 * we are done. 2481 * we are done.
2478 */ 2482 */
2479 if (ret != ENOSPC) 2483 if (ret != ENOSPC)
2480 xfs_icsb_balance_counter(mp, field, 0, 0); 2484 xfs_icsb_balance_counter(mp, field, 0);
2481 xfs_icsb_unlock(mp); 2485 xfs_icsb_unlock(mp);
2482 return ret; 2486 return ret;
2483 2487
@@ -2501,7 +2505,7 @@ balance_counter:
2501 * will either succeed through the fast path or slow path without 2505 * will either succeed through the fast path or slow path without
2502 * another balance operation being required. 2506 * another balance operation being required.
2503 */ 2507 */
2504 xfs_icsb_balance_counter(mp, field, 0, delta); 2508 xfs_icsb_balance_counter(mp, field, delta);
2505 xfs_icsb_unlock(mp); 2509 xfs_icsb_unlock(mp);
2506 goto again; 2510 goto again;
2507} 2511}