Whamcloud - gitweb
LU-911 osd: OI is implemented internally within OSD
[fs/lustre-release.git] / lustre / osd-ldiskfs / osd_iam.c
index d949fa5..6d98c83 100644 (file)
@@ -28,6 +28,8 @@
 /*
  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright (c) 2011, 2012, Whamcloud, Inc.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -190,6 +192,8 @@ EXPORT_SYMBOL(iam_container_setup);
  */
 void iam_container_fini(struct iam_container *c)
 {
+        brelse(c->ic_root_bh);
+        c->ic_root_bh = NULL;
 }
 EXPORT_SYMBOL(iam_container_fini);
 
@@ -268,6 +272,18 @@ int iam_node_read(struct iam_container *c, iam_ptr_t ptr,
 {
         int result = 0;
 
+        /* NB: it can be called by iam_lfix_guess() which is still at
+         * very early stage, c->ic_root_bh and c->ic_descr->id_ops
+         * haven't been intialized yet.
+         * Also, we don't have this for IAM dir.
+         */
+        if (c->ic_root_bh != NULL &&
+            c->ic_descr->id_ops->id_root_ptr(c) == ptr) {
+                get_bh(c->ic_root_bh);
+                *bh = c->ic_root_bh;
+                return 0;
+        }
+
         *bh = ldiskfs_bread(h, c->ic_object, (int)ptr, 0, &result);
         if (*bh == NULL)
                 result = -EIO;