svn commit: r246258 - head/sys/fs/ext2fs

Pedro F. Giffuni pfg at FreeBSD.org
Sat Feb 2 22:23:47 UTC 2013


Author: pfg
Date: Sat Feb  2 22:23:45 2013
New Revision: 246258
URL: http://svnweb.freebsd.org/changeset/base/246258

Log:
  ext2fs:	general cleanup.
  
  - Remove unused extern declarations in fs.h
  - Correct comments in ext2_dir.h
  - Several panic() messages showed wrong function names.
  - Remove commented out stray line in ext2_alloc.c.
  - Remove the unused macro EXT2_BLOCK_SIZE_BITS() and the then
    write-only member e2fs_blocksize_bits from struct m_ext2fs.
  - Remove the unused macro EXT2_FIRST_INO() and the then write-only
    member e2fs_first_inode from struct m_ext2fs.
  - Remove EXT2_DESC_PER_BLOCK() and the member e2fs_descpb from
    struct m_ext2fs.
  - Remove the unused members e2fs_bmask, e2fs_dbpg and
    e2fs_mount_opt from struct m_ext2fs
  - Correct harmless off-by-one error for fspath in ext2_vfsops.c.
  - Remove the unused and broken macros EXT2_ADDR_PER_BLOCK_BITS()
    and EXT2_DESC_PER_BLOCK_BITS().
  - Remove the !_KERNEL versions of the EXT2_* macros.
  
  Submitted by:	Christoph Mallon
  MFC after:	2 weeks

Modified:
  head/sys/fs/ext2fs/ext2_alloc.c
  head/sys/fs/ext2fs/ext2_dir.h
  head/sys/fs/ext2fs/ext2_inode.c
  head/sys/fs/ext2fs/ext2_lookup.c
  head/sys/fs/ext2fs/ext2_vfsops.c
  head/sys/fs/ext2fs/ext2fs.h
  head/sys/fs/ext2fs/fs.h

Modified: head/sys/fs/ext2fs/ext2_alloc.c
==============================================================================
--- head/sys/fs/ext2fs/ext2_alloc.c	Sat Feb  2 21:57:06 2013	(r246257)
+++ head/sys/fs/ext2fs/ext2_alloc.c	Sat Feb  2 22:23:45 2013	(r246258)
@@ -242,7 +242,7 @@ ext2_reallocblks(ap)
 	} else {
 #ifdef DIAGNOSTIC
 		if (start_ap[start_lvl-1].in_lbn == idp->in_lbn)
-			panic("ext2_reallocblk: start == end");
+			panic("ext2_reallocblks: start == end");
 #endif
 		ssize = len - (idp->in_off + 1);
 		if (bread(vp, idp->in_lbn, (int)fs->e2fs_bsize, NOCRED, &ebp))
@@ -1004,7 +1004,7 @@ ext2_blkfree(ip, bno, size)
         if (isclr(bbp, bno)) {
                 printf("block = %lld, fs = %s\n",
                      (long long)bno, fs->e2fs_fsmnt);
-                panic("blkfree: freeing free block");
+                panic("ext2_blkfree: freeing free block");
         }
         clrbit(bbp, bno);
 	EXT2_LOCK(ump);
@@ -1032,7 +1032,6 @@ ext2_vfree(pvp, ino, mode)
 	struct ext2mount *ump;
 	int error, cg;
 	char * ibp;
-/*	mode_t save_i_mode; */
 
 	pip = VTOI(pvp);
 	fs = pip->i_e2fs;
@@ -1055,7 +1054,7 @@ ext2_vfree(pvp, ino, mode)
 		printf("ino = %llu, fs = %s\n",
 			 (unsigned long long)ino, fs->e2fs_fsmnt);
 		if (fs->e2fs_ronly == 0)
-			panic("ifree: freeing free inode");
+			panic("ext2_vfree: freeing free inode");
 	}
 	clrbit(ibp, ino);
 	EXT2_LOCK(ump);
@@ -1100,7 +1099,7 @@ ext2_mapsearch(struct m_ext2fs *fs, char
 		if (loc == NULL) {
 			printf("start = %d, len = %d, fs = %s\n",
 				start, len, fs->e2fs_fsmnt);
-			panic("ext2fs_alloccg: map corrupted");
+			panic("ext2_mapsearch: map corrupted");
 			/* NOTREACHED */
 		}
 	}

