Whamcloud - gitweb
b=13299
[fs/lustre-release.git] / lustre / include / lustre_export.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  */
4
5 #ifndef __EXPORT_H
6 #define __EXPORT_H
7
8 #include <lustre/lustre_idl.h>
9 #include <lustre_dlm.h>
10 #include <lprocfs_status.h>
11
12 /* Data stored per client in the last_rcvd file.  In le32 order. */
13 struct mds_client_data;
14
15 struct mds_export_data {
16         struct list_head        med_open_head;
17         spinlock_t              med_open_lock; /* lock med_open_head, mfd_list*/
18         struct mds_client_data *med_mcd;
19         __u64                   med_ibits_known;
20         loff_t                  med_lr_off;
21         int                     med_lr_idx;
22 };
23
24 struct osc_creator {
25         spinlock_t              oscc_lock;
26         struct list_head        oscc_list;
27         struct obd_device       *oscc_obd;
28         obd_id                  oscc_last_id;//last available pre-created object
29         obd_id                  oscc_next_id;// what object id to give out next
30         int                     oscc_grow_count;
31         struct obdo             oscc_oa;
32         int                     oscc_flags;
33         cfs_waitq_t             oscc_waitq; /* creating procs wait on this */
34 };
35
36 struct ldlm_export_data {
37         struct list_head       led_held_locks; /* protected by led_lock below */
38         spinlock_t             led_lock;
39 };
40
41 struct ec_export_data { /* echo client */
42         struct list_head eced_locks;
43 };
44
45 /* In-memory access to client data from OST struct */
46 struct filter_client_data;
47 struct filter_export_data {
48         spinlock_t                 fed_lock;      /* protects fed_open_head */
49         struct filter_client_data *fed_fcd;
50         loff_t                     fed_lr_off;
51         int                        fed_lr_idx;
52         long                       fed_dirty;    /* in bytes */
53         long                       fed_grant;    /* in bytes */
54         struct list_head           fed_mod_list; /* files being modified */
55         int                        fed_mod_count;/* items in fed_writing list */
56         long                       fed_pending;  /* bytes just being written */
57         struct brw_stats           fed_brw_stats;
58 };
59
60 typedef struct nid_stat {
61         lnet_nid_t               nid;
62         struct list_head         nid_chain;
63         struct obd_device       *nid_obd;
64         struct proc_dir_entry   *nid_proc;
65         struct lprocfs_stats    *nid_stats;
66         struct brw_stats        *nid_brw_stats;
67         int                      nid_exp_ref_count;
68 }nid_stat_t;
69
70 struct obd_export {
71         struct portals_handle     exp_handle;
72         atomic_t                  exp_refcount;
73         atomic_t                  exp_rpc_count;
74         struct obd_uuid           exp_client_uuid;
75         struct list_head          exp_obd_chain;
76         struct hlist_node         exp_uuid_hash; /* uuid-export hash*/
77         struct hlist_node         exp_nid_hash; /* nid-export hash */
78         /* exp_obd_chain_timed fo ping evictor, protected by obd_dev_lock */
79         struct list_head          exp_obd_chain_timed;
80         struct obd_device        *exp_obd;
81         struct obd_import        *exp_imp_reverse; /* to make RPCs backwards */
82         struct nid_stat          *exp_nid_stats;
83         struct lprocfs_stats     *exp_ldlm_stats;
84         struct ptlrpc_connection *exp_connection;
85         __u32                     exp_conn_cnt;
86         struct ldlm_export_data   exp_ldlm_data;
87         struct list_head          exp_outstanding_replies;
88         time_t                    exp_last_request_time;
89         spinlock_t                exp_lock; /* protects flags int below */
90         /* ^ protects exp_outstanding_replies too */
91         __u64                     exp_connect_flags;
92         int                       exp_flags;
93         unsigned int              exp_failed:1,
94                                   exp_disconnected:1,
95                                   exp_connecting:1,
96                                   exp_replay_needed:1,
97                                   exp_need_sync:1, /* needs sync from connect */
98                                   exp_libclient:1; /* liblustre client? */
99         union {
100                 struct mds_export_data    eu_mds_data;
101                 struct filter_export_data eu_filter_data;
102                 struct ec_export_data     eu_ec_data;
103         } u;
104 };
105
106 #define exp_mds_data    u.eu_mds_data
107 #define exp_lov_data    u.eu_lov_data
108 #define exp_filter_data u.eu_filter_data
109 #define exp_ec_data     u.eu_ec_data
110
111 static inline int exp_connect_cancelset(struct obd_export *exp)
112 {
113         return exp ? !!(exp->exp_connect_flags & OBD_CONNECT_CANCELSET) : 0;
114 }
115
116 static inline int exp_connect_lru_resize(struct obd_export *exp)
117 {
118         LASSERT(exp != NULL);
119         return !!(exp->exp_connect_flags & OBD_CONNECT_LRU_RESIZE);
120 }
121
122 static inline int imp_connect_lru_resize(struct obd_import *imp)
123 {
124         struct obd_connect_data *ocd;
125
126         LASSERT(imp != NULL);
127         ocd = &imp->imp_connect_data;
128         return !!(ocd->ocd_connect_flags & OBD_CONNECT_LRU_RESIZE);
129 }
130
131 struct exp_uuid_cb_data {
132         char                   *page;
133         int                     count;
134         int                    *eof;
135         int                    *len;
136         struct obd_export      *exp;
137 };
138
139 extern struct obd_export *class_conn2export(struct lustre_handle *conn);
140 extern struct obd_device *class_conn2obd(struct lustre_handle *conn);
141 typedef void (*hash_item_iterate_cb) (void *);
142
143 #endif /* __EXPORT_H */