virtual ~Allocator() {}
virtual int reserve(uint64_t need) = 0;
+ virtual void unreserve(uint64_t unused) = 0;
virtual int allocate(
uint64_t need_size, uint64_t alloc_unit, int64_t hint,
Mutex::Locker l(lock);
dout(10) << __func__ << " need " << need << " num_free " << num_free
<< " num_reserved " << num_reserved << dendl;
- if (need > num_free - num_reserved)
+ if ((int64_t)need > num_free - num_reserved)
return -ENOSPC;
num_reserved += need;
return 0;
}
+void StupidAllocator::unreserve(uint64_t unused)
+{
+ Mutex::Locker l(lock);
+ dout(10) << __func__ << " unused " << unused << " num_free " << num_free
+ << " num_reserved " << num_reserved << dendl;
+ assert(unused >= num_reserved);
+ num_reserved -= unused;
+}
+
int StupidAllocator::allocate(
uint64_t need_size, uint64_t alloc_unit, int64_t hint,
uint64_t *offset, uint32_t *length)
~StupidAllocator();
int reserve(uint64_t need);
+ void unreserve(uint64_t unused);
int allocate(
uint64_t need_size, uint64_t alloc_unit, int64_t hint,