Whamcloud - gitweb
55961d16ae502616fc84a3eb9d9daba653fbcada
[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  * GPL HEADER START
5  *
6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 only,
10  * as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License version 2 for more details (a copy is included
16  * in the LICENSE file that accompanied this code).
17  *
18  * You should have received a copy of the GNU General Public License
19  * version 2 along with this program; If not, see
20  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
21  *
22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23  * CA 95054 USA or visit www.sun.com if you need additional information or
24  * have any questions.
25  *
26  * GPL HEADER END
27  */
28 /*
29  * Copyright  2008 Sun Microsystems, Inc. All rights reserved
30  * Use is subject to license terms.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  */
36
37 #ifndef __EXPORT_H
38 #define __EXPORT_H
39
40 #include <lustre/lustre_idl.h>
41 #include <lustre_dlm.h>
42 #include <lprocfs_status.h>
43 #include <class_hash.h>
44
45 /* Data stored per client in the last_rcvd file.  In le32 order. */
46 struct mds_client_data;
47 struct mdt_client_data;
48 struct mds_idmap_table;
49 struct mdt_idmap_table;
50
51 struct mdt_export_data {
52         struct list_head        med_open_head;
53         spinlock_t              med_open_lock; /* lock med_open_head, mfd_list*/
54         struct semaphore        med_lcd_lock;
55         struct lsd_client_data *med_lcd;
56         __u64                   med_ibits_known;
57         loff_t                  med_lr_off;
58         int                     med_lr_idx;
59         unsigned int            med_rmtclient:1; /* remote client? */
60         struct semaphore           med_idmap_sem;
61         struct lustre_idmap_table *med_idmap;
62 };
63
64 struct osc_creator {
65         spinlock_t              oscc_lock;
66         struct list_head        oscc_list;
67         struct obd_device       *oscc_obd;
68         obd_id                  oscc_last_id;//last available pre-created object
69         obd_id                  oscc_next_id;// what object id to give out next
70         int                     oscc_grow_count;
71         /**
72          * Limit oscc_grow_count value, can be changed via proc fs
73          */
74         int                     oscc_max_grow_count;
75         struct obdo             oscc_oa;
76         int                     oscc_flags;
77         cfs_waitq_t             oscc_waitq; /* creating procs wait on this */
78 };
79
80 struct ec_export_data { /* echo client */
81         struct list_head eced_locks;
82 };
83
84 /* In-memory access to client data from OST struct */
85 struct filter_export_data {
86         spinlock_t                 fed_lock;      /* protects fed_open_head */
87         struct lsd_client_data    *fed_lcd;
88         loff_t                     fed_lr_off;
89         int                        fed_lr_idx;
90         long                       fed_dirty;    /* in bytes */
91         long                       fed_grant;    /* in bytes */
92         struct list_head           fed_mod_list; /* files being modified */
93         int                        fed_mod_count;/* items in fed_writing list */
94         long                       fed_pending;  /* bytes just being written */
95         __u32                      fed_group;
96         struct brw_stats           fed_brw_stats;
97 };
98
99 typedef struct nid_stat {
100         lnet_nid_t               nid;
101         struct hlist_node        nid_hash;
102         struct list_head         nid_list;
103         struct obd_device       *nid_obd;
104         struct proc_dir_entry   *nid_proc;
105         struct lprocfs_stats    *nid_stats;
106         struct brw_stats        *nid_brw_stats;
107         int                      nid_exp_ref_count;
108 }nid_stat_t;
109
110 struct obd_export {
111         struct portals_handle     exp_handle;
112         atomic_t                  exp_refcount;
113         atomic_t                  exp_rpc_count;
114         struct obd_uuid           exp_client_uuid;
115         struct list_head          exp_obd_chain;
116         struct hlist_node         exp_uuid_hash; /* uuid-export hash*/
117         struct hlist_node         exp_nid_hash; /* nid-export hash */
118         /* exp_obd_chain_timed fo ping evictor, protected by obd_dev_lock */
119         struct list_head          exp_obd_chain_timed;
120         struct obd_device        *exp_obd;
121         struct obd_import        *exp_imp_reverse; /* to make RPCs backwards */
122         struct nid_stat          *exp_nid_stats;
123         struct lprocfs_stats     *exp_md_stats;
124         struct lprocfs_stats     *exp_ldlm_stats;
125         struct ptlrpc_connection *exp_connection;
126         __u32                     exp_conn_cnt;
127         lustre_hash_t            *exp_lock_hash; /* existing lock hash */
128         spinlock_t                exp_lock_hash_lock;
129         struct list_head          exp_outstanding_replies;
130         time_t                    exp_last_request_time;
131         struct list_head          exp_req_replay_queue;
132         spinlock_t                exp_lock; /* protects flags int below */
133         /* ^ protects exp_outstanding_replies too */
134         __u64                     exp_connect_flags;
135         int                       exp_flags;
136         unsigned long             exp_failed:1,
137                                   exp_in_recovery:1,
138                                   exp_disconnected:1,
139                                   exp_connecting:1,
140                                   exp_req_replay_needed:1,
141                                   exp_lock_replay_needed:1,
142                                   exp_need_sync:1,
143                                   exp_flvr_changed:1,
144                                   exp_flvr_adapt:1,
145                                   exp_libclient:1; /* liblustre client? */
146         /* also protected by exp_lock */
147         enum lustre_sec_part      exp_sp_peer;
148         struct sptlrpc_flavor     exp_flvr;             /* current */
149         struct sptlrpc_flavor     exp_flvr_old[2];      /* about-to-expire */
150         cfs_time_t                exp_flvr_expire[2];   /* seconds */
151
152         union {
153                 struct mdt_export_data    eu_mdt_data;
154                 struct filter_export_data eu_filter_data;
155                 struct ec_export_data     eu_ec_data;
156         } u;
157 };
158
159 #define exp_mdt_data    u.eu_mdt_data
160 #define exp_filter_data u.eu_filter_data
161 #define exp_ec_data     u.eu_ec_data
162
163 static inline int exp_connect_cancelset(struct obd_export *exp)
164 {
165         LASSERT(exp != NULL);
166         return !!(exp->exp_connect_flags & OBD_CONNECT_CANCELSET);
167 }
168
169 static inline int exp_connect_lru_resize(struct obd_export *exp)
170 {
171         LASSERT(exp != NULL);
172         return !!(exp->exp_connect_flags & OBD_CONNECT_LRU_RESIZE);
173 }
174
175 static inline int imp_connect_lru_resize(struct obd_import *imp)
176 {
177         struct obd_connect_data *ocd;
178
179         LASSERT(imp != NULL);
180         ocd = &imp->imp_connect_data;
181         return !!(ocd->ocd_connect_flags & OBD_CONNECT_LRU_RESIZE);
182 }
183
184 extern struct obd_export *class_conn2export(struct lustre_handle *conn);
185 extern struct obd_device *class_conn2obd(struct lustre_handle *conn);
186
187 #endif /* __EXPORT_H */