summaryrefslogtreecommitdiffstats
path: root/fs/xfs/scrub
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2017-11-03 10:34:43 -0700
committerDarrick J. Wong <darrick.wong@oracle.com>2017-11-06 11:53:40 -0800
commitb2b1712a640824e7c131bfdd2585d57bf8ccb39a (patch)
treead756c7caa0bb7252aaf444b077c518e0a5d9f0f /fs/xfs/scrub
parent906abed501bf5a2103946deb7a4a40b31c56f027 (diff)
downloadlinux-b2b1712a640824e7c131bfdd2585d57bf8ccb39a.tar.bz2
xfs: introduce the xfs_iext_cursor abstraction
Add a new xfs_iext_cursor structure to hide the direct extent map index manipulations. In addition to the existing lookup/get/insert/ remove and update routines new primitives to get the first and last extent cursor, as well as moving up and down by one extent are provided. Also new are convenience to increment/decrement the cursor and retreive the new extent, as well as to peek into the previous/next extent without updating the cursor and last but not least a macro to iterate over all extents in a fork. [darrick: rename for_each_iext to for_each_xfs_iext] Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Diffstat (limited to 'fs/xfs/scrub')
-rw-r--r--fs/xfs/scrub/bmap.c6
-rw-r--r--fs/xfs/scrub/dir.c14
2 files changed, 10 insertions, 10 deletions
diff --git a/fs/xfs/scrub/bmap.c b/fs/xfs/scrub/bmap.c
index 3c17b182616f..be0bc11b6594 100644
--- a/fs/xfs/scrub/bmap.c
+++ b/fs/xfs/scrub/bmap.c
@@ -237,7 +237,7 @@ xfs_scrub_bmap(
struct xfs_inode *ip = sc->ip;
struct xfs_ifork *ifp;
xfs_fileoff_t endoff;
- xfs_extnum_t idx;
+ struct xfs_iext_cursor icur;
bool found;
int error = 0;
@@ -317,9 +317,9 @@ xfs_scrub_bmap(
/* Scrub extent records. */
info.lastoff = 0;
ifp = XFS_IFORK_PTR(ip, whichfork);
- for (found = xfs_iext_lookup_extent(ip, ifp, 0, &idx, &irec);
+ for (found = xfs_iext_lookup_extent(ip, ifp, 0, &icur, &irec);
found != 0;
- found = xfs_iext_get_extent(ifp, ++idx, &irec)) {
+ found = xfs_iext_next_extent(ifp, &icur, &irec)) {
if (xfs_scrub_should_terminate(sc, &error))
break;
if (isnullstartblock(irec.br_startblock))
diff --git a/fs/xfs/scrub/dir.c b/fs/xfs/scrub/dir.c
index c61362faed4a..73ac795aa6a5 100644
--- a/fs/xfs/scrub/dir.c
+++ b/fs/xfs/scrub/dir.c
@@ -614,7 +614,7 @@ xfs_scrub_directory_blocks(
xfs_fileoff_t leaf_lblk;
xfs_fileoff_t free_lblk;
xfs_fileoff_t lblk;
- xfs_extnum_t idx;
+ struct xfs_iext_cursor icur;
xfs_dablk_t dabno;
bool found;
int is_block = 0;
@@ -639,7 +639,7 @@ xfs_scrub_directory_blocks(
goto out;
/* Iterate all the data extents in the directory... */
- found = xfs_iext_lookup_extent(sc->ip, ifp, lblk, &idx, &got);
+ found = xfs_iext_lookup_extent(sc->ip, ifp, lblk, &icur, &got);
while (found) {
/* Block directories only have a single block at offset 0. */
if (is_block &&
@@ -676,17 +676,17 @@ xfs_scrub_directory_blocks(
}
dabno = got.br_startoff + got.br_blockcount;
lblk = roundup(dabno, args.geo->fsbcount);
- found = xfs_iext_lookup_extent(sc->ip, ifp, lblk, &idx, &got);
+ found = xfs_iext_lookup_extent(sc->ip, ifp, lblk, &icur, &got);
}
if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
goto out;
/* Look for a leaf1 block, which has free info. */
- if (xfs_iext_lookup_extent(sc->ip, ifp, leaf_lblk, &idx, &got) &&
+ if (xfs_iext_lookup_extent(sc->ip, ifp, leaf_lblk, &icur, &got) &&
got.br_startoff == leaf_lblk &&
got.br_blockcount == args.geo->fsbcount &&
- !xfs_iext_get_extent(ifp, ++idx, &got)) {
+ !xfs_iext_next_extent(ifp, &icur, &got)) {
if (is_block) {
xfs_scrub_fblock_set_corrupt(sc, XFS_DATA_FORK, lblk);
goto out;
@@ -702,7 +702,7 @@ xfs_scrub_directory_blocks(
/* Scan for free blocks */
lblk = free_lblk;
- found = xfs_iext_lookup_extent(sc->ip, ifp, lblk, &idx, &got);
+ found = xfs_iext_lookup_extent(sc->ip, ifp, lblk, &icur, &got);
while (found) {
/*
* Dirs can't have blocks mapped above 2^32.
@@ -740,7 +740,7 @@ xfs_scrub_directory_blocks(
}
dabno = got.br_startoff + got.br_blockcount;
lblk = roundup(dabno, args.geo->fsbcount);
- found = xfs_iext_lookup_extent(sc->ip, ifp, lblk, &idx, &got);
+ found = xfs_iext_lookup_extent(sc->ip, ifp, lblk, &icur, &got);
}
out:
return error;