mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-03 23:28:58 +00:00
Avoid lost buffers in fsck_ffs.
Sponsored by: Netflix
(cherry picked from commit 4313e2ae44
)
This commit is contained in:
parent
b6aec78847
commit
010e3bc772
|
@ -264,6 +264,8 @@ ino_blkatoff(union dinode *dp, ino_t ino, ufs_lbn_t lbn, int *frags,
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
*frags = 0;
|
*frags = 0;
|
||||||
|
if (bpp != NULL)
|
||||||
|
*bpp = NULL;
|
||||||
/*
|
/*
|
||||||
* Handle extattr blocks first.
|
* Handle extattr blocks first.
|
||||||
*/
|
*/
|
||||||
|
@ -300,6 +302,8 @@ ino_blkatoff(union dinode *dp, ino_t ino, ufs_lbn_t lbn, int *frags,
|
||||||
continue;
|
continue;
|
||||||
if (lbn > 0 && lbn >= next)
|
if (lbn > 0 && lbn >= next)
|
||||||
continue;
|
continue;
|
||||||
|
if (DIP(dp, di_ib[i]) == 0)
|
||||||
|
return (0);
|
||||||
return (indir_blkatoff(DIP(dp, di_ib[i]), ino, -cur - i, lbn,
|
return (indir_blkatoff(DIP(dp, di_ib[i]), ino, -cur - i, lbn,
|
||||||
bpp));
|
bpp));
|
||||||
}
|
}
|
||||||
|
@ -321,8 +325,6 @@ indir_blkatoff(ufs2_daddr_t blk, ino_t ino, ufs_lbn_t cur, ufs_lbn_t lbn,
|
||||||
ufs_lbn_t base;
|
ufs_lbn_t base;
|
||||||
int i, level;
|
int i, level;
|
||||||
|
|
||||||
if (blk == 0)
|
|
||||||
return (0);
|
|
||||||
level = lbn_level(cur);
|
level = lbn_level(cur);
|
||||||
if (level == -1)
|
if (level == -1)
|
||||||
pfatal("Invalid indir lbn %jd in ino %ju\n",
|
pfatal("Invalid indir lbn %jd in ino %ju\n",
|
||||||
|
@ -352,12 +354,14 @@ indir_blkatoff(ufs2_daddr_t blk, ino_t ino, ufs_lbn_t cur, ufs_lbn_t lbn,
|
||||||
return (0);
|
return (0);
|
||||||
blk = IBLK(bp, i);
|
blk = IBLK(bp, i);
|
||||||
bp->b_index = i;
|
bp->b_index = i;
|
||||||
if (bpp != NULL)
|
if (cur == lbn || blk == 0) {
|
||||||
*bpp = bp;
|
if (bpp != NULL)
|
||||||
else
|
*bpp = bp;
|
||||||
brelse(bp);
|
else
|
||||||
if (cur == lbn)
|
brelse(bp);
|
||||||
return (blk);
|
return (blk);
|
||||||
|
}
|
||||||
|
brelse(bp);
|
||||||
if (level == 0)
|
if (level == 0)
|
||||||
pfatal("Invalid lbn %jd at level 0 for ino %ju\n", lbn,
|
pfatal("Invalid lbn %jd at level 0 for ino %ju\n", lbn,
|
||||||
(uintmax_t)ino);
|
(uintmax_t)ino);
|
||||||
|
|
Loading…
Reference in a new issue