From owner-p4-projects@FreeBSD.ORG Wed Jul 14 08:28:22 2010 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 49C5C1065673; Wed, 14 Jul 2010 08:28:22 +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 0D9C41065677 for ; Wed, 14 Jul 2010 08:28:22 +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 E6C968FC18 for ; Wed, 14 Jul 2010 08:28:21 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id o6E8SLNS097549 for ; Wed, 14 Jul 2010 08:28:21 GMT (envelope-from lz@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id o6E8SLm3097547 for perforce@freebsd.org; Wed, 14 Jul 2010 08:28:21 GMT (envelope-from lz@FreeBSD.org) Date: Wed, 14 Jul 2010 08:28:21 GMT Message-Id: <201007140828.o6E8SLm3097547@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 180937 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: Wed, 14 Jul 2010 08:28:22 -0000 http://p4web.freebsd.org/@@180937?ac=10 Change 180937 by lz@gnehzuil-freebsd on 2010/07/14 08:28:12 Now ext2fs can read ext4 extents from any sub-directory. Affected files ... .. //depot/projects/soc2010/ext4fs/src/sys/fs/ext2fs/ext2_extents.c#5 edit .. //depot/projects/soc2010/ext4fs/src/sys/fs/ext2fs/ext2_readwrite.c#6 edit .. //depot/projects/soc2010/ext4fs/src/sys/fs/ext2fs/ext2_subr.c#3 edit Differences ... ==== //depot/projects/soc2010/ext4fs/src/sys/fs/ext2fs/ext2_extents.c#5 (text+ko) ==== @@ -132,6 +132,9 @@ ehp = (struct ext4_extent_header *)((char *)ip->i_db); depth = ehp->eh_depth; + if (ehp->eh_magic != EXT4_EXT_MAGIC) + return (NULL); + if (path == NULL) { path = malloc(sizeof(struct ext4_extent_path) * (depth * 2), M_EXT2NODE, M_WAITOK | M_ZERO); ==== //depot/projects/soc2010/ext4fs/src/sys/fs/ext2fs/ext2_readwrite.c#6 (text+ko) ==== @@ -80,7 +80,6 @@ mode = ip->i_mode; uio = ap->a_uio; -printf("====\n"); orig_resid = uio->uio_resid; KASSERT(orig_resid >= 0, ("ext2_read: uio->uio_resid < 0")); if (orig_resid == 0) ==== //depot/projects/soc2010/ext4fs/src/sys/fs/ext2fs/ext2_subr.c#3 (text+ko) ==== @@ -50,6 +50,7 @@ #include #include #include +#include #ifdef KDB void ext2_checkoverlap(struct buf *, struct inode *); @@ -70,8 +71,13 @@ struct inode *ip; struct m_ext2fs *fs; struct buf *bp; + struct ext4_extent *ep; + struct ext4_extent_header *ehp; + struct ext4_extent_path path[20]; int32_t lbn; int bsize, error; + int depth; + daddr_t newblk; ip = VTOI(vp); fs = ip->i_e2fs; @@ -79,13 +85,38 @@ bsize = blksize(fs, ip, lbn); *bpp = NULL; - if ((error = bread(vp, lbn, bsize, NOCRED, &bp)) != 0) { - brelse(bp); - return (error); - } - if (res) - *res = (char *)bp->b_data + blkoff(fs, offset); - *bpp = bp; + if (ext4_ext_find_extent(fs, ip, lbn, path) == NULL) + goto normal; + depth = ((struct ext4_extent_header *)(ip->i_db))->eh_depth; + if (path[depth].ep_ext == NULL && depth != 0) + goto normal; + ehp = path[depth].ep_header; + ep = path[depth].ep_ext; + if (ep == NULL) + goto normal; + + newblk = lbn - ep->e_blk + + (ep->e_start_lo | ((daddr_t)(ep->e_start_hi) << 31) << 1); + + if ((error = bread(ip->i_devvp, fsbtodb(fs, newblk), bsize, NOCRED, &bp)) != 0) { + brelse(bp); + return (error); + } + if (res) + *res = (char *)bp->b_data + blkoff(fs, offset); + *bpp = bp; + return (0); + +normal: + if (*bpp == NULL) { + if ((error = bread(vp, lbn, bsize, NOCRED, &bp)) != 0) { + brelse(bp); + return (error); + } + if (res) + *res = (char *)bp->b_data + blkoff(fs, offset); + *bpp = bp; + } return (0); }