lvol: remove num_clusters member from spdk_lvol

This is not needed - we can easily get the number
of clusters from the underlying blob.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I94a716731bd1b8c4b333fe295bd5a963928b4330

Reviewed-on: https://review.gerrithub.io/404615
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Jim Harris 2018-03-20 16:24:47 -07:00
parent 1cc6601a77
commit 3fe80a337c
4 changed files with 9 additions and 7 deletions

View File

@ -97,7 +97,6 @@ struct spdk_lvol_store {
struct spdk_lvol {
struct spdk_lvol_store *lvol_store;
struct spdk_blob *blob;
uint64_t num_clusters;
spdk_blob_id blob_id;
char *unique_id;
char name[SPDK_LVOL_NAME_MAX];

View File

@ -805,7 +805,8 @@ _create_lvol_disk(struct spdk_lvol *lvol)
}
bdev->product_name = "Logical Volume";
bdev->blocklen = spdk_bs_get_page_size(lvol->lvol_store->blobstore);
total_size = lvol->num_clusters * spdk_bs_get_cluster_size(lvol->lvol_store->blobstore);
total_size = spdk_blob_get_num_clusters(lvol->blob) *
spdk_bs_get_cluster_size(lvol->lvol_store->blobstore);
assert((total_size % bdev->blocklen) == 0);
bdev->blockcnt = total_size / bdev->blocklen;
bdev->uuid = lvol->uuid;

View File

@ -192,7 +192,6 @@ _spdk_load_next_lvol(void *cb_arg, struct spdk_blob *blob, int lvolerrno)
lvol->blob = blob;
lvol->blob_id = blob_id;
lvol->lvol_store = lvs;
lvol->num_clusters = spdk_blob_get_num_clusters(blob);
lvol->close_only = false;
spdk_uuid_fmt_lower(uuid, sizeof(uuid), &lvol->lvol_store->uuid);
lvol->unique_id = spdk_sprintf_alloc("%s_%"PRIu64, uuid, (uint64_t)blob_id);
@ -1067,7 +1066,6 @@ spdk_lvol_create(struct spdk_lvol_store *lvs, const char *name, uint64_t sz,
lvol->lvol_store = lvs;
num_clusters = divide_round_up(sz, spdk_bs_get_cluster_size(bs));
lvol->num_clusters = num_clusters;
lvol->close_only = false;
lvol->thin_provision = thin_provision;
strncpy(lvol->name, name, SPDK_LVS_NAME_MAX);
@ -1106,7 +1104,7 @@ spdk_lvol_resize(struct spdk_lvol *lvol, uint64_t sz,
struct spdk_lvol_store *lvs = lvol->lvol_store;
struct spdk_lvol_req *req;
uint64_t free_clusters = spdk_bs_free_cluster_count(lvs->blobstore);
uint64_t used_clusters = lvol->num_clusters;
uint64_t used_clusters = spdk_blob_get_num_clusters(blob);
uint64_t new_clusters = divide_round_up(sz, spdk_bs_get_cluster_size(lvs->blobstore));
/* Check if size of lvol increasing */
@ -1131,8 +1129,6 @@ spdk_lvol_resize(struct spdk_lvol *lvol, uint64_t sz,
goto invalid;
}
lvol->num_clusters = new_clusters;
spdk_blob_sync_md(blob, _spdk_lvol_resize_cb, req);
return rc;

View File

@ -157,6 +157,12 @@ spdk_blob_close(struct spdk_blob *b, spdk_blob_op_complete cb_fn, void *cb_arg)
{
}
uint64_t
spdk_blob_get_num_clusters(struct spdk_blob *b)
{
return 0;
}
static struct spdk_lvol *_lvol_create(struct spdk_lvol_store *lvs);
void