WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [linux-2.6.18-xen] pvSCSI: Fix some aspects of attach/de

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [linux-2.6.18-xen] pvSCSI: Fix some aspects of attach/detach functionality
From: "Xen patchbot-linux-2.6.18-xen" <patchbot-linux-2.6.18-xen@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 08 Jul 2008 22:30:15 -0700
Delivery-date: Tue, 08 Jul 2008 22:30:34 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1215505834 -3600
# Node ID 132bae41625ff2bb9f48c65bf643c462093d455d
# Parent  92247f7e5d8ab7f64c7e0ed9c1c8afe8a9abf46d
pvSCSI: Fix some aspects of attach/detach functionality

Signed-off-by: Tomonari Horikoshi <t.horikoshi@xxxxxxxxxxxxxx>
Signed-off-by: Jun Kamada <kama@xxxxxxxxxxxxxx>
---
 drivers/xen/scsiback/xenbus.c  |   97 ++++++++++++-----------------------------
 drivers/xen/scsifront/xenbus.c |   16 ++----
 2 files changed, 35 insertions(+), 78 deletions(-)

diff -r 92247f7e5d8a -r 132bae41625f drivers/xen/scsiback/xenbus.c
--- a/drivers/xen/scsiback/xenbus.c     Tue Jul 08 09:29:42 2008 +0100
+++ b/drivers/xen/scsiback/xenbus.c     Tue Jul 08 09:30:34 2008 +0100
@@ -104,51 +104,23 @@ struct scsi_device *scsiback_get_scsi_de
        if (IS_ERR(shost)) {
                printk(KERN_ERR "scsiback: host%d doesn't exist.\n",
                        phy->hst);
-               goto invald_value;
+               return NULL;
        }
        sdev   = scsi_device_lookup(shost, phy->chn, phy->tgt, phy->lun);
        if (!sdev) {
                printk(KERN_ERR "scsiback: %d:%d:%d:%d doesn't exist.\n",
                        phy->hst, phy->chn, phy->tgt, phy->lun);
-               goto invald_value;
+               scsi_host_put(shost);
+               return NULL;
        }
 
        scsi_host_put(shost);
-invald_value:
        return (sdev);
 }
 
 #define VSCSIBACK_OP_ADD_OR_DEL_LUN    1
 #define VSCSIBACK_OP_UPDATEDEV_STATE   2
 
