Whamcloud - gitweb
LU-542 Fix mdt xattr handler logic error
[fs/lustre-release.git] / lustre / mdd / mdd_orphans.c
index c64327c..2902df5 100644 (file)
  * GPL HEADER END
  */
 /*
- * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright (c) 2011 Whamcloud, Inc.
+ *
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -86,8 +89,8 @@ static struct dt_key* orph_key_fill_18(const struct lu_env *env,
         int rc;
 
         LASSERT(key);
-        rc = snprintf(key, NAME_MAX + 1, ORPHAN_FILE_NAME_FORMAT_18, fid_seq(lf),
-                      fid_oid(lf));
+        rc = snprintf(key, NAME_MAX + 1, ORPHAN_FILE_NAME_FORMAT_18,
+                      (unsigned long long)fid_seq(lf), fid_oid(lf));
         if (rc > 0)
                 return (struct dt_key*) key;
         else
@@ -315,10 +318,19 @@ static int orphan_object_destroy(const struct lu_env *env,
 {
         struct thandle *th = NULL;
         struct mdd_device *mdd = mdo2mdd(&obj->mod_obj);
+        struct md_attr *ma = &mdd_env_info(env)->mti_ma;
         int rc = 0;
         ENTRY;
 
-        mdd_txn_param_build(env, mdd, MDD_TXN_UNLINK_OP);
+        /* init ma */
+        ma->ma_lmm_size = mdd_lov_mdsize(env, mdd);
+        ma->ma_lmm = mdd_max_lmm_get(env, mdd);
+        ma->ma_cookie_size = mdd_lov_cookiesize(env, mdd);
+        ma->ma_cookie = mdd_max_cookie_get(env, mdd);
+        ma->ma_need = MA_INODE | MA_LOV | MA_COOKIE;
+        ma->ma_valid = 0;
+
+        mdd_log_txn_param_build(env, &obj->mod_obj, ma, MDD_TXN_UNLINK_OP, 0);
         th = mdd_trans_start(env, mdd);
         if (IS_ERR(th)) {
                 CERROR("Cannot get thandle\n");
@@ -390,8 +402,8 @@ static int orph_index_iterate(const struct lu_env *env,
         /* In recovery phase, do not need for any lock here */
 
         iops = &dor->do_index_ops->dio_it;
-        it = iops->init(env, dor, BYPASS_CAPA);
-        if (it != NULL) {
+        it = iops->init(env, dor, LUDA_64BITHASH, BYPASS_CAPA);
+        if (!IS_ERR(it)) {
                 result = iops->load(env, it, 0);
                 if (result > 0) {
                         /* main cycle */
@@ -443,8 +455,8 @@ next:
                 iops->put(env, it);
                 iops->fini(env, it);
         } else {
-                CERROR("not enough memory for clean pending.\n");
-                result = -ENOMEM;
+                result = PTR_ERR(it);
+                CERROR("Cannot clean pending (%d).\n", result);
         }
 
         RETURN(result);