Merge tag 'v3.18' into for_next
[firefly-linux-kernel-4.4.55.git] / drivers / block / nbd.c
index 3a70ea2f7cd69b2641302e6c44560f32245a078c..4bc2a5cb9935fbc6f5256102bdf9c2c24b9e6d8c 100644 (file)
@@ -243,14 +243,11 @@ static int nbd_send_req(struct nbd_device *nbd, struct request *req)
        struct nbd_request request;
        unsigned long size = blk_rq_bytes(req);
 
+       memset(&request, 0, sizeof(request));
        request.magic = htonl(NBD_REQUEST_MAGIC);
        request.type = htonl(nbd_cmd(req));
 
-       if (nbd_cmd(req) == NBD_CMD_FLUSH) {
-               /* Other values are reserved for FLUSH requests.  */
-               request.from = 0;
-               request.len = 0;
-       } else {
+       if (nbd_cmd(req) != NBD_CMD_FLUSH && nbd_cmd(req) != NBD_CMD_DISC) {
                request.from = cpu_to_be64((u64)blk_rq_pos(req) << 9);
                request.len = htonl(size);
        }
@@ -533,7 +530,7 @@ static int nbd_thread(void *data)
        struct nbd_device *nbd = data;
        struct request *req;
 
-       set_user_nice(current, -20);
+       set_user_nice(current, MIN_NICE);
        while (!kthread_should_stop() || !list_empty(&nbd->waiting_queue)) {
                /* wait for something to do */
                wait_event_interruptible(nbd->waiting_wq,
@@ -850,6 +847,7 @@ static int __init nbd_init(void)
                 * Tell the block layer that we are not a rotational device
                 */
                queue_flag_set_unlocked(QUEUE_FLAG_NONROT, disk->queue);
+               queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, disk->queue);
                disk->queue->limits.discard_granularity = 512;
                disk->queue->limits.max_discard_sectors = UINT_MAX;
                disk->queue->limits.discard_zeroes_data = 0;