Skip to content

Commit 39ab26d

Browse files
author
Darrick J. Wong
committed
xfs: return a failure address from xfs_rmap_irec_offset_unpack
Currently, xfs_rmap_irec_offset_unpack returns only 0 or -EFSCORRUPTED. Change this function to return the code address of a failed conversion in preparation for the next patch, which standardizes localized record checking and reporting code. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Dave Chinner <dchinner@redhat.com>
1 parent 2b30cc0 commit 39ab26d

3 files changed

Lines changed: 14 additions & 15 deletions

File tree

fs/xfs/libxfs/xfs_rmap.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ xfs_rmap_delete(
193193
}
194194

195195
/* Convert an internal btree record to an rmap record. */
196-
int
196+
xfs_failaddr_t
197197
xfs_rmap_btrec_to_irec(
198198
const union xfs_btree_rec *rec,
199199
struct xfs_rmap_irec *irec)
@@ -2320,11 +2320,10 @@ xfs_rmap_query_range_helper(
23202320
{
23212321
struct xfs_rmap_query_range_info *query = priv;
23222322
struct xfs_rmap_irec irec;
2323-
int error;
23242323

2325-
error = xfs_rmap_btrec_to_irec(rec, &irec);
2326-
if (error)
2327-
return error;
2324+
if (xfs_rmap_btrec_to_irec(rec, &irec) != NULL)
2325+
return -EFSCORRUPTED;
2326+
23282327
return query->fn(cur, &irec, query->priv);
23292328
}
23302329

fs/xfs/libxfs/xfs_rmap.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,14 @@ xfs_rmap_irec_offset_pack(
6262
return x;
6363
}
6464

65-
static inline int
65+
static inline xfs_failaddr_t
6666
xfs_rmap_irec_offset_unpack(
6767
__u64 offset,
6868
struct xfs_rmap_irec *irec)
6969
{
7070
if (offset & ~(XFS_RMAP_OFF_MASK | XFS_RMAP_OFF_FLAGS))
71-
return -EFSCORRUPTED;
71+
return __this_address;
72+
7273
irec->rm_offset = XFS_RMAP_OFF(offset);
7374
irec->rm_flags = 0;
7475
if (offset & XFS_RMAP_OFF_ATTR_FORK)
@@ -77,7 +78,7 @@ xfs_rmap_irec_offset_unpack(
7778
irec->rm_flags |= XFS_RMAP_BMBT_BLOCK;
7879
if (offset & XFS_RMAP_OFF_UNWRITTEN)
7980
irec->rm_flags |= XFS_RMAP_UNWRITTEN;
80-
return 0;
81+
return NULL;
8182
}
8283

8384
static inline void
@@ -192,7 +193,7 @@ int xfs_rmap_lookup_le_range(struct xfs_btree_cur *cur, xfs_agblock_t bno,
192193
int xfs_rmap_compare(const struct xfs_rmap_irec *a,
193194
const struct xfs_rmap_irec *b);
194195
union xfs_btree_rec;
195-
int xfs_rmap_btrec_to_irec(const union xfs_btree_rec *rec,
196+
xfs_failaddr_t xfs_rmap_btrec_to_irec(const union xfs_btree_rec *rec,
196197
struct xfs_rmap_irec *irec);
197198
int xfs_rmap_has_record(struct xfs_btree_cur *cur, xfs_agblock_t bno,
198199
xfs_extlen_t len, bool *exists);

fs/xfs/scrub/rmap.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ xchk_rmapbt_rec(
100100
bool is_unwritten;
101101
bool is_bmbt;
102102
bool is_attr;
103-
int error;
104103

105-
error = xfs_rmap_btrec_to_irec(rec, &irec);
106-
if (!xchk_btree_process_error(bs->sc, bs->cur, 0, &error))
107-
goto out;
104+
if (xfs_rmap_btrec_to_irec(rec, &irec) != NULL) {
105+
xchk_btree_set_corrupt(bs->sc, bs->cur, 0);
106+
return 0;
107+
}
108108

109109
/* Check extent. */
110110
if (irec.rm_startblock + irec.rm_blockcount <= irec.rm_startblock)
@@ -159,8 +159,7 @@ xchk_rmapbt_rec(
159159
}
160160

161161
xchk_rmapbt_xref(bs->sc, &irec);
162-
out:
163-
return error;
162+
return 0;
164163
}
165164

166165
/* Scrub the rmap btree for some AG. */

0 commit comments

Comments
 (0)