reduce: allocate scratch buffer space for requests
Each request will need a scratch buffer of size chunk_size. This is needed for read/modify/write operations when only part of a chunk is written. Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: Ided33f1e9ae18dd9a5de45f53f0a994a6f260b17 Reviewed-on: https://review.gerrithub.io/434111 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
6a6c6bf366
commit
d465a21a30
@ -75,6 +75,7 @@ struct spdk_reduce_pm_file {
|
||||
};
|
||||
|
||||
struct spdk_reduce_vol_request {
|
||||
uint8_t *buf;
|
||||
TAILQ_ENTRY(spdk_reduce_vol_request) tailq;
|
||||
};
|
||||
|
||||
@ -92,6 +93,7 @@ struct spdk_reduce_vol {
|
||||
|
||||
struct spdk_reduce_vol_request *request_mem;
|
||||
TAILQ_HEAD(, spdk_reduce_vol_request) requests;
|
||||
uint8_t *bufspace;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -236,13 +238,21 @@ _allocate_vol_requests(struct spdk_reduce_vol *vol)
|
||||
struct spdk_reduce_vol_request *req;
|
||||
int i;
|
||||
|
||||
vol->bufspace = spdk_dma_malloc(REDUCE_NUM_VOL_REQUESTS * vol->params.chunk_size, 64, NULL);
|
||||
if (vol->bufspace == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
vol->request_mem = calloc(REDUCE_NUM_VOL_REQUESTS, sizeof(*req));
|
||||
if (vol->request_mem == NULL) {
|
||||
free(vol->bufspace);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
for (i = 0; i < REDUCE_NUM_VOL_REQUESTS; i++) {
|
||||
TAILQ_INSERT_HEAD(&vol->requests, &vol->request_mem[i], tailq);
|
||||
req = &vol->request_mem[i];
|
||||
TAILQ_INSERT_HEAD(&vol->requests, req, tailq);
|
||||
req->buf = vol->bufspace + i * vol->params.chunk_size;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -261,6 +271,7 @@ _init_load_cleanup(struct spdk_reduce_vol *vol, struct reduce_init_load_ctx *ctx
|
||||
spdk_bit_array_free(&vol->allocated_chunk_maps);
|
||||
spdk_bit_array_free(&vol->allocated_backing_io_units);
|
||||
free(vol->request_mem);
|
||||
spdk_dma_free(vol->bufspace);
|
||||
free(vol);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user