Commit 58e2388f authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Kill BTREE_INSERT_ATOMIC

Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent b1fd23df
......@@ -326,7 +326,6 @@ int bch2_set_acl(struct mnt_idmap *idmap,
ret = bch2_inode_write(&trans, inode_iter, &inode_u) ?:
bch2_trans_commit(&trans, NULL,
&inode->ei_journal_seq,
BTREE_INSERT_ATOMIC|
BTREE_INSERT_NOUNLOCK);
btree_err:
if (ret == -EINTR)
......
......@@ -316,7 +316,6 @@ static int bch2_alloc_write_key(struct btree_trans *trans,
bch2_trans_update(trans, iter, &a->k_i);
ret = bch2_trans_commit(trans, NULL, NULL,
BTREE_INSERT_ATOMIC|
BTREE_INSERT_NOFAIL|
BTREE_INSERT_NOMARK|
flags);
......@@ -913,7 +912,6 @@ static int bch2_invalidate_one_bucket2(struct btree_trans *trans,
*/
ret = bch2_trans_commit(trans, NULL,
invalidating_cached_data ? journal_seq : NULL,
BTREE_INSERT_ATOMIC|
BTREE_INSERT_NOUNLOCK|
BTREE_INSERT_NOCHECK_RW|
BTREE_INSERT_NOFAIL|
......
......@@ -16,7 +16,6 @@ void bch2_btree_journal_key(struct btree_trans *, struct btree_iter *,
struct bkey_i *);
enum {
__BTREE_INSERT_ATOMIC,
__BTREE_INSERT_NOUNLOCK,
__BTREE_INSERT_NOFAIL,
__BTREE_INSERT_NOCHECK_RW,
......@@ -35,12 +34,6 @@ enum {
__BCH_HASH_SET_MUST_REPLACE,
};
/*
* Don't drop/retake locks before doing btree update, instead return -EINTR if
* we had to drop locks for any reason
*/
#define BTREE_INSERT_ATOMIC (1 << __BTREE_INSERT_ATOMIC)
/*
* Don't drop locks _after_ successfully updating btree:
*/
......@@ -101,8 +94,7 @@ int __bch2_trans_commit(struct btree_trans *);
* This is main entry point for btree updates.
*
* Return values:
* -EINTR: locking changed, this function should be called again. Only returned
* if passed BTREE_INSERT_ATOMIC.
* -EINTR: locking changed, this function should be called again.
* -EROFS: filesystem read only
* -EIO: journal or btree node IO error
*/
......
......@@ -298,8 +298,6 @@ static inline void btree_insert_entry_checks(struct btree_trans *trans,
BUG_ON(bkey_cmp(bkey_start_pos(&i->k->k), i->iter->pos));
EBUG_ON((i->iter->flags & BTREE_ITER_IS_EXTENTS) &&
bkey_cmp(i->k->k.p, i->iter->l[0].b->key.k.p) > 0);
EBUG_ON((i->iter->flags & BTREE_ITER_IS_EXTENTS) &&
!(trans->flags & BTREE_INSERT_ATOMIC));
BUG_ON(debug_check_bkeys(c) &&
!bkey_deleted(&i->k->k) &&
......@@ -641,8 +639,8 @@ int bch2_trans_commit_error(struct btree_trans *trans,
/*
* if the split succeeded without dropping locks the insert will
* still be atomic (in the BTREE_INSERT_ATOMIC sense, what the
* caller peeked() and is overwriting won't have changed)
* still be atomic (what the caller peeked() and is overwriting
* won't have changed)
*/
#if 0
/*
......@@ -713,13 +711,6 @@ int bch2_trans_commit_error(struct btree_trans *trans,
return ret2;
}
/*
* BTREE_ITER_ATOMIC means we have to return -EINTR if we
* dropped locks:
*/
if (!(flags & BTREE_INSERT_ATOMIC))
return 0;
trace_trans_restart_atomic(trans->ip);
}
......@@ -756,9 +747,6 @@ int __bch2_trans_commit(struct btree_trans *trans)
if (!trans->nr_updates)
goto out_noupdates;
/* for the sake of sanity: */
EBUG_ON(trans->nr_updates > 1 && !(trans->flags & BTREE_INSERT_ATOMIC));
if (trans->flags & BTREE_INSERT_GC_LOCK_HELD)
lockdep_assert_held(&trans->c->gc_lock);
......@@ -795,8 +783,6 @@ int __bch2_trans_commit(struct btree_trans *trans)
if (likely(!(trans->flags & BTREE_INSERT_NOCHECK_RW)))
percpu_ref_put(&trans->c->writes);
out_noupdates:
EBUG_ON(!(trans->flags & BTREE_INSERT_ATOMIC) && ret == -EINTR);
trans_for_each_iter_all(trans, iter)
iter->flags &= ~BTREE_ITER_KEEP_UNTIL_COMMIT;
......@@ -897,7 +883,6 @@ int bch2_btree_delete_at_range(struct btree_trans *trans,
bch2_trans_update(trans, iter, &delete);
ret = bch2_trans_commit(trans, NULL, journal_seq,
BTREE_INSERT_ATOMIC|
BTREE_INSERT_NOFAIL);
if (ret)
break;
......
......@@ -739,7 +739,6 @@ static int ec_stripe_bkey_insert(struct bch_fs *c,
bch2_trans_update(&trans, iter, &stripe->k_i);
ret = bch2_trans_commit(&trans, NULL, NULL,
BTREE_INSERT_ATOMIC|
BTREE_INSERT_NOFAIL);
err:
if (ret == -EINTR)
......@@ -822,7 +821,6 @@ static int ec_stripe_update_ptrs(struct bch_fs *c,
bch2_trans_update(&trans, iter, sk.k);
ret = bch2_trans_commit(&trans, NULL, NULL,
BTREE_INSERT_ATOMIC|
BTREE_INSERT_NOFAIL|
BTREE_INSERT_USE_RESERVE);
if (ret == -EINTR)
......@@ -1235,7 +1233,6 @@ static int __bch2_stripe_write_key(struct btree_trans *trans,
bch2_trans_update(trans, iter, &new_key->k_i);
return bch2_trans_commit(trans, NULL, NULL,
BTREE_INSERT_ATOMIC|
BTREE_INSERT_NOFAIL|flags);
}
......
......@@ -2558,7 +2558,6 @@ static long bchfs_fcollapse_finsert(struct bch_inode_info *inode,
ret = bch2_trans_commit(&trans, &disk_res,
&inode->ei_journal_seq,
BTREE_INSERT_ATOMIC|
BTREE_INSERT_NOFAIL|
commit_flags);
bch2_disk_reservation_put(c, &disk_res);
......
......@@ -143,7 +143,6 @@ int __must_check bch2_write_inode(struct bch_fs *c,
bch2_inode_write(&trans, iter, &inode_u) ?:
bch2_trans_commit(&trans, NULL,
&inode->ei_journal_seq,
BTREE_INSERT_ATOMIC|
BTREE_INSERT_NOUNLOCK|
BTREE_INSERT_NOFAIL);
if (ret == -EINTR)
......@@ -279,7 +278,6 @@ __bch2_create(struct mnt_idmap *idmap,
goto err_before_quota;
ret = bch2_trans_commit(&trans, NULL, &journal_seq,
BTREE_INSERT_ATOMIC|
BTREE_INSERT_NOUNLOCK);
if (unlikely(ret)) {
bch2_quota_acct(c, bch_qid(&inode_u), Q_INO, -1,
......@@ -409,7 +407,6 @@ static int __bch2_link(struct bch_fs *c,
&dentry->d_name) ?:
bch2_trans_commit(&trans, NULL,
&inode->ei_journal_seq,
BTREE_INSERT_ATOMIC|
BTREE_INSERT_NOUNLOCK);
} while (ret == -EINTR);
......@@ -466,7 +463,6 @@ static int bch2_unlink(struct inode *vdir, struct dentry *dentry)
&inode_u, &dentry->d_name) ?:
bch2_trans_commit(&trans, NULL,
&dir->ei_journal_seq,
BTREE_INSERT_ATOMIC|
BTREE_INSERT_NOUNLOCK|
BTREE_INSERT_NOFAIL);
} while (ret == -EINTR);
......@@ -598,7 +594,6 @@ static int bch2_rename2(struct mnt_idmap *idmap,
mode) ?:
bch2_trans_commit(&trans, NULL,
&journal_seq,
BTREE_INSERT_ATOMIC|
BTREE_INSERT_NOUNLOCK);
if (ret == -EINTR)
goto retry;
......@@ -733,7 +728,6 @@ static int bch2_setattr_nonsize(struct mnt_idmap *idmap,
ret = bch2_inode_write(&trans, inode_iter, &inode_u) ?:
bch2_trans_commit(&trans, NULL,
&inode->ei_journal_seq,
BTREE_INSERT_ATOMIC|
BTREE_INSERT_NOUNLOCK|
BTREE_INSERT_NOFAIL);
btree_err:
......
......@@ -79,7 +79,6 @@ static int remove_dirent(struct btree_trans *trans,
struct bkey_s_c_dirent dirent)
{
return __bch2_trans_do(trans, NULL, NULL,
BTREE_INSERT_ATOMIC|
BTREE_INSERT_NOFAIL|
BTREE_INSERT_LAZY_RW,
TRANS_RESET_MEM,
......@@ -99,7 +98,6 @@ static int reattach_inode(struct bch_fs *c,
name = (struct qstr) QSTR(name_buf);
ret = bch2_trans_do(c, NULL, NULL,
BTREE_INSERT_ATOMIC|
BTREE_INSERT_LAZY_RW,
bch2_link_trans(&trans, lostfound_inode->bi_inum,
inum, &dir_u, &inode_u, &name));
......@@ -199,7 +197,6 @@ static int hash_redo_key(const struct bch_hash_desc desc,
return bch2_hash_set(trans, desc, &h->info, k_iter->pos.inode,
tmp, BCH_HASH_SET_MUST_CREATE) ?:
bch2_trans_commit(trans, NULL, NULL,
BTREE_INSERT_ATOMIC|
BTREE_INSERT_NOFAIL|
BTREE_INSERT_LAZY_RW);
}
......@@ -213,7 +210,6 @@ static int fsck_hash_delete_at(struct btree_trans *trans,
retry:
ret = bch2_hash_delete_at(trans, desc, info, iter) ?:
bch2_trans_commit(trans, NULL, NULL,
BTREE_INSERT_ATOMIC|
BTREE_INSERT_NOFAIL|
BTREE_INSERT_LAZY_RW);
if (ret == -EINTR) {
......@@ -389,7 +385,6 @@ static int check_dirent_hash(struct btree_trans *trans, struct hash_check *h,
if (fsck_err(c, "dirent with junk at end, was %s (%zu) now %s (%u)",
buf, strlen(buf), d->v.d_name, len)) {
ret = __bch2_trans_do(trans, NULL, NULL,
BTREE_INSERT_ATOMIC|
BTREE_INSERT_NOFAIL|
BTREE_INSERT_LAZY_RW,
TRANS_RESET_MEM,
......@@ -663,7 +658,6 @@ static int check_dirents(struct bch_fs *c)
n->v.d_type = mode_to_type(target.bi_mode);
ret = __bch2_trans_do(&trans, NULL, NULL,
BTREE_INSERT_ATOMIC|
BTREE_INSERT_NOFAIL|
BTREE_INSERT_LAZY_RW,
TRANS_RESET_MEM,
......@@ -808,7 +802,6 @@ static int check_lostfound(struct bch_fs *c,
bch2_inode_init_early(c, lostfound_inode);
ret = bch2_trans_do(c, NULL, NULL,
BTREE_INSERT_ATOMIC|
BTREE_INSERT_NOFAIL|
BTREE_INSERT_LAZY_RW,
bch2_create_trans(&trans,
......@@ -1280,7 +1273,6 @@ static int check_inode(struct btree_trans *trans,
bch2_inode_pack(&p, &u);
ret = __bch2_trans_do(trans, NULL, NULL,
BTREE_INSERT_ATOMIC|
BTREE_INSERT_NOFAIL|
BTREE_INSERT_LAZY_RW,
TRANS_RESET_MEM,
......
......@@ -496,7 +496,6 @@ int bch2_inode_rm(struct bch_fs *c, u64 inode_nr)
bch2_trans_update(&trans, iter, &delete.k_i);
ret = bch2_trans_commit(&trans, NULL, NULL,
BTREE_INSERT_ATOMIC|
BTREE_INSERT_NOFAIL);
} while (ret == -EINTR);
......
......@@ -313,7 +313,6 @@ int bch2_extent_update(struct btree_trans *trans,
ret = bch2_trans_commit(trans, disk_res, journal_seq,
BTREE_INSERT_NOCHECK_RW|
BTREE_INSERT_NOFAIL|
BTREE_INSERT_ATOMIC|
BTREE_INSERT_USE_RESERVE);
if (!ret && i_sectors_delta)
*i_sectors_delta += delta;
......@@ -1740,7 +1739,6 @@ static void bch2_rbio_narrow_crcs(struct bch_read_bio *rbio)
bch2_trans_update(&trans, iter, new.k);
ret = bch2_trans_commit(&trans, NULL, NULL,
BTREE_INSERT_ATOMIC|
BTREE_INSERT_NOFAIL|
BTREE_INSERT_NOWAIT);
if (ret == -EINTR)
......
......@@ -79,7 +79,6 @@ static int __bch2_dev_usrdata_drop(struct bch_fs *c, unsigned dev_idx, int flags
bch2_trans_update(&trans, iter, sk.k);
ret = bch2_trans_commit(&trans, NULL, NULL,
BTREE_INSERT_ATOMIC|
BTREE_INSERT_NOFAIL);
/*
......
......@@ -153,7 +153,6 @@ static int bch2_migrate_index_update(struct bch_write_op *op)
ret = bch2_trans_commit(&trans, &op->res,
op_journal_seq(op),
BTREE_INSERT_ATOMIC|
BTREE_INSERT_NOFAIL|
BTREE_INSERT_USE_RESERVE|
m->data_opts.btree_insert_flags);
......
......@@ -309,14 +309,12 @@ static int bch2_extent_replay_key(struct bch_fs *c, enum btree_id btree_id,
0, -((s64) k->k.size),
BCH_BUCKET_MARK_OVERWRITE) ?:
bch2_trans_commit(&trans, &disk_res, NULL,
BTREE_INSERT_ATOMIC|
BTREE_INSERT_NOFAIL|
BTREE_INSERT_LAZY_RW|
BTREE_INSERT_NOMARK_OVERWRITES|
BTREE_INSERT_NO_CLEAR_REPLICAS);
} else {
ret = bch2_trans_commit(&trans, &disk_res, NULL,
BTREE_INSERT_ATOMIC|
BTREE_INSERT_NOFAIL|
BTREE_INSERT_LAZY_RW|
BTREE_INSERT_JOURNAL_REPLAY|
......@@ -1009,7 +1007,7 @@ int bch2_fs_initialize(struct bch_fs *c)
bch2_inode_init_early(c, &lostfound_inode);
err = "error creating lost+found";
ret = bch2_trans_do(c, NULL, NULL, BTREE_INSERT_ATOMIC,
ret = bch2_trans_do(c, NULL, NULL, 0,
bch2_create_trans(&trans, BCACHEFS_ROOT_INO,
&root_inode, &lostfound_inode,
&lostfound,
......
......@@ -288,8 +288,7 @@ s64 bch2_remap_range(struct bch_fs *c,
inode_u.bi_size < new_i_size) {
inode_u.bi_size = new_i_size;
ret2 = bch2_inode_write(&trans, inode_iter, &inode_u) ?:
bch2_trans_commit(&trans, NULL, journal_seq,
BTREE_INSERT_ATOMIC);
bch2_trans_commit(&trans, NULL, journal_seq, 0);
}
} while (ret2 == -EINTR);
......
......@@ -328,8 +328,7 @@ static int bch2_xattr_set_handler(const struct xattr_handler *handler,
struct bch_inode_info *inode = to_bch_ei(vinode);
struct bch_fs *c = inode->v.i_sb->s_fs_info;
return bch2_trans_do(c, NULL, &inode->ei_journal_seq,
BTREE_INSERT_ATOMIC,
return bch2_trans_do(c, NULL, &inode->ei_journal_seq, 0,
bch2_xattr_set(&trans, inode->v.i_ino,
&inode->ei_str_hash,
name, value, size,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment