X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Fos%2Fbluestore%2FAllocator.h;fp=src%2Fceph%2Fsrc%2Fos%2Fbluestore%2FAllocator.h;h=a93428d9c1b8655d5ff257d34756dc0e4e42205a;hb=812ff6ca9fcd3e629e49d4328905f33eee8ca3f5;hp=0000000000000000000000000000000000000000;hpb=15280273faafb77777eab341909a3f495cf248d9;p=stor4nfv.git diff --git a/src/ceph/src/os/bluestore/Allocator.h b/src/ceph/src/os/bluestore/Allocator.h new file mode 100644 index 0000000..a93428d --- /dev/null +++ b/src/ceph/src/os/bluestore/Allocator.h @@ -0,0 +1,61 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ +#ifndef CEPH_OS_BLUESTORE_ALLOCATOR_H +#define CEPH_OS_BLUESTORE_ALLOCATOR_H + +#include +#include "include/assert.h" +#include "os/bluestore/bluestore_types.h" + +class FreelistManager; + +class Allocator { +public: + virtual ~Allocator() {} + + virtual int reserve(uint64_t need) = 0; + virtual void unreserve(uint64_t unused) = 0; + + /* + * Allocate required number of blocks in n number of extents. + * Min and Max number of extents are limited by: + * a. alloc unit + * b. max_alloc_size. + * as no extent can be lesser than alloc_unit and greater than max_alloc size. + * Apart from that extents can vary between these lower and higher limits according + * to free block search algorithm and availability of contiguous space. + */ + virtual int64_t allocate(uint64_t want_size, uint64_t alloc_unit, + uint64_t max_alloc_size, int64_t hint, + AllocExtentVector *extents) = 0; + + int64_t allocate(uint64_t want_size, uint64_t alloc_unit, + int64_t hint, AllocExtentVector *extents) { + return allocate(want_size, alloc_unit, want_size, hint, extents); + } + + virtual void release( + uint64_t offset, uint64_t length) = 0; + + virtual void dump() = 0; + + virtual void init_add_free(uint64_t offset, uint64_t length) = 0; + virtual void init_rm_free(uint64_t offset, uint64_t length) = 0; + + virtual uint64_t get_free() = 0; + + virtual void shutdown() = 0; + static Allocator *create(CephContext* cct, string type, int64_t size, + int64_t block_size); +}; + +#endif