Lines Matching refs:spc

21 void deinit_space(struct hp_space *spc)
23 kvfree(spc->bitmap);
24 atomic64_sub(BITS_TO_LONGS(spc->nr_ext) * sizeof(long), &spc_mem);
25 spc->ext_size = 0;
26 spc->nr_ext = 0;
27 atomic_set(&spc->last_alloc_bit, 0);
28 atomic_set(&spc->nr_alloced, 0);
33 bool init_space(struct hp_space *spc, u64 dev_size, u32 ext_size)
43 spc->ext_size = ext_size;
44 spc->nr_ext = div_u64(dev_size, ext_size);
45 atomic_set(&spc->last_alloc_bit, 0);
46 atomic_set(&spc->nr_alloced, 0);
47 init_waitqueue_head(&spc->empty_wq);
48 spc->bitmap = kvzalloc(BITS_TO_LONGS(spc->nr_ext) * sizeof(long), GFP_KERNEL);
49 if (!spc->bitmap) {
53 atomic64_add(BITS_TO_LONGS(spc->nr_ext) * sizeof(long), &spc_mem);
55 pr_info("hyperhold space init succ, capacity = %u x %u.\n", ext_size, spc->nr_ext);
60 int alloc_eid(struct hp_space *spc)
66 last_bit = atomic_read(&spc->last_alloc_bit);
67 bit = find_next_zero_bit(spc->bitmap, spc->nr_ext, last_bit);
68 if (bit == spc->nr_ext)
69 bit = find_next_zero_bit(spc->bitmap, spc->nr_ext, 0);
70 if (bit == spc->nr_ext)
72 if (test_and_set_bit(bit, spc->bitmap))
75 atomic_set(&spc->last_alloc_bit, bit);
76 atomic_inc(&spc->nr_alloced);
87 void free_eid(struct hp_space *spc, u32 eid)
89 if (!test_and_clear_bit(eid, spc->bitmap)) {
94 if (atomic_dec_and_test(&spc->nr_alloced)) {
96 wake_up(&spc->empty_wq);
101 static void dump_space(struct hp_space *spc)
106 for (i = 0; i < spc->nr_ext; i++)
107 if (test_bit(i, spc->bitmap))
111 bool wait_for_space_empty(struct hp_space *spc, bool force)
113 if (!atomic_read(&spc->nr_alloced))
118 dump_space(spc);
119 wait_event(spc->empty_wq, !atomic_read(&spc->nr_alloced));