Change a number of malloc(9) calls to use M_WAITOK instead of

M_NOWAIT.

Sponsored by:	Intel
Suggested by:	carl
Reviewed by:	carl
This commit is contained in:
Jim Harris 2013-03-26 22:11:34 +00:00
parent 955910a916
commit 237d2019e5
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=248770
5 changed files with 12 additions and 22 deletions

View File

@ -260,7 +260,7 @@ nvd_new_controller(struct nvme_controller *ctrlr)
struct nvd_controller *nvd_ctrlr;
nvd_ctrlr = malloc(sizeof(struct nvd_controller), M_NVD,
M_ZERO | M_NOWAIT);
M_ZERO | M_WAITOK);
TAILQ_INIT(&nvd_ctrlr->disk_head);
TAILQ_INSERT_TAIL(&ctrlr_head, nvd_ctrlr, tailq);
@ -275,7 +275,7 @@ nvd_new_disk(struct nvme_namespace *ns, void *ctrlr_arg)
struct disk *disk;
struct nvd_controller *ctrlr = ctrlr_arg;
ndisk = malloc(sizeof(struct nvd_disk), M_NVD, M_ZERO | M_NOWAIT);
ndisk = malloc(sizeof(struct nvd_disk), M_NVD, M_ZERO | M_WAITOK);
disk = disk_alloc();
disk->d_strategy = nvd_strategy;

View File

@ -263,10 +263,7 @@ nvme_ctrlr_construct_io_qpairs(struct nvme_controller *ctrlr)
ctrlr->max_xfer_size = NVME_MAX_XFER_SIZE;
ctrlr->ioq = malloc(ctrlr->num_io_queues * sizeof(struct nvme_qpair),
M_NVME, M_ZERO | M_NOWAIT);
if (ctrlr->ioq == NULL)
return (ENOMEM);
M_NVME, M_ZERO | M_WAITOK);
for (i = 0; i < ctrlr->num_io_queues; i++) {
qpair = &ctrlr->ioq[i];

View File

@ -254,7 +254,7 @@ nvme_ns_bio_process(struct nvme_namespace *ns, struct bio *bp,
*/
dsm_range =
malloc(sizeof(struct nvme_dsm_range), M_NVME,
M_ZERO | M_NOWAIT);
M_ZERO | M_WAITOK);
dsm_range->length =
bp->bio_bcount/nvme_ns_get_sector_size(ns);
dsm_range->starting_lba =

View File

@ -297,12 +297,11 @@ nvme_qpair_construct(struct nvme_qpair *qpair, uint32_t id,
qpair->num_cmds = 0;
qpair->num_intr_handler_calls = 0;
/* TODO: error checking on contigmalloc, bus_dmamap_load calls */
qpair->cmd = contigmalloc(qpair->num_entries *
sizeof(struct nvme_command), M_NVME, M_ZERO | M_NOWAIT,
sizeof(struct nvme_command), M_NVME, M_ZERO,
0, BUS_SPACE_MAXADDR, PAGE_SIZE, 0);
qpair->cpl = contigmalloc(qpair->num_entries *
sizeof(struct nvme_completion), M_NVME, M_ZERO | M_NOWAIT,
sizeof(struct nvme_completion), M_NVME, M_ZERO,
0, BUS_SPACE_MAXADDR, PAGE_SIZE, 0);
bus_dmamap_create(qpair->dma_tag, 0, &qpair->cmd_dma_map);
@ -323,19 +322,13 @@ nvme_qpair_construct(struct nvme_qpair *qpair, uint32_t id,
STAILQ_INIT(&qpair->queued_req);
for (i = 0; i < qpair->num_trackers; i++) {
tr = malloc(sizeof(*tr), M_NVME, M_ZERO | M_NOWAIT);
if (tr == NULL) {
printf("warning: nvme tracker malloc failed\n");
break;
}
tr = malloc(sizeof(*tr), M_NVME, M_ZERO | M_WAITOK);
nvme_qpair_construct_tracker(qpair, tr, i);
TAILQ_INSERT_HEAD(&qpair->free_tr, tr, tailq);
}
qpair->act_tr = malloc(sizeof(struct nvme_tracker *) * qpair->num_entries,
M_NVME, M_ZERO | M_NOWAIT);
M_NVME, M_ZERO | M_WAITOK);
}
static void

View File

@ -96,7 +96,7 @@ nvme_ns_bio_test(void *arg)
int ref;
#endif
buf = malloc(io_test->size, M_NVME, M_NOWAIT);
buf = malloc(io_test->size, M_NVME, M_WAITOK);
idx = atomic_fetchadd_int(&io_test->td_idx, 1);
dev = io_test->ns->cdev;
@ -217,11 +217,11 @@ nvme_ns_io_test(void *arg)
struct nvme_completion cpl;
int error;
tth = malloc(sizeof(*tth), M_NVME, M_NOWAIT | M_ZERO);
tth = malloc(sizeof(*tth), M_NVME, M_WAITOK | M_ZERO);
tth->ns = io_test->ns;
tth->opc = io_test->opc;
memcpy(&tth->start, &io_test->start, sizeof(tth->start));
tth->buf = malloc(io_test->size, M_NVME, M_NOWAIT);
tth->buf = malloc(io_test->size, M_NVME, M_WAITOK);
tth->size = io_test->size;
tth->time = io_test->time;
tth->idx = atomic_fetchadd_int(&io_test->td_idx, 1);
@ -269,7 +269,7 @@ nvme_ns_test(struct nvme_namespace *ns, u_long cmd, caddr_t arg)
return;
io_test_internal = malloc(sizeof(*io_test_internal), M_NVME,
M_NOWAIT | M_ZERO);
M_WAITOK | M_ZERO);
io_test_internal->opc = io_test->opc;
io_test_internal->ns = ns;
io_test_internal->td_active = io_test->num_threads;