1

bcachefs: bch2_trans_exit() no longer returns errors

Now that peek_node()/next_node() are converted to return errors
directly, we don't need bch2_trans_exit() to return errors - it's
cleaner this way and wasn't used much anymore.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
This commit is contained in:
Kent Overstreet 2021-10-19 15:08:00 -04:00 committed by Kent Overstreet
parent d355c6f4f7
commit 9a796fdb06
15 changed files with 31 additions and 29 deletions

View File

@ -1346,10 +1346,8 @@ retry_all:
} while (ret);
}
if (unlikely(ret == -EIO)) {
trans->error = true;
if (unlikely(ret == -EIO))
goto out;
}
BUG_ON(ret && ret != -EINTR);
@ -2781,7 +2779,7 @@ leaked:
#endif
}
int bch2_trans_exit(struct btree_trans *trans)
void bch2_trans_exit(struct btree_trans *trans)
__releases(&c->btree_trans_barrier)
{
struct btree_insert_entry *i;
@ -2831,8 +2829,6 @@ int bch2_trans_exit(struct btree_trans *trans)
trans->mem = (void *) 0x1;
trans->paths = (void *) 0x1;
return trans->error ? -EIO : 0;
}
static void __maybe_unused

View File

@ -351,7 +351,7 @@ static inline void set_btree_iter_dontneed(struct btree_iter *iter)
void *bch2_trans_kmalloc(struct btree_trans *, size_t);
void bch2_trans_begin(struct btree_trans *);
void bch2_trans_init(struct btree_trans *, struct bch_fs *, unsigned, size_t);
int bch2_trans_exit(struct btree_trans *);
void bch2_trans_exit(struct btree_trans *);
void bch2_btree_trans_to_text(struct printbuf *, struct bch_fs *);

View File

