PERFORCE change 183858 for review

Zheng Liu lz at FreeBSD.org
Thu Sep 16 13:25:49 UTC 2010


http://p4web.freebsd.org/@@183858?ac=10

Change 183858 by lz at gnehzuil-freebsd on 2010/09/16 13:25:00

	       Make ext4fs can be compiled.

Affected files ...

.. //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_alloc.c#2 edit
.. //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_balloc.c#2 edit
.. //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_bmap.c#2 edit
.. //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_dinode.h#2 edit
.. //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_dir.h#2 edit
.. //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_extents.c#2 edit
.. //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_extents.h#2 edit
.. //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_extern.h#2 edit
.. //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_htree.c#2 edit
.. //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_htree.h#2 edit
.. //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_inode.c#2 edit
.. //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_inode_cnv.c#2 edit
.. //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_lookup.c#2 edit
.. //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_mount.h#2 edit
.. //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_readwrite.c#2 edit
.. //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_rsv_win.h#2 edit
.. //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_subr.c#2 edit
.. //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_vfsops.c#2 edit
.. //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_vnops.c#2 edit
.. //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4fs.h#2 edit
.. //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/fs.h#2 edit
.. //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/inode.h#2 edit

Differences ...

==== //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_alloc.c#2 (text+ko) ====

@@ -33,7 +33,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)ffs_alloc.c	8.8 (Berkeley) 2/21/94
- * $FreeBSD: src/sys/fs/ext2fs/ext2_alloc.c,v 1.1 2010/01/14 14:30:54 lulf Exp $
+ * $FreeBSD: src/sys/fs/ext4fs/ext4_alloc.c,v 1.1 2010/09/16 20:35:00 lz Exp $
  */
 
 #include <sys/param.h>
@@ -45,12 +45,12 @@
 #include <sys/syslog.h>
 #include <sys/buf.h>
 
-#include <fs/ext2fs/inode.h>
-#include <fs/ext2fs/ext2_mount.h>
-#include <fs/ext2fs/ext2fs.h>
-#include <fs/ext2fs/fs.h>
-#include <fs/ext2fs/ext2_extern.h>
-#include <fs/ext2fs/ext2_rsv_win.h>
+#include <fs/ext4fs/inode.h>
+#include <fs/ext4fs/ext4_mount.h>
+#include <fs/ext4fs/ext4fs.h>
+#include <fs/ext4fs/fs.h>
+#include <fs/ext4fs/ext4_extern.h>
+#include <fs/ext4fs/ext4_rsv_win.h>
 
 /* Just for clear */
 #define phy_blk(cg, fs) (((cg) * (fs->e2fs->e2fs_fpg)) + fs->e2fs->e2fs_first_dblock)

==== //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_balloc.c#2 (text+ko) ====

@@ -33,7 +33,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)ffs_balloc.c	8.4 (Berkeley) 9/23/93
- * $FreeBSD: src/sys/fs/ext2fs/ext2_balloc.c,v 1.1 2010/01/14 14:30:54 lulf Exp $
+ * $FreeBSD: src/sys/fs/ext4fs/ext4_balloc.c,v 1.1 2010/09/16 20:35:00 lz Exp $
  */
 
 #include <sys/param.h>
@@ -44,12 +44,12 @@
 #include <sys/ucred.h>
 #include <sys/vnode.h>
 
-#include <fs/ext2fs/inode.h>
-#include <fs/ext2fs/ext2fs.h>
-#include <fs/ext2fs/fs.h>
-#include <fs/ext2fs/ext2_extern.h>
-#include <fs/ext2fs/ext2_mount.h>
-#include <fs/ext2fs/ext2_rsv_win.h>
+#include <fs/ext4fs/inode.h>
+#include <fs/ext4fs/ext4fs.h>
+#include <fs/ext4fs/fs.h>
+#include <fs/ext4fs/ext4_extern.h>
+#include <fs/ext4fs/ext4_mount.h>
+#include <fs/ext4fs/ext4_rsv_win.h>
 /*
  * Balloc defines the structure of file system storage
  * by allocating the physical blocks on a device given

==== //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_bmap.c#2 (text+ko) ====

@@ -32,7 +32,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)ufs_bmap.c	8.7 (Berkeley) 3/21/95
- * $FreeBSD: src/sys/fs/ext2fs/ext2_bmap.c,v 1.1 2010/01/14 14:30:54 lulf Exp $
+ * $FreeBSD: src/sys/fs/ext4fs/ext4_bmap.c,v 1.1 2010/09/16 20:36:00 lz Exp $
  */
 
 #include <sys/param.h>
@@ -45,12 +45,12 @@
 #include <sys/resourcevar.h>
 #include <sys/stat.h>
 
