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 #include <lustre_dlm.h>
41 #include <lustre/lustre_idl.h>
42 #include <lprocfs_status.h>
43 #include <class_hash.h>
45 struct lu_export_data {
46 struct semaphore led_lcd_lock; /**< protect led_lcd */
47 struct lsd_client_data *led_lcd; /**< client data */
48 loff_t led_lr_off; /**< offset in last_rcvd */
49 int led_lr_idx; /**< client index */
52 struct mds_export_data {
53 struct lu_export_data med_led;
54 struct list_head med_open_head;
55 spinlock_t med_open_lock; /* lock med_open_head, mfd_list*/
56 __u64 med_ibits_known;
59 #define med_lcd_lock med_led.led_lcd_lock
60 #define med_lcd med_led.led_lcd
61 #define med_lr_off med_led.led_lr_off
62 #define med_lr_idx med_led.led_lr_idx
66 struct list_head oscc_wait_create_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
71 int oscc_max_grow_count;
74 cfs_waitq_t oscc_waitq; /* creating procs wait on this */
77 struct ec_export_data { /* echo client */
78 struct list_head eced_locks;
81 /* In-memory access to client data from OST struct */
82 struct filter_export_data {
83 struct lu_export_data fed_led;
84 spinlock_t fed_lock; /**< protects fed_mod_list */
85 long fed_dirty; /* in bytes */
86 long fed_grant; /* in bytes */
87 struct list_head fed_mod_list; /* files being modified */
88 int fed_mod_count;/* items in fed_writing list */
89 long fed_pending; /* bytes just being written */
92 #define fed_lcd_lock fed_led.led_lcd_lock
93 #define fed_lcd fed_led.led_lcd
94 #define fed_lr_off fed_led.led_lr_off
95 #define fed_lr_idx fed_led.led_lr_idx
97 typedef struct nid_stat {
99 struct hlist_node nid_hash;
100 struct list_head nid_list;
101 struct obd_device *nid_obd;
102 struct proc_dir_entry *nid_proc;
103 struct lprocfs_stats *nid_stats;
104 struct brw_stats *nid_brw_stats;
105 struct lprocfs_stats *nid_ldlm_stats;
106 atomic_t nid_exp_ref_count; /* for obd_nid_stats_hash
110 #define nidstat_getref(nidstat) \
112 atomic_inc(&(nidstat)->nid_exp_ref_count); \
115 #define nidstat_putref(nidstat) \
117 atomic_dec(&(nidstat)->nid_exp_ref_count); \
118 LASSERTF(atomic_read(&(nidstat)->nid_exp_ref_count) >= 0, \
119 "stat %p nid_exp_ref_count < 0\n", nidstat); \
123 OBD_OPT_FORCE = 0x0001,
124 OBD_OPT_FAILOVER = 0x0002,
125 OBD_OPT_ABORT_RECOV = 0x0004,
129 struct portals_handle exp_handle;
130 atomic_t exp_refcount;
131 atomic_t exp_rpc_count;
132 struct obd_uuid exp_client_uuid;
133 lnet_nid_t exp_client_nid;
134 struct list_head exp_obd_chain;
135 struct hlist_node exp_uuid_hash; /* uuid-export hash*/
136 struct hlist_node exp_nid_hash; /* nid-export hash */
137 /* exp_obd_chain_timed fo ping evictor, protected by obd_dev_lock */
138 struct list_head exp_obd_chain_timed;
139 struct obd_device *exp_obd;
140 struct obd_import *exp_imp_reverse; /* to make RPCs backwards */
141 struct nid_stat *exp_nid_stats;
142 struct ptlrpc_connection *exp_connection;
144 lustre_hash_t *exp_lock_hash; /* existing lock hash */
145 spinlock_t exp_lock_hash_lock;
146 struct list_head exp_outstanding_replies;
147 struct list_head exp_uncommitted_replies;
148 spinlock_t exp_uncommitted_replies_lock;
149 time_t exp_last_request_time;
150 struct list_head exp_req_replay_queue;
151 spinlock_t exp_lock; /* protects flags int below */
152 /* ^ protects exp_outstanding_replies too */
153 __u64 exp_connect_flags;
154 enum obd_option exp_flags;
155 unsigned long exp_failed:1,
159 /* VBR: export missed recovery */
161 /* VBR: failed version checking */
164 exp_need_sync:1, /* needs sync from connect */
165 exp_libclient:1, /* liblustre client? */
166 /* client timed out and tried to reconnect,
167 * but couldn't because of active rpcs */
168 exp_abort_active_req:1;
169 struct list_head exp_queued_rpc; /* RPC to be handled */
170 /* VBR: per-export last committed */
171 __u64 exp_last_committed;
173 struct lu_export_data eu_target_data;
174 struct mds_export_data eu_mds_data;
175 struct filter_export_data eu_filter_data;
176 struct ec_export_data eu_ec_data;
180 #define exp_target_data u.eu_target_data
181 #define exp_mds_data u.eu_mds_data
182 #define exp_filter_data u.eu_filter_data
183 #define exp_ec_data u.eu_ec_data
185 static inline int exp_expired(struct obd_export *exp, __u32 age)
187 LASSERT(exp->exp_delayed);
188 return cfs_time_before(exp->exp_last_request_time + age,
189 cfs_time_current_sec());
192 static inline int exp_connect_cancelset(struct obd_export *exp)
194 LASSERT(exp != NULL);
195 return !!(exp->exp_connect_flags & OBD_CONNECT_CANCELSET);
198 static inline int exp_connect_lru_resize(struct obd_export *exp)
200 LASSERT(exp != NULL);
201 return !!(exp->exp_connect_flags & OBD_CONNECT_LRU_RESIZE);
204 static inline int exp_connect_vbr(struct obd_export *exp)
206 LASSERT(exp != NULL);
207 LASSERT(exp->exp_connection);
208 return !!(exp->exp_connect_flags & OBD_CONNECT_VBR);
211 static inline int imp_connect_lru_resize(struct obd_import *imp)
213 struct obd_connect_data *ocd;
215 LASSERT(imp != NULL);
216 ocd = &imp->imp_connect_data;
217 return !!(ocd->ocd_connect_flags & OBD_CONNECT_LRU_RESIZE);
220 extern struct obd_export *class_conn2export(struct lustre_handle *conn);
221 extern struct obd_device *class_conn2obd(struct lustre_handle *conn);
223 #endif /* __EXPORT_H */