Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (C) 2003 Sistina Software.
0003  * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
0004  *
0005  * Module Author: Heinz Mauelshagen
0006  *
0007  * This file is released under the GPL.
0008  *
0009  * Path-Selector registration.
0010  */
0011 
0012 #ifndef DM_PATH_SELECTOR_H
0013 #define DM_PATH_SELECTOR_H
0014 
0015 #include <linux/device-mapper.h>
0016 
0017 #include "dm-mpath.h"
0018 
0019 /*
0020  * We provide an abstraction for the code that chooses which path
0021  * to send some io down.
0022  */
0023 struct path_selector_type;
0024 struct path_selector {
0025     struct path_selector_type *type;
0026     void *context;
0027 };
0028 
0029 /*
0030  * If a path selector uses this flag, a high resolution timer is used
0031  * (via ktime_get_ns) to account for IO start time in BIO-based mpath.
0032  * This improves performance of some path selectors (i.e. HST), in
0033  * exchange for slightly higher overhead when submitting the BIO.
0034  * The extra cost is usually offset by improved path selection for
0035  * some benchmarks.
0036  *
0037  * This has no effect for request-based mpath, since it already uses a
0038  * higher precision timer by default.
0039  */
0040 #define DM_PS_USE_HR_TIMER      0x00000001
0041 #define dm_ps_use_hr_timer(type)    ((type)->features & DM_PS_USE_HR_TIMER)
0042 
0043 /* Information about a path selector type */
0044 struct path_selector_type {
0045     char *name;
0046     struct module *module;
0047 
0048     unsigned int features;
0049     unsigned int table_args;
0050     unsigned int info_args;
0051 
0052     /*
0053      * Constructs a path selector object, takes custom arguments
0054      */
0055     int (*create) (struct path_selector *ps, unsigned argc, char **argv);
0056     void (*destroy) (struct path_selector *ps);
0057 
0058     /*
0059      * Add an opaque path object, along with some selector specific
0060      * path args (eg, path priority).
0061      */
0062     int (*add_path) (struct path_selector *ps, struct dm_path *path,
0063              int argc, char **argv, char **error);
0064 
0065     /*
0066      * Chooses a path for this io, if no paths are available then
0067      * NULL will be returned.
0068      */
0069     struct dm_path *(*select_path) (struct path_selector *ps,
0070                     size_t nr_bytes);
0071 
0072     /*
0073      * Notify the selector that a path has failed.
0074      */
0075     void (*fail_path) (struct path_selector *ps, struct dm_path *p);
0076 
0077     /*
0078      * Ask selector to reinstate a path.
0079      */
0080     int (*reinstate_path) (struct path_selector *ps, struct dm_path *p);
0081 
0082     /*
0083      * Table content based on parameters added in ps_add_path_fn
0084      * or path selector status
0085      */
0086     int (*status) (struct path_selector *ps, struct dm_path *path,
0087                status_type_t type, char *result, unsigned int maxlen);
0088 
0089     int (*start_io) (struct path_selector *ps, struct dm_path *path,
0090              size_t nr_bytes);
0091     int (*end_io) (struct path_selector *ps, struct dm_path *path,
0092                size_t nr_bytes, u64 start_time);
0093 };
0094 
0095 /* Register a path selector */
0096 int dm_register_path_selector(struct path_selector_type *type);
0097 
0098 /* Unregister a path selector */
0099 int dm_unregister_path_selector(struct path_selector_type *type);
0100 
0101 /* Returns a registered path selector type */
0102 struct path_selector_type *dm_get_path_selector(const char *name);
0103 
0104 /* Releases a path selector  */
0105 void dm_put_path_selector(struct path_selector_type *pst);
0106 
0107 #endif