From 7cf8c1ce4f1aec5a66493b3c4db234287e34a21b Mon Sep 17 00:00:00 2001 From: nikita Date: Tue, 15 Aug 2006 11:19:00 +0000 Subject: [PATCH] add "positioning by hash" to iam --- lustre/include/dt_object.h | 4 + .../kernel_patches/patches/ext3-iam-separate.patch | 176 +++++++++++++++------ lustre/kernel_patches/patches/ext3-iam-uapi.patch | 72 +++++---- lustre/osd/osd_handler.c | 34 ++-- 4 files changed, 198 insertions(+), 88 deletions(-) diff --git a/lustre/include/dt_object.h b/lustre/include/dt_object.h index 7e0d283..9f52549 100644 --- a/lustre/include/dt_object.h +++ b/lustre/include/dt_object.h @@ -313,6 +313,10 @@ struct dt_index_operations { const struct dt_it *di); struct dt_rec *(*rec)(const struct lu_context *ctxt, const struct dt_it *di); + __u32 (*store)(const struct lu_context *ctxt, + const struct dt_it *di); + int (*load)(const struct lu_context *ctxt, + const struct dt_it *di, __u32 hash); } dio_it; }; diff --git a/lustre/kernel_patches/patches/ext3-iam-separate.patch b/lustre/kernel_patches/patches/ext3-iam-separate.patch index 80d8eaf..047edc6 100644 --- a/lustre/kernel_patches/patches/ext3-iam-separate.patch +++ b/lustre/kernel_patches/patches/ext3-iam-separate.patch @@ -1,7 +1,7 @@ Index: iam/fs/ext3/Makefile =================================================================== --- iam.orig/fs/ext3/Makefile 2006-05-31 20:24:32.000000000 +0400 -+++ iam/fs/ext3/Makefile 2006-08-11 20:55:34.000000000 +0400 ++++ iam/fs/ext3/Makefile 2006-08-14 23:16:52.000000000 +0400 @@ -6,7 +6,7 @@ obj-$(CONFIG_EXT3_FS) += ext3.o ext3-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o iopen.o \ @@ -14,8 +14,8 @@ Index: iam/fs/ext3/Makefile Index: iam/fs/ext3/iam.c =================================================================== --- iam.orig/fs/ext3/iam.c 2004-04-06 17:27:52.000000000 +0400 -+++ iam/fs/ext3/iam.c 2006-07-21 22:21:17.000000000 +0400 -@@ -0,0 +1,1280 @@ ++++ iam/fs/ext3/iam.c 2006-08-14 21:23:00.000000000 +0400 +@@ -0,0 +1,1324 @@ +/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- + * vim:expandtab:shiftwidth=8:tabstop=8: + * @@ -342,13 +342,11 @@ Index: iam/fs/ext3/iam.c + return iam_leaf_ops(leaf)->key_size(leaf); +} + -+#if 0 +static struct iam_ikey *iam_leaf_ikey(const struct iam_leaf *leaf, + struct iam_ikey *key) +{ + return iam_leaf_ops(leaf)->ikey(leaf, key); +} -+#endif + +static int iam_leaf_keycmp(const struct iam_leaf *leaf, + const struct iam_key *key) @@ -642,7 +640,7 @@ Index: iam/fs/ext3/iam.c + * Performs tree top-to-bottom traversal starting from root, and loads leaf + * node. + */ -+static int iam_path_lookup(struct iam_path *path) ++static int iam_path_lookup(struct iam_path *path, int index) +{ + struct iam_container *c; + struct iam_descr *descr; @@ -657,33 +655,28 @@ Index: iam/fs/ext3/iam.c + if (result == 0) { + result = iam_leaf_load(path); + assert(ergo(result == 0, iam_leaf_check(leaf))); -+ if (result == 0) -+ result = iam_leaf_ops(leaf)-> -+ lookup(leaf, path->ip_key_target); ++ if (result == 0) { ++ if (index) ++ result = iam_leaf_ops(leaf)-> ++ ilookup(leaf, path->ip_ikey_target); ++ else ++ result = iam_leaf_ops(leaf)-> ++ lookup(leaf, path->ip_key_target); ++ } + } + return result; +} + +/* -+ * Attach iterator. After successful completion, @it points to record with -+ * least key not larger than @k. -+ * -+ * Return value: 0: positioned on existing record, -+ * +ve: exact position found, -+ * -ve: error. -+ * -+ * precondition: it_state(it) == IAM_IT_DETACHED -+ * postcondition: ergo(result == 0 && it_state(it) == IAM_IT_ATTACHED, -+ * it_keycmp(it, k) <= 0) ++ * Common part of iam_it_{i,}get(). + */ -+int iam_it_get(struct iam_iterator *it, const struct iam_key *k) ++static int __iam_it_get(struct iam_iterator *it, int index) +{ + int result; + assert(it_state(it) == IAM_IT_DETACHED); + -+ it->ii_path.ip_key_target = k; + iam_it_lock(it); -+ result = iam_path_lookup(&it->ii_path); ++ result = iam_path_lookup(&it->ii_path, index); + if (result >= 0) { + switch (result) { + case IAM_LOOKUP_EXACT: @@ -704,18 +697,54 @@ Index: iam/fs/ext3/iam.c + } + } else + iam_it_unlock(it); -+ assert(ergo(result > 0, it_keycmp(it, k) == 0)); -+ assert(ergo(result == 0 && it_state(it) == IAM_IT_ATTACHED, -+ it_keycmp(it, k) <= 0)); + /* + * See iam_it_get_exact() for explanation. + */ + assert(result != -ENOENT); + return result; +} ++ ++/* ++ * Attach iterator. After successful completion, @it points to record with ++ * least key not larger than @k. ++ * ++ * Return value: 0: positioned on existing record, ++ * +ve: exact position found, ++ * -ve: error. ++ * ++ * precondition: it_state(it) == IAM_IT_DETACHED ++ * postcondition: ergo(result == 0 && it_state(it) == IAM_IT_ATTACHED, ++ * it_keycmp(it, k) <= 0) ++ */ ++int iam_it_get(struct iam_iterator *it, const struct iam_key *k) ++{ ++ int result; ++ assert(it_state(it) == IAM_IT_DETACHED); ++ ++ it->ii_path.ip_ikey_target = NULL; ++ it->ii_path.ip_key_target = k; ++ ++ result = __iam_it_get(it, 0); ++ ++ assert(ergo(result > 0, it_keycmp(it, k) == 0)); ++ assert(ergo(result == 0 && it_state(it) == IAM_IT_ATTACHED, ++ it_keycmp(it, k) <= 0)); ++ return result; ++} +EXPORT_SYMBOL(iam_it_get); + +/* ++ * Attach iterator by index key. ++ */ ++static int iam_it_iget(struct iam_iterator *it, const struct iam_ikey *k) ++{ ++ assert(it_state(it) == IAM_IT_DETACHED); ++ ++ it->ii_path.ip_ikey_target = k; ++ return __iam_it_get(it, 1); ++} ++ ++/* + * Attach iterator, and assure it points to the record (not skewed). + * + * Return value: 0: positioned on existing record, @@ -892,6 +921,21 @@ Index: iam/fs/ext3/iam.c +EXPORT_SYMBOL(iam_it_rec_set); + +/* ++ * Return pointer to the index key under iterator. ++ * ++ * precondition: it_state(it) == IAM_IT_ATTACHED || ++ * it_state(it) == IAM_IT_SKEWED ++ */ ++static struct iam_ikey *iam_it_ikey_get(const struct iam_iterator *it, ++ struct iam_ikey *ikey) ++{ ++ assert(it_state(it) == IAM_IT_ATTACHED || ++ it_state(it) == IAM_IT_SKEWED); ++ assert(it_at_rec(it)); ++ return iam_leaf_ikey(&it->ii_path.ip_leaf, ikey); ++} ++ ++/* + * Return pointer to the key under iterator. + * + * precondition: it_state(it) == IAM_IT_ATTACHED || @@ -1109,10 +1153,10 @@ Index: iam/fs/ext3/iam.c + + assert(it_state(it) == IAM_IT_ATTACHED); + assert(it_at_rec(it)); -+ assert(iam_it_container(it)->ic_descr->id_key_size <= sizeof result); ++ assert(iam_it_container(it)->ic_descr->id_ikey_size <= sizeof result); + -+ result = *(iam_pos_t *)iam_it_key_get(it); -+ return result; ++ result = 0; ++ return *(iam_pos_t *)iam_it_ikey_get(it, (void *)&result); +} +EXPORT_SYMBOL(iam_it_store); + @@ -1127,8 +1171,8 @@ Index: iam/fs/ext3/iam.c +int iam_it_load(struct iam_iterator *it, iam_pos_t pos) +{ + assert(it_state(it) == IAM_IT_DETACHED && it->ii_flags&IAM_IT_MOVE); -+ assert(iam_it_container(it)->ic_descr->id_key_size <= sizeof pos); -+ return iam_it_get(it, (struct iam_key *)&pos); ++ assert(iam_it_container(it)->ic_descr->id_ikey_size <= sizeof pos); ++ return iam_it_iget(it, (struct iam_ikey *)&pos); +} +EXPORT_SYMBOL(iam_it_load); + @@ -1299,8 +1343,8 @@ Index: iam/fs/ext3/iam.c Index: iam/fs/ext3/iam_htree.c =================================================================== --- iam.orig/fs/ext3/iam_htree.c 2004-04-06 17:27:52.000000000 +0400 -+++ iam/fs/ext3/iam_htree.c 2006-07-01 19:09:16.000000000 +0400 -@@ -0,0 +1,655 @@ ++++ iam/fs/ext3/iam_htree.c 2006-08-14 21:29:47.000000000 +0400 +@@ -0,0 +1,664 @@ +/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- + * vim:expandtab:shiftwidth=8:tabstop=8: + * @@ -1589,6 +1633,12 @@ Index: iam/fs/ext3/iam_htree.c + return result; +} + ++static int iam_htree_ilookup(struct iam_leaf *l, const struct iam_ikey *ik) ++{ ++ assert(0); ++ return IAM_LOOKUP_OK; ++} ++ +static void iam_htree_key_set(struct iam_leaf *l, const struct iam_key *k) +{ + assert(iam_leaf_at_rec(l)); @@ -1733,6 +1783,7 @@ Index: iam/fs/ext3/iam_htree.c + .key_size = iam_htree_key_size, + .rec_set = iam_htree_rec_set, + .lookup = iam_htree_lookup, ++ .ilookup = iam_htree_ilookup, + .at_end = iam_htree_at_end, + .rec_add = iam_htree_rec_add, + .rec_del = iam_htree_rec_del, @@ -1827,8 +1878,10 @@ Index: iam/fs/ext3/iam_htree.c + } + if (name != NULL) + ext3fs_dirhash(name, namelen, ipc->ipc_hinfo); -+ path->ip_ikey_target = iam_path_ikey(path, 4); -+ *(__u32 *)path->ip_ikey_target = ipc->ipc_hinfo->hash; ++ if (path->ip_ikey_target == NULL) { ++ path->ip_ikey_target = iam_path_ikey(path, 4); ++ *(__u32 *)path->ip_ikey_target = ipc->ipc_hinfo->hash; ++ } + } else { + /* non-root index */ + assert(entries == data + iam_path_descr(path)->id_node_gap); @@ -1959,8 +2012,8 @@ Index: iam/fs/ext3/iam_htree.c Index: iam/fs/ext3/iam_lfix.c =================================================================== --- iam.orig/fs/ext3/iam_lfix.c 2004-04-06 17:27:52.000000000 +0400 -+++ iam/fs/ext3/iam_lfix.c 2006-07-01 19:19:48.000000000 +0400 -@@ -0,0 +1,660 @@ ++++ iam/fs/ext3/iam_lfix.c 2006-08-14 21:24:50.000000000 +0400 +@@ -0,0 +1,669 @@ +/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- + * vim:expandtab:shiftwidth=8:tabstop=8: + * @@ -2231,6 +2284,12 @@ Index: iam/fs/ext3/iam_lfix.c + return result; +} + ++static int iam_lfix_ilookup(struct iam_leaf *l, const struct iam_ikey *ik) ++{ ++ assert(0); ++ return IAM_LOOKUP_OK; ++} ++ +static void iam_lfix_key_set(struct iam_leaf *l, const struct iam_key *k) +{ + assert(iam_leaf_at_rec(l)); @@ -2397,6 +2456,7 @@ Index: iam/fs/ext3/iam_lfix.c + .key_size = iam_lfix_key_size, + .rec_set = iam_lfix_rec_set, + .lookup = iam_lfix_lookup, ++ .ilookup = iam_lfix_ilookup, + .at_end = iam_lfix_at_end, + .rec_add = iam_lfix_rec_add, + .rec_del = iam_lfix_rec_del, @@ -2506,7 +2566,9 @@ Index: iam/fs/ext3/iam_lfix.c + + root = data; + path->ip_indirect = root->ilr_indirect_levels; -+ path->ip_ikey_target = (struct iam_ikey *)path->ip_key_target; ++ if (path->ip_ikey_target == NULL) ++ path->ip_ikey_target = ++ (struct iam_ikey *)path->ip_key_target; + } + frame->entries = frame->at = entries; + return 0; @@ -2624,8 +2686,8 @@ Index: iam/fs/ext3/iam_lfix.c Index: iam/fs/ext3/iam_lvar.c =================================================================== --- iam.orig/fs/ext3/iam_lvar.c 2004-04-06 17:27:52.000000000 +0400 -+++ iam/fs/ext3/iam_lvar.c 2006-07-21 22:23:04.000000000 +0400 -@@ -0,0 +1,837 @@ ++++ iam/fs/ext3/iam_lvar.c 2006-08-14 23:16:11.000000000 +0400 +@@ -0,0 +1,863 @@ +/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- + * vim:expandtab:shiftwidth=8:tabstop=8: + * @@ -2868,7 +2930,6 @@ Index: iam/fs/ext3/iam_lvar.c + + hash = (void *)key; + *hash = e_hash(n_cur(l)); -+ BUG(); /* shouldn't be called currently */ + return key; +} + @@ -2987,6 +3048,29 @@ Index: iam/fs/ext3/iam_lvar.c + return result; +} + ++static int lvar_ilookup(struct iam_leaf *leaf, const struct iam_ikey *ik) ++{ ++ struct lvar_leaf_entry *scan; ++ struct lvar_leaf_entry *end; ++ lvar_hash_t hash; ++ ++ end = n_end(leaf); ++ hash = *(const lvar_hash_t *)ik; ++ ++ for (scan = n_start(leaf); scan < end; scan = e_next(leaf, scan)) { ++ lvar_hash_t scan_hash; ++ ++ scan_hash = e_hash(scan); ++ if (scan_hash >= hash) { ++ leaf->il_at = lvar_lentry(scan); ++ return scan_hash == hash ? ++ IAM_LOOKUP_EXACT : IAM_LOOKUP_OK; ++ } ++ } ++ assert(0); ++ return IAM_LOOKUP_OK; ++} ++ +static void lvar_key_set(struct iam_leaf *l, const struct iam_key *k) +{ + assert(n_at_rec(l)); @@ -3177,6 +3261,7 @@ Index: iam/fs/ext3/iam_lvar.c + .key_size = lvar_key_size, + .rec_set = lvar_rec_set, + .lookup = lvar_lookup, ++ .ilookup = lvar_ilookup, + .at_end = lvar_at_end, + .rec_add = lvar_rec_add, + .rec_del = lvar_rec_del, @@ -3281,9 +3366,12 @@ Index: iam/fs/ext3/iam_lvar.c + root = data; + name = kchar(path->ip_key_target); + path->ip_indirect = root->vr_indirect_levels; -+ path->ip_ikey_target = iam_path_ikey(path, 4); -+ *(lvar_hash_t *)path->ip_ikey_target = -+ get_hash(path->ip_container, name, strlen(name)); ++ if (path->ip_ikey_target == NULL) { ++ path->ip_ikey_target = iam_path_ikey(path, 4); ++ *(lvar_hash_t *)path->ip_ikey_target = ++ get_hash(path->ip_container, name, ++ strlen(name)); ++ } + } + frame->entries = frame->at = entries; + return 0; @@ -5461,7 +5549,7 @@ Index: iam/fs/ext3/namei.c Index: iam/include/linux/lustre_iam.h =================================================================== --- iam.orig/include/linux/lustre_iam.h 2006-05-31 20:24:32.000000000 +0400 -+++ iam/include/linux/lustre_iam.h 2006-08-11 20:55:34.000000000 +0400 ++++ iam/include/linux/lustre_iam.h 2006-08-14 23:16:52.000000000 +0400 @@ -1,9 +1,68 @@ +/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- + * vim:expandtab:shiftwidth=8:tabstop=8: diff --git a/lustre/kernel_patches/patches/ext3-iam-uapi.patch b/lustre/kernel_patches/patches/ext3-iam-uapi.patch index c09584f..cfe8e17 100644 --- a/lustre/kernel_patches/patches/ext3-iam-uapi.patch +++ b/lustre/kernel_patches/patches/ext3-iam-uapi.patch @@ -1,7 +1,7 @@ Index: iam/fs/ext3/Makefile =================================================================== ---- iam.orig/fs/ext3/Makefile 2006-08-11 20:55:34.000000000 +0400 -+++ iam/fs/ext3/Makefile 2006-08-11 20:55:34.000000000 +0400 +--- iam.orig/fs/ext3/Makefile 2006-08-14 23:16:52.000000000 +0400 ++++ iam/fs/ext3/Makefile 2006-08-14 23:16:52.000000000 +0400 @@ -6,7 +6,7 @@ obj-$(CONFIG_EXT3_FS) += ext3.o ext3-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o iopen.o \ @@ -13,8 +13,8 @@ Index: iam/fs/ext3/Makefile ext3-$(CONFIG_EXT3_FS_POSIX_ACL) += acl.o Index: iam/fs/ext3/dir.c =================================================================== ---- iam.orig/fs/ext3/dir.c 2006-08-11 20:55:34.000000000 +0400 -+++ iam/fs/ext3/dir.c 2006-08-11 20:55:34.000000000 +0400 +--- iam.orig/fs/ext3/dir.c 2006-08-14 23:16:52.000000000 +0400 ++++ iam/fs/ext3/dir.c 2006-08-14 23:16:52.000000000 +0400 @@ -28,6 +28,7 @@ #include #include @@ -112,8 +112,8 @@ Index: iam/fs/ext3/dir.c (filp->f_version != inode->i_version)) { Index: iam/fs/ext3/file.c =================================================================== ---- iam.orig/fs/ext3/file.c 2006-08-11 20:55:34.000000000 +0400 -+++ iam/fs/ext3/file.c 2006-08-11 20:55:34.000000000 +0400 +--- iam.orig/fs/ext3/file.c 2006-08-14 23:16:52.000000000 +0400 ++++ iam/fs/ext3/file.c 2006-08-14 23:16:52.000000000 +0400 @@ -23,6 +23,7 @@ #include #include @@ -149,7 +149,7 @@ Index: iam/fs/ext3/file.c Index: iam/fs/ext3/iam-uapi.c =================================================================== --- iam.orig/fs/ext3/iam-uapi.c 2004-04-06 17:27:52.000000000 +0400 -+++ iam/fs/ext3/iam-uapi.c 2006-08-11 20:55:34.000000000 +0400 ++++ iam/fs/ext3/iam-uapi.c 2006-08-14 23:16:52.000000000 +0400 @@ -0,0 +1,361 @@ +/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- + * vim:expandtab:shiftwidth=8:tabstop=8: @@ -514,8 +514,8 @@ Index: iam/fs/ext3/iam-uapi.c +} Index: iam/fs/ext3/ioctl.c =================================================================== ---- iam.orig/fs/ext3/ioctl.c 2006-08-11 20:55:34.000000000 +0400 -+++ iam/fs/ext3/ioctl.c 2006-08-11 20:55:34.000000000 +0400 +--- iam.orig/fs/ext3/ioctl.c 2006-08-14 23:16:52.000000000 +0400 ++++ iam/fs/ext3/ioctl.c 2006-08-14 23:16:52.000000000 +0400 @@ -250,6 +250,6 @@ flags_err: @@ -526,8 +526,8 @@ Index: iam/fs/ext3/ioctl.c } Index: iam/include/linux/lustre_iam.h =================================================================== ---- iam.orig/include/linux/lustre_iam.h 2006-08-11 20:55:34.000000000 +0400 -+++ iam/include/linux/lustre_iam.h 2006-08-11 20:55:34.000000000 +0400 +--- iam.orig/include/linux/lustre_iam.h 2006-08-14 23:16:52.000000000 +0400 ++++ iam/include/linux/lustre_iam.h 2006-08-14 23:16:53.000000000 +0400 @@ -30,9 +30,6 @@ #ifndef __LINUX_LUSTRE_IAM_H__ #define __LINUX_LUSTRE_IAM_H__ @@ -713,7 +713,15 @@ Index: iam/include/linux/lustre_iam.h /* * Search leaf @l for a record with key @k or for a place * where such record is to be inserted. -@@ -221,12 +277,13 @@ struct iam_leaf_operations { +@@ -210,6 +266,7 @@ struct iam_leaf_operations { + * Scratch keys from @path can be used. + */ + int (*lookup)(struct iam_leaf *l, const struct iam_key *k); ++ int (*ilookup)(struct iam_leaf *l, const struct iam_ikey *ik); + + int (*can_add)(const struct iam_leaf *l, + const struct iam_key *k, const struct iam_rec *r); +@@ -221,12 +278,13 @@ struct iam_leaf_operations { /* * remove rec for a leaf */ @@ -729,7 +737,7 @@ Index: iam/include/linux/lustre_iam.h }; struct iam_path *iam_leaf_path(const struct iam_leaf *leaf); -@@ -241,6 +298,10 @@ struct iam_descr { +@@ -241,6 +299,10 @@ struct iam_descr { */ size_t id_key_size; /* @@ -740,7 +748,7 @@ Index: iam/include/linux/lustre_iam.h * Size of a pointer to the next level (stored in index nodes), in * bytes. */ -@@ -264,6 +325,9 @@ struct iam_descr { +@@ -264,6 +326,9 @@ struct iam_descr { struct iam_leaf_operations *id_leaf_ops; }; @@ -750,7 +758,7 @@ Index: iam/include/linux/lustre_iam.h struct iam_container { /* * Underlying flat file. IO against this object is issued to -@@ -284,7 +348,7 @@ struct iam_path_descr { +@@ -284,7 +349,7 @@ struct iam_path_descr { /* * Scratch-pad area for temporary keys. */ @@ -759,15 +767,15 @@ Index: iam/include/linux/lustre_iam.h }; /* -@@ -316,6 +380,7 @@ struct iam_path { +@@ -316,6 +381,7 @@ struct iam_path { * Key searched for. */ const struct iam_key *ip_key_target; -+ struct iam_ikey *ip_ikey_target; ++ const struct iam_ikey *ip_ikey_target; /* * Description-specific data. */ -@@ -334,6 +399,7 @@ struct iam_path_compat { +@@ -334,6 +400,7 @@ struct iam_path_compat { struct dx_hash_info *ipc_hinfo; struct dentry *ipc_dentry; struct iam_path_descr ipc_descr; @@ -775,7 +783,7 @@ Index: iam/include/linux/lustre_iam.h }; /* -@@ -347,7 +413,9 @@ enum iam_it_state { +@@ -347,7 +414,9 @@ enum iam_it_state { /* initial state */ IAM_IT_DETACHED, /* iterator is above particular record in the container */ @@ -786,7 +794,7 @@ Index: iam/include/linux/lustre_iam.h }; /* -@@ -355,7 +423,7 @@ enum iam_it_state { +@@ -355,7 +424,7 @@ enum iam_it_state { */ enum iam_it_flags { /* @@ -795,7 +803,7 @@ Index: iam/include/linux/lustre_iam.h */ IAM_IT_MOVE = (1 << 0), /* -@@ -372,15 +440,26 @@ enum iam_it_flags { +@@ -372,15 +441,26 @@ enum iam_it_flags { * doesn't point to any particular record in this container. * * After successful call to iam_it_get() and until corresponding call to @@ -825,7 +833,7 @@ Index: iam/include/linux/lustre_iam.h * */ struct iam_iterator { -@@ -390,7 +469,8 @@ struct iam_iterator { +@@ -390,7 +470,8 @@ struct iam_iterator { __u32 ii_flags; enum iam_it_state ii_state; /* @@ -835,7 +843,7 @@ Index: iam/include/linux/lustre_iam.h */ struct iam_path ii_path; }; -@@ -405,133 +485,25 @@ void iam_path_compat_fini(struct iam_pat +@@ -405,133 +486,25 @@ void iam_path_compat_fini(struct iam_pat struct iam_path_descr *iam_ipd_alloc(int keysize); void iam_ipd_free(struct iam_path_descr *ipd); @@ -972,7 +980,7 @@ Index: iam/include/linux/lustre_iam.h int iam_it_load(struct iam_iterator *it, iam_pos_t pos); int iam_lookup(struct iam_container *c, const struct iam_key *k, -@@ -577,16 +549,65 @@ static inline struct inode *iam_path_obj +@@ -577,16 +550,65 @@ static inline struct inode *iam_path_obj return p->ip_container->ic_object; } @@ -1044,7 +1052,7 @@ Index: iam/include/linux/lustre_iam.h } static inline void iam_reccpy(const struct iam_path *p, struct iam_rec *rec_dst, -@@ -604,7 +625,7 @@ static inline void *iam_entry_off(struct +@@ -604,7 +626,7 @@ static inline void *iam_entry_off(struct static inline unsigned dx_get_block(struct iam_path *p, struct iam_entry *entry) { return le32_to_cpu(*(u32*)iam_entry_off(entry, @@ -1053,7 +1061,7 @@ Index: iam/include/linux/lustre_iam.h & 0x00ffffff; } -@@ -612,21 +633,64 @@ static inline void dx_set_block(struct i +@@ -612,21 +634,64 @@ static inline void dx_set_block(struct i struct iam_entry *entry, unsigned value) { *(u32*)iam_entry_off(entry, @@ -1122,7 +1130,7 @@ Index: iam/include/linux/lustre_iam.h static inline unsigned dx_get_count(struct iam_entry *entries) { return le16_to_cpu(((struct dx_countlimit *) entries)->count); -@@ -647,9 +711,18 @@ static inline unsigned dx_node_limit(str +@@ -647,9 +712,18 @@ static inline unsigned dx_node_limit(str struct iam_descr *param = iam_path_descr(p); unsigned entry_space = iam_path_obj(p)->i_sb->s_blocksize - param->id_node_gap; @@ -1142,7 +1150,7 @@ Index: iam/include/linux/lustre_iam.h static inline struct iam_entry *dx_get_entries(struct iam_path *path, void *data, int root) { -@@ -665,7 +738,8 @@ static inline struct iam_entry *dx_node_ +@@ -665,7 +739,8 @@ static inline struct iam_entry *dx_node_ frame->bh->b_data, frame == path->ip_frames); } @@ -1152,7 +1160,7 @@ Index: iam/include/linux/lustre_iam.h { assert(0 <= nr && nr < ARRAY_SIZE(path->ip_data->ipd_key_scratch)); return path->ip_data->ipd_key_scratch[nr]; -@@ -674,6 +748,7 @@ static inline struct iam_key *iam_path_k +@@ -674,6 +749,7 @@ static inline struct iam_key *iam_path_k int dx_lookup(struct iam_path *path); void dx_insert_block(struct iam_path *path, struct iam_frame *frame, u32 hash, u32 block); @@ -1160,7 +1168,7 @@ Index: iam/include/linux/lustre_iam.h int ext3_htree_next_block(struct inode *dir, __u32 hash, struct iam_path *path, __u32 *start_hash); -@@ -681,6 +756,20 @@ int ext3_htree_next_block(struct inode * +@@ -681,6 +757,20 @@ int ext3_htree_next_block(struct inode * struct buffer_head *ext3_append(handle_t *handle, struct inode *inode, u32 *block, int *err); int split_index_node(handle_t *handle, struct iam_path *path); @@ -1181,7 +1189,7 @@ Index: iam/include/linux/lustre_iam.h /* * external -@@ -698,10 +787,12 @@ int iam_node_read(struct iam_container * +@@ -698,10 +788,12 @@ int iam_node_read(struct iam_container * handle_t *handle, struct buffer_head **bh); void iam_insert_key(struct iam_path *path, struct iam_frame *frame, @@ -1195,7 +1203,7 @@ Index: iam/include/linux/lustre_iam.h struct iam_path *iam_leaf_path(const struct iam_leaf *leaf); struct iam_container *iam_leaf_container(const struct iam_leaf *leaf); -@@ -709,14 +800,79 @@ struct iam_descr *iam_leaf_descr(const s +@@ -709,14 +801,79 @@ struct iam_descr *iam_leaf_descr(const s struct iam_leaf_operations *iam_leaf_ops(const struct iam_leaf *leaf); diff --git a/lustre/osd/osd_handler.c b/lustre/osd/osd_handler.c index 3436bd7..ef1eaa4 100644 --- a/lustre/osd/osd_handler.c +++ b/lustre/osd/osd_handler.c @@ -529,7 +529,7 @@ static void osd_trans_stop(const struct lu_context *ctx, struct thandle *th) result = dt_txn_hook_stop(ctx, th->th_dev, th); if (result != 0) CERROR("Failure in transaction hook: %d\n", result); - + /**/ oh->ot_handle = NULL; result = journal_stop(hdl); @@ -1042,14 +1042,9 @@ static int osd_dir_page_build(const struct lu_context *ctx, int first, fid_cpu_to_le(fid); recsize = (sizeof *ent + len + 3) & ~3; - /* - * XXX an interface is needed to obtain a hash. - * - * XXX this is horrible, most horrible hack. - */ - hash = *(__u32 *)(name - sizeof(__u16) - sizeof(__u32)); + hash = iops->store(ctx, it); *end = hash; - CERROR("%p %p %d "DFID": %#8.8x (%d)\"%*.*s\"\n", + CDEBUG(D_INODE, "%p %p %d "DFID": %#8.8x (%d)\"%*.*s\"\n", area, ent, nob, PFID(fid), hash, len, len, len, name); if (nob >= recsize) { ent->lde_fid = *fid; @@ -1112,7 +1107,7 @@ static int osd_readpage(const struct lu_context *ctxt, /* * XXX position iterator at rdpg->rp_hash */ - rc = iops->get(ctxt, it, (const void *)""); + rc = iops->load(ctxt, it, rdpg->rp_hash); if (rc > 0) { struct page *pg; /* no, Richard, it _is_ initialized */ struct lu_dirent *last; @@ -1439,6 +1434,19 @@ static struct dt_rec *osd_it_rec(const struct lu_context *ctx, return (struct dt_rec *)iam_it_rec_get(&it->oi_it); } +static __u32 osd_it_store(const struct lu_context *ctxt, const struct dt_it *di) +{ + struct osd_it *it = (struct osd_it *)di; + return iam_it_store(&it->oi_it); +} + +static int osd_it_load(const struct lu_context *ctxt, + const struct dt_it *di, __u32 hash) +{ + struct osd_it *it = (struct osd_it *)di; + return iam_it_load(&it->oi_it, hash); +} + static struct dt_index_operations osd_index_ops = { .dio_lookup = osd_index_lookup, .dio_insert = osd_index_insert, @@ -1451,7 +1459,9 @@ static struct dt_index_operations osd_index_ops = { .next = osd_it_next, .key = osd_it_key, .key_size = osd_it_key_size, - .rec = osd_it_rec + .rec = osd_it_rec, + .store = osd_it_store, + .load = osd_it_load } }; @@ -1955,9 +1965,9 @@ static int osd_inode_getattr(const struct lu_context *ctx, struct inode *inode, struct lu_attr *attr) { attr->la_valid |= LA_ATIME | LA_MTIME | LA_CTIME | LA_MODE | - LA_SIZE | LA_BLOCKS | LA_UID | LA_GID | + LA_SIZE | LA_BLOCKS | LA_UID | LA_GID | LA_FLAGS | LA_NLINK | LA_RDEV | LA_BLKSIZE; - + attr->la_atime = LTIME_S(inode->i_atime); attr->la_mtime = LTIME_S(inode->i_mtime); attr->la_ctime = LTIME_S(inode->i_ctime); -- 1.8.3.1