lib/blob: change extent pages array size on blob resize
With this patch extent pages array will change it size accordingly to size of the blob. Similar to clusters, only resizing up is done on blob resize. Shrinking is done on persisting the blob. Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Change-Id: Id7f7c81efbd96af414fce9fc4045cbb476cc93a6 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/479962 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Paul Luse <paul.e.luse@intel.com>
This commit is contained in:
parent
eebbd951cf
commit
59f7f3f736
@ -1557,6 +1557,8 @@ _spdk_blob_resize(struct spdk_blob *blob, uint64_t sz)
|
||||
uint64_t lfc; /* lowest free cluster */
|
||||
uint32_t lfmd; /* lowest free md page */
|
||||
uint64_t num_clusters;
|
||||
uint32_t *ep_tmp;
|
||||
uint64_t new_num_ep = 0, current_num_ep = 0;
|
||||
struct spdk_blob_store *bs;
|
||||
|
||||
bs = blob->bs;
|
||||
@ -1578,6 +1580,13 @@ _spdk_blob_resize(struct spdk_blob *blob, uint64_t sz)
|
||||
num_clusters = blob->active.num_clusters;
|
||||
}
|
||||
|
||||
if (blob->use_extent_table) {
|
||||
/* Round up since every cluster beyond current Extent Table size,
|
||||
* requires new extent page. */
|
||||
new_num_ep = spdk_divide_round_up(sz, SPDK_EXTENTS_PER_EP);
|
||||
current_num_ep = spdk_divide_round_up(num_clusters, SPDK_EXTENTS_PER_EP);
|
||||
}
|
||||
|
||||
/* Do two passes - one to verify that we can obtain enough clusters
|
||||
* and md pages, another to actually claim them.
|
||||
*/
|
||||
@ -1608,7 +1617,17 @@ _spdk_blob_resize(struct spdk_blob *blob, uint64_t sz)
|
||||
blob->active.clusters = tmp;
|
||||
blob->active.cluster_array_size = sz;
|
||||
|
||||
/* TODO: Expand the extents table, only if enough clusters were added */
|
||||
/* Expand the extents table, only if enough clusters were added */
|
||||
if (new_num_ep > current_num_ep && blob->use_extent_table) {
|
||||
ep_tmp = realloc(blob->active.extent_pages, sizeof(*blob->active.extent_pages) * new_num_ep);
|
||||
if (new_num_ep > 0 && ep_tmp == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
memset(ep_tmp + blob->active.extent_pages_array_size, 0,
|
||||
sizeof(*blob->active.extent_pages) * (new_num_ep - blob->active.extent_pages_array_size));
|
||||
blob->active.extent_pages = ep_tmp;
|
||||
blob->active.extent_pages_array_size = new_num_ep;
|
||||
}
|
||||
}
|
||||
|
||||
blob->state = SPDK_BLOB_STATE_DIRTY;
|
||||
@ -1624,6 +1643,7 @@ _spdk_blob_resize(struct spdk_blob *blob, uint64_t sz)
|
||||
}
|
||||
|
||||
blob->active.num_clusters = sz;
|
||||
blob->active.num_extent_pages = new_num_ep;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -372,6 +372,10 @@ SPDK_STATIC_ASSERT(SPDK_BS_PAGE_SIZE == sizeof(struct spdk_blob_md_page), "Inval
|
||||
|
||||
#define SPDK_BS_MAX_DESC_SIZE sizeof(((struct spdk_blob_md_page*)0)->descriptors)
|
||||
|
||||
/* TODO: Set to low amount for purpose of testing */
|
||||
/* Maximum number of LBA's a single Extent Page can fit */
|
||||
#define SPDK_EXTENTS_PER_EP 100
|
||||
|
||||
#define SPDK_BS_SUPER_BLOCK_SIG "SPDKBLOB"
|
||||
|
||||
struct spdk_bs_super_block {
|
||||
|
Loading…
Reference in New Issue
Block a user