direct-io.hg

changeset 11279:7bfd8efb4fa7

Reduce AIO context allocations in blktap.

Signed-off-by: Andrew Warfield <andy@xensource.com>
author akw@devbox.site
date Tue Aug 29 14:34:57 2006 -0700 (2006-08-29)
parents 8273f730371b
children b4e9f12df619 7299065fac68
files tools/blktap/drivers/block-aio.c tools/blktap/drivers/block-qcow.c
line diff
     1.1 --- a/tools/blktap/drivers/block-aio.c	Tue Aug 29 12:23:11 2006 +0100
     1.2 +++ b/tools/blktap/drivers/block-aio.c	Tue Aug 29 14:34:57 2006 -0700
     1.3 @@ -52,7 +52,7 @@
     1.4   */
     1.5  #define REQUEST_ASYNC_FD 1
     1.6  
     1.7 -#define MAX_AIO_REQS (MAX_REQUESTS * MAX_SEGMENTS_PER_REQ * 8)
     1.8 +#define MAX_AIO_REQS (MAX_REQUESTS * MAX_SEGMENTS_PER_REQ)
     1.9  
    1.10  struct pending_aio {
    1.11  	td_callback_t cb;
    1.12 @@ -146,7 +146,7 @@ int tdaio_open (struct td_state *s, cons
    1.13  	struct tdaio_state *prv = (struct tdaio_state *)s->private;
    1.14  	s->private = prv;
    1.15  
    1.16 -	DPRINTF("XXX: block-aio open('%s')", name);
    1.17 +	DPRINTF("block-aio open('%s')", name);
    1.18  	/* Initialize AIO */
    1.19  	prv->iocb_free_count = MAX_AIO_REQS;
    1.20  	prv->iocb_queued     = 0;
    1.21 @@ -156,9 +156,18 @@ int tdaio_open (struct td_state *s, cons
    1.22  
    1.23  	if (prv->poll_fd < 0) {
    1.24  		ret = prv->poll_fd;
    1.25 -		DPRINTF("Couldn't get fd for AIO poll support.  This is "
    1.26 -			"probably because your kernel does not have the "
    1.27 -			"aio-poll patch applied.\n");
    1.28 +                if (ret == -EAGAIN) {
    1.29 +                        DPRINTF("Couldn't setup AIO context.  If you are "
    1.30 +                                "trying to concurrently use a large number "
    1.31 +                                "of blktap-based disks, you may need to "
    1.32 +                                "increase the system-wide aio request limit. "
    1.33 +                                "(e.g. 'echo echo 1048576 > /proc/sys/"
    1.34 +                                "aio-max-nr')\n");
    1.35 +                } else {
    1.36 +                        DPRINTF("Couldn't get fd for AIO poll support.  This "
    1.37 +                                "is probably because your kernel does not "
    1.38 +                                "have the aio-poll patch applied.\n");
    1.39 +                }
    1.40  		goto done;
    1.41  	}
    1.42  
     2.1 --- a/tools/blktap/drivers/block-qcow.c	Tue Aug 29 12:23:11 2006 +0100
     2.2 +++ b/tools/blktap/drivers/block-qcow.c	Tue Aug 29 14:34:57 2006 -0700
     2.3 @@ -51,7 +51,7 @@
     2.4  /******AIO DEFINES******/
     2.5  #define REQUEST_ASYNC_FD 1
     2.6  #define MAX_QCOW_IDS  0xFFFF
     2.7 -#define MAX_AIO_REQS (MAX_REQUESTS * MAX_SEGMENTS_PER_REQ * 8)
     2.8 +#define MAX_AIO_REQS (MAX_REQUESTS * MAX_SEGMENTS_PER_REQ)
     2.9  
    2.10  struct pending_aio {
    2.11          td_callback_t cb;
    2.12 @@ -176,10 +176,21 @@ static int init_aio_state(struct td_stat
    2.13          s->aio_ctx = (io_context_t) REQUEST_ASYNC_FD;   
    2.14          s->poll_fd = io_setup(MAX_AIO_REQS, &s->aio_ctx);
    2.15  
    2.16 -        if (s->poll_fd < 0) {
    2.17 -                DPRINTF("Retrieving Async poll fd failed\n");
    2.18 +	if (s->poll_fd < 0) {
    2.19 +                if (s->poll_fd == -EAGAIN) {
    2.20 +                        DPRINTF("Couldn't setup AIO context.  If you are "
    2.21 +                                "trying to concurrently use a large number "
    2.22 +                                "of blktap-based disks, you may need to "
    2.23 +                                "increase the system-wide aio request limit. "
    2.24 +                                "(e.g. 'echo echo 1048576 > /proc/sys/"
    2.25 +                                "aio-max-nr')\n");
    2.26 +                } else {
    2.27 +                        DPRINTF("Couldn't get fd for AIO poll support.  This "
    2.28 +                                "is probably because your kernel does not "
    2.29 +                                "have the aio-poll patch applied.\n");
    2.30 +                }
    2.31  		goto fail;
    2.32 -        }
    2.33 +	}
    2.34  
    2.35          for (i=0;i<MAX_AIO_REQS;i++)
    2.36                  s->iocb_free[i] = &s->iocb_list[i];