Whamcloud - gitweb
use special macro for print time_t, cleanup in includes.
[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 struct mdt_client_data;
15 struct mds_idmap_table;
16 struct mdt_idmap_table;
17
18 struct mds_export_data {
19         struct list_head        med_open_head;
20         spinlock_t              med_open_lock; /* lock med_open_head, mfd_list*/
21         struct mds_client_data *med_mcd;
22         __u64                   med_ibits_known;
23         loff_t                  med_lr_off;
24         int                     med_lr_idx;
25         unsigned int            med_rmtclient:1; /* remote client? */
26         struct semaphore           med_idmap_sem;
27         struct lustre_idmap_table *med_idmap;
28 };
29
30 struct mdt_export_data {
31         struct list_head        med_open_head;
32         spinlock_t              med_open_lock; /* lock med_open_head, mfd_list*/
33         struct semaphore        med_mcd_lock; 
34         struct mdt_client_data *med_mcd;
35         __u64                   med_ibits_known;
36         loff_t                  med_lr_off;
37         int                     med_lr_idx;
38         unsigned int            med_rmtclient:1; /* remote client? */
39         struct semaphore           med_idmap_sem;
40         struct lustre_idmap_table *med_idmap;
41 };
42
43 struct osc_creator {
44         spinlock_t              oscc_lock;
45         struct list_head        oscc_list;
46         struct obd_device       *oscc_obd;
47         obd_id                  oscc_last_id;//last available pre-created object
48         obd_id                  oscc_next_id;// what object id to give out next
49         int                     oscc_grow_count;
50         struct obdo             oscc_oa;
51         int                     oscc_flags;
52         cfs_waitq_t             oscc_waitq; /* creating procs wait on this */
53 };
54
55 struct ldlm_export_data {
56         struct list_head       led_held_locks; /* protected by led_lock */
57         spinlock_t             led_lock;
58 };
59
60 struct ec_export_data { /* echo client */
61         struct list_head eced_locks;
62 };
63
64 /* In-memory access to client data from OST struct */
65 struct filter_client_data;
66 struct filter_export_data {
67         spinlock_t                 fed_lock;      /* protects fed_open_head */
68         struct filter_client_data *fed_fcd;
69         loff_t                     fed_lr_off;
70         int                        fed_lr_idx;
71         long                       fed_dirty;    /* in bytes */
72         long                       fed_grant;    /* in bytes */
73         struct list_head           fed_mod_list; /* files being modified */
74         int                        fed_mod_count;/* items in fed_writing list */
75         long                       fed_pending;  /* bytes just being written */
76         __u32                      fed_group;
77         struct brw_stats           fed_brw_stats;
78 };
79
80 typedef struct nid_stat {
81         lnet_nid_t               nid;
82         struct hlist_node        nid_hash;
83         struct list_head         nid_list;
84         struct obd_device       *nid_obd;
85         struct proc_dir_entry   *nid_proc;
86         struct lprocfs_stats    *nid_stats;
87         struct brw_stats        *nid_brw_stats;
88         int                      nid_exp_ref_count;
89 }nid_stat_t;
90
91 struct obd_export {
92         struct portals_handle     exp_handle;
93         atomic_t                  exp_refcount;
94         atomic_t                  exp_rpc_count;
95         struct obd_uuid           exp_client_uuid;
96         struct list_head          exp_obd_chain;
97         struct hlist_node         exp_uuid_hash; /* uuid-export hash*/
98         struct hlist_node         exp_nid_hash; /* nid-export hash */
99         /* exp_obd_chain_timed fo ping evictor, protected by obd_dev_lock */
100         struct list_head          exp_obd_chain_timed;
101         struct obd_device        *exp_obd;
102         struct obd_import        *exp_imp_reverse; /* to make RPCs backwards */
103         struct nid_stat          *exp_nid_stats;
104         struct lprocfs_stats     *exp_md_stats;
105         struct lprocfs_stats     *exp_ldlm_stats;
106         struct ptlrpc_connection *exp_connection;
107         __u32                     exp_conn_cnt;
108         struct ldlm_export_data   exp_ldlm_data;
109         struct list_head          exp_outstanding_replies;
110         time_t                    exp_last_request_time;
111         spinlock_t                exp_lock; /* protects flags int below */
112         /* ^ protects exp_outstanding_replies too */
113         __u64                     exp_connect_flags;
114         int                       exp_flags;
115         unsigned long             exp_failed:1,
116                                   exp_in_recovery:1,
117                                   exp_disconnected:1,
118                                   exp_connecting:1,
119                                   exp_req_replay_needed:1,
120                                   exp_lock_replay_needed:1,
121                                   exp_need_sync:1,
122                                   exp_flvr_changed:1,
123                                   exp_flvr_adapt:1,
124                                   exp_libclient:1; /* liblustre client? */
125         /* also protected by exp_lock */
126         enum lustre_sec_part      exp_sp_peer;
127         struct sptlrpc_flavor     exp_flvr;             /* current */
128         struct sptlrpc_flavor     exp_flvr_old[2];      /* about-to-expire */
129         cfs_time_t                exp_flvr_expire[2];   /* seconds */
130
131         union {
132                 struct mds_export_data    eu_mds_data;
133                 struct mdt_export_data    eu_mdt_data;
134                 struct filter_export_data eu_filter_data;
135                 struct ec_export_data     eu_ec_data;
136         } u;
137 };
138
139 #define exp_mds_data    u.eu_mds_data
140 #define exp_mdt_data    u.eu_mdt_data
141 #define exp_lov_data    u.eu_lov_data
142 #define exp_filter_data u.eu_filter_data
143 #define exp_ec_data     u.eu_ec_data
144
145 static inline int exp_connect_cancelset(struct obd_export *exp)
146 {
147         LASSERT(exp != NULL);
148         return !!(exp->exp_connect_flags & OBD_CONNECT_CANCELSET);
149 }
150
151 static inline int exp_connect_lru_resize(struct obd_export *exp)
152 {
153         LASSERT(exp != NULL);
154         return !!(exp->exp_connect_flags & OBD_CONNECT_LRU_RESIZE);
155 }
156
157 static inline int imp_connect_lru_resize(struct obd_import *imp)
158 {
159         struct obd_connect_data *ocd;
160
161         LASSERT(imp != NULL);
162         ocd = &imp->imp_connect_data;
163         return !!(ocd->ocd_connect_flags & OBD_CONNECT_LRU_RESIZE);
164 }
165
166 extern struct obd_export *class_conn2export(struct lustre_handle *conn);
167 extern struct obd_device *class_conn2obd(struct lustre_handle *conn);
168
169 #endif /* __EXPORT_H */