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

[Xen-changelog] [linux-2.6.18-xen] blkback: 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:02 +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 1433253999 -7200
# Node ID bad892a4682644c989bd33b8534459814771db6a
# Parent  43dfca4e7fa04cfd90a8c195d592c7ab43d54b2b
blkback: 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.

Also shorten the static part of the name.

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


diff -r 43dfca4e7fa0 -r bad892a46826 drivers/xen/blkback/xenbus.c
--- a/drivers/xen/blkback/xenbus.c      Tue Jun 02 16:03:26 2015 +0200
+++ b/drivers/xen/blkback/xenbus.c      Tue Jun 02 16:06:39 2015 +0200
@@ -34,30 +34,21 @@ static int connect_ring(struct backend_i
 static void backend_changed(struct xenbus_watch *, const char **,
                            unsigned int);
 
-static int blkback_name(blkif_t *blkif, char *buf)
+static char *blkback_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, "blkback.%d.%s", blkif->domid, devname);
-       kfree(devpath);
-       
-       return 0;
+       return devpath;
 }
 
 static void update_blkif_status(blkif_t *blkif)
 { 
        int err;
-       char name[TASK_COMM_LEN];
+       char *devname;
 
        /* Not ready to connect? */
        if (!blkif->irq || !blkif->vbd.bdev)
@@ -72,12 +63,6 @@ static void update_blkif_status(blkif_t 
        if (blkif->be->dev->state != XenbusStateConnected)
                return;
 
-       err = blkback_name(blkif, name);
-       if (err) {
-               xenbus_dev_error(blkif->be->dev, err, "get blkback dev name");
-               return;
-       }
-
        err = filemap_write_and_wait(blkif->vbd.bdev->bd_inode->i_mapping);
        if (err) {
                xenbus_dev_error(blkif->be->dev, err, "block flush");
@@ -85,7 +70,16 @@ static void update_blkif_status(blkif_t 
        }
        invalidate_inode_pages2(blkif->vbd.bdev->bd_inode->i_mapping);
 
-       blkif->xenblkd = kthread_run(blkif_schedule, blkif, name);
+       devname = blkback_name(blkif->be->dev);
+       if (IS_ERR(devname)) {
+               xenbus_dev_error(blkif->be->dev, PTR_ERR(devname),
+                                "get blkback dev name");
+               return;
+       }
+
+       blkif->xenblkd = kthread_run(blkif_schedule, blkif,
+                                    "blkbk.%d.%s", blkif->domid, devname);
+       kfree(devname);
        if (IS_ERR(blkif->xenblkd)) {
                err = PTR_ERR(blkif->xenblkd);
                blkif->xenblkd = NULL;

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