Skip to content

Commit 028ddca

Browse files
bluesheep1337axboe
authored andcommitted
bcache: Remove unnecessary NULL point check in node allocations
Due to the previous fix of __bch_btree_node_alloc, the return value will never be a NULL pointer. So IS_ERR is enough to handle the failure situation. Fix it by replacing IS_ERR_OR_NULL check by an IS_ERR check. Fixes: cafe563 ("bcache: A block layer cache") Cc: [email protected] Signed-off-by: Zheng Wang <[email protected]> Signed-off-by: Coly Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent ccb8c3b commit 028ddca

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

drivers/md/bcache/btree.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,7 @@ static struct btree *btree_node_alloc_replacement(struct btree *b,
11381138
{
11391139
struct btree *n = bch_btree_node_alloc(b->c, op, b->level, b->parent);
11401140

1141-
if (!IS_ERR_OR_NULL(n)) {
1141+
if (!IS_ERR(n)) {
11421142
mutex_lock(&n->write_lock);
11431143
bch_btree_sort_into(&b->keys, &n->keys, &b->c->sort);
11441144
bkey_copy_key(&n->key, &b->key);
@@ -1340,7 +1340,7 @@ static int btree_gc_coalesce(struct btree *b, struct btree_op *op,
13401340
memset(new_nodes, 0, sizeof(new_nodes));
13411341
closure_init_stack(&cl);
13421342

1343-
while (nodes < GC_MERGE_NODES && !IS_ERR_OR_NULL(r[nodes].b))
1343+
while (nodes < GC_MERGE_NODES && !IS_ERR(r[nodes].b))
13441344
keys += r[nodes++].keys;
13451345

13461346
blocks = btree_default_blocks(b->c) * 2 / 3;
@@ -1352,7 +1352,7 @@ static int btree_gc_coalesce(struct btree *b, struct btree_op *op,
13521352

13531353
for (i = 0; i < nodes; i++) {
13541354
new_nodes[i] = btree_node_alloc_replacement(r[i].b, NULL);
1355-
if (IS_ERR_OR_NULL(new_nodes[i]))
1355+
if (IS_ERR(new_nodes[i]))
13561356
goto out_nocoalesce;
13571357
}
13581358

@@ -1487,7 +1487,7 @@ static int btree_gc_coalesce(struct btree *b, struct btree_op *op,
14871487
bch_keylist_free(&keylist);
14881488

14891489
for (i = 0; i < nodes; i++)
1490-
if (!IS_ERR_OR_NULL(new_nodes[i])) {
1490+
if (!IS_ERR(new_nodes[i])) {
14911491
btree_node_free(new_nodes[i]);
14921492
rw_unlock(true, new_nodes[i]);
14931493
}
@@ -1669,7 +1669,7 @@ static int bch_btree_gc_root(struct btree *b, struct btree_op *op,
16691669
if (should_rewrite) {
16701670
n = btree_node_alloc_replacement(b, NULL);
16711671

1672-
if (!IS_ERR_OR_NULL(n)) {
1672+
if (!IS_ERR(n)) {
16731673
bch_btree_node_write_sync(n);
16741674

16751675
bch_btree_set_root(n);

drivers/md/bcache/super.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,7 +1723,7 @@ static void cache_set_flush(struct closure *cl)
17231723
if (!IS_ERR_OR_NULL(c->gc_thread))
17241724
kthread_stop(c->gc_thread);
17251725

1726-
if (!IS_ERR_OR_NULL(c->root))
1726+
if (!IS_ERR(c->root))
17271727
list_add(&c->root->list, &c->btree_cache);
17281728

17291729
/*
@@ -2087,7 +2087,7 @@ static int run_cache_set(struct cache_set *c)
20872087

20882088
err = "cannot allocate new btree root";
20892089
c->root = __bch_btree_node_alloc(c, NULL, 0, true, NULL);
2090-
if (IS_ERR_OR_NULL(c->root))
2090+
if (IS_ERR(c->root))
20912091
goto err;
20922092

20932093
mutex_lock(&c->root->write_lock);

0 commit comments

Comments
 (0)