aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/xen
diff options
context:
space:
mode:
authorTao Chen <boby.chen@huawei.com>2015-03-10 16:49:18 -0400
committerDavid Vrabel <david.vrabel@citrix.com>2015-03-16 10:49:15 -0400
commit785748788bafb1f286a73195c2c43ad3cda5234d (patch)
tree87fd5d3b2f49a238625da58ef3f46db473431390 /drivers/xen
parentebfe79a7c85c171def09ff86f6fdea254a51d6c9 (diff)
xen-scsiback: define a pr_fmt macro with xen-pvscsi
Add the {xen-pvscsi: } prefix in pr_fmt and remove DPRINTK, then replace all DPRINTK with pr_debug. Also fixed up some comments just as eliminate redundant whitespace and format the code. These will make the code easier to read. Signed-off-by: Tao Chen <boby.chen@huawei.com> Reviewed-by: Juergen Gross <jgross@suse.com> Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Diffstat (limited to 'drivers/xen')
-rw-r--r--drivers/xen/xen-scsiback.c75
1 files changed, 36 insertions, 39 deletions
diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c
index 9faca6a60bb0..d0b0bc549355 100644
--- a/drivers/xen/xen-scsiback.c
+++ b/drivers/xen/xen-scsiback.c
@@ -31,6 +31,8 @@
31 * IN THE SOFTWARE. 31 * IN THE SOFTWARE.
32 */ 32 */
33 33
34#define pr_fmt(fmt) "xen-pvscsi: " fmt
35
34#include <stdarg.h> 36#include <stdarg.h>
35 37
36#include <linux/module.h> 38#include <linux/module.h>
@@ -69,9 +71,6 @@
69#include <xen/interface/grant_table.h> 71#include <xen/interface/grant_table.h>
70#include <xen/interface/io/vscsiif.h> 72#include <xen/interface/io/vscsiif.h>
71 73
72#define DPRINTK(_f, _a...) \
73 pr_debug("(file=%s, line=%d) " _f, __FILE__ , __LINE__ , ## _a)
74
75#define VSCSI_VERSION "v0.1" 74#define VSCSI_VERSION "v0.1"
76#define VSCSI_NAMELEN 32 75#define VSCSI_NAMELEN 32
77 76
@@ -271,7 +270,7 @@ static void scsiback_print_status(char *sense_buffer, int errors,
271{ 270{
272 struct scsiback_tpg *tpg = pending_req->v2p->tpg; 271 struct scsiback_tpg *tpg = pending_req->v2p->tpg;
273 272
274 pr_err("xen-pvscsi[%s:%d] cmnd[0]=%02x -> st=%02x msg=%02x host=%02x drv=%02x\n", 273 pr_err("[%s:%d] cmnd[0]=%02x -> st=%02x msg=%02x host=%02x drv=%02x\n",
275 tpg->tport->tport_name, pending_req->v2p->lun, 274 tpg->tport->tport_name, pending_req->v2p->lun,
276 pending_req->cmnd[0], status_byte(errors), msg_byte(errors), 275 pending_req->cmnd[0], status_byte(errors), msg_byte(errors),
277 host_byte(errors), driver_byte(errors)); 276 host_byte(errors), driver_byte(errors));
@@ -427,7 +426,7 @@ static int scsiback_gnttab_data_map_batch(struct gnttab_map_grant_ref *map,
427 BUG_ON(err); 426 BUG_ON(err);
428 for (i = 0; i < cnt; i++) { 427 for (i = 0; i < cnt; i++) {
429 if (unlikely(map[i].status != GNTST_okay)) { 428 if (unlikely(map[i].status != GNTST_okay)) {
430 pr_err("xen-pvscsi: invalid buffer -- could not remap it\n"); 429 pr_err("invalid buffer -- could not remap it\n");
431 map[i].handle = SCSIBACK_INVALID_HANDLE; 430 map[i].handle = SCSIBACK_INVALID_HANDLE;
432 err = -ENOMEM; 431 err = -ENOMEM;
433 } else { 432 } else {
@@ -449,7 +448,7 @@ static int scsiback_gnttab_data_map_list(struct vscsibk_pend *pending_req,
449 for (i = 0; i < cnt; i++) { 448 for (i = 0; i < cnt; i++) {
450 if (get_free_page(pg + mapcount)) { 449 if (get_free_page(pg + mapcount)) {
451 put_free_pages(pg, mapcount); 450 put_free_pages(pg, mapcount);
452 pr_err("xen-pvscsi: no grant page\n"); 451 pr_err("no grant page\n");
453 return -ENOMEM; 452 return -ENOMEM;
454 } 453 }
455 gnttab_set_map_op(&map[mapcount], vaddr_page(pg[mapcount]), 454 gnttab_set_map_op(&map[mapcount], vaddr_page(pg[mapcount]),
@@ -492,7 +491,7 @@ static int scsiback_gnttab_data_map(struct vscsiif_request *ring_req,
492 return 0; 491 return 0;
493 492
494 if (nr_segments > VSCSIIF_SG_TABLESIZE) { 493 if (nr_segments > VSCSIIF_SG_TABLESIZE) {
495 DPRINTK("xen-pvscsi: invalid parameter nr_seg = %d\n", 494 pr_debug("invalid parameter nr_seg = %d\n",
496 ring_req->nr_segments); 495 ring_req->nr_segments);
497 return -EINVAL; 496 return -EINVAL;
498 } 497 }
@@ -516,13 +515,12 @@ static int scsiback_gnttab_data_map(struct vscsiif_request *ring_req,
516 nr_segments += n_segs; 515 nr_segments += n_segs;
517 } 516 }
518 if (nr_segments > SG_ALL) { 517 if (nr_segments > SG_ALL) {
519 DPRINTK("xen-pvscsi: invalid nr_seg = %d\n", 518 pr_debug("invalid nr_seg = %d\n", nr_segments);
520 nr_segments);
521 return -EINVAL; 519 return -EINVAL;
522 } 520 }
523 } 521 }
524 522
525 /* free of (sgl) in fast_flush_area()*/ 523 /* free of (sgl) in fast_flush_area() */
526 pending_req->sgl = kmalloc_array(nr_segments, 524 pending_req->sgl = kmalloc_array(nr_segments,
527 sizeof(struct scatterlist), GFP_KERNEL); 525 sizeof(struct scatterlist), GFP_KERNEL);
528 if (!pending_req->sgl) 526 if (!pending_req->sgl)
@@ -679,7 +677,8 @@ static int prepare_pending_reqs(struct vscsibk_info *info,
679 v2p = scsiback_do_translation(info, &vir); 677 v2p = scsiback_do_translation(info, &vir);
680 if (!v2p) { 678 if (!v2p) {
681 pending_req->v2p = NULL; 679 pending_req->v2p = NULL;
682 DPRINTK("xen-pvscsi: doesn't exist.\n"); 680 pr_debug("the v2p of (chn:%d, tgt:%d, lun:%d) doesn't exist.\n",
681 vir.chn, vir.tgt, vir.lun);
683 return -ENODEV; 682 return -ENODEV;
684 } 683 }
685 pending_req->v2p = v2p; 684 pending_req->v2p = v2p;
@@ -690,14 +689,14 @@ static int prepare_pending_reqs(struct vscsibk_info *info,
690 (pending_req->sc_data_direction != DMA_TO_DEVICE) && 689 (pending_req->sc_data_direction != DMA_TO_DEVICE) &&
691 (pending_req->sc_data_direction != DMA_FROM_DEVICE) && 690 (pending_req->sc_data_direction != DMA_FROM_DEVICE) &&
692 (pending_req->sc_data_direction != DMA_NONE)) { 691 (pending_req->sc_data_direction != DMA_NONE)) {
693 DPRINTK("xen-pvscsi: invalid parameter data_dir = %d\n", 692 pr_debug("invalid parameter data_dir = %d\n",
694 pending_req->sc_data_direction); 693 pending_req->sc_data_direction);
695 return -EINVAL; 694 return -EINVAL;
696 } 695 }
697 696
698 pending_req->cmd_len = ring_req->cmd_len; 697 pending_req->cmd_len = ring_req->cmd_len;
699 if (pending_req->cmd_len > VSCSIIF_MAX_COMMAND_SIZE) { 698 if (pending_req->cmd_len > VSCSIIF_MAX_COMMAND_SIZE) {
700 DPRINTK("xen-pvscsi: invalid parameter cmd_len = %d\n", 699 pr_debug("invalid parameter cmd_len = %d\n",
701 pending_req->cmd_len); 700 pending_req->cmd_len);
702 return -EINVAL; 701 return -EINVAL;
703 } 702 }
@@ -721,7 +720,7 @@ static int scsiback_do_cmd_fn(struct vscsibk_info *info)
721 720
722 if (RING_REQUEST_PROD_OVERFLOW(ring, rp)) { 721 if (RING_REQUEST_PROD_OVERFLOW(ring, rp)) {
723 rc = ring->rsp_prod_pvt; 722 rc = ring->rsp_prod_pvt;
724 pr_warn("xen-pvscsi: Dom%d provided bogus ring requests (%#x - %#x = %u). Halting ring processing\n", 723 pr_warn("Dom%d provided bogus ring requests (%#x - %#x = %u). Halting ring processing\n",
725 info->domid, rp, rc, rp - rc); 724 info->domid, rp, rc, rp - rc);
726 info->ring_error = 1; 725 info->ring_error = 1;
727 return 0; 726 return 0;
@@ -772,7 +771,7 @@ static int scsiback_do_cmd_fn(struct vscsibk_info *info)
772 scsiback_device_action(pending_req, TMR_LUN_RESET, 0); 771 scsiback_device_action(pending_req, TMR_LUN_RESET, 0);
773 break; 772 break;
774 default: 773 default:
775 pr_err_ratelimited("xen-pvscsi: invalid request\n"); 774 pr_err_ratelimited("invalid request\n");
776 scsiback_do_resp_with_sense(NULL, DRIVER_ERROR << 24, 775 scsiback_do_resp_with_sense(NULL, DRIVER_ERROR << 24,
777 0, pending_req); 776 0, pending_req);
778 kmem_cache_free(scsiback_cachep, pending_req); 777 kmem_cache_free(scsiback_cachep, pending_req);
@@ -874,14 +873,13 @@ static int scsiback_add_translation_entry(struct vscsibk_info *info,
874 873
875 lunp = strrchr(phy, ':'); 874 lunp = strrchr(phy, ':');
876 if (!lunp) { 875 if (!lunp) {
877 pr_err("xen-pvscsi: illegal format of physical device %s\n", 876 pr_err("illegal format of physical device %s\n", phy);
878 phy);
879 return -EINVAL; 877 return -EINVAL;
880 } 878 }
881 *lunp = 0; 879 *lunp = 0;
882 lunp++; 880 lunp++;
883 if (kstrtouint(lunp, 10, &lun) || lun >= TRANSPORT_MAX_LUNS_PER_TPG) { 881 if (kstrtouint(lunp, 10, &lun) || lun >= TRANSPORT_MAX_LUNS_PER_TPG) {
884 pr_err("xen-pvscsi: lun number not valid: %s\n", lunp); 882 pr_err("lun number not valid: %s\n", lunp);
885 return -EINVAL; 883 return -EINVAL;
886 } 884 }
887 885
@@ -909,7 +907,7 @@ static int scsiback_add_translation_entry(struct vscsibk_info *info,
909 mutex_unlock(&scsiback_mutex); 907 mutex_unlock(&scsiback_mutex);
910 908
911 if (!tpg) { 909 if (!tpg) {
912 pr_err("xen-pvscsi: %s:%d %s\n", phy, lun, error); 910 pr_err("%s:%d %s\n", phy, lun, error);
913 return -ENODEV; 911 return -ENODEV;
914 } 912 }
915 913
@@ -926,7 +924,7 @@ static int scsiback_add_translation_entry(struct vscsibk_info *info,
926 if ((entry->v.chn == v->chn) && 924 if ((entry->v.chn == v->chn) &&
927 (entry->v.tgt == v->tgt) && 925 (entry->v.tgt == v->tgt) &&
928 (entry->v.lun == v->lun)) { 926 (entry->v.lun == v->lun)) {
929 pr_warn("xen-pvscsi: Virtual ID is already used. Assignment was not performed.\n"); 927 pr_warn("Virtual ID is already used. Assignment was not performed.\n");
930 err = -EEXIST; 928 err = -EEXIST;
931 goto out; 929 goto out;
932 } 930 }
@@ -997,7 +995,7 @@ static void scsiback_do_add_lun(struct vscsibk_info *info, const char *state,
997 if (!scsiback_add_translation_entry(info, phy, vir)) { 995 if (!scsiback_add_translation_entry(info, phy, vir)) {
998 if (xenbus_printf(XBT_NIL, info->dev->nodename, state, 996 if (xenbus_printf(XBT_NIL, info->dev->nodename, state,
999 "%d", XenbusStateInitialised)) { 997 "%d", XenbusStateInitialised)) {
1000 pr_err("xen-pvscsi: xenbus_printf error %s\n", state); 998 pr_err("xenbus_printf error %s\n", state);
1001 scsiback_del_translation_entry(info, vir); 999 scsiback_del_translation_entry(info, vir);
1002 } 1000 }
1003 } else { 1001 } else {
@@ -1012,7 +1010,7 @@ static void scsiback_do_del_lun(struct vscsibk_info *info, const char *state,
1012 if (!scsiback_del_translation_entry(info, vir)) { 1010 if (!scsiback_del_translation_entry(info, vir)) {
1013 if (xenbus_printf(XBT_NIL, info->dev->nodename, state, 1011 if (xenbus_printf(XBT_NIL, info->dev->nodename, state,
1014 "%d", XenbusStateClosed)) 1012 "%d", XenbusStateClosed))
1015 pr_err("xen-pvscsi: xenbus_printf error %s\n", state); 1013 pr_err("xenbus_printf error %s\n", state);
1016 } 1014 }
1017} 1015}
1018 1016
@@ -1071,15 +1069,14 @@ static void scsiback_do_1lun_hotplug(struct vscsibk_info *info, int op,
1071 /* modify vscsi-devs/dev-x/state */ 1069 /* modify vscsi-devs/dev-x/state */
1072 if (xenbus_printf(XBT_NIL, dev->nodename, state, 1070 if (xenbus_printf(XBT_NIL, dev->nodename, state,
1073 "%d", XenbusStateConnected)) { 1071 "%d", XenbusStateConnected)) {
1074 pr_err("xen-pvscsi: xenbus_printf error %s\n", 1072 pr_err("xenbus_printf error %s\n", str);
1075 str);
1076 scsiback_del_translation_entry(info, &vir); 1073 scsiback_del_translation_entry(info, &vir);
1077 xenbus_printf(XBT_NIL, dev->nodename, state, 1074 xenbus_printf(XBT_NIL, dev->nodename, state,
1078 "%d", XenbusStateClosed); 1075 "%d", XenbusStateClosed);
1079 } 1076 }
1080 } 1077 }
1081 break; 1078 break;
1082 /*When it is necessary, processing is added here.*/ 1079 /* When it is necessary, processing is added here. */
1083 default: 1080 default:
1084 break; 1081 break;
1085 } 1082 }
@@ -1196,7 +1193,7 @@ static int scsiback_probe(struct xenbus_device *dev,
1196 struct vscsibk_info *info = kzalloc(sizeof(struct vscsibk_info), 1193 struct vscsibk_info *info = kzalloc(sizeof(struct vscsibk_info),
1197 GFP_KERNEL); 1194 GFP_KERNEL);
1198 1195
1199 DPRINTK("%p %d\n", dev, dev->otherend_id); 1196 pr_debug("%s %p %d\n", __func__, dev, dev->otherend_id);
1200 1197
1201 if (!info) { 1198 if (!info) {
1202 xenbus_dev_fatal(dev, -ENOMEM, "allocating backend structure"); 1199 xenbus_dev_fatal(dev, -ENOMEM, "allocating backend structure");
@@ -1227,7 +1224,7 @@ static int scsiback_probe(struct xenbus_device *dev,
1227 return 0; 1224 return 0;
1228 1225
1229fail: 1226fail:
1230 pr_warn("xen-pvscsi: %s failed\n", __func__); 1227 pr_warn("%s failed\n", __func__);
1231 scsiback_remove(dev); 1228 scsiback_remove(dev);
1232 1229
1233 return err; 1230 return err;
@@ -1432,7 +1429,7 @@ check_len:
1432 } 1429 }
1433 snprintf(&tport->tport_name[0], VSCSI_NAMELEN, "%s", &name[off]); 1430 snprintf(&tport->tport_name[0], VSCSI_NAMELEN, "%s", &name[off]);
1434 1431
1435 pr_debug("xen-pvscsi: Allocated emulated Target %s Address: %s\n", 1432 pr_debug("Allocated emulated Target %s Address: %s\n",
1436 scsiback_dump_proto_id(tport), name); 1433 scsiback_dump_proto_id(tport), name);
1437 1434
1438 return &tport->tport_wwn; 1435 return &tport->tport_wwn;
@@ -1443,7 +1440,7 @@ static void scsiback_drop_tport(struct se_wwn *wwn)
1443 struct scsiback_tport *tport = container_of(wwn, 1440 struct scsiback_tport *tport = container_of(wwn,
1444 struct scsiback_tport, tport_wwn); 1441 struct scsiback_tport, tport_wwn);
1445 1442
1446 pr_debug("xen-pvscsi: Deallocating emulated Target %s Address: %s\n", 1443 pr_debug("Deallocating emulated Target %s Address: %s\n",
1447 scsiback_dump_proto_id(tport), tport->tport_name); 1444 scsiback_dump_proto_id(tport), tport->tport_name);
1448 1445
1449 kfree(tport); 1446 kfree(tport);
@@ -1470,8 +1467,8 @@ static u32 scsiback_tpg_get_inst_index(struct se_portal_group *se_tpg)
1470static int scsiback_check_stop_free(struct se_cmd *se_cmd) 1467static int scsiback_check_stop_free(struct se_cmd *se_cmd)
1471{ 1468{
1472 /* 1469 /*
1473 * Do not release struct se_cmd's containing a valid TMR 1470 * Do not release struct se_cmd's containing a valid TMR pointer.
1474 * pointer. These will be released directly in scsiback_device_action() 1471 * These will be released directly in scsiback_device_action()
1475 * with transport_generic_free_cmd(). 1472 * with transport_generic_free_cmd().
1476 */ 1473 */
1477 if (se_cmd->se_cmd_flags & SCF_SCSI_TMR_CDB) 1474 if (se_cmd->se_cmd_flags & SCF_SCSI_TMR_CDB)
@@ -1637,7 +1634,7 @@ static int scsiback_make_nexus(struct scsiback_tpg *tpg,
1637 return -ENOMEM; 1634 return -ENOMEM;
1638 } 1635 }
1639 /* 1636 /*
1640 * Initialize the struct se_session pointer 1637 * Initialize the struct se_session pointer
1641 */ 1638 */
1642 tv_nexus->tvn_se_sess = transport_init_session(TARGET_PROT_NORMAL); 1639 tv_nexus->tvn_se_sess = transport_init_session(TARGET_PROT_NORMAL);
1643 if (IS_ERR(tv_nexus->tvn_se_sess)) { 1640 if (IS_ERR(tv_nexus->tvn_se_sess)) {
@@ -1708,7 +1705,7 @@ static int scsiback_drop_nexus(struct scsiback_tpg *tpg)
1708 return -EBUSY; 1705 return -EBUSY;
1709 } 1706 }
1710 1707
1711 pr_debug("xen-pvscsi: Removing I_T Nexus to emulated %s Initiator Port: %s\n", 1708 pr_debug("Removing I_T Nexus to emulated %s Initiator Port: %s\n",
1712 scsiback_dump_proto_id(tpg->tport), 1709 scsiback_dump_proto_id(tpg->tport),
1713 tv_nexus->tvn_se_sess->se_node_acl->initiatorname); 1710 tv_nexus->tvn_se_sess->se_node_acl->initiatorname);
1714 1711
@@ -1754,7 +1751,7 @@ static ssize_t scsiback_tpg_store_nexus(struct se_portal_group *se_tpg,
1754 unsigned char i_port[VSCSI_NAMELEN], *ptr, *port_ptr; 1751 unsigned char i_port[VSCSI_NAMELEN], *ptr, *port_ptr;
1755 int ret; 1752 int ret;
1756 /* 1753 /*
1757 * Shutdown the active I_T nexus if 'NULL' is passed.. 1754 * Shutdown the active I_T nexus if 'NULL' is passed.
1758 */ 1755 */
1759 if (!strncmp(page, "NULL", 4)) { 1756 if (!strncmp(page, "NULL", 4)) {
1760 ret = scsiback_drop_nexus(tpg); 1757 ret = scsiback_drop_nexus(tpg);
@@ -1925,7 +1922,7 @@ static void scsiback_drop_tpg(struct se_portal_group *se_tpg)
1925 */ 1922 */
1926 scsiback_drop_nexus(tpg); 1923 scsiback_drop_nexus(tpg);
1927 /* 1924 /*
1928 * Deregister the se_tpg from TCM.. 1925 * Deregister the se_tpg from TCM.
1929 */ 1926 */
1930 core_tpg_deregister(se_tpg); 1927 core_tpg_deregister(se_tpg);
1931 kfree(tpg); 1928 kfree(tpg);
@@ -1995,7 +1992,7 @@ static int scsiback_register_configfs(void)
1995 struct target_fabric_configfs *fabric; 1992 struct target_fabric_configfs *fabric;
1996 int ret; 1993 int ret;
1997 1994
1998 pr_debug("xen-pvscsi: fabric module %s on %s/%s on "UTS_RELEASE"\n", 1995 pr_debug("fabric module %s on %s/%s on "UTS_RELEASE"\n",
1999 VSCSI_VERSION, utsname()->sysname, utsname()->machine); 1996 VSCSI_VERSION, utsname()->sysname, utsname()->machine);
2000 /* 1997 /*
2001 * Register the top level struct config_item_type with TCM core 1998 * Register the top level struct config_item_type with TCM core
@@ -2032,7 +2029,7 @@ static int scsiback_register_configfs(void)
2032 * Setup our local pointer to *fabric 2029 * Setup our local pointer to *fabric
2033 */ 2030 */
2034 scsiback_fabric_configfs = fabric; 2031 scsiback_fabric_configfs = fabric;
2035 pr_debug("xen-pvscsi: Set fabric -> scsiback_fabric_configfs\n"); 2032 pr_debug("Set fabric -> scsiback_fabric_configfs\n");
2036 return 0; 2033 return 0;
2037}; 2034};
2038 2035
@@ -2043,7 +2040,7 @@ static void scsiback_deregister_configfs(void)
2043 2040
2044 target_fabric_configfs_deregister(scsiback_fabric_configfs); 2041 target_fabric_configfs_deregister(scsiback_fabric_configfs);
2045 scsiback_fabric_configfs = NULL; 2042 scsiback_fabric_configfs = NULL;
2046 pr_debug("xen-pvscsi: Cleared scsiback_fabric_configfs\n"); 2043 pr_debug("Cleared scsiback_fabric_configfs\n");
2047}; 2044};
2048 2045
2049static const struct xenbus_device_id scsiback_ids[] = { 2046static const struct xenbus_device_id scsiback_ids[] = {
@@ -2094,7 +2091,7 @@ out_unregister_xenbus:
2094 xenbus_unregister_driver(&scsiback_driver); 2091 xenbus_unregister_driver(&scsiback_driver);
2095out_cache_destroy: 2092out_cache_destroy:
2096 kmem_cache_destroy(scsiback_cachep); 2093 kmem_cache_destroy(scsiback_cachep);
2097 pr_err("xen-pvscsi: %s: error %d\n", __func__, ret); 2094 pr_err("%s: error %d\n", __func__, ret);
2098 return ret; 2095 return ret;
2099} 2096}
2100 2097