Fix physical block number overflow in different places.

Approved by:    pfg (mentor)
MFC after:      6 months
This commit is contained in:
fsu 2017-10-24 20:10:08 +00:00
parent be8349452e
commit edb3be92a6
4 changed files with 14 additions and 13 deletions

View File

@ -56,8 +56,8 @@
static daddr_t ext2_alloccg(struct inode *, int, daddr_t, int);
static daddr_t ext2_clusteralloc(struct inode *, int, daddr_t, int);
static u_long ext2_dirpref(struct inode *);
static u_long ext2_hashalloc(struct inode *, int, long, int,
daddr_t (*)(struct inode *, int, daddr_t,
static e4fs_daddr_t ext2_hashalloc(struct inode *, int, long, int,
daddr_t (*)(struct inode *, int, daddr_t,
int));
static daddr_t ext2_nodealloccg(struct inode *, int, daddr_t, int);
static daddr_t ext2_mapsearch(struct m_ext2fs *, char *, daddr_t);
@ -85,7 +85,7 @@ ext2_alloc(struct inode *ip, daddr_t lbn, e4fs_daddr_t bpref, int size,
{
struct m_ext2fs *fs;
struct ext2mount *ump;
int32_t bno;
e4fs_daddr_t bno;
int cg;
*bnp = 0;
@ -134,7 +134,7 @@ ext2_alloc(struct inode *ip, daddr_t lbn, e4fs_daddr_t bpref, int size,
/*
* Allocate EA's block for inode.
*/
daddr_t
e4fs_daddr_t
ext2_alloc_meta(struct inode *ip)
{
struct m_ext2fs *fs;
@ -617,12 +617,12 @@ ext2_blkpref(struct inode *ip, e2fs_lbn_t lbn, int indx, e2fs_daddr_t *bap,
* 2) quadradically rehash on the cylinder group number.
* 3) brute force search for a free block.
*/
static u_long
static e4fs_daddr_t
ext2_hashalloc(struct inode *ip, int cg, long pref, int size,
daddr_t (*allocator) (struct inode *, int, daddr_t, int))
{
struct m_ext2fs *fs;
ino_t result;
e4fs_daddr_t result;
int i, icg = cg;
mtx_assert(EXT2_MTX(ip->i_ump), MA_OWNED);
@ -1181,7 +1181,7 @@ ext2_blkfree(struct inode *ip, e4fs_daddr_t bno, long size)
fs = ip->i_e2fs;
ump = ip->i_ump;
cg = dtog(fs, bno);
if ((u_int)bno >= fs->e2fs->e2fs_bcount) {
if (bno >= fs->e2fs->e2fs_bcount) {
printf("bad block %lld, ino %ju\n", (long long)bno,
(uintmax_t)ip->i_number);
ext2_fserr(fs, ip->i_uid, "bad block");

View File

@ -51,7 +51,7 @@ struct vnode;
int ext2_add_entry(struct vnode *, struct ext2fs_direct_2 *);
int ext2_alloc(struct inode *, daddr_t, e4fs_daddr_t, int,
struct ucred *, e4fs_daddr_t *);
daddr_t ext2_alloc_meta(struct inode *ip);
e4fs_daddr_t ext2_alloc_meta(struct inode *ip);
int ext2_balloc(struct inode *,
e2fs_lbn_t, int, struct ucred *, struct buf **, int);
int ext2_blkatoff(struct vnode *, off_t, char **, struct buf **);
@ -61,7 +61,7 @@ e4fs_daddr_t ext2_blkpref(struct inode *, e2fs_lbn_t, int, e2fs_daddr_t *,
int ext2_bmap(struct vop_bmap_args *);
int ext2_bmaparray(struct vnode *, daddr_t, daddr_t *, int *, int *);
int ext4_bmapext(struct vnode *, int32_t, int64_t *, int *, int *);
void ext2_clusteracct(struct m_ext2fs *, char *, int, daddr_t, int);
void ext2_clusteracct(struct m_ext2fs *, char *, int, e4fs_daddr_t, int);
void ext2_dirbad(struct inode *ip, doff_t offset, char *how);
void ext2_fserr(struct m_ext2fs *, uid_t, char *);
void ext2_ei2i(struct ext2fs_dinode *, struct inode *);

View File

@ -224,9 +224,9 @@ ext2_ind_truncate(struct vnode *vp, off_t length, int flags, struct ucred *cred,
struct thread *td)
{
struct vnode *ovp = vp;
int32_t lastblock;
e4fs_daddr_t lastblock;
struct inode *oip;
int32_t bn, lbn, lastiblock[EXT2_NIADDR], indir_lbn[EXT2_NIADDR];
e4fs_daddr_t bn, lbn, lastiblock[EXT2_NIADDR], indir_lbn[EXT2_NIADDR];
uint32_t oldblks[EXT2_NDADDR + EXT2_NIADDR];
uint32_t newblks[EXT2_NDADDR + EXT2_NIADDR];
struct m_ext2fs *fs;

View File

@ -91,11 +91,12 @@ ext2_blkatoff(struct vnode *vp, off_t offset, char **res, struct buf **bpp)
* Cnt == 1 means free; cnt == -1 means allocating.
*/
void
ext2_clusteracct(struct m_ext2fs *fs, char *bbp, int cg, daddr_t bno, int cnt)
ext2_clusteracct(struct m_ext2fs *fs, char *bbp, int cg, e4fs_daddr_t bno, int cnt)
{
int32_t *sump = fs->e2fs_clustersum[cg].cs_sum;
int32_t *lp;
int back, bit, end, forw, i, loc, start;
e4fs_daddr_t start, end, loc, forw, back;
int bit, i;
/* Initialize the cluster summary array. */
if (fs->e2fs_clustersum[cg].cs_init == 0) {