* 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
*/
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2011, 2014, Intel Corporation.
+ * Copyright (c) 2011, 2016, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
struct inode *inode = c->ic_object;
struct iam_idle_head *head;
struct buffer_head *bh;
- int err;
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;
- return ERR_PTR(err);
+ if (bh == NULL)
+ bh = ERR_PTR(-EIO);
+ return bh;
}
head = (struct iam_idle_head *)(bh->b_data);
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.
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;
}
/*
}
#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
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;
}
{
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);
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)
{
*/
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)
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) {
goto fail;
mutex_unlock(&c->ic_idle_mutex);
- bh = ldiskfs_bread(NULL, inode, *b, 0, e);
- if (bh == NULL)
+ 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;
}
return bh;
newblock:
- bh = osd_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:
struct inode *obj;
struct iam_path *path;
- assert_inv(iam_leaf_check(leaf));
-
c = iam_leaf_container(leaf);
path = leaf->il_path;
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;
}
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) {
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;
}
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);
}
}
}
- 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);