/* * 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? */unsignedpg_init_in_progress;/* Only one pg_init allowed at once */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? */unsignedsaved_queue_if_no_path;/* Saved state during suspension */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)(struct<