dm: use kmem_cache macro
Alasdair G Kergon
maintainerPATCH 3/18 dm: use kmem_cache macro
From: Alasdair G Kergon <[email protected]>
Use new KMEM_CACHE() macro and make the newly-exposed structure names more meaningful. Also remove some superfluous casts and inlines (let a modern compiler be the judge).
Cc Christoph Lameter <[email protected]>
Signed-off-by Alasdair G Kergon <[email protected]>
--- drivers/md/dm-crypt.c | 30 +++++------ drivers/md/dm-delay.c | 11 +--- drivers/md/dm-exception-store.c | 17 +++--- drivers/md/dm-mpath.c | 23 ++++---- drivers/md/dm-snap.c | 105 +++++++++++++++++++--------------------- drivers/md/dm-snap.h | 6 +- drivers/md/dm.c | 24 ++++----- drivers/md/kcopyd.c | 11 +--- 8 files changed, 106 insertions(+), 121 deletions(-)
drivers/md/dm-crypt.c +14 -16
@@ -30,7 +30,7 @@/* * per bio private data */ -struct crypt_io { +struct dm_crypt_io {struct dm_target *target;struct bio *base_bio;struct work_struct work;
@@ -106,7 +106,7 @@ struct crypt_config {static struct kmem_cache *_crypt_io_pool; -static void clone_init (struct crypt_io *,struct bio *); +static void clone_init (struct dm_crypt_io *,struct bio *);/* * Different IV generation algorithms:
@@ -382,7 +382,7 @@ static int crypt_convert(struct crypt_costatic void dm_crypt_bio_destructor (struct bio *bio) { -struct crypt_io *io = bio->bi_private; +struct dm_crypt_io *io = bio->bi_private;struct crypt_config *cc = io->target->private;bio_free (bio, cc->bs);
@@ -393,7 +393,7 @@ static int crypt_convert(struct crypt_co* This should never violate the device limitations * May return a smaller bio when running out of pages */ -static struct bio *crypt_alloc_buffer (struct crypt_io *io,unsigned int size) +static struct bio *crypt_alloc_buffer (struct dm_crypt_io *io,unsigned size) {struct crypt_config *cc = io->target->private;struct bio *clone;
@@ -479,7 +479,7 @@ static void crypt_free_buffer_pages(stru* One of the bios was finished. Check for completion of * the whole request and correctly clean up the buffer. */ -static void dec_pending (struct crypt_io *io,int error) +static void dec_pending (struct dm_crypt_io *io,int error) {struct crypt_config *cc = (struct crypt_config *) io->target->private;
@@ -503,7 +503,7 @@ static void dec_pending(struct crypt_iostatic struct workqueue_struct *_kcryptd_workqueue;static void kcryptd_do_work (struct work_struct *work); -static void kcryptd_queue_io (struct crypt_io *io) +static void kcryptd_queue_io (struct dm_crypt_io *io) {INIT_WORK (&io->work, kcryptd_do_work);queue_work (_kcryptd_workqueue, &io->work);
@@ -511,7 +511,7 @@ static void kcryptd_queue_io(struct crypstatic int crypt_endio (struct bio *clone,unsigned int done,int error) { -struct crypt_io *io = clone->bi_private; +struct dm_crypt_io *io = clone->bi_private;struct crypt_config *cc = io->target->private;unsigned read_io =bio_data_dir (clone) ==READ ;
@@ -545,7 +545,7 @@ out:return error; } -static void clone_init (struct crypt_io *io,struct bio *clone) +static void clone_init (struct dm_crypt_io *io,struct bio *clone) {struct crypt_config *cc = io->target->private;
@@ -556,7 +556,7 @@ static void clone_init(struct crypt_io * clone->bi_destructor = dm_crypt_bio_destructor; } -static void process_read (struct crypt_io *io) +static void process_read (struct dm_crypt_io *io) {struct crypt_config *cc = io->target->private;struct bio *base_bio = io->base_bio;
@@ -587,7 +587,7 @@ static void process_read(struct crypt_iogeneric_make_request (clone); } -static void process_write (struct crypt_io *io) +static void process_write (struct dm_crypt_io *io) {struct crypt_config *cc = io->target->private;struct bio *base_bio = io->base_bio;
@@ -644,7 +644,7 @@ static void process_write(struct crypt_i } } -static void process_read_endio (struct crypt_io *io) +static void process_read_endio (struct dm_crypt_io *io) {struct crypt_config *cc = io->target->private;struct convert_context ctx;
@@ -657,7 +657,7 @@ static void process_read_endio(struct crstatic void kcryptd_do_work (struct work_struct *work) { - struct crypt_io *io = container_of(work, struct crypt_io, work); + struct dm_crypt_io *io = container_of(work, struct dm_crypt_io, work);if (io->post_process)process_read_endio (io);
@@ -939,7 +939,7 @@ static int crypt_map(struct dm_target *t union map_info *map_context) {struct crypt_config *cc = ti->private; -struct crypt_io *io; +struct dm_crypt_io *io;if (bio_barrier (bio))return -EOPNOTSUPP ;
@@ -1062,9 +1062,7 @@ static int __init dm_crypt_init(void) {int r; - _crypt_io_pool =kmem_cache_create ("dm-crypt_io" , -sizeof (struct crypt_io ), -0 ,0 ,NULL ,NULL ); + _crypt_io_pool =KMEM_CACHE (dm_crypt_io,0 );if (!_crypt_io_pool)return -ENOMEM ;
drivers/md/dm-delay.c +4 -7
@@ -37,7 +37,7 @@ struct delay_c {unsigned writes; }; -struct delay_info { +struct dm_delay_info {struct delay_c *context;struct list_head list;struct bio *bio;
@@ -80,7 +80,7 @@ static void flush_bios(struct bio *bio)static struct bio *flush_delayed_bios (struct delay_c *dc,int flush_all) { -struct delay_info *delayed, *next; +struct dm_delay_info *delayed, *next;unsigned long next_expires =0 ;int start_timer =0 ;DEFINE_BIO_LIST (flush_bios);
@@ -227,7 +227,7 @@ static void delay_dtr(struct dm_target *static int delay_bio (struct delay_c *dc,int delay,struct bio *bio) { -struct delay_info *delayed; +struct dm_delay_info *delayed;unsigned long expires =0 ;if (!delay || !atomic_read (&dc->may_delay))
@@ -338,10 +338,7 @@ static int __init dm_delay_init(void) goto bad_queue; } - delayed_cache =kmem_cache_create ("dm-delay" , -sizeof (struct delay_info ), - __alignof__(struct delay_info ), -0 ,NULL ,NULL ); + delayed_cache =KMEM_CACHE (dm_delay_info,0 );if (!delayed_cache) {DMERR ("Couldn't create delayed bio cache." ); goto bad_memcache;
drivers/md/dm-exception-store.c +9 -8
@@ -127,7 +127,7 @@ struct pstore {struct dm_io_client *io_client; }; -static inline unsigned int sectors_to_pages (unsigned int sectors) +static unsigned sectors_to_pages (unsigned sectors) {return sectors / (PAGE_SIZE >>9 ); }
@@ -393,7 +393,7 @@ static int read_exceptions(struct pstorereturn 0 ; } -static inline struct pstore *get_info (struct exception_store *store) +static struct pstore *get_info (struct exception_store *store) {return (struct pstore *) store->context; }
@@ -480,7 +480,7 @@ static int persistent_read_metadata(stru }static int persistent_prepare (struct exception_store *store, -struct exception *e) +struct dm_snap_exception *e) {struct pstore *ps =get_info (store);uint32_t stride;
@@ -505,7 +505,7 @@ static int persistent_prepare(struct exc }static void persistent_commit (struct exception_store *store, -struct exception *e, +struct dm_snap_exception *e,void (*callback) (void *,int success),void *callback_context) {
@@ -616,7 +616,8 @@ static int transient_read_metadata(strucreturn 0 ; } -static int transient_prepare (struct exception_store *store,struct exception *e) +static int transient_prepare (struct exception_store *store, +struct dm_snap_exception *e) {struct transient_c *tc = (struct transient_c *) store->context;sector_t size =get_dev_size (store->snap->cow->bdev);
@@ -631,9 +632,9 @@ static int transient_prepare(struct exce }static void transient_commit (struct exception_store *store, -struct exception *e, -void (*callback) (void *,int success), -void *callback_context) +struct dm_snap_exception *e, +void (*callback) (void *,int success), +void *callback_context) {/* Just succeed */ callback (callback_context,1 );
drivers/md/dm-mpath.c +11 -12
@@ -83,7 +83,7 @@ struct multipath {struct work_struct trigger_event;/* -* We must use a mempool of mpath_io structs so that we +* We must use a mempool of dm_mpath_io structs so that we * can resubmit bios on error. */ mempool_t *mpio_pool;
@@ -92,7 +92,7 @@ struct multipath {/* * Context information attached to each bio we process. */ -struct mpath_io { +struct dm_mpath_io {struct pgpath *pgpath;struct dm_bio_details details; };
@@ -122,7 +122,7 @@ static struct pgpath *alloc_pgpath(void)return pgpath; } -static inline void free_pgpath (struct pgpath *pgpath) +static void free_pgpath (struct pgpath *pgpath) {kfree (pgpath); }
@@ -299,8 +299,8 @@ static int __must_push_back(struct multi dm_noflush_suspending(m->ti)); } -static int map_io (struct multipath *m,struct bio *bio,struct mpath_io *mpio, -unsigned was_queued) +static int map_io (struct multipath *m,struct bio *bio, +struct dm_mpath_io *mpio,unsigned was_queued) {int r =DM_MAPIO_REMAPPED ;unsigned long flags;
@@ -374,7 +374,7 @@ static void dispatch_queued_ios(struct mint r;unsigned long flags;struct bio *bio =NULL , *next; -struct mpath_io *mpio; +struct dm_mpath_io *mpio;union map_info *info;spin_lock_irqsave (&m->lock, flags);
@@ -795,7 +795,7 @@ static int multipath_map(struct dm_targe union map_info *map_context) {int r; -struct mpath_io *mpio; +struct dm_mpath_io *mpio;struct multipath *m = (struct multipath *) ti->private;if (bio_barrier (bio))
@@ -1014,7 +1014,7 @@ void dm_pg_init_complete(struct dm_path* end_io handling */ static int do_end_io (struct multipath *m,struct bio *bio, -int error,struct mpath_io *mpio) +int error,struct dm_mpath_io *mpio) {struct hw_handler *hwh = &m->hw_handler;unsigned err_flags =MP_FAIL_PATH ;/* Default behavior */
@@ -1075,8 +1075,8 @@ static int do_end_io(struct multipath *mstatic int multipath_end_io (struct dm_target *ti,struct bio *bio,int error,union map_info *map_context) { -struct multipath *m = (struct multipath *) ti->private; -struct mpath_io *mpio = (struct mpath_io *) map_context->ptr; +struct multipath *m = ti->private; +struct dm_mpath_io *mpio = map_context->ptr;struct pgpath *pgpath = mpio->pgpath;struct path_selector *ps;int r;
@@ -1346,8 +1346,7 @@ static int __init dm_multipath_init(voidint r;/* allocate a slab for the dm_ios */ - _mpio_cache =kmem_cache_create ("dm_mpath" ,sizeof (struct mpath_io ), -0 ,0 ,NULL ,NULL ); + _mpio_cache =KMEM_CACHE (dm_mpath_io,0 );if (!_mpio_cache)return -ENOMEM ;
drivers/md/dm-snap.c +50 -55
321 lines not on this page · raw message
drivers/md/dm-snap.h +3 -3
@@ -30,7 +30,7 @@ typedef sector_t chunk_t;* An exception is used where an old chunk of data has been * replaced by a new one. */ -struct exception { +struct dm_snap_exception {struct list_head hash_list;chunk_t old_chunk;
@@ -58,13 +58,13 @@ struct exception_store {* Find somewhere to store the next exception. */ int (*prepare_exception) (struct exception_store *store, -struct exception *e); +struct dm_snap_exception *e);/* * Update the metadata with this exception. */ void (*commit_exception) (struct exception_store *store, -struct exception *e, +struct dm_snap_exception *e,void (*callback) (void *,int success),void *callback_context);
drivers/md/dm.c +11 -13
@@ -45,7 +45,7 @@ struct dm_io {* One of these is allocated per target within a bio. Hopefully * this will be simplified out one day. */ -struct target_io { +struct dm_target_io {struct dm_io *io;struct dm_target *ti;union map_info info;
@@ -54,7 +54,7 @@ struct target_io {union map_info *dm_get_mapinfo (struct bio *bio) {if (bio && bio->bi_private) -return &((struct target_io *)bio->bi_private)->info; +return &((struct dm_target_io *)bio->bi_private)->info;return NULL ; }
@@ -132,14 +132,12 @@ static int __init local_init(void)int r;/* allocate a slab for the dm_ios */ - _io_cache =kmem_cache_create ("dm_io" , -sizeof (struct dm_io ),0 ,0 ,NULL ,NULL ); + _io_cache =KMEM_CACHE (dm_io,0 );if (!_io_cache)return -ENOMEM ;/* allocate a slab for the target ios */ - _tio_cache =kmem_cache_create ("dm_tio" ,sizeof (struct target_io ), -0 ,0 ,NULL ,NULL ); + _tio_cache =KMEM_CACHE (dm_target_io,0 );if (!_tio_cache) {kmem_cache_destroy (_io_cache);return -ENOMEM ;
@@ -325,22 +323,22 @@ out:return r; } -static inline struct dm_io *alloc_io (struct mapped_device *md) +static struct dm_io *alloc_io (struct mapped_device *md) {return mempool_alloc (md->io_pool,GFP_NOIO ); } -static inline void free_io (struct mapped_device *md,struct dm_io *io) +static void free_io (struct mapped_device *md,struct dm_io *io) {mempool_free (io, md->io_pool); } -static inline struct target_io *alloc_tio (struct mapped_device *md) +static struct dm_target_io *alloc_tio (struct mapped_device *md) {return mempool_alloc (md->tio_pool,GFP_NOIO ); } -static inline void free_tio (struct mapped_device *md,struct target_io *tio) +static void free_tio (struct mapped_device *md,struct dm_target_io *tio) {mempool_free (tio, md->tio_pool); }
@@ -498,7 +496,7 @@ static void dec_pending(struct dm_io *iostatic int clone_endio (struct bio *bio,unsigned int done,int error) {int r =0 ; -struct target_io *tio = bio->bi_private; +struct dm_target_io *tio = bio->bi_private;struct mapped_device *md = tio->io->md;dm_endio_fn endio = tio->ti->type->end_io;
@@ -558,7 +556,7 @@ static sector_t max_io_len(struct mapped }static void __map_bio (struct dm_target *ti,struct bio *clone, -struct target_io *tio) +struct dm_target_io *tio) {int r;sector_t sector;
@@ -672,7 +670,7 @@ static void __clone_and_map(struct clonestruct bio *clone, *bio = ci->bio;struct dm_target *ti =dm_table_find_target (ci->map, ci->sector);sector_t len =0 , max =max_io_len (ci->md, ci->sector, ti); -struct target_io *tio; +struct dm_target_io *tio;/* * Allocate a target io object.
drivers/md/kcopyd.c +4 -7
@@ -29,7 +29,7 @@static struct workqueue_struct *_kcopyd_wq;static struct work_struct _kcopyd_work; -static inline void wake (void ) +static void wake (void ) {queue_work (_kcopyd_wq, &_kcopyd_work); }
@@ -226,10 +226,7 @@ static LIST_HEAD(_pages_jobs);static int jobs_init (void ) { - _job_cache =kmem_cache_create ("kcopyd-jobs" , -sizeof (struct kcopyd_job ), - __alignof__(struct kcopyd_job ), -0 ,NULL ,NULL ); + _job_cache =KMEM_CACHE (kcopyd_job,0 );if (!_job_cache)return -ENOMEM ;
@@ -258,7 +255,7 @@ static void jobs_exit(void)* Functions to push and pop a job onto the head of a given job * list. */ -static inline struct kcopyd_job *pop (struct list_head *jobs) +static struct kcopyd_job *pop (struct list_head *jobs) {struct kcopyd_job *job =NULL ;unsigned long flags;
@@ -274,7 +271,7 @@ static inline struct kcopyd_job *pop(strreturn job; } -static inline void push (struct list_head *jobs,struct kcopyd_job *job) +static void push (struct list_head *jobs,struct kcopyd_job *job) {unsigned long flags;