Lines Matching refs:io

18 #include <linux/dm-io.h>
20 #define DM_MSG_PREFIX "io"
30 * Aligning 'struct io' reduces the number of bits required to store
33 struct io {
84 * We need to keep track of which region a bio is doing io for.
86 * ensure the 'struct io' pointer is aligned so enough low bits are
90 static void store_io_and_region_in_bio(struct bio *bio, struct io *io,
93 if (unlikely(!IS_ALIGNED((unsigned long)io, DM_IO_MAX_REGIONS))) {
94 DMCRIT("Unaligned struct io pointer %p", io);
98 bio->bi_private = (void *)((unsigned long)io | region);
101 static void retrieve_io_and_region_from_bio(struct bio *bio, struct io **io,
106 *io = (void *)(val & -(unsigned long)DM_IO_MAX_REGIONS);
111 * We need an io object to keep track of the number of bios that
112 * have been dispatched for a particular io.
114 static void complete_io(struct io *io)
116 unsigned long error_bits = io->error_bits;
117 io_notify_fn fn = io->callback;
118 void *context = io->context;
120 if (io->vma_invalidate_size)
121 invalidate_kernel_vmap_range(io->vma_invalidate_address,
122 io->vma_invalidate_size);
124 mempool_free(io, &io->client->pool);
128 static void dec_count(struct io *io, unsigned int region, blk_status_t error)
131 set_bit(region, &io->error_bits);
133 if (atomic_dec_and_test(&io->count))
134 complete_io(io);
139 struct io *io;
147 * The bio destructor in bio_put() may use the io object.
149 retrieve_io_and_region_from_bio(bio, &io, &region);
154 dec_count(io, region, error);
159 * destination page for io.
298 struct io *io)
322 atomic_inc(&io->count);
323 dec_count(io, region, BLK_STS_NOTSUPP);
348 bio = bio_alloc_bioset(GFP_NOIO, num_bvecs, &io->client->bios);
353 store_io_and_region_in_bio(bio, io, region);
385 atomic_inc(&io->count);
392 struct io *io, int sync)
409 do_region(op, op_flags, i, where + i, dp, io);
414 * the io being completed too early.
416 dec_count(io, 0, 0);
436 struct io *io;
446 io = mempool_alloc(&client->pool, GFP_NOIO);
447 io->error_bits = 0;
448 atomic_set(&io->count, 1); /* see dispatch_io() */
449 io->client = client;
450 io->callback = sync_io_complete;
451 io->context = &sio;
453 io->vma_invalidate_address = dp->vma_invalidate_address;
454 io->vma_invalidate_size = dp->vma_invalidate_size;
456 dispatch_io(op, op_flags, num_regions, where, dp, io, 1);
470 struct io *io;
478 io = mempool_alloc(&client->pool, GFP_NOIO);
479 io->error_bits = 0;
480 atomic_set(&io->count, 1); /* see dispatch_io() */
481 io->client = client;
482 io->callback = fn;
483 io->context = context;
485 io->vma_invalidate_address = dp->vma_invalidate_address;
486 io->vma_invalidate_size = dp->vma_invalidate_size;
488 dispatch_io(op, op_flags, num_regions, where, dp, io, 0);
560 _dm_io_cache = KMEM_CACHE(io, 0);