Whamcloud - gitweb
b=24171 check the init() iterator results properly
authorMikhail Pershin <mikhail.pershin@oracle.com>
Wed, 15 Dec 2010 14:50:39 +0000 (17:50 +0300)
committerVitaly Fertman <vitaly.fertman@oracle.com>
Fri, 17 Dec 2010 01:18:45 +0000 (04:18 +0300)
i=vitaly
i=bzzz

lustre/mdd/mdd_dir.c
lustre/mdd/mdd_orphans.c

index ba0ab43..61a4b4b 100644 (file)
@@ -251,7 +251,7 @@ static int mdd_dir_is_empty(const struct lu_env *env,
 
         iops = &obj->do_index_ops->dio_it;
         it = iops->init(env, obj, BYPASS_CAPA);
 
         iops = &obj->do_index_ops->dio_it;
         it = iops->init(env, obj, BYPASS_CAPA);
-        if (it != NULL) {
+        if (!IS_ERR(it)) {
                 result = iops->get(env, it, (const void *)"");
                 if (result > 0) {
                         int i;
                 result = iops->get(env, it, (const void *)"");
                 if (result > 0) {
                         int i;
@@ -270,7 +270,7 @@ static int mdd_dir_is_empty(const struct lu_env *env,
                 iops->put(env, it);
                 iops->fini(env, it);
         } else
                 iops->put(env, it);
                 iops->fini(env, it);
         } else
-                result = -ENOMEM;
+                result = PTR_ERR(it);
         RETURN(result);
 }
 
         RETURN(result);
 }
 
index 12953a2..6c29665 100644 (file)
@@ -391,7 +391,7 @@ static int orph_index_iterate(const struct lu_env *env,
 
         iops = &dor->do_index_ops->dio_it;
         it = iops->init(env, dor, BYPASS_CAPA);
 
         iops = &dor->do_index_ops->dio_it;
         it = iops->init(env, dor, BYPASS_CAPA);
-        if (it != NULL) {
+        if (!IS_ERR(it)) {
                 result = iops->load(env, it, 0);
                 if (result > 0) {
                         /* main cycle */
                 result = iops->load(env, it, 0);
                 if (result > 0) {
                         /* main cycle */
@@ -443,8 +443,8 @@ next:
                 iops->put(env, it);
                 iops->fini(env, it);
         } else {
                 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);
         }
 
         RETURN(result);