From owner-p4-projects@FreeBSD.ORG Sun Aug 1 03:01:18 2010 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 670671065672; Sun, 1 Aug 2010 03:01:18 +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 2AE37106566C for ; Sun, 1 Aug 2010 03:01:18 +0000 (UTC) (envelope-from lz@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id F2BD98FC12 for ; Sun, 1 Aug 2010 03:01:17 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.4/8.14.4) with ESMTP id o7131Hvr093433 for ; Sun, 1 Aug 2010 03:01:17 GMT (envelope-from lz@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.4/8.14.4/Submit) id o7131HT0093431 for perforce@freebsd.org; Sun, 1 Aug 2010 03:01:17 GMT (envelope-from lz@FreeBSD.org) Date: Sun, 1 Aug 2010 03:01:17 GMT Message-Id: <201008010301.o7131HT0093431@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to lz@FreeBSD.org using -f From: Zheng Liu To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 181664 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: Sun, 01 Aug 2010 03:01:18 -0000 http://p4web.freebsd.org/@@181664?ac=10 Change 181664 by lz@gnehzuil-freebsd on 2010/08/01 03:00:22 Fix a bug in ext2_blkatoff() function and remove some code. Affected files ... .. //depot/projects/soc2010/ext4fs/src/sys/fs/ext2fs/ext2_lookup.c#4 edit .. //depot/projects/soc2010/ext4fs/src/sys/fs/ext2fs/ext2_subr.c#5 edit Differences ... ==== //depot/projects/soc2010/ext4fs/src/sys/fs/ext2fs/ext2_lookup.c#4 (text+ko) ==== @@ -71,60 +71,6 @@ SYSCTL_INT(_vfs_e2fs, OID_AUTO, dircheck, CTLFLAG_RW, &dirchk, 0, ""); /* - * Define hash directory index data structure. - */ -struct fake_dirent { - u_int32_t inode; - u_int16_t reclen; - u_int8_t namlen; - u_int8_t filetype; -}; - -struct di_countlimit { - u_int16_t limit; - u_int16_t count; -}; - -struct di_entry { - u_int32_t hash; - u_int32_t blk; -}; - -struct di_root { - struct fake_dirent dot; - char dotname[4]; - struct fake_dirent dotdot; - char dotdotname[4]; - struct di_root_info { - u_int32_t reserved; - u_int8_t hash_version; - u_int8_t ind_levels; - u_int8_t unused_flags; - } info; - struct di_entry ent[0]; -}; - -struct di_node { - struct fake_dirent fake; - struct di_entry ent[0]; -}; - -struct di_frame { - struct buf *bp; - struct di_entry *ep; - struct di_entry *at; -}; - -struct di_map_entry { - u_int32_t hash; - u_int16_t offset; - u_int16_t size; -}; - -static int ext2_index_lookup(struct vop_cachedlookup_args *ap); -static int ext2_link_lookup(struct vop_cachedlookup_args *ap); - -/* DIRBLKSIZE in ffs is DEV_BSIZE (in most cases 512) while it is the native blocksize in ext2fs - thus, a #define is no longer appropriate @@ -307,19 +253,42 @@ } /* - * lookup function with hash directory index. + * Convert a component of a pathname into a pointer to a locked inode. + * This is a very central and rather complicated routine. + * If the file system is not maintained in a strict tree hierarchy, + * this can result in a deadlock situation (see comments in code below). + * + * The cnp->cn_nameiop argument is LOOKUP, CREATE, RENAME, or DELETE depending + * on whether the name is to be looked up, created, renamed, or deleted. + * When CREATE, RENAME, or DELETE is specified, information usable in + * creating, renaming, or deleting a directory entry may be calculated. + * If flag has LOCKPARENT or'ed into it and the target of the pathname + * exists, lookup returns both the target and its parent directory locked. + * When creating or renaming and LOCKPARENT is specified, the target may + * not be ".". When deleting and LOCKPARENT is specified, the target may + * be "."., but the caller must check to ensure it does an vrele and vput + * instead of two vputs. + * + * Overall outline of ext2_lookup: + * + * search for name in directory, to found or notfound + * notfound: + * if creating, return locked directory, leaving info on available slots + * else return error + * found: + * if at end of path and deleting, return information to allow delete + * if at end of path and rewriting (RENAME and LOCKPARENT), lock target + * inode and return info to allow rewrite + * if not at end, add name to cache; if at end and neither creating + * nor deleting, add name to cache */ -static int -ext2_index_lookup(struct vop_cachedlookup_args *ap) -{ - return (EIO); -} - -/* - * Traditional lookup function. - */ -static int -ext2_link_lookup(struct vop_cachedlookup_args *ap) +int +ext2_lookup(ap) + struct vop_cachedlookup_args /* { + struct vnode *a_dvp; + struct vnode **a_vpp; + struct componentname *a_cnp; + } */ *ap; { struct vnode *vdp; /* vnode for directory being searched */ struct inode *dp; /* inode for directory being searched */ @@ -722,56 +691,6 @@ return (0); } -/* - * Convert a component of a pathname into a pointer to a locked inode. - * This is a very central and rather complicated routine. - * If the file system is not maintained in a strict tree hierarchy, - * this can result in a deadlock situation (see comments in code below). - * - * The cnp->cn_nameiop argument is LOOKUP, CREATE, RENAME, or DELETE depending - * on whether the name is to be looked up, created, renamed, or deleted. - * When CREATE, RENAME, or DELETE is specified, information usable in - * creating, renaming, or deleting a directory entry may be calculated. - * If flag has LOCKPARENT or'ed into it and the target of the pathname - * exists, lookup returns both the target and its parent directory locked. - * When creating or renaming and LOCKPARENT is specified, the target may - * not be ".". When deleting and LOCKPARENT is specified, the target may - * be "."., but the caller must check to ensure it does an vrele and vput - * instead of two vputs. - * - * Overall outline of ext2_lookup: - * - * search for name in directory, to found or notfound - * notfound: - * if creating, return locked directory, leaving info on available slots - * else return error - * found: - * if at end of path and deleting, return information to allow delete - * if at end of path and rewriting (RENAME and LOCKPARENT), lock target - * inode and return info to allow rewrite - * if not at end, add name to cache; if at end and neither creating - * nor deleting, add name to cache - */ -int -ext2_lookup(ap) - struct vop_cachedlookup_args /* { - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; - } */ *ap; -{ - struct vnode *vp; - struct ext2fs *fs; - - vp = ap->a_dvp; - fs = VFSTOEXT2(vp->v_mount)->um_e2fs->e2fs; - - if (fs->e2fs_features_compat & EXT4F_COMPAT_DIR_INDEX) - return ext2_index_lookup(ap); - else - return ext2_link_lookup(ap); -} - void ext2_dirbad(ip, offset, how) struct inode *ip; ==== //depot/projects/soc2010/ext4fs/src/sys/fs/ext2fs/ext2_subr.c#5 (text+ko) ==== @@ -83,6 +83,7 @@ fs = ip->i_e2fs; lbn = lblkno(fs, offset); bsize = blksize(fs, ip, lbn); + memset(&path, 0, sizeof(path)); *bpp = NULL; if (ext4_ext_find_extent(fs, ip, lbn, &path) == NULL) @@ -98,6 +99,10 @@ newblk = lbn - ep->e_blk + (ep->e_start_lo | ((daddr_t)(ep->e_start_hi) << 31) << 1); + if (path.ep_bp != NULL) { + brelse(path.ep_bp); + path.ep_bp = NULL; + } if ((error = bread(ip->i_devvp, fsbtodb(fs, newblk), bsize, NOCRED, &bp)) != 0) { brelse(bp); return (error);