mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
xfs: factor out a generic xfs_group structure
Split the lookup and refcount handling of struct xfs_perag into an embedded xfs_group structure that can be reused for the upcoming realtime groups. It will be extended with more features later. Note that he xg_type field will only need a single bit even with realtime group support. For now it fills a hole, but it might be worth to fold it into another field if we can use this space better. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
This commit is contained in:
committed by
Darrick J. Wong
parent
0a4d79741d
commit
e9c4d8bfb2
@@ -14,6 +14,7 @@ xfs-y += xfs_trace.o
|
||||
|
||||
# build the libxfs code first
|
||||
xfs-y += $(addprefix libxfs/, \
|
||||
xfs_group.o \
|
||||
xfs_ag.o \
|
||||
xfs_alloc.o \
|
||||
xfs_alloc_btree.o \
|
||||
|
||||
+27
-112
@@ -30,85 +30,7 @@
|
||||
#include "xfs_trace.h"
|
||||
#include "xfs_inode.h"
|
||||
#include "xfs_icache.h"
|
||||
|
||||
|
||||
/*
|
||||
* Passive reference counting access wrappers to the perag structures. If the
|
||||
* per-ag structure is to be freed, the freeing code is responsible for cleaning
|
||||
* up objects with passive references before freeing the structure. This is
|
||||
* things like cached buffers.
|
||||
*/
|
||||
struct xfs_perag *
|
||||
xfs_perag_get(
|
||||
struct xfs_mount *mp,
|
||||
xfs_agnumber_t agno)
|
||||
{
|
||||
struct xfs_perag *pag;
|
||||
|
||||
rcu_read_lock();
|
||||
pag = xa_load(&mp->m_perags, agno);
|
||||
if (pag) {
|
||||
trace_xfs_perag_get(pag, _RET_IP_);
|
||||
ASSERT(atomic_read(&pag->pag_ref) >= 0);
|
||||
atomic_inc(&pag->pag_ref);
|
||||
}
|
||||
rcu_read_unlock();
|
||||
return pag;
|
||||
}
|
||||
|
||||
/* Get a passive reference to the given perag. */
|
||||
struct xfs_perag *
|
||||
xfs_perag_hold(
|
||||
struct xfs_perag *pag)
|
||||
{
|
||||
ASSERT(atomic_read(&pag->pag_ref) > 0 ||
|
||||
atomic_read(&pag->pag_active_ref) > 0);
|
||||
|
||||
trace_xfs_perag_hold(pag, _RET_IP_);
|
||||
atomic_inc(&pag->pag_ref);
|
||||
return pag;
|
||||
}
|
||||
|
||||
void
|
||||
xfs_perag_put(
|
||||
struct xfs_perag *pag)
|
||||
{
|
||||
trace_xfs_perag_put(pag, _RET_IP_);
|
||||
ASSERT(atomic_read(&pag->pag_ref) > 0);
|
||||
atomic_dec(&pag->pag_ref);
|
||||
}
|
||||
|
||||
/*
|
||||
* Active references for perag structures. This is for short term access to the
|
||||
* per ag structures for walking trees or accessing state. If an AG is being
|
||||
* shrunk or is offline, then this will fail to find that AG and return NULL
|
||||
* instead.
|
||||
*/
|
||||
struct xfs_perag *
|
||||
xfs_perag_grab(
|
||||
struct xfs_mount *mp,
|
||||
xfs_agnumber_t agno)
|
||||
{
|
||||
struct xfs_perag *pag;
|
||||
|
||||
rcu_read_lock();
|
||||
pag = xa_load(&mp->m_perags, agno);
|
||||
if (pag) {
|
||||
trace_xfs_perag_grab(pag, _RET_IP_);
|
||||
if (!atomic_inc_not_zero(&pag->pag_active_ref))
|
||||
pag = NULL;
|
||||
}
|
||||
rcu_read_unlock();
|
||||
return pag;
|
||||
}
|
||||
|
||||
void
|
||||
xfs_perag_rele(
|
||||
struct xfs_perag *pag)
|
||||
{
|
||||
trace_xfs_perag_rele(pag, _RET_IP_);
|
||||
atomic_dec(&pag->pag_active_ref);
|
||||
}
|
||||
#include "xfs_group.h"
|
||||
|
||||
/*
|
||||
* xfs_initialize_perag_data
|
||||
@@ -183,6 +105,19 @@ out:
|
||||
return error;
|
||||
}
|
||||
|
||||
static void
|
||||
xfs_perag_uninit(
|
||||
struct xfs_group *xg)
|
||||
{
|
||||
#ifdef __KERNEL__
|
||||
struct xfs_perag *pag = to_perag(xg);
|
||||
|
||||
xfs_defer_drain_free(&pag->pag_intents_drain);
|
||||
cancel_delayed_work_sync(&pag->pag_blockgc_work);
|
||||
xfs_buf_cache_destroy(&pag->pag_bcache);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Free up the per-ag resources within the specified AG range.
|
||||
*/
|
||||
@@ -195,22 +130,8 @@ xfs_free_perag_range(
|
||||
{
|
||||
xfs_agnumber_t agno;
|
||||
|
||||
for (agno = first_agno; agno < end_agno; agno++) {
|
||||
struct xfs_perag *pag = xa_erase(&mp->m_perags, agno);
|
||||
|
||||
ASSERT(pag);
|
||||
XFS_IS_CORRUPT(pag->pag_mount, atomic_read(&pag->pag_ref) != 0);
|
||||
xfs_defer_drain_free(&pag->pag_intents_drain);
|
||||
|
||||
cancel_delayed_work_sync(&pag->pag_blockgc_work);
|
||||
xfs_buf_cache_destroy(&pag->pag_bcache);
|
||||
|
||||
/* drop the mount's active reference */
|
||||
xfs_perag_rele(pag);
|
||||
XFS_IS_CORRUPT(pag->pag_mount,
|
||||
atomic_read(&pag->pag_active_ref) != 0);
|
||||
kfree_rcu_mightsleep(pag);
|
||||
}
|
||||
for (agno = first_agno; agno < end_agno; agno++)
|
||||
xfs_group_free(mp, agno, XG_TYPE_AG, xfs_perag_uninit);
|
||||
}
|
||||
|
||||
/* Find the size of the AG, in blocks. */
|
||||
@@ -332,16 +253,9 @@ xfs_perag_alloc(
|
||||
__xfs_agino_range(mp, pag->block_count, &pag->agino_min,
|
||||
&pag->agino_max);
|
||||
|
||||
pag->pag_agno = index;
|
||||
pag->pag_mount = mp;
|
||||
/* Active ref owned by mount indicates AG is online. */
|
||||
atomic_set(&pag->pag_active_ref, 1);
|
||||
|
||||
error = xa_insert(&mp->m_perags, index, pag, GFP_KERNEL);
|
||||
if (error) {
|
||||
WARN_ON_ONCE(error == -EBUSY);
|
||||
error = xfs_group_insert(mp, pag_group(pag), index, XG_TYPE_AG);
|
||||
if (error)
|
||||
goto out_buf_cache_destroy;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -833,7 +747,7 @@ xfs_ag_shrink_space(
|
||||
struct xfs_trans **tpp,
|
||||
xfs_extlen_t delta)
|
||||
{
|
||||
struct xfs_mount *mp = pag->pag_mount;
|
||||
struct xfs_mount *mp = pag_mount(pag);
|
||||
struct xfs_alloc_arg args = {
|
||||
.tp = *tpp,
|
||||
.mp = mp,
|
||||
@@ -850,7 +764,7 @@ xfs_ag_shrink_space(
|
||||
xfs_agblock_t aglen;
|
||||
int error, err2;
|
||||
|
||||
ASSERT(pag->pag_agno == mp->m_sb.sb_agcount - 1);
|
||||
ASSERT(pag_agno(pag) == mp->m_sb.sb_agcount - 1);
|
||||
error = xfs_ialloc_read_agi(pag, *tpp, 0, &agibp);
|
||||
if (error)
|
||||
return error;
|
||||
@@ -947,8 +861,8 @@ xfs_ag_shrink_space(
|
||||
|
||||
/* Update perag geometry */
|
||||
pag->block_count -= delta;
|
||||
__xfs_agino_range(pag->pag_mount, pag->block_count, &pag->agino_min,
|
||||
&pag->agino_max);
|
||||
__xfs_agino_range(mp, pag->block_count, &pag->agino_min,
|
||||
&pag->agino_max);
|
||||
|
||||
xfs_ialloc_log_agi(*tpp, agibp, XFS_AGI_LENGTH);
|
||||
xfs_alloc_log_agf(*tpp, agfbp, XFS_AGF_LENGTH);
|
||||
@@ -973,12 +887,13 @@ xfs_ag_extend_space(
|
||||
struct xfs_trans *tp,
|
||||
xfs_extlen_t len)
|
||||
{
|
||||
struct xfs_mount *mp = pag_mount(pag);
|
||||
struct xfs_buf *bp;
|
||||
struct xfs_agi *agi;
|
||||
struct xfs_agf *agf;
|
||||
int error;
|
||||
|
||||
ASSERT(pag->pag_agno == pag->pag_mount->m_sb.sb_agcount - 1);
|
||||
ASSERT(pag_agno(pag) == mp->m_sb.sb_agcount - 1);
|
||||
|
||||
error = xfs_ialloc_read_agi(pag, tp, 0, &bp);
|
||||
if (error)
|
||||
@@ -1018,8 +933,8 @@ xfs_ag_extend_space(
|
||||
|
||||
/* Update perag geometry */
|
||||
pag->block_count = be32_to_cpu(agf->agf_length);
|
||||
__xfs_agino_range(pag->pag_mount, pag->block_count, &pag->agino_min,
|
||||
&pag->agino_max);
|
||||
__xfs_agino_range(mp, pag->block_count, &pag->agino_min,
|
||||
&pag->agino_max);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1046,7 +961,7 @@ xfs_ag_get_geometry(
|
||||
|
||||
/* Fill out form. */
|
||||
memset(ageo, 0, sizeof(*ageo));
|
||||
ageo->ag_number = pag->pag_agno;
|
||||
ageo->ag_number = pag_agno(pag);
|
||||
|
||||
agi = agi_bp->b_addr;
|
||||
ageo->ag_icount = be32_to_cpu(agi->agi_count);
|
||||
|
||||
+65
-16
@@ -7,6 +7,8 @@
|
||||
#ifndef __LIBXFS_AG_H
|
||||
#define __LIBXFS_AG_H 1
|
||||
|
||||
#include "xfs_group.h"
|
||||
|
||||
struct xfs_mount;
|
||||
struct xfs_trans;
|
||||
struct xfs_perag;
|
||||
@@ -30,10 +32,7 @@ struct xfs_ag_resv {
|
||||
* performance of allocation group selection.
|
||||
*/
|
||||
struct xfs_perag {
|
||||
struct xfs_mount *pag_mount; /* owner filesystem */
|
||||
xfs_agnumber_t pag_agno; /* AG this structure belongs to */
|
||||
atomic_t pag_ref; /* passive reference count */
|
||||
atomic_t pag_active_ref; /* active reference count */
|
||||
struct xfs_group pag_group;
|
||||
unsigned long pag_opstate;
|
||||
uint8_t pagf_bno_level; /* # of levels in bno btree */
|
||||
uint8_t pagf_cnt_level; /* # of levels in cnt btree */
|
||||
@@ -121,6 +120,26 @@ struct xfs_perag {
|
||||
#endif /* __KERNEL__ */
|
||||
};
|
||||
|
||||
static inline struct xfs_perag *to_perag(struct xfs_group *xg)
|
||||
{
|
||||
return container_of(xg, struct xfs_perag, pag_group);
|
||||
}
|
||||
|
||||
static inline struct xfs_group *pag_group(struct xfs_perag *pag)
|
||||
{
|
||||
return &pag->pag_group;
|
||||
}
|
||||
|
||||
static inline struct xfs_mount *pag_mount(const struct xfs_perag *pag)
|
||||
{
|
||||
return pag->pag_group.xg_mount;
|
||||
}
|
||||
|
||||
static inline xfs_agnumber_t pag_agno(const struct xfs_perag *pag)
|
||||
{
|
||||
return pag->pag_group.xg_gno;
|
||||
}
|
||||
|
||||
/*
|
||||
* Per-AG operational state. These are atomic flag bits.
|
||||
*/
|
||||
@@ -151,13 +170,43 @@ int xfs_initialize_perag_data(struct xfs_mount *mp, xfs_agnumber_t agno);
|
||||
int xfs_update_last_ag_size(struct xfs_mount *mp, xfs_agnumber_t prev_agcount);
|
||||
|
||||
/* Passive AG references */
|
||||
struct xfs_perag *xfs_perag_get(struct xfs_mount *mp, xfs_agnumber_t agno);
|
||||
struct xfs_perag *xfs_perag_hold(struct xfs_perag *pag);
|
||||
void xfs_perag_put(struct xfs_perag *pag);
|
||||
static inline struct xfs_perag *
|
||||
xfs_perag_get(
|
||||
struct xfs_mount *mp,
|
||||
xfs_agnumber_t agno)
|
||||
{
|
||||
return to_perag(xfs_group_get(mp, agno, XG_TYPE_AG));
|
||||
}
|
||||
|
||||
static inline struct xfs_perag *
|
||||
xfs_perag_hold(
|
||||
struct xfs_perag *pag)
|
||||
{
|
||||
return to_perag(xfs_group_hold(pag_group(pag)));
|
||||
}
|
||||
|
||||
static inline void
|
||||
xfs_perag_put(
|
||||
struct xfs_perag *pag)
|
||||
{
|
||||
xfs_group_put(pag_group(pag));
|
||||
}
|
||||
|
||||
/* Active AG references */
|
||||
struct xfs_perag *xfs_perag_grab(struct xfs_mount *, xfs_agnumber_t);
|
||||
void xfs_perag_rele(struct xfs_perag *pag);
|
||||
static inline struct xfs_perag *
|
||||
xfs_perag_grab(
|
||||
struct xfs_mount *mp,
|
||||
xfs_agnumber_t agno)
|
||||
{
|
||||
return to_perag(xfs_group_grab(mp, agno, XG_TYPE_AG));
|
||||
}
|
||||
|
||||
static inline void
|
||||
xfs_perag_rele(
|
||||
struct xfs_perag *pag)
|
||||
{
|
||||
xfs_group_rele(pag_group(pag));
|
||||
}
|
||||
|
||||
/*
|
||||
* Per-ag geometry infomation and validation
|
||||
@@ -233,9 +282,9 @@ xfs_perag_next(
|
||||
xfs_agnumber_t *agno,
|
||||
xfs_agnumber_t end_agno)
|
||||
{
|
||||
struct xfs_mount *mp = pag->pag_mount;
|
||||
struct xfs_mount *mp = pag_mount(pag);
|
||||
|
||||
*agno = pag->pag_agno + 1;
|
||||
*agno = pag_agno(pag) + 1;
|
||||
xfs_perag_rele(pag);
|
||||
while (*agno <= end_agno) {
|
||||
pag = xfs_perag_grab(mp, *agno);
|
||||
@@ -266,9 +315,9 @@ xfs_perag_next_wrap(
|
||||
xfs_agnumber_t restart_agno,
|
||||
xfs_agnumber_t wrap_agno)
|
||||
{
|
||||
struct xfs_mount *mp = pag->pag_mount;
|
||||
struct xfs_mount *mp = pag_mount(pag);
|
||||
|
||||
*agno = pag->pag_agno + 1;
|
||||
*agno = pag_agno(pag) + 1;
|
||||
xfs_perag_rele(pag);
|
||||
while (*agno != stop_agno) {
|
||||
if (*agno >= wrap_agno) {
|
||||
@@ -335,7 +384,7 @@ xfs_agbno_to_fsb(
|
||||
struct xfs_perag *pag,
|
||||
xfs_agblock_t agbno)
|
||||
{
|
||||
return XFS_AGB_TO_FSB(pag->pag_mount, pag->pag_agno, agbno);
|
||||
return XFS_AGB_TO_FSB(pag_mount(pag), pag_agno(pag), agbno);
|
||||
}
|
||||
|
||||
static inline xfs_daddr_t
|
||||
@@ -343,7 +392,7 @@ xfs_agbno_to_daddr(
|
||||
struct xfs_perag *pag,
|
||||
xfs_agblock_t agbno)
|
||||
{
|
||||
return XFS_AGB_TO_DADDR(pag->pag_mount, pag->pag_agno, agbno);
|
||||
return XFS_AGB_TO_DADDR(pag_mount(pag), pag_agno(pag), agbno);
|
||||
}
|
||||
|
||||
static inline xfs_ino_t
|
||||
@@ -351,7 +400,7 @@ xfs_agino_to_ino(
|
||||
struct xfs_perag *pag,
|
||||
xfs_agino_t agino)
|
||||
{
|
||||
return XFS_AGINO_TO_INO(pag->pag_mount, pag->pag_agno, agino);
|
||||
return XFS_AGINO_TO_INO(pag_mount(pag), pag_agno(pag), agino);
|
||||
}
|
||||
|
||||
#endif /* __LIBXFS_AG_H */
|
||||
|
||||
@@ -70,6 +70,7 @@ xfs_ag_resv_critical(
|
||||
struct xfs_perag *pag,
|
||||
enum xfs_ag_resv_type type)
|
||||
{
|
||||
struct xfs_mount *mp = pag_mount(pag);
|
||||
xfs_extlen_t avail;
|
||||
xfs_extlen_t orig;
|
||||
|
||||
@@ -92,8 +93,8 @@ xfs_ag_resv_critical(
|
||||
|
||||
/* Critically low if less than 10% or max btree height remains. */
|
||||
return XFS_TEST_ERROR(avail < orig / 10 ||
|
||||
avail < pag->pag_mount->m_agbtree_maxlevels,
|
||||
pag->pag_mount, XFS_ERRTAG_AG_RESV_CRITICAL);
|
||||
avail < mp->m_agbtree_maxlevels,
|
||||
mp, XFS_ERRTAG_AG_RESV_CRITICAL);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -137,8 +138,8 @@ __xfs_ag_resv_free(
|
||||
trace_xfs_ag_resv_free(pag, type, 0);
|
||||
|
||||
resv = xfs_perag_resv(pag, type);
|
||||
if (pag->pag_agno == 0)
|
||||
pag->pag_mount->m_ag_max_usable += resv->ar_asked;
|
||||
if (pag_agno(pag) == 0)
|
||||
pag_mount(pag)->m_ag_max_usable += resv->ar_asked;
|
||||
/*
|
||||
* RMAPBT blocks come from the AGFL and AGFL blocks are always
|
||||
* considered "free", so whatever was reserved at mount time must be
|
||||
@@ -148,7 +149,7 @@ __xfs_ag_resv_free(
|
||||
oldresv = resv->ar_orig_reserved;
|
||||
else
|
||||
oldresv = resv->ar_reserved;
|
||||
xfs_add_fdblocks(pag->pag_mount, oldresv);
|
||||
xfs_add_fdblocks(pag_mount(pag), oldresv);
|
||||
resv->ar_reserved = 0;
|
||||
resv->ar_asked = 0;
|
||||
resv->ar_orig_reserved = 0;
|
||||
@@ -170,7 +171,7 @@ __xfs_ag_resv_init(
|
||||
xfs_extlen_t ask,
|
||||
xfs_extlen_t used)
|
||||
{
|
||||
struct xfs_mount *mp = pag->pag_mount;
|
||||
struct xfs_mount *mp = pag_mount(pag);
|
||||
struct xfs_ag_resv *resv;
|
||||
int error;
|
||||
xfs_extlen_t hidden_space;
|
||||
@@ -209,7 +210,7 @@ __xfs_ag_resv_init(
|
||||
trace_xfs_ag_resv_init_error(pag, error, _RET_IP_);
|
||||
xfs_warn(mp,
|
||||
"Per-AG reservation for AG %u failed. Filesystem may run out of space.",
|
||||
pag->pag_agno);
|
||||
pag_agno(pag));
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -219,7 +220,7 @@ __xfs_ag_resv_init(
|
||||
* counter, we only make the adjustment for AG 0. This assumes that
|
||||
* there aren't any AGs hungrier for per-AG reservation than AG 0.
|
||||
*/
|
||||
if (pag->pag_agno == 0)
|
||||
if (pag_agno(pag) == 0)
|
||||
mp->m_ag_max_usable -= ask;
|
||||
|
||||
resv = xfs_perag_resv(pag, type);
|
||||
@@ -237,7 +238,7 @@ xfs_ag_resv_init(
|
||||
struct xfs_perag *pag,
|
||||
struct xfs_trans *tp)
|
||||
{
|
||||
struct xfs_mount *mp = pag->pag_mount;
|
||||
struct xfs_mount *mp = pag_mount(pag);
|
||||
xfs_extlen_t ask;
|
||||
xfs_extlen_t used;
|
||||
int error = 0, error2;
|
||||
|
||||
+19
-20
@@ -275,7 +275,7 @@ xfs_alloc_complain_bad_rec(
|
||||
|
||||
xfs_warn(mp,
|
||||
"%sbt record corruption in AG %d detected at %pS!",
|
||||
cur->bc_ops->name, cur->bc_ag.pag->pag_agno, fa);
|
||||
cur->bc_ops->name, pag_agno(cur->bc_ag.pag), fa);
|
||||
xfs_warn(mp,
|
||||
"start block 0x%x block count 0x%x", irec->ar_startblock,
|
||||
irec->ar_blockcount);
|
||||
@@ -799,7 +799,7 @@ xfs_agfl_verify(
|
||||
* use it by using uncached buffers that don't have the perag attached
|
||||
* so we can detect and avoid this problem.
|
||||
*/
|
||||
if (bp->b_pag && be32_to_cpu(agfl->agfl_seqno) != bp->b_pag->pag_agno)
|
||||
if (bp->b_pag && be32_to_cpu(agfl->agfl_seqno) != pag_agno((bp->b_pag)))
|
||||
return __this_address;
|
||||
|
||||
for (i = 0; i < xfs_agfl_size(mp); i++) {
|
||||
@@ -879,13 +879,12 @@ xfs_alloc_read_agfl(
|
||||
struct xfs_trans *tp,
|
||||
struct xfs_buf **bpp)
|
||||
{
|
||||
struct xfs_mount *mp = pag->pag_mount;
|
||||
struct xfs_mount *mp = pag_mount(pag);
|
||||
struct xfs_buf *bp;
|
||||
int error;
|
||||
|
||||
error = xfs_trans_read_buf(
|
||||
mp, tp, mp->m_ddev_targp,
|
||||
XFS_AG_DADDR(mp, pag->pag_agno, XFS_AGFL_DADDR(mp)),
|
||||
error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp,
|
||||
XFS_AG_DADDR(mp, pag_agno(pag), XFS_AGFL_DADDR(mp)),
|
||||
XFS_FSS_TO_BB(mp, 1), 0, &bp, &xfs_agfl_buf_ops);
|
||||
if (xfs_metadata_is_sick(error))
|
||||
xfs_ag_mark_sick(pag, XFS_SICK_AG_AGFL);
|
||||
@@ -2428,7 +2427,7 @@ xfs_alloc_longest_free_extent(
|
||||
* reservations and AGFL rules in place, we can return this extent.
|
||||
*/
|
||||
if (pag->pagf_longest > delta)
|
||||
return min_t(xfs_extlen_t, pag->pag_mount->m_ag_max_usable,
|
||||
return min_t(xfs_extlen_t, pag_mount(pag)->m_ag_max_usable,
|
||||
pag->pagf_longest - delta);
|
||||
|
||||
/* Otherwise, let the caller try for 1 block if there's space. */
|
||||
@@ -2611,7 +2610,7 @@ xfs_agfl_reset(
|
||||
xfs_warn(mp,
|
||||
"WARNING: Reset corrupted AGFL on AG %u. %d blocks leaked. "
|
||||
"Please unmount and run xfs_repair.",
|
||||
pag->pag_agno, pag->pagf_flcount);
|
||||
pag_agno(pag), pag->pagf_flcount);
|
||||
|
||||
agf->agf_flfirst = 0;
|
||||
agf->agf_fllast = cpu_to_be32(xfs_agfl_size(mp) - 1);
|
||||
@@ -3188,7 +3187,7 @@ xfs_validate_ag_length(
|
||||
* use it by using uncached buffers that don't have the perag attached
|
||||
* so we can detect and avoid this problem.
|
||||
*/
|
||||
if (bp->b_pag && seqno != bp->b_pag->pag_agno)
|
||||
if (bp->b_pag && seqno != pag_agno(bp->b_pag))
|
||||
return __this_address;
|
||||
|
||||
/*
|
||||
@@ -3357,13 +3356,13 @@ xfs_read_agf(
|
||||
int flags,
|
||||
struct xfs_buf **agfbpp)
|
||||
{
|
||||
struct xfs_mount *mp = pag->pag_mount;
|
||||
struct xfs_mount *mp = pag_mount(pag);
|
||||
int error;
|
||||
|
||||
trace_xfs_read_agf(pag);
|
||||
|
||||
error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp,
|
||||
XFS_AG_DADDR(mp, pag->pag_agno, XFS_AGF_DADDR(mp)),
|
||||
XFS_AG_DADDR(mp, pag_agno(pag), XFS_AGF_DADDR(mp)),
|
||||
XFS_FSS_TO_BB(mp, 1), flags, agfbpp, &xfs_agf_buf_ops);
|
||||
if (xfs_metadata_is_sick(error))
|
||||
xfs_ag_mark_sick(pag, XFS_SICK_AG_AGF);
|
||||
@@ -3386,6 +3385,7 @@ xfs_alloc_read_agf(
|
||||
int flags,
|
||||
struct xfs_buf **agfbpp)
|
||||
{
|
||||
struct xfs_mount *mp = pag_mount(pag);
|
||||
struct xfs_buf *agfbp;
|
||||
struct xfs_agf *agf;
|
||||
int error;
|
||||
@@ -3412,7 +3412,7 @@ xfs_alloc_read_agf(
|
||||
pag->pagf_cnt_level = be32_to_cpu(agf->agf_cnt_level);
|
||||
pag->pagf_rmap_level = be32_to_cpu(agf->agf_rmap_level);
|
||||
pag->pagf_refcount_level = be32_to_cpu(agf->agf_refcount_level);
|
||||
if (xfs_agfl_needs_reset(pag->pag_mount, agf))
|
||||
if (xfs_agfl_needs_reset(mp, agf))
|
||||
set_bit(XFS_AGSTATE_AGFL_NEEDS_RESET, &pag->pag_opstate);
|
||||
else
|
||||
clear_bit(XFS_AGSTATE_AGFL_NEEDS_RESET, &pag->pag_opstate);
|
||||
@@ -3425,16 +3425,15 @@ xfs_alloc_read_agf(
|
||||
* counter only tracks non-root blocks.
|
||||
*/
|
||||
allocbt_blks = pag->pagf_btreeblks;
|
||||
if (xfs_has_rmapbt(pag->pag_mount))
|
||||
if (xfs_has_rmapbt(mp))
|
||||
allocbt_blks -= be32_to_cpu(agf->agf_rmap_blocks) - 1;
|
||||
if (allocbt_blks > 0)
|
||||
atomic64_add(allocbt_blks,
|
||||
&pag->pag_mount->m_allocbt_blks);
|
||||
atomic64_add(allocbt_blks, &mp->m_allocbt_blks);
|
||||
|
||||
set_bit(XFS_AGSTATE_AGF_INIT, &pag->pag_opstate);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
else if (!xfs_is_shutdown(pag->pag_mount)) {
|
||||
else if (!xfs_is_shutdown(mp)) {
|
||||
ASSERT(pag->pagf_freeblks == be32_to_cpu(agf->agf_freeblks));
|
||||
ASSERT(pag->pagf_btreeblks == be32_to_cpu(agf->agf_btreeblks));
|
||||
ASSERT(pag->pagf_flcount == be32_to_cpu(agf->agf_flcount));
|
||||
@@ -3652,7 +3651,7 @@ xfs_alloc_vextent_this_ag(
|
||||
int error;
|
||||
|
||||
ASSERT(args->pag != NULL);
|
||||
ASSERT(args->pag->pag_agno == agno);
|
||||
ASSERT(pag_agno(args->pag) == agno);
|
||||
|
||||
args->agno = agno;
|
||||
args->agbno = 0;
|
||||
@@ -3865,7 +3864,7 @@ xfs_alloc_vextent_exact_bno(
|
||||
int error;
|
||||
|
||||
ASSERT(args->pag != NULL);
|
||||
ASSERT(args->pag->pag_agno == XFS_FSB_TO_AGNO(mp, target));
|
||||
ASSERT(pag_agno(args->pag) == XFS_FSB_TO_AGNO(mp, target));
|
||||
|
||||
args->agno = XFS_FSB_TO_AGNO(mp, target);
|
||||
args->agbno = XFS_FSB_TO_AGBNO(mp, target);
|
||||
@@ -3904,7 +3903,7 @@ xfs_alloc_vextent_near_bno(
|
||||
int error;
|
||||
|
||||
if (!needs_perag)
|
||||
ASSERT(args->pag->pag_agno == XFS_FSB_TO_AGNO(mp, target));
|
||||
ASSERT(pag_agno(args->pag) == XFS_FSB_TO_AGNO(mp, target));
|
||||
|
||||
args->agno = XFS_FSB_TO_AGNO(mp, target);
|
||||
args->agbno = XFS_FSB_TO_AGBNO(mp, target);
|
||||
@@ -3941,7 +3940,7 @@ xfs_free_extent_fix_freelist(
|
||||
memset(&args, 0, sizeof(struct xfs_alloc_arg));
|
||||
args.tp = tp;
|
||||
args.mp = tp->t_mountp;
|
||||
args.agno = pag->pag_agno;
|
||||
args.agno = pag_agno(pag);
|
||||
args.pag = pag;
|
||||
|
||||
/*
|
||||
|
||||
@@ -178,7 +178,7 @@ xfs_allocbt_init_ptr_from_cur(
|
||||
{
|
||||
struct xfs_agf *agf = cur->bc_ag.agbp->b_addr;
|
||||
|
||||
ASSERT(cur->bc_ag.pag->pag_agno == be32_to_cpu(agf->agf_seqno));
|
||||
ASSERT(pag_agno(cur->bc_ag.pag) == be32_to_cpu(agf->agf_seqno));
|
||||
|
||||
if (xfs_btree_is_bno(cur->bc_ops))
|
||||
ptr->s = agf->agf_bno_root;
|
||||
|
||||
@@ -3280,7 +3280,7 @@ xfs_bmap_longest_free_extent(
|
||||
}
|
||||
|
||||
longest = xfs_alloc_longest_free_extent(pag,
|
||||
xfs_alloc_min_freelist(pag->pag_mount, pag),
|
||||
xfs_alloc_min_freelist(pag_mount(pag), pag),
|
||||
xfs_ag_resv_needed(pag, XFS_AG_RESV_NONE));
|
||||
if (*blen < longest)
|
||||
*blen = longest;
|
||||
|
||||
@@ -372,7 +372,7 @@ xfs_btree_check_ptr(
|
||||
case XFS_BTREE_TYPE_AG:
|
||||
xfs_err(cur->bc_mp,
|
||||
"AG %u: Corrupt %sbt pointer at level %d index %d.",
|
||||
cur->bc_ag.pag->pag_agno, cur->bc_ops->name,
|
||||
pag_agno(cur->bc_ag.pag), cur->bc_ops->name,
|
||||
level, index);
|
||||
break;
|
||||
}
|
||||
@@ -1312,7 +1312,7 @@ xfs_btree_owner(
|
||||
case XFS_BTREE_TYPE_INODE:
|
||||
return cur->bc_ino.ip->i_ino;
|
||||
case XFS_BTREE_TYPE_AG:
|
||||
return cur->bc_ag.pag->pag_agno;
|
||||
return pag_agno(cur->bc_ag.pag);
|
||||
default:
|
||||
ASSERT(0);
|
||||
return 0;
|
||||
@@ -4744,7 +4744,7 @@ xfs_btree_agblock_v5hdr_verify(
|
||||
return __this_address;
|
||||
if (block->bb_u.s.bb_blkno != cpu_to_be64(xfs_buf_daddr(bp)))
|
||||
return __this_address;
|
||||
if (pag && be32_to_cpu(block->bb_u.s.bb_owner) != pag->pag_agno)
|
||||
if (pag && be32_to_cpu(block->bb_u.s.bb_owner) != pag_agno(pag))
|
||||
return __this_address;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,169 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* Copyright (c) 2018 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include "xfs.h"
|
||||
#include "xfs_shared.h"
|
||||
#include "xfs_format.h"
|
||||
#include "xfs_trans_resv.h"
|
||||
#include "xfs_mount.h"
|
||||
#include "xfs_error.h"
|
||||
#include "xfs_trace.h"
|
||||
#include "xfs_group.h"
|
||||
|
||||
/*
|
||||
* Groups can have passive and active references.
|
||||
*
|
||||
* For passive references the code freeing a group is responsible for cleaning
|
||||
* up objects that hold the passive references (e.g. cached buffers).
|
||||
* Routines manipulating passive references are xfs_group_get, xfs_group_hold
|
||||
* and xfs_group_put.
|
||||
*
|
||||
* Active references are for short term access to the group for walking trees or
|
||||
* accessing state. If a group is being shrunk or offlined, the lookup will fail
|
||||
* to find that group and return NULL instead.
|
||||
* Routines manipulating active references are xfs_group_grab and
|
||||
* xfs_group_rele.
|
||||
*/
|
||||
|
||||
struct xfs_group *
|
||||
xfs_group_get(
|
||||
struct xfs_mount *mp,
|
||||
uint32_t index,
|
||||
enum xfs_group_type type)
|
||||
{
|
||||
struct xfs_group *xg;
|
||||
|
||||
rcu_read_lock();
|
||||
xg = xa_load(&mp->m_groups[type].xa, index);
|
||||
if (xg) {
|
||||
trace_xfs_group_get(xg, _RET_IP_);
|
||||
ASSERT(atomic_read(&xg->xg_ref) >= 0);
|
||||
atomic_inc(&xg->xg_ref);
|
||||
}
|
||||
rcu_read_unlock();
|
||||
return xg;
|
||||
}
|
||||
|
||||
struct xfs_group *
|
||||
xfs_group_hold(
|
||||
struct xfs_group *xg)
|
||||
{
|
||||
ASSERT(atomic_read(&xg->xg_ref) > 0 ||
|
||||
atomic_read(&xg->xg_active_ref) > 0);
|
||||
|
||||
trace_xfs_group_hold(xg, _RET_IP_);
|
||||
atomic_inc(&xg->xg_ref);
|
||||
return xg;
|
||||
}
|
||||
|
||||
void
|
||||
xfs_group_put(
|
||||
struct xfs_group *xg)
|
||||
{
|
||||
trace_xfs_group_put(xg, _RET_IP_);
|
||||
|
||||
ASSERT(atomic_read(&xg->xg_ref) > 0);
|
||||
atomic_dec(&xg->xg_ref);
|
||||
}
|
||||
|
||||
struct xfs_group *
|
||||
xfs_group_grab(
|
||||
struct xfs_mount *mp,
|
||||
uint32_t index,
|
||||
enum xfs_group_type type)
|
||||
{
|
||||
struct xfs_group *xg;
|
||||
|
||||
rcu_read_lock();
|
||||
xg = xa_load(&mp->m_groups[type].xa, index);
|
||||
if (xg) {
|
||||
trace_xfs_group_grab(xg, _RET_IP_);
|
||||
if (!atomic_inc_not_zero(&xg->xg_active_ref))
|
||||
xg = NULL;
|
||||
}
|
||||
rcu_read_unlock();
|
||||
return xg;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find the next group after @xg, or the first group if @xg is NULL.
|
||||
*/
|
||||
struct xfs_group *
|
||||
xfs_group_grab_next_mark(
|
||||
struct xfs_mount *mp,
|
||||
struct xfs_group *xg,
|
||||
xa_mark_t mark,
|
||||
enum xfs_group_type type)
|
||||
{
|
||||
unsigned long index = 0;
|
||||
|
||||
if (xg) {
|
||||
index = xg->xg_gno + 1;
|
||||
xfs_group_rele(xg);
|
||||
}
|
||||
|
||||
rcu_read_lock();
|
||||
xg = xa_find(&mp->m_groups[type].xa, &index, ULONG_MAX, mark);
|
||||
if (xg) {
|
||||
trace_xfs_group_grab_next_tag(xg, _RET_IP_);
|
||||
if (!atomic_inc_not_zero(&xg->xg_active_ref))
|
||||
xg = NULL;
|
||||
}
|
||||
rcu_read_unlock();
|
||||
return xg;
|
||||
}
|
||||
|
||||
void
|
||||
xfs_group_rele(
|
||||
struct xfs_group *xg)
|
||||
{
|
||||
trace_xfs_group_rele(xg, _RET_IP_);
|
||||
atomic_dec(&xg->xg_active_ref);
|
||||
}
|
||||
|
||||
void
|
||||
xfs_group_free(
|
||||
struct xfs_mount *mp,
|
||||
uint32_t index,
|
||||
enum xfs_group_type type,
|
||||
void (*uninit)(struct xfs_group *xg))
|
||||
{
|
||||
struct xfs_group *xg = xa_erase(&mp->m_groups[type].xa, index);
|
||||
|
||||
XFS_IS_CORRUPT(mp, atomic_read(&xg->xg_ref) != 0);
|
||||
|
||||
if (uninit)
|
||||
uninit(xg);
|
||||
|
||||
/* drop the mount's active reference */
|
||||
xfs_group_rele(xg);
|
||||
XFS_IS_CORRUPT(mp, atomic_read(&xg->xg_active_ref) != 0);
|
||||
kfree_rcu_mightsleep(xg);
|
||||
}
|
||||
|
||||
int
|
||||
xfs_group_insert(
|
||||
struct xfs_mount *mp,
|
||||
struct xfs_group *xg,
|
||||
uint32_t index,
|
||||
enum xfs_group_type type)
|
||||
{
|
||||
int error;
|
||||
|
||||
xg->xg_mount = mp;
|
||||
xg->xg_gno = index;
|
||||
xg->xg_type = type;
|
||||
|
||||
/* Active ref owned by mount indicates group is online. */
|
||||
atomic_set(&xg->xg_active_ref, 1);
|
||||
|
||||
error = xa_insert(&mp->m_groups[type].xa, index, xg, GFP_KERNEL);
|
||||
if (error) {
|
||||
WARN_ON_ONCE(error == -EBUSY);
|
||||
return error;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Copyright (c) 2018 Red Hat, Inc.
|
||||
*/
|
||||
#ifndef __LIBXFS_GROUP_H
|
||||
#define __LIBXFS_GROUP_H 1
|
||||
|
||||
struct xfs_group {
|
||||
struct xfs_mount *xg_mount;
|
||||
uint32_t xg_gno;
|
||||
enum xfs_group_type xg_type;
|
||||
atomic_t xg_ref; /* passive reference count */
|
||||
atomic_t xg_active_ref; /* active reference count */
|
||||
};
|
||||
|
||||
struct xfs_group *xfs_group_get(struct xfs_mount *mp, uint32_t index,
|
||||
enum xfs_group_type type);
|
||||
struct xfs_group *xfs_group_hold(struct xfs_group *xg);
|
||||
void xfs_group_put(struct xfs_group *xg);
|
||||
|
||||
struct xfs_group *xfs_group_grab(struct xfs_mount *mp, uint32_t index,
|
||||
enum xfs_group_type type);
|
||||
struct xfs_group *xfs_group_grab_next_mark(struct xfs_mount *mp,
|
||||
struct xfs_group *xg, xa_mark_t mark, enum xfs_group_type type);
|
||||
void xfs_group_rele(struct xfs_group *xg);
|
||||
|
||||
void xfs_group_free(struct xfs_mount *mp, uint32_t index,
|
||||
enum xfs_group_type type, void (*uninit)(struct xfs_group *xg));
|
||||
int xfs_group_insert(struct xfs_mount *mp, struct xfs_group *xg,
|
||||
uint32_t index, enum xfs_group_type);
|
||||
|
||||
#define xfs_group_set_mark(_xg, _mark) \
|
||||
xa_set_mark(&(_xg)->xg_mount->m_groups[(_xg)->xg_type].xa, \
|
||||
(_xg)->xg_gno, (_mark))
|
||||
#define xfs_group_clear_mark(_xg, _mark) \
|
||||
xa_clear_mark(&(_xg)->xg_mount->m_groups[(_xg)->xg_type].xa, \
|
||||
(_xg)->xg_gno, (_mark))
|
||||
#define xfs_group_marked(_mp, _type, _mark) \
|
||||
xa_marked(&(_mp)->m_groups[(_type)].xa, (_mark))
|
||||
|
||||
#endif /* __LIBXFS_GROUP_H */
|
||||
+20
-20
@@ -142,7 +142,7 @@ xfs_inobt_complain_bad_rec(
|
||||
|
||||
xfs_warn(mp,
|
||||
"%sbt record corruption in AG %d detected at %pS!",
|
||||
cur->bc_ops->name, cur->bc_ag.pag->pag_agno, fa);
|
||||
cur->bc_ops->name, pag_agno(cur->bc_ag.pag), fa);
|
||||
xfs_warn(mp,
|
||||
"start inode 0x%x, count 0x%x, free 0x%x freemask 0x%llx, holemask 0x%x",
|
||||
irec->ir_startino, irec->ir_count, irec->ir_freecount,
|
||||
@@ -551,7 +551,7 @@ xfs_inobt_insert_sprec(
|
||||
struct xfs_buf *agbp,
|
||||
struct xfs_inobt_rec_incore *nrec) /* in/out: new/merged rec. */
|
||||
{
|
||||
struct xfs_mount *mp = pag->pag_mount;
|
||||
struct xfs_mount *mp = pag_mount(pag);
|
||||
struct xfs_btree_cur *cur;
|
||||
int error;
|
||||
int i;
|
||||
@@ -645,7 +645,7 @@ xfs_finobt_insert_sprec(
|
||||
struct xfs_buf *agbp,
|
||||
struct xfs_inobt_rec_incore *nrec) /* in/out: new rec. */
|
||||
{
|
||||
struct xfs_mount *mp = pag->pag_mount;
|
||||
struct xfs_mount *mp = pag_mount(pag);
|
||||
struct xfs_btree_cur *cur;
|
||||
int error;
|
||||
int i;
|
||||
@@ -880,7 +880,7 @@ sparse_alloc:
|
||||
* rather than a linear progression to prevent the next generation
|
||||
* number from being easily guessable.
|
||||
*/
|
||||
error = xfs_ialloc_inode_init(args.mp, tp, NULL, newlen, pag->pag_agno,
|
||||
error = xfs_ialloc_inode_init(args.mp, tp, NULL, newlen, pag_agno(pag),
|
||||
args.agbno, args.len, get_random_u32());
|
||||
|
||||
if (error)
|
||||
@@ -1071,7 +1071,7 @@ xfs_dialloc_check_ino(
|
||||
if (error)
|
||||
return -EAGAIN;
|
||||
|
||||
error = xfs_imap_to_bp(pag->pag_mount, tp, &imap, &bp);
|
||||
error = xfs_imap_to_bp(pag_mount(pag), tp, &imap, &bp);
|
||||
if (error)
|
||||
return -EAGAIN;
|
||||
|
||||
@@ -1122,7 +1122,7 @@ xfs_dialloc_ag_inobt(
|
||||
/*
|
||||
* If in the same AG as the parent, try to get near the parent.
|
||||
*/
|
||||
if (pagno == pag->pag_agno) {
|
||||
if (pagno == pag_agno(pag)) {
|
||||
int doneleft; /* done, to the left */
|
||||
int doneright; /* done, to the right */
|
||||
|
||||
@@ -1599,7 +1599,7 @@ xfs_dialloc_ag(
|
||||
* parent. If so, find the closest available inode to the parent. If
|
||||
* not, consider the agi hint or find the first free inode in the AG.
|
||||
*/
|
||||
if (pag->pag_agno == pagno)
|
||||
if (pag_agno(pag) == pagno)
|
||||
error = xfs_dialloc_ag_finobt_near(pagino, &cur, &rec);
|
||||
else
|
||||
error = xfs_dialloc_ag_finobt_newino(agi, cur, &rec);
|
||||
@@ -2053,7 +2053,7 @@ xfs_difree_inobt(
|
||||
struct xfs_icluster *xic,
|
||||
struct xfs_inobt_rec_incore *orec)
|
||||
{
|
||||
struct xfs_mount *mp = pag->pag_mount;
|
||||
struct xfs_mount *mp = pag_mount(pag);
|
||||
struct xfs_agi *agi = agbp->b_addr;
|
||||
struct xfs_btree_cur *cur;
|
||||
struct xfs_inobt_rec_incore rec;
|
||||
@@ -2187,7 +2187,7 @@ xfs_difree_finobt(
|
||||
xfs_agino_t agino,
|
||||
struct xfs_inobt_rec_incore *ibtrec) /* inobt record */
|
||||
{
|
||||
struct xfs_mount *mp = pag->pag_mount;
|
||||
struct xfs_mount *mp = pag_mount(pag);
|
||||
struct xfs_btree_cur *cur;
|
||||
struct xfs_inobt_rec_incore rec;
|
||||
int offset = agino - ibtrec->ir_startino;
|
||||
@@ -2310,9 +2310,9 @@ xfs_difree(
|
||||
/*
|
||||
* Break up inode number into its components.
|
||||
*/
|
||||
if (pag->pag_agno != XFS_INO_TO_AGNO(mp, inode)) {
|
||||
xfs_warn(mp, "%s: agno != pag->pag_agno (%d != %d).",
|
||||
__func__, XFS_INO_TO_AGNO(mp, inode), pag->pag_agno);
|
||||
if (pag_agno(pag) != XFS_INO_TO_AGNO(mp, inode)) {
|
||||
xfs_warn(mp, "%s: agno != pag_agno(pag) (%d != %d).",
|
||||
__func__, XFS_INO_TO_AGNO(mp, inode), pag_agno(pag));
|
||||
ASSERT(0);
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -2373,7 +2373,7 @@ xfs_imap_lookup(
|
||||
xfs_agblock_t *offset_agbno,
|
||||
int flags)
|
||||
{
|
||||
struct xfs_mount *mp = pag->pag_mount;
|
||||
struct xfs_mount *mp = pag_mount(pag);
|
||||
struct xfs_inobt_rec_incore rec;
|
||||
struct xfs_btree_cur *cur;
|
||||
struct xfs_buf *agbp;
|
||||
@@ -2384,7 +2384,7 @@ xfs_imap_lookup(
|
||||
if (error) {
|
||||
xfs_alert(mp,
|
||||
"%s: xfs_ialloc_read_agi() returned error %d, agno %d",
|
||||
__func__, error, pag->pag_agno);
|
||||
__func__, error, pag_agno(pag));
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -2434,7 +2434,7 @@ xfs_imap(
|
||||
struct xfs_imap *imap, /* location map structure */
|
||||
uint flags) /* flags for inode btree lookup */
|
||||
{
|
||||
struct xfs_mount *mp = pag->pag_mount;
|
||||
struct xfs_mount *mp = pag_mount(pag);
|
||||
xfs_agblock_t agbno; /* block number of inode in the alloc group */
|
||||
xfs_agino_t agino; /* inode number within alloc group */
|
||||
xfs_agblock_t chunk_agbno; /* first block in inode chunk */
|
||||
@@ -2726,13 +2726,13 @@ xfs_read_agi(
|
||||
xfs_buf_flags_t flags,
|
||||
struct xfs_buf **agibpp)
|
||||
{
|
||||
struct xfs_mount *mp = pag->pag_mount;
|
||||
struct xfs_mount *mp = pag_mount(pag);
|
||||
int error;
|
||||
|
||||
trace_xfs_read_agi(pag);
|
||||
|
||||
error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp,
|
||||
XFS_AG_DADDR(mp, pag->pag_agno, XFS_AGI_DADDR(mp)),
|
||||
XFS_AG_DADDR(mp, pag_agno(pag), XFS_AGI_DADDR(mp)),
|
||||
XFS_FSS_TO_BB(mp, 1), flags, agibpp, &xfs_agi_buf_ops);
|
||||
if (xfs_metadata_is_sick(error))
|
||||
xfs_ag_mark_sick(pag, XFS_SICK_AG_AGI);
|
||||
@@ -2780,7 +2780,7 @@ xfs_ialloc_read_agi(
|
||||
* we are in the middle of a forced shutdown.
|
||||
*/
|
||||
ASSERT(pag->pagi_freecount == be32_to_cpu(agi->agi_freecount) ||
|
||||
xfs_is_shutdown(pag->pag_mount));
|
||||
xfs_is_shutdown(pag_mount(pag)));
|
||||
if (agibpp)
|
||||
*agibpp = agibp;
|
||||
else
|
||||
@@ -3119,13 +3119,13 @@ xfs_ialloc_check_shrink(
|
||||
int has;
|
||||
int error;
|
||||
|
||||
if (!xfs_has_sparseinodes(pag->pag_mount))
|
||||
if (!xfs_has_sparseinodes(pag_mount(pag)))
|
||||
return 0;
|
||||
|
||||
cur = xfs_inobt_init_cursor(pag, tp, agibp);
|
||||
|
||||
/* Look up the inobt record that would correspond to the new EOFS. */
|
||||
agino = XFS_AGB_TO_AGINO(pag->pag_mount, new_length);
|
||||
agino = XFS_AGB_TO_AGINO(pag_mount(pag), new_length);
|
||||
error = xfs_inobt_lookup(cur, agino, XFS_LOOKUP_LE, &has);
|
||||
if (error || !has)
|
||||
goto out;
|
||||
|
||||
@@ -248,7 +248,7 @@ xfs_inobt_init_ptr_from_cur(
|
||||
{
|
||||
struct xfs_agi *agi = cur->bc_ag.agbp->b_addr;
|
||||
|
||||
ASSERT(cur->bc_ag.pag->pag_agno == be32_to_cpu(agi->agi_seqno));
|
||||
ASSERT(pag_agno(cur->bc_ag.pag) == be32_to_cpu(agi->agi_seqno));
|
||||
|
||||
ptr->s = agi->agi_root;
|
||||
}
|
||||
@@ -260,7 +260,7 @@ xfs_finobt_init_ptr_from_cur(
|
||||
{
|
||||
struct xfs_agi *agi = cur->bc_ag.agbp->b_addr;
|
||||
|
||||
ASSERT(cur->bc_ag.pag->pag_agno == be32_to_cpu(agi->agi_seqno));
|
||||
ASSERT(pag_agno(cur->bc_ag.pag) == be32_to_cpu(agi->agi_seqno));
|
||||
ptr->s = agi->agi_free_root;
|
||||
}
|
||||
|
||||
@@ -478,7 +478,7 @@ xfs_inobt_init_cursor(
|
||||
struct xfs_trans *tp,
|
||||
struct xfs_buf *agbp)
|
||||
{
|
||||
struct xfs_mount *mp = pag->pag_mount;
|
||||
struct xfs_mount *mp = pag_mount(pag);
|
||||
struct xfs_btree_cur *cur;
|
||||
|
||||
cur = xfs_btree_alloc_cursor(mp, tp, &xfs_inobt_ops,
|
||||
@@ -504,7 +504,7 @@ xfs_finobt_init_cursor(
|
||||
struct xfs_trans *tp,
|
||||
struct xfs_buf *agbp)
|
||||
{
|
||||
struct xfs_mount *mp = pag->pag_mount;
|
||||
struct xfs_mount *mp = pag_mount(pag);
|
||||
struct xfs_btree_cur *cur;
|
||||
|
||||
cur = xfs_btree_alloc_cursor(mp, tp, &xfs_finobt_ops,
|
||||
@@ -715,7 +715,7 @@ static xfs_extlen_t
|
||||
xfs_inobt_max_size(
|
||||
struct xfs_perag *pag)
|
||||
{
|
||||
struct xfs_mount *mp = pag->pag_mount;
|
||||
struct xfs_mount *mp = pag_mount(pag);
|
||||
xfs_agblock_t agblocks = pag->block_count;
|
||||
|
||||
/* Bail out if we're uninitialized, which can happen in mkfs. */
|
||||
@@ -727,7 +727,7 @@ xfs_inobt_max_size(
|
||||
* never be available for the kinds of things that would require btree
|
||||
* expansion. We therefore can pretend the space isn't there.
|
||||
*/
|
||||
if (xfs_ag_contains_log(mp, pag->pag_agno))
|
||||
if (xfs_ag_contains_log(mp, pag_agno(pag)))
|
||||
agblocks -= mp->m_sb.sb_logblocks;
|
||||
|
||||
return xfs_btree_calc_size(M_IGEO(mp)->inobt_mnr,
|
||||
@@ -791,10 +791,10 @@ xfs_finobt_calc_reserves(
|
||||
xfs_extlen_t tree_len = 0;
|
||||
int error;
|
||||
|
||||
if (!xfs_has_finobt(pag->pag_mount))
|
||||
if (!xfs_has_finobt(pag_mount(pag)))
|
||||
return 0;
|
||||
|
||||
if (xfs_has_inobtcounts(pag->pag_mount))
|
||||
if (xfs_has_inobtcounts(pag_mount(pag)))
|
||||
error = xfs_finobt_read_blocks(pag, tp, &tree_len);
|
||||
else
|
||||
error = xfs_finobt_count_blocks(pag, tp, &tree_len);
|
||||
|
||||
@@ -154,7 +154,7 @@ xfs_refcount_complain_bad_rec(
|
||||
|
||||
xfs_warn(mp,
|
||||
"Refcount BTree record corruption in AG %d detected at %pS!",
|
||||
cur->bc_ag.pag->pag_agno, fa);
|
||||
pag_agno(cur->bc_ag.pag), fa);
|
||||
xfs_warn(mp,
|
||||
"Start block 0x%x, block count 0x%x, references 0x%x",
|
||||
irec->rc_startblock, irec->rc_blockcount, irec->rc_refcount);
|
||||
@@ -1321,7 +1321,7 @@ xfs_refcount_continue_op(
|
||||
ri->ri_startblock = xfs_agbno_to_fsb(pag, new_agbno);
|
||||
|
||||
ASSERT(xfs_verify_fsbext(mp, ri->ri_startblock, ri->ri_blockcount));
|
||||
ASSERT(pag->pag_agno == XFS_FSB_TO_AGNO(mp, ri->ri_startblock));
|
||||
ASSERT(pag_agno(pag) == XFS_FSB_TO_AGNO(mp, ri->ri_startblock));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ xfs_refcountbt_alloc_block(
|
||||
*stat = 0;
|
||||
return 0;
|
||||
}
|
||||
ASSERT(args.agno == cur->bc_ag.pag->pag_agno);
|
||||
ASSERT(args.agno == pag_agno(cur->bc_ag.pag));
|
||||
ASSERT(args.len == 1);
|
||||
|
||||
new->s = cpu_to_be32(args.agbno);
|
||||
@@ -169,7 +169,7 @@ xfs_refcountbt_init_ptr_from_cur(
|
||||
{
|
||||
struct xfs_agf *agf = cur->bc_ag.agbp->b_addr;
|
||||
|
||||
ASSERT(cur->bc_ag.pag->pag_agno == be32_to_cpu(agf->agf_seqno));
|
||||
ASSERT(pag_agno(cur->bc_ag.pag) == be32_to_cpu(agf->agf_seqno));
|
||||
|
||||
ptr->s = agf->agf_refcount_root;
|
||||
}
|
||||
@@ -361,7 +361,7 @@ xfs_refcountbt_init_cursor(
|
||||
{
|
||||
struct xfs_btree_cur *cur;
|
||||
|
||||
ASSERT(pag->pag_agno < mp->m_sb.sb_agcount);
|
||||
ASSERT(pag_agno(pag) < mp->m_sb.sb_agcount);
|
||||
|
||||
cur = xfs_btree_alloc_cursor(mp, tp, &xfs_refcountbt_ops,
|
||||
mp->m_refc_maxlevels, xfs_refcountbt_cur_cache);
|
||||
@@ -514,7 +514,7 @@ xfs_refcountbt_calc_reserves(
|
||||
* never be available for the kinds of things that would require btree
|
||||
* expansion. We therefore can pretend the space isn't there.
|
||||
*/
|
||||
if (xfs_ag_contains_log(mp, pag->pag_agno))
|
||||
if (xfs_ag_contains_log(mp, pag_agno(pag)))
|
||||
agblocks -= mp->m_sb.sb_logblocks;
|
||||
|
||||
*ask += xfs_refcountbt_max_size(mp, agblocks);
|
||||
|
||||
@@ -213,7 +213,7 @@ xfs_rmap_check_irec(
|
||||
struct xfs_perag *pag,
|
||||
const struct xfs_rmap_irec *irec)
|
||||
{
|
||||
struct xfs_mount *mp = pag->pag_mount;
|
||||
struct xfs_mount *mp = pag_mount(pag);
|
||||
bool is_inode;
|
||||
bool is_unwritten;
|
||||
bool is_bmbt;
|
||||
@@ -288,7 +288,7 @@ xfs_rmap_complain_bad_rec(
|
||||
else
|
||||
xfs_warn(mp,
|
||||
"Reverse Mapping BTree record corruption in AG %d detected at %pS!",
|
||||
cur->bc_ag.pag->pag_agno, fa);
|
||||
pag_agno(cur->bc_ag.pag), fa);
|
||||
xfs_warn(mp,
|
||||
"Owner 0x%llx, flags 0x%x, start block 0x%x block count 0x%x",
|
||||
irec->rm_owner, irec->rm_flags, irec->rm_startblock,
|
||||
|
||||
@@ -227,7 +227,7 @@ xfs_rmapbt_init_ptr_from_cur(
|
||||
{
|
||||
struct xfs_agf *agf = cur->bc_ag.agbp->b_addr;
|
||||
|
||||
ASSERT(cur->bc_ag.pag->pag_agno == be32_to_cpu(agf->agf_seqno));
|
||||
ASSERT(pag_agno(cur->bc_ag.pag) == be32_to_cpu(agf->agf_seqno));
|
||||
|
||||
ptr->s = agf->agf_rmap_root;
|
||||
}
|
||||
@@ -647,9 +647,8 @@ xfs_rmapbt_mem_cursor(
|
||||
struct xfbtree *xfbt)
|
||||
{
|
||||
struct xfs_btree_cur *cur;
|
||||
struct xfs_mount *mp = pag->pag_mount;
|
||||
|
||||
cur = xfs_btree_alloc_cursor(mp, tp, &xfs_rmapbt_mem_ops,
|
||||
cur = xfs_btree_alloc_cursor(pag_mount(pag), tp, &xfs_rmapbt_mem_ops,
|
||||
xfs_rmapbt_maxlevels_ondisk(), xfs_rmapbt_cur_cache);
|
||||
cur->bc_mem.xfbtree = xfbt;
|
||||
cur->bc_nlevels = xfbt->nlevels;
|
||||
@@ -863,7 +862,7 @@ xfs_rmapbt_calc_reserves(
|
||||
* never be available for the kinds of things that would require btree
|
||||
* expansion. We therefore can pretend the space isn't there.
|
||||
*/
|
||||
if (xfs_ag_contains_log(mp, pag->pag_agno))
|
||||
if (xfs_ag_contains_log(mp, pag_agno(pag)))
|
||||
agblocks -= mp->m_sb.sb_logblocks;
|
||||
|
||||
/* Reserve 1% of the AG or enough for 1 block per record. */
|
||||
|
||||
@@ -1120,7 +1120,7 @@ xfs_update_secondary_sbs(
|
||||
struct xfs_buf *bp;
|
||||
|
||||
error = xfs_buf_get(mp->m_ddev_targp,
|
||||
XFS_AG_DADDR(mp, pag->pag_agno, XFS_SB_DADDR),
|
||||
XFS_AG_DADDR(mp, pag_agno(pag), XFS_SB_DADDR),
|
||||
XFS_FSS_TO_BB(mp, 1), &bp);
|
||||
/*
|
||||
* If we get an error reading or writing alternate superblocks,
|
||||
@@ -1132,7 +1132,7 @@ xfs_update_secondary_sbs(
|
||||
if (error) {
|
||||
xfs_warn(mp,
|
||||
"error allocating secondary superblock for ag %d",
|
||||
pag->pag_agno);
|
||||
pag_agno(pag));
|
||||
if (!saved_error)
|
||||
saved_error = error;
|
||||
continue;
|
||||
@@ -1153,7 +1153,7 @@ xfs_update_secondary_sbs(
|
||||
if (error) {
|
||||
xfs_warn(mp,
|
||||
"write error %d updating a secondary superblock near ag %d",
|
||||
error, pag->pag_agno);
|
||||
error, pag_agno(pag));
|
||||
if (!saved_error)
|
||||
saved_error = error;
|
||||
continue;
|
||||
|
||||
@@ -212,6 +212,14 @@ enum xbtree_recpacking {
|
||||
XBTREE_RECPACKING_FULL,
|
||||
};
|
||||
|
||||
enum xfs_group_type {
|
||||
XG_TYPE_AG,
|
||||
XG_TYPE_MAX,
|
||||
} __packed;
|
||||
|
||||
#define XG_TYPE_STRINGS \
|
||||
{ XG_TYPE_AG, "ag" }
|
||||
|
||||
/*
|
||||
* Type verifier functions
|
||||
*/
|
||||
|
||||
@@ -208,7 +208,7 @@ xrep_agf_init_header(
|
||||
memset(agf, 0, BBTOB(agf_bp->b_length));
|
||||
agf->agf_magicnum = cpu_to_be32(XFS_AGF_MAGIC);
|
||||
agf->agf_versionnum = cpu_to_be32(XFS_AGF_VERSION);
|
||||
agf->agf_seqno = cpu_to_be32(pag->pag_agno);
|
||||
agf->agf_seqno = cpu_to_be32(pag_agno(pag));
|
||||
agf->agf_length = cpu_to_be32(pag->block_count);
|
||||
agf->agf_flfirst = old_agf->agf_flfirst;
|
||||
agf->agf_fllast = old_agf->agf_fllast;
|
||||
@@ -384,7 +384,7 @@ xrep_agf(
|
||||
* was corrupt after xfs_alloc_read_agf failed with -EFSCORRUPTED.
|
||||
*/
|
||||
error = xfs_trans_read_buf(mp, sc->tp, mp->m_ddev_targp,
|
||||
XFS_AG_DADDR(mp, sc->sa.pag->pag_agno,
|
||||
XFS_AG_DADDR(mp, pag_agno(sc->sa.pag),
|
||||
XFS_AGF_DADDR(mp)),
|
||||
XFS_FSS_TO_BB(mp, 1), 0, &agf_bp, NULL);
|
||||
if (error)
|
||||
@@ -687,7 +687,7 @@ xrep_agfl_init_header(
|
||||
agfl = XFS_BUF_TO_AGFL(agfl_bp);
|
||||
memset(agfl, 0xFF, BBTOB(agfl_bp->b_length));
|
||||
agfl->agfl_magicnum = cpu_to_be32(XFS_AGFL_MAGIC);
|
||||
agfl->agfl_seqno = cpu_to_be32(sc->sa.pag->pag_agno);
|
||||
agfl->agfl_seqno = cpu_to_be32(pag_agno(sc->sa.pag));
|
||||
uuid_copy(&agfl->agfl_uuid, &mp->m_sb.sb_meta_uuid);
|
||||
|
||||
/*
|
||||
@@ -741,7 +741,7 @@ xrep_agfl(
|
||||
* was corrupt after xfs_alloc_read_agfl failed with -EFSCORRUPTED.
|
||||
*/
|
||||
error = xfs_trans_read_buf(mp, sc->tp, mp->m_ddev_targp,
|
||||
XFS_AG_DADDR(mp, sc->sa.pag->pag_agno,
|
||||
XFS_AG_DADDR(mp, pag_agno(sc->sa.pag),
|
||||
XFS_AGFL_DADDR(mp)),
|
||||
XFS_FSS_TO_BB(mp, 1), 0, &agfl_bp, NULL);
|
||||
if (error)
|
||||
@@ -897,7 +897,7 @@ xrep_agi_init_header(
|
||||
memset(agi, 0, BBTOB(agi_bp->b_length));
|
||||
agi->agi_magicnum = cpu_to_be32(XFS_AGI_MAGIC);
|
||||
agi->agi_versionnum = cpu_to_be32(XFS_AGI_VERSION);
|
||||
agi->agi_seqno = cpu_to_be32(pag->pag_agno);
|
||||
agi->agi_seqno = cpu_to_be32(pag_agno(pag));
|
||||
agi->agi_length = cpu_to_be32(pag->block_count);
|
||||
agi->agi_newino = cpu_to_be32(NULLAGINO);
|
||||
agi->agi_dirino = cpu_to_be32(NULLAGINO);
|
||||
@@ -1112,9 +1112,9 @@ xrep_iunlink_igrab(
|
||||
struct xfs_perag *pag,
|
||||
struct xfs_inode *ip)
|
||||
{
|
||||
struct xfs_mount *mp = pag->pag_mount;
|
||||
struct xfs_mount *mp = pag_mount(pag);
|
||||
|
||||
if (XFS_INO_TO_AGNO(mp, ip->i_ino) != pag->pag_agno)
|
||||
if (XFS_INO_TO_AGNO(mp, ip->i_ino) != pag_agno(pag))
|
||||
return false;
|
||||
|
||||
if (!xfs_inode_on_unlinked_list(ip))
|
||||
@@ -1138,7 +1138,7 @@ xrep_iunlink_visit(
|
||||
unsigned int bucket;
|
||||
int error;
|
||||
|
||||
ASSERT(XFS_INO_TO_AGNO(mp, ip->i_ino) == ragi->sc->sa.pag->pag_agno);
|
||||
ASSERT(XFS_INO_TO_AGNO(mp, ip->i_ino) == pag_agno(ragi->sc->sa.pag));
|
||||
ASSERT(xfs_inode_on_unlinked_list(ip));
|
||||
|
||||
agino = XFS_INO_TO_AGINO(mp, ip->i_ino);
|
||||
@@ -1169,7 +1169,7 @@ xrep_iunlink_mark_incore(
|
||||
struct xrep_agi *ragi)
|
||||
{
|
||||
struct xfs_perag *pag = ragi->sc->sa.pag;
|
||||
struct xfs_mount *mp = pag->pag_mount;
|
||||
struct xfs_mount *mp = pag_mount(pag);
|
||||
uint32_t first_index = 0;
|
||||
bool done = false;
|
||||
unsigned int nr_found = 0;
|
||||
@@ -1209,7 +1209,7 @@ xrep_iunlink_mark_incore(
|
||||
* us to see this inode, so another lookup from the
|
||||
* same index will not find it again.
|
||||
*/
|
||||
if (XFS_INO_TO_AGNO(mp, ip->i_ino) != pag->pag_agno)
|
||||
if (XFS_INO_TO_AGNO(mp, ip->i_ino) != pag_agno(pag))
|
||||
continue;
|
||||
first_index = XFS_INO_TO_AGINO(mp, ip->i_ino + 1);
|
||||
if (first_index < XFS_INO_TO_AGINO(mp, ip->i_ino))
|
||||
@@ -1761,7 +1761,7 @@ xrep_agi(
|
||||
* was corrupt after xfs_ialloc_read_agi failed with -EFSCORRUPTED.
|
||||
*/
|
||||
error = xfs_trans_read_buf(mp, sc->tp, mp->m_ddev_targp,
|
||||
XFS_AG_DADDR(mp, sc->sa.pag->pag_agno,
|
||||
XFS_AG_DADDR(mp, pag_agno(sc->sa.pag),
|
||||
XFS_AGI_DADDR(mp)),
|
||||
XFS_FSS_TO_BB(mp, 1), 0, &ragi->agi_bp, NULL);
|
||||
if (error)
|
||||
|
||||
@@ -543,7 +543,7 @@ xrep_abt_dispose_one(
|
||||
|
||||
/* Add a deferred rmap for each extent we used. */
|
||||
if (resv->used > 0)
|
||||
xfs_rmap_alloc_extent(sc->tp, pag->pag_agno, resv->agbno,
|
||||
xfs_rmap_alloc_extent(sc->tp, pag_agno(pag), resv->agbno,
|
||||
resv->used, XFS_RMAP_OWN_AG);
|
||||
|
||||
/*
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user