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

[Xen-changelog] [linux-2.6.18-xen] blktap: simplify kthread name generation


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

# HG changeset patch
# User Jan Beulich <jbeulich@xxxxxxxx>
# Date 1433254059 -7200
# Node ID aba765eb6c4449c1d8763071e63555f12c0a5d71
# Parent  bad892a4682644c989bd33b8534459814771db6a
blktap: simplify kthread name generation

kthread_run() taking a format string it can quite well do all the
formatting itself, at once allowing us to eliminate the theoretical
risk of unintentionally passing a % character in the name.

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


diff -r bad892a46826 -r aba765eb6c44 drivers/xen/blktap/xenbus.c
--- a/drivers/xen/blktap/xenbus.c       Tue Jun 02 16:06:39 2015 +0200
+++ b/drivers/xen/blktap/xenbus.c       Tue Jun 02 16:07:39 2015 +0200
@@ -92,24 +92,16 @@ static long get_id(const char *str)
         return simple_strtol(num, NULL, 10);
 }                              
 
-static int blktap_name(blkif_t *blkif, char *buf)
+static char *blktap_name(const struct xenbus_device *dev)
 {
        char *devpath, *devname;
-       struct xenbus_device *dev = blkif->be->dev;
 
        devpath = xenbus_read(XBT_NIL, dev->nodename, "dev", NULL);
-       if (IS_ERR(devpath)) 
-               return PTR_ERR(devpath);
        
-       if ((devname = strstr(devpath, "/dev/")) != NULL)
-               devname += strlen("/dev/");
-       else
-               devname  = devpath;
+       if (!IS_ERR(devpath) && (devname = strstr(devpath, "/dev/")) != NULL)
+               return devname + strlen("/dev/");
 
-       snprintf(buf, TASK_COMM_LEN, "blktap.%d.%s", blkif->domid, devname);
-       kfree(devpath);
-       
-       return 0;
+       return devpath;
 }
 
 /****************************************************************
@@ -206,7 +198,7 @@ static int blktap_remove(struct xenbus_d
 static void tap_update_blkif_status(blkif_t *blkif)
 { 
        int err;
-       char name[TASK_COMM_LEN];
+       char *devname;
 
        /* Not ready to connect? */
        if(!blkif->irq || !blkif->sectors) {
@@ -222,12 +214,6 @@ static void tap_update_blkif_status(blki
        if (blkif->be->dev->state != XenbusStateConnected)
                return;
 
-       err = blktap_name(blkif, name);
-       if (err) {
-               xenbus_dev_error(blkif->be->dev, err, "get blktap dev name");
-               return;
-       }
-
        if (!blkif->be->group_added) {
                err = xentap_sysfs_addif(blkif->be->dev);
                if (err) {
@@ -237,16 +223,25 @@ static void tap_update_blkif_status(blki
                }
        }
 
-       blkif->xenblkd = kthread_run(tap_blkif_schedule, blkif, name);
+       devname = blktap_name(blkif->be->dev);
+       if (IS_ERR(devname)) {
+               xenbus_dev_error(blkif->be->dev, PTR_ERR(devname),
+                                "get blktap dev name");
+               return;
+       }
+
+       blkif->xenblkd = kthread_run(tap_blkif_schedule, blkif,
+                                    "blktap.%d.%s", blkif->domid, devname);
        if (IS_ERR(blkif->xenblkd)) {
                err = PTR_ERR(blkif->xenblkd);
                blkif->xenblkd = NULL;
                xenbus_dev_fatal(blkif->be->dev, err, "start xenblkd");
-               WPRINTK("Error starting thread %s\n", name);
+               WPRINTK("Error starting d%d:%s thread\n",
+                       blkif->domid, devname);
        } else
                DPRINTK("Thread started for domid %d, connected disk %d\n",
                        blkif->domid, blkif->dev_num);
-
+       kfree(devname);
 }
 
 /**

_______________________________________________
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®.