Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 Aug 2010 10:48:49 GMT
From:      Zheng Liu <lz@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 182558 for review
Message-ID:  <201008181048.o7IAmndY065706@skunkworks.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@182558?ac=10

Change 182558 by lz@gnehzuil-freebsd on 2010/08/18 10:48:17

	       clean code to generate a patch for submitting it.

Affected files ...

.. //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2_alloc.c#26 edit
.. //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2_balloc.c#6 edit
.. //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2_rsv_win.h#12 edit
.. //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2_vfsops.c#7 edit
.. //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2fs.h#4 edit
.. //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/inode.h#5 edit

Differences ...

==== //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2_alloc.c#26 (text+ko) ====

@@ -52,7 +52,6 @@
 #include <fs/ext2fs/ext2_extern.h>
 #include <fs/ext2fs/ext2_rsv_win.h>
 
-/* Just for clear */
 #define phy_blk(cg, fs) (((cg) * (fs->e2fs->e2fs_fpg)) + fs->e2fs->e2fs_first_dblock)
 
 static daddr_t	ext2_alloccg(struct inode *, int, daddr_t, int);
@@ -122,7 +121,7 @@
         if (bpref < 0)
                 bpref = 0;
 
-        /* Check whther it use reservation window */
+        /* Check whether it use reservation window */
         if (rp != NULL) {
                 /*
                  * If window's start is not in this cylinder group,
@@ -247,7 +246,7 @@
 static void
 ext2_remove_rsv_win(struct m_ext2fs *fs, struct ext2_rsv_win *rp)
 {
-	RB_REMOVE(ext2_rsv_win_tree, &fs->e2fs_rsv_tree, rp);
+	RB_REMOVE(ext2_rsv_win_tree, fs->e2fs_rsv_tree, rp);
 	rp->rsv_start = EXT2_RSV_NOT_ALLOCATED;
 	rp->rsv_end = EXT2_RSV_NOT_ALLOCATED;
 	rp->rsv_alloc_hit = 0;
@@ -314,7 +313,7 @@
                 rp->rsv_end = start + size - 1;
                 rp->rsv_alloc_hit = 0;
 
-                RB_INSERT(ext2_rsv_win_tree, &fs->e2fs_rsv_tree, rp);
+                RB_INSERT(ext2_rsv_win_tree, fs->e2fs_rsv_tree, rp);
 
                 return (0);
         }
@@ -336,7 +335,7 @@
                         return (-1);
 
                 prev = rsv;
-                rsv = RB_NEXT(ext2_rsv_win_tree, &fs->e2fs_rsv_tree, rsv);
+                rsv = RB_NEXT(ext2_rsv_win_tree, fs->e2fs_rsv_tree, rsv);
 
                 if (rsv == NULL)
                         break;
@@ -353,7 +352,7 @@
         rp->rsv_alloc_hit = 0;
 
         if (prev != rp)
-                RB_INSERT(ext2_rsv_win_tree, &fs->e2fs_rsv_tree, rp);
+                RB_INSERT(ext2_rsv_win_tree, fs->e2fs_rsv_tree, rp);
 
         return (0);
 }
@@ -419,7 +418,7 @@
 
         EXT2_TREE_LOCK(fs);
 
-        search = ext2_search_rsv(&fs->e2fs_rsv_tree, start);
+        search = ext2_search_rsv(fs->e2fs_rsv_tree, start);
 
 repeat:
         ret = ext2_find_rsv(search, rp, fs, start, cg);

==== //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2_balloc.c#6 (text+ko) ====

@@ -79,6 +79,9 @@
 	fs = ip->i_e2fs;
 	ump = ip->i_ump;
 
+        if (ip->i_rsv == NULL)
+                ext2_init_rsv(ip);
+
 	/*
 	 * check if this is a sequential block allocation. 
 	 * If so, increment next_alloc fields to allow ext2_blkpref 
@@ -137,11 +140,6 @@
 			else
 				nsize = fs->e2fs_bsize;
 			EXT2_LOCK(ump);
-/*
-			error = ext2_alloc(ip, lbn,
-			    ext2_blkpref(ip, lbn, (int)lbn, &ip->i_db[0], 0),
-			    nsize, cred, &newb);
-*/
 			error = ext2_alloc_rsv(ip, lbn,
 				    ext2_blkpref(ip, lbn, (int)lbn, &ip->i_db[0], 0),
 				    nsize, cred, &newb);
@@ -176,11 +174,6 @@
 		EXT2_LOCK(ump);
 		pref = ext2_blkpref(ip, lbn, indirs[0].in_off + 
 					     EXT2_NDIR_BLOCKS, &ip->i_db[0], 0);
-/*
-	        if ((error = ext2_alloc(ip, lbn, pref, 
-			(int)fs->e2fs_bsize, cred, &newb)))
-			return (error);
-*/
 	        if ((error = ext2_alloc_rsv(ip, lbn, pref, 
 				(int)fs->e2fs_bsize, cred, &newb)))
 				return (error);
@@ -222,9 +215,6 @@
 		if (pref == 0)
 			pref = ext2_blkpref(ip, lbn, indirs[i].in_off, bap,
 						bp->b_lblkno);
-/*
-		error =  ext2_alloc(ip, lbn, pref, (int)fs->e2fs_bsize, cred, &newb);
-*/
 		error =  ext2_alloc_rsv(ip, lbn, pref, (int)fs->e2fs_bsize, cred, &newb);
 		if (error) {
 			brelse(bp);
@@ -264,13 +254,6 @@
 		EXT2_LOCK(ump);
 		pref = ext2_blkpref(ip, lbn, indirs[i].in_off, &bap[0], 
 				bp->b_lblkno);
-/*
-		if ((error = ext2_alloc(ip,
-		    lbn, pref, (int)fs->e2fs_bsize, cred, &newb)) != 0) {
-			brelse(bp);
-			return (error);
-		}
-*/
 		if ((error = ext2_alloc_rsv(ip, lbn, pref,
 				(int)fs->e2fs_bsize, cred, &newb)) != 0) {
 			brelse(bp);

==== //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2_rsv_win.h#12 (text+ko) ====

@@ -31,8 +31,8 @@
 #include <sys/tree.h>
 
 #define EXT2_RSV_DEFAULT_RESERVE_BLKS 8
-#define EXT2_RSV_MAX_RESERVE_BLKS 1024
-#define EXT2_RSV_NOT_ALLOCATED 0
+#define EXT2_RSV_MAX_RESERVE_BLKS     1024
+#define EXT2_RSV_NOT_ALLOCATED        0
 
 #define EXT2_RSV_LOCK(ip)   mtx_lock(&ip->i_rsv_lock)
 #define EXT2_RSV_UNLOCK(ip) mtx_unlock(&ip->i_rsv_lock)
@@ -60,19 +60,19 @@
 		 const struct ext2_rsv_win *b)
 {
 	if (a->rsv_start < b->rsv_start)
-		return -1;
+		return (-1);
 	if (a->rsv_start == b->rsv_start)
-		return 0;
+		return (0);
 
-	return 1;
+	return (1);
 }
 RB_PROTOTYPE(ext2_rsv_win_tree, ext2_rsv_win, rsv_link, ext2_rsv_win_cmp);
 
+/* predefine */
 struct inode;
 /* ext2_alloc.c */
 void    ext2_init_rsv(struct inode *ip);
 void    ext2_discard_rsv(struct inode *ip);
-int     ext2_alloc_rsv(struct inode *, int32_t, int32_t,
-                       int, struct ucred *, int32_t *);
+int     ext2_alloc_rsv(struct inode *, int32_t, int32_t, int, struct ucred *, int32_t *);
 
 #endif /* !_FS_EXT2FS_EXT2_RSV_WIN_H_ */

==== //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2_vfsops.c#7 (text+ko) ====

@@ -1,4 +1,4 @@
-/*-
+/*
  *  modified for EXT2FS support in Lites 1.1
  *
  *  Aug 1995, Godmar Back (gback@cs.utah.edu)
@@ -61,6 +61,7 @@
 #include <fs/ext2fs/fs.h>
 #include <fs/ext2fs/ext2_extern.h>
 #include <fs/ext2fs/ext2fs.h>
+#include <fs/ext2fs/ext2_rsv_win.h>
 
 static int	ext2_flushfiles(struct mount *mp, int flags, struct thread *td);
 static int	ext2_mountfs(struct vnode *, struct mount *);
@@ -585,7 +586,9 @@
 	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);
+        ump->um_e2fs->e2fs_rsv_tree = malloc(sizeof(struct ext2_rsv_win_tree),
+            M_EXT2MNT, M_WAITOK | M_ZERO);
+	RB_INIT(ump->um_e2fs->e2fs_rsv_tree);
 
 	brelse(bp);
 	bp = NULL;
@@ -686,6 +689,7 @@
 	g_topology_unlock();
 	PICKUP_GIANT();
 	vrele(ump->um_devvp);
+        free(fs->e2fs_rsv_tree, M_EXT2MNT);
 	mtx_destroy(&fs->e2fs_rsv_lock);
 	free(fs->e2fs_gd, M_EXT2MNT);
 	free(fs->e2fs_contigdirs, M_EXT2MNT);
@@ -928,11 +932,7 @@
 
 	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);
 
 	/*
 	 * Now we want to make sure that block pointers for unused

==== //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2fs.h#4 (text+ko) ====

@@ -39,7 +39,6 @@
 
 #include <sys/types.h>
 #include <sys/lock.h>
-#include <fs/ext2fs/ext2_rsv_win.h>
 
 /*
  * Special inode numbers
@@ -177,8 +176,8 @@
 	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 */
+	struct mtx e2fs_rsv_lock;                /* Protect reservation window RB tree */
+	struct ext2_rsv_win_tree *e2fs_rsv_tree; /* Reservation window index */
 };
 
 /*

==== //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/inode.h#5 (text+ko) ====

@@ -40,7 +40,6 @@
 
 #include <sys/lock.h>
 #include <sys/queue.h>
-#include <fs/ext2fs/ext2_rsv_win.h>
 
 #define	ROOTINO	((ino_t)2)
 
@@ -102,6 +101,7 @@
 	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 */
 };



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201008181048.o7IAmndY065706>