[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH] linux-2.6.18/scsifront: cleanup
- properly type the shadow field tracking the active command - as a result, there's no need to also track the data direction - in turn, re-arranging shadow fields reduces the size of the structure on 64-bit architectures - there's no point in map_data_for_request() failing if there are no grant references available when none are needed anyway - don't redundantly include linux/version.h --- a/drivers/xen/scsifront/common.h +++ b/drivers/xen/scsifront/common.h @@ -80,21 +80,17 @@ struct vscsifrnt_shadow { * VSCSIIF_ACT_SCSI_CDB or VSCSIIF_ACT_SCSI_RESET */ unsigned char act; + /* Number of pieces of scatter-gather */ + unsigned int nr_segments; + /* do reset function */ wait_queue_head_t wq_reset; /* reset work queue */ int wait_reset; /* reset work queue condition */ int32_t rslt_reset; /* reset response status */ /* (SUCESS or FAILED) */ - /* for DMA_TO_DEVICE(1), DMA_FROM_DEVICE(2), DMA_NONE(3) - requests */ - unsigned int sc_data_direction; - - /* Number of pieces of scatter-gather */ - unsigned int nr_segments; - /* requested struct scsi_cmnd is stored from kernel */ - unsigned long req_scsi_cmnd; + struct scsi_cmnd *sc; int gref[VSCSIIF_SG_TABLESIZE]; }; --- a/drivers/xen/scsifront/scsifront.c +++ b/drivers/xen/scsifront/scsifront.c @@ -28,8 +28,6 @@ * IN THE SOFTWARE. */ - -#include <linux/version.h> #include "common.h" static int get_id_from_freelist(struct vscsifrnt_info *info) @@ -57,8 +55,8 @@ static void add_id_to_freelist(struct vs spin_lock_irqsave(&info->shadow_lock, flags); - info->shadow[id].next_free = info->shadow_free; - info->shadow[id].req_scsi_cmnd = 0; + info->shadow[id].next_free = info->shadow_free; + info->shadow[id].sc = NULL; info->shadow_free = id; spin_unlock_irqrestore(&info->shadow_lock, flags); @@ -111,7 +109,7 @@ static void scsifront_gnttab_done(struct { int i; - if (s->sc_data_direction == DMA_NONE) + if (s->sc->sc_data_direction == DMA_NONE) return; if (s->nr_segments) { @@ -138,7 +136,7 @@ static void scsifront_cdb_cmd_done(struc uint8_t sense_len; id = ring_res->rqid; - sc = (struct scsi_cmnd *)info->shadow[id].req_scsi_cmnd; + sc = info->shadow[id].sc; if (sc == NULL) BUG(); @@ -252,7 +250,7 @@ static int map_data_for_request(struct v unsigned long buffer_pfn; unsigned int data_len = 0; - if (sc->sc_data_direction == DMA_NONE) + if (sc->sc_data_direction == DMA_NONE || !sc->request_bufflen) return 0; err = gnttab_alloc_grant_references(VSCSIIF_SG_TABLESIZE, &gref_head); @@ -300,7 +298,7 @@ static int map_data_for_request(struct v ref_cnt++; } } - } else if (sc->request_bufflen) { + } else { unsigned long end = ((unsigned long)sc->request_buffer + sc->request_bufflen + PAGE_SIZE - 1) >> PAGE_SHIFT; unsigned long start = (unsigned long)sc->request_buffer >> PAGE_SHIFT; @@ -388,9 +386,8 @@ static int scsifront_queuecommand(struct ring_req->sc_data_direction = (uint8_t)sc->sc_data_direction; ring_req->timeout_per_command = (sc->timeout_per_command / HZ); - info->shadow[rqid].req_scsi_cmnd = (unsigned long)sc; - info->shadow[rqid].sc_data_direction = sc->sc_data_direction; - info->shadow[rqid].act = ring_req->act; + info->shadow[rqid].sc = sc; + info->shadow[rqid].act = VSCSIIF_ACT_SCSI_CDB; ref_cnt = map_data_for_request(info, sc, ring_req, rqid); if (ref_cnt < 0) { --- a/drivers/xen/scsifront/xenbus.c +++ b/drivers/xen/scsifront/xenbus.c @@ -33,7 +33,6 @@ * 2010, Samuel Kvasnica, IMS Nanofabrication AG */ -#include <linux/version.h> #include "common.h" #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11) Attachment:
xen-scsifront-cleanup.patch _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |