Whamcloud - gitweb
LU-7988 hsm: update many cookie status at once
[fs/lustre-release.git] / lustre / osd-ldiskfs / osd_iam.c
index 203e1e7..dd671d1 100644 (file)
  * in the LICENSE file that accompanied this code).
  *
  * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see [sun.com URL with a
- * copy of GPLv2].
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * version 2 along with this program; If not, see
+ * http://www.gnu.org/licenses/gpl-2.0.html
  *
  * GPL HEADER END
  */
@@ -27,7 +23,7 @@
  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2012, Intel Corporation.
+ * Copyright (c) 2011, 2016, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
 #include <linux/string.h>
 #include <linux/quotaops.h>
 #include <linux/buffer_head.h>
+
+#include <ldiskfs/ldiskfs.h>
+#include <ldiskfs/xattr.h>
+#undef ENTRY
+
 #include "osd_internal.h"
 
-#include "xattr.h"
-#include "acl.h"
+#include <ldiskfs/acl.h>
 
 /*
  * List of all registered formats.
  *
  * No locking. Callers synchronize.
  */
-static CFS_LIST_HEAD(iam_formats);
+static struct list_head iam_formats = LIST_HEAD_INIT(iam_formats);
 
 void iam_format_register(struct iam_format *fmt)
 {
-        cfs_list_add(&fmt->if_linkage, &iam_formats);
+       list_add(&fmt->if_linkage, &iam_formats);
 }
-EXPORT_SYMBOL(iam_format_register);
 
 static struct buffer_head *
 iam_load_idle_blocks(struct iam_container *c, iam_ptr_t blk)
@@ -171,26 +170,26 @@ iam_load_idle_blocks(struct iam_container *c, iam_ptr_t blk)
        struct inode *inode = c->ic_object;
        struct iam_idle_head *head;
        struct buffer_head *bh;
-       int err;
 
-       LASSERT(down_trylock(&c->ic_idle_sem) != 0);
+       LASSERT(mutex_is_locked(&c->ic_idle_mutex));
 
        if (blk == 0)
                return NULL;
 
