Whamcloud - gitweb
43fc0bb0e303ba1d9f690368a6fb5bd96883adbf
[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_export_data {
14         struct list_head        med_open_head;
15         spinlock_t              med_open_lock; /* lock med_open_head, mfd_list*/
16         struct lsd_client_data *med_lcd;
17         __u64                   med_ibits_known;
18         loff_t                  med_lr_off;
19         int                     med_lr_idx;
20 };
21
22 struct osc_creator {
23         spinlock_t              oscc_lock;
24         struct list_head        oscc_list;
25         struct obd_device       *oscc_obd;
26         obd_id                  oscc_last_id;//last available pre-created object
27         obd_id                  oscc_next_id;// what object id to give out next
28         int                     oscc_grow_count;
29         struct obdo             oscc_oa;
30         int                     oscc_flags;
31         cfs_waitq_t             oscc_waitq; /* creating procs wait on this */
32 };
33
34 struct ldlm_export_data {
35         struct list_head       led_held_locks; /* protected by led_lock below */
36         spinlock_t             led_lock;
37 };
38
39 struct ec_export_data { /* echo client */
40         struct list_head eced_locks;
41 };
42
43 /* In-memory access to client data from OST struct */
44 struct filter_export_data {
45         spinlock_t                 fed_lock;      /* protects fed_open_head */
46         struct lsd_client_data    *fed_lcd;
47         loff_t                     fed_lr_off;
48         int                        fed_lr_idx;
49         long                       fed_dirty;    /* in bytes */
50         long                       fed_grant;    /* in bytes */
51         struct list_head           fed_mod_list; /* files being modified */
52         int                        fed_mod_count;/* items in fed_writing list */
53         long                       fed_pending;  /* bytes just being written */
54         struct brw_stats           fed_brw_stats;
55 };
56
57 typedef struct nid_stat {
58         lnet_nid_t               nid;
59         struct hlist_node        nid_hash;
60         struct list_head         nid_list;
61         struct obd_device       *nid_obd;
62         struct proc_dir_entry   *nid_proc;
63         struct lprocfs_stats    *nid_stats;
64         struct brw_stats        *nid_brw_stats;
65         int                      nid_exp_ref_count;
66 }nid_stat_t;
67
68 struct obd_export {
69         struct portals_handle     exp_handle;
70         atomic_t                  exp_refcount;
71         atomic_t                  exp_rpc_count;
72         struct obd_uuid           exp_client_uuid;
73         struct list_head          exp_obd_chain;
74         struct hlist_node         exp_uuid_hash; /* uuid-export hash*/
75         struct hlist_node         exp_nid_hash; /* nid-export hash */
76         /* exp_obd_chain_timed fo ping evictor, protected by obd_dev_lock */
77         struct list_head          exp_obd_chain_timed;
78         struct obd_device        *exp_obd;
79         struct obd_import        *exp_imp_reverse; /* to make RPCs backwards */
80         struct nid_stat          *exp_nid_stats;
81         struct lprocfs_stats     *exp_ldlm_stats;
82         struct lprocfs_stats     *exp_ops_stats;
83         struct ptlrpc_connection *exp_connection;
84         __u32                     exp_conn_cnt;
85         struct ldlm_export_data   exp_ldlm_data;
86         struct list_head          exp_outstanding_replies;
87         time_t                    exp_last_request_time;
88         struct list_head          exp_req_replay_queue;
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 long             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         LASSERT(exp != NULL);
114         return !!(exp->exp_connect_flags & OBD_CONNECT_CANCELSET);
115 }
116
117 static inline int exp_connect_lru_resize(struct obd_export *exp)
118 {
119         LASSERT(exp != NULL);
120         return !!(exp->exp_connect_flags & OBD_CONNECT_LRU_RESIZE);
121 }
122
123 static inline int imp_connect_lru_resize(struct obd_import *imp)
124 {
125         struct obd_connect_data *ocd;
126
127         LASSERT(imp != NULL);
128         ocd = &imp->imp_connect_data;
129         return !!(ocd->ocd_connect_flags & OBD_CONNECT_LRU_RESIZE);
130 }
131
132 extern struct obd_export *class_conn2export(struct lustre_handle *conn);
133 extern struct obd_device *class_conn2obd(struct lustre_handle *conn);
134
135 #endif /* __EXPORT_H */