From owner-p4-projects@FreeBSD.ORG Fri Jul 30 12:13:37 2010 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id C99A7106567A; Fri, 30 Jul 2010 12:13:36 +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 8CF981065689 for ; Fri, 30 Jul 2010 12:13:36 +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 79EF88FC12 for ; Fri, 30 Jul 2010 12:13:36 +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 o6UCDaCd055982 for ; Fri, 30 Jul 2010 12:13:36 GMT (envelope-from lz@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.4/8.14.4/Submit) id o6UCDaJ9055980 for perforce@freebsd.org; Fri, 30 Jul 2010 12:13:36 GMT (envelope-from lz@FreeBSD.org) Date: Fri, 30 Jul 2010 12:13:36 GMT Message-Id: <201007301213.o6UCDaJ9055980@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 181592 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, 30 Jul 2010 12:13:37 -0000 http://p4web.freebsd.org/@@181592?ac=10 Change 181592 by lz@gnehzuil-freebsd on 2010/07/30 12:13:08 Add some data structures for hash directory index and split ext2_lookup function into two functions, ext2_link_lookup() and ext2_index_lookup(). Affected files ... .. //depot/projects/soc2010/ext4fs/src/sys/fs/ext2fs/ext2_lookup.c#3 edit .. //depot/projects/soc2010/ext4fs/src/sys/fs/ext2fs/ext2fs.h#6 edit Differences ... ==== //depot/projects/soc2010/ext4fs/src/sys/fs/ext2fs/ext2_lookup.c#3 (text+ko) ==== @@ -71,6 +71,60 @@ 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 @@ -253,42 +307,19 @@ } /* - * 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 + * lookup function with hash directory index. + */ +static int +ext2_index_lookup(struct vop_cachedlookup_args *ap) +{ + return (EIO); +} + +/* + * Traditional lookup function. */ -int -ext2_lookup(ap) - struct vop_cachedlookup_args /* { - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; - } */ *ap; +static int +ext2_link_lookup(struct vop_cachedlookup_args *ap) { struct vnode *vdp; /* vnode for directory being searched */ struct inode *dp; /* inode for directory being searched */ @@ -691,6 +722,56 @@ 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/ext2fs.h#6 (text+ko) ==== @@ -248,6 +248,10 @@ */ #define EXT2F_COMPAT_PREALLOC 0x0001 #define EXT2F_COMPAT_RESIZE 0x0010 +#define EXT4F_COMPAT_IMAGIC_INODES 0x0002 +#define EXT4F_COMPAT_HAS_JOURNAL 0x0004 +#define EXT4F_COMPAT_EXT_ATTR 0x0008 +#define EXT4F_COMPAT_DIR_INDEX 0x0020 #define EXT2F_ROCOMPAT_SPARSESUPER 0x0001 #define EXT2F_ROCOMPAT_LARGEFILE 0x0002