Whamcloud - gitweb
LU-32 osd: keep root node BH ref of IAM container
[fs/lustre-release.git] / lustre / osd-ldiskfs / osd_iam.c
index ab036a2..98cde18 100644 (file)
@@ -26,7 +26,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  */
 /*
 #include "osd_internal.h"
 
 #include "xattr.h"
-#include "iopen.h"
 #include "acl.h"
 
 /*
@@ -191,6 +190,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);
 
@@ -269,6 +270,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;
@@ -1643,7 +1656,7 @@ static int iam_shift_entries(struct iam_path *path,
         count2 = count - count1;
         dx_get_ikey(path, iam_entry_shift(path, entries, count1), pivot);
 
-        dxtrace(printk("Split index %i/%i\n", count1, count2));
+        dxtrace(printk("Split index %d/%d\n", count1, count2));
 
         memcpy((char *) iam_entry_shift(path, entries2, delta),
                (char *) iam_entry_shift(path, entries, count1),