From 2fa408e59aa7636c61ef6a262ea5b40add67eef5 Mon Sep 17 00:00:00 2001 From: tappro Date: Fri, 10 Nov 2006 20:10:59 +0000 Subject: [PATCH] - avoid assert case in mdd_unlink() while building the transaction parameters. The issue is sanity check was done too late. --- lustre/mdd/mdd_dir.c | 10 +++++++++- lustre/mdd/mdd_object.c | 8 ++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lustre/mdd/mdd_dir.c b/lustre/mdd/mdd_dir.c index 8aa57ae..b42c8a7 100644 --- a/lustre/mdd/mdd_dir.c +++ b/lustre/mdd/mdd_dir.c @@ -544,6 +544,14 @@ static int mdd_unlink(const struct lu_env *env, struct md_object *pobj, int rc, is_dir; ENTRY; + /* + * Check -ENOENT early here because we need to get object type + * to calculate credits before transaction start + */ + if (!lu_object_exists(&cobj->mo_lu)) + RETURN(-ENOENT); + LASSERT(lu_object_exists(&cobj->mo_lu) > 0); + rc = mdd_log_txn_param_build(env, cobj, ma, MDD_TXN_UNLINK_OP); if (rc) RETURN(rc); @@ -1100,7 +1108,7 @@ static int mdd_create(const struct lu_env *env, rc = mdd_create_sanity_check(env, pobj, name, ma, spec->sp_cr_lookup); if (rc) RETURN(rc); - + /* * No RPC inside the transaction, so OST objects should be created at * first. diff --git a/lustre/mdd/mdd_object.c b/lustre/mdd/mdd_object.c index ad94a3b..df9f9b7 100644 --- a/lustre/mdd/mdd_object.c +++ b/lustre/mdd/mdd_object.c @@ -917,6 +917,14 @@ static int mdd_ref_del(const struct lu_env *env, struct md_object *obj, int rc; ENTRY; + /* + * Check -ENOENT early here because we need to get object type + * to calculate credits before transaction start + */ + if (!lu_object_exists(&obj->mo_lu)) + RETURN(-ENOENT); + LASSERT(lu_object_exists(&obj->mo_lu) > 0); + rc = mdd_log_txn_param_build(env, obj, ma, MDD_TXN_UNLINK_OP); if (rc) RETURN(rc); -- 1.8.3.1