Merge branch 'stable/for-jens-4.7' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen into for-linus

Konrad writes:

Thishas two fixes for a guest migrating from host that
has multi-queue to one without it (and vice-versa).

Changed files
+22 -13
drivers
+22 -13
drivers/block/xen-blkfront.c
··· 874 874 const struct blk_mq_queue_data *qd) 875 875 { 876 876 unsigned long flags; 877 - struct blkfront_ring_info *rinfo = (struct blkfront_ring_info *)hctx->driver_data; 877 + int qid = hctx->queue_num; 878 + struct blkfront_info *info = hctx->queue->queuedata; 879 + struct blkfront_ring_info *rinfo = NULL; 878 880 881 + BUG_ON(info->nr_rings <= qid); 882 + rinfo = &info->rinfo[qid]; 879 883 blk_mq_start_request(qd->rq); 880 884 spin_lock_irqsave(&rinfo->ring_lock, flags); 881 885 if (RING_FULL(&rinfo->ring)) ··· 905 901 return BLK_MQ_RQ_QUEUE_BUSY; 906 902 } 907 903 908 - static int blk_mq_init_hctx(struct blk_mq_hw_ctx *hctx, void *data, 909 - unsigned int index) 910 - { 911 - struct blkfront_info *info = (struct blkfront_info *)data; 912 - 913 - BUG_ON(info->nr_rings <= index); 914 - hctx->driver_data = &info->rinfo[index]; 915 - return 0; 916 - } 917 - 918 904 static struct blk_mq_ops blkfront_mq_ops = { 919 905 .queue_rq = blkif_queue_rq, 920 906 .map_queue = blk_mq_map_queue, 921 - .init_hctx = blk_mq_init_hctx, 922 907 }; 923 908 924 909 static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size, ··· 943 950 return PTR_ERR(rq); 944 951 } 945 952 953 + rq->queuedata = info; 946 954 queue_flag_set_unlocked(QUEUE_FLAG_VIRT, rq); 947 955 948 956 if (info->feature_discard) { ··· 2143 2149 return err; 2144 2150 2145 2151 err = talk_to_blkback(dev, info); 2152 + if (!err) 2153 + blk_mq_update_nr_hw_queues(&info->tag_set, info->nr_rings); 2146 2154 2147 2155 /* 2148 2156 * We have to wait for the backend to switch to ··· 2481 2485 break; 2482 2486 2483 2487 case XenbusStateConnected: 2484 - if (dev->state != XenbusStateInitialised) { 2488 + /* 2489 + * talk_to_blkback sets state to XenbusStateInitialised 2490 + * and blkfront_connect sets it to XenbusStateConnected 2491 + * (if connection went OK). 2492 + * 2493 + * If the backend (or toolstack) decides to poke at backend 2494 + * state (and re-trigger the watch by setting the state repeatedly 2495 + * to XenbusStateConnected (4)) we need to deal with this. 2496 + * This is allowed as this is used to communicate to the guest 2497 + * that the size of disk has changed! 2498 + */ 2499 + if ((dev->state != XenbusStateInitialised) && 2500 + (dev->state != XenbusStateConnected)) { 2485 2501 if (talk_to_blkback(dev, info)) 2486 2502 break; 2487 2503 } 2504 + 2488 2505 blkfront_connect(info); 2489 2506 break; 2490 2507