nbd.c (c6380ecd8e9bee7aba3d9a5a94b58168244c4a61) nbd.c (8b904b5b6b58b9a29dcf3f82d936d9e7fd69fda6)
1/*
2 * Network block device - make block devices work over TCP
3 *
4 * Note that you can not swap over this thing, yet. Seems to work but
5 * deadlocks sometimes - you can not swap over TCP in general.
6 *
7 * Copyright 1997-2000, 2008 Pavel Machek <pavel@ucw.cz>
8 * Parts copyright 2001 Steven Whitehouse <steve@chygwyn.com>

--- 950 unchanged lines hidden (view full) ---

959static void nbd_parse_flags(struct nbd_device *nbd)
960{
961 struct nbd_config *config = nbd->config;
962 if (config->flags & NBD_FLAG_READ_ONLY)
963 set_disk_ro(nbd->disk, true);
964 else
965 set_disk_ro(nbd->disk, false);
966 if (config->flags & NBD_FLAG_SEND_TRIM)
1/*
2 * Network block device - make block devices work over TCP
3 *
4 * Note that you can not swap over this thing, yet. Seems to work but
5 * deadlocks sometimes - you can not swap over TCP in general.
6 *
7 * Copyright 1997-2000, 2008 Pavel Machek <pavel@ucw.cz>
8 * Parts copyright 2001 Steven Whitehouse <steve@chygwyn.com>

--- 950 unchanged lines hidden (view full) ---

959static void nbd_parse_flags(struct nbd_device *nbd)
960{
961 struct nbd_config *config = nbd->config;
962 if (config->flags & NBD_FLAG_READ_ONLY)
963 set_disk_ro(nbd->disk, true);
964 else
965 set_disk_ro(nbd->disk, false);
966 if (config->flags & NBD_FLAG_SEND_TRIM)
967 queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, nbd->disk->queue);
967 blk_queue_flag_set(QUEUE_FLAG_DISCARD, nbd->disk->queue);
968 if (config->flags & NBD_FLAG_SEND_FLUSH) {
969 if (config->flags & NBD_FLAG_SEND_FUA)
970 blk_queue_write_cache(nbd->disk->queue, true, true);
971 else
972 blk_queue_write_cache(nbd->disk->queue, true, false);
973 }
974 else
975 blk_queue_write_cache(nbd->disk->queue, false, false);

--- 59 unchanged lines hidden (view full) ---

1035 kfree(config->socks[i]);
1036 }
1037 kfree(config->socks);
1038 }
1039 kfree(nbd->config);
1040 nbd->config = NULL;
1041
1042 nbd->tag_set.timeout = 0;
968 if (config->flags & NBD_FLAG_SEND_FLUSH) {
969 if (config->flags & NBD_FLAG_SEND_FUA)
970 blk_queue_write_cache(nbd->disk->queue, true, true);
971 else
972 blk_queue_write_cache(nbd->disk->queue, true, false);
973 }
974 else
975 blk_queue_write_cache(nbd->disk->queue, false, false);

--- 59 unchanged lines hidden (view full) ---

1035 kfree(config->socks[i]);
1036 }
1037 kfree(config->socks);
1038 }
1039 kfree(nbd->config);
1040 nbd->config = NULL;
1041
1042 nbd->tag_set.timeout = 0;
1043 queue_flag_clear_unlocked(QUEUE_FLAG_DISCARD, nbd->disk->queue);
1043 blk_queue_flag_clear(QUEUE_FLAG_DISCARD, nbd->disk->queue);
1044
1045 mutex_unlock(&nbd->config_lock);
1046 nbd_put(nbd);
1047 module_put(THIS_MODULE);
1048 }
1049}
1050
1051static int nbd_start_device(struct nbd_device *nbd)

--- 431 unchanged lines hidden (view full) ---

1483 err = PTR_ERR(q);
1484 goto out_free_tags;
1485 }
1486 disk->queue = q;
1487
1488 /*
1489 * Tell the block layer that we are not a rotational device
1490 */
1044
1045 mutex_unlock(&nbd->config_lock);
1046 nbd_put(nbd);
1047 module_put(THIS_MODULE);
1048 }
1049}
1050
1051static int nbd_start_device(struct nbd_device *nbd)

--- 431 unchanged lines hidden (view full) ---

1483 err = PTR_ERR(q);
1484 goto out_free_tags;
1485 }
1486 disk->queue = q;
1487
1488 /*
1489 * Tell the block layer that we are not a rotational device
1490 */
1491 queue_flag_set_unlocked(QUEUE_FLAG_NONROT, disk->queue);
1492 queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, disk->queue);
1491 blk_queue_flag_set(QUEUE_FLAG_NONROT, disk->queue);
1492 blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, disk->queue);
1493 disk->queue->limits.discard_granularity = 512;
1494 blk_queue_max_discard_sectors(disk->queue, UINT_MAX);
1495 blk_queue_max_segment_size(disk->queue, UINT_MAX);
1496 blk_queue_max_segments(disk->queue, USHRT_MAX);
1497 blk_queue_max_hw_sectors(disk->queue, 65536);
1498 disk->queue->limits.max_sectors = 256;
1499
1500 mutex_init(&nbd->config_lock);

--- 662 unchanged lines hidden ---
1493 disk->queue->limits.discard_granularity = 512;
1494 blk_queue_max_discard_sectors(disk->queue, UINT_MAX);
1495 blk_queue_max_segment_size(disk->queue, UINT_MAX);
1496 blk_queue_max_segments(disk->queue, USHRT_MAX);
1497 blk_queue_max_hw_sectors(disk->queue, 65536);
1498 disk->queue->limits.max_sectors = 256;
1499
1500 mutex_init(&nbd->config_lock);

--- 662 unchanged lines hidden ---