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