dm-io.c: Add io routines to perform io on a vm area. --- diff/drivers/md/dm-io.c 2004-03-16 11:47:20.307672696 +0000 +++ source/drivers/md/dm-io.c 2004-03-16 11:47:22.682311696 +0000 @@ -420,6 +420,28 @@ void bvec_dp_init(struct dpages *dp, str dp->context_ptr = bvec; } +void vm_get_page(struct dpages *dp, + struct page **p, unsigned long *len, unsigned *offset) +{ + *p = vmalloc_to_page(dp->context_ptr); + *offset = dp->context_u; + *len = PAGE_SIZE - dp->context_u; +} + +void vm_next_page(struct dpages *dp) +{ + dp->context_ptr += PAGE_SIZE - dp->context_u; + dp->context_u = 0; +} + +void vm_dp_init(struct dpages *dp, void *data) +{ + dp->get_page = vm_get_page; + dp->next_page = vm_next_page; + dp->context_u = ((unsigned) data) & (PAGE_SIZE - 1); + dp->context_ptr = data; +} + /*----------------------------------------------------------------- * IO routines that accept a list of pages. *---------------------------------------------------------------*/ @@ -554,6 +576,14 @@ int dm_io_sync_bvec(unsigned int num_reg return sync_io(num_regions, where, rw, &dp, error_bits); } +int dm_io_sync_vm(unsigned int num_regions, struct io_region *where, int rw, + void *data, unsigned long *error_bits) +{ + struct dpages dp; + vm_dp_init(&dp, data); + return sync_io(num_regions, where, rw, &dp, error_bits); +} + int dm_io_async(unsigned int num_regions, struct io_region *where, int rw, struct page_list *pl, unsigned int offset, io_notify_fn fn, void *context) @@ -571,6 +601,13 @@ int dm_io_async_bvec(unsigned int num_re return async_io(num_regions, where, rw, &dp, fn, context); } +int dm_io_async_vm(unsigned int num_regions, struct io_region *where, int rw, + void *data, io_notify_fn fn, void *context) +{ + struct dpages dp; + vm_dp_init(&dp, data); + return async_io(num_regions, where, rw, &dp, fn, context); +} EXPORT_SYMBOL(dm_io_get); EXPORT_SYMBOL(dm_io_put); --- diff/drivers/md/dm-io.h 2004-03-16 11:47:20.307672696 +0000 +++ source/drivers/md/dm-io.h 2004-03-16 11:47:22.683311544 +0000 @@ -55,6 +55,8 @@ int dm_io_sync(unsigned int num_regions, int dm_io_sync_bvec(unsigned int num_regions, struct io_region *where, int rw, struct bio_vec *bvec, unsigned long *error_bits); +int dm_io_sync_vm(unsigned int num_regions, struct io_region *where, int rw, + void *data, unsigned long *error_bits); /* * Aynchronous IO. @@ -69,4 +71,7 @@ int dm_io_async(unsigned int num_regions int dm_io_async_bvec(unsigned int num_regions, struct io_region *where, int rw, struct bio_vec *bvec, io_notify_fn fn, void *context); +int dm_io_async_vm(unsigned int num_regions, struct io_region *where, int rw, + void *data, io_notify_fn fn, void *context); + #endif