Modified: head/sys/fs/ext2fs/ext2_dir.h
==============================================================================
--- head/sys/fs/ext2fs/ext2_dir.h	Sat Feb  2 21:57:06 2013	(r246257)
+++ head/sys/fs/ext2fs/ext2_dir.h	Sat Feb  2 22:23:45 2013	(r246258)
@@ -37,7 +37,7 @@
 struct	ext2fs_direct {
 	uint32_t e2d_ino;		/* inode number of entry */
 	uint16_t e2d_reclen;		/* length of this record */
-	uint16_t e2d_namlen;		/* length of string in d_name */
+	uint16_t e2d_namlen;		/* length of string in e2d_name */
 	char e2d_name[EXT2FS_MAXNAMLEN];/* name with length<=EXT2FS_MAXNAMLEN */
 };
 /*
@@ -49,7 +49,7 @@ struct	ext2fs_direct {
 struct	ext2fs_direct_2 {
 	uint32_t e2d_ino;		/* inode number of entry */
 	uint16_t e2d_reclen;		/* length of this record */
-	uint8_t e2d_namlen;		/* length of string in d_name */
+	uint8_t e2d_namlen;		/* length of string in e2d_name */
 	uint8_t e2d_type;		/* file type */
 	char e2d_name[EXT2FS_MAXNAMLEN];/* name with length<=EXT2FS_MAXNAMLEN */
 };

