Whamcloud - gitweb
LU-5519 lfsck: repair master LMV for striped directory
[fs/lustre-release.git] / lustre / osd-zfs / osd_index.c
index 2f420a9..fd6f2de 100644 (file)
@@ -169,11 +169,24 @@ static struct dt_it *osd_index_it_init(const struct lu_env *env,
        LASSERT(osd_object_is_zap(obj->oo_db));
        LASSERT(info);
 
-       it = &info->oti_it_zap;
+       if (info->oti_it_inline) {
+               OBD_ALLOC_PTR(it);
+               if (it == NULL)
+                       RETURN(ERR_PTR(-ENOMEM));
+       } else {
+               it = &info->oti_it_zap;
+               info->oti_it_inline = 1;
+       }
 
        rc = osd_obj_cursor_init(&it->ozi_zc, obj, 0);
-       if (rc != 0)
+       if (rc != 0) {
+               if (it != &info->oti_it_zap)
+                       OBD_FREE_PTR(it);
+               else
+                       info->oti_it_inline = 0;
+
                RETURN(ERR_PTR(rc));
+       }
 
        it->ozi_obj   = obj;
        it->ozi_capa  = capa;
@@ -185,8 +198,9 @@ static struct dt_it *osd_index_it_init(const struct lu_env *env,
 
 static void osd_index_it_fini(const struct lu_env *env, struct dt_it *di)
 {
-       struct osd_zap_it *it = (struct osd_zap_it *)di;
-       struct osd_object *obj;
+       struct osd_thread_info  *info   = osd_oti_get(env);
+       struct osd_zap_it       *it     = (struct osd_zap_it *)di;
+       struct osd_object       *obj;
        ENTRY;
 
        LASSERT(it);
@@ -196,6 +210,10 @@ static void osd_index_it_fini(const struct lu_env *env, struct dt_it *di)
 
        osd_zap_cursor_fini(it->ozi_zc);
        lu_object_put(env, &obj->oo_dt.do_lu);
+       if (it != &info->oti_it_zap)
+               OBD_FREE_PTR(it);
+       else
+               info->oti_it_inline = 0;
 
        EXIT;
 }