Whamcloud - gitweb
- avoid assert case in mdd_unlink() while building the transaction parameters.
authortappro <tappro>
Fri, 10 Nov 2006 20:10:59 +0000 (20:10 +0000)
committertappro <tappro>
Fri, 10 Nov 2006 20:10:59 +0000 (20:10 +0000)
  The issue is sanity check was done too late.

lustre/mdd/mdd_dir.c
lustre/mdd/mdd_object.c

index 8aa57ae..b42c8a7 100644 (file)
@@ -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.
index ad94a3b..df9f9b7 100644 (file)
@@ -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);