-#include <fs/ext2fs/inode.h>
-#include <fs/ext2fs/fs.h>
-#include <fs/ext2fs/ext2fs.h>
-#include <fs/ext2fs/ext2_mount.h>
-#include <fs/ext2fs/ext2_extern.h>
-#include <fs/ext2fs/ext2_dinode.h>
+#include <fs/ext4fs/inode.h>
+#include <fs/ext4fs/fs.h>
+#include <fs/ext4fs/ext4fs.h>
+#include <fs/ext4fs/ext4_mount.h>
+#include <fs/ext4fs/ext4_extern.h>
+#include <fs/ext4fs/ext4_dinode.h>
 
 static int ext4_bmapext(struct vnode *, int32_t, int64_t *, int *, int *);
 

==== //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_dinode.h#2 (text+ko) ====

@@ -23,11 +23,11 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/fs/ext2fs/ext2_dinode.h,v 1.1 2010/01/14 14:30:54 lulf Exp $
+ * $FreeBSD: src/sys/fs/ext4fs/ext4_dinode.h,v 1.1 2010/09/16 20:34:00 lz Exp $
  */
 
-#ifndef _FS_EXT2FS_EXT2_DINODE_H_
-#define _FS_EXT2FS_EXT2_DINODE_H_
+#ifndef _FS_EXT4FS_EXT4_DINODE_H_
+#define _FS_EXT4FS_EXT4_DINODE_H_
 
 /*
  * Inode flags
@@ -121,5 +121,4 @@
         u_int32_t e2di_version_hi;
 };
 
-#endif /* _FS_EXT2FS_EXT2_DINODE_H_ */
-
+#endif /* _FS_EXT4FS_EXT4_DINODE_H_ */

==== //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_dir.h#2 (text+ko) ====

@@ -23,11 +23,11 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/fs/ext2fs/ext2_dir.h,v 1.1 2010/01/14 14:30:54 lulf Exp $
+ * $FreeBSD: src/sys/fs/ext4fs/ext4_dir.h,v 1.1 2010/09/16 20:37:00 lz Exp $
  */
 
-#ifndef _FS_EXT2FS_EXT2_DIR_H_
-#define _FS_EXT2FS_EXT2_DIR_H_
+#ifndef _FS_EXT4FS_EXT4_DIR_H_
+#define _FS_EXT4FS_EXT4_DIR_H_
 
 /*
  * Structure of a directory entry
@@ -77,5 +77,4 @@
 #define EXT2_DIR_ROUND 			(EXT2_DIR_PAD - 1)
 #define EXT2_DIR_REC_LEN(name_len)	(((name_len) + 8 + EXT2_DIR_ROUND) & \
 					 ~EXT2_DIR_ROUND)
-#endif /* !_FS_EXT2FS_EXT2_DIR_H_ */
-
+#endif /* !_FS_EXT4FS_EXT4_DIR_H_ */

==== //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_extents.c#2 (text+ko) ====

@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/fs/ext2fs/ext2_extents.c,v 0.1 2010/07/02 17:22:00 lz Exp $
+ * $FreeBSD: src/sys/fs/ext4fs/ext4_extents.c,v 0.1 2010/09/16 20:37:00 lz Exp $
  */
 
 #include <sys/param.h>
@@ -36,12 +36,12 @@
 #include <sys/buf.h>
 #include <sys/conf.h>
 
-#include <fs/ext2fs/ext2_mount.h>
-#include <fs/ext2fs/fs.h>
-#include <fs/ext2fs/inode.h>
-#include <fs/ext2fs/ext2fs.h>
-#include <fs/ext2fs/ext2_extents.h>
-#include <fs/ext2fs/ext2_extern.h>
+#include <fs/ext4fs/ext4_mount.h>
+#include <fs/ext4fs/fs.h>
+#include <fs/ext4fs/inode.h>
+#include <fs/ext4fs/ext4fs.h>
+#include <fs/ext4fs/ext4_extents.h>
+#include <fs/ext4fs/ext4_extern.h>
 
 static void ext4_ext_binsearch_index(struct inode *, struct ext4_extent_path *, daddr_t);
 static void ext4_ext_binsearch(struct inode *, struct ext4_extent_path *, daddr_t);

==== //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_extents.h#2 (text+ko) ====

@@ -23,10 +23,10 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/fs/ext2fs/ext2_extents.h,v 0.1 2010/06/22 18:01:51 lz Exp $
+ * $FreeBSD: src/sys/fs/ext4fs/ext4_extents.h,v 0.1 2010/09/16 20:38:51 lz Exp $
  */
-#ifndef _FS_EXT2FS_EXT2_EXTENTS_H_
-#define _FS_EXT2FS_EXT2_EXTENTS_H_
+#ifndef _FS_EXT4FS_EXT4_EXTENTS_H_
+#define _FS_EXT4FS_EXT4_EXTENTS_H_
 
 #include <sys/types.h>
 