-static int scsiback_change_device_state(struct xenbus_device *dev,
-                       char *state_path, enum xenbus_state set_state)
-{
-       struct xenbus_transaction tr;
-       int err;
-       
-       do {
-               err = xenbus_transaction_start(&tr);
-               if (err != 0) { 
-                       printk(KERN_ERR "scsiback: transaction start failed\n");
-                       return err;
-               }
-               err = xenbus_printf(tr, dev->nodename, state_path, 
-                                   "%d", set_state);
-               if (err != 0) {
-                       printk(KERN_ERR "scsiback: xenbus_printf failed\n");
-                       xenbus_transaction_end(tr, 1);
-                       return err;
-               }
-               err = xenbus_transaction_end(tr, 0);
-       } while (err == -EAGAIN);
-       
-       if (err != 0) {
-               printk(KERN_ERR "scsiback: failed to end %s.\n", __FUNCTION__);
-               return err;
-       }
-       return 0;       
-}
 
 static void scsiback_do_lun_hotplug(struct backend_info *be, int op)
 {
@@ -160,8 +132,6 @@ static void scsiback_do_lun_hotplug(stru
        unsigned int dir_n = 0;
        struct xenbus_device *dev = be->dev;
        struct scsi_device *sdev;
-       struct xenbus_transaction xbt;
-
 
        dir = xenbus_directory(XBT_NIL, dev->nodename, "vscsi-devs", &dir_n);
        if (IS_ERR(dir))
@@ -181,8 +151,8 @@ static void scsiback_do_lun_hotplug(stru
                err = xenbus_scanf(XBT_NIL, dev->nodename, str,
                        "%u:%u:%u:%u", &phy.hst, &phy.chn, &phy.tgt, &phy.lun);
                if (XENBUS_EXIST_ERR(err)) {
-                       xenbus_printf(xbt, dev->nodename, state_str,
-                                       "%d", XenbusStateClosing);
+                       xenbus_printf(XBT_NIL, dev->nodename, state_str,
+                                       "%d", XenbusStateClosed);
                        continue;
                }
 
@@ -191,8 +161,8 @@ static void scsiback_do_lun_hotplug(stru
                err = xenbus_scanf(XBT_NIL, dev->nodename, str,
                        "%u:%u:%u:%u", &vir.hst, &vir.chn, &vir.tgt, &vir.lun);
                if (XENBUS_EXIST_ERR(err)) {
-                       xenbus_printf(xbt, dev->nodename, state_str,
-                                       "%d", XenbusStateClosing);
+                       xenbus_printf(XBT_NIL, dev->nodename, state_str,
+                                       "%d", XenbusStateClosed);
                        continue;
                }
 
@@ -200,36 +170,30 @@ static void scsiback_do_lun_hotplug(stru
                case VSCSIBACK_OP_ADD_OR_DEL_LUN:
                        if (device_state == XenbusStateInitialising) {
                                sdev = scsiback_get_scsi_device(&phy);
-                               if (!sdev) {
-                                       err = scsiback_change_device_state(dev,
-                                               state_str, XenbusStateClosing);
-                                       if (err)
-                                               goto fail;
-                               } else {
+                               if (!sdev)
+                                       xenbus_printf(XBT_NIL, dev->nodename, 
state_str, 
+                                                           "%d", 
XenbusStateClosed);
+                               else {
                                        err = 
scsiback_add_translation_entry(be->info, sdev, &vir);
                                        if (!err) {
-                                               err = 
scsiback_change_device_state(dev,
-                                                       state_str, 
XenbusStateInitialised);
-                                               if (err)
-                                                       goto fail;
+                                               if (xenbus_printf(XBT_NIL, 
dev->nodename, state_str, 
+                                                                   "%d", 
XenbusStateInitialised)) {
+                                                       printk(KERN_ERR 
"scsiback: xenbus_printf error %s\n", state_str);
+                                                       
scsiback_del_translation_entry(be->info, &vir);
+                                               }
                                        } else {
-                                               err = 
scsiback_change_device_state(dev,
-                                                       state_str, 
XenbusStateClosing);
-                                               if (err)
-                                                       goto fail;
+                                               scsi_device_put(sdev);
+                                               xenbus_printf(XBT_NIL, 
dev->nodename, state_str, 
+                                                                   "%d", 
XenbusStateClosed);
                                        }
                                }
                        }
 
                        if (device_state == XenbusStateClosing) {
-                               err = scsiback_del_translation_entry(be->info, 
&vir);
-                               if (err)
-                                       goto fail;
-                               else {
-                                       err = scsiback_change_device_state(dev,
-                                               state_str, XenbusStateClosed);
-                                       if (err)
-                                               goto fail;
+                               if (!scsiback_del_translation_entry(be->info, 
&vir)) {
+                                       if (xenbus_printf(XBT_NIL, 
dev->nodename, state_str, 
+                                                           "%d", 
XenbusStateClosed))
+                                               printk(KERN_ERR "scsiback: 
xenbus_printf error %s\n", state_str);
                                }
                        }
                        break;
@@ -237,10 +201,13 @@ static void scsiback_do_lun_hotplug(stru
                case VSCSIBACK_OP_UPDATEDEV_STATE:
                        if (device_state == XenbusStateInitialised) {
                                /* modify vscsi-devs/dev-x/state */
-                               err = scsiback_change_device_state(dev,
-                                       state_str, XenbusStateConnected);
-                               if (err)
-                                       goto fail;
+                               if (xenbus_printf(XBT_NIL, dev->nodename, 
state_str, 
+                                                   "%d", 
XenbusStateConnected)) {
+                                       printk(KERN_ERR "scsiback: 
xenbus_printf error %s\n", state_str);
+                                       
scsiback_del_translation_entry(be->info, &vir);
+                                       xenbus_printf(XBT_NIL, dev->nodename, 
state_str, 
+                                                           "%d", 
XenbusStateClosed);
+                               }
                        }
                        break;
                /*When it is necessary, processing is added here.*/
@@ -251,10 +218,6 @@ static void scsiback_do_lun_hotplug(stru
 
        kfree(dir);
        return ;
-fail :
-       kfree(dir);
-       xenbus_dev_fatal(dev, err, "read or write %s ", str);
-       return;
 }
 
 
diff -r 92247f7e5d8a -r 132bae41625f drivers/xen/scsifront/xenbus.c
--- a/drivers/xen/scsifront/xenbus.c    Tue Jul 08 09:29:42 2008 +0100
+++ b/drivers/xen/scsifront/xenbus.c    Tue Jul 08 09:30:34 2008 +0100
@@ -100,13 +100,13 @@ static int scsifront_alloc_ring(struct v
 
        if (err <= 0) {
                xenbus_dev_fatal(dev, err, "bind_listening_port_to_irqhandler");
-               goto fail;
+               goto free_sring;
        }
        info->irq = err;
 
        return 0;
-fail:
-       /* free resource */
+
+/* free resource */
 free_sring:
        scsifront_free(info);
 
@@ -298,14 +298,14 @@ static void scsifront_do_lun_hotplug(str
                err = xenbus_scanf(XBT_NIL, dev->otherend, str, "%u",
                        &device_state);
                if (XENBUS_EXIST_ERR(err))
-                       goto fail;
+                       continue;
                
                /* virtual SCSI device */
                snprintf(str, sizeof(str), "vscsi-devs/%s/v-dev", dir[i]);
                err = xenbus_scanf(XBT_NIL, dev->otherend, str,
                        "%u:%u:%u:%u", &hst, &chn, &tgt, &lun);
                if (XENBUS_EXIST_ERR(err))
-                       goto fail;
+                       continue;
 
                /* front device state path */
                snprintf(state_str, sizeof(state_str), "vscsi-devs/%s/state", 
dir[i]);
@@ -338,17 +338,11 @@ static void scsifront_do_lun_hotplug(str
                        }
                        break;
                default:
-                       goto fail;
                        break;
                }
        }
        
        kfree(dir);
-       return;
-
-fail:
-       kfree(dir);
-       xenbus_dev_fatal(dev, err, "read or write %s ", str);
        return;
 }
 

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [linux-2.6.18-xen] pvSCSI: Fix some aspects of attach/detach functionality, Xen patchbot-linux-2.6.18-xen <=