Some microoptimizations for da and ada drivers:
- Replace ordered_tag_count counter with single flag; - From da remove outstanding_cmds counter, duplicating pending_ccbs list; - From da_softc remove unused links field.
This commit is contained in:
parent
62940ea951
commit
030844d1e7
@ -80,7 +80,7 @@ typedef enum {
|
||||
ADA_FLAG_CAN_NCQ = 0x0008,
|
||||
ADA_FLAG_CAN_DMA = 0x0010,
|
||||
ADA_FLAG_NEED_OTAG = 0x0020,
|
||||
ADA_FLAG_WENT_IDLE = 0x0040,
|
||||
ADA_FLAG_WAS_OTAG = 0x0040,
|
||||
ADA_FLAG_CAN_TRIM = 0x0080,
|
||||
ADA_FLAG_OPEN = 0x0100,
|
||||
ADA_FLAG_SCTX_INIT = 0x0200,
|
||||
@ -130,12 +130,12 @@ struct trim_request {
|
||||
struct ada_softc {
|
||||
struct bio_queue_head bio_queue;
|
||||
struct bio_queue_head trim_queue;
|
||||
int outstanding_cmds; /* Number of active commands */
|
||||
int refcount; /* Active xpt_action() calls */
|
||||
ada_state state;
|
||||
ada_flags flags;
|
||||
ada_flags flags;
|
||||
ada_quirks quirks;
|
||||
int sort_io_queue;
|
||||
int ordered_tag_count;
|
||||
int outstanding_cmds;
|
||||
int trim_max_ranges;
|
||||
int trim_running;
|
||||
int read_ahead;
|
||||
@ -153,7 +153,6 @@ struct ada_softc {
|
||||
struct sysctl_oid *sysctl_tree;
|
||||
struct callout sendordered_c;
|
||||
struct trim_request trim_req;
|
||||
int refcount;
|
||||
};
|
||||
|
||||
struct ada_quirk_entry {
|
||||
@ -1489,7 +1488,7 @@ adastart(struct cam_periph *periph, union ccb *start_ccb)
|
||||
if ((bp->bio_flags & BIO_ORDERED) != 0
|
||||
|| (softc->flags & ADA_FLAG_NEED_OTAG) != 0) {
|
||||
softc->flags &= ~ADA_FLAG_NEED_OTAG;
|
||||
softc->ordered_tag_count++;
|
||||
softc->flags |= ADA_FLAG_WAS_OTAG;
|
||||
tag_code = 0;
|
||||
} else {
|
||||
tag_code = 1;
|
||||
@ -1743,7 +1742,7 @@ adadone(struct cam_periph *periph, union ccb *done_ccb)
|
||||
}
|
||||
softc->outstanding_cmds--;
|
||||
if (softc->outstanding_cmds == 0)
|
||||
softc->flags |= ADA_FLAG_WENT_IDLE;
|
||||
softc->flags |= ADA_FLAG_WAS_OTAG;
|
||||
xpt_release_ccb(done_ccb);
|
||||
if (state == ADA_CCB_TRIM) {
|
||||
TAILQ_HEAD(, bio) queue;
|
||||
@ -1905,14 +1904,11 @@ adasendorderedtag(void *arg)
|
||||
struct ada_softc *softc = arg;
|
||||
|
||||
if (ada_send_ordered) {
|
||||
if ((softc->ordered_tag_count == 0)
|
||||
&& ((softc->flags & ADA_FLAG_WENT_IDLE) == 0)) {
|
||||
softc->flags |= ADA_FLAG_NEED_OTAG;
|
||||
if (softc->outstanding_cmds > 0) {
|
||||
if ((softc->flags & ADA_FLAG_WAS_OTAG) == 0)
|
||||
softc->flags |= ADA_FLAG_NEED_OTAG;
|
||||
softc->flags &= ~ADA_FLAG_WAS_OTAG;
|
||||
}
|
||||
if (softc->outstanding_cmds > 0)
|
||||
softc->flags &= ~ADA_FLAG_WENT_IDLE;
|
||||
|
||||
softc->ordered_tag_count = 0;
|
||||
}
|
||||
/* Queue us up again */
|
||||
callout_reset(&softc->sendordered_c,
|
||||
|
@ -84,7 +84,7 @@ typedef enum {
|
||||
DA_FLAG_PACK_LOCKED = 0x004,
|
||||
DA_FLAG_PACK_REMOVABLE = 0x008,
|
||||
DA_FLAG_NEED_OTAG = 0x020,
|
||||
DA_FLAG_WENT_IDLE = 0x040,
|
||||
DA_FLAG_WAS_OTAG = 0x040,
|
||||
DA_FLAG_RETRY_UA = 0x080,
|
||||
DA_FLAG_OPEN = 0x100,
|
||||
DA_FLAG_SCTX_INIT = 0x200,
|
||||
@ -198,19 +198,17 @@ struct da_softc {
|
||||
struct bio_queue_head bio_queue;
|
||||
struct bio_queue_head delete_queue;
|
||||
struct bio_queue_head delete_run_queue;
|
||||
SLIST_ENTRY(da_softc) links;
|
||||
LIST_HEAD(, ccb_hdr) pending_ccbs;
|
||||
int tur; /* TEST UNIT READY should be sent */
|
||||
int refcount; /* Active xpt_action() calls */
|
||||
da_state state;
|
||||
da_flags flags;
|
||||
da_quirks quirks;
|
||||
int sort_io_queue;
|
||||
int minimum_cmd_size;
|
||||
int error_inject;
|
||||
int ordered_tag_count;
|
||||
int outstanding_cmds;
|
||||
int trim_max_ranges;
|
||||
int delete_running;
|
||||
int tur;
|
||||
int delete_available; /* Delete methods possibly available */
|
||||
uint32_t unmap_max_ranges;
|
||||
uint32_t unmap_max_lba;
|
||||
@ -228,7 +226,6 @@ struct da_softc {
|
||||
uint8_t unmap_buf[UNMAP_BUF_SIZE];
|
||||
struct scsi_read_capacity_data_long rcaplong;
|
||||
struct callout mediapoll_c;
|
||||
int refcount;
|
||||
};
|
||||
|
||||
#define dadeleteflag(softc, delete_method, enable) \
|
||||
@ -2244,7 +2241,7 @@ dastart(struct cam_periph *periph, union ccb *start_ccb)
|
||||
if ((bp->bio_flags & BIO_ORDERED) != 0 ||
|
||||
(softc->flags & DA_FLAG_NEED_OTAG) != 0) {
|
||||
softc->flags &= ~DA_FLAG_NEED_OTAG;
|
||||
softc->ordered_tag_count++;
|
||||
softc->flags |= DA_FLAG_WAS_OTAG;
|
||||
tag_code = MSG_ORDERED_Q_TAG;
|
||||
} else {
|
||||
tag_code = MSG_SIMPLE_Q_TAG;
|
||||
@ -2297,13 +2294,8 @@ dastart(struct cam_periph *periph, union ccb *start_ccb)
|
||||
start_ccb->ccb_h.flags |= CAM_UNLOCKED;
|
||||
|
||||
out:
|
||||
/*
|
||||
* Block out any asynchronous callbacks
|
||||
* while we touch the pending ccb list.
|
||||
*/
|
||||
LIST_INSERT_HEAD(&softc->pending_ccbs,
|
||||
&start_ccb->ccb_h, periph_links.le);
|
||||
softc->outstanding_cmds++;
|
||||
|
||||
/* We expect a unit attention from this device */
|
||||
if ((softc->flags & DA_FLAG_RETRY_UA) != 0) {
|
||||
@ -2969,14 +2961,9 @@ dadone(struct cam_periph *periph, union ccb *done_ccb)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Block out any asynchronous callbacks
|
||||
* while we touch the pending ccb list.
|
||||
*/
|
||||
LIST_REMOVE(&done_ccb->ccb_h, periph_links.le);
|
||||
softc->outstanding_cmds--;
|
||||
if (softc->outstanding_cmds == 0)
|
||||
softc->flags |= DA_FLAG_WENT_IDLE;
|
||||
if (LIST_EMPTY(&softc->pending_ccbs))
|
||||
softc->flags |= DA_FLAG_WAS_OTAG;
|
||||
|
||||
xpt_release_ccb(done_ccb);
|
||||
if (state == DA_CCB_DELETE) {
|
||||
@ -3583,7 +3570,7 @@ damediapoll(void *arg)
|
||||
struct cam_periph *periph = arg;
|
||||
struct da_softc *softc = periph->softc;
|
||||
|
||||
if (!softc->tur && softc->outstanding_cmds == 0) {
|
||||
if (!softc->tur && LIST_EMPTY(&softc->pending_ccbs)) {
|
||||
if (cam_periph_acquire(periph) == CAM_REQ_CMP) {
|
||||
softc->tur = 1;
|
||||
daschedule(periph);
|
||||
@ -3755,14 +3742,11 @@ dasendorderedtag(void *arg)
|
||||
struct da_softc *softc = arg;
|
||||
|
||||
if (da_send_ordered) {
|
||||
if ((softc->ordered_tag_count == 0)
|
||||
&& ((softc->flags & DA_FLAG_WENT_IDLE) == 0)) {
|
||||
softc->flags |= DA_FLAG_NEED_OTAG;
|
||||
if (!LIST_EMPTY(&softc->pending_ccbs)) {
|
||||
if ((softc->flags & DA_FLAG_WAS_OTAG) == 0)
|
||||
softc->flags |= DA_FLAG_NEED_OTAG;
|
||||
softc->flags &= ~DA_FLAG_WAS_OTAG;
|
||||
}
|
||||
if (softc->outstanding_cmds > 0)
|
||||
softc->flags &= ~DA_FLAG_WENT_IDLE;
|
||||
|
||||
softc->ordered_tag_count = 0;
|
||||
}
|
||||
/* Queue us up again */
|
||||
callout_reset(&softc->sendordered_c,
|
||||
|
Loading…
Reference in New Issue
Block a user