From 9773bdf9952cb3ef9fbab6d3c4e6af3d87e700bd Mon Sep 17 00:00:00 2001 From: nikita Date: Fri, 13 Oct 2006 20:10:30 +0000 Subject: [PATCH] osd: get rid of /*OBJ-TEMP* hack. --- .../kernel_patches/patches/ext3-iam-separate.patch | 116 ++++++++++--------- lustre/osd/osd_handler.c | 126 +++++---------------- lustre/osd/osd_internal.h | 4 - 3 files changed, 94 insertions(+), 152 deletions(-) diff --git a/lustre/kernel_patches/patches/ext3-iam-separate.patch b/lustre/kernel_patches/patches/ext3-iam-separate.patch index 6d5df28..2bfd4f9 100644 --- a/lustre/kernel_patches/patches/ext3-iam-separate.patch +++ b/lustre/kernel_patches/patches/ext3-iam-separate.patch @@ -4387,7 +4387,7 @@ Index: iam/fs/ext3/namei.c } /* -@@ -800,598 +232,118 @@ struct stats dx_show_entries(struct dx_h +@@ -800,7 +232,7 @@ struct stats dx_show_entries(struct dx_h } #endif /* DX_DEBUG */ @@ -4396,21 +4396,21 @@ Index: iam/fs/ext3/namei.c { u32 ptr; int err = 0; - int i; +@@ -810,588 +242,108 @@ static int dx_lookup(struct iam_path *pa + struct iam_frame *frame; + struct iam_container *c; -- struct iam_descr *param; -- struct iam_frame *frame; -- struct iam_container *c; -- - param = path_descr(path); -- c = path->ip_container; -- -- for (frame = path->ip_frames, i = 0, ++ param = iam_path_descr(path); + c = path->ip_container; + + for (frame = path->ip_frames, i = 0, - ptr = param->id_root_ptr(path->ip_container); -- i <= path->ip_indirect; -- ptr = dx_get_block(path, frame->at), ++frame, ++i) { -- struct iam_entry *entries; -- struct iam_entry *p; ++ ptr = param->id_ops->id_root_ptr(c); + i <= path->ip_indirect; + ptr = dx_get_block(path, frame->at), ++frame, ++i) { + struct iam_entry *entries; + struct iam_entry *p; - struct iam_entry *q; - struct iam_entry *m; - unsigned count; @@ -4915,64 +4915,44 @@ Index: iam/fs/ext3/namei.c - err = dx_lookup(path); - if (err) - goto errout; -+ struct iam_descr *param; -+ struct iam_frame *frame; -+ struct iam_container *c; ++ struct iam_entry *q; ++ struct iam_entry *m; ++ unsigned count; - err = iam_leaf_delete(h, path, k); -errout: - iam_path_fini(path); - return err; -} -+ param = iam_path_descr(path); -+ c = path->ip_container; ++ err = param->id_ops->id_node_read(c, (iam_ptr_t)ptr, NULL, ++ &frame->bh); ++ if (err != 0) ++ break; -EXPORT_SYMBOL(iam_delete); -+ for (frame = path->ip_frames, i = 0, -+ ptr = param->id_ops->id_root_ptr(c); -+ i <= path->ip_indirect; -+ ptr = dx_get_block(path, frame->at), ++frame, ++i) { -+ struct iam_entry *entries; -+ struct iam_entry *p; -+ struct iam_entry *q; -+ struct iam_entry *m; -+ unsigned count; ++ if (EXT3_INVARIANT_ON) { ++ err = param->id_ops->id_node_check(path, frame); ++ if (err != 0) ++ break; ++ } -static int iam_leaf_update(handle_t *handle, struct iam_path *path, - struct iam_key *k, struct iam_rec *r) -{ - struct iam_leaf leaf; - int err; -+ err = param->id_ops->id_node_read(c, (iam_ptr_t)ptr, NULL, -+ &frame->bh); ++ err = param->id_ops->id_node_load(path, frame); + if (err != 0) + break; - err = iam_leaf_init(path, &leaf); - if (err) - goto errout; -+ if (EXT3_INVARIANT_ON) { -+ err = param->id_ops->id_node_check(path, frame); -+ if (err != 0) -+ break; -+ } ++ assert_inv(dx_node_check(path, frame)); - err = iam_leaf_lookup(path, &leaf, k); - if (err) - goto errout; -+ err = param->id_ops->id_node_load(path, frame); -+ if (err != 0) -+ break; - -- memcpy(iam_leaf_entry_at(path, leaf.at), r, path_descr(path)->id_rec_size); -- memcpy(iam_leaf_key_at(path, leaf.at), k, path_descr(path)->id_key_size); -+ assert_inv(dx_node_check(path, frame)); - -- err = ext3_journal_dirty_metadata(handle, leaf.bh); -- if (err) -- ext3_std_error(path_obj(path)->i_sb, err); --errout: -- iam_leaf_fini(&leaf); + entries = frame->entries; + count = dx_get_count(entries); + assert_corr(count && count <= dx_get_limit(entries)); @@ -4988,12 +4968,19 @@ Index: iam/fs/ext3/namei.c + else + p = iam_entry_shift(path, m, +1); + } -+ + +- memcpy(iam_leaf_entry_at(path, leaf.at), r, path_descr(path)->id_rec_size); +- memcpy(iam_leaf_key_at(path, leaf.at), k, path_descr(path)->id_key_size); + frame->at = iam_entry_shift(path, p, -1); + if (EXT3_INVARIANT_ON) { // linear search cross check + unsigned n = count - 1; + struct iam_entry *at; -+ + +- err = ext3_journal_dirty_metadata(handle, leaf.bh); +- if (err) +- ext3_std_error(path_obj(path)->i_sb, err); +-errout: +- iam_leaf_fini(&leaf); + at = entries; + while (n--) { + dxtrace(printk(",")); @@ -5631,7 +5618,7 @@ Index: iam/fs/ext3/namei.c + err = ext3_journal_dirty_metadata(handle, parent->bh); + if (err) + goto journal_error; -+ } + } + err = ext3_journal_dirty_metadata(handle, bh); + if (err) + goto journal_error; @@ -5641,7 +5628,7 @@ Index: iam/fs/ext3/namei.c + */ + assert_corr(dx_get_count(path->ip_frame->entries) < + dx_get_limit(path->ip_frame->entries)); - } ++ } + if (nr_splet > 0) { + /* + * Log ->i_size modification. @@ -5685,6 +5672,33 @@ Index: iam/fs/ext3/namei.c err = add_dirent_to_buf(handle, dentry, inode, de, bh); goto cleanup2; +@@ -2752,6 +1830,26 @@ static struct inode * ext3_new_inode_wan + return ext3_new_inode(handle, dir, mode, inum); + } + ++struct inode *ext3_create_inode(handle_t *handle, struct inode * dir, int mode) ++{ ++ struct inode *inode; ++ ++ inode = ext3_new_inode(handle, dir, mode, 0); ++ if (!IS_ERR(inode)) { ++ if (S_ISCHR(mode) || S_ISBLK(mode) || S_ISFIFO(mode)) { ++#ifdef CONFIG_LDISKFS_FS_XATTR ++ inode->i_op = &ext3_special_inode_operations; ++#endif ++ } else { ++ inode->i_op = &ext3_file_inode_operations; ++ inode->i_fop = &ext3_file_operations; ++ ext3_set_aops(inode); ++ } ++ } ++ return inode; ++} ++EXPORT_SYMBOL(ext3_create_inode); ++ + /* + * By the time this is called, we already have created + * the directory cache entry for the new file, but it Index: iam/include/linux/ext3_fs.h =================================================================== --- iam.orig/include/linux/ext3_fs.h diff --git a/lustre/osd/osd_handler.c b/lustre/osd/osd_handler.c index ede82c4..7396779 100644 --- a/lustre/osd/osd_handler.c +++ b/lustre/osd/osd_handler.c @@ -283,13 +283,6 @@ static int osd_write_locked(const struct lu_env *env, struct osd_object *o) return oti->oti_w_locks > 0 && o->oo_owner == env; } -static void osd_fid_build_name(const struct lu_fid *fid, char *name) -{ - static const char *qfmt = LPX64":%lx:%lx"; - - sprintf(name, qfmt, fid_seq(fid), fid_oid(fid), fid_ver(fid)); -} - /* helper to push us into KERNEL_DS context */ static struct file *osd_rw_init(const struct lu_env *env, struct inode *inode, mm_segment_t *seg) @@ -409,8 +402,8 @@ static int osd_inode_unlinked(const struct inode *inode) } enum { - OSD_TXN_OI_DELETE_CREDITS = 20, - OSD_TXN_RMENTRY_CREDITS = 20 + OSD_TXN_OI_DELETE_CREDITS = 20, + OSD_TXN_INODE_DELETE_CREDITS = 20 }; static int osd_inode_remove(const struct lu_env *env, @@ -421,51 +414,15 @@ static int osd_inode_remove(const struct lu_env *env, struct osd_thread_info *oti = lu_context_key_get(&env->le_ctx, &osd_key); struct txn_param *prm = &oti->oti_txn; struct thandle *th; - struct dentry *dentry; int result; - prm->tp_credits = OSD_TXN_OI_DELETE_CREDITS + OSD_TXN_RMENTRY_CREDITS; + prm->tp_credits = OSD_TXN_OI_DELETE_CREDITS + + OSD_TXN_INODE_DELETE_CREDITS; th = osd_trans_start(env, &osd->od_dt_dev, prm); if (!IS_ERR(th)) { osd_oi_write_lock(&osd->od_oi); result = osd_oi_delete(oti, &osd->od_oi, fid, th); osd_oi_write_unlock(&osd->od_oi); - - /* - * The following is added by huanghua@clusterfs.com as - * a temporary hack, to remove the directory entry in - * "*OBJ_TEMP*". We will finally do not use this hack, - * and at that time we will remove these code under #if. - */ -#if 1 - osd_fid_build_name(fid, oti->oti_name); - oti->oti_str.name = oti->oti_name; - oti->oti_str.len = strlen(oti->oti_name); - - dentry = d_alloc(osd->od_obj_area, &oti->oti_str); - if (dentry != NULL) { - struct inode *dir = osd->od_obj_area->d_inode; - - /* - * The nlink is 0 now. But to avoid warning message, - * I set it to 1, and unlink() will decrease it to 0. - */ - obj->oo_inode->i_nlink = 1; - d_instantiate(dentry, obj->oo_inode); - result = dir->i_op->unlink(dir, dentry); - if (S_ISDIR(obj->oo_inode->i_mode)) { - /* - * The nlink of a dir was not decreased to - * less than 2. see ldiskfs_unlink() and - * ldiskfs_dec_count(). - */ - obj->oo_inode->i_nlink = 0; - mark_inode_dirty(obj->oo_inode); - } - dput(dentry); - } else -#endif - iput(obj->oo_inode); osd_trans_stop(env, th); } else result = PTR_ERR(th); @@ -487,10 +444,6 @@ static void osd_object_delete(const struct lu_env *env, struct lu_object *l) * If object is unlinked remove fid->ino mapping from object index. * * File body will be deleted by iput(). - * - * NOTE: currently objects are created in ->od_obj_area directory - * ("*OBJ-TEMP*"), but name in that directory is _not_ counted in - * inode ->i_nlink. */ osd_index_fini(obj); @@ -503,8 +456,8 @@ static void osd_object_delete(const struct lu_env *env, struct lu_object *l) LU_OBJECT_DEBUG(D_ERROR, env, l, "Failed to cleanup: %d\n", result); - } else - iput(inode); + } + iput(inode); obj->oo_inode = NULL; } } @@ -1030,40 +983,32 @@ static int osd_create_post(struct osd_thread_info *info, struct osd_object *obj, return 0; } +extern struct inode *ldiskfs_create_inode(handle_t *handle, + struct inode * dir, int mode); + static int osd_mkfile(struct osd_thread_info *info, struct osd_object *obj, umode_t mode, struct thandle *th) { int result; - struct osd_device *osd = osd_obj2dev(obj); - struct inode *dir; - - /* - * XXX temporary solution. - */ - struct dentry *dentry; + struct osd_device *osd = osd_obj2dev(obj); + struct osd_thandle *oth; + struct inode *dir; + struct inode *inode; LASSERT(osd_invariant(obj)); LASSERT(obj->oo_inode == NULL); LASSERT(osd->od_obj_area != NULL); + oth = container_of(th, struct osd_thandle, ot_super); dir = osd->od_obj_area->d_inode; - LASSERT(dir->i_op != NULL && dir->i_op->create != NULL); - - osd_fid_build_name(lu_object_fid(&obj->oo_dt.do_lu), info->oti_name); - info->oti_str.name = info->oti_name; - info->oti_str.len = strlen(info->oti_name); + LASSERT(dir->i_op != NULL); - dentry = d_alloc(osd->od_obj_area, &info->oti_str); - if (dentry != NULL) { - result = dir->i_op->create(dir, dentry, mode, NULL); - if (result == 0) { - LASSERT(dentry->d_inode != NULL); - obj->oo_inode = dentry->d_inode; - igrab(obj->oo_inode); - } - dput(dentry); + inode = ldiskfs_create_inode(oth->ot_handle, dir, mode); + if (!IS_ERR(inode)) { + obj->oo_inode = inode; + result = 0; } else - result = -ENOMEM; + result = PTR_ERR(inode); LASSERT(osd_invariant(obj)); return result; } @@ -1082,11 +1027,11 @@ static int osd_mkdir(struct osd_thread_info *info, struct osd_object *obj, int result; struct osd_thandle *oth; - oth = container_of0(th, struct osd_thandle, ot_super); LASSERT(S_ISDIR(attr->la_mode)); result = osd_mkfile(info, obj, (attr->la_mode & (S_IFMT | S_IRWXUGO | S_ISVTX)), th); if (result == 0) { + oth = container_of(th, struct osd_thandle, ot_super); LASSERT(obj->oo_inode != NULL); /* * XXX uh-oh... call low-level iam function directly. @@ -1122,33 +1067,20 @@ static int osd_mknod(struct osd_thread_info *info, struct osd_object *obj, struct inode *dir; umode_t mode = attr->la_mode & (S_IFMT | S_IRWXUGO | S_ISVTX); - /* - * XXX temporary solution. - */ - struct dentry *dentry; - LASSERT(osd_invariant(obj)); LASSERT(obj->oo_inode == NULL); LASSERT(osd->od_obj_area != NULL); + LASSERT(S_ISCHR(mode) || S_ISBLK(mode) || + S_ISFIFO(mode) || S_ISSOCK(mode)); dir = osd->od_obj_area->d_inode; - LASSERT(dir->i_op != NULL && dir->i_op->create != NULL); - - osd_fid_build_name(lu_object_fid(&obj->oo_dt.do_lu), info->oti_name); - info->oti_str.name = info->oti_name; - info->oti_str.len = strlen(info->oti_name); + LASSERT(dir->i_op != NULL); - dentry = d_alloc(osd->od_obj_area, &info->oti_str); - if (dentry != NULL) { - result = dir->i_op->mknod(dir, dentry, mode, attr->la_rdev); - if (result == 0) { - LASSERT(dentry->d_inode != NULL); - obj->oo_inode = dentry->d_inode; - igrab(obj->oo_inode); - } - dput(dentry); - } else - result = -ENOMEM; + result = osd_mkfile(info, obj, mode, th); + if (result == 0) { + LASSERT(obj->oo_inode != NULL); + init_special_inode(obj->oo_inode, mode, attr->la_rdev); + } LASSERT(osd_invariant(obj)); return result; } diff --git a/lustre/osd/osd_internal.h b/lustre/osd/osd_internal.h index ec53c65..5e6d9ab 100644 --- a/lustre/osd/osd_internal.h +++ b/lustre/osd/osd_internal.h @@ -57,10 +57,6 @@ struct osd_thread_info { struct osd_inode_id oti_id; struct iattr oti_iattr; /* - * XXX temporary: Buffer for fid->name conversion. - */ - char oti_name[32]; - /* * XXX temporary: for ->i_op calls. */ struct qstr oti_str; -- 1.8.3.1