@@ -100,4 +100,4 @@
 struct  ext4_extent_path *ext4_ext_find_extent(struct m_ext2fs *fs, struct inode *,
                                                daddr_t, struct ext4_extent_path *);
 
-#endif /* !_FS_EXT2FS_EXT2_EXTENTS_H_ */
+#endif /* !_FS_EXT4FS_EXT4_EXTENTS_H_ */

==== //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_extern.h#2 (text+ko) ====

@@ -33,11 +33,11 @@
  * SUCH DAMAGE.
  *
  *	@(#)ffs_extern.h	8.3 (Berkeley) 4/16/94
- * $FreeBSD: src/sys/fs/ext2fs/ext2_extern.h,v 1.1 2010/01/14 14:30:54 lulf Exp $
+ * $FreeBSD: src/sys/fs/ext4fs/ext4_extern.h,v 1.1 2010/09/16 20:38:54 lz Exp $
  */
 
-#ifndef _FS_EXT2FS_EXT2_EXTERN_H_
-#define	_FS_EXT2FS_EXT2_EXTERN_H_
+#ifndef _FS_EXT4FS_EXT4_EXTERN_H_
+#define	_FS_EXT4FS_EXT4_EXTERN_H_
 
 struct ext2fs_dinode;
 struct indir;
@@ -90,4 +90,4 @@
 extern struct vop_vector ext2_vnodeops;
 extern struct vop_vector ext2_fifoops;
 
-#endif /* !_FS_EXT2FS_EXT2_EXTERN_H_ */
+#endif /* !_FS_EXT4FS_EXT4_EXTERN_H_ */

==== //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_htree.c#2 (text+ko) ====

@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/fs/ext2fs/ext2_htree.c,v 0.1 2010/08/01 15:02:00 lz Exp $
+ * $FreeBSD: src/sys/fs/ext4fs/ext4_htree.c,v 0.1 2010/09/16 20:39:00 lz Exp $
  */
 
 #include <sys/param.h>
@@ -34,14 +34,14 @@
 #include <sys/buf.h>
 #include <sys/hash.h>
 
-#include <fs/ext2fs/inode.h>
-#include <fs/ext2fs/ext2_mount.h>
-#include <fs/ext2fs/ext2fs.h>
-#include <fs/ext2fs/fs.h>
-#include <fs/ext2fs/ext2_extern.h>
-#include <fs/ext2fs/ext2_dinode.h>
-#include <fs/ext2fs/ext2_dir.h>
-#include <fs/ext2fs/ext2_htree.h>
+#include <fs/ext4fs/inode.h>
+#include <fs/ext4fs/ext4_mount.h>
+#include <fs/ext4fs/ext4fs.h>
+#include <fs/ext4fs/fs.h>
+#include <fs/ext4fs/ext4_extern.h>
+#include <fs/ext4fs/ext4_dinode.h>
+#include <fs/ext4fs/ext4_dir.h>
+#include <fs/ext4fs/ext4_htree.h>
 
 static int ext4_get_limit(struct dirindex_entry *);
 static int ext4_root_limit(struct inode *, int);

==== //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_htree.h#2 (text+ko) ====

@@ -23,10 +23,10 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/fs/ext2fs/ext2_htree.h,v 0.1 2010/08/01 14:45:00 lz Exp $
+ * $FreeBSD: src/sys/fs/ext4fs/ext4_htree.h,v 0.1 2010/09/16 20:40:00 lz Exp $
  */
-#ifndef _FS_EXT2FS_EXT2_HTREE_H_
-#define _FS_EXT2FS_EXT2_HTREE_H_
+#ifndef _FS_EXT4FS_EXT4_HTREE_H_
+#define _FS_EXT4FS_EXT4_HTREE_H_
 
 #define DIRINDEX_HASH_LEGACY            0
 #define DIRINDEX_HASH_HALF_MD4          1
@@ -99,4 +99,4 @@
 int ext4_dirindex_lookup(struct vnode *, char *, int,
                          doff_t *, struct buf **, doff_t *prevoffp);
 
-#endif /* !_FS_EXT2FS_EXT2_HTREE_H_ */
+#endif /* !_FS_EXT4FS_EXT4_HTREE_H_ */

==== //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_inode.c#2 (text+ko) ====

@@ -33,7 +33,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)ffs_inode.c	8.5 (Berkeley) 12/30/93
- * $FreeBSD: src/sys/fs/ext2fs/ext2_inode.c,v 1.1 2010/01/14 14:30:54 lulf Exp $
+ * $FreeBSD: src/sys/fs/ext4fs/ext4_inode.c,v 1.1 2010/09/16 20:40:54 lz Exp $
  */
 
 #include <sys/param.h>
