Whamcloud - gitweb
Branch HEAD
[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         __u32                   med_nllu;
27         __u32                   med_nllg;
28         struct mds_idmap_table *med_idmap;
29 };
30
31 struct mdt_export_data {
32         struct list_head        med_open_head;
33         spinlock_t              med_open_lock; /* lock med_open_head, mfd_list*/
34         struct semaphore        med_mcd_lock; 
35         struct mdt_client_data *med_mcd;
36         __u64                   med_ibits_known;
37         loff_t                  med_lr_off;
38         int                     med_lr_idx;
39         unsigned int            med_rmtclient:1; /* remote client? */
40         __u32                   med_nllu;
41         __u32                   med_nllg;
42         struct mdt_idmap_table *med_idmap;
43 };
44
45 struct osc_creator {
46         spinlock_t              oscc_lock;
47         struct list_head        oscc_list;
48         struct obd_device       *oscc_obd;
49         obd_id                  oscc_last_id;//last available pre-created object
50         obd_id                  oscc_next_id;// what object id to give out next
51         int                     oscc_grow_count;
52         struct obdo             oscc_oa;
53         int                     oscc_flags;
54         cfs_waitq_t             oscc_waitq; /* creating procs wait on this */
55 };
56
57 struct ldlm_export_data {
58         struct list_head       led_held_locks; /* protected by led_lock */
59         spinlock_t             led_lock;
60 };
61
62 struct ec_export_data { /* echo client */
63         struct list_head eced_locks;
64 };
65
66 /* In-memory access to client data from OST struct */
67 struct filter_client_data;
68 struct filter_export_data {
69         spinlock_t                 fed_lock;      /* protects fed_open_head */
70         struct filter_client_data *fed_fcd;
71         loff_t                     fed_lr_off;
72         int                        fed_lr_idx;
73         long                       fed_dirty;    /* in bytes */
74         long                       fed_grant;    /* in bytes */
75         struct list_head           fed_mod_list; /* files being modified */
76         int                        fed_mod_count;/* items in fed_writing list */
77         long                       fed_pending;  /* bytes just being written */
78         __u32                      fed_group;
79         struct brw_stats           fed_brw_stats;
80 };
81
82 struct obd_export {
83         struct portals_handle     exp_handle;
84         atomic_t                  exp_refcount;
85         atomic_t                  exp_rpc_count;
86         struct obd_uuid           exp_client_uuid;
87         struct list_head          exp_obd_chain;
88         /* exp_obd_chain_timed fo ping evictor, protected by obd_dev_lock */
89         struct list_head          exp_obd_chain_timed;
90         struct obd_device        *exp_obd;
91         struct obd_import        *exp_imp_reverse; /* to make RPCs backwards */
92         struct proc_dir_entry    *exp_proc;
93         struct lprocfs_stats     *exp_ops_stats;
94         struct lprocfs_stats     *exp_md_stats;
95         struct lprocfs_stats     *exp_ldlm_stats;
96         struct ptlrpc_connection *exp_connection;
97         __u32                     exp_conn_cnt;
98         struct ldlm_export_data   exp_ldlm_data;
99         struct list_head          exp_outstanding_replies;
100         time_t                    exp_last_request_time;
101         spinlock_t                exp_lock; /* protects flags int below */
102         /* ^ protects exp_outstanding_replies too */
103         __u64                     exp_connect_flags;
104         int                       exp_flags;
105         unsigned int              exp_failed:1,
106                                   exp_in_recovery:1,
107                                   exp_disconnected:1,
108                                   exp_connecting:1,
109                                   exp_req_replay_needed:1,
110                                   exp_lock_replay_needed:1,
111                                   exp_need_sync:1,
112                                   exp_libclient:1; /* liblustre client? */
113         union {
114                 struct mds_export_data    eu_mds_data;
115                 struct mdt_export_data    eu_mdt_data;
116                 struct filter_export_data eu_filter_data;
117                 struct ec_export_data     eu_ec_data;
118         } u;
119 };
120
121 #define exp_mds_data    u.eu_mds_data
122 #define exp_mdt_data    u.eu_mdt_data
123 #define exp_lov_data    u.eu_lov_data
124 #define exp_filter_data u.eu_filter_data
125 #define exp_ec_data     u.eu_ec_data
126
127 static inline int exp_connect_cancelset(struct obd_export *exp)
128 {
129         return exp ? exp->exp_connect_flags & OBD_CONNECT_CANCELSET : 0;
130 }
131
132 static inline int exp_connect_lru_resize(struct obd_export *exp)
133 {
134         LASSERT(exp != NULL);
135         return exp->exp_connect_flags & OBD_CONNECT_LRU_RESIZE;
136 }
137
138 static inline int imp_connect_lru_resize(struct obd_import *imp)
139 {
140         LASSERT(imp != NULL);
141         return imp->imp_connect_data.ocd_connect_flags & 
142                       OBD_CONNECT_LRU_RESIZE;
143 }
144
145 extern struct obd_export *class_conn2export(struct lustre_handle *conn);
146 extern struct obd_device *class_conn2obd(struct lustre_handle *conn);
147
148 #endif /* __EXPORT_H */