return verify_ag_bno(sbp, agno, agbno) == 0;
}
-void
-convert_extent(
- xfs_bmbt_rec_32_t *rp,
- xfs_dfiloff_t *op, /* starting offset (blockno in file) */
- xfs_dfsbno_t *sp, /* starting block (fs blockno) */
- xfs_dfilblks_t *cp, /* blockcount */
- int *fp) /* extent flag */
-{
- xfs_bmbt_irec_t irec, *s = &irec;
- xfs_bmbt_rec_t rpcopy, *p = &rpcopy;
-
- memcpy(&rpcopy, rp, sizeof(rpcopy));
- /* Just use the extent parsing routine from the kernel */
- libxfs_bmbt_disk_get_all(p, s);
-
- if (fs_has_extflgbit) {
- if (s->br_state == XFS_EXT_UNWRITTEN) {
- *fp = 1;
- } else {
- *fp = 0;
- }
- } else {
- *fp = 0;
- }
- *op = s->br_startoff;
- *sp = s->br_startblock;
- *cp = s->br_blockcount;
-}
-
/*
* return address of block fblock if it's within the range described
* by the extent list. Otherwise, returns a null address.
xfs_dfsbno_t
get_bmbt_reclist(
xfs_mount_t *mp,
- xfs_bmbt_rec_32_t *rp,
+ xfs_bmbt_rec_t *rp,
int numrecs,
xfs_dfiloff_t fblock)
{
int i;
- xfs_dfilblks_t cnt;
- xfs_dfiloff_t off_bno;
- xfs_dfsbno_t start;
- int flag;
+ xfs_bmbt_irec_t irec;
for (i = 0; i < numrecs; i++, rp++) {
- convert_extent(rp, &off_bno, &start, &cnt, &flag);
- if (off_bno >= fblock && off_bno + cnt < fblock)
- return(start + fblock - off_bno);
+ libxfs_bmbt_disk_get_all(rp, &irec);
+ if (irec.br_startoff >= fblock &&
+ irec.br_startoff + irec.br_blockcount < fblock)
+ return (irec.br_startblock + fblock - irec.br_startoff);
}
return(NULLDFSBNO);
static int
process_rt_rec(
xfs_mount_t *mp,
- xfs_bmbt_rec_32_t *rp,
+ xfs_bmbt_irec_t *irec,
xfs_ino_t ino,
xfs_drfsbno_t *tot,
int check_dups)
{
xfs_dfsbno_t b;
xfs_drtbno_t ext;
- xfs_dfilblks_t c; /* count */
- xfs_dfsbno_t s; /* start */
- xfs_dfiloff_t o; /* offset */
int state;
- int flag; /* extent flag */
int pwe; /* partially-written extent */
- convert_extent(rp, &o, &s, &c, &flag);
-
/*
* check numeric validity of the extent
*/
- if (s >= mp->m_sb.sb_rblocks) {
+ if (irec->br_startblock >= mp->m_sb.sb_rblocks) {
do_warn(_("inode %llu - bad rt extent start block number "
- "%llu, offset %llu\n"), ino, s, o);
+ "%llu, offset %llu\n"), ino,
+ irec->br_startblock, irec->br_startoff);
return 1;
}
- if (s + c - 1 >= mp->m_sb.sb_rblocks) {
+ if (irec->br_startblock + irec->br_blockcount - 1 >= mp->m_sb.sb_rblocks) {
do_warn(_("inode %llu - bad rt extent last block number %llu, "
- "offset %llu\n"), ino, s + c - 1, o);
+ "offset %llu\n"), ino, irec->br_startblock +
+ irec->br_blockcount - 1, irec->br_startoff);
return 1;
}
- if (s + c - 1 < s) {
+ if (irec->br_startblock + irec->br_blockcount - 1 < irec->br_startblock) {
do_warn(_("inode %llu - bad rt extent overflows - start %llu, "
- "end %llu, offset %llu\n"),
- ino, s, s + c - 1, o);
+ "end %llu, offset %llu\n"), ino,
+ irec->br_startblock, irec->br_startblock +
+ irec->br_blockcount - 1, irec->br_startoff);
return 1;
}
* are multiples of an extent
*/
if (XFS_SB_VERSION_HASEXTFLGBIT(&mp->m_sb) == 0 &&
- (s % mp->m_sb.sb_rextsize != 0 ||
- c % mp->m_sb.sb_rextsize != 0)) {
+ (irec->br_startblock % mp->m_sb.sb_rextsize != 0 ||
+ irec->br_blockcount % mp->m_sb.sb_rextsize != 0)) {
do_warn(_("malformed rt inode extent [%llu %llu] (fs rtext "
- "size = %u)\n"), s, c, mp->m_sb.sb_rextsize);
+ "size = %u)\n"), irec->br_startblock,
+ irec->br_blockcount, mp->m_sb.sb_rextsize);
return 1;
}
/*
* set the appropriate number of extents
*/
- for (b = s; b < s + c; b += mp->m_sb.sb_rextsize) {
+ for (b = irec->br_startblock; b < irec->br_startblock +
+ irec->br_blockcount; b += mp->m_sb.sb_rextsize) {
ext = (xfs_drtbno_t) b / mp->m_sb.sb_rextsize;
- pwe = XFS_SB_VERSION_HASEXTFLGBIT(&mp->m_sb) && flag &&
+ pwe = XFS_SB_VERSION_HASEXTFLGBIT(&mp->m_sb) &&
+ irec->br_state == XFS_EXT_UNWRITTEN &&
(b % mp->m_sb.sb_rextsize != 0);
if (check_dups == 1) {
do_warn(_("data fork in rt ino %llu claims "
"dup rt extent, off - %llu, "
"start - %llu, count %llu\n"),
- ino, o, s, c);
+ ino, irec->br_startoff,
+ irec->br_startblock,
+ irec->br_blockcount);
return 1;
}
continue;
case XR_E_INO:
case XR_E_INUSE_FS:
do_error(_("data fork in rt inode %llu found "
- "metadata block %llu in rt bmap\n"),
- ino, ext);
+ "metadata block %llu in rt bmap\n"),
+ ino, ext);
case XR_E_INUSE:
if (pwe)
/*
* bump up the block counter
*/
- *tot += c;
+ *tot += irec->br_blockcount;
return 0;
}
int
process_bmbt_reclist_int(
xfs_mount_t *mp,
- xfs_bmbt_rec_32_t *rp,
+ xfs_bmbt_rec_t *rp,
int numrecs,
int type,
xfs_ino_t ino,
int check_dups,
int whichfork)
{
- xfs_dfsbno_t b;
- xfs_dfilblks_t c; /* count */
+ xfs_bmbt_irec_t irec;
xfs_dfilblks_t cp = 0; /* prev count */
- xfs_dfsbno_t s; /* start */
xfs_dfsbno_t sp = 0; /* prev start */
- xfs_dfiloff_t o = 0; /* offset */
xfs_dfiloff_t op = 0; /* prev offset */
+ xfs_dfsbno_t b;
char *ftype;
char *forkname;
int i;
int state;
- int flag; /* extent flag */
xfs_dfsbno_t e;
xfs_agnumber_t agno;
xfs_agblock_t agbno;
ftype = _("regular");
for (i = 0; i < numrecs; i++, rp++) {
- convert_extent(rp, &o, &s, &c, &flag);
+ libxfs_bmbt_disk_get_all(rp, &irec);
if (i == 0)
- *last_key = *first_key = o;
+ *last_key = *first_key = irec.br_startoff;
else
- *last_key = o;
- if (i > 0 && op + cp > o) {
+ *last_key = irec.br_startoff;
+ if (i > 0 && op + cp > irec.br_startoff) {
do_warn(_("bmap rec out of order, inode %llu entry %d "
"[o s c] [%llu %llu %llu], %d [%llu %llu %llu]\n"),
- ino, i, o, s, c, i-1, op, sp, cp);
+ ino, i, irec.br_startoff, irec.br_startblock,
+ irec.br_blockcount, i - 1, op, sp, cp);
goto done;
}
- op = o;
- cp = c;
- sp = s;
+ op = irec.br_startoff;
+ cp = irec.br_blockcount;
+ sp = irec.br_startblock;
/*
* check numeric validity of the extent
*/
- if (c == 0) {
- do_warn(_("zero length extent (off = %llu, "
- "fsbno = %llu) in ino %llu\n"), o, s, ino);
+ if (irec.br_blockcount == 0) {
+ do_warn(_("zero length extent (off = %llu, fsbno = "
+ "%llu) in ino %llu\n"), irec.br_startoff,
+ irec.br_startblock, ino);
goto done;
}
* realtime bitmaps don't use AG locks, so returning
* immediately is fine for this code path.
*/
- if (process_rt_rec(mp, rp, ino, tot, check_dups))
+ if (process_rt_rec(mp, &irec, ino, tot, check_dups))
return 1;
/*
- * skip rest of loop processing since that's
+ * skip rest of loop processing since that'irec.br_startblock
* all for regular file forks and attr forks
*/
continue;
/*
* regular file data fork or attribute fork
*/
- switch (verify_dfsbno_range(mp, s, c)) {
+ switch (verify_dfsbno_range(mp, irec.br_startblock,
+ irec.br_blockcount)) {
case XR_DFSBNORANGE_VALID:
break;
case XR_DFSBNORANGE_BADSTART:
do_warn(_("inode %llu - bad extent starting "
"block number %llu, offset %llu\n"),
- ino, s, o);
+ ino, irec.br_startblock,
+ irec.br_startoff);
goto done;
case XR_DFSBNORANGE_BADEND:
do_warn(_("inode %llu - bad extent last block "
- "number %llu, offset %llu\n"),
- ino, s + c - 1, o);
+ "number %llu, offset %llu\n"), ino,
+ irec.br_startblock + irec.br_blockcount
+ - 1, irec.br_startoff);
goto done;
case XR_DFSBNORANGE_OVERFLOW:
do_warn(_("inode %llu - bad extent overflows - "
"start %llu, end %llu, offset %llu\n"),
- ino, s, s + c - 1, o);
+ ino, irec.br_startblock,
+ irec.br_startblock + irec.br_blockcount
+ - 1, irec.br_startoff);
goto done;
}
- if (o >= fs_max_file_offset) {
+ if (irec.br_startoff >= fs_max_file_offset) {
do_warn(_("inode %llu - extent offset too large - "
"start %llu, count %llu, offset %llu\n"),
- ino, s, c, o);
+ ino, irec.br_startblock, irec.br_blockcount,
+ irec.br_startoff);
goto done;
}
if (blkmapp && *blkmapp)
- blkmap_set_ext(blkmapp, o, s, c);
+ blkmap_set_ext(blkmapp, irec.br_startoff,
+ irec.br_startblock, irec.br_blockcount);
/*
* Profiling shows that the following loop takes the
* most time in all of xfs_repair.
*/
- agno = XFS_FSB_TO_AGNO(mp, s);
- agbno = XFS_FSB_TO_AGBNO(mp, s);
- e = s + c;
+ agno = XFS_FSB_TO_AGNO(mp, irec.br_startblock);
+ agbno = XFS_FSB_TO_AGBNO(mp, irec.br_startblock);
+ e = irec.br_startblock + irec.br_blockcount;
if (agno != locked_agno) {
if (locked_agno != -1)
pthread_mutex_unlock(&ag_locks[locked_agno]);
* checking each entry without setting the
* block bitmap
*/
- for (b = s; b < e; b++, agbno++) {
+ for (b = irec.br_startblock; b < e; b++, agbno++) {
if (search_dup_extent(mp, agno, agbno)) {
do_warn(_("%s fork in ino %llu claims "
"dup extent, off - %llu, "
"start - %llu, cnt %llu\n"),
- forkname, ino, o, s, c);
+ forkname, ino, irec.br_startoff,
+ irec.br_startblock,
+ irec.br_blockcount);
goto done;
}
}
- *tot += c;
+ *tot += irec.br_blockcount;
continue;
}
- for (b = s; b < e; b++, agbno++) {
+ for (b = irec.br_startblock; b < e; b++, agbno++) {
/*
* Process in chunks of 16 (XR_BB_UNIT/XR_BB)
* for common XR_E_UNKNOWN to XR_E_INUSE transition
*/
- if (((agbno & XR_BB_MASK) == 0) && ((s + c - b) >= (XR_BB_UNIT/XR_BB))) {
+ if (((agbno & XR_BB_MASK) == 0) && ((irec.br_startblock + irec.br_blockcount - b) >= (XR_BB_UNIT/XR_BB))) {
if (ba_bmap[agno][agbno>>XR_BB] == XR_E_UNKNOWN_LL) {
ba_bmap[agno][agbno>>XR_BB] = XR_E_INUSE_LL;
agbno += (XR_BB_UNIT/XR_BB) - 1;
state, b);
}
}
- *tot += c;
+ *tot += irec.br_blockcount;
}
error = 0;
done:
xfs_dfiloff_t *last_key,
int whichfork)
{
- return(process_bmbt_reclist_int(mp, rp, numrecs, type, ino, tot,
- blkmapp, first_key, last_key, 0,
- whichfork));
+ return(process_bmbt_reclist_int(mp, (xfs_bmbt_rec_t *)rp, numrecs, type,
+ ino, tot, blkmapp, first_key, last_key,
+ 0, whichfork));
}
/*
xfs_dfiloff_t first_key = 0;
xfs_dfiloff_t last_key = 0;
- return(process_bmbt_reclist_int(mp, rp, numrecs, type, ino, tot,
- NULL, &first_key, &last_key, 1,
- whichfork));
+ return(process_bmbt_reclist_int(mp, (xfs_bmbt_rec_t *)rp, numrecs, type,
+ ino, tot, NULL, &first_key, &last_key,
+ 1, whichfork));
}
/*
xfs_dfiloff_t bno,
int whichfork)
{
- xfs_dfiloff_t fbno;
- xfs_dfilblks_t bcnt;
- xfs_dfsbno_t fsbno;
+ xfs_bmbt_irec_t irec;
xfs_dfsbno_t final_fsbno = NULLDFSBNO;
- xfs_bmbt_rec_32_t *rootblock = (xfs_bmbt_rec_32_t *)
+ xfs_bmbt_rec_t *rootblock = (xfs_bmbt_rec_t *)
XFS_DFORK_PTR(dip, whichfork);
xfs_extnum_t nextents = XFS_DFORK_NEXTENTS(dip, whichfork);
int i;
- int flag;
for (i = 0; i < nextents; i++) {
- convert_extent(rootblock + i, &fbno, &fsbno, &bcnt, &flag);
-
- if (fbno <= bno && bno < fbno + bcnt) {
- final_fsbno = bno - fbno + fsbno;
+ libxfs_bmbt_disk_get_all(rootblock + i, &irec);
+ if (irec.br_startoff <= bno &&
+ bno < irec.br_startoff + irec.br_blockcount) {
+ final_fsbno = bno - irec.br_startoff + irec.br_startblock;
break;
}
}
#ifdef DEBUG
int prev_level;
#endif
- int flag;
int found;
- xfs_bmbt_rec_32_t *rec;
+ xfs_bmbt_rec_t *rec;
+ xfs_bmbt_irec_t irec;
xfs_bmbt_ptr_t *pp;
xfs_bmbt_key_t *key;
xfs_bmdr_key_t *rkey;
xfs_bmdr_ptr_t *rp;
- xfs_dfiloff_t fbno;
xfs_dfsbno_t fsbno;
- xfs_dfilblks_t bcnt;
xfs_buf_t *bp;
xfs_dfsbno_t final_fsbno = NULLDFSBNO;
xfs_bmbt_block_t *block;
ino, INT_GET(block->bb_numrecs, ARCH_CONVERT),
mp->m_bmap_dmnr[0]);
- rec = (xfs_bmbt_rec_32_t *)XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize,
- xfs_bmbt, block, 1, mp->m_bmap_dmxr[0]);
+ rec = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, xfs_bmbt, block, 1,
+ mp->m_bmap_dmxr[0]);
for (i = 0; i < INT_GET(block->bb_numrecs, ARCH_CONVERT); i++) {
- convert_extent(rec + i, &fbno, &fsbno, &bcnt, &flag);
-
- if (fbno <= bno && bno < fbno + bcnt) {
- final_fsbno = bno - fbno + fsbno;
+ libxfs_bmbt_disk_get_all(rec + i, &irec);
+ if (irec.br_startoff <= bno &&
+ bno < irec.br_startoff + irec.br_blockcount) {
+ final_fsbno = bno - irec.br_startoff + irec.br_startblock;
break;
}
}
int
process_symlink_extlist(xfs_mount_t *mp, xfs_ino_t lino, xfs_dinode_t *dino)
{
- xfs_dfsbno_t start; /* start */
- xfs_dfilblks_t cnt; /* count */
- xfs_dfiloff_t offset; /* offset */
xfs_dfiloff_t expected_offset;
- xfs_bmbt_rec_32_t *rp;
+ xfs_bmbt_rec_t *rp;
+ xfs_bmbt_irec_t irec;
int numrecs;
int i;
int max_blocks;
int whichfork = XFS_DATA_FORK;
- int flag;
if (INT_GET(dino->di_core.di_size, ARCH_CONVERT) <=
XFS_DFORK_SIZE(dino, mp, whichfork)) {
return(1);
}
- rp = (xfs_bmbt_rec_32_t *)XFS_DFORK_PTR(dino, whichfork);
+ rp = (xfs_bmbt_rec_t *)XFS_DFORK_PTR(dino, whichfork);
numrecs = XFS_DFORK_NEXTENTS(dino, whichfork);
/*
expected_offset = 0;
for (i = 0; numrecs > 0; i++, numrecs--) {
- convert_extent(rp, &offset, &start, &cnt, &flag);
+ libxfs_bmbt_disk_get_all(rp, &irec);
- if (offset != expected_offset) {
+ if (irec.br_startoff != expected_offset) {
do_warn(
_("bad extent #%d offset (%llu) in symlink %llu data fork\n"),
- i, offset, lino);
+ i, irec.br_startoff, lino);
return(1);
}
- if (cnt == 0 || cnt > max_blocks) {
+ if (irec.br_blockcount == 0 || irec.br_blockcount > max_blocks) {
do_warn(
_("bad extent #%d count (%llu) in symlink %llu data fork\n"),
- i, cnt, lino);
+ i, irec.br_blockcount, lino);
return(1);
}
- max_blocks -= cnt;
- expected_offset += cnt;
+ max_blocks -= irec.br_blockcount;
+ expected_offset += irec.br_blockcount;
}
return(0);