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