Date: Sun, 23 Jun 2013 02:44:42 +0000 (UTC) From: "Pedro F. Giffuni" <pfg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r252103 - head/sys/fs/ext2fs Message-ID: <201306230244.r5N2ig2a066840@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: pfg Date: Sun Jun 23 02:44:42 2013 New Revision: 252103 URL: http://svnweb.freebsd.org/changeset/base/252103 Log: 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 Modified: head/sys/fs/ext2fs/ext2_alloc.c head/sys/fs/ext2fs/ext2_balloc.c head/sys/fs/ext2fs/ext2_bmap.c head/sys/fs/ext2fs/ext2_extern.h head/sys/fs/ext2fs/ext2_subr.c head/sys/fs/ext2fs/fs.h head/sys/fs/ext2fs/inode.h Modified: head/sys/fs/ext2fs/ext2_alloc.c ============================================================================== --- head/sys/fs/ext2fs/ext2_alloc.c Sun Jun 23 00:01:28 2013 (r252102) +++ head/sys/fs/ext2fs/ext2_alloc.c Sun Jun 23 02:44:42 2013 (r252103) @@ -165,7 +165,8 @@ ext2_reallocblks(struct vop_reallocblks_ 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; Modified: head/sys/fs/ext2fs/ext2_balloc.c ============================================================================== --- head/sys/fs/ext2fs/ext2_balloc.c Sun Jun 23 00:01:28 2013 (r252102) +++ head/sys/fs/ext2fs/ext2_balloc.c Sun Jun 23 02:44:42 2013 (r252103) @@ -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; Modified: head/sys/fs/ext2fs/ext2_bmap.c ============================================================================== --- head/sys/fs/ext2fs/ext2_bmap.c Sun Jun 23 00:01:28 2013 (r252102) +++ head/sys/fs/ext2fs/ext2_bmap.c Sun Jun 23 02:44:42 2013 (r252103) @@ -99,8 +99,8 @@ ext2_bmaparray(struct vnode *vp, int32_t 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 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; Modified: head/sys/fs/ext2fs/ext2_extern.h ============================================================================== --- head/sys/fs/ext2fs/ext2_extern.h Sun Jun 23 00:01:28 2013 (r252102) +++ head/sys/fs/ext2fs/ext2_extern.h Sun Jun 23 02:44:42 2013 (r252103) @@ -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); Modified: head/sys/fs/ext2fs/ext2_subr.c ============================================================================== --- head/sys/fs/ext2fs/ext2_subr.c Sun Jun 23 00:01:28 2013 (r252102) +++ head/sys/fs/ext2fs/ext2_subr.c Sun Jun 23 02:44:42 2013 (r252103) @@ -68,7 +68,7 @@ ext2_blkatoff(struct vnode *vp, off_t of struct inode *ip; struct m_ext2fs *fs; struct buf *bp; - int32_t lbn; + e2fs_lbn_t lbn; int bsize, error; ip = VTOI(vp); Modified: head/sys/fs/ext2fs/fs.h ============================================================================== --- head/sys/fs/ext2fs/fs.h Sun Jun 23 00:01:28 2013 (r252102) +++ head/sys/fs/ext2fs/fs.h Sun Jun 23 02:44:42 2013 (r252103) @@ -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)) Modified: head/sys/fs/ext2fs/inode.h ============================================================================== --- head/sys/fs/ext2fs/inode.h Sun Jun 23 00:01:28 2013 (r252102) +++ head/sys/fs/ext2fs/inode.h Sun Jun 23 02:44:42 2013 (r252103) @@ -50,6 +50,11 @@ #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 * part is the information that is needed only while the file is active (such @@ -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. */ };
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201306230244.r5N2ig2a066840>