@ -377,7 +377,6 @@ struct btree_trans {
u8 nr_sorted;
u8 nr_updates;
bool used_mempool:1;
bool error:1;
bool in_traverse_all:1;
bool restarted:1;
bool paths_sorted:1;

View File

@ -120,14 +120,14 @@ static inline int bch2_trans_commit(struct btree_trans *trans,
#define bch2_trans_do(_c, _disk_res, _journal_seq, _flags, _do) \
({ \
struct btree_trans trans; \
int _ret, _ret2; \
int _ret; \
\
bch2_trans_init(&trans, (_c), 0, 0); \
_ret = __bch2_trans_do(&trans, _disk_res, _journal_seq, _flags, \
_do); \
_ret2 = bch2_trans_exit(&trans); \
bch2_trans_exit(&trans); \
\
_ret ?: _ret2; \
_ret; \
})
#define trans_for_each_update(_trans, _i) \

View File

@ -491,7 +491,7 @@ err:
if (ret == -EINTR)
goto retry;
ret = bch2_trans_exit(&trans) ?: ret;
bch2_trans_exit(&trans);
return ret;
}

View File

@ -1670,11 +1670,12 @@ int bch2_ec_mem_alloc(struct bch_fs *c, bool gc)
bch2_trans_iter_init(&trans, &iter, BTREE_ID_stripes, POS(0, U64_MAX), 0);
k = bch2_btree_iter_prev(&iter);
if (!IS_ERR_OR_NULL(k.k))
ret = bkey_err(k);
if (!ret && k.k)
idx = k.k->p.offset + 1;
bch2_trans_iter_exit(&trans, &iter);
ret = bch2_trans_exit(&trans);
bch2_trans_exit(&trans);
if (ret)
return ret;

View File

@ -2223,7 +2223,8 @@ err:
if (ret == -EINTR)
goto retry;
return bch2_trans_exit(&trans) ?: ret;
bch2_trans_exit(&trans);
return ret;
}
static int __bch2_truncate_page(struct bch_inode_info *inode,
@ -3125,7 +3126,7 @@ err:
if (ret == -EINTR)
goto retry;
ret = bch2_trans_exit(&trans) ?: ret;
bch2_trans_exit(&trans);
if (ret)
return ret;
@ -3240,7 +3241,7 @@ err:
if (ret == -EINTR)
goto retry;
ret = bch2_trans_exit(&trans) ?: ret;
bch2_trans_exit(&trans);
if (ret)
return ret;

View File

@ -1016,7 +1016,7 @@ err:
ret = bch2_fill_extent(c, info, bkey_i_to_s_c(prev.k),
FIEMAP_EXTENT_LAST);
ret = bch2_trans_exit(&trans) ?: ret;
bch2_trans_exit(&trans);
bch2_bkey_buf_exit(&cur, c);
bch2_bkey_buf_exit(&prev, c);
return ret < 0 ? ret : 0;

View File

@ -981,7 +981,8 @@ static int check_inodes(struct bch_fs *c, bool full)
BUG_ON(ret == -EINTR);
return bch2_trans_exit(&trans) ?: ret;
bch2_trans_exit(&trans);
return ret;
}
noinline_for_stack
@ -1659,7 +1660,8 @@ fsck_err:
goto retry;
bch2_trans_iter_exit(&trans, &iter);
return bch2_trans_exit(&trans) ?: ret;
bch2_trans_exit(&trans);
return ret;
}
/* Get root directory, create if it doesn't exist: */
@ -1876,7 +1878,8 @@ static int check_directory_structure(struct bch_fs *c)
kfree(path.entries);
return bch2_trans_exit(&trans) ?: ret;
bch2_trans_exit(&trans);
return ret;
}
struct nlink_table {

View File

@ -100,7 +100,7 @@ static int __bch2_dev_usrdata_drop(struct bch_fs *c, unsigned dev_idx, int flags
}
bch2_trans_iter_exit(&trans, &iter);
ret = bch2_trans_exit(&trans) ?: ret;
bch2_trans_exit(&trans);
bch2_bkey_buf_exit(&sk, c);
BUG_ON(ret == -EINTR);
@ -180,7 +180,7 @@ next:
ret = 0;
err:
ret = bch2_trans_exit(&trans) ?: ret;
bch2_trans_exit(&trans);
bch2_bkey_buf_exit(&k, c);
BUG_ON(ret == -EINTR);

View File

@ -773,7 +773,7 @@ next_nondata:
out:
bch2_trans_iter_exit(&trans, &iter);
ret = bch2_trans_exit(&trans) ?: ret;
bch2_trans_exit(&trans);
bch2_bkey_buf_exit(&sk, c);
return ret;

View File

@ -374,7 +374,8 @@ static int bch2_quota_init_type(struct bch_fs *c, enum quota_types type)
}
bch2_trans_iter_exit(&trans, &iter);
return bch2_trans_exit(&trans) ?: ret;
bch2_trans_exit(&trans);
return ret;
}
void bch2_fs_quota_exit(struct bch_fs *c)
@ -452,7 +453,8 @@ int bch2_fs_quota_read(struct bch_fs *c)
}
bch2_trans_iter_exit(&trans, &iter);
return bch2_trans_exit(&trans) ?: ret;
bch2_trans_exit(&trans);
return ret;
}
/* Enable/disable/delete quotas for an entire filesystem: */

View File

@ -349,7 +349,7 @@ s64 bch2_remap_range(struct bch_fs *c,
bch2_trans_iter_exit(&trans, &inode_iter);
} while (ret2 == -EINTR);
ret = bch2_trans_exit(&trans) ?: ret;
bch2_trans_exit(&trans);
bch2_bkey_buf_exit(&new_src, c);
bch2_bkey_buf_exit(&new_dst, c);

View File

@ -327,7 +327,7 @@ static int bch2_compression_stats_to_text(struct printbuf *out, struct bch_fs *c
}
bch2_trans_iter_exit(&trans, &iter);
ret = bch2_trans_exit(&trans) ?: ret;
bch2_trans_exit(&trans);
if (ret)
return ret;

View File

@ -316,7 +316,7 @@ err:
if (ret == -EINTR)
goto retry;
ret = bch2_trans_exit(&trans) ?: ret;
bch2_trans_exit(&trans);
if (ret)
return ret;