Whamcloud - gitweb
land v0.9.1 on HEAD, in preparation for a 1.0.x branch
[fs/lustre-release.git] / lustre / include / linux / lustre_import.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * Copyright (C) 2001  Cluster File Systems, Inc.
5  *
6  * This code is issued under the GNU General Public License.
7  * See the file COPYING in this distribution
8  */
9
10 #ifndef __IMPORT_H
11 #define __IMPORT_H
12
13 #include <linux/lustre_handles.h>
14 #include <linux/lustre_idl.h>
15
16 enum lustre_imp_state {
17 //        LUSTRE_IMP_INVALID    = 1,
18         LUSTRE_IMP_NEW        = 2,
19         LUSTRE_IMP_DISCON     = 3,
20         LUSTRE_IMP_CONNECTING = 4,
21         LUSTRE_IMP_REPLAY     = 5,
22         LUSTRE_IMP_RECOVER    = 6,
23         LUSTRE_IMP_FULL       = 7,
24         LUSTRE_IMP_EVICTED    = 8,
25 };
26
27
28 struct obd_import {
29         struct portals_handle     imp_handle;
30         atomic_t                  imp_refcount;
31         struct lustre_handle      imp_dlm_handle; /* client's ldlm export */
32         struct ptlrpc_connection *imp_connection;
33         struct ptlrpc_client     *imp_client;
34         struct list_head          imp_observers;
35         struct list_head          imp_pinger_chain;
36
37         /* Lists of requests that are retained for replay, waiting for a reply,
38          * or waiting for recovery to complete, respectively.
39          */
40         struct list_head          imp_replay_list;
41         struct list_head          imp_sending_list;
42         struct list_head          imp_delayed_list;
43
44         struct obd_device        *imp_obd;
45         struct semaphore          imp_recovery_sem;
46         enum lustre_imp_state     imp_state;
47         int                       imp_generation;
48         __u32                     imp_conn_cnt;
49         __u64                     imp_max_transno;
50         __u64                     imp_peer_committed_transno;
51         struct obd_uuid           imp_target_uuid; /* XXX -> lustre_name */
52         struct lustre_handle      imp_remote_handle;
53         unsigned long             imp_next_ping;
54         
55         /* Protects flags, level, generation, conn_cnt, *_list */
56         spinlock_t                imp_lock;
57
58         /* flags */
59         int                       imp_invalid:1, imp_replayable:1,
60                                   imp_dlm_fake:1, imp_server_timeout:1;
61         __u32                     imp_connect_op;
62 };
63
64 typedef void (*obd_import_callback)(struct obd_import *imp, void *closure,
65                                     int event, void *event_arg, void *cb_data);
66
67 struct obd_import_observer {
68         struct list_head     oio_chain;
69         obd_import_callback  oio_cb;
70         void                *oio_cb_data;
71 };
72
73 void class_observe_import(struct obd_import *imp, obd_import_callback cb,
74                           void *cb_data);
75 void class_unobserve_import(struct obd_import *imp, obd_import_callback cb,
76                             void *cb_data);
77 void class_notify_import_observers(struct obd_import *imp, int event,
78                                    void *event_arg);
79
80 #define IMP_EVENT_ACTIVE   1
81 #define IMP_EVENT_INACTIVE 2
82
83 /* genops.c */
84 struct obd_export;
85 extern struct obd_import *class_exp2cliimp(struct obd_export *);
86 extern struct obd_import *class_conn2cliimp(struct lustre_handle *);
87
88 #endif /* __IMPORT_H */