Define and use e2fs_lbn_t in ext2fs.
In line to what is done in UFS, define an internal type e2fs_lbn_t for the logical block numbers. This change is basically a no-op as the new type is unchanged (int32_t) but it may be useful as bumping this may be required for ext4fs. Also, as pointed out by Bruce Evans: -Use daddr_t for daddr in ext2_bmaparray(). This seems to improve reliability with the reallocblks option. - Add a cast to the fsbtodb() macro as in UFS. Reviewed by: bde MFC after: 3 days
This commit is contained in:
parent
13f8962353
commit
da057ed2d3
@ -165,7 +165,8 @@ ext2_reallocblks(struct vop_reallocblks_args *ap)
|
||||
struct ext2mount *ump;
|
||||
struct cluster_save *buflist;
|
||||
struct indir start_ap[NIADDR + 1], end_ap[NIADDR + 1], *idp;
|
||||
int32_t start_lbn, end_lbn, soff, newblk, blkno;
|
||||
e2fs_lbn_t start_lbn, end_lbn;
|
||||
int32_t soff, newblk, blkno;
|
||||
int i, len, start_lvl, end_lvl, pref, ssize;
|
||||
|
||||
if (doreallocblks == 0)
|
||||
@ -550,7 +551,7 @@ ext2_dirpref(struct inode *pip)
|
||||
* that will hold the pointer
|
||||
*/
|
||||
int32_t
|
||||
ext2_blkpref(struct inode *ip, int32_t lbn, int indx, int32_t *bap,
|
||||
ext2_blkpref(struct inode *ip, e2fs_lbn_t lbn, int indx, int32_t *bap,
|
||||
int32_t blocknr)
|
||||
{
|
||||
int tmp;
|
||||
|
@ -57,7 +57,7 @@
|
||||
* the inode and the logical block number in a file.
|
||||
*/
|
||||
int
|
||||
ext2_balloc(struct inode *ip, int32_t lbn, int size, struct ucred *cred,
|
||||
ext2_balloc(struct inode *ip, e2fs_lbn_t lbn, int size, struct ucred *cred,
|
||||
struct buf **bpp, int flags)
|
||||
{
|
||||
struct m_ext2fs *fs;
|
||||
|
@ -99,8 +99,8 @@ ext2_bmaparray(struct vnode *vp, int32_t bn, int32_t *bnp, int *runp, int *runb)
|
||||
struct mount *mp;
|
||||
struct vnode *devvp;
|
||||
struct indir a[NIADDR+1], *ap;
|
||||
int32_t daddr;
|
||||
long metalbn;
|
||||
daddr_t daddr;
|
||||
e2fs_lbn_t metalbn;
|
||||
int error, num, maxrun = 0, bsize;
|
||||
int *nump;
|
||||
|
||||
@ -241,7 +241,8 @@ ext2_bmaparray(struct vnode *vp, int32_t bn, int32_t *bnp, int *runp, int *runb)
|
||||
int
|
||||
ext2_getlbns(struct vnode *vp, int32_t bn, struct indir *ap, int *nump)
|
||||
{
|
||||
long blockcnt, metalbn, realbn;
|
||||
long blockcnt;
|
||||
e2fs_lbn_t metalbn, realbn;
|
||||
struct ext2mount *ump;
|
||||
int i, numlevels, off;
|
||||
int64_t qblockcnt;
|
||||
|
@ -49,10 +49,10 @@ struct vnode;
|
||||
int ext2_alloc(struct inode *,
|
||||
int32_t, int32_t, int, struct ucred *, int32_t *);
|
||||
int ext2_balloc(struct inode *,
|
||||
int32_t, int, struct ucred *, struct buf **, int);
|
||||
e2fs_lbn_t, int, struct ucred *, struct buf **, int);
|
||||
int ext2_blkatoff(struct vnode *, off_t, char **, struct buf **);
|
||||
void ext2_blkfree(struct inode *, int32_t, long);
|
||||
int32_t ext2_blkpref(struct inode *, int32_t, int, int32_t *, int32_t);
|
||||
int32_t ext2_blkpref(struct inode *, e2fs_lbn_t, int, int32_t *, int32_t);
|
||||
int ext2_bmap(struct vop_bmap_args *);
|
||||
int ext2_bmaparray(struct vnode *, int32_t, int32_t *, int *, int *);
|
||||
void ext2_clusteracct(struct m_ext2fs *, char *, int, daddr_t, int);
|
||||
|
@ -68,7 +68,7 @@ ext2_blkatoff(struct vnode *vp, off_t offset, char **res, struct buf **bpp)
|
||||
struct inode *ip;
|
||||
struct m_ext2fs *fs;
|
||||
struct buf *bp;
|
||||
int32_t lbn;
|
||||
e2fs_lbn_t lbn;
|
||||
int bsize, error;
|
||||
|
||||
ip = VTOI(vp);
|
||||
|
@ -98,8 +98,8 @@
|
||||
* Turn file system block numbers into disk block addresses.
|
||||
* This maps file system blocks to device size blocks.
|
||||
*/
|
||||
#define fsbtodb(fs, b) ((b) << ((fs)->e2fs_fsbtodb))
|
||||
#define dbtofsb(fs, b) ((b) >> ((fs)->e2fs_fsbtodb))
|
||||
#define fsbtodb(fs, b) ((daddr_t)(b) << (fs)->e2fs_fsbtodb)
|
||||
#define dbtofsb(fs, b) ((b) >> (fs)->e2fs_fsbtodb)
|
||||
|
||||
/* get group containing inode */
|
||||
#define ino_to_cg(fs, x) (((x) - 1) / (fs->e2fs_ipg))
|
||||
|
@ -49,6 +49,11 @@
|
||||
#define NDADDR 12 /* Direct addresses in inode. */
|
||||
#define NIADDR 3 /* Indirect addresses in inode. */
|
||||
|
||||
/*
|
||||
* The size of physical and logical block numbers and time fields in UFS.
|
||||
*/
|
||||
typedef int32_t e2fs_lbn_t;
|
||||
|
||||
/*
|
||||
* The inode is used to describe each active (or recently active) file in the
|
||||
* EXT2FS filesystem. It is composed of two types of information. The first
|
||||
@ -148,7 +153,7 @@ struct inode {
|
||||
* ext2_getlbns and used by truncate and bmap code.
|
||||
*/
|
||||
struct indir {
|
||||
int32_t in_lbn; /* Logical block number. */
|
||||
e2fs_lbn_t in_lbn; /* Logical block number. */
|
||||
int in_off; /* Offset in buffer. */
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user