Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a211432c authored by Darrick J. Wong's avatar Darrick J. Wong
Browse files

xfs: create simplified inode walk function



Create a new iterator function to simplify walking inodes in an XFS
filesystem.  This new iterator will replace the existing open-coded
walking that goes on in various places.

Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
parent 5bb46e3e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -81,6 +81,7 @@ xfs-y += xfs_aops.o \
				   xfs_iops.o \
				   xfs_inode.o \
				   xfs_itable.o \
				   xfs_iwalk.o \
				   xfs_message.o \
				   xfs_mount.o \
				   xfs_mru_cache.o \
+33 −4
Original line number Diff line number Diff line
@@ -562,6 +562,36 @@ xfs_inobt_max_size(
					XFS_INODES_PER_CHUNK);
}

/* Read AGI and create inobt cursor. */
int
xfs_inobt_cur(
	struct xfs_mount	*mp,
	struct xfs_trans	*tp,
	xfs_agnumber_t		agno,
	xfs_btnum_t		which,
	struct xfs_btree_cur	**curpp,
	struct xfs_buf		**agi_bpp)
{
	struct xfs_btree_cur	*cur;
	int			error;

	ASSERT(*agi_bpp == NULL);
	ASSERT(*curpp == NULL);

	error = xfs_ialloc_read_agi(mp, tp, agno, agi_bpp);
	if (error)
		return error;

	cur = xfs_inobt_init_cursor(mp, tp, *agi_bpp, agno, which);
	if (!cur) {
		xfs_trans_brelse(tp, *agi_bpp);
		*agi_bpp = NULL;
		return -ENOMEM;
	}
	*curpp = cur;
	return 0;
}

static int
xfs_inobt_count_blocks(
	struct xfs_mount	*mp,
@@ -570,15 +600,14 @@ xfs_inobt_count_blocks(
	xfs_btnum_t		btnum,
	xfs_extlen_t		*tree_blocks)
{
	struct xfs_buf		*agbp;
	struct xfs_btree_cur	*cur;
	struct xfs_buf		*agbp = NULL;
	struct xfs_btree_cur	*cur = NULL;
	int			error;

	error = xfs_ialloc_read_agi(mp, tp, agno, &agbp);
	error = xfs_inobt_cur(mp, tp, agno, btnum, &cur, &agbp);
	if (error)
		return error;

	cur = xfs_inobt_init_cursor(mp, tp, agbp, agno, btnum);
	error = xfs_btree_count_blocks(cur, tree_blocks);
	xfs_btree_del_cursor(cur, error);
	xfs_trans_brelse(tp, agbp);
+3 −0
Original line number Diff line number Diff line
@@ -64,5 +64,8 @@ int xfs_finobt_calc_reserves(struct xfs_mount *mp, struct xfs_trans *tp,
		xfs_agnumber_t agno, xfs_extlen_t *ask, xfs_extlen_t *used);
extern xfs_extlen_t xfs_iallocbt_calc_size(struct xfs_mount *mp,
		unsigned long long len);
int xfs_inobt_cur(struct xfs_mount *mp, struct xfs_trans *tp,
		xfs_agnumber_t agno, xfs_btnum_t btnum,
		struct xfs_btree_cur **curpp, struct xfs_buf **agi_bpp);

#endif	/* __XFS_IALLOC_BTREE_H__ */
+3 −2
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#include "xfs_error.h"
#include "xfs_icache.h"
#include "xfs_health.h"
#include "xfs_iwalk.h"

/*
 * Return stat information for one inode.
@@ -160,7 +161,7 @@ xfs_bulkstat_one(
 * Loop over all clusters in a chunk for a given incore inode allocation btree
 * record.  Do a readahead if there are any allocated inodes in that cluster.
 */
STATIC void
void
xfs_bulkstat_ichunk_ra(
	struct xfs_mount		*mp,
	xfs_agnumber_t			agno,
@@ -194,7 +195,7 @@ xfs_bulkstat_ichunk_ra(
 * are some left allocated, update the data for the pointed-to record as well as
 * return the count of grabbed inodes.
 */
STATIC int
int
xfs_bulkstat_grab_ichunk(
	struct xfs_btree_cur		*cur,	/* btree cursor */
	xfs_agino_t			agino,	/* starting inode of chunk */
+8 −0
Original line number Diff line number Diff line
@@ -84,4 +84,12 @@ xfs_inumbers(
	void			__user *buffer, /* buffer with inode info */
	inumbers_fmt_pf		formatter);

/* Temporarily needed while we refactor functions. */
struct xfs_btree_cur;
struct xfs_inobt_rec_incore;
void xfs_bulkstat_ichunk_ra(struct xfs_mount *mp, xfs_agnumber_t agno,
		struct xfs_inobt_rec_incore *irec);
int xfs_bulkstat_grab_ichunk(struct xfs_btree_cur *cur, xfs_agino_t agino,
		int *icount, struct xfs_inobt_rec_incore *irec);

#endif	/* __XFS_ITABLE_H__ */
Loading