/* * Copyright (C) 2003 Sistina Software Limited. * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. * * This file is released under the GPL. */#include"dm.h"#include"dm-path-selector.h"#include"dm-hw-handler.h"#include"dm-bio-list.h"#include"dm-bio-record.h"#include<linux/ctype.h>#include<linux/init.h>#include<linux/mempool.h>#include<linux/module.h>#include<linux/pagemap.h>#include<linux/slab.h>#include<linux/time.h>#include<linux/workqueue.h>#include<asm/atomic.h>#define MESG_STR(x) x, sizeof(x)/* Path properties */structpgpath{structlist_headlist;structpriority_group*pg;/* Owning PG */unsignedfail_count;/* Cumulative failure count */structpathpath;};#define path_to_pgpath(__pgp) container_of((__pgp), struct pgpath, path)/* * Paths are grouped into Priority Groups and numbered from 1 upwards. * Each has a path selector which controls which path gets used. */structpriority_group{structlist_headlist;structmultipath*m;/* Owning multipath instance */structpath_selectorps;unsignedpg_num;/* Reference number */unsignedbypassed;/* Temporarily bypass this PG? */unsignednr_pgpaths;/* Number of paths in PG */structlist_headpgpaths;};/* Multipath context */structmultipath{structlist_headlist;structdm_target*ti;spinlock_tlock;structhw_handlerhw_handler;unsignednr_priority_groups;structlist_headpriority_groups;unsignedpg_init_required;/* pg_init needs calling? */unsignednr_valid_paths;/* Total number of usable paths */structpgpath*current_pgpath;structpriority_group*current_pg;structpriority_group*next_pg;/* Switch to this PG if set */unsignedrepeat_count;/* I/Os left before calling PS again */unsignedqueue_io;/* Must we queue all I/O? */unsignedqueue_if_no_path;/* Queue I/O if last path fails? */unsignedsuspended;/* Has dm core suspended our I/O? */structwork_structprocess_queued_ios;structbio_listqueued_ios;unsignedqueue_size;structwork_structtrigger_event;/* * We must use a mempool of mpath_io structs so that we * can resubmit bios on error. */mempool_t*mpio_pool;};/* * Context information attached to each bio we process. */structmpath_io{structpgpath*pgpath;structdm_bio_detailsdetails;};typedefint(*action_fn)(structpgpath*pgpath);#define MIN_IOS 256 /* Mempool size */statickmem_cache_t*_mpio_cache;staticvoidprocess_queued_ios(void*data);staticvoidtrigger_event(void*data);/*----------------------------------------------- * Allocation routines *-----------------------------------------------*/staticstructpgpath*alloc_pgpath(void){structpgpath*pgpath