-       bh = ldiskfs_bread(NULL, inode, blk, 0, &err);
-       if (bh == NULL) {
-               CERROR("%.16s: cannot load idle blocks, blk = %u, err = %d\n",
-                      LDISKFS_SB(inode->i_sb)->s_es->s_volume_name, blk, err);
+       bh = __ldiskfs_bread(NULL, inode, blk, 0);
+       if (IS_ERR_OR_NULL(bh)) {
+               CERROR("%s: cannot load idle blocks, blk = %u, err = %ld\n",
+                      osd_ino2name(inode), blk, bh ? PTR_ERR(bh) : -EIO);
                c->ic_idle_failed = 1;
-               return ERR_PTR(err);
+               if (bh == NULL)
+                       bh = ERR_PTR(-EIO);
+               return bh;
        }
 
        head = (struct iam_idle_head *)(bh->b_data);
        if (le16_to_cpu(head->iih_magic) != IAM_IDLE_HEADER_MAGIC) {
-               CERROR("%.16s: invalid idle block head, blk = %u, magic = %d\n",
-                      LDISKFS_SB(inode->i_sb)->s_es->s_volume_name, blk,
-                      le16_to_cpu(head->iih_magic));
+               CERROR("%s: invalid idle block head, blk = %u, magic = %d\n",
+                      osd_ino2name(inode), blk, le16_to_cpu(head->iih_magic));
                brelse(bh);
                c->ic_idle_failed = 1;
                return ERR_PTR(-EBADF);
@@ -222,7 +221,7 @@ static int iam_format_guess(struct iam_container *c)
         }
 
         result = -ENOENT;
-        cfs_list_for_each_entry(fmt, &iam_formats, if_linkage) {
+       list_for_each_entry(fmt, &iam_formats, if_linkage) {
                 result = fmt->if_guess(c);
                 if (result == 0)
                         break;
@@ -237,13 +236,13 @@ static int iam_format_guess(struct iam_container *c)
                idle_blocks = (__u32 *)(c->ic_root_bh->b_data +
                                        c->ic_descr->id_root_gap +
                                        sizeof(struct dx_countlimit));
-               down(&c->ic_idle_sem);
+               mutex_lock(&c->ic_idle_mutex);
                bh = iam_load_idle_blocks(c, le32_to_cpu(*idle_blocks));
                if (bh != NULL && IS_ERR(bh))
                        result = PTR_ERR(bh);
                else
                        c->ic_idle_bh = bh;
-               up(&c->ic_idle_sem);
+               mutex_unlock(&c->ic_idle_mutex);
        }
 
        return result;
@@ -260,10 +259,9 @@ int iam_container_init(struct iam_container *c,
        c->ic_object = inode;
        init_rwsem(&c->ic_sem);
        dynlock_init(&c->ic_tree_lock);
-       sema_init(&c->ic_idle_sem, 1);
+       mutex_init(&c->ic_idle_mutex);
        return 0;
 }
-EXPORT_SYMBOL(iam_container_init);
 
 /*
  * Determine container format.
@@ -272,7 +270,6 @@ int iam_container_setup(struct iam_container *c)
 {
         return iam_format_guess(c);
 }
-EXPORT_SYMBOL(iam_container_setup);
 
 /*
  * Finalize container @c, release all resources.
@@ -284,7 +281,6 @@ void iam_container_fini(struct iam_container *c)
        brelse(c->ic_root_bh);
        c->ic_root_bh = NULL;
 }
-EXPORT_SYMBOL(iam_container_fini);
 
 void iam_path_init(struct iam_path *path, struct iam_container *c,
                    struct iam_path_descr *pd)
@@ -350,18 +346,14 @@ struct iam_path_descr *iam_ipd_alloc(void *area, int keysize)
                 ipd->ipd_key_scratch[i] = karea;
         return ipd;
 }
-EXPORT_SYMBOL(iam_ipd_alloc);
 
 void iam_ipd_free(struct iam_path_descr *ipd)
 {
 }
-EXPORT_SYMBOL(iam_ipd_free);
 
 int iam_node_read(struct iam_container *c, iam_ptr_t ptr,
                   handle_t *h, struct buffer_head **bh)
 {
-        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.
@@ -374,10 +366,14 @@ int iam_node_read(struct iam_container *c, iam_ptr_t ptr,
                 return 0;
         }
 
-        *bh = ldiskfs_bread(h, c->ic_object, (int)ptr, 0, &result);
-        if (*bh == NULL)
-                result = -EIO;
-        return result;
+       *bh = __ldiskfs_bread(h, c->ic_object, (int)ptr, 0);
+       if (IS_ERR(*bh))
+               return PTR_ERR(*bh);
+
+       if (*bh == NULL)
+               return -EIO;
+
+       return 0;
 }
 
 /*
@@ -425,32 +421,31 @@ static int iam_leaf_keyeq(const struct iam_leaf *leaf,
 }
 
 #if LDISKFS_INVARIANT_ON
-static int iam_leaf_check(struct iam_leaf *leaf);
 extern int dx_node_check(struct iam_path *p, struct iam_frame *f);
 
 static int iam_path_check(struct iam_path *p)
 {
-        int i;
-        int result;
-        struct iam_frame *f;
-        struct iam_descr *param;
+       int i;
+       int result;
+       struct iam_frame *f;
+       struct iam_descr *param;
+
+       result = 1;
+       param = iam_path_descr(p);
+       for (i = 0; result && i < ARRAY_SIZE(p->ip_frames); ++i) {
+               f = &p->ip_frames[i];
+               if (f->bh != NULL) {
+                       result = dx_node_check(p, f);
+                       if (result)
+                               result = !param->id_ops->id_node_check(p, f);
+               }
+       }
+       if (result && p->ip_leaf.il_bh != NULL)
+               result = 1;
+       if (result == 0)
+               ldiskfs_std_error(iam_path_obj(p)->i_sb, result);
 
-        result = 1;
-        param = iam_path_descr(p);
-        for (i = 0; result && i < ARRAY_SIZE(p->ip_frames); ++i) {
-                f = &p->ip_frames[i];
-                if (f->bh != NULL) {
-                        result = dx_node_check(p, f);
-                        if (result)
-                                result = !param->id_ops->id_node_check(p, f);
-                }
-        }
-        if (result && p->ip_leaf.il_bh != NULL)
-                result = iam_leaf_check(&p->ip_leaf);
-        if (result == 0) {
-                ldiskfs_std_error(iam_path_obj(p)->i_sb, result);
-        }
-        return result;
+       return result;
 }
 #endif
 
@@ -480,7 +475,6 @@ static int iam_leaf_load(struct iam_path *path)
                leaf->il_bh = bh;
                leaf->il_curidx = block;
                err = iam_leaf_ops(leaf)->init(leaf);
-               assert_inv(ergo(err == 0, iam_leaf_check(leaf)));
        }
        return err;
 }
@@ -507,7 +501,6 @@ static void iam_leaf_fini(struct iam_leaf *leaf)
 {
         if (leaf->il_path != NULL) {
                 iam_leaf_unlock(leaf);
-                assert_inv(ergo(leaf->il_bh != NULL, iam_leaf_check(leaf)));
                 iam_leaf_ops(leaf)->fini(leaf);
                 if (leaf->il_bh) {
                         brelse(leaf->il_bh);
@@ -543,7 +536,8 @@ int iam_leaf_at_end(const struct iam_leaf *leaf)
         return iam_leaf_ops(leaf)->at_end(leaf);
 }
 
-void iam_leaf_split(struct iam_leaf *l, struct buffer_head **bh, iam_ptr_t nr)
+static void iam_leaf_split(struct iam_leaf *l, struct buffer_head **bh,
+                          iam_ptr_t nr)
 {
         iam_leaf_ops(l)->split(l, bh, nr);
 }
@@ -559,52 +553,12 @@ int iam_leaf_can_add(const struct iam_leaf *l,
         return iam_leaf_ops(l)->can_add(l, k, r);
 }
 
-#if LDISKFS_INVARIANT_ON
-static int iam_leaf_check(struct iam_leaf *leaf)
-{
-        return 1;
-#if 0
-        struct iam_lentry    *orig;
-        struct iam_path      *path;
-        struct iam_container *bag;
-        struct iam_ikey       *k0;
-        struct iam_ikey       *k1;
-        int result;
-        int first;
-
-        orig = leaf->il_at;
-        path = iam_leaf_path(leaf);
-        bag  = iam_leaf_container(leaf);
-
-        result = iam_leaf_ops(leaf)->init(leaf);
-        if (result != 0)
-                return result;
-
-        first = 1;
-        iam_leaf_start(leaf);
-        k0 = iam_path_ikey(path, 0);
-        k1 = iam_path_ikey(path, 1);
-        while (!iam_leaf_at_end(leaf)) {
-                iam_ikeycpy(bag, k0, k1);
-                iam_ikeycpy(bag, k1, iam_leaf_ikey(leaf, k1));
-                if (!first && iam_ikeycmp(bag, k0, k1) > 0) {
-                        return 0;
-                }
-                first = 0;
-                iam_leaf_next(leaf);
-        }
-        leaf->il_at = orig;
-        return 1;
-#endif
-}
-#endif
-
 static int iam_txn_dirty(handle_t *handle,
                          struct iam_path *path, struct buffer_head *bh)
 {
         int result;
 
-        result = ldiskfs_journal_dirty_metadata(handle, bh);
+       result = ldiskfs_handle_dirty_metadata(handle, NULL, bh);
         if (result != 0)
                 ldiskfs_std_error(iam_path_obj(path)->i_sb, result);
         return result;
@@ -724,7 +678,6 @@ int  iam_it_init(struct iam_iterator *it, struct iam_container *c, __u32 flags,
         iam_path_init(&it->ii_path, c, pd);
         return 0;
 }
-EXPORT_SYMBOL(iam_it_init);
 
 /*
  * Finalize iterator and release all resources.
@@ -736,7 +689,6 @@ void iam_it_fini(struct iam_iterator *it)
         assert_corr(it_state(it) == IAM_IT_DETACHED);
         iam_path_fini(&it->ii_path);
 }
-EXPORT_SYMBOL(iam_it_fini);
 
 /*
  * this locking primitives are used to protect parts
@@ -749,7 +701,7 @@ static struct dynlock_handle *iam_lock_htree(struct iam_container *ic,
        return dynlock_lock(&ic->ic_tree_lock, value, lt, GFP_NOFS);
 }
 
-int iam_index_lock(struct iam_path *path, struct dynlock_handle **lh)
+static int iam_index_lock(struct iam_path *path, struct dynlock_handle **lh)
 {
         struct iam_frame *f;
 
@@ -809,8 +761,8 @@ int dx_index_is_compat(struct iam_path *path)
  *
  */
 
-struct iam_entry *iam_find_position(struct iam_path *path,
-                                   struct iam_frame *frame)
+static struct iam_entry *iam_find_position(struct iam_path *path,
+                                          struct iam_frame *frame)
 {
         int count;
         struct iam_entry *p;
@@ -1036,8 +988,8 @@ static int iam_check_full_path(struct iam_path *path, int search)
  * Performs path lookup and returns with found leaf (if any) locked by htree
  * lock.
  */
-int iam_lookup_lock(struct iam_path *path,
-                   struct dynlock_handle **dl, enum dynlock_type lt)
+static int iam_lookup_lock(struct iam_path *path,
+                          struct dynlock_handle **dl, enum dynlock_type lt)
 {
         int result;
 
@@ -1069,18 +1021,15 @@ int iam_lookup_lock(struct iam_path *path,
  */
 static int iam_path_lookup(struct iam_path *path, int index)
 {
-        struct iam_container *c;
         struct iam_leaf  *leaf;
         int result;
 
-        c = path->ip_container;
         leaf = &path->ip_leaf;
         result = iam_lookup_lock(path, &leaf->il_lock, DLT_WRITE);
         assert_inv(iam_path_check(path));
         do_corr(schedule());
         if (result == 0) {
                 result = iam_leaf_load(path);
-                assert_inv(ergo(result == 0, iam_leaf_check(leaf)));
                 if (result == 0) {
                         do_corr(schedule());
                         if (index)
@@ -1195,7 +1144,6 @@ int iam_it_get(struct iam_iterator *it, const struct iam_key *k)
                          it_keycmp(it, k) <= 0));
         return result;
 }
-EXPORT_SYMBOL(iam_it_get);
 
 /*
  * Attach iterator by index key.
@@ -1234,7 +1182,6 @@ int iam_it_get_at(struct iam_iterator *it, const struct iam_key *k)
         assert_corr(ergo(result >= 0, it_state(it) == IAM_IT_ATTACHED));
         return result;
 }
-EXPORT_SYMBOL(iam_it_get_at);
 
 /*
  * Duplicates iterator.
@@ -1275,7 +1222,6 @@ void iam_it_put(struct iam_iterator *it)
                 iam_leaf_fini(&it->ii_path.ip_leaf);
         }
 }
-EXPORT_SYMBOL(iam_it_put);
 
 static struct iam_ikey *iam_it_ikey_get(const struct iam_iterator *it,
                                         struct iam_ikey *ikey);
@@ -1411,15 +1357,13 @@ static void iam_unlock_array(struct iam_container *ic,
 int iam_index_next(struct iam_container *c, struct iam_path *path)
 {
         iam_ptr_t cursor;
-        struct dynlock_handle *lh[DX_MAX_TREE_HEIGHT] = { 0, };
+       struct dynlock_handle *lh[DX_MAX_TREE_HEIGHT] = { NULL, };
         int result;
-        struct inode *object;
 
         /*
          * Locking for iam_index_next()... is to be described.
          */
 
-        object = c->ic_object;
         cursor = path->ip_frame->leaf;
 
         while (1) {
@@ -1553,7 +1497,6 @@ int iam_it_next(struct iam_iterator *it)
                          it_ikeycmp(it, ik_orig) >= 0));
         return result;
 }
-EXPORT_SYMBOL(iam_it_next);
 
 /*
  * Return pointer to the record under iterator.
@@ -1567,7 +1510,6 @@ struct iam_rec *iam_it_rec_get(const struct iam_iterator *it)
         assert_corr(it_at_rec(it));
         return iam_leaf_rec(&it->ii_path.ip_leaf);
 }
-EXPORT_SYMBOL(iam_it_rec_get);
 
 static void iam_it_reccpy(struct iam_iterator *it, const struct iam_rec *r)
 {
@@ -1605,7 +1547,6 @@ int iam_it_rec_set(handle_t *h,
         }
         return result;
 }
-EXPORT_SYMBOL(iam_it_rec_set);
 
 /*
  * Return pointer to the index key under iterator.
@@ -1635,7 +1576,6 @@ struct iam_key *iam_it_key_get(const struct iam_iterator *it)
         assert_corr(it_at_rec(it));
         return iam_leaf_key(&it->ii_path.ip_leaf);
 }
-EXPORT_SYMBOL(iam_it_key_get);
 
 /*
  * Return size of key under iterator (in bytes)
@@ -1650,9 +1590,8 @@ int iam_it_key_size(const struct iam_iterator *it)
         assert_corr(it_at_rec(it));
         return iam_leaf_key_size(&it->ii_path.ip_leaf);
 }
-EXPORT_SYMBOL(iam_it_key_size);
 
-struct buffer_head *
+static struct buffer_head *
 iam_new_node(handle_t *h, struct iam_container *c, iam_ptr_t *b, int *e)
 {
        struct inode *inode = c->ic_object;
@@ -1665,9 +1604,9 @@ iam_new_node(handle_t *h, struct iam_container *c, iam_ptr_t *b, int *e)
        if (c->ic_idle_bh == NULL)
                goto newblock;
 
-       down(&c->ic_idle_sem);
+       mutex_lock(&c->ic_idle_mutex);
        if (unlikely(c->ic_idle_bh == NULL)) {
-               up(&c->ic_idle_sem);
+               mutex_unlock(&c->ic_idle_mutex);
                goto newblock;
        }
 
@@ -1681,14 +1620,19 @@ iam_new_node(handle_t *h, struct iam_container *c, iam_ptr_t *b, int *e)
                --count;
                *b = le32_to_cpu(head->iih_blks[count]);
                head->iih_count = cpu_to_le16(count);
-               *e = ldiskfs_journal_dirty_metadata(h, c->ic_idle_bh);
+               *e = ldiskfs_handle_dirty_metadata(h, inode, c->ic_idle_bh);
                if (*e != 0)
                        goto fail;
 
-               up(&c->ic_idle_sem);
-               bh = ldiskfs_bread(NULL, inode, *b, 0, e);
-               if (bh == NULL)
+               mutex_unlock(&c->ic_idle_mutex);
+               bh = __ldiskfs_bread(NULL, inode, *b, 0);
+               if (IS_ERR_OR_NULL(bh)) {
+                       if (IS_ERR(bh))
+                               *e = PTR_ERR(bh);
+                       else
+                               *e = -EIO;
                        return NULL;
+               }
                goto got;
        }
 
@@ -1705,7 +1649,7 @@ iam_new_node(handle_t *h, struct iam_container *c, iam_ptr_t *b, int *e)
        iam_lock_bh(c->ic_root_bh);
        *idle_blocks = head->iih_next;
        iam_unlock_bh(c->ic_root_bh);
-       *e = ldiskfs_journal_dirty_metadata(h, c->ic_root_bh);
+       *e = ldiskfs_handle_dirty_metadata(h, inode, c->ic_root_bh);
        if (*e != 0) {
                iam_lock_bh(c->ic_root_bh);
                *idle_blocks = cpu_to_le32(*b);
@@ -1723,7 +1667,7 @@ iam_new_node(handle_t *h, struct iam_container *c, iam_ptr_t *b, int *e)
        }
 
        c->ic_idle_bh = idle;
-       up(&c->ic_idle_sem);
+       mutex_unlock(&c->ic_idle_mutex);
 
 got:
        /* get write access for the found buffer head */
@@ -1740,11 +1684,16 @@ got:
        return bh;
 
 newblock:
-       bh = ldiskfs_append(h, inode, b, e);
+       bh = osd_ldiskfs_append(h, inode, b);
+       if (IS_ERR(bh)) {
+               *e = PTR_ERR(bh);
+               bh = NULL;
+       }
+
        return bh;
 
 fail:
-       up(&c->ic_idle_sem);
+       mutex_unlock(&c->ic_idle_mutex);
        ldiskfs_std_error(inode->i_sb, *e);
        return NULL;
 }
@@ -1785,8 +1734,6 @@ static int iam_new_leaf(handle_t *handle, struct iam_leaf *leaf)
         struct inode         *obj;
         struct iam_path      *path;
 
-        assert_inv(iam_leaf_check(leaf));
-
         c = iam_leaf_container(leaf);
         path = leaf->il_path;
 
@@ -1814,15 +1761,13 @@ static int iam_new_leaf(handle_t *handle, struct iam_leaf *leaf)
                                iam_unlock_htree(path->ip_container, lh);
                         do_corr(schedule());
                         err = iam_txn_dirty(handle, path, new_leaf);
-                        brelse(new_leaf);
                         if (err == 0)
                                 err = ldiskfs_mark_inode_dirty(handle, obj);
                         do_corr(schedule());
                 } else
                         err = -ENOMEM;
+               brelse(new_leaf);
         }
-        assert_inv(iam_leaf_check(leaf));
-        assert_inv(iam_leaf_check(&iam_leaf_path(leaf)->ip_leaf));
         assert_inv(iam_path_check(iam_leaf_path(leaf)));
         return err;
 }
@@ -1892,8 +1837,8 @@ int split_index_node(handle_t *handle, struct iam_path *path,
 
         struct iam_entry *entries;   /* old block contents */
         struct iam_entry *entries2;  /* new block contents */
-         struct iam_frame *frame, *safe;
-        struct buffer_head *bh_new[DX_MAX_TREE_HEIGHT] = {0};
+       struct iam_frame *frame, *safe;
+       struct buffer_head *bh_new[DX_MAX_TREE_HEIGHT] = {NULL};
         u32 newblock[DX_MAX_TREE_HEIGHT] = {0};
         struct dynlock_handle *lock[DX_MAX_TREE_HEIGHT] = {NULL,};
         struct dynlock_handle *new_lock[DX_MAX_TREE_HEIGHT] = {NULL,};
@@ -2067,7 +2012,7 @@ int split_index_node(handle_t *handle, struct iam_path *path,
                         ++ frame;
                         assert_inv(dx_node_check(path, frame));
                         bh_new[0] = NULL; /* buffer head is "consumed" */
-                        err = ldiskfs_journal_dirty_metadata(handle, bh2);
+                       err = ldiskfs_handle_dirty_metadata(handle, NULL, bh2);
                         if (err)
                                 goto journal_error;
                         do_corr(schedule());
@@ -2099,16 +2044,17 @@ int split_index_node(handle_t *handle, struct iam_path *path,
                         dxtrace(dx_show_index ("node", frame->entries));
                         dxtrace(dx_show_index ("node",
                                ((struct dx_node *) bh2->b_data)->entries));
-                        err = ldiskfs_journal_dirty_metadata(handle, bh2);
+                       err = ldiskfs_handle_dirty_metadata(handle, NULL, bh2);
                         if (err)
                                 goto journal_error;
                         do_corr(schedule());
-                        err = ldiskfs_journal_dirty_metadata(handle, parent->bh);
+                       err = ldiskfs_handle_dirty_metadata(handle, NULL,
+                                                           parent->bh);
                         if (err)
                                 goto journal_error;
                 }
                 do_corr(schedule());
-                err = ldiskfs_journal_dirty_metadata(handle, bh);
+               err = ldiskfs_handle_dirty_metadata(handle, NULL, bh);
                 if (err)
                         goto journal_error;
         }
@@ -2155,7 +2101,6 @@ static int iam_add_rec(handle_t *handle, struct iam_iterator *it,
         struct iam_leaf *leaf;
 
         leaf = &path->ip_leaf;
-        assert_inv(iam_leaf_check(leaf));
         assert_inv(iam_path_check(path));
         err = iam_txn_add(handle, path, leaf->il_bh);
         if (err == 0) {
@@ -2198,8 +2143,6 @@ static int iam_add_rec(handle_t *handle, struct iam_iterator *it,
                         err = iam_txn_dirty(handle, path, leaf->il_bh);
                 }
         }
-        assert_inv(iam_leaf_check(leaf));
-        assert_inv(iam_leaf_check(&path->ip_leaf));
         assert_inv(iam_path_check(path));
         return err;
 }
@@ -2241,7 +2184,6 @@ int iam_it_rec_insert(handle_t *h, struct iam_iterator *it,
                          it_keycmp(it, k) == 0));
         return result;
 }
-EXPORT_SYMBOL(iam_it_rec_insert);
 
 static inline int iam_idle_blocks_limit(struct inode *inode)
 {
@@ -2275,8 +2217,8 @@ static iam_ptr_t iam_index_shrink(handle_t *h, struct iam_path *p,
 
        lh = iam_lock_htree(c, frame->curidx, DLT_WRITE);
        if (lh == NULL) {
-               CWARN("%.16s: No memory to recycle idle blocks\n",
-                     LDISKFS_SB(inode->i_sb)->s_es->s_volume_name);
+               CWARN("%s: No memory to recycle idle blocks\n",
+                     osd_ino2name(inode));
                return 0;
        }
 
@@ -2382,7 +2324,7 @@ static void iam_recycle_leaf(handle_t *h, struct iam_path *p,
        int count;
        int rc;
 
-       down(&c->ic_idle_sem);
+       mutex_lock(&c->ic_idle_mutex);
        if (unlikely(c->ic_idle_failed)) {
                rc = -EFAULT;
                goto unlock;
@@ -2415,10 +2357,10 @@ static void iam_recycle_leaf(handle_t *h, struct iam_path *p,
        rc = iam_txn_dirty(h, p, c->ic_idle_bh);
 
 unlock:
-       up(&c->ic_idle_sem);
+       mutex_unlock(&c->ic_idle_mutex);
        if (rc != 0)
-               CWARN("%.16s: idle blocks failed, will lose the blk %u\n",
-                     LDISKFS_SB(inode->i_sb)->s_es->s_volume_name, blk);
+               CWARN("%s: idle blocks failed, will lose the blk %u\n",
+                     osd_ino2name(inode), blk);
 }
 
 /*
@@ -2443,7 +2385,6 @@ int iam_it_rec_delete(handle_t *h, struct iam_iterator *it)
         path = &it->ii_path;
         leaf = &path->ip_leaf;
 
-        assert_inv(iam_leaf_check(leaf));
         assert_inv(iam_path_check(path));
 
         result = iam_txn_add(h, path, leaf->il_bh);
@@ -2470,13 +2411,11 @@ int iam_it_rec_delete(handle_t *h, struct iam_iterator *it)
                        }
                }
         }
-        assert_inv(iam_leaf_check(leaf));
         assert_inv(iam_path_check(path));
         assert_corr(it_state(it) == IAM_IT_ATTACHED ||
                     it_state(it) == IAM_IT_DETACHED);
         return result;
 }
-EXPORT_SYMBOL(iam_it_rec_delete);
 
 /*
  * Convert iterator to cookie.
@@ -2497,7 +2436,6 @@ iam_pos_t iam_it_store(const struct iam_iterator *it)
         result = 0;
         return *(iam_pos_t *)iam_it_ikey_get(it, (void *)&result);
 }
-EXPORT_SYMBOL(iam_it_store);
 
 /*
  * Restore iterator from cookie.
@@ -2514,7 +2452,6 @@ int iam_it_load(struct iam_iterator *it, iam_pos_t pos)
         assert_corr(iam_it_container(it)->ic_descr->id_ikey_size <= sizeof pos);
         return iam_it_iget(it, (struct iam_ikey *)&pos);
 }
-EXPORT_SYMBOL(iam_it_load);
 
 /***********************************************************************/
 /* invariants                                                          */
@@ -2525,7 +2462,7 @@ static inline int ptr_inside(void *base, size_t size, void *ptr)
         return (base <= ptr) && (ptr < base + size);
 }
 
-int iam_frame_invariant(struct iam_frame *f)
+static int iam_frame_invariant(struct iam_frame *f)
 {
         return
                 (f->bh != NULL &&
@@ -2534,7 +2471,8 @@ int iam_frame_invariant(struct iam_frame *f)
                 ptr_inside(f->bh->b_data, f->bh->b_size, f->at) &&
                 f->entries <= f->at);
 }
-int iam_leaf_invariant(struct iam_leaf *l)
+
+static int iam_leaf_invariant(struct iam_leaf *l)
 {
         return
                 l->il_bh != NULL &&
@@ -2544,7 +2482,7 @@ int iam_leaf_invariant(struct iam_leaf *l)
                 l->il_entries <= l->il_at;
 }
 
-int iam_path_invariant(struct iam_path *p)
+static int iam_path_invariant(struct iam_path *p)
 {
         int i;
 
@@ -2599,7 +2537,6 @@ int iam_lookup(struct iam_container *c, const struct iam_key *k,
         iam_it_fini(&it);
         return result;
 }
-EXPORT_SYMBOL(iam_lookup);
 
 /*
  * Insert new record @r with key @k into container @c (within context of
@@ -2628,7 +2565,6 @@ int iam_insert(handle_t *h, struct iam_container *c, const struct iam_key *k,
         iam_it_fini(&it);
         return result;
 }
-EXPORT_SYMBOL(iam_insert);
 
 /*
  * Update record with the key @k in container @c (within context of
@@ -2659,7 +2595,6 @@ int iam_update(handle_t *h, struct iam_container *c, const struct iam_key *k,
         iam_it_fini(&it);
         return result;
 }
-EXPORT_SYMBOL(iam_update);
 
 /*
  * Delete existing record with key @k.
@@ -2684,7 +2619,6 @@ int iam_delete(handle_t *h, struct iam_container *c, const struct iam_key *k,
         iam_it_fini(&it);
         return result;
 }
-EXPORT_SYMBOL(iam_delete);
 
 int iam_root_limit(int rootgap, int blocksize, int size)
 {