Whamcloud - gitweb
b=16098
[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 [sun.com URL with a
20  * copy of GPLv2].
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
44 /* Data stored per client in the last_rcvd file.  In le32 order. */
45 struct mds_client_data;
46 struct mdt_client_data;
47 struct mds_idmap_table;
48 struct mdt_idmap_table;
49
50 struct mdt_export_data {
51         struct list_head        med_open_head;
52         spinlock_t              med_open_lock; /* lock med_open_head, mfd_list*/
53         struct semaphore        med_lcd_lock;
54         struct lsd_client_data *med_lcd;
55         __u64                   med_ibits_known;
56         loff_t                  med_lr_off;
57         int                     med_lr_idx;
58         unsigned int            med_rmtclient:1; /* remote client? */
59         struct semaphore           med_idmap_sem;
60         struct lustre_idmap_table *med_idmap;
61 };
62
63 struct osc_creator {
64         spinlock_t              oscc_lock;
65         struct list_head        oscc_list;
66         struct obd_device       *oscc_obd;
67         obd_id                  oscc_last_id;//last available pre-created object
68         obd_id                  oscc_next_id;// what object id to give out next
69         int                     oscc_grow_count;
70         /**
71          * Limit oscc_grow_count value, can be changed via proc fs
72          */
73         int                     oscc_max_grow_count;
74         struct obdo             oscc_oa;
75         int                     oscc_flags;
76         cfs_waitq_t             oscc_waitq; /* creating procs wait on this */
77 };
78
79 struct ldlm_export_data {
80         struct list_head       led_held_locks; /* protected by led_lock */
81         spinlock_t             led_lock;
82 };
83
84 struct ec_export_data { /* echo client */
85         struct list_head eced_locks;
86 };
87
88 /* In-memory access to client data from OST struct */
89 struct filter_export_data {
90         spinlock_t                 fed_lock;      /* protects fed_open_head */
91         struct lsd_client_data    *fed_lcd;
92         loff_t                     fed_lr_off;
93         int                        fed_lr_idx;
94         long                       fed_dirty;    /* in bytes */
95         long                       fed_grant;    /* in bytes */
96         struct list_head           fed_mod_list; /* files being modified */
97         int                        fed_mod_count;/* items in fed_writing list */
98         long                       fed_pending;  /* bytes just being written */
99         __u32                      fed_group;
100         struct brw_stats           fed_brw_stats;
101 };
102
103 typedef struct nid_stat {
104         lnet_nid_t               nid;
105         struct hlist_node        nid_hash;
106         struct list_head         nid_list;
107         struct obd_device       *nid_obd;
108         struct proc_dir_entry   *nid_proc;
109         struct lprocfs_stats    *nid_stats;
110         struct brw_stats        *nid_brw_stats;
111         int                      nid_exp_ref_count;
112 }nid_stat_t;
113
114 struct obd_export {
115         struct portals_handle     exp_handle;
116         atomic_t                  exp_refcount;
117         atomic_t                  exp_rpc_count;
118         struct obd_uuid           exp_client_uuid;
119         struct list_head          exp_obd_chain;
120         struct hlist_node         exp_uuid_hash; /* uuid-export hash*/
121         struct hlist_node         exp_nid_hash; /* nid-export hash */
122         /* exp_obd_chain_timed fo ping evictor, protected by obd_dev_lock */
123         struct list_head          exp_obd_chain_timed;
124         struct obd_device        *exp_obd;
125         struct obd_import        *exp_imp_reverse; /* to make RPCs backwards */
126         struct nid_stat          *exp_nid_stats;
127         struct lprocfs_stats     *exp_md_stats;
128         struct lprocfs_stats     *exp_ldlm_stats;
129         struct ptlrpc_connection *exp_connection;
130         __u32                     exp_conn_cnt;
131         struct ldlm_export_data   exp_ldlm_data;
132         struct list_head          exp_outstanding_replies;
133         time_t                    exp_last_request_time;
134         struct list_head          exp_req_replay_queue;
135         spinlock_t                exp_lock; /* protects flags int below */
136         /* ^ protects exp_outstanding_replies too */
137         __u64                     exp_connect_flags;
138         int                       exp_flags;
139         unsigned long             exp_failed:1,
140                                   exp_in_recovery:1,
141                                   exp_disconnected:1,
142                                   exp_connecting:1,
143                                   exp_req_replay_needed:1,
144                                   exp_lock_replay_needed:1,
145                                   exp_need_sync:1,
146                                   exp_flvr_changed:1,
147                                   exp_flvr_adapt:1,
148                                   exp_libclient:1; /* liblustre client? */
149         /* also protected by exp_lock */
150         enum lustre_sec_part      exp_sp_peer;
151         struct sptlrpc_flavor     exp_flvr;             /* current */
152         struct sptlrpc_flavor     exp_flvr_old[2];      /* about-to-expire */
153         cfs_time_t                exp_flvr_expire[2];   /* seconds */
154
155         union {
156                 struct mdt_export_data    eu_mdt_data;
157                 struct filter_export_data eu_filter_data;
158                 struct ec_export_data     eu_ec_data;
159         } u;
160 };
161
162 #define exp_mdt_data    u.eu_mdt_data
163 #define exp_filter_data u.eu_filter_data
164 #define exp_ec_data     u.eu_ec_data
165
166 static inline int exp_connect_cancelset(struct obd_export *exp)
167 {
168         LASSERT(exp != NULL);
169         return !!(exp->exp_connect_flags & OBD_CONNECT_CANCELSET);
170 }
171
172 static inline int exp_connect_lru_resize(struct obd_export *exp)
173 {
174         LASSERT(exp != NULL);
175         return !!(exp->exp_connect_flags & OBD_CONNECT_LRU_RESIZE);
176 }
177
178 static inline int imp_connect_lru_resize(struct obd_import *imp)
179 {
180         struct obd_connect_data *ocd;
181
182         LASSERT(imp != NULL);
183         ocd = &imp->imp_connect_data;
184         return !!(ocd->ocd_connect_flags & OBD_CONNECT_LRU_RESIZE);
185 }
186
187 extern struct obd_export *class_conn2export(struct lustre_handle *conn);
188 extern struct obd_device *class_conn2obd(struct lustre_handle *conn);
189
190 #endif /* __EXPORT_H */