#include <linux/sched/task.h>
#include <linux/sort.h>
+const char * const bch2_allocator_states[] = {
+#define x(n) #n,
+ ALLOC_THREAD_STATES()
+#undef x
+ NULL
+};
+
static const unsigned BCH_ALLOC_V1_FIELD_BYTES[] = {
#define x(name, bits) [BCH_ALLOC_FIELD_V1_##name] = bits / 8,
BCH_ALLOC_FIELDS_V1()
s64 available;
int ret = 0;
- ca->allocator_state = ALLOCATOR_BLOCKED;
+ ca->allocator_state = ALLOCATOR_blocked;
closure_wake_up(&c->freelist_wait);
while (1) {
}
__set_current_state(TASK_RUNNING);
- ca->allocator_state = ALLOCATOR_RUNNING;
+ ca->allocator_state = ALLOCATOR_running;
closure_wake_up(&c->freelist_wait);
return ret;
fifo_pop(&ca->free_inc, bucket);
closure_wake_up(&c->freelist_wait);
- ca->allocator_state = ALLOCATOR_RUNNING;
+ ca->allocator_state = ALLOCATOR_running;
spin_unlock(&c->freelist_lock);
goto out;
}
}
- if (ca->allocator_state != ALLOCATOR_BLOCKED_FULL) {
- ca->allocator_state = ALLOCATOR_BLOCKED_FULL;
+ if (ca->allocator_state != ALLOCATOR_blocked_full) {
+ ca->allocator_state = ALLOCATOR_blocked_full;
closure_wake_up(&c->freelist_wait);
}
while (1) {
if (!allocator_thread_running(ca)) {
- ca->allocator_state = ALLOCATOR_STOPPED;
+ ca->allocator_state = ALLOCATOR_stopped;
if (kthread_wait_freezable(allocator_thread_running(ca)))
break;
}
- ca->allocator_state = ALLOCATOR_RUNNING;
+ ca->allocator_state = ALLOCATOR_running;
cond_resched();
if (kthread_should_stop())
stop:
pr_debug("alloc thread stopping (ret %i)", ret);
- ca->allocator_state = ALLOCATOR_STOPPED;
+ ca->allocator_state = ALLOCATOR_stopped;
closure_wake_up(&c->freelist_wait);
return 0;
}
{
if (ca->alloc_thread)
closure_wait_event(&c->freelist_wait,
- ca->allocator_state != ALLOCATOR_RUNNING);
+ ca->allocator_state != ALLOCATOR_running);
}
/* stop allocator thread: */
"open_buckets_wait\t%s\n"
"open_buckets_btree\t%u\n"
"open_buckets_user\t%u\n"
- "btree reserve cache\t%u\n",
+ "btree reserve cache\t%u\n"
+ "thread state:\t\t%s\n",
stats.buckets_ec,
__dev_buckets_available(ca, stats),
fifo_used(&ca->free_inc), ca->free_inc.size,
c->open_buckets_wait.list.first ? "waiting" : "empty",
nr[BCH_DATA_btree],
nr[BCH_DATA_user],
- c->btree_reserve_cache_nr);
+ c->btree_reserve_cache_nr,
+ bch2_allocator_states[ca->allocator_state]);
}
static const char * const bch2_rw[] = {