@@ -47,11 +47,12 @@
 #include <vm/vm.h>
 #include <vm/vm_extern.h>
 
-#include <fs/ext2fs/inode.h>
-#include <fs/ext2fs/ext2_mount.h>
-#include <fs/ext2fs/ext2fs.h>
-#include <fs/ext2fs/fs.h>
-#include <fs/ext2fs/ext2_extern.h>
+#include <fs/ext4fs/inode.h>
+#include <fs/ext4fs/ext4_mount.h>
+#include <fs/ext4fs/ext4fs.h>
+#include <fs/ext4fs/fs.h>
+#include <fs/ext4fs/ext4_extern.h>
+#include <fs/ext4fs/ext4_rsv_win.h>
 
 static int ext2_indirtrunc(struct inode *, int32_t, int32_t, int32_t, int,
 	    long *);
@@ -154,6 +155,10 @@
 	fs = oip->i_e2fs;
 	osize = oip->i_size;
 
+        EXT2_RSV_LOCK(oip);
+	ext2_discard_rsv(oip);
+        EXT2_RSV_UNLOCK(oip);
+
 	/*
 	 * Lengthen the size of the file. We must ensure that the
 	 * last byte of the file is allocated. Since the smallest
@@ -485,6 +490,10 @@
 	if (prtactive && vrefcnt(vp) != 0)
 		vprint("ext2_inactive: pushing active", vp);
 
+        EXT2_RSV_LOCK(ip);
+        ext2_discard_rsv(ip);
+        EXT2_RSV_UNLOCK(ip);
+
 	/*
 	 * Ignore inodes related to stale file handles.
 	 */
@@ -533,6 +542,14 @@
 	}
 	vfs_hash_remove(vp);
 
+        EXT2_RSV_LOCK(ip);
+        if (ip->i_rsv != NULL) {
+                free(ip->i_rsv, M_EXT2NODE);
+                ip->i_rsv = NULL;
+        }
+        EXT2_RSV_UNLOCK(ip);
+        mtx_destroy(&ip->i_rsv_lock);
+
         mtx_destroy(&ip->i_ext_lock);
 
 	free(vp->v_data, M_EXT2NODE);

==== //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_inode_cnv.c#2 (text+ko) ====

@@ -19,7 +19,7 @@
  * improvements that they make and grant CSL redistribution rights.
  *
  *      Utah $Hdr$
- * $FreeBSD: src/sys/fs/ext2fs/ext2_inode_cnv.c,v 1.1 2010/01/14 14:30:54 lulf Exp $
+ * $FreeBSD: src/sys/fs/ext4fs/ext4_inode_cnv.c,v 1.1 2010/09/16 20:41:00 lz Exp $
  */
 
 /*
@@ -31,11 +31,11 @@
 #include <sys/stat.h>
 #include <sys/vnode.h>
 
-#include <fs/ext2fs/inode.h>
-#include <fs/ext2fs/ext2fs.h>
-#include <fs/ext2fs/ext2_extern.h>
-#include <fs/ext2fs/ext2_dinode.h>
-#include <fs/ext2fs/ext2_extents.h>
+#include <fs/ext4fs/inode.h>
+#include <fs/ext4fs/ext4fs.h>
+#include <fs/ext4fs/ext4_extern.h>
+#include <fs/ext4fs/ext4_dinode.h>
+#include <fs/ext4fs/ext4_extents.h>
 
 void
 ext2_print_inode( in )

==== //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_lookup.c#2 (text+ko) ====

@@ -38,7 +38,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)ufs_lookup.c	8.6 (Berkeley) 4/1/94
- * $FreeBSD: src/sys/fs/ext2fs/ext2_lookup.c,v 1.1 2010/01/14 14:30:54 lulf Exp $
+ * $FreeBSD: src/sys/fs/ext4fs/ext4_lookup.c,v 1.1 2010/09/16 20:42:54 lz Exp $
  */
 
 #include <sys/param.h>
@@ -55,11 +55,12 @@
 
 #include <ufs/ufs/dir.h>
 
-#include <fs/ext2fs/inode.h>
-#include <fs/ext2fs/ext2_mount.h>
-#include <fs/ext2fs/ext2_extern.h>
-#include <fs/ext2fs/ext2fs.h>
-#include <fs/ext2fs/ext2_dir.h>
+#include <fs/ext4fs/inode.h>
+#include <fs/ext4fs/ext4_mount.h>
+#include <fs/ext4fs/ext4_extern.h>
+#include <fs/ext4fs/ext4fs.h>
+#include <fs/ext4fs/ext4_dir.h>
+#include <fs/ext4fs/ext4_htree.h>
 
 #ifdef DIAGNOSTIC
 static int dirchk = 1;
@@ -348,6 +349,25 @@
 			cnp->cn_namelen + 3) &~ 3; */
 	}
 
+	bmask = VFSTOEXT2(vdp->v_mount)->um_mountp->mnt_stat.f_iosize - 1;
+
+        /* Usr hash directory index to search a large direcotries. */
+        numdirpasses = 2;
+        prevoff = 0;
+        if (ext4_is_dirindex(dp)) {
+                switch (ext4_dirindex_lookup(vdp, cnp->cn_nameptr,
+                    cnp->cn_namelen, &i_offset, &bp, NULL)) {
+                case 0:
+                        ep = (struct ext2fs_direct_2 *)((char *)bp->b_data +
+                            (i_offset & bmask));
+                        entryoffsetinblock = i_offset;
+                        goto dirindex_found;
+                case ENOENT:
+                default:
+                        break;
+                }
+        }
+
 	/*
 	 * If there is cached information on a previous search of
 	 * this directory, pick up where we last left off.
@@ -359,7 +379,6 @@
 	 * profiling time and hence has been removed in the interest
 	 * of simplicity.
 	 */
-	bmask = VFSTOEXT2(vdp->v_mount)->um_mountp->mnt_stat.f_iosize - 1;
 	if (nameiop != LOOKUP || i_diroff == 0 ||
 	    i_diroff > dp->i_size) {
 		entryoffsetinblock = 0;
@@ -462,6 +481,7 @@
 				 * reclen in ndp->ni_ufs area, and release
 				 * directory buffer.
 				 */
+dirindex_found:
 				ino = ep->e2d_ino;
 				goto found;
 			}

==== //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_mount.h#2 (text+ko) ====

@@ -27,11 +27,11 @@
  * SUCH DAMAGE.
  *
  *	@(#)ufsmount.h	8.6 (Berkeley) 3/30/95
- * $FreeBSD: src/sys/fs/ext2fs/ext2_mount.h,v 1.1 2010/01/14 14:30:54 lulf Exp $
+ * $FreeBSD: src/sys/fs/ext4fs/ext4_mount.h,v 1.1 2010/09/16 20:42:00 lz Exp $
  */
 
-#ifndef _FS_EXT2FS_EXT2_MOUNT_H_
-#define _FS_EXT2FS_EXT2_MOUNT_H_
+#ifndef _FS_EXT4FS_EXT4_MOUNT_H_
+#define _FS_EXT4FS_EXT4_MOUNT_H_
 
 #ifdef _KERNEL
 
@@ -76,4 +76,4 @@
 #define	is_sequential(ump, a, b)	((b) == (a) + ump->um_seqinc)
 #endif /* _KERNEL */
 
-#endif
+#endif /* _FS_EXT4FS_EXT4_MOUNT_H_ */

==== //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_readwrite.c#2 (text+ko) ====

@@ -33,11 +33,11 @@
  * SUCH DAMAGE.
  *
  *	@(#)ufs_readwrite.c	8.7 (Berkeley) 1/21/94
- * $FreeBSD: src/sys/fs/ext2fs/ext2_readwrite.c,v 1.1 2010/01/14 14:30:54 lulf Exp $
+ * $FreeBSD: src/sys/fs/ext4fs/ext4_readwrite.c,v 1.1 2010/09/16 20:43:00 lz Exp $
  */
 
-#include <fs/ext2fs/ext2_dinode.h>
-#include <fs/ext2fs/ext2_extents.h>
+#include <fs/ext4fs/ext4_dinode.h>
+#include <fs/ext4fs/ext4_extents.h>
 
 /* XXX TODO: remove these obfuscations (as in ffs_vnops.c). */
 #define	BLKSIZE(a, b, c)	blksize(a, b, c)

==== //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_rsv_win.h#2 (text+ko) ====

@@ -23,10 +23,10 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/fs/ext2fs/ext2_rsv_win.h,v 0.1 2010/05/08 12:41:51 lz Exp $
+ * $FreeBSD: src/sys/fs/ext4fs/ext4_rsv_win.h,v 0.1 2010/09/16 20:43:51 lz Exp $
  */
-#ifndef _FS_EXT2FS_EXT2_RSV_WIN_H_
-#define _FS_EXT2FS_EXT2_RSV_WIN_H_
+#ifndef _FS_EXT4FS_EXT4_RSV_WIN_H_
+#define _FS_EXT4FS_EXT4_RSV_WIN_H_
 
 #include <sys/tree.h>
 
@@ -76,4 +76,4 @@
 int     ext2_alloc_rsv(struct inode *, int32_t, int32_t,
                        int, struct ucred *, int32_t *);
 
-#endif /* !_FS_EXT2FS_EXT2_RSV_WIN_H_ */
+#endif /* !_FS_EXT4FS_EXT4_RSV_WIN_H_ */

==== //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_subr.c#2 (text+ko) ====

@@ -33,7 +33,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)ffs_subr.c	8.2 (Berkeley) 9/21/93
- * $FreeBSD: src/sys/fs/ext2fs/ext2_subr.c,v 1.1 2010/01/14 14:30:54 lulf Exp $
+ * $FreeBSD: src/sys/fs/ext4fs/ext4_subr.c,v 1.1 2010/09/16 20:44:00 lz Exp $
  */
 
 #include <sys/param.h>
@@ -46,11 +46,11 @@
 #include <sys/ucred.h>
 #include <sys/vnode.h>
 
-#include <fs/ext2fs/inode.h>
-#include <fs/ext2fs/ext2_extern.h>
-#include <fs/ext2fs/ext2fs.h>
-#include <fs/ext2fs/fs.h>
-#include <fs/ext2fs/ext2_extents.h>
+#include <fs/ext4fs/inode.h>
+#include <fs/ext4fs/ext4_extern.h>
+#include <fs/ext4fs/ext4fs.h>
+#include <fs/ext4fs/fs.h>
+#include <fs/ext4fs/ext4_extents.h>
 
 #ifdef KDB
 void	ext2_checkoverlap(struct buf *, struct inode *);

==== //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_vfsops.c#2 (text+ko) ====

@@ -33,7 +33,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)ffs_vfsops.c	8.8 (Berkeley) 4/18/94
- * $FreeBSD: src/sys/fs/ext2fs/ext2_vfsops.c,v 1.1 2010/01/14 14:30:54 lulf Exp $
+ * $FreeBSD: src/sys/fs/ext4fs/ext4_vfsops.c,v 1.1 2010/09/16 20:44:00 lz Exp $
  */
 
 #include <sys/param.h>
@@ -58,13 +58,13 @@
 #include <geom/geom.h>
 #include <geom/geom_vfs.h>
 
-#include <fs/ext2fs/ext2_mount.h>
-#include <fs/ext2fs/inode.h>
+#include <fs/ext4fs/ext4_mount.h>
+#include <fs/ext4fs/inode.h>
 
-#include <fs/ext2fs/fs.h>
-#include <fs/ext2fs/ext2_extern.h>
-#include <fs/ext2fs/ext2fs.h>
-#include <fs/ext2fs/ext2_dinode.h>
+#include <fs/ext4fs/fs.h>
+#include <fs/ext4fs/ext4_extern.h>
+#include <fs/ext4fs/ext4fs.h>
+#include <fs/ext4fs/ext4_dinode.h>
 
 static int	ext2_flushfiles(struct mount *mp, int flags, struct thread *td);
 static int	ext2_mountfs(struct vnode *, struct mount *);
@@ -98,6 +98,8 @@
 		    int ronly);
 static int	compute_sb_data(struct vnode * devvp,
 		    struct ext2fs * es, struct m_ext2fs * fs);
+static int      ext4_init_fg(struct m_ext2fs *);
+static int      find_most_set_bit(int64_t n);
 
 static const char *ext2_opts[] = { "from", "export", "acls", "noexec",
     "noatime", "union", "suiddir", "multilabel", "nosymfollow",
@@ -353,6 +355,7 @@
 	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);
+        fs->e2fs_descpbbits = find_most_set_bit(fs->e2fs_descpb);
 	/* s_resuid / s_resgid ? */
 	fs->e2fs_gcount = (((int64_t)(es->e2fs_bcount_hi) << 32 | es->e2fs_bcount_lo)
             - es->e2fs_first_dblock + EXT2_BLOCKS_PER_GROUP(fs) - 1) /
@@ -389,6 +392,9 @@
 		bp = NULL;
 	}
 
+        /* initialize flex groups */
+        ext4_init_fg(fs);
+
 	fs->e2fs_total_dir = 0;
 	for (i=0; i < fs->e2fs_gcount; i++){
 		fs->e2fs_total_dir += (fs->e2fs_gd[i].ext2bgd_ndirs_lo);
@@ -414,11 +420,77 @@
         }
 
         if (E2FS_REV0_INODE_SIZE + fs->e2fs_want_extra_isize >
-            fs->e2fs_isize)
+            fs->e2fs_isize) {
                 printf("EXT2-fs: no space for extra inode.\n");
+                return (EIO);
+        }
+
+	return (0);
+}
 
+/*
+ * Initialize flex groups data structure.
+ */
+static int
+ext4_init_fg(struct m_ext2fs *fs)
+{
+        struct ext2fs *es = fs->e2fs;
+        int i, gpf = 0;
+        unsigned int fgcount, fg;
+        long nifree, nbfree, ndirs;
 
-	return (0);
+        fs->e2fs_log_gpf = es->e2fs_log_gpf;
+        gpf = 1 << fs->e2fs_log_gpf;
+
+        if (gpf < 2) {
+                fs->e2fs_log_gpf = 0;
+                return (0);
+        }
+
+        fgcount = ((fs->e2fs_gcount + gpf - 1) +
+            ((es->e2fs_reserved_ngdb + 1) << fs->e2fs_descpbbits)) / gpf;
+
+        fs->e2fs_fg = malloc(fgcount * sizeof(struct ext4_flex_groups),
+            M_EXT2MNT, M_WAITOK | M_ZERO);
+
+        for (i = 0; i < fs->e2fs_gcount; i++) {
+                nifree = 0;
+                nbfree = 0;
+                ndirs = 0;
+                fg = i >> fs->e2fs_log_gpf;
+
+                /* XXX: need to support 64 bits. */
+                nifree = fs->e2fs_gd[i].ext2bgd_nifree_lo;
+                nbfree = fs->e2fs_gd[i].ext2bgd_nbfree_lo;
+                ndirs = fs->e2fs_gd[i].ext2bgd_ndirs_lo;
+
+                atomic_add_long(&fs->e2fs_fg[fg].e2fg_nifree, nifree);
+                atomic_add_long(&fs->e2fs_fg[fg].e2fg_nbfree, nbfree);
+                atomic_add_long(&fs->e2fs_fg[fg].e2fg_ndirs, ndirs);
+        }
+
+        return (0);
+}
+
+/*
+ * Find most significant set bit.
+ *
+ * TODO: Maybe it need to rewrite by assembly language for
+ * improving the performance.
+ */
+static int
+find_most_set_bit(int64_t n)
+{
+        int64_t num, i;
+        unsigned int pos, res = 0;
+
+        for (num = 1; num <= n; num++) {
+                for (i = (num >> 1), pos = 0; i != 0; pos++)
+                        i >>= 1;
+                res = pos;
+        }
+
+        return res;
 }
 
 /*
@@ -606,6 +678,12 @@
 	if ((error = compute_sb_data(devvp, ump->um_e2fs->e2fs, ump->um_e2fs)))
 		goto out;
 
+	/* Initial reservation window index and lock */
+	bzero(&ump->um_e2fs->e2fs_rsv_lock, sizeof(struct mtx));
+	mtx_init(&ump->um_e2fs->e2fs_rsv_lock,
+            "rsv tree lock", NULL, MTX_DEF);
+	RB_INIT(&ump->um_e2fs->e2fs_rsv_tree);
+
 	brelse(bp);
 	bp = NULL;
 	fs = ump->um_e2fs;
@@ -705,6 +783,8 @@
 	g_topology_unlock();
 	PICKUP_GIANT();
 	vrele(ump->um_devvp);
+	mtx_destroy(&fs->e2fs_rsv_lock);
+        free(fs->e2fs_fg, M_EXT2MNT);
 	free(fs->e2fs_gd, M_EXT2MNT);
 	free(fs->e2fs_contigdirs, M_EXT2MNT);
 	free(fs->e2fs, M_EXT2MNT);
@@ -948,6 +1028,15 @@
 	ip->i_prealloc_count = 0;
 	ip->i_prealloc_block = 0;
 
+        /* initialize rsv lock and rsv data structure */
+	bzero(&ip->i_rsv_lock, sizeof(struct mtx));
+	mtx_init(&ip->i_rsv_lock, "inode rsv lock", NULL, MTX_DEF);
+        EXT2_RSV_LOCK(ip);
+        ip->i_rsv = NULL;
+        if (ip->i_rsv == NULL)
+                ext2_init_rsv(ip);
+        EXT2_RSV_UNLOCK(ip);
+
         /* initialize ext lock */
         bzero(&ip->i_ext_lock, sizeof(struct mtx));
         mtx_init(&ip->i_ext_lock, "inode ext lock", NULL, MTX_DEF);

==== //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4_vnops.c#2 (text+ko) ====

@@ -39,7 +39,7 @@
  *
  *	@(#)ufs_vnops.c	8.7 (Berkeley) 2/3/94
  *	@(#)ufs_vnops.c 8.27 (Berkeley) 5/27/95
- * $FreeBSD: src/sys/fs/ext2fs/ext2_vnops.c,v 1.3 2010/02/20 10:19:19 uqs Exp $
+ * $FreeBSD: src/sys/fs/ext4fs/ext4_vnops.c,v 1.3 2010/09/16 20:45:00 lz Exp $
  */
 
 #include "opt_suiddir.h"
@@ -74,12 +74,12 @@
 #include <sys/signalvar.h>
 #include <ufs/ufs/dir.h>
 
-#include <fs/ext2fs/inode.h>
-#include <fs/ext2fs/ext2_mount.h>
-#include <fs/ext2fs/fs.h>
-#include <fs/ext2fs/ext2_extern.h>
-#include <fs/ext2fs/ext2fs.h>
-#include <fs/ext2fs/ext2_dir.h>
+#include <fs/ext4fs/inode.h>
+#include <fs/ext4fs/ext4_mount.h>
+#include <fs/ext4fs/fs.h>
+#include <fs/ext4fs/ext4_extern.h>
+#include <fs/ext4fs/ext4fs.h>
+#include <fs/ext4fs/ext4_dir.h>
 
 static int ext2_makeinode(int mode, struct vnode *, struct vnode **, struct componentname *);
 static void ext2_itimes_locked(struct vnode *);

==== //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/ext4fs.h#2 (text+ko) ====

@@ -4,7 +4,7 @@
  *  Aug 1995, Godmar Back (gback at cs.utah.edu)
  *  University of Utah, Department of Computer Science
  *
- * $FreeBSD: src/sys/fs/ext2fs/ext2fs.h,v 1.1 2010/01/14 14:30:54 lulf Exp $
+ * $FreeBSD: src/sys/fs/ext4fs/ext4fs.h,v 1.1 2010/09/16 20:46:00 lz Exp $
  */
 /*-
  * Copyright (c) 2009 Aditya Sarawgi
@@ -34,12 +34,14 @@
  * 
  */
 
-#ifndef _FS_EXT2FS_EXT2_FS_H
-#define _FS_EXT2FS_EXT2_FS_H
+#ifndef _FS_EXT4FS_EXT4_FS_H
+#define _FS_EXT4FS_EXT4_FS_H
 
 #include <sys/types.h>
 #include <sys/lock.h>
 
+#include <fs/ext4fs/ext4_rsv_win.h>
+
 /*
  * Special inode numbers
  */
@@ -91,6 +93,15 @@
  */
 #define MAXMNTLEN 512
 
+/* ext4 flex block group data structure */
+struct ext4_flex_groups {
+        long e2fg_nifree;
+        long e2fg_nbfree;
+        long e2fg_ndirs;
+};
+
+#define EXT4_FLEX_ALLOC_DIR_SIZE 4
+
 /*
  * Super block for an ext2fs file system.
  */
@@ -204,6 +215,13 @@
 	off_t e2fs_maxfilesize;
 	struct ext2_gd *e2fs_gd;  /* Group Descriptors */
 
+	struct mtx e2fs_rsv_lock;                /* Protect reservation window RB tree */
+	struct ext2_rsv_win_tree e2fs_rsv_tree; /* Reservation window index */
+
+        u_int8_t e2fs_log_gpf;    /* FLEX_BG group size */
+        int      e2fs_descpbbits;
+        struct ext4_flex_groups *e2fs_fg;
+
         u_int16_t e2fs_min_extra_isize;        /* all inodes have at least some bytes */
         u_int16_t e2fs_want_extra_isize;       /* new inodes should reserve some bytes */
 };
@@ -399,4 +417,4 @@
 
 #endif
 
-#endif	/* _LINUX_EXT2_FS_H */
+#endif	/* _LINUX_EXT4_FS_H */

==== //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/fs.h#2 (text+ko) ====


==== //depot/projects/soc2010/ext4fs/src/sys/fs/ext4fs/inode.h#2 (text+ko) ====

@@ -35,15 +35,15 @@
  * $FreeBSD: src/sys/fs/ext2fs/inode.h,v 1.1 2010/01/14 14:30:54 lulf Exp $
  */
 
-#ifndef _FS_EXT2FS_INODE_H_
-#define	_FS_EXT2FS_INODE_H_
+#ifndef _FS_EXT4FS_INODE_H_
+#define	_FS_EXT4FS_INODE_H_
 
 #include <sys/param.h>
 #include <sys/lock.h>
 #include <sys/mutex.h>
 #include <sys/queue.h>
 
-#include <fs/ext2fs/ext2_extents.h>
+#include <fs/ext4fs/ext4_extents.h>
 
 #define	ROOTINO	((ino_t)2)
 
@@ -105,6 +105,10 @@
 	u_int32_t	i_uid;		/* File owner. */
 	u_int32_t	i_gid;		/* File group. */
 
+        /* Fields for reservation window */
+        struct mtx          i_rsv_lock; /* Protects i_rsv */
+	struct ext2_rsv_win *i_rsv;     /* Reservation window */
+
         /* ext4 extents support */
         struct mtx      i_ext_lock;     /* this lock only is required in read/write mode
                                            but we still use it in read-only mode. */
@@ -176,4 +180,4 @@
 };
 #endif /* _KERNEL */
 
-#endif /* !_FS_EXT2FS_INODE_H_ */
+#endif /* !_FS_EXT4FS_INODE_H_ */


More information about the p4-projects mailing list