Modified: head/sys/fs/ext2fs/ext2_inode.c
==============================================================================
--- head/sys/fs/ext2fs/ext2_inode.c	Sat Feb  2 21:57:06 2013	(r246257)
+++ head/sys/fs/ext2fs/ext2_inode.c	Sat Feb  2 22:23:45 2013	(r246258)
@@ -311,7 +311,7 @@ ext2_truncate(vp, length, flags, cred, t
 		oip->i_size = length;
 		newspace = blksize(fs, oip, lastblock);
 		if (newspace == 0)
-			panic("itrunc: newspace");
+			panic("ext2_truncate: newspace");
 		if (oldspace - newspace > 0) {
 			/*
 			 * Block number of space to be free'd is

Modified: head/sys/fs/ext2fs/ext2_lookup.c
==============================================================================
--- head/sys/fs/ext2fs/ext2_lookup.c	Sat Feb  2 21:57:06 2013	(r246257)
+++ head/sys/fs/ext2fs/ext2_lookup.c	Sat Feb  2 22:23:45 2013	(r246258)
@@ -812,7 +812,7 @@ ext2_direnter(ip, dvp, cnp)
 
 #ifdef DIAGNOSTIC
 	if ((cnp->cn_flags & SAVENAME) == 0)
-		panic("direnter: missing name");
+		panic("ext2_direnter: missing name");
 #endif
 	dp = VTOI(dvp);
 	newdir.e2d_ino = ip->i_number;

Modified: head/sys/fs/ext2fs/ext2_vfsops.c
==============================================================================
--- head/sys/fs/ext2fs/ext2_vfsops.c	Sat Feb  2 21:57:06 2013	(r246257)
+++ head/sys/fs/ext2fs/ext2_vfsops.c	Sat Feb  2 22:23:45 2013	(r246258)
@@ -127,7 +127,7 @@ ext2_mount(struct mount *mp)
 
 	vfs_getopt(opts, "fspath", (void **)&path, NULL);
 	/* Double-check the length of path.. */
-	if (strlen(path) >= MAXMNTLEN - 1)
+	if (strlen(path) >= MAXMNTLEN)
 		return (ENAMETOOLONG);
 
 	fspec = NULL;
@@ -318,12 +318,12 @@ compute_sb_data(struct vnode *devvp, str
 	int i;
 	int logic_sb_block = 1;	/* XXX for now */
 	struct buf *bp;
+	uint32_t e2fs_descpb;
 
 	fs->e2fs_bsize = EXT2_MIN_BLOCK_SIZE << es->e2fs_log_bsize;
 	fs->e2fs_bshift = EXT2_MIN_BLOCK_LOG_SIZE + es->e2fs_log_bsize;
 	fs->e2fs_fsbtodb = es->e2fs_log_bsize + 1;
 	fs->e2fs_qbmask = fs->e2fs_bsize - 1;
-	fs->e2fs_blocksize_bits = es->e2fs_log_bsize + 10;
 	fs->e2fs_fsize = EXT2_MIN_FRAG_SIZE << es->e2fs_log_fsize;
 	if (fs->e2fs_fsize)
 		fs->e2fs_fpb = fs->e2fs_bsize / fs->e2fs_fsize;
@@ -331,10 +331,8 @@ compute_sb_data(struct vnode *devvp, str
 	fs->e2fs_fpg = es->e2fs_fpg;
 	fs->e2fs_ipg = es->e2fs_ipg;
 	if (es->e2fs_rev == E2FS_REV0) {
-		fs->e2fs_first_inode = EXT2_FIRSTINO;
 		fs->e2fs_isize = E2FS_REV0_INODE_SIZE ;
 	} else {
-		fs->e2fs_first_inode = es->e2fs_first_ino;
 		fs->e2fs_isize = es->e2fs_inode_size;
 
 		/*
@@ -357,12 +355,11 @@ compute_sb_data(struct vnode *devvp, str
 
 	fs->e2fs_ipb = fs->e2fs_bsize / EXT2_INODE_SIZE(fs);
 	fs->e2fs_itpg = fs->e2fs_ipg /fs->e2fs_ipb;
-	fs->e2fs_descpb = fs->e2fs_bsize / sizeof(struct ext2_gd);
 	/* s_resuid / s_resgid ? */
 	fs->e2fs_gcount = (es->e2fs_bcount - es->e2fs_first_dblock +
 	    EXT2_BLOCKS_PER_GROUP(fs) - 1) / EXT2_BLOCKS_PER_GROUP(fs);
-	db_count = (fs->e2fs_gcount + EXT2_DESC_PER_BLOCK(fs) - 1) /
-	    EXT2_DESC_PER_BLOCK(fs);
+	e2fs_descpb = fs->e2fs_bsize / sizeof(struct ext2_gd);
+	db_count = (fs->e2fs_gcount + e2fs_descpb - 1) / e2fs_descpb;
 	fs->e2fs_gdbcount = db_count;
 	fs->e2fs_gd = malloc(db_count * fs->e2fs_bsize,
 	    M_EXT2MNT, M_WAITOK);
@@ -766,7 +763,7 @@ ext2_statfs(struct mount *mp, struct sta
 	ump = VFSTOEXT2(mp);
 	fs = ump->um_e2fs;
 	if (fs->e2fs->e2fs_magic != E2FS_MAGIC)
-		panic("ext2fs_statfs");
+		panic("ext2_statfs");
 
 	/*
 	 * Compute the overhead (FS structures)

Modified: head/sys/fs/ext2fs/ext2fs.h
==============================================================================
--- head/sys/fs/ext2fs/ext2fs.h	Sat Feb  2 21:57:06 2013	(r246257)
+++ head/sys/fs/ext2fs/ext2fs.h	Sat Feb  2 22:23:45 2013	(r246258)
@@ -153,7 +153,6 @@ struct m_ext2fs {
 	char     e2fs_fmod;       /* super block modified flag */
 	uint32_t e2fs_bsize;      /* Block size */
 	uint32_t e2fs_bshift;     /* calc of logical block no */
-	int32_t  e2fs_bmask;      /* calc of block offset */
 	int32_t  e2fs_bpg;	  /* Number of blocks per group */
 	int64_t  e2fs_qbmask;     /* = s_blocksize -1 */
 	uint32_t e2fs_fsbtodb;    /* Shift to get disk block */
@@ -163,14 +162,9 @@ struct m_ext2fs {
 	uint32_t e2fs_fsize;      /* Size of fragments per block */
 	uint32_t e2fs_fpb;	  /* Number of fragments per block */
 	uint32_t e2fs_fpg;	  /* Number of fragments per group */
-	uint32_t e2fs_dbpg;       /* Number of descriptor blocks per group */
-	uint32_t e2fs_descpb;     /* Number of group descriptors per block */
 	uint32_t e2fs_gdbcount;   /* Number of group descriptors */
 	uint32_t e2fs_gcount;     /* Number of groups */
-	uint32_t e2fs_first_inode;/* First inode on fs */
 	int32_t  e2fs_isize;      /* Size of inode */
-	uint32_t e2fs_mount_opt;
-	uint32_t e2fs_blocksize_bits;
 	uint32_t e2fs_total_dir;  /* Total number of directories */
 	uint8_t	*e2fs_contigdirs; /* (u) # of contig. allocated dirs */
 	char     e2fs_wasvalid;   /* valid at mount time */
@@ -313,27 +307,9 @@ struct csum {
 #define EXT2_MIN_BLOCK_SIZE		1024
 #define	EXT2_MAX_BLOCK_SIZE		4096
 #define EXT2_MIN_BLOCK_LOG_SIZE		  10
-#if defined(_KERNEL)
-# define EXT2_BLOCK_SIZE(s)		((s)->e2fs_bsize)
-#else
-# define EXT2_BLOCK_SIZE(s)		(EXT2_MIN_BLOCK_SIZE << (s)->e2fs_log_bsize)
-#endif
+#define EXT2_BLOCK_SIZE(s)		((s)->e2fs_bsize)
 #define	EXT2_ADDR_PER_BLOCK(s)		(EXT2_BLOCK_SIZE(s) / sizeof(uint32_t))
-#if defined(_KERNEL)
-# define EXT2_BLOCK_SIZE_BITS(s)	((s)->e2fs_blocksize_bits)
-#else
-# define EXT2_BLOCK_SIZE_BITS(s)	((s)->e2fs_log_bsize + 10)
-#endif
-#if defined(_KERNEL)
-#define	EXT2_ADDR_PER_BLOCK_BITS(s)	(EXT2_SB(s)->s_addr_per_block_bits)
 #define EXT2_INODE_SIZE(s)		(EXT2_SB(s)->e2fs_isize)
-#define EXT2_FIRST_INO(s)		(EXT2_SB(s)->e2fs_first_inode)
-#else
-#define EXT2_INODE_SIZE(s)	(((s)->s_rev_level == E2FS_REV0) ? \
-				 E2FS_REV0 : (s)->s_inode_size)
-#define EXT2_FIRST_INO(s)	(((s)->s_rev_level == E2FS_REV0) ? \
-				 E2FS_REV0 : (s)->e2fs_first_ino)
-#endif
 
 /*
  * Macro-instructions used to manage fragments
@@ -341,25 +317,12 @@ struct csum {
 #define EXT2_MIN_FRAG_SIZE		1024
 #define	EXT2_MAX_FRAG_SIZE		4096
 #define EXT2_MIN_FRAG_LOG_SIZE		  10
-#if defined(_KERNEL)
-# define EXT2_FRAG_SIZE(s)		(EXT2_SB(s)->e2fs_fsize)
-# define EXT2_FRAGS_PER_BLOCK(s)	(EXT2_SB(s)->e2fs_fpb)
-#else
-# define EXT2_FRAG_SIZE(s)		(EXT2_MIN_FRAG_SIZE << (s)->e2fs_log_fsize)
-# define EXT2_FRAGS_PER_BLOCK(s)	(EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s))
-#endif
+#define EXT2_FRAG_SIZE(s)		(EXT2_SB(s)->e2fs_fsize)
+#define EXT2_FRAGS_PER_BLOCK(s)		(EXT2_SB(s)->e2fs_fpb)
 
 /*
  * Macro-instructions used to manage group descriptors
  */
-#if defined(_KERNEL)
-# define EXT2_BLOCKS_PER_GROUP(s)	(EXT2_SB(s)->e2fs_bpg)
-# define EXT2_DESC_PER_BLOCK(s)		(EXT2_SB(s)->e2fs_descpb)
-# define EXT2_DESC_PER_BLOCK_BITS(s)	(EXT2_SB(s)->s_desc_per_block_bits)
-#else
-# define EXT2_BLOCKS_PER_GROUP(s)	((s)->e2fs_bpg)
-# define EXT2_DESC_PER_BLOCK(s)		(EXT2_BLOCK_SIZE(s) / sizeof(struct ext2_gd))
-
-#endif
+#define EXT2_BLOCKS_PER_GROUP(s)	(EXT2_SB(s)->e2fs_bpg)
 
 #endif	/* !_FS_EXT2FS_EXT2FS_H_ */

Modified: head/sys/fs/ext2fs/fs.h
==============================================================================
--- head/sys/fs/ext2fs/fs.h	Sat Feb  2 21:57:06 2013	(r246257)
+++ head/sys/fs/ext2fs/fs.h	Sat Feb  2 22:23:45 2013	(r246258)
@@ -149,7 +149,4 @@
  */
 #define	NINDIR(fs)	(EXT2_ADDR_PER_BLOCK(fs))
 
-extern int inside[], around[];
-extern u_char *fragtbl[];
-
 #endif /* !_FS_EXT2FS_FS_H_ */


More information about the svn-src-head mailing list