PERFORCE change 190776 for review
Zheng Liu
lz at FreeBSD.org
Fri Apr 1 16:32:56 UTC 2011
http://p4web.freebsd.org/@@190776?ac=10
Change 190776 by lz at freebsd-dev on 2011/03/30 13:20:45
Move ext2_init_rsv(), ext2_discard_rsv() and ext2_remove_rsv_win() to ext2_prealloc.c.
Affected files ...
.. //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2_alloc.c#43 edit
.. //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2_extern.h#5 edit
.. //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2_prealloc.c#2 edit
.. //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2_prealloc.h#3 edit
Differences ...
==== //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2_alloc.c#43 (text+ko) ====
@@ -77,14 +77,11 @@
static int ext2_bpref_in_rsv(struct ext2_rsv_win *, int32_t);
static int ext2_find_rsv(struct ext2_rsv_win *, struct ext2_rsv_win *,
struct m_ext2fs *, int32_t, int);
-static void ext2_remove_rsv_win(struct m_ext2fs *, struct ext2_rsv_win *);
static u_long ext2_rsvalloc(struct m_ext2fs *, struct inode *,
int, struct buf *, int32_t, int);
static daddr_t ext2_search_next_block(struct m_ext2fs *, char *, int, int);
static struct ext2_rsv_win *ext2_search_rsv(struct ext2_rsv_win_tree *, int32_t);
-RB_GENERATE(ext2_rsv_win_tree, ext2_rsv_win, rsv_link, ext2_rsv_win_cmp);
-
/*
* Allocate a block in the file system.
*
@@ -99,14 +96,11 @@
* groups without preference.
*/
-SYSCTL_NODE(_vfs, OID_AUTO, ext2fs, CTLFLAG_RW, 0, "EXT2FS filesystem");
+SYSCTL_NODE(_vfs, OID_AUTO, ext2fs, CTLFLAG_RD, 0, "EXT2FS filesystem");
static int doprealloc = 0;
SYSCTL_INT(_vfs_ext2fs, OID_AUTO, doprealloc, CTLFLAG_RW, &doprealloc, 0, "");
-static int prealloc_size = 8;
-SYSCTL_UINT(_vfs_ext2fs, OID_AUTO, prealloc_size, CTLFLAG_RW, &prealloc_size, 0, "");
-
/*
* Allocate a free block.
*
@@ -202,78 +196,6 @@
}
/*
- * Initialize reservation window per inode.
- */
-void
-ext2_init_rsv(struct inode *ip)
-{
- struct ext2_rsv_win *rp;
-
- rp = malloc(sizeof(struct ext2_rsv_win),
- M_EXT2NODE, M_WAITOK | M_ZERO);
-
- /*
- * If malloc failed, we just do not use the
- * reservation window mechanism.
- */
- if (rp == NULL)
- return;
-
- rp->rsv_start = EXT2_RSV_NOT_ALLOCATED;
- rp->rsv_end = EXT2_RSV_NOT_ALLOCATED;
-
- if (prealloc_size < EXT2_RSV_MAX_RESERVE_BLKS)
- rp->rsv_goal_size = prealloc_size;
- else
- rp->rsv_goal_size = EXT2_RSV_DEFAULT_RESERVE_BLKS;
- rp->rsv_alloc_hit = 0;
-
- ip->i_rsv = rp;
-}
-
-/*
- * Discard reservation window.
- *
- * It is called during the following situations:
- * 1. free an inode
- * 2. truncate a file
- */
-void
-ext2_discard_rsv(struct inode *ip)
-{
- struct ext2_rsv_win *rp;
-
- if (ip->i_rsv == NULL)
- return;
-
- rp = ip->i_rsv;
-
- /* If reservation window is empty, nothing to do */
- if (rp->rsv_end == EXT2_RSV_NOT_ALLOCATED)
- return;
-
- EXT2_TREE_LOCK(ip->i_e2fs);
- ext2_remove_rsv_win(ip->i_e2fs, rp);
- EXT2_TREE_UNLOCK(ip->i_e2fs);
- if (prealloc_size < EXT2_RSV_MAX_RESERVE_BLKS)
- rp->rsv_goal_size = prealloc_size;
- else
- rp->rsv_goal_size = EXT2_RSV_DEFAULT_RESERVE_BLKS;
-}
-
-/*
- * Remove a ext2_rsv_win structure from RB tree.
- */
-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);
- rp->rsv_start = EXT2_RSV_NOT_ALLOCATED;
- rp->rsv_end = EXT2_RSV_NOT_ALLOCATED;
- rp->rsv_alloc_hit = 0;
-}
-
-/*
* Check bpref is in the reservation window.
*/
static int
==== //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2_extern.h#5 (text+ko) ====
@@ -91,4 +91,7 @@
extern struct vop_vector ext2_vnodeops;
extern struct vop_vector ext2_fifoops;
+#include <sys/sysctl.h>
+SYSCTL_DECL(_vfs_ext2fs);
+
#endif /* !_FS_EXT2FS_EXT2_EXTERN_H_ */
==== //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2_prealloc.c#2 (text+ko) ====
@@ -42,3 +42,80 @@
#include <fs/ext2fs/fs.h>
#include <fs/ext2fs/ext2_extern.h>
#include <fs/ext2fs/ext2_prealloc.h>
+
+RB_GENERATE(ext2_rsv_win_tree, ext2_rsv_win, rsv_link, ext2_rsv_win_cmp);
+
+static int prealloc_size = 8;
+SYSCTL_UINT(_vfs_ext2fs, OID_AUTO, prealloc_size, CTLFLAG_RW, &prealloc_size, 0, "");
+
+/*
+ * Remove a ext2_rsv_win structure from RB tree.
+ */
+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);
+ rp->rsv_start = EXT2_RSV_NOT_ALLOCATED;
+ rp->rsv_end = EXT2_RSV_NOT_ALLOCATED;
+ rp->rsv_alloc_hit = 0;
+}
+
+/*
+ * Initialize reservation window per inode.
+ */
+void
+ext2_init_rsv(struct inode *ip)
+{
+ struct ext2_rsv_win *rp;
+
+ rp = malloc(sizeof(struct ext2_rsv_win),
+ M_EXT2NODE, M_WAITOK | M_ZERO);
+
+ /*
+ * If malloc failed, we just do not use the
+ * reservation window mechanism.
+ */
+ if (rp == NULL)
+ return;
+
+ rp->rsv_start = EXT2_RSV_NOT_ALLOCATED;
+ rp->rsv_end = EXT2_RSV_NOT_ALLOCATED;
+
+ if (prealloc_size < EXT2_RSV_MAX_RESERVE_BLKS)
+ rp->rsv_goal_size = prealloc_size;
+ else
+ rp->rsv_goal_size = EXT2_RSV_DEFAULT_RESERVE_BLKS;
+ rp->rsv_alloc_hit = 0;
+
+ ip->i_rsv = rp;
+}
+
+/*
+ * Discard reservation window.
+ *
+ * It is called during the following situations:
+ * 1. free an inode
+ * 2. truncate a file
+ */
+void
+ext2_discard_rsv(struct inode *ip)
+{
+ struct ext2_rsv_win *rp;
+
+ if (ip->i_rsv == NULL)
+ return;
+
+ rp = ip->i_rsv;
+
+ /* If reservation window is empty, nothing to do */
+ if (rp->rsv_end == EXT2_RSV_NOT_ALLOCATED)
+ return;
+
+ EXT2_TREE_LOCK(ip->i_e2fs);
+ ext2_remove_rsv_win(ip->i_e2fs, rp);
+ EXT2_TREE_UNLOCK(ip->i_e2fs);
+ if (prealloc_size < EXT2_RSV_MAX_RESERVE_BLKS)
+ rp->rsv_goal_size = prealloc_size;
+ else
+ rp->rsv_goal_size = EXT2_RSV_DEFAULT_RESERVE_BLKS;
+}
==== //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2_prealloc.h#3 (text+ko) ====
@@ -74,5 +74,6 @@
void ext2_init_rsv(struct inode *ip);
void ext2_discard_rsv(struct inode *ip);
int ext2_prealloc(struct inode *, int32_t, int32_t, int, struct ucred *);
+void ext2_remove_rsv_win(struct m_ext2fs *, struct ext2_rsv_win *);
#endif /* !_FS_EXT2FS_EXT2_PREALLOC_H_ */
More information about the p4-projects
mailing list