xfs: do not use xfs_mod_incore_sb for per-cpu counters
Export xfs_icsb_modify_counters and always use it for modifying the per-cpu counters. Remove support for per-cpu counters from xfs_mod_incore_sb to simplify it. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Alex Elder <aelder@sgi.com>
This commit is contained in:
parent
61ba35dea0
commit
96540c7858
5 changed files with 35 additions and 40 deletions
|
@ -614,7 +614,7 @@ xfs_bmap_add_extent(
|
||||||
nblks += cur->bc_private.b.allocated;
|
nblks += cur->bc_private.b.allocated;
|
||||||
ASSERT(nblks <= da_old);
|
ASSERT(nblks <= da_old);
|
||||||
if (nblks < da_old)
|
if (nblks < da_old)
|
||||||
xfs_mod_incore_sb(ip->i_mount, XFS_SBS_FDBLOCKS,
|
xfs_icsb_modify_counters(ip->i_mount, XFS_SBS_FDBLOCKS,
|
||||||
(int64_t)(da_old - nblks), rsvd);
|
(int64_t)(da_old - nblks), rsvd);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -1079,7 +1079,8 @@ xfs_bmap_add_extent_delay_real(
|
||||||
diff = (int)(temp + temp2 - startblockval(PREV.br_startblock) -
|
diff = (int)(temp + temp2 - startblockval(PREV.br_startblock) -
|
||||||
(cur ? cur->bc_private.b.allocated : 0));
|
(cur ? cur->bc_private.b.allocated : 0));
|
||||||
if (diff > 0 &&
|
if (diff > 0 &&
|
||||||
xfs_mod_incore_sb(ip->i_mount, XFS_SBS_FDBLOCKS, -((int64_t)diff), rsvd)) {
|
xfs_icsb_modify_counters(ip->i_mount, XFS_SBS_FDBLOCKS,
|
||||||
|
-((int64_t)diff), rsvd)) {
|
||||||
/*
|
/*
|
||||||
* Ick gross gag me with a spoon.
|
* Ick gross gag me with a spoon.
|
||||||
*/
|
*/
|
||||||
|
@ -1089,16 +1090,18 @@ xfs_bmap_add_extent_delay_real(
|
||||||
temp--;
|
temp--;
|
||||||
diff--;
|
diff--;
|
||||||
if (!diff ||
|
if (!diff ||
|
||||||
!xfs_mod_incore_sb(ip->i_mount,
|
!xfs_icsb_modify_counters(ip->i_mount,
|
||||||
XFS_SBS_FDBLOCKS, -((int64_t)diff), rsvd))
|
XFS_SBS_FDBLOCKS,
|
||||||
|
-((int64_t)diff), rsvd))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (temp2) {
|
if (temp2) {
|
||||||
temp2--;
|
temp2--;
|
||||||
diff--;
|
diff--;
|
||||||
if (!diff ||
|
if (!diff ||
|
||||||
!xfs_mod_incore_sb(ip->i_mount,
|
!xfs_icsb_modify_counters(ip->i_mount,
|
||||||
XFS_SBS_FDBLOCKS, -((int64_t)diff), rsvd))
|
XFS_SBS_FDBLOCKS,
|
||||||
|
-((int64_t)diff), rsvd))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1766,7 +1769,7 @@ xfs_bmap_add_extent_hole_delay(
|
||||||
}
|
}
|
||||||
if (oldlen != newlen) {
|
if (oldlen != newlen) {
|
||||||
ASSERT(oldlen > newlen);
|
ASSERT(oldlen > newlen);
|
||||||
xfs_mod_incore_sb(ip->i_mount, XFS_SBS_FDBLOCKS,
|
xfs_icsb_modify_counters(ip->i_mount, XFS_SBS_FDBLOCKS,
|
||||||
(int64_t)(oldlen - newlen), rsvd);
|
(int64_t)(oldlen - newlen), rsvd);
|
||||||
/*
|
/*
|
||||||
* Nothing to do for disk quota accounting here.
|
* Nothing to do for disk quota accounting here.
|
||||||
|
@ -3111,9 +3114,10 @@ xfs_bmap_del_extent(
|
||||||
* Nothing to do for disk quota accounting here.
|
* Nothing to do for disk quota accounting here.
|
||||||
*/
|
*/
|
||||||
ASSERT(da_old >= da_new);
|
ASSERT(da_old >= da_new);
|
||||||
if (da_old > da_new)
|
if (da_old > da_new) {
|
||||||
xfs_mod_incore_sb(mp, XFS_SBS_FDBLOCKS, (int64_t)(da_old - da_new),
|
xfs_icsb_modify_counters(mp, XFS_SBS_FDBLOCKS,
|
||||||
rsvd);
|
(int64_t)(da_old - da_new), rsvd);
|
||||||
|
}
|
||||||
done:
|
done:
|
||||||
*logflagsp = flags;
|
*logflagsp = flags;
|
||||||
return error;
|
return error;
|
||||||
|
@ -4526,13 +4530,13 @@ xfs_bmapi(
|
||||||
-((int64_t)extsz), (flags &
|
-((int64_t)extsz), (flags &
|
||||||
XFS_BMAPI_RSVBLOCKS));
|
XFS_BMAPI_RSVBLOCKS));
|
||||||
} else {
|
} else {
|
||||||
error = xfs_mod_incore_sb(mp,
|
error = xfs_icsb_modify_counters(mp,
|
||||||
XFS_SBS_FDBLOCKS,
|
XFS_SBS_FDBLOCKS,
|
||||||
-((int64_t)alen), (flags &
|
-((int64_t)alen), (flags &
|
||||||
XFS_BMAPI_RSVBLOCKS));
|
XFS_BMAPI_RSVBLOCKS));
|
||||||
}
|
}
|
||||||
if (!error) {
|
if (!error) {
|
||||||
error = xfs_mod_incore_sb(mp,
|
error = xfs_icsb_modify_counters(mp,
|
||||||
XFS_SBS_FDBLOCKS,
|
XFS_SBS_FDBLOCKS,
|
||||||
-((int64_t)indlen), (flags &
|
-((int64_t)indlen), (flags &
|
||||||
XFS_BMAPI_RSVBLOCKS));
|
XFS_BMAPI_RSVBLOCKS));
|
||||||
|
@ -4542,7 +4546,7 @@ xfs_bmapi(
|
||||||
(int64_t)extsz, (flags &
|
(int64_t)extsz, (flags &
|
||||||
XFS_BMAPI_RSVBLOCKS));
|
XFS_BMAPI_RSVBLOCKS));
|
||||||
else if (error)
|
else if (error)
|
||||||
xfs_mod_incore_sb(mp,
|
xfs_icsb_modify_counters(mp,
|
||||||
XFS_SBS_FDBLOCKS,
|
XFS_SBS_FDBLOCKS,
|
||||||
(int64_t)alen, (flags &
|
(int64_t)alen, (flags &
|
||||||
XFS_BMAPI_RSVBLOCKS));
|
XFS_BMAPI_RSVBLOCKS));
|
||||||
|
@ -5206,7 +5210,7 @@ xfs_bunmapi(
|
||||||
ip, -((long)del.br_blockcount), 0,
|
ip, -((long)del.br_blockcount), 0,
|
||||||
XFS_QMOPT_RES_RTBLKS);
|
XFS_QMOPT_RES_RTBLKS);
|
||||||
} else {
|
} else {
|
||||||
xfs_mod_incore_sb(mp, XFS_SBS_FDBLOCKS,
|
xfs_icsb_modify_counters(mp, XFS_SBS_FDBLOCKS,
|
||||||
(int64_t)del.br_blockcount, rsvd);
|
(int64_t)del.br_blockcount, rsvd);
|
||||||
(void)xfs_trans_reserve_quota_nblks(NULL,
|
(void)xfs_trans_reserve_quota_nblks(NULL,
|
||||||
ip, -((long)del.br_blockcount), 0,
|
ip, -((long)del.br_blockcount), 0,
|
||||||
|
|
|
@ -596,7 +596,8 @@ xfs_reserve_blocks(
|
||||||
* the extra reserve blocks from the reserve.....
|
* the extra reserve blocks from the reserve.....
|
||||||
*/
|
*/
|
||||||
int error;
|
int error;
|
||||||
error = xfs_mod_incore_sb(mp, XFS_SBS_FDBLOCKS, fdblks_delta, 0);
|
error = xfs_icsb_modify_counters(mp, XFS_SBS_FDBLOCKS,
|
||||||
|
fdblks_delta, 0);
|
||||||
if (error == ENOSPC)
|
if (error == ENOSPC)
|
||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,16 +52,11 @@ STATIC void xfs_icsb_balance_counter(xfs_mount_t *, xfs_sb_field_t,
|
||||||
int);
|
int);
|
||||||
STATIC void xfs_icsb_balance_counter_locked(xfs_mount_t *, xfs_sb_field_t,
|
STATIC void xfs_icsb_balance_counter_locked(xfs_mount_t *, xfs_sb_field_t,
|
||||||
int);
|
int);
|
||||||
STATIC int xfs_icsb_modify_counters(xfs_mount_t *, xfs_sb_field_t,
|
|
||||||
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);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define xfs_icsb_balance_counter(mp, a, b) 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_balance_counter_locked(mp, a, b) do { } while (0)
|
||||||
#define xfs_icsb_modify_counters(mp, a, b, c) do { } while (0)
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const struct {
|
static const struct {
|
||||||
|
@ -1843,28 +1838,19 @@ xfs_mod_incore_sb_unlocked(
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xfs_mod_incore_sb(
|
xfs_mod_incore_sb(
|
||||||
xfs_mount_t *mp,
|
struct xfs_mount *mp,
|
||||||
xfs_sb_field_t field,
|
xfs_sb_field_t field,
|
||||||
int64_t delta,
|
int64_t delta,
|
||||||
int rsvd)
|
int rsvd)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
/* check for per-cpu counters */
|
|
||||||
switch (field) {
|
|
||||||
#ifdef HAVE_PERCPU_SB
|
#ifdef HAVE_PERCPU_SB
|
||||||
case XFS_SBS_ICOUNT:
|
ASSERT(field < XFS_SBS_ICOUNT || field > XFS_SBS_FDBLOCKS);
|
||||||
case XFS_SBS_IFREE:
|
|
||||||
case XFS_SBS_FDBLOCKS:
|
|
||||||
status = xfs_icsb_modify_counters(mp, field, delta, rsvd);
|
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
default:
|
spin_lock(&mp->m_sb_lock);
|
||||||
spin_lock(&mp->m_sb_lock);
|
status = xfs_mod_incore_sb_unlocked(mp, field, delta, rsvd);
|
||||||
status = xfs_mod_incore_sb_unlocked(mp, field, delta, rsvd);
|
spin_unlock(&mp->m_sb_lock);
|
||||||
spin_unlock(&mp->m_sb_lock);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,6 +91,8 @@ extern void xfs_icsb_reinit_counters(struct xfs_mount *);
|
||||||
extern void xfs_icsb_destroy_counters(struct xfs_mount *);
|
extern void xfs_icsb_destroy_counters(struct xfs_mount *);
|
||||||
extern void xfs_icsb_sync_counters(struct xfs_mount *, int);
|
extern void xfs_icsb_sync_counters(struct xfs_mount *, int);
|
||||||
extern void xfs_icsb_sync_counters_locked(struct xfs_mount *, int);
|
extern void xfs_icsb_sync_counters_locked(struct xfs_mount *, int);
|
||||||
|
extern int xfs_icsb_modify_counters(struct xfs_mount *, xfs_sb_field_t,
|
||||||
|
int64_t, int);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define xfs_icsb_init_counters(mp) (0)
|
#define xfs_icsb_init_counters(mp) (0)
|
||||||
|
@ -98,6 +100,8 @@ extern void xfs_icsb_sync_counters_locked(struct xfs_mount *, int);
|
||||||
#define xfs_icsb_reinit_counters(mp) do { } while (0)
|
#define xfs_icsb_reinit_counters(mp) do { } while (0)
|
||||||
#define xfs_icsb_sync_counters(mp, flags) do { } while (0)
|
#define xfs_icsb_sync_counters(mp, flags) do { } while (0)
|
||||||
#define xfs_icsb_sync_counters_locked(mp, flags) do { } while (0)
|
#define xfs_icsb_sync_counters_locked(mp, flags) do { } while (0)
|
||||||
|
#define xfs_icsb_modify_counters(mp, field, delta, rsvd) \
|
||||||
|
xfs_mod_incore_sb(mp, field, delta, rsvd)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct xfs_mount {
|
typedef struct xfs_mount {
|
||||||
|
|
|
@ -696,7 +696,7 @@ xfs_trans_reserve(
|
||||||
* fail if the count would go below zero.
|
* fail if the count would go below zero.
|
||||||
*/
|
*/
|
||||||
if (blocks > 0) {
|
if (blocks > 0) {
|
||||||
error = xfs_mod_incore_sb(tp->t_mountp, XFS_SBS_FDBLOCKS,
|
error = xfs_icsb_modify_counters(tp->t_mountp, XFS_SBS_FDBLOCKS,
|
||||||
-((int64_t)blocks), rsvd);
|
-((int64_t)blocks), rsvd);
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS);
|
current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS);
|
||||||
|
@ -767,7 +767,7 @@ xfs_trans_reserve(
|
||||||
|
|
||||||
undo_blocks:
|
undo_blocks:
|
||||||
if (blocks > 0) {
|
if (blocks > 0) {
|
||||||
(void) xfs_mod_incore_sb(tp->t_mountp, XFS_SBS_FDBLOCKS,
|
xfs_icsb_modify_counters(tp->t_mountp, XFS_SBS_FDBLOCKS,
|
||||||
(int64_t)blocks, rsvd);
|
(int64_t)blocks, rsvd);
|
||||||
tp->t_blk_res = 0;
|
tp->t_blk_res = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue