diff options
author | Johann Latocha | 2012-02-23 19:28:19 +0100 |
---|---|---|
committer | Johann Latocha | 2012-02-23 19:28:19 +0100 |
commit | f84b05519a15c650f667d7fef5967244ffbdaca6 (patch) | |
tree | 608f72b1ea903093dfb48e2f975605aba007b132 | |
parent | [KERNEL] One more KP fixed (diff) | |
download | dnbd3-f84b05519a15c650f667d7fef5967244ffbdaca6.tar.gz dnbd3-f84b05519a15c650f667d7fef5967244ffbdaca6.tar.xz dnbd3-f84b05519a15c650f667d7fef5967244ffbdaca6.zip |
[KERNEL] Read ahead increased
-rw-r--r-- | dnbd3-client.conf.example | 4 | ||||
-rw-r--r-- | src/client/client.c | 19 | ||||
-rw-r--r-- | src/config.h | 1 | ||||
-rw-r--r-- | src/kernel/blk.c | 6 | ||||
-rw-r--r-- | src/types.h | 1 | ||||
-rw-r--r-- | src/version.h | 4 |
6 files changed, 29 insertions, 6 deletions
diff --git a/dnbd3-client.conf.example b/dnbd3-client.conf.example index 1b0ccbd..9d33cf6 100644 --- a/dnbd3-client.conf.example +++ b/dnbd3-client.conf.example @@ -6,6 +6,7 @@ port=5003 vid=1 rid=3 device=/dev/dnbd0 +ahead=256 [Ubuntu 10.10] server=132.230.4.29 @@ -13,6 +14,7 @@ port=5003 vid=2 rid=1 device=/dev/dnbd1 +ahead=256 [Ubuntu 11.04] server=132.230.4.29 @@ -20,6 +22,7 @@ port=5003 vid=3 rid=1 device=/dev/dnbd2 +ahead=256 [Ubuntu 11.10] server=132.230.4.29 @@ -27,3 +30,4 @@ port=5003 vid=4 rid=1 device=/dev/dnbd3 +ahead=256 diff --git a/src/client/client.c b/src/client/client.c index c1acd28..4810005 100644 --- a/src/client/client.c +++ b/src/client/client.c @@ -36,18 +36,20 @@ char *_config_file_name = DEFAULT_CLIENT_CONFIG_FILE; void dnbd3_print_help(char* argv_0) { - printf("Usage: %s -h <host> [-p <port>] -v <vid> [-r <rid>] -d <device> || -f <file> || -c <device>\n", argv_0); + printf("\nUsage: %s\n" + "\t-h <host> [-p <port>] -v <vid> [-r <rid>] -d <device> [-a <kb>] || -f <file> || -c <device>\n\n", argv_0); printf("Start the DNBD3 client.\n"); printf("-f or --file \t\t Configuration file (default /etc/dnbd3-client.conf)\n"); printf("-h or --host \t\t Host running dnbd3-server.\n"); printf("-p or --port \t\t Port used by server (default %i).\n", PORT); printf("-v or --vid \t\t Volume-ID of exported image.\n"); - printf("-r or --rid \t\t Release-ID of exported image (if 0 latest available rid will be used).\n"); + printf("-r or --rid \t\t Release-ID of exported image (default 0, latest).\n"); printf("-d or --device \t\t DNBD3 device name.\n"); + printf("-a or --ahead \t\t Read ahead in KByte (default %i).\n", DEFAULT_READ_AHEAD_KB); printf("-c or --close \t\t Disconnect and close device.\n"); printf("-s or --switch \t\t Switch dnbd3-server on device (DEBUG).\n"); printf("-H or --help \t\t Show this help text and quit.\n"); - printf("-V or --version \t Show version and quit.\n"); + printf("-V or --version \t Show version and quit.\n\n"); exit(EXIT_SUCCESS); } @@ -83,10 +85,11 @@ int main(int argc, char *argv[]) msg.port = PORTSTR; msg.vid = 0; msg.rid = 0; + msg.read_ahead_kb = DEFAULT_READ_AHEAD_KB; int opt = 0; int longIndex = 0; - static const char *optString = "f:h:p:v:r:d:c:s:HV?"; + static const char *optString = "f:h:p:v:r:d:a:c:s:HV?"; static const struct option longOpts[] = { { "file", required_argument, NULL, 'f' }, @@ -95,6 +98,7 @@ int main(int argc, char *argv[]) { "vid", required_argument, NULL, 'v' }, { "rid", required_argument, NULL, 'r' }, { "device", required_argument, NULL, 'd' }, + { "ahead", required_argument, NULL, 'a' }, { "close", required_argument, NULL, 'c' }, { "switch", required_argument, NULL, 's' }, { "help", no_argument, NULL, 'H' }, @@ -124,6 +128,9 @@ int main(int argc, char *argv[]) case 'd': dev = optarg; break; + case 'a': + msg.read_ahead_kb = atoi(optarg); + break; case 'c': dev = optarg; close_dev = 1; @@ -203,6 +210,10 @@ int main(int argc, char *argv[]) msg.rid = g_key_file_get_integer(gkf, groups[i], "rid", NULL); dev = g_key_file_get_string(gkf, groups[i], "device", NULL); + msg.read_ahead_kb = g_key_file_get_integer(gkf, groups[i], "ahead", NULL); + if (!msg.read_ahead_kb) + msg.read_ahead_kb = DEFAULT_READ_AHEAD_KB; + fd = open(dev, O_WRONLY); printf("INFO: Connecting %s to %s:%s vid:%i rid:%i\n", dev, msg.host, msg.port, msg.vid, msg.rid); diff --git a/src/config.h b/src/config.h index 594d7b5..58ca9fc 100644 --- a/src/config.h +++ b/src/config.h @@ -36,6 +36,7 @@ #define KERNEL_SECTOR_SIZE 512 #define DNBD3_BLOCK_SIZE 4096 #define NUMBER_DEVICES 8 +#define DEFAULT_READ_AHEAD_KB 256 // misc #define DEFAULT_SERVER_CONFIG_FILE "/etc/dnbd3-server.conf" diff --git a/src/kernel/blk.c b/src/kernel/blk.c index 1023743..2b12b74 100644 --- a/src/kernel/blk.c +++ b/src/kernel/blk.c @@ -22,6 +22,8 @@ #include "net.h" #include "sysfs.h" +#include <linux/pagemap.h> + int dnbd3_blk_add_device(dnbd3_device_t *dev, int minor) { struct gendisk *disk; @@ -69,6 +71,8 @@ int dnbd3_blk_add_device(dnbd3_device_t *dev, int minor) } blk_queue_logical_block_size(blk_queue, DNBD3_BLOCK_SIZE); + blk_queue_physical_block_size(blk_queue, DNBD3_BLOCK_SIZE); + disk->queue = blk_queue; disk->private_data = dev; queue_flag_set_unlocked(QUEUE_FLAG_NONROT, disk->queue); @@ -95,6 +99,7 @@ struct block_device_operations dnbd3_blk_ops = int dnbd3_blk_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg) { dnbd3_device_t *dev = bdev->bd_disk->private_data; + struct request_queue *blk_queue = dev->disk->queue; dnbd3_ioctl_t *msg = kmalloc(sizeof(dnbd3_ioctl_t), GFP_KERNEL); copy_from_user((char *)msg, (char *)arg, sizeof(*msg)); @@ -105,6 +110,7 @@ int dnbd3_blk_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, u strcpy(dev->cur_server.port, msg->port); dev->vid = msg->vid; dev->rid = msg->rid; + blk_queue->backing_dev_info.ra_pages = (msg->read_ahead_kb * 1024)/ PAGE_CACHE_SIZE; dnbd3_net_connect(dev); break; diff --git a/src/types.h b/src/types.h index 7c4c5e2..75bc8a1 100644 --- a/src/types.h +++ b/src/types.h @@ -35,6 +35,7 @@ typedef struct char *port; int vid; int rid; + int read_ahead_kb; } dnbd3_ioctl_t; // network diff --git a/src/version.h b/src/version.h index 2664741..3dd8618 100644 --- a/src/version.h +++ b/src/version.h @@ -21,7 +21,7 @@ #ifndef VERSION_H_ #define VERSION_H_ -#define VERSION_STRING "0.3.0" -#define VERSION_NUMBER 030 +#define VERSION_STRING "0.7.0" +#define VERSION_NUMBER 070 #endif /* VERSION_H_ */ |