Add uma zone for composite ops.
Submitted by: des
This commit is contained in:
parent
f8aa7a835c
commit
b3c3ba2ed7
@ -75,7 +75,8 @@ static int ata_identify(device_t dev);
|
||||
MALLOC_DEFINE(M_ATA, "ATA generic", "ATA driver generic layer");
|
||||
int (*ata_ioctl_func)(struct ata_cmd *iocmd) = NULL;
|
||||
devclass_t ata_devclass;
|
||||
uma_zone_t ata_zone;
|
||||
uma_zone_t ata_request_zone;
|
||||
uma_zone_t ata_composite_zone;
|
||||
int ata_wc = 1;
|
||||
|
||||
/* local vars */
|
||||
@ -837,9 +838,18 @@ MODULE_VERSION(ata, 1);
|
||||
static void
|
||||
ata_init(void)
|
||||
{
|
||||
/* init our UMA zone for ATA requests */
|
||||
ata_zone = uma_zcreate("ata_request", sizeof(struct ata_request),
|
||||
NULL, NULL, NULL, NULL, 0, 0);
|
||||
ata_request_zone = uma_zcreate("ata_request", sizeof(struct ata_request),
|
||||
NULL, NULL, NULL, NULL, 0, 0);
|
||||
ata_composite_zone = uma_zcreate("ata_composite",
|
||||
sizeof(struct ata_composite),
|
||||
NULL, NULL, NULL, NULL, 0, 0);
|
||||
}
|
||||
SYSINIT(ata_register, SI_SUB_DRIVERS, SI_ORDER_SECOND, ata_init, NULL);
|
||||
|
||||
SYSINIT(atadev, SI_SUB_DRIVERS, SI_ORDER_SECOND, ata_init, NULL)
|
||||
static void
|
||||
ata_uninit(void)
|
||||
{
|
||||
uma_zdestroy(ata_composite_zone);
|
||||
uma_zdestroy(ata_request_zone);
|
||||
}
|
||||
SYSUNINIT(ata_unregister, SI_SUB_DRIVERS, SI_ORDER_SECOND, ata_uninit, NULL);
|
||||
|
@ -475,10 +475,16 @@ void ata_generic_hw(struct ata_channel *ch);
|
||||
int ata_generic_command(struct ata_device *atadev, u_int8_t command, u_int64_t lba, u_int16_t count, u_int16_t feature);
|
||||
int ata_getparam(device_t parent, struct ata_device *atadev, u_int8_t command);
|
||||
|
||||
/* macros for alloc/free of ata_requests */
|
||||
extern uma_zone_t ata_zone;
|
||||
#define ata_alloc_request() uma_zalloc(ata_zone, M_NOWAIT | M_ZERO)
|
||||
#define ata_free_request(request) uma_zfree(ata_zone, request)
|
||||
/* macros for alloc/free of struct ata_request */
|
||||
extern uma_zone_t ata_request_zone;
|
||||
#define ata_alloc_request() uma_zalloc(ata_request_zone, M_NOWAIT | M_ZERO)
|
||||
#define ata_free_request(request) uma_zfree(ata_request_zone, request)
|
||||
|
||||
/* macros for alloc/free of struct ata_composite */
|
||||
extern uma_zone_t ata_composite_zone;
|
||||
#define ata_alloc_composite() uma_zalloc(ata_composite_zone, M_NOWAIT | M_ZERO)
|
||||
#define ata_free_composite(composite) uma_zfree(ata_composite_zone, composite)
|
||||
|
||||
MALLOC_DECLARE(M_ATA);
|
||||
|
||||
/* misc newbus defines */
|
||||
|
@ -381,8 +381,7 @@ ata_raid_strategy(struct bio *bp)
|
||||
|
||||
/* do we have a spare to rebuild on ? */
|
||||
if (rdp->disks[this].flags & AR_DF_SPARE) {
|
||||
if ((composite = malloc(sizeof(struct ata_composite),
|
||||
M_AR, M_NOWAIT | M_ZERO))) {
|
||||
if ((composite = ata_alloc_composite())) {
|
||||
if ((rebuild = ata_alloc_request())) {
|
||||
rdp->rebuild_lba = blk + chunk;
|
||||
bcopy(request, rebuild,
|
||||
@ -404,12 +403,13 @@ ata_raid_strategy(struct bio *bp)
|
||||
ata_raid_send_request(rebuild);
|
||||
}
|
||||
else {
|
||||
free(composite, M_AR);
|
||||
ata_free_composite(composite);
|
||||
printf("DOH! ata_alloc_request failed!\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
printf("DOH! composite malloc failed!\n");
|
||||
else {
|
||||
printf("DOH! ata_alloc_composite failed!\n");
|
||||
}
|
||||
}
|
||||
else if (rdp->disks[this].flags & AR_DF_ONLINE) {
|
||||
/*
|
||||
@ -441,9 +441,8 @@ ata_raid_strategy(struct bio *bp)
|
||||
struct ata_composite *composite;
|
||||
int this = drv + rdp->width;
|
||||
|
||||
if ((composite = malloc(sizeof(struct ata_composite),
|
||||
M_AR, M_NOWAIT | M_ZERO)) &&
|
||||
(mirror = ata_alloc_request())) {
|
||||
if ((composite = ata_alloc_composite())) {
|
||||
if ((mirror = ata_alloc_request())) {
|
||||
rdp->rebuild_lba = blk + chunk;
|
||||
bcopy(request, mirror, sizeof(struct ata_request));
|
||||
mirror->this = this;
|
||||
@ -460,6 +459,14 @@ ata_raid_strategy(struct bio *bp)
|
||||
ata_raid_send_request(mirror);
|
||||
rdp->disks[this].last_lba = bp->bio_pblkno + chunk;
|
||||
}
|
||||
else {
|
||||
ata_free_composite(composite);
|
||||
printf("DOH! ata_alloc_request failed!\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("DOH! ata_alloc_composite failed!\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
drv += rdp->width;
|
||||
@ -694,7 +701,7 @@ ata_raid_done(struct ata_request *request)
|
||||
}
|
||||
}
|
||||
mtx_destroy(&composite->lock);
|
||||
free(composite, M_AR);
|
||||
ata_free_composite(composite);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -2921,7 +2928,7 @@ ata_raid_init_request(struct ar_softc *rdp, struct bio *bio)
|
||||
|
||||
if (!(request = ata_alloc_request())) {
|
||||
printf("FAILURE - out of memory in ata_raid_init_request\n");
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
request->timeout = 5;
|
||||
request->retries = 2;
|
||||
|
Loading…
x
Reference in New Issue
Block a user