Date: Sat, 15 May 2010 01:44:46 GMT From: Zheng Liu <lz@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 178280 for review Message-ID: <201005150144.o4F1ikYA007289@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@178280?ac=10 Change 178280 by lz@gnehzuil-freebsd on 2010/05/15 01:43:48 Fix two bugs. Affected files ... .. //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2_alloc.c#8 edit Differences ... ==== //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2_alloc.c#8 (text+ko) ==== @@ -133,24 +133,24 @@ } /* - * Add a ext2_rsv_win struct to RB tree. + * Remove a ext2_rsv_win structure from RB tree. */ static void -ext2_add_rsv_win(struct m_ext2fs *fs, struct ext2_rsv_win *rp) +ext2_remove_rsv_win(struct m_ext2fs *fs, struct ext2_rsv_win *rp) { - RB_INSERT(ext2_rsv_win_tree, &fs->e2fs_rsv_tree, rp); + rp->rw_start = EXT2_RWI_NOT_ALLOCATED; + rp->rw_end = EXT2_RWI_NOT_ALLOCATED; + rp->rw_alloc_hit = 0; + RB_REMOVE(ext2_rsv_win_tree, &fs->e2fs_rsv_tree, rp); } /* - * Remove a ext2_rsv_win structure from RB tree. + * Add a ext2_rsv_win struct to RB tree. */ static void -ext2_remove_rsv_win(struct m_ext2fs *fs, struct ext2_rsv_win *rp) +ext2_add_rsv_win(struct m_ext2fs *fs, struct ext2_rsv_win *rp) { - rp->rw_start = EXT2_RWI_NOT_ALLOCATED; - rp->rw_end = EXT2_RWI_NOT_ALLOCATED; - rp->rw_alloc_hit = 0; - RB_REMOVE(ext2_rsv_win_tree, &fs->e2fs_rsv_tree, rp); + RB_INSERT(ext2_rsv_win_tree, &fs->e2fs_rsv_tree, rp); } /* @@ -162,6 +162,9 @@ { struct ext2_rsv_win *next, *prev; + if (RB_EMPTY(root)) + return NULL; + next = RB_ROOT(root); do { prev = next; @@ -170,11 +173,11 @@ else if (bpref > next->rw_end) next = RB_RIGHT(next, rw_link); else - return next; + return prev; } while(next != NULL); - if (next == NULL || next->rw_start > bpref) - next = prev; + if (prev->rw_start > bpref) + prev = RB_PREV(ext2_rsv_win_tree, root, prev); return next; } @@ -330,21 +333,18 @@ struct buf *bp, int32_t bpref, struct ext2_rsv_win *rp) { struct ext2mount *ump; - u_long start, end; + u_long start; char *bbp; u_long bno; ump = ip->i_ump; bbp = (char *)bp->b_data; - if (rp != NULL && rp->rw_end != EXT2_RWI_NOT_ALLOCATED) { + if (rp != NULL && rp->rw_end != EXT2_RWI_NOT_ALLOCATED) start = dtogd(fs, rp->rw_start + rp->rw_alloc_hit) / NBBY; - end = dtogd(fs, rp->rw_end) / NBBY; - } else { - start = dtogd(fs, bpref) / NBBY; - end = howmany(fs->e2fs->e2fs_fpg, NBBY) - start; - } + else + return 0; - if (bbp[start * NBBY] == 0) { + if (bbp[start] == 0) { bno = start * NBBY; goto gotit; } @@ -425,8 +425,6 @@ else cg = dtog(fs, bpref); - /* TODO: If cg doesn't have enought blocks, do not use reservation window */ - /* If cg has some free blocks, then try to allocate a free block from this cg */ if (fs->e2fs_gd[cg].ext2bgd_nbfree > 0) { /* Read block bitmap from buffer */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201005150144.o4F1ikYA007289>