nbd: pass queue_limits to blk_mq_alloc_disk
[linux-2.6-microblaze.git] / drivers / block / nbd.c
index 4e72ec4..9ee9587 100644 (file)
@@ -508,7 +508,7 @@ static int __sock_xmit(struct nbd_device *nbd, struct socket *sock, int send,
                       struct iov_iter *iter, int msg_flags, int *sent)
 {
        int result;
-       struct msghdr msg;
+       struct msghdr msg = {} ;
        unsigned int noreclaim_flag;
 
        if (unlikely(!sock)) {
@@ -524,10 +524,6 @@ static int __sock_xmit(struct nbd_device *nbd, struct socket *sock, int send,
        do {
                sock->sk->sk_allocation = GFP_NOIO | __GFP_MEMALLOC;
                sock->sk->sk_use_task_frag = false;
-               msg.msg_name = NULL;
-               msg.msg_namelen = 0;
-               msg.msg_control = NULL;
-               msg.msg_controllen = 0;
                msg.msg_flags = msg_flags | MSG_NOSIGNAL;
 
                if (send)
@@ -1787,6 +1783,12 @@ static const struct blk_mq_ops nbd_mq_ops = {
 
 static struct nbd_device *nbd_dev_add(int index, unsigned int refs)
 {
+       struct queue_limits lim = {
+               .max_hw_sectors         = 65536,
+               .max_user_sectors       = 256,
+               .max_segments           = USHRT_MAX,
+               .max_segment_size       = UINT_MAX,
+       };
        struct nbd_device *nbd;
        struct gendisk *disk;
        int err = -ENOMEM;
@@ -1827,7 +1829,7 @@ static struct nbd_device *nbd_dev_add(int index, unsigned int refs)
        if (err < 0)
                goto out_free_tags;
 
-       disk = blk_mq_alloc_disk(&nbd->tag_set, NULL);
+       disk = blk_mq_alloc_disk(&nbd->tag_set, &lim, NULL);
        if (IS_ERR(disk)) {
                err = PTR_ERR(disk);
                goto out_free_idr;
@@ -1847,11 +1849,6 @@ static struct nbd_device *nbd_dev_add(int index, unsigned int refs)
         * Tell the block layer that we are not a rotational device
         */
        blk_queue_flag_set(QUEUE_FLAG_NONROT, disk->queue);
-       blk_queue_max_discard_sectors(disk->queue, 0);
-       blk_queue_max_segment_size(disk->queue, UINT_MAX);
-       blk_queue_max_segments(disk->queue, USHRT_MAX);
-       blk_queue_max_hw_sectors(disk->queue, 65536);
-       disk->queue->limits.max_sectors = 256;
 
        mutex_init(&nbd->config_lock);
        refcount_set(&nbd->config_refs, 0);
@@ -2437,6 +2434,12 @@ static int nbd_genl_status(struct sk_buff *skb, struct genl_info *info)
        }
 
        dev_list = nla_nest_start_noflag(reply, NBD_ATTR_DEVICE_LIST);
+       if (!dev_list) {
+               nlmsg_free(reply);
+               ret = -EMSGSIZE;
+               goto out;
+       }
+
        if (index == -1) {
                ret = idr_for_each(&nbd_index_idr, &status_cb, reply);
                if (ret) {