process_bmbt_reclist_int(
xfs_mount_t *mp,
xfs_bmbt_rec_t *rp,
- int numrecs,
+ int *numrecs,
int type,
xfs_ino_t ino,
xfs_drfsbno_t *tot,
else
ftype = _("regular");
- for (i = 0; i < numrecs; i++) {
+ for (i = 0; i < *numrecs; i++) {
libxfs_bmbt_disk_get_all(rp + i, &irec);
if (i == 0)
*last_key = *first_key = irec.br_startoff;
done:
if (locked_agno != -1)
pthread_mutex_unlock(&ag_locks[locked_agno]);
+
+ if (i != *numrecs) {
+ ASSERT(i < *numrecs);
+ do_warn(_("correcting nextents for inode %" PRIu64 "\n"), ino);
+ *numrecs = i;
+ }
+
return error;
}
process_bmbt_reclist(
xfs_mount_t *mp,
xfs_bmbt_rec_t *rp,
- int numrecs,
+ int *numrecs,
int type,
xfs_ino_t ino,
xfs_drfsbno_t *tot,
scan_bmbt_reclist(
xfs_mount_t *mp,
xfs_bmbt_rec_t *rp,
- int numrecs,
+ int *numrecs,
int type,
xfs_ino_t ino,
xfs_drfsbno_t *tot,
xfs_bmbt_rec_t *rp;
xfs_dfiloff_t first_key;
xfs_dfiloff_t last_key;
+ int numrecs;
+ int ret;
lino = XFS_AGINO_TO_INO(mp, agno, ino);
rp = (xfs_bmbt_rec_t *)XFS_DFORK_PTR(dip, whichfork);
*tot = 0;
- *nex = XFS_DFORK_NEXTENTS(dip, whichfork);
+ numrecs = XFS_DFORK_NEXTENTS(dip, whichfork);
+
/*
* XXX - if we were going to fix up the btree record,
* we'd do it right here. For now, if there's a problem,
* we'll bail out and presumably clear the inode.
*/
if (check_dups == 0)
- return(process_bmbt_reclist(mp, rp, *nex, type, lino,
+ ret = process_bmbt_reclist(mp, rp, &numrecs, type, lino,
tot, blkmapp, &first_key, &last_key,
- whichfork));
+ whichfork);
else
- return(scan_bmbt_reclist(mp, rp, *nex, type, lino, tot,
- whichfork));
+ ret = scan_bmbt_reclist(mp, rp, &numrecs, type, lino, tot,
+ whichfork);
+
+ *nex = numrecs;
+ return ret;
}
/*
lino, anextents);
}
}
+
+ /*
+ * We are comparing different units here, but that's fine given that
+ * an extent has to have at least a block in it.
+ */
+ if (nblocks < nextents + anextents) {
+ do_warn(
+_("nblocks (%" PRIu64 ") smaller than nextents for inode %" PRIu64 "\n"), nblocks, lino);
+ return 1;
+ }
+
return 0;
}
* we'll bail out and presumably clear the inode.
*/
if (check_dups == 0) {
- err = process_bmbt_reclist(mp, rp, numrecs,
- type, ino, tot, blkmapp,
- &first_key, &last_key,
- whichfork);
+ err = process_bmbt_reclist(mp, rp, &numrecs, type, ino,
+ tot, blkmapp, &first_key,
+ &last_key, whichfork);
if (err)
- return(1);
+ return 1;
+
/*
* check that key ordering is monotonically increasing.
* if the last_key value in the cursor is set to
bm_cursor->level[level].first_key = first_key;
bm_cursor->level[level].last_key = last_key;
- return(0);
- } else
- return(scan_bmbt_reclist(mp, rp, numrecs,
- type, ino, tot, whichfork));
+ return 0;
+ } else {
+ return scan_bmbt_reclist(mp, rp, &numrecs, type, ino,
+ tot, whichfork);
+ }
}
if (numrecs > mp->m_bmap_dmxr[1] || (isroot == 0 && numrecs <
mp->m_bmap_dmnr[1])) {