Whamcloud - gitweb
LU-4423 lnet: use 64-bit time for selftest
[fs/lustre-release.git] / lustre / osd-ldiskfs / osd_iam.c
index 8e2e0c5..bf217eb 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, 2015, Intel Corporation.
+ * Copyright (c) 2011, 2016, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -174,20 +170,21 @@ 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 = 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("%.16s: cannot load idle blocks, blk = %u, err = %ld\n",
+                      LDISKFS_SB(inode->i_sb)->s_es->s_volume_name, blk,
+                      bh ? PTR_ERR(bh) : -EIO);
                c->ic_idle_failed = 1;
-               err = err ? err : -EIO;
-               return ERR_PTR(err);
+               if (bh == NULL)
+                       bh = ERR_PTR(-EIO);
+               return bh;
        }
 
        head = (struct iam_idle_head *)(bh->b_data);
@@ -359,8 +356,6 @@ void iam_ipd_free(struct iam_path_descr *ipd)
 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.
@@ -373,10 +368,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 = result ? 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;
 }
 
 /*
@@ -1024,11 +1023,9 @@ static 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));
@@ -1364,13 +1361,11 @@ int iam_index_next(struct iam_container *c, struct iam_path *path)
         iam_ptr_t cursor;
        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) {
@@ -1632,9 +1627,12 @@ iam_new_node(handle_t *h, struct iam_container *c, iam_ptr_t *b, int *e)
                        goto fail;
 
                mutex_unlock(&c->ic_idle_mutex);
-               bh = ldiskfs_bread(NULL, inode, *b, 0, e);
-               if (bh == NULL) {
-                       *e = *e ? *e : -EIO;
+               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;