[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [linux-2.6.18-xen] scsifront: cleanup


  • To: xen-changelog@xxxxxxxxxxxxxxxxxxx
  • From: Xen patchbot-linux-2.6.18-xen <patchbot@xxxxxxx>
  • Date: Wed, 14 Nov 2012 11:22:03 +0000
  • Delivery-date: Wed, 14 Nov 2012 11:23:42 +0000
  • List-id: "Change log for Mercurial \(receive only\)" <xen-changelog.lists.xen.org>

# HG changeset patch
# User Jan Beulich <jbeulich@xxxxxxxx>
# Date 1352891404 -3600
# Node ID f09889eaf6527f4ea0cc922e7d02da3bb7f919b5
# Parent  171f57e6ad50fb71354b5b7f2177394102ca02fe
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

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---


diff -r 171f57e6ad50 -r f09889eaf652 drivers/xen/scsifront/common.h
--- a/drivers/xen/scsifront/common.h    Mon Nov 12 09:40:45 2012 +0100
+++ b/drivers/xen/scsifront/common.h    Wed Nov 14 12:10:04 2012 +0100
@@ -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];
 };
 
diff -r 171f57e6ad50 -r f09889eaf652 drivers/xen/scsifront/scsifront.c
--- a/drivers/xen/scsifront/scsifront.c Mon Nov 12 09:40:45 2012 +0100
+++ b/drivers/xen/scsifront/scsifront.c Wed Nov 14 12:10:04 2012 +0100
@@ -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) {
diff -r 171f57e6ad50 -r f09889eaf652 drivers/xen/scsifront/xenbus.c
--- a/drivers/xen/scsifront/xenbus.c    Mon Nov 12 09:40:45 2012 +0100
+++ b/drivers/xen/scsifront/xenbus.c    Wed Nov 14 12:10:04 2012 +0100
@@ -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)

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.