1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
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).
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
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
29 * Copyright 2008 Sun Microsystems, Inc. All rights reserved
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
40 /** \defgroup export export
45 #include <lprocfs_status.h>
46 #include <lustre/lustre_idl.h>
47 #include <lustre_dlm.h>
49 struct mds_client_data;
50 struct mdt_client_data;
51 struct mds_idmap_table;
52 struct mdt_idmap_table;
54 struct lu_export_data {
55 /** Protects led_lcd below */
56 cfs_semaphore_t led_lcd_lock;
57 /** Per-client data for each export */
58 struct lsd_client_data *led_lcd;
59 /** Offset of record in last_rcvd file */
61 /** Client index in last_rcvd file */
65 struct mdt_export_data {
66 struct lu_export_data med_led;
67 cfs_list_t med_open_head;
68 cfs_spinlock_t med_open_lock; /* lock med_open_head, mfd_list*/
69 __u64 med_ibits_known;
70 cfs_semaphore_t med_idmap_sem;
71 struct lustre_idmap_table *med_idmap;
74 #define med_lcd_lock med_led.led_lcd_lock
75 #define med_lcd med_led.led_lcd
76 #define med_lr_off med_led.led_lr_off
77 #define med_lr_idx med_led.led_lr_idx
80 cfs_spinlock_t oscc_lock;
81 cfs_list_t oscc_wait_create_list;
82 struct obd_device *oscc_obd;
83 obd_id oscc_last_id;//last available pre-created object
84 obd_id oscc_next_id;// what object id to give out next
87 * Limit oscc_grow_count value, can be changed via proc fs
89 int oscc_max_grow_count;
92 cfs_waitq_t oscc_waitq; /* creating procs wait on this */
95 struct ec_export_data { /* echo client */
96 cfs_list_t eced_locks;
99 /* In-memory access to client data from OST struct */
100 struct filter_export_data {
101 struct lu_export_data fed_led;
102 cfs_spinlock_t fed_lock; /**< protects fed_mod_list */
103 long fed_dirty; /* in bytes */
104 long fed_grant; /* in bytes */
105 cfs_list_t fed_mod_list; /* files being modified */
106 int fed_mod_count;/* items in fed_writing list */
107 long fed_pending; /* bytes just being written */
111 #define fed_lcd_lock fed_led.led_lcd_lock
112 #define fed_lcd fed_led.led_lcd
113 #define fed_lr_off fed_led.led_lr_off
114 #define fed_lr_idx fed_led.led_lr_idx
116 typedef struct nid_stat {
118 cfs_hlist_node_t nid_hash;
120 struct obd_device *nid_obd;
121 struct proc_dir_entry *nid_proc;
122 struct lprocfs_stats *nid_stats;
123 struct lprocfs_stats *nid_ldlm_stats;
124 struct brw_stats *nid_brw_stats;
125 cfs_atomic_t nid_exp_ref_count; /* for obd_nid_stats_hash
129 #define nidstat_getref(nidstat) \
131 cfs_atomic_inc(&(nidstat)->nid_exp_ref_count); \
134 #define nidstat_putref(nidstat) \
136 cfs_atomic_dec(&(nidstat)->nid_exp_ref_count); \
137 LASSERTF(cfs_atomic_read(&(nidstat)->nid_exp_ref_count) >= 0, \
138 "stat %p nid_exp_ref_count < 0\n", nidstat); \
142 OBD_OPT_FORCE = 0x0001,
143 OBD_OPT_FAILOVER = 0x0002,
144 OBD_OPT_ABORT_RECOV = 0x0004,
148 struct portals_handle exp_handle;
149 cfs_atomic_t exp_refcount;
151 * Set of counters below is to track where export references are
152 * kept. The exp_rpc_count is used for reconnect handling also,
153 * the cb_count and locks_count are for debug purposes only for now.
154 * The sum of them should be less than exp_refcount by 3
156 cfs_atomic_t exp_rpc_count; /* RPC references */
157 cfs_atomic_t exp_cb_count; /* Commit callback references */
158 cfs_atomic_t exp_locks_count; /** Lock references */
159 #if LUSTRE_TRACKS_LOCK_EXP_REFS
160 cfs_list_t exp_locks_list;
161 cfs_spinlock_t exp_locks_list_guard;
163 cfs_atomic_t exp_replay_count;
164 struct obd_uuid exp_client_uuid;
165 cfs_list_t exp_obd_chain;
166 cfs_hlist_node_t exp_uuid_hash; /* uuid-export hash*/
167 cfs_hlist_node_t exp_nid_hash; /* nid-export hash */
168 /* exp_obd_chain_timed fo ping evictor, protected by obd_dev_lock */
169 cfs_list_t exp_obd_chain_timed;
170 struct obd_device *exp_obd;
171 struct obd_import *exp_imp_reverse; /* to make RPCs backwards */
172 struct nid_stat *exp_nid_stats;
173 struct lprocfs_stats *exp_md_stats;
174 struct ptlrpc_connection *exp_connection;
176 cfs_hash_t *exp_lock_hash; /* existing lock hash */
177 cfs_spinlock_t exp_lock_hash_lock;
178 cfs_list_t exp_outstanding_replies;
179 cfs_list_t exp_uncommitted_replies;
180 cfs_spinlock_t exp_uncommitted_replies_lock;
181 __u64 exp_last_committed;
182 cfs_time_t exp_last_request_time;
183 cfs_list_t exp_req_replay_queue;
184 cfs_spinlock_t exp_lock; /* protects flags int below */
185 /* ^ protects exp_outstanding_replies too */
186 __u64 exp_connect_flags;
187 enum obd_option exp_flags;
188 unsigned long exp_failed:1,
192 /** VBR: export missed recovery */
194 /** VBR: failed version checking */
196 exp_req_replay_needed:1,
197 exp_lock_replay_needed:1,
201 exp_libclient:1, /* liblustre client? */
202 /* client timed out and tried to reconnect,
203 * but couldn't because of active rpcs */
204 exp_abort_active_req:1;
205 cfs_list_t exp_queued_rpc; /* RPC to be handled */
206 /* also protected by exp_lock */
207 enum lustre_sec_part exp_sp_peer;
208 struct sptlrpc_flavor exp_flvr; /* current */
209 struct sptlrpc_flavor exp_flvr_old[2]; /* about-to-expire */
210 cfs_time_t exp_flvr_expire[2]; /* seconds */
213 struct lu_export_data eu_target_data;
214 struct mdt_export_data eu_mdt_data;
215 struct filter_export_data eu_filter_data;
216 struct ec_export_data eu_ec_data;
220 #define exp_target_data u.eu_target_data
221 #define exp_mdt_data u.eu_mdt_data
222 #define exp_filter_data u.eu_filter_data
223 #define exp_ec_data u.eu_ec_data
225 static inline int exp_expired(struct obd_export *exp, cfs_duration_t age)
227 LASSERT(exp->exp_delayed);
228 return cfs_time_before(cfs_time_add(exp->exp_last_request_time, age),
229 cfs_time_current_sec());
232 static inline int exp_connect_cancelset(struct obd_export *exp)
234 LASSERT(exp != NULL);
235 return !!(exp->exp_connect_flags & OBD_CONNECT_CANCELSET);
238 static inline int exp_connect_lru_resize(struct obd_export *exp)
240 LASSERT(exp != NULL);
241 return !!(exp->exp_connect_flags & OBD_CONNECT_LRU_RESIZE);
244 static inline int exp_connect_rmtclient(struct obd_export *exp)
246 LASSERT(exp != NULL);
247 return !!(exp->exp_connect_flags & OBD_CONNECT_RMT_CLIENT);
250 static inline int client_is_remote(struct obd_export *exp)
252 struct obd_import *imp = class_exp2cliimp(exp);
254 return !!(imp->imp_connect_data.ocd_connect_flags &
255 OBD_CONNECT_RMT_CLIENT);
258 static inline int exp_connect_vbr(struct obd_export *exp)
260 LASSERT(exp != NULL);
261 LASSERT(exp->exp_connection);
262 return !!(exp->exp_connect_flags & OBD_CONNECT_VBR);
265 static inline int exp_connect_som(struct obd_export *exp)
267 LASSERT(exp != NULL);
268 return !!(exp->exp_connect_flags & OBD_CONNECT_SOM);
271 static inline int imp_connect_lru_resize(struct obd_import *imp)
273 struct obd_connect_data *ocd;
275 LASSERT(imp != NULL);
276 ocd = &imp->imp_connect_data;
277 return !!(ocd->ocd_connect_flags & OBD_CONNECT_LRU_RESIZE);
280 extern struct obd_export *class_conn2export(struct lustre_handle *conn);
281 extern struct obd_device *class_conn2obd(struct lustre_handle *conn);
285 #endif /* __EXPORT_H */