From da93b1d4d407450ac59ca4c847f068d3fa2fdc31 Mon Sep 17 00:00:00 2001 From: tappro Date: Thu, 2 Nov 2006 17:16:40 +0000 Subject: [PATCH] - fix split issue with create file on wrong mds. Check for split is needed always in cml_create, even after cmm_split_try() - fix issue with cross-ref link to existent name, in that case the extra ref occur on inode. Additional lookup() in cmr_link() prevents such situation. --- lustre/cmm/cmm_object.c | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/lustre/cmm/cmm_object.c b/lustre/cmm/cmm_object.c index 2423503..29b7966 100644 --- a/lustre/cmm/cmm_object.c +++ b/lustre/cmm/cmm_object.c @@ -417,21 +417,15 @@ static int cml_create(const struct lu_env *env, */ RETURN(rc); } - - /* - * Proceed with mdo_create() as nothing happened, split is not - * yet expected. - */ - } else { - /* - * Check for possible split directory and let caller know that - * it should tell client that directory is split and operation - * should repeat to correct MDT. - */ - rc = cmm_split_check(env, mo_p, child_name); - if (rc) - RETURN(rc); } + /* + * Check for possible split directory and let caller know that + * it should tell client that directory is split and operation + * should repeat to correct MDT. + */ + rc = cmm_split_check(env, mo_p, child_name); + if (rc) + RETURN(rc); #endif rc = mdo_create(env, md_object_next(mo_p), child_name, @@ -883,14 +877,18 @@ static int cmr_link(const struct lu_env *env, struct md_object *mo_p, int rc; ENTRY; - //XXX: make sure that MDT checks name isn't exist - - rc = mo_ref_add(env, md_object_next(mo_s)); - if (rc == 0) { - rc = mdo_name_insert(env, md_object_next(mo_p), - name, lu_object_fid(&mo_s->mo_lu), 0); + /* make sure that name isn't exist before doing remote call */ + rc = mdo_lookup(env, md_object_next(mo_p), name, + lu_object_fid(&mo_s->mo_lu)); + if (rc == 0) + rc = -EEXIST; + else if (rc == -ENOENT) { + rc = mo_ref_add(env, md_object_next(mo_s)); + if (rc == 0) { + rc = mdo_name_insert(env, md_object_next(mo_p), name, + lu_object_fid(&mo_s->mo_lu), 0); + } } - RETURN(rc); } @@ -903,8 +901,8 @@ static int cmr_unlink(const struct lu_env *env, struct md_object *mo_p, rc = mo_ref_del(env, md_object_next(mo_c), ma); if (rc == 0) { - rc = mdo_name_remove(env, md_object_next(mo_p), - name, S_ISDIR(ma->ma_attr.la_mode)); + rc = mdo_name_remove(env, md_object_next(mo_p), name, + S_ISDIR(ma->ma_attr.la_mode)); } RETURN(rc); -- 1.8.3.1