return iter;
}
-static int bch2_trans_preload_mem(struct btree_trans *trans, size_t size)
+void *bch2_trans_kmalloc(struct btree_trans *trans, size_t size)
{
- if (size > trans->mem_bytes) {
+ size_t new_top = trans->mem_top + size;
+ void *p;
+
+ if (new_top > trans->mem_bytes) {
size_t old_bytes = trans->mem_bytes;
- size_t new_bytes = roundup_pow_of_two(size);
+ size_t new_bytes = roundup_pow_of_two(new_top);
void *new_mem;
WARN_ON_ONCE(new_bytes > BTREE_TRANS_MEM_MAX);
}
if (!new_mem)
- return -ENOMEM;
+ return ERR_PTR(-ENOMEM);
trans->mem = new_mem;
trans->mem_bytes = new_bytes;
if (old_bytes) {
- trace_trans_restart_mem_realloced(trans->ip, new_bytes);
- return -EINTR;
+ trace_trans_restart_mem_realloced(trans->ip, _RET_IP_, new_bytes);
+ return ERR_PTR(-EINTR);
}
}
- return 0;
-}
-
-void *bch2_trans_kmalloc(struct btree_trans *trans, size_t size)
-{
- void *p;
- int ret;
-
- ret = bch2_trans_preload_mem(trans, trans->mem_top + size);
- if (ret)
- return ERR_PTR(ret);
-
p = trans->mem + trans->mem_top;
trans->mem_top += size;
return p;
__entry->want_pos_snapshot)
);
-TRACE_EVENT(trans_restart_iters_realloced,
- TP_PROTO(unsigned long ip, unsigned nr),
- TP_ARGS(ip, nr),
-
- TP_STRUCT__entry(
- __field(unsigned long, ip )
- __field(unsigned, nr )
- ),
-
- TP_fast_assign(
- __entry->ip = ip;
- __entry->nr = nr;
- ),
-
- TP_printk("%pS nr %u", (void *) __entry->ip, __entry->nr)
-);
-
TRACE_EVENT(trans_restart_mem_realloced,
- TP_PROTO(unsigned long ip, unsigned long bytes),
- TP_ARGS(ip, bytes),
+ TP_PROTO(unsigned long trans_ip, unsigned long caller_ip,
+ unsigned long bytes),
+ TP_ARGS(trans_ip, caller_ip, bytes),
TP_STRUCT__entry(
- __field(unsigned long, ip )
- __field(unsigned long, bytes )
+ __field(unsigned long, trans_ip )
+ __field(unsigned long, caller_ip )
+ __field(unsigned long, bytes )
),
TP_fast_assign(
- __entry->ip = ip;
- __entry->bytes = bytes;
+ __entry->trans_ip = trans_ip;
+ __entry->caller_ip = caller_ip;
+ __entry->bytes = bytes;
),
- TP_printk("%pS bytes %lu", (void *) __entry->ip, __entry->bytes)
+ TP_printk("%pS %pS bytes %lu",
+ (void *) __entry->trans_ip,
+ (void *) __entry->caller_ip,
+ __entry->bytes)
);
DEFINE_EVENT(transaction_restart, trans_restart_journal_res_get,