diff options
author | Dongli Zhang <dongli.zhang@oracle.com> | 2019-01-14 11:41:43 -0500 |
---|---|---|
committer | Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | 2019-01-17 10:26:23 -0500 |
commit | 5b8e432dbb0e20bd8e99033f4a0bfa0d38c0e08e (patch) | |
tree | a8c702d89a34d1b97bbc5309b47247b3e1d3a8c8 | |
parent | 1c7fc5cbc33980acd13d668f1c8f0313d6ae9fd8 (diff) |
xen/blkback: add stack variable 'blkif' in connect_ring()
As 'be->blkif' is used for many times in connect_ring(), the stack variable
'blkif' is added to substitute 'be-blkif'.
Suggested-by: Paul Durrant <paul.durrant@citrix.com>
Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
-rw-r--r-- | drivers/block/xen-blkback/xenbus.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c index a4bc74e72c39..a4aadac772e5 100644 --- a/drivers/block/xen-blkback/xenbus.c +++ b/drivers/block/xen-blkback/xenbus.c | |||
@@ -1023,6 +1023,7 @@ fail: | |||
1023 | static int connect_ring(struct backend_info *be) | 1023 | static int connect_ring(struct backend_info *be) |
1024 | { | 1024 | { |
1025 | struct xenbus_device *dev = be->dev; | 1025 | struct xenbus_device *dev = be->dev; |
1026 | struct xen_blkif *blkif = be->blkif; | ||
1026 | unsigned int pers_grants; | 1027 | unsigned int pers_grants; |
1027 | char protocol[64] = ""; | 1028 | char protocol[64] = ""; |
1028 | int err, i; | 1029 | int err, i; |
@@ -1033,25 +1034,25 @@ static int connect_ring(struct backend_info *be) | |||
1033 | 1034 | ||
1034 | pr_debug("%s %s\n", __func__, dev->otherend); | 1035 | pr_debug("%s %s\n", __func__, dev->otherend); |
1035 | 1036 | ||
1036 | be->blkif->blk_protocol = BLKIF_PROTOCOL_DEFAULT; | 1037 | blkif->blk_protocol = BLKIF_PROTOCOL_DEFAULT; |
1037 | err = xenbus_scanf(XBT_NIL, dev->otherend, "protocol", | 1038 | err = xenbus_scanf(XBT_NIL, dev->otherend, "protocol", |
1038 | "%63s", protocol); | 1039 | "%63s", protocol); |
1039 | if (err <= 0) | 1040 | if (err <= 0) |
1040 | strcpy(protocol, "unspecified, assuming default"); | 1041 | strcpy(protocol, "unspecified, assuming default"); |
1041 | else if (0 == strcmp(protocol, XEN_IO_PROTO_ABI_NATIVE)) | 1042 | else if (0 == strcmp(protocol, XEN_IO_PROTO_ABI_NATIVE)) |
1042 | be->blkif->blk_protocol = BLKIF_PROTOCOL_NATIVE; | 1043 | blkif->blk_protocol = BLKIF_PROTOCOL_NATIVE; |
1043 | else if (0 == strcmp(protocol, XEN_IO_PROTO_ABI_X86_32)) | 1044 | else if (0 == strcmp(protocol, XEN_IO_PROTO_ABI_X86_32)) |
1044 | be->blkif->blk_protocol = BLKIF_PROTOCOL_X86_32; | 1045 | blkif->blk_protocol = BLKIF_PROTOCOL_X86_32; |
1045 | else if (0 == strcmp(protocol, XEN_IO_PROTO_ABI_X86_64)) | 1046 | else if (0 == strcmp(protocol, XEN_IO_PROTO_ABI_X86_64)) |
1046 | be->blkif->blk_protocol = BLKIF_PROTOCOL_X86_64; | 1047 | blkif->blk_protocol = BLKIF_PROTOCOL_X86_64; |
1047 | else { | 1048 | else { |
1048 | xenbus_dev_fatal(dev, err, "unknown fe protocol %s", protocol); | 1049 | xenbus_dev_fatal(dev, err, "unknown fe protocol %s", protocol); |
1049 | return -ENOSYS; | 1050 | return -ENOSYS; |
1050 | } | 1051 | } |
1051 | pers_grants = xenbus_read_unsigned(dev->otherend, "feature-persistent", | 1052 | pers_grants = xenbus_read_unsigned(dev->otherend, "feature-persistent", |
1052 | 0); | 1053 | 0); |
1053 | be->blkif->vbd.feature_gnt_persistent = pers_grants; | 1054 | blkif->vbd.feature_gnt_persistent = pers_grants; |
1054 | be->blkif->vbd.overflow_max_grants = 0; | 1055 | blkif->vbd.overflow_max_grants = 0; |
1055 | 1056 | ||
1056 | /* | 1057 | /* |
1057 | * Read the number of hardware queues from frontend. | 1058 | * Read the number of hardware queues from frontend. |
@@ -1067,16 +1068,16 @@ static int connect_ring(struct backend_info *be) | |||
1067 | requested_num_queues, xenblk_max_queues); | 1068 | requested_num_queues, xenblk_max_queues); |
1068 | return -ENOSYS; | 1069 | return -ENOSYS; |
1069 | } | 1070 | } |
1070 | be->blkif->nr_rings = requested_num_queues; | 1071 | blkif->nr_rings = requested_num_queues; |
1071 | if (xen_blkif_alloc_rings(be->blkif)) | 1072 | if (xen_blkif_alloc_rings(blkif)) |
1072 | return -ENOMEM; | 1073 | return -ENOMEM; |
1073 | 1074 | ||
1074 | pr_info("%s: using %d queues, protocol %d (%s) %s\n", dev->nodename, | 1075 | pr_info("%s: using %d queues, protocol %d (%s) %s\n", dev->nodename, |
1075 | be->blkif->nr_rings, be->blkif->blk_protocol, protocol, | 1076 | blkif->nr_rings, blkif->blk_protocol, protocol, |
1076 | pers_grants ? "persistent grants" : ""); | 1077 | pers_grants ? "persistent grants" : ""); |
1077 | 1078 | ||
1078 | if (be->blkif->nr_rings == 1) | 1079 | if (blkif->nr_rings == 1) |
1079 | return read_per_ring_refs(&be->blkif->rings[0], dev->otherend); | 1080 | return read_per_ring_refs(&blkif->rings[0], dev->otherend); |
1080 | else { | 1081 | else { |
1081 | xspathsize = strlen(dev->otherend) + xenstore_path_ext_size; | 1082 | xspathsize = strlen(dev->otherend) + xenstore_path_ext_size; |
1082 | xspath = kmalloc(xspathsize, GFP_KERNEL); | 1083 | xspath = kmalloc(xspathsize, GFP_KERNEL); |
@@ -1085,10 +1086,10 @@ static int connect_ring(struct backend_info *be) | |||
1085 | return -ENOMEM; | 1086 | return -ENOMEM; |
1086 | } | 1087 | } |
1087 | 1088 | ||
1088 | for (i = 0; i < be->blkif->nr_rings; i++) { | 1089 | for (i = 0; i < blkif->nr_rings; i++) { |
1089 | memset(xspath, 0, xspathsize); | 1090 | memset(xspath, 0, xspathsize); |
1090 | snprintf(xspath, xspathsize, "%s/queue-%u", dev->otherend, i); | 1091 | snprintf(xspath, xspathsize, "%s/queue-%u", dev->otherend, i); |
1091 | err = read_per_ring_refs(&be->blkif->rings[i], xspath); | 1092 | err = read_per_ring_refs(&blkif->rings[i], xspath); |
1092 | if (err) { | 1093 | if (err) { |
1093 | kfree(xspath); | 1094 | kfree(xspath); |
1094 | return err; | 1095 | return err; |