/*1* Copyright (C) 2003 Sistina Software.2* Copyright (C) 2004 Red Hat, Inc. All rights reserved.3*4* Module Author: Heinz Mauelshagen5*6* This file is released under the GPL.7*8* Path-Selector registration.9*/1011#ifndef DM_PATH_SELECTOR_H12#define DM_PATH_SELECTOR_H1314#include <linux/device-mapper.h>1516#include "dm-mpath.h"1718/*19* We provide an abstraction for the code that chooses which path20* to send some io down.21*/22struct path_selector_type;23struct path_selector {24struct path_selector_type *type;25void *context;26};2728/* Information about a path selector type */29struct path_selector_type {30char *name;31struct module *module;3233unsigned int table_args;34unsigned int info_args;3536/*37* Constructs a path selector object, takes custom arguments38*/39int (*create) (struct path_selector *ps, unsigned argc, char **argv);40void (*destroy) (struct path_selector *ps);4142/*43* Add an opaque path object, along with some selector specific44* path args (eg, path priority).45*/46int (*add_path) (struct path_selector *ps, struct dm_path *path,47int argc, char **argv, char **error);4849/*50* Chooses a path for this io, if no paths are available then51* NULL will be returned.52*53* repeat_count is the number of times to use the path before54* calling the function again. 0 means don't call it again unless55* the path fails.56*/57struct dm_path *(*select_path) (struct path_selector *ps,58unsigned *repeat_count,59size_t nr_bytes);6061/*62* Notify the selector that a path has failed.63*/64void (*fail_path) (struct path_selector *ps, struct dm_path *p);6566/*67* Ask selector to reinstate a path.68*/69int (*reinstate_path) (struct path_selector *ps, struct dm_path *p);7071/*72* Table content based on parameters added in ps_add_path_fn73* or path selector status74*/75int (*status) (struct path_selector *ps, struct dm_path *path,76status_type_t type, char *result, unsigned int maxlen);7778int (*start_io) (struct path_selector *ps, struct dm_path *path,79size_t nr_bytes);80int (*end_io) (struct path_selector *ps, struct dm_path *path,81size_t nr_bytes);82};8384/* Register a path selector */85int dm_register_path_selector(struct path_selector_type *type);8687/* Unregister a path selector */88int dm_unregister_path_selector(struct path_selector_type *type);8990/* Returns a registered path selector type */91struct path_selector_type *dm_get_path_selector(const char *name);9293/* Releases a path selector */94void dm_put_path_selector(struct path_selector_type *pst);9596#endif979899