Whamcloud - gitweb
LU-598 open non-exist object should return ENOENT
[fs/lustre-release.git] / lustre / mdd / mdd_orphans.c
index 64294cf..8c9a994 100644 (file)
@@ -26,7 +26,7 @@
  * 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.
  */
 /*
@@ -70,7 +70,8 @@ static struct dt_key* orph_key_fill(const struct lu_env *env,
         int rc;
 
         LASSERT(key);
-        rc = snprintf(key, NAME_MAX + 1, ORPHAN_FILE_NAME_FORMAT, fid_seq(lf),
+        rc = snprintf(key, NAME_MAX + 1, ORPHAN_FILE_NAME_FORMAT,
+                      (long long unsigned int)fid_seq(lf),
                       fid_oid(lf), fid_ver(lf), op);
         if (rc > 0)
                 return (struct dt_key*) key;
@@ -85,8 +86,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
@@ -98,14 +99,15 @@ static int orphan_key_to_fid(char *key, struct lu_fid *lf)
         int rc = 0;
         unsigned int op;
 
-        rc = sscanf(key, ORPHAN_FILE_NAME_FORMAT, &lf->f_seq, &lf->f_oid,
+        rc = sscanf(key, ORPHAN_FILE_NAME_FORMAT,
+                    (long long unsigned int *)&lf->f_seq, &lf->f_oid,
                     &lf->f_ver, &op);
         if (rc == 4)
                 return 0;
 
         /* build igif */
         rc = sscanf(key, ORPHAN_FILE_NAME_FORMAT_18,
-                    &lf->f_seq, &lf->f_oid);
+                    (long long unsigned int *)&lf->f_seq, &lf->f_oid);
         if (rc == 2) {
                 lf->f_ver = 0;
                 return 0;
@@ -143,7 +145,7 @@ static inline int mdd_orphan_insert_obj(const struct lu_env *env,
         ENTRY;
 
         return  dor->do_index_ops->dio_insert(env, dor,
-                                              __mdd_fid_rec(env, lf),
+                                              (struct dt_rec *)lf,
                                               key, th,
                                               BYPASS_CAPA, 1);
 }
@@ -215,7 +217,7 @@ static int orph_index_insert(const struct lu_env *env,
                                        dotdot, th, BYPASS_CAPA);
 
         next->do_index_ops->dio_insert(env, next,
-                                       __mdd_fid_rec(env, lf_dor),
+                                       (struct dt_rec *) lf_dor,
                                        dotdot, th, BYPASS_CAPA, 1);
 
 out:
@@ -388,8 +390,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 */
@@ -441,8 +443,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);
@@ -501,7 +503,7 @@ int __mdd_orphan_cleanup(const struct lu_env *env, struct mdd_device *d)
  *  \pre obj nlink == 0 && obj->mod_count != 0
  *
  *  \retval 0  success
- *  \retva  -ve index operation error.
+ *  \retval  -ve index operation error.
  */
 
 int __mdd_orphan_add(const struct lu_env *env,
@@ -518,7 +520,7 @@ int __mdd_orphan_add(const struct lu_env *env,
  *  \pre obj->mod_count == 0 && ORPHAN_OBJ is set for obj.
  *
  *  \retval 0  success
- *  \retva  -ve index operation error.
+ *  \retval  -ve index operation error.
  */
 
 int __mdd_orphan_del(const struct lu_env *env,