Whamcloud - gitweb
- lmv_getattr_name() recognizes cross-node name and repeats getattr to proper
[fs/lustre-release.git] / lustre / mdc / mdc_request.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * Copyright (C) 2001-2003 Cluster File Systems, Inc.
5  *
6  *   This file is part of Lustre, http://www.sf.net/projects/lustre/
7  *
8  *   Lustre is free software; you can redistribute it and/or
9  *   modify it under the terms of version 2 of the GNU General Public
10  *   License as published by the Free Software Foundation.
11  *
12  *   Lustre is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *
17  *   You should have received a copy of the GNU General Public License
18  *   along with Lustre; if not, write to the Free Software
19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  */
21
22 #ifndef EXPORT_SYMTAB
23 # define EXPORT_SYMTAB
24 #endif
25 #define DEBUG_SUBSYSTEM S_MDC
26
27 #ifdef __KERNEL__
28 # include <linux/module.h>
29 # include <linux/pagemap.h>
30 # include <linux/miscdevice.h>
31 # include <linux/init.h>
32 #else
33 # include <liblustre.h>
34 #endif
35
36 #include <linux/obd_class.h>
37 #include <linux/lustre_mds.h>
38 #include <linux/lustre_dlm.h>
39 #include <linux/lprocfs_status.h>
40 #include "mdc_internal.h"
41
42 #define REQUEST_MINOR 244
43
44 static int mdc_cleanup(struct obd_device *obd, int flags);
45
46 extern int mds_queue_req(struct ptlrpc_request *);
47 /* Helper that implements most of mdc_getstatus and signal_completed_replay. */
48 /* XXX this should become mdc_get_info("key"), sending MDS_GET_INFO RPC */
49 static int send_getstatus(struct obd_import *imp, struct ll_fid *rootfid,
50                           int level, int msg_flags)
51 {
52         struct ptlrpc_request *req;
53         struct mds_body *body;
54         int rc, size = sizeof(*body);
55         ENTRY;
56
57         req = ptlrpc_prep_req(imp, MDS_GETSTATUS, 1, &size, NULL);
58         if (!req)
59                 GOTO(out, rc = -ENOMEM);
60
61         body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof (*body));
62         req->rq_send_state = level;
63         req->rq_replen = lustre_msg_size(1, &size);
64
65         mdc_pack_req_body(req);
66         req->rq_reqmsg->flags |= msg_flags;
67         rc = ptlrpc_queue_wait(req);
68
69         if (!rc) {
70                 body = lustre_swab_repbuf (req, 0, sizeof (*body),
71                                            lustre_swab_mds_body);
72                 if (body == NULL) {
73                         CERROR ("Can't extract mds_body\n");
74                         GOTO (out, rc = -EPROTO);
75                 }
76
77                 memcpy(rootfid, &body->fid1, sizeof(*rootfid));
78
79                 CDEBUG(D_NET, "root ino="LPU64", last_committed="LPU64
80                        ", last_xid="LPU64"\n",
81                        rootfid->id, req->rq_repmsg->last_committed,
82                        req->rq_repmsg->last_xid);
83         }
84
85         EXIT;
86  out:
87         ptlrpc_req_finished(req);
88         return rc;
89 }
90
91 /* This should be mdc_get_info("rootfid") */
92 int mdc_getstatus(struct obd_export *exp, struct ll_fid *rootfid)
93 {
94         return send_getstatus(class_exp2cliimp(exp), rootfid, LUSTRE_IMP_FULL,
95                               0);
96 }
97
98 int mdc_getattr_common(struct obd_export *exp, unsigned int ea_size, 
99                        struct ptlrpc_request *req)
100 {
101         struct mds_body *body;
102         void            *eadata;
103         int              rc;
104         int              size[2] = {sizeof(*body), 0};
105         int              bufcount = 1;
106         ENTRY;
107
108         /* request message already built */
109
110         if (ea_size != 0) {
111                 size[bufcount++] = ea_size;
112                 CDEBUG(D_INODE, "reserved %u bytes for MD/symlink in packet\n",
113                        ea_size);
114         }
115         req->rq_replen = lustre_msg_size(bufcount, size);
116
117         mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
118         rc = ptlrpc_queue_wait(req);
119         mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
120         if (rc != 0)
121                 RETURN (rc);
122
123         body = lustre_swab_repbuf (req, 0, sizeof (*body),
124                                    lustre_swab_mds_body);
125         if (body == NULL) {
126                 CERROR ("Can't unpack mds_body\n");
127                 RETURN (-EPROTO);
128         }
129
130         CDEBUG(D_NET, "mode: %o\n", body->mode);
131
132         LASSERT_REPSWAB (req, 1);
133         if (body->eadatasize != 0) {
134                 /* reply indicates presence of eadata; check it's there... */
135                 eadata = lustre_msg_buf (req->rq_repmsg, 1, body->eadatasize);
136                 if (eadata == NULL) {
137                         CERROR ("Missing/short eadata\n");
138                         RETURN (-EPROTO);
139                 }
140         }
141
142         RETURN (0);
143 }
144
145 int mdc_getattr(struct obd_export *exp, struct ll_fid *fid,
146                 unsigned long valid, unsigned int ea_size,
147                 struct ptlrpc_request **request)
148 {
149         struct ptlrpc_request *req;
150         struct mds_body *body;
151         int size = sizeof(*body);
152         int rc;
153         ENTRY;
154
155         /* XXX do we need to make another request here?  We just did a getattr
156          *     to do the lookup in the first place.
157          */
158         req = ptlrpc_prep_req(class_exp2cliimp(exp), MDS_GETATTR, 1, &size,
159                               NULL);
160         if (!req)
161                 GOTO(out, rc = -ENOMEM);
162
163         body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof (*body));
164         memcpy(&body->fid1, fid, sizeof(*fid));
165         body->valid = valid;
166         body->eadatasize = ea_size;
167         mdc_pack_req_body(req);
168
169         rc = mdc_getattr_common(exp, ea_size, req);
170         if (rc != 0) {
171                 ptlrpc_req_finished (req);
172                 req = NULL;
173         }
174  out:
175         *request = req;
176         RETURN (rc);
177 }
178
179 int mdc_getattr_name(struct obd_export *exp, struct ll_fid *fid,
180                      char *filename, int namelen, unsigned long valid,
181                      unsigned int ea_size, struct ptlrpc_request **request)
182 {
183         struct ptlrpc_request *req;
184         struct mds_body *body;
185         int rc, size[2] = {sizeof(*body), namelen};
186         ENTRY;
187
188         req = ptlrpc_prep_req(class_exp2cliimp(exp), MDS_GETATTR_NAME, 2,
189                               size, NULL);
190         if (!req)
191                 GOTO(out, rc = -ENOMEM);
192
193         body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof (*body));
194         memcpy(&body->fid1, fid, sizeof(*fid));
195         body->valid = valid;
196         body->eadatasize = ea_size;
197         mdc_pack_req_body(req);
198
199         if (filename != NULL) {
200                 LASSERT (strnlen (filename, namelen) == namelen - 1);
201                 memcpy(lustre_msg_buf(req->rq_reqmsg, 1, namelen),
202                        filename, namelen);
203         } else {
204                 LASSERT(namelen == 1);
205         }
206
207         rc = mdc_getattr_common(exp, ea_size, req);
208         if (rc != 0) {
209                 ptlrpc_req_finished (req);
210                 req = NULL;
211         }
212  out:
213         *request = req;
214         RETURN(rc);
215 }
216
217 /* This should be called with both the request and the reply still packed. */
218 void mdc_store_inode_generation(struct ptlrpc_request *req, int reqoff,
219                                 int repoff)
220 {
221         struct mds_rec_create *rec =
222                 lustre_msg_buf(req->rq_reqmsg, reqoff, sizeof(*rec));
223         struct mds_body *body =
224                 lustre_msg_buf(req->rq_repmsg, repoff, sizeof(*body));
225
226         LASSERT (rec != NULL);
227         LASSERT (body != NULL);
228
229         memcpy(&rec->cr_replayfid, &body->fid1, sizeof rec->cr_replayfid);
230         DEBUG_REQ(D_HA, req, "storing generation %u for ino "LPU64,
231                   rec->cr_replayfid.generation, rec->cr_replayfid.id);
232 }
233
234 int mdc_req2lustre_md(struct ptlrpc_request *req, int offset,
235                       struct obd_export *exp_osc,
236                       struct obd_export *exp_mdc,
237                       struct lustre_md *md)
238 {
239         int rc = 0;
240         ENTRY;
241
242         LASSERT(md);
243         memset(md, 0, sizeof(*md));
244
245         md->body = lustre_msg_buf(req->rq_repmsg, offset, sizeof (*md->body));
246         LASSERT (md->body != NULL);
247         LASSERT_REPSWABBED (req, offset);
248
249         if (!(md->body->valid & OBD_MD_FLEASIZE))
250                 RETURN(0);
251
252         /* ea is presented in reply, parse it */
253         if (S_ISREG(md->body->mode)) {
254                 int lmmsize;
255                 struct lov_mds_md *lmm;
256
257                 if (md->body->eadatasize == 0) {
258                         CERROR ("OBD_MD_FLEASIZE set, but eadatasize 0\n");
259                         RETURN(-EPROTO);
260                 }
261                 lmmsize = md->body->eadatasize;
262                 lmm = lustre_msg_buf(req->rq_repmsg, offset + 1, lmmsize);
263                 LASSERT (lmm != NULL);
264                 LASSERT_REPSWABBED (req, offset + 1);
265
266                 rc = obd_unpackmd(exp_osc, &md->lsm, lmm, lmmsize);
267                 if (rc >= 0) {
268                         LASSERT (rc >= sizeof (*md->lsm));
269                         rc = 0;
270                 }
271         } else if (S_ISDIR(md->body->mode)) {
272                 struct mea *mea;
273                 int mdsize;
274                 LASSERT(exp_mdc != NULL);
275                 /* dir can be non-splitted */
276                 if (md->body->eadatasize == 0)
277                         RETURN(0);
278
279                 mdsize = md->body->eadatasize;
280                 mea = lustre_msg_buf(req->rq_repmsg, offset + 1, mdsize);
281                 LASSERT(mea != NULL);
282
283                 rc = obd_unpackmd(exp_mdc, (void *) &md->mea,
284                                   (void *) mea, mdsize);
285                 if (rc >= 0) {
286                         LASSERT (rc >= sizeof (*md->mea));
287                         rc = 0;
288                 }
289         } else {
290                 LASSERT(0);
291         }
292         RETURN(rc);
293 }
294
295 static void mdc_commit_open(struct ptlrpc_request *req)
296 {
297         struct mdc_open_data *mod = req->rq_cb_data;
298         if (mod == NULL)
299                 return;
300
301         if (mod->mod_close_req != NULL)
302                 mod->mod_close_req->rq_cb_data = NULL;
303
304         if (mod->mod_och != NULL)
305                 mod->mod_och->och_mod = NULL;
306
307         OBD_FREE(mod, sizeof(*mod));
308         req->rq_cb_data = NULL;
309 }
310
311 static void mdc_replay_open(struct ptlrpc_request *req)
312 {
313         struct mdc_open_data *mod = req->rq_cb_data;
314         struct obd_client_handle *och;
315         struct ptlrpc_request *close_req;
316         struct lustre_handle old; 
317         struct mds_body *body;
318         ENTRY;
319
320         body = lustre_swab_repbuf(req, 1, sizeof(*body), lustre_swab_mds_body);
321         LASSERT (body != NULL);
322
323         if (mod == NULL) {
324                 DEBUG_REQ(D_ERROR, req,
325                           "can't properly replay without open data");
326                 EXIT;
327                 return;
328         }
329
330         och = mod->mod_och;
331         if (och != NULL) {
332                 struct lustre_handle *file_fh; 
333                 LASSERT(och->och_magic == OBD_CLIENT_HANDLE_MAGIC);
334                 file_fh = &och->och_fh;
335                 CDEBUG(D_HA, "updating handle from "LPX64" to "LPX64"\n",
336                        file_fh->cookie, body->handle.cookie);
337                 memcpy(&old, file_fh, sizeof(old));
338                 memcpy(file_fh, &body->handle, sizeof(*file_fh));
339         } 
340
341         close_req = mod->mod_close_req;
342         if (close_req != NULL) {
343                 struct mds_body *close_body;
344                 LASSERT(close_req->rq_reqmsg->opc == MDS_CLOSE);
345                 close_body = lustre_msg_buf(close_req->rq_reqmsg, 0,
346                                             sizeof(*close_body));
347                 if (och != NULL)
348                         LASSERT(!memcmp(&old, &close_body->handle, sizeof old));
349                 DEBUG_REQ(D_HA, close_req, "updating close body with new fh");
350                 memcpy(&close_body->handle, &body->handle,
351                        sizeof(close_body->handle));
352         }
353
354         EXIT;
355 }
356
357 void mdc_set_open_replay_data(struct obd_client_handle *och,
358                               struct ptlrpc_request *open_req)
359 {
360         struct mdc_open_data *mod;
361         struct mds_rec_create *rec =
362                 lustre_msg_buf(open_req->rq_reqmsg, 2, sizeof(*rec));
363         struct mds_body *body =
364                 lustre_msg_buf(open_req->rq_repmsg, 1, sizeof(*body));
365
366         LASSERT(rec != NULL);
367         /* outgoing messages always in my byte order */
368         LASSERT(body != NULL);
369         /* incoming message in my byte order (it's been swabbed) */
370         LASSERT_REPSWABBED(open_req, 1);
371
372         OBD_ALLOC(mod, sizeof(*mod));
373         if (mod == NULL) {
374                 DEBUG_REQ(D_ERROR, open_req, "can't allocate mdc_open_data");
375                 return;
376         }
377
378         och->och_mod = mod;
379         mod->mod_och = och;
380         mod->mod_open_req = open_req;
381
382         memcpy(&rec->cr_replayfid, &body->fid1, sizeof rec->cr_replayfid);
383         open_req->rq_replay_cb = mdc_replay_open;
384         open_req->rq_commit_cb = mdc_commit_open;
385         open_req->rq_cb_data = mod;
386         DEBUG_REQ(D_HA, open_req, "set up replay data");
387 }
388
389 void mdc_clear_open_replay_data(struct obd_client_handle *och)
390 {
391         struct mdc_open_data *mod = och->och_mod;
392
393         /* Don't free the structure now (it happens in mdc_commit_open, after
394          * we're sure we won't need to fix up the close request in the future),
395          * but make sure that replay doesn't poke at the och, which is about to
396          * be freed. */
397         LASSERT(mod != (void *)0x5a5a5a5a);
398         if (mod != NULL)
399                 mod->mod_och = NULL;
400         och->och_mod = NULL;
401 }
402
403 static void mdc_commit_close(struct ptlrpc_request *req)
404 {
405         struct mdc_open_data *mod = req->rq_cb_data;
406         struct ptlrpc_request *open_req;
407         struct obd_import *imp = req->rq_import;
408
409         DEBUG_REQ(D_HA, req, "close req committed");
410         if (mod == NULL)
411                 return;
412
413         mod->mod_close_req = NULL;
414         req->rq_cb_data = NULL;
415         req->rq_commit_cb = NULL;
416
417         open_req = mod->mod_open_req;
418         LASSERT(open_req != NULL);
419         LASSERT(open_req != (void *)0x5a5a5a5a);
420
421         DEBUG_REQ(D_HA, open_req, "open req balanced");
422         LASSERT(open_req->rq_transno != 0);
423         LASSERT(open_req->rq_import == imp);
424
425         /* We no longer want to preserve this for transno-unconditional
426          * replay. */
427         spin_lock(&open_req->rq_lock);
428         open_req->rq_replay = 0;
429         spin_unlock(&open_req->rq_lock);
430 }
431
432 static int mdc_close_interpret(struct ptlrpc_request *req, void *data, int rc)
433 {
434         union ptlrpc_async_args *aa = data;
435         struct mdc_rpc_lock *rpc_lock = aa->pointer_arg[0];
436         struct obd_device *obd = aa->pointer_arg[1];
437
438         if (rpc_lock == NULL) {
439                 CERROR("called with NULL rpc_lock\n");
440         } else {
441                 mdc_put_rpc_lock(rpc_lock, NULL);
442                 LASSERTF(req->rq_async_args.pointer_arg[0] ==
443                          obd->u.cli.cl_rpc_lock, "%p != %p\n",
444                          req->rq_async_args.pointer_arg[0],
445                          obd->u.cli.cl_rpc_lock);
446                 aa->pointer_arg[0] = NULL;
447         }
448         wake_up(&req->rq_reply_waitq);
449         RETURN(rc);
450 }
451
452 /* We can't use ptlrpc_check_reply, because we don't want to wake up for
453  * anything but a reply or an error. */
454 static int mdc_close_check_reply(struct ptlrpc_request *req)
455 {
456         int rc = 0;
457         unsigned long flags;
458
459         spin_lock_irqsave(&req->rq_lock, flags);
460         if (PTLRPC_REQUEST_COMPLETE(req)) {
461                 rc = 1;
462         }
463         spin_unlock_irqrestore (&req->rq_lock, flags);
464         return rc;
465 }
466
467 static int go_back_to_sleep(void *unused)
468 {
469         return 0;
470 }
471
472 int mdc_close(struct obd_export *exp, struct obdo *obdo,
473               struct obd_client_handle *och, struct ptlrpc_request **request)
474 {
475         struct mds_body *body;
476         struct obd_device *obd = class_exp2obd(exp);
477         int reqsize = sizeof(*body);
478         int rc, repsize[3] = {sizeof(*body),
479                               obd->u.cli.cl_max_mds_easize,
480                               obd->u.cli.cl_max_mds_cookiesize};
481         struct ptlrpc_request *req;
482         struct mdc_open_data *mod;
483         struct l_wait_info lwi;
484         ENTRY;
485
486         req = ptlrpc_prep_req(class_exp2cliimp(exp), MDS_CLOSE, 1, &reqsize,
487                               NULL);
488         if (req == NULL)
489                 GOTO(out, rc = -ENOMEM);
490
491         /* Ensure that this close's handle is fixed up during replay. */
492         LASSERT(och != NULL);
493         mod = och->och_mod;
494         if (likely(mod != NULL)) {
495                 mod->mod_close_req = req;
496                 DEBUG_REQ(D_HA, mod->mod_open_req, "matched open req %p",
497                           mod->mod_open_req);
498         } else {
499                 CDEBUG(D_HA, "couldn't find open req; expecting close error\n");
500         }
501
502         body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof(*body));
503         mdc_pack_fid(&body->fid1, obdo->o_id, 0, obdo->o_mode);
504         memcpy(&body->handle, &och->och_fh, sizeof(body->handle));
505         body->size = obdo->o_size;
506         body->blocks = obdo->o_blocks;
507         body->flags = obdo->o_flags;
508         body->valid = obdo->o_valid;
509
510         req->rq_replen = lustre_msg_size(3, repsize);
511         req->rq_commit_cb = mdc_commit_close;
512         LASSERT(req->rq_cb_data == NULL);
513         req->rq_cb_data = mod;
514
515         /* We hand a ref to the rpcd here, so we need another one of our own. */
516         ptlrpc_request_addref(req);
517
518         mdc_get_rpc_lock(obd->u.cli.cl_rpc_lock, NULL);
519         req->rq_interpret_reply = mdc_close_interpret;
520         req->rq_async_args.pointer_arg[0] = obd->u.cli.cl_rpc_lock;
521         req->rq_async_args.pointer_arg[1] = obd;
522         ptlrpcd_add_req(req);
523         lwi = LWI_TIMEOUT_INTR(MAX(req->rq_timeout * HZ, 1), go_back_to_sleep,
524                                NULL, NULL);
525         rc = l_wait_event(req->rq_reply_waitq, mdc_close_check_reply(req),
526                           &lwi);
527         if (rc == 0) {
528                 rc = req->rq_repmsg->status;
529                 if (req->rq_repmsg->type == PTL_RPC_MSG_ERR) {
530                         DEBUG_REQ(D_ERROR, req, "type == PTL_RPC_MSG_ERR, err "
531                                   "= %d", rc);
532                         if (rc > 0)
533                                 rc = -rc;
534                 } else if (mod == NULL) {
535                         CERROR("Unexpected: can't find mdc_open_data, but the "
536                                "close succeeded.  Please tell CFS.\n");
537                 }
538                 if (!lustre_swab_repbuf(req, 0, sizeof(struct mds_body),
539                                         lustre_swab_mds_body)) {
540                         CERROR("Error unpacking mds_body\n");
541                         rc = -EPROTO;
542                 }
543         }
544         if (req->rq_async_args.pointer_arg[0] != NULL) {
545                 CERROR("returned without dropping rpc_lock: rc %d\n", rc);
546                 mdc_close_interpret(req, &req->rq_async_args, rc);
547                 portals_debug_dumplog();
548         }
549
550         EXIT;
551  out:
552         *request = req;
553         return rc;
554 }
555
556 int mdc_done_writing(struct obd_export *exp, struct obdo *obdo)
557 {
558         struct ptlrpc_request *req;
559         struct mds_body *body;
560         int rc, size = sizeof(*body);
561         ENTRY;
562
563         req = ptlrpc_prep_req(class_exp2cliimp(exp), MDS_DONE_WRITING, 1,
564                               &size, NULL);
565         if (req == NULL)
566                 RETURN(-ENOMEM);
567
568         body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof(*body));
569         mdc_pack_fid(&body->fid1, obdo->o_id, 0, obdo->o_mode);
570         body->size = obdo->o_size;
571         body->blocks = obdo->o_blocks;
572         body->flags = obdo->o_flags;
573         body->valid = obdo->o_valid;
574 //        memcpy(&body->handle, &och->och_fh, sizeof(body->handle));
575
576         req->rq_replen = lustre_msg_size(1, &size);
577
578         rc = ptlrpc_queue_wait(req);
579         ptlrpc_req_finished(req);
580         RETURN(rc);
581 }
582
583 int mdc_readpage(struct obd_export *exp, struct ll_fid *mdc_fid,
584                  __u64 offset, struct page *page,
585                  struct ptlrpc_request **request)
586 {
587         struct obd_import *imp = class_exp2cliimp(exp);
588         struct ptlrpc_request *req = NULL;
589         struct ptlrpc_bulk_desc *desc = NULL;
590         struct mds_body *body;
591         int rc, size = sizeof(*body);
592         ENTRY;
593
594         CDEBUG(D_INODE, "inode: %ld\n", (long)mdc_fid->id);
595
596         req = ptlrpc_prep_req(imp, MDS_READPAGE, 1, &size, NULL);
597         if (req == NULL)
598                 GOTO(out, rc = -ENOMEM);
599         /* XXX FIXME bug 249 */
600         req->rq_request_portal = MDS_READPAGE_PORTAL;
601
602         desc = ptlrpc_prep_bulk_imp(req, 1, BULK_PUT_SINK, MDS_BULK_PORTAL);
603         if (desc == NULL)
604                 GOTO(out, rc = -ENOMEM);
605         /* NB req now owns desc and will free it when it gets freed */
606
607         ptlrpc_prep_bulk_page(desc, page, 0, PAGE_CACHE_SIZE);
608
609         mdc_readdir_pack(req, offset, PAGE_CACHE_SIZE, mdc_fid);
610
611         req->rq_replen = lustre_msg_size(1, &size);
612         rc = ptlrpc_queue_wait(req);
613
614         if (rc == 0) {
615                 body = lustre_swab_repbuf(req, 0, sizeof (*body),
616                                           lustre_swab_mds_body);
617                 if (body == NULL) {
618                         CERROR("Can't unpack mds_body\n");
619                         GOTO(out, rc = -EPROTO);
620                 }
621
622                 if (req->rq_bulk->bd_nob_transferred != PAGE_CACHE_SIZE) {
623                         CERROR ("Unexpected # bytes transferred: %d"
624                                 " (%ld expected)\n",
625                                 req->rq_bulk->bd_nob_transferred,
626                                 PAGE_CACHE_SIZE);
627                         GOTO (out, rc = -EPROTO);
628                 }
629         }
630
631         EXIT;
632  out:
633         *request = req;
634         return rc;
635 }
636
637 static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
638                          void *karg, void *uarg)
639 {
640         struct obd_device *obd = exp->exp_obd;
641         struct obd_ioctl_data *data = karg;
642         struct obd_import *imp = obd->u.cli.cl_import;
643         struct llog_ctxt *ctxt;
644         int rc;
645         ENTRY;
646         
647         MOD_INC_USE_COUNT;
648
649         switch (cmd) {
650         case OBD_IOC_CLIENT_RECOVER:
651                 rc = ptlrpc_recover_import(imp, data->ioc_inlbuf1);
652                 if (rc < 0)
653                         GOTO(out, rc);
654                 GOTO(out, rc = 0);
655         case IOC_OSC_SET_ACTIVE:
656                 rc = ptlrpc_set_import_active(imp, data->ioc_offset);
657                 GOTO(out, rc);
658         case OBD_IOC_PARSE: {
659                 ctxt = llog_get_context(&exp->exp_obd->obd_llogs,
660                                         LLOG_CONFIG_REPL_CTXT);
661                 rc = class_config_parse_llog(ctxt, data->ioc_inlbuf1, NULL);
662                 GOTO(out, rc);
663         }
664 #ifdef __KERNEL__
665         case OBD_IOC_LLOG_INFO:
666         case OBD_IOC_LLOG_PRINT: {
667                 ctxt = llog_get_context(&obd->obd_llogs, LLOG_CONFIG_REPL_CTXT);
668                 rc = llog_ioctl(ctxt, cmd, data);
669                 
670                 GOTO(out, rc);
671         }
672 #endif
673         default:
674                 CERROR("osc_ioctl(): unrecognised ioctl %#x\n", cmd);
675                 GOTO(out, rc = -ENOTTY);
676         }
677 out:
678         MOD_DEC_USE_COUNT;
679         return rc;
680 }
681
682 int mdc_set_info(struct obd_export *exp, obd_count keylen,
683                  void *key, obd_count vallen, void *val)
684 {
685         int rc = -EINVAL;
686
687         if (keylen == strlen("initial_recov") &&
688             memcmp(key, "initial_recov", strlen("initial_recov")) == 0) {
689                 struct obd_import *imp = exp->exp_obd->u.cli.cl_import;
690                 if (vallen != sizeof(int))
691                         RETURN(-EINVAL);
692                 imp->imp_initial_recov = *(int *)val;
693                 CDEBUG(D_HA, "%s: set imp_no_init_recov = %d\n",
694                        exp->exp_obd->obd_name,
695                        imp->imp_initial_recov);
696                 RETURN(0);
697         } else if (keylen >= strlen("client") && strcmp(key, "client") == 0) {
698                 struct ptlrpc_request *req;
699                 char *bufs[1] = {key};
700                 int rc;
701                 req = ptlrpc_prep_req(class_exp2cliimp(exp), OST_SET_INFO, 1,
702                                       &keylen, bufs);
703                 if (req == NULL)
704                         RETURN(-ENOMEM);
705
706                 req->rq_replen = lustre_msg_size(0, NULL);
707                 rc = ptlrpc_queue_wait(req);
708                 ptlrpc_req_finished(req);
709                 RETURN(rc);
710         }
711         
712         RETURN(rc);
713 }
714
715 static int mdc_statfs(struct obd_device *obd, struct obd_statfs *osfs,
716                       unsigned long max_age)
717 {
718         struct ptlrpc_request *req;
719         struct obd_statfs *msfs;
720         int rc, size = sizeof(*msfs);
721         ENTRY;
722
723         /* We could possibly pass max_age in the request (as an absolute
724          * timestamp or a "seconds.usec ago") so the target can avoid doing
725          * extra calls into the filesystem if that isn't necessary (e.g.
726          * during mount that would help a bit).  Having relative timestamps
727          * is not so great if request processing is slow, while absolute
728          * timestamps are not ideal because they need time synchronization. */
729         req = ptlrpc_prep_req(obd->u.cli.cl_import, MDS_STATFS, 0, NULL, NULL);
730         if (!req)
731                 RETURN(-ENOMEM);
732
733         req->rq_replen = lustre_msg_size(1, &size);
734
735         mdc_get_rpc_lock(obd->u.cli.cl_rpc_lock, NULL);
736         rc = ptlrpc_queue_wait(req);
737         mdc_put_rpc_lock(obd->u.cli.cl_rpc_lock, NULL);
738
739         if (rc)
740                 GOTO(out, rc);
741
742         msfs = lustre_swab_repbuf(req, 0, sizeof(*msfs),lustre_swab_obd_statfs);
743         if (msfs == NULL) {
744                 CERROR("Can't unpack obd_statfs\n");
745                 GOTO(out, rc = -EPROTO);
746         }
747
748         memcpy(osfs, msfs, sizeof (*msfs));
749         EXIT;
750 out:
751         ptlrpc_req_finished(req);
752
753         return rc;
754 }
755
756 static int mdc_pin(struct obd_export *exp, obd_id ino, __u32 gen, int type,
757                    struct obd_client_handle *handle, int flag)
758 {
759         struct ptlrpc_request *req;
760         struct mds_body *body;
761         int rc, size = sizeof(*body);
762         ENTRY;
763
764         req = ptlrpc_prep_req(class_exp2cliimp(exp), MDS_PIN, 1, &size, NULL);
765         if (req == NULL)
766                 RETURN(-ENOMEM);
767
768         body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof (*body));
769         mdc_pack_fid(&body->fid1, ino, gen, type);
770         body->flags = flag;
771
772         req->rq_replen = lustre_msg_size(1, &size);
773
774         mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
775         rc = ptlrpc_queue_wait(req);
776         mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
777         if (rc) {
778                 CERROR("pin failed: %d\n", rc);
779                 ptlrpc_req_finished(req);
780                 RETURN(rc);
781         }
782
783         body = lustre_swab_repbuf(req, 0, sizeof(*body), lustre_swab_mds_body);
784         if (body == NULL) {
785                 ptlrpc_req_finished(req);
786                 RETURN(rc);
787         }
788
789         memcpy(&handle->och_fh, &body->handle, sizeof(body->handle));
790         handle->och_magic = OBD_CLIENT_HANDLE_MAGIC;
791
792         OBD_ALLOC(handle->och_mod, sizeof(*handle->och_mod));
793         if (handle->och_mod == NULL) {
794                 DEBUG_REQ(D_ERROR, req, "can't allocate mdc_open_data");
795                 RETURN(-ENOMEM);
796         }
797         handle->och_mod->mod_open_req = req; /* will be dropped by unpin */
798
799         RETURN(rc);
800 }
801
802 static int mdc_unpin(struct obd_export *exp,
803                      struct obd_client_handle *handle, int flag)
804 {
805         struct ptlrpc_request *req;
806         struct mds_body *body;
807         int rc, size = sizeof(*body);
808         ENTRY;
809
810         if (handle->och_magic != OBD_CLIENT_HANDLE_MAGIC)
811                 RETURN(0);
812
813         req = ptlrpc_prep_req(class_exp2cliimp(exp), MDS_CLOSE, 1, &size, NULL);
814         if (req == NULL)
815                 RETURN(-ENOMEM);
816
817         body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof(*body));
818         memcpy(&body->handle, &handle->och_fh, sizeof(body->handle));
819         body->flags = flag;
820
821         req->rq_replen = lustre_msg_size(0, NULL);
822         mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
823         rc = ptlrpc_queue_wait(req);
824         mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
825
826         if (rc != 0)
827                 CERROR("unpin failed: %d\n", rc);
828
829         ptlrpc_req_finished(req);
830         ptlrpc_req_finished(handle->och_mod->mod_open_req);
831         OBD_FREE(handle->och_mod, sizeof(*handle->och_mod));
832         RETURN(rc);
833 }
834
835 int mdc_sync(struct obd_export *exp, struct ll_fid *fid,
836              struct ptlrpc_request **request)
837 {
838         struct ptlrpc_request *req;
839         struct mds_body *body;
840         int size = sizeof(*body);
841         int rc;
842         ENTRY;
843
844         req = ptlrpc_prep_req(class_exp2cliimp(exp), MDS_SYNC, 1,&size,NULL);
845         if (!req)
846                 RETURN(rc = -ENOMEM);
847
848         if (fid) {
849                 body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof (*body));
850                 memcpy(&body->fid1, fid, sizeof(*fid));
851                 mdc_pack_req_body(req);
852         }
853
854         req->rq_replen = lustre_msg_size(1, &size);
855
856         rc = ptlrpc_queue_wait(req);
857         if (rc || request == NULL)
858                 ptlrpc_req_finished(req);
859         else
860                 *request = req;
861
862         RETURN(rc);
863 }
864
865 static int mdc_attach(struct obd_device *dev, obd_count len, void *data)
866 {
867         struct lprocfs_static_vars lvars;
868
869         lprocfs_init_vars(mdc, &lvars);
870         return lprocfs_obd_attach(dev, lvars.obd_vars);
871 }
872
873 static int mdc_detach(struct obd_device *dev)
874 {
875         return lprocfs_obd_detach(dev);
876 }
877
878 static int mdc_import_event(struct obd_device *obd,
879                             struct obd_import *imp, 
880                             enum obd_import_event event)
881 {
882         int rc = 0;
883
884         LASSERT(imp->imp_obd == obd);
885
886         switch (event) {
887         case IMP_EVENT_DISCON: {
888                 break;
889         }
890         case IMP_EVENT_INACTIVE: {
891                 if (obd->obd_observer)
892                         rc = obd_notify(obd->obd_observer, obd, 0);
893                 break;
894         }
895         case IMP_EVENT_INVALIDATE: {
896                 struct ldlm_namespace *ns = obd->obd_namespace;
897                 
898                 ldlm_namespace_cleanup(ns, LDLM_FL_LOCAL_ONLY);
899
900                 break;
901         }
902         case IMP_EVENT_ACTIVE: {
903                 if (obd->obd_observer)
904                         rc = obd_notify(obd->obd_observer, obd, 1);
905                 break;
906         }
907         default:
908                 CERROR("Unknown import event %d\n", event);
909                 LBUG();
910         }
911         RETURN(rc);
912 }
913
914 static int mdc_setup(struct obd_device *obd, obd_count len, void *buf)
915 {
916         struct client_obd *cli = &obd->u.cli;
917         int rc;
918         ENTRY;
919
920         OBD_ALLOC(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock));
921         if (!cli->cl_rpc_lock)
922                 RETURN(-ENOMEM);
923         mdc_init_rpc_lock(cli->cl_rpc_lock);
924
925         ptlrpcd_addref();
926
927         OBD_ALLOC(cli->cl_setattr_lock, sizeof (*cli->cl_setattr_lock));
928         if (!cli->cl_setattr_lock)
929                 GOTO(out_free_rpc, rc = -ENOMEM);
930         mdc_init_rpc_lock(cli->cl_setattr_lock);
931
932         rc = client_obd_setup(obd, len, buf);
933         if (rc) {
934                 OBD_FREE(cli->cl_setattr_lock, sizeof (*cli->cl_setattr_lock));
935  out_free_rpc:
936                 OBD_FREE(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock));
937         }
938
939         rc = obd_llog_init(obd, &obd->obd_llogs, obd, 0, NULL);
940         if (rc) {
941                 mdc_cleanup(obd, 0);
942                 CERROR("failed to setup llogging subsystems\n");
943         }
944
945         RETURN(rc);
946 }
947
948 int mdc_init_ea_size(struct obd_export *exp, int easize, int cookiesize)
949 {
950         struct obd_device *obd = exp->exp_obd;
951         struct client_obd *cli = &obd->u.cli;
952         ENTRY;
953
954         if (cli->cl_max_mds_easize < easize)
955                 cli->cl_max_mds_easize = easize;
956         if (cli->cl_max_mds_cookiesize < cookiesize)
957                 cli->cl_max_mds_cookiesize = cookiesize;
958         RETURN(0);
959 }
960
961 static int mdc_precleanup(struct obd_device *obd, int flags)
962 {
963         int rc = 0;
964         
965         rc = obd_llog_finish(obd, &obd->obd_llogs, 0);
966         if (rc != 0)
967                 CERROR("failed to cleanup llogging subsystems\n");
968
969         RETURN(rc);
970 }
971
972 static int mdc_cleanup(struct obd_device *obd, int flags)
973 {
974         struct client_obd *cli = &obd->u.cli;
975  
976         OBD_FREE(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock));
977         OBD_FREE(cli->cl_setattr_lock, sizeof (*cli->cl_setattr_lock));
978
979         ptlrpcd_decref();
980
981         return client_obd_cleanup(obd, flags);
982 }
983
984
985 static int mdc_llog_init(struct obd_device *obd, struct obd_llogs *llogs, 
986                          struct obd_device *tgt, int count,
987                          struct llog_catid *logid)
988 {
989         struct llog_ctxt *ctxt;
990         int rc;
991         ENTRY;
992
993         rc = llog_setup(obd, llogs, LLOG_CONFIG_REPL_CTXT, tgt, 0, NULL,
994                         &llog_client_ops);
995         if (rc == 0) {
996                 ctxt = llog_get_context(llogs, LLOG_CONFIG_REPL_CTXT);
997                 ctxt->loc_imp = obd->u.cli.cl_import;
998         }
999
1000         RETURN(rc);
1001 }
1002
1003 static int mdc_llog_finish(struct obd_device *obd,
1004                            struct obd_llogs *llogs, int count)
1005 {
1006         int rc;
1007         ENTRY;
1008
1009         rc = llog_cleanup(llog_get_context(llogs, LLOG_CONFIG_REPL_CTXT));
1010         RETURN(rc);
1011 }
1012
1013 int mdc_obj_create(struct obd_export *exp, struct obdo *oa,
1014                     struct lov_stripe_md **ea, struct obd_trans_info *oti)
1015 {
1016         struct ptlrpc_request *request;
1017         struct ost_body *body;
1018         int rc, size = sizeof(*body);
1019         ENTRY;
1020
1021         LASSERT(oa);
1022
1023         request = ptlrpc_prep_req(class_exp2cliimp(exp), OST_CREATE,
1024                                   1, &size, NULL);
1025         if (!request)
1026                 GOTO(out_req, rc = -ENOMEM);
1027
1028         body = lustre_msg_buf(request->rq_reqmsg, 0, sizeof (*body));
1029         memcpy(&body->oa, oa, sizeof(body->oa));
1030
1031         request->rq_replen = lustre_msg_size(1, &size);
1032         rc = ptlrpc_queue_wait(request);
1033         if (rc)
1034                 GOTO(out_req, rc);
1035
1036         body = lustre_swab_repbuf(request, 0, sizeof(*body),
1037                                   lustre_swab_ost_body);
1038         if (body == NULL) {
1039                 CERROR ("can't unpack ost_body\n");
1040                 GOTO (out_req, rc = -EPROTO);
1041         }
1042
1043         memcpy(oa, &body->oa, sizeof(*oa));
1044
1045         /* store ino/generation for recovery */
1046         body = lustre_msg_buf(request->rq_reqmsg, 0, sizeof (*body));
1047         body->oa.o_id = oa->o_id;
1048         body->oa.o_generation = oa->o_generation;
1049
1050         CDEBUG(D_HA, "transno: "LPD64"\n", request->rq_repmsg->transno);
1051         EXIT;
1052 out_req:
1053         ptlrpc_req_finished(request);
1054         return rc;
1055 }
1056
1057 static int mdc_get_info(struct obd_export *exp, obd_count keylen,
1058                         void *key, __u32 *vallen, void *val)
1059 {
1060         ENTRY;
1061         if (!vallen || !val)
1062                 RETURN(-EFAULT);
1063
1064         if (keylen >= strlen("mdsize") && strcmp(key, "mdsize") == 0) {
1065                 struct ptlrpc_request *req;
1066                 __u32 *reply;
1067                 char *bufs[1] = {key};
1068                 int rc;
1069                 req = ptlrpc_prep_req(class_exp2cliimp(exp), OST_GET_INFO, 1,
1070                                       &keylen, bufs);
1071                 if (req == NULL)
1072                         RETURN(-ENOMEM);
1073
1074                 req->rq_replen = lustre_msg_size(1, vallen);
1075                 rc = ptlrpc_queue_wait(req);
1076                 if (rc)
1077                         GOTO(out, rc);
1078
1079                 /* FIXME: right swap routine here! */
1080                 reply = lustre_swab_repbuf(req, 0, sizeof(*reply), NULL);
1081                 if (reply == NULL) {
1082                         CERROR("Can't unpack mdsize\n");
1083                         GOTO(out, rc = -EPROTO);
1084                 }
1085                 *((__u32 *)val) = *reply;
1086         out:
1087                 ptlrpc_req_finished(req);
1088                 RETURN(rc);
1089         }
1090         RETURN(-EINVAL);
1091 }
1092
1093 int mdc_brw(int rw, struct obd_export *exp, struct obdo *oa,
1094                 struct lov_stripe_md *ea, obd_count oa_bufs,
1095                 struct brw_page *pgarr, struct obd_trans_info *oti)
1096 {
1097         struct ptlrpc_bulk_desc *desc;
1098         struct niobuf_remote *niobuf;
1099         struct ptlrpc_request *req;
1100         struct obd_ioobj *ioobj;
1101         struct ost_body *body;
1102         int err, opc, i;
1103         int size[3];
1104
1105         opc = ((rw & OBD_BRW_WRITE) != 0) ? OST_WRITE : OST_READ;
1106         
1107         size[0] = sizeof(*body);
1108         size[1] = sizeof(*ioobj);
1109         size[2] = oa_bufs * sizeof(*niobuf);
1110
1111         req = ptlrpc_prep_req(class_exp2cliimp(exp), opc, 3, size, NULL);
1112         LASSERT(req != NULL);
1113
1114         if (opc == OST_WRITE)
1115                 desc = ptlrpc_prep_bulk_imp(req, oa_bufs, BULK_GET_SOURCE,
1116                                             OST_BULK_PORTAL);
1117         else
1118                 desc = ptlrpc_prep_bulk_imp(req, oa_bufs, BULK_PUT_SINK,
1119                                             OST_BULK_PORTAL);
1120         LASSERT(desc != NULL);
1121
1122         body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof(*body));
1123         ioobj = lustre_msg_buf(req->rq_reqmsg, 1, sizeof(*ioobj));
1124         niobuf = lustre_msg_buf(req->rq_reqmsg, 2, oa_bufs * sizeof(*niobuf));
1125
1126         memcpy(&body->oa, oa, sizeof(*oa));
1127         obdo_to_ioobj(oa, ioobj);
1128         ioobj->ioo_bufcnt = oa_bufs;
1129
1130         for (i = 0; i < oa_bufs; i++, niobuf++) {
1131                 struct brw_page *pg = &pgarr[i];
1132
1133                 LASSERT(pg->count > 0);
1134                 LASSERT((pg->off & ~PAGE_MASK) + pg->count <= PAGE_SIZE);
1135
1136                 ptlrpc_prep_bulk_page(desc, pg->pg, pg->off & ~PAGE_MASK,
1137                                       pg->count);
1138
1139                 niobuf->offset = pg->off;
1140                 niobuf->len = pg->count;
1141                 niobuf->flags = pg->flag;
1142         }
1143
1144         /* size[0] still sizeof (*body) */
1145         if (opc == OST_WRITE) {
1146                 /* 1 RC per niobuf */
1147                 size[1] = sizeof(__u32) * oa_bufs;
1148                 req->rq_replen = lustre_msg_size(2, size);
1149         } else {
1150                 /* 1 RC for the whole I/O */
1151                 req->rq_replen = lustre_msg_size(1, size);
1152         }
1153         err = ptlrpc_queue_wait(req);
1154         LASSERT(err == 0);
1155
1156         ptlrpc_req_finished(req);
1157         return 0;
1158 }
1159
1160 static int mdc_valid_attrs(struct obd_export *exp, struct ll_fid *fid)
1161 {
1162         struct ldlm_res_id res_id = { .name = {0} };
1163         struct obd_device *obd = exp->exp_obd;
1164         struct lustre_handle lockh;
1165         ldlm_policy_data_t policy;
1166         int flags;
1167         ENTRY;
1168
1169         res_id.name[0] = fid->id;
1170         res_id.name[1] = fid->generation;
1171         policy.l_inodebits.bits = MDS_INODELOCK_UPDATE;
1172
1173         CDEBUG(D_INFO, "trying to match res "LPU64"\n", res_id.name[0]);
1174
1175         /* FIXME use LDLM_FL_TEST_LOCK instead */
1176         flags = LDLM_FL_BLOCK_GRANTED | LDLM_FL_CBPENDING;
1177         if (ldlm_lock_match(obd->obd_namespace, flags, &res_id,
1178                             LDLM_IBITS, &policy, LCK_PR, &lockh)) {
1179                 ldlm_lock_decref(&lockh, LCK_PR);
1180                 RETURN(1);
1181         }
1182
1183         if (ldlm_lock_match(obd->obd_namespace, flags, &res_id,
1184                             LDLM_IBITS, &policy, LCK_PW, &lockh)) {
1185                 ldlm_lock_decref(&lockh, LCK_PW);
1186                 RETURN(1);
1187         }
1188         RETURN(0);
1189 }
1190
1191 struct obd_ops mdc_obd_ops = {
1192         o_owner:        THIS_MODULE,
1193         o_attach:       mdc_attach,
1194         o_detach:       mdc_detach,
1195         o_setup:        mdc_setup,
1196         o_precleanup:   mdc_precleanup,
1197         o_cleanup:      mdc_cleanup,
1198         o_connect:      client_connect_import,
1199         o_disconnect:   client_disconnect_export,
1200         o_iocontrol:    mdc_iocontrol,
1201         o_set_info:     mdc_set_info,
1202         o_statfs:       mdc_statfs,
1203         o_pin:          mdc_pin,
1204         o_unpin:        mdc_unpin,
1205         o_llog_init:    mdc_llog_init,
1206         o_llog_finish:  mdc_llog_finish,
1207         o_create:       mdc_obj_create,
1208         o_get_info:     mdc_get_info,
1209         o_brw:          mdc_brw,
1210         o_init_ea_size: mdc_init_ea_size,
1211 };
1212
1213 struct md_ops mdc_md_ops = {
1214         m_getstatus:     mdc_getstatus,
1215         m_getattr:       mdc_getattr,
1216         m_change_cbdata: mdc_change_cbdata,
1217         m_close:         mdc_close,
1218         m_create:        mdc_create,
1219         m_done_writing:  mdc_done_writing,
1220         m_enqueue:       mdc_enqueue,
1221         m_getattr_name:  mdc_getattr_name,
1222         m_intent_lock:   mdc_intent_lock,
1223         m_link:          mdc_link,
1224         m_rename:        mdc_rename,
1225         m_setattr:       mdc_setattr,
1226         m_sync:          mdc_sync,
1227         m_readpage:      mdc_readpage,
1228         m_unlink:        mdc_unlink,
1229         m_valid_attrs:   mdc_valid_attrs,
1230 };
1231
1232 int __init mdc_init(void)
1233 {
1234         struct lprocfs_static_vars lvars;
1235         lprocfs_init_vars(mdc, &lvars);
1236         return class_register_type(&mdc_obd_ops, &mdc_md_ops, lvars.module_vars,
1237                                    LUSTRE_MDC_NAME);
1238 }
1239
1240 static void /*__exit*/ mdc_exit(void)
1241 {
1242         class_unregister_type(LUSTRE_MDC_NAME);
1243 }
1244
1245 #ifdef __KERNEL__
1246 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
1247 MODULE_DESCRIPTION("Lustre Metadata Client");
1248 MODULE_LICENSE("GPL");
1249
1250 EXPORT_SYMBOL(mdc_req2lustre_md);
1251 EXPORT_SYMBOL(mdc_change_cbdata);
1252 EXPORT_SYMBOL(mdc_getstatus);
1253 EXPORT_SYMBOL(mdc_getattr);
1254 EXPORT_SYMBOL(mdc_getattr_name);
1255 EXPORT_SYMBOL(mdc_create);
1256 EXPORT_SYMBOL(mdc_unlink);
1257 EXPORT_SYMBOL(mdc_rename);
1258 EXPORT_SYMBOL(mdc_link);
1259 EXPORT_SYMBOL(mdc_readpage);
1260 EXPORT_SYMBOL(mdc_setattr);
1261 EXPORT_SYMBOL(mdc_close);
1262 EXPORT_SYMBOL(mdc_done_writing);
1263 EXPORT_SYMBOL(mdc_sync);
1264 EXPORT_SYMBOL(mdc_set_open_replay_data);
1265 EXPORT_SYMBOL(mdc_clear_open_replay_data);
1266 EXPORT_SYMBOL(mdc_store_inode_generation);
1267
1268 module_init(mdc_init);
1269 module_exit(mdc_exit);
1270 #endif