From owner-p4-projects@FreeBSD.ORG Fri Apr 1 16:32:56 2011 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id C1D5B1065AA0; Fri, 1 Apr 2011 16:32:55 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1FD8910657BF for ; Fri, 1 Apr 2011 16:32:53 +0000 (UTC) (envelope-from lz@FreeBSD.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id 0BF9D8FC17 for ; Fri, 1 Apr 2011 16:32:53 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.4/8.14.4) with ESMTP id p31GWqfe075469 for ; Fri, 1 Apr 2011 16:32:52 GMT (envelope-from lz@FreeBSD.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.4/8.14.4/Submit) id p31GWqKx075466 for perforce@freebsd.org; Fri, 1 Apr 2011 16:32:52 GMT (envelope-from lz@FreeBSD.org) Date: Fri, 1 Apr 2011 16:32:52 GMT Message-Id: <201104011632.p31GWqKx075466@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to lz@FreeBSD.org using -f From: Zheng Liu To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 190776 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 16:32:56 -0000 http://p4web.freebsd.org/@@190776?ac=10 Change 190776 by lz@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 +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 #include #include + +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_ */