PERFORCE change 180937 for review
Zheng Liu
lz at FreeBSD.org
Wed Jul 14 08:28:22 UTC 2010
http://p4web.freebsd.org/@@180937?ac=10
Change 180937 by lz at 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 <fs/ext2fs/ext2_extern.h>
#include <fs/ext2fs/ext2fs.h>
#include <fs/ext2fs/fs.h>
+#include <fs/ext2fs/ext2_extents.h>
#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);
}
More information about the p4-projects
mailing list