PERFORCE change 181592 for review
Zheng Liu
lz at FreeBSD.org
Fri Jul 30 12:13:37 UTC 2010
http://p4web.freebsd.org/@@181592?ac=10
Change 181592 by lz at 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
More information about the p4-projects
mailing list