@@ -34,8 +34,9 @@ blkmap_alloc(
if (nex < 1)
nex = 1;
+ nex = min(nex, XFS_MAX_EXTCNT_DATA_FORK_LARGE);
-#if (BITS_PER_LONG == 32) /* on 64-bit platforms this is never true */
+#ifdef BLKMAP_NEXTS_MAX
if (nex > BLKMAP_NEXTS_MAX) {
do_warn(
_("Number of extents requested in blkmap_alloc (%llu) overflows 32 bits.\n"
@@ -115,7 +116,7 @@ blkmap_get(
xfs_fileoff_t o)
{
bmap_ext_t *ext = blkmap->exts;
- int i;
+ xfs_extnum_t i;
for (i = 0; i < blkmap->nexts; i++, ext++) {
if (o >= ext->startoff && o < ext->startoff + ext->blockcount)
@@ -137,7 +138,7 @@ blkmap_getn(
{
bmap_ext_t *bmp = NULL;
bmap_ext_t *ext;
- int i;
+ xfs_extnum_t i;
int nex;
if (nb == 1) {
@@ -233,7 +234,7 @@ xfs_fileoff_t
blkmap_next_off(
blkmap_t *blkmap,
xfs_fileoff_t o,
- int *t)
+ xfs_extnum_t *t)
{
bmap_ext_t *ext;
@@ -263,7 +264,7 @@ blkmap_grow(
{
pthread_key_t key = dblkmap_key;
blkmap_t *new_blkmap;
- int new_naexts;
+ xfs_extnum_t new_naexts;
/* reduce the number of reallocations for large files */
if (blkmap->naexts < 1000)
@@ -278,20 +279,21 @@ blkmap_grow(
ASSERT(pthread_getspecific(key) == blkmap);
}
-#if (BITS_PER_LONG == 32) /* on 64-bit platforms this is never true */
+#ifdef BLKMAP_NEXTS_MAX
if (new_naexts > BLKMAP_NEXTS_MAX) {
do_error(
- _("Number of extents requested in blkmap_grow (%d) overflows 32 bits.\n"
+ _("Number of extents requested in blkmap_grow (%llu) overflows 32 bits.\n"
"You need a 64 bit system to repair this filesystem.\n"),
- new_naexts);
+ (unsigned long long)new_naexts);
return NULL;
}
#endif
- if (new_naexts <= 0) {
+ if (new_naexts > XFS_MAX_EXTCNT_DATA_FORK_LARGE) {
do_error(
- _("Number of extents requested in blkmap_grow (%d) overflowed the\n"
- "maximum number of supported extents (%d).\n"),
- new_naexts, BLKMAP_NEXTS_MAX);
+ _("Number of extents requested in blkmap_grow (%llu) overflowed the\n"
+ "maximum number of supported extents (%llu).\n"),
+ (unsigned long long)new_naexts,
+ (unsigned long long)XFS_MAX_EXTCNT_DATA_FORK_LARGE);
return NULL;
}
@@ -20,8 +20,8 @@ typedef struct bmap_ext {
* Block map.
*/
typedef struct blkmap {
- int naexts;
- int nexts;
+ xfs_extnum_t naexts;
+ xfs_extnum_t nexts;
bmap_ext_t exts[1];
} blkmap_t;
@@ -37,8 +37,6 @@ typedef struct blkmap {
*/
#if BITS_PER_LONG == 32
#define BLKMAP_NEXTS_MAX ((INT_MAX / sizeof(bmap_ext_t)) - 1)
-#else
-#define BLKMAP_NEXTS_MAX INT_MAX
#endif
extern pthread_key_t dblkmap_key;
@@ -56,6 +54,7 @@ int blkmap_getn(blkmap_t *blkmap, xfs_fileoff_t o,
xfs_filblks_t nb, bmap_ext_t **bmpp,
bmap_ext_t *bmpp_single);
xfs_fileoff_t blkmap_last_off(blkmap_t *blkmap);
-xfs_fileoff_t blkmap_next_off(blkmap_t *blkmap, xfs_fileoff_t o, int *t);
+xfs_fileoff_t blkmap_next_off(blkmap_t *blkmap, xfs_fileoff_t o,
+ xfs_extnum_t *t);
#endif /* _XFS_REPAIR_BMAP_H */
@@ -1136,7 +1136,7 @@ process_quota_inode(
xfs_dqid_t dqid;
xfs_fileoff_t qbno;
int i;
- int t = 0;
+ xfs_extnum_t t = 0;
int error;
switch (ino_type) {
@@ -1327,7 +1327,7 @@ process_leaf_node_dir2(
int i;
xfs_fileoff_t ndbno;
int nex;
- int t;
+ xfs_extnum_t t;
bmap_ext_t lbmp;
int dirty = 0;