Whamcloud - gitweb
fixes:
[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-2004 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/lustre_sec.h>
40 #include <linux/lprocfs_status.h>
41 #include <linux/lustre_acl.h>
42 #include <linux/lustre_lite.h>
43 #include <linux/lustre_gs.h>
44 #include "mdc_internal.h"
45
46 #define REQUEST_MINOR 244
47
48 static int mdc_cleanup(struct obd_device *obd, int flags);
49
50 extern int mds_queue_req(struct ptlrpc_request *);
51 /* Helper that implements most of mdc_getstatus and signal_completed_replay. */
52 /* XXX this should become mdc_get_info("key"), sending MDS_GET_INFO RPC */
53 static int send_getstatus(struct obd_import *imp, struct lustre_id *rootid,
54                           int level, int msg_flags)
55 {
56         struct ptlrpc_request *req;
57         struct mds_body *body;
58         int rc, size[2] = {0, sizeof(*body)};
59         ENTRY;
60
61         //size[0] = lustre_secdesc_size();
62
63         req = ptlrpc_prep_req(imp, LUSTRE_MDS_VERSION, MDS_GETSTATUS,
64                               2, size, NULL);
65         if (!req)
66                 GOTO(out, rc = -ENOMEM);
67
68         //lustre_pack_secdesc(req, size[0]);
69
70         body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF, sizeof (*body));
71         req->rq_send_state = level;
72         req->rq_replen = lustre_msg_size(1, &size[1]);
73
74         req->rq_reqmsg->flags |= msg_flags;
75         rc = ptlrpc_queue_wait(req);
76
77         if (!rc) {
78                 body = lustre_swab_repbuf (req, 0, sizeof (*body),
79                                            lustre_swab_mds_body);
80                 if (body == NULL) {
81                         CERROR ("Can't extract mds_body\n");
82                         GOTO (out, rc = -EPROTO);
83                 }
84
85                 memcpy(rootid, &body->id1, sizeof(*rootid));
86
87                 CDEBUG(D_NET, "root ino="LPU64", last_committed="LPU64
88                        ", last_xid="LPU64"\n", rootid->li_stc.u.e3s.l3s_ino,
89                        req->rq_repmsg->last_committed, req->rq_repmsg->last_xid);
90         }
91
92         EXIT;
93  out:
94         ptlrpc_req_finished(req);
95         return rc;
96 }
97
98 /* This should be mdc_get_info("rootid") */
99 int mdc_getstatus(struct obd_export *exp, struct lustre_id *rootid)
100 {
101         return send_getstatus(class_exp2cliimp(exp), rootid,
102                               LUSTRE_IMP_FULL, 0);
103 }
104
105 int
106 mdc_interpret_getattr(struct ptlrpc_request *req, void *unused, int rc)
107 {
108         struct mds_body *body = NULL;
109         struct lustre_capa *capa = NULL;
110         unsigned long expiry;
111         ENTRY;
112
113         if (rc) {
114                 DEBUG_REQ(D_ERROR, req,
115                           "async getattr failed: rc = %d", rc);
116                 RETURN(rc);
117         }
118
119         body = lustre_swab_repbuf(req, 0, sizeof (*body), lustre_swab_mds_body);
120         if (body == NULL) {
121                 CERROR ("Can't unpack mds_body\n");
122                 RETURN(-EPROTO);
123         }
124
125         if (!(body->valid & OBD_MD_CAPA)) {
126                 CDEBUG(D_INFO, "MDS has disabled capability\n");
127                 RETURN(0);
128         }
129
130         capa = lustre_swab_repbuf(req, 1, sizeof(*capa),
131                                   lustre_swab_lustre_capa);
132         if (capa == NULL && rc != 0) {
133                 CERROR ("Can't unpack lustre_capa\n");
134                 RETURN(-EPROTO);
135         }
136
137         rc = capa_renew(capa, CLIENT_CAPA);
138         if (rc)
139                 RETURN(rc);
140
141         spin_lock(&capa_lock);
142         expiry = expiry_to_jiffies(capa->lc_expiry - capa_pre_expiry(capa));
143         if (time_before(expiry, ll_capa_timer.expires) ||
144             !timer_pending(&ll_capa_timer)) {
145                 mod_timer(&ll_capa_timer, expiry);
146                 CDEBUG(D_INFO, "ll_capa_timer new timer: %lu\n", expiry);
147         }
148         spin_unlock(&capa_lock);
149
150         RETURN(rc);
151 }
152
153 int mdc_getattr_async(struct obd_export *exp, struct ptlrpc_request *req)
154 {
155         int repsize[2] = {sizeof(struct mds_body), sizeof(struct lustre_capa)};
156         ENTRY;
157
158         req->rq_replen = lustre_msg_size(2, repsize);
159         req->rq_interpret_reply = mdc_interpret_getattr;
160         ptlrpcd_add_req(req);
161
162         RETURN (0);
163 }
164
165 int mdc_getattr_common(struct obd_export *exp, unsigned int ea_size,
166                        struct ptlrpc_request *req)
167 {
168         struct mds_body *body, *reqbody;
169         void            *eadata;
170         int              rc;
171         int              repsize[2] = {sizeof(*body)};
172         int              bufcount = 1;
173         ENTRY;
174
175         /* request message already built */
176
177         if (ea_size != 0) {
178                 repsize[bufcount++] = ea_size;
179                 CDEBUG(D_INODE, "reserved %u bytes for MD/symlink in packet\n",
180                        ea_size);
181         }
182
183         reqbody = lustre_msg_buf(req->rq_reqmsg, 1, sizeof(*reqbody));
184         LASSERT(!(reqbody->valid & OBD_MD_FLACL));
185
186         if (reqbody->valid & OBD_MD_FLKEY) {
187                 repsize[bufcount++] = 5;
188                 repsize[bufcount++] = sizeof(struct lustre_key);
189         } else if (reqbody->valid & OBD_MD_CAPA) {
190                 LASSERT(ea_size == 0);
191                 repsize[bufcount++] = sizeof(struct lustre_capa);
192         }
193
194         req->rq_replen = lustre_msg_size(bufcount, repsize);
195
196         mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
197         rc = ptlrpc_queue_wait(req);
198         mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
199         if (rc != 0)
200                 RETURN (rc);
201
202         body = lustre_swab_repbuf (req, 0, sizeof (*body),
203                                    lustre_swab_mds_body);
204         if (body == NULL) {
205                 CERROR ("Can't unpack mds_body\n");
206                 RETURN (-EPROTO);
207         }
208
209         CDEBUG(D_NET, "mode: %o\n", body->mode);
210
211         LASSERT_REPSWAB (req, 1);
212
213         /* Skip the check if getxattr/listxattr are called with no buffers */
214         if ((reqbody->eadatasize != 0) &&
215             !(reqbody->valid & (OBD_MD_FLXATTR | OBD_MD_FLXATTRLIST))) {
216                 /* reply indicates presence of eadata; check it's there... */
217                 eadata = lustre_msg_buf (req->rq_repmsg, 1,
218                                          body->eadatasize);
219                 if (eadata == NULL) {
220                         CERROR ("Missing/short eadata\n");
221                         RETURN (-EPROTO);
222                 }
223         }
224
225         RETURN (0);
226 }
227
228 static int mdc_cancel_unused(struct obd_export *exp,
229                              struct lov_stripe_md *lsm, 
230                              int flags, void *opaque)
231 {
232         struct obd_device *obd = class_exp2obd(exp);
233
234         ENTRY;
235         RETURN(ldlm_cli_cancel_unused(obd->obd_namespace,
236                                       NULL, flags, opaque));
237 }
238
239 int mdc_getattr(struct obd_export *exp, struct lustre_id *id,
240                 __u64 valid, const char *xattr_name,
241                 const void *xattr_data, unsigned int xattr_datalen,
242                 unsigned int ea_size, struct obd_capa *ocapa,
243                 struct ptlrpc_request **request)
244 {
245         struct ptlrpc_request *req;
246         struct mds_body *body;
247         int xattr_namelen = xattr_name ? strlen(xattr_name) + 1 : 0;
248         int size[4] = {0, sizeof(*body)};
249         int bufcount = 2;
250         int rc;
251         ENTRY;
252
253         size[0] = lustre_secdesc_size();
254
255         if (valid & OBD_MD_FLXATTR) {
256                 size[bufcount++] = xattr_namelen;
257
258                 if (xattr_datalen > 0) {
259                         LASSERT(xattr_data);
260                         size[bufcount++] = xattr_datalen;
261                 }
262         } else if (valid & OBD_MD_CAPA) {
263                 LASSERT(valid  == OBD_MD_CAPA);
264                 LASSERT(ocapa);
265                 size[bufcount++] = sizeof(*ocapa);
266         } else {
267                 LASSERT(!xattr_data && !xattr_datalen);
268         }
269
270         req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
271                               MDS_GETATTR, bufcount, size, NULL);
272         if (!req)
273                 GOTO(out, rc = -ENOMEM);
274
275         lustre_pack_secdesc(req, size[0]);
276
277         body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF, sizeof (*body));
278         memcpy(&body->id1, id, sizeof(*id));
279         body->valid = valid;
280         body->eadatasize = ea_size;
281
282         if (valid & OBD_MD_FLXATTR) {
283                 memcpy(lustre_msg_buf(req->rq_reqmsg, 2, xattr_namelen),
284                        xattr_name, xattr_namelen);
285                 if (xattr_datalen)
286                         memcpy(lustre_msg_buf(req->rq_reqmsg, 3, xattr_datalen),
287                                xattr_data, xattr_datalen);
288         }
289
290         if (valid & OBD_MD_CAPA) {
291                 /* renew capability */
292                 memcpy(&body->handle, &ocapa->c_handle, sizeof(body->handle));
293                 memcpy(lustre_msg_buf(req->rq_reqmsg, 2, sizeof(ocapa->c_capa)),
294                        &ocapa->c_capa, sizeof(ocapa->c_capa));
295
296                 rc = mdc_getattr_async(exp, req);
297                 req = NULL;     /* ptlrpcd will finish request */
298         } else {
299                 rc = mdc_getattr_common(exp, ea_size, req);
300                 if (rc != 0) {
301                         ptlrpc_req_finished (req);
302                         req = NULL;
303                 }
304         }
305  out:
306         *request = req;
307         RETURN (rc);
308 }
309
310 int mdc_access_check(struct obd_export *exp, struct lustre_id *id,
311                      struct ptlrpc_request **request)
312
313 {
314         struct ptlrpc_request *req;
315         struct mds_body *body;
316         int size[2] = {0, sizeof(*body)};
317         int rc;
318         ENTRY;
319
320         size[0] = lustre_secdesc_size();
321         req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
322                               MDS_ACCESS_CHECK, 2, size, NULL);
323         if (!req)
324                 GOTO(out, rc = -ENOMEM);
325
326         lustre_pack_secdesc(req, size[0]);
327         body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF, sizeof (*body));
328         memcpy(&body->id1, id, sizeof(*id));
329
330         size[0] = sizeof(*body);
331         size[1] = sizeof(struct mds_remote_perm);
332         req->rq_replen = lustre_msg_size(2, size);
333
334         mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
335         rc = ptlrpc_queue_wait(req);
336         mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
337         if (rc != 0) {
338                 ptlrpc_req_finished (req);
339                 req = NULL;
340         } else {
341                 body = lustre_swab_repbuf (req, 0, sizeof (*body),
342                                            lustre_swab_mds_body);
343                 if (body == NULL) {
344                         CERROR ("Can't unpack mds_body\n");
345                         RETURN (-EPROTO);
346                 }
347         }
348
349  out:
350         *request = req;
351         RETURN (rc);
352 }
353
354 int mdc_getattr_lock(struct obd_export *exp, struct lustre_id *id,
355                      char *filename, int namelen, __u64 valid,
356                      unsigned int ea_size, struct ptlrpc_request **request)
357 {
358         struct ptlrpc_request *req;
359         struct mds_body *body;
360         int rc, size[3] = {0, sizeof(*body), namelen};
361         ENTRY;
362
363         size[0] = lustre_secdesc_size();
364
365         req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
366                               MDS_GETATTR_LOCK, 3, size, NULL);
367         if (!req)
368                 GOTO(out, rc = -ENOMEM);
369
370         lustre_pack_secdesc(req, size[0]);
371
372         body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF, sizeof (*body));
373         memcpy(&body->id1, id, sizeof(*id));
374         body->valid = valid;
375         body->eadatasize = ea_size;
376
377         if (filename != NULL) {
378                 LASSERT (strnlen (filename, namelen) == namelen - 1);
379                 memcpy(lustre_msg_buf(req->rq_reqmsg, 2, namelen),
380                        filename, namelen);
381         } else {
382                 LASSERT(namelen == 1);
383         }
384
385         rc = mdc_getattr_common(exp, ea_size, req);
386         if (rc != 0) {
387                 ptlrpc_req_finished (req);
388                 req = NULL;
389         }
390  out:
391         *request = req;
392         RETURN(rc);
393 }
394
395 /* This should be called with both the request and the reply still packed. */
396 int mdc_store_inode_generation(struct obd_export *exp,
397                                struct ptlrpc_request *req,
398                                int reqoff, int repoff)
399 {
400         struct mds_rec_create *rec =
401                 lustre_msg_buf(req->rq_reqmsg, reqoff, sizeof(*rec));
402         struct mds_body *body =
403                 lustre_msg_buf(req->rq_repmsg, repoff, sizeof(*body));
404
405         LASSERT (rec != NULL);
406         LASSERT (body != NULL);
407
408         memcpy(&rec->cr_replayid, &body->id1, sizeof(rec->cr_replayid));
409         DEBUG_REQ(D_HA, req, "storing generation for ino "DLID4,
410                   OLID4(&rec->cr_replayid));
411         return 0;
412 }
413
414 int mdc_req2lustre_capa(struct ptlrpc_request *req, unsigned int offset,
415                         struct lustre_capa **capa)
416 {
417         struct mds_body *body;
418         struct lustre_capa *lcapa;
419
420         body = lustre_msg_buf(req->rq_repmsg, offset, sizeof(*body));
421         if (!body)
422                 RETURN(-ENOMEM);
423
424         if (!(body->valid & OBD_MD_CAPA)) {
425                 *capa = NULL;
426                 RETURN(0);
427         }
428
429         lcapa = (struct lustre_capa *)lustre_swab_repbuf(req, offset + 1,
430                                         sizeof(*capa), lustre_swab_lustre_capa);
431         if (!lcapa)
432                 RETURN(-ENOMEM);
433                 
434         OBD_ALLOC(*capa, sizeof(**capa));
435         if (!*capa)
436                 RETURN(-ENOMEM);
437         memcpy(*capa, lcapa, sizeof(**capa));
438
439         RETURN(0);
440 }
441
442 static
443 int mdc_unpack_acl(struct obd_export *exp_lmv, struct ptlrpc_request *req, 
444                    unsigned int offset, struct lustre_md *md)
445 {
446         struct posix_acl *acl;
447         struct mds_remote_perm *perm;
448         int    size, rc;
449         void  *buf;
450         ENTRY;
451  
452         if (!(md->body->valid & OBD_MD_FLACL))
453                 RETURN(0);
454
455         if (md->body->valid & OBD_MD_FLRMTACL) {
456                 offset++; /* first 'size' is not used */
457
458                 buf = lustre_swab_repbuf(req, offset, sizeof(*perm),
459                                          lustre_swab_remote_perm);
460                 if (buf == NULL) {
461                         CERROR("Can't unpack remote perm\n");
462                         RETURN(-EFAULT);
463                 }
464
465                 OBD_ALLOC(perm, sizeof(*perm));
466                 if (!perm)
467                         RETURN(-ENOMEM);
468                 memcpy(perm, buf, sizeof(*perm));
469                 md->remote_perm = perm;
470         } else {
471                 size = le32_to_cpu(*(__u32 *) lustre_msg_buf(
472                                    req->rq_repmsg, offset, 4));
473                 buf = lustre_msg_buf(req->rq_repmsg, offset + 1, size);
474
475                 acl = posix_acl_from_xattr(buf, size);
476                 if (IS_ERR(acl)) {
477                         rc = PTR_ERR(acl);
478                         CERROR("convert xattr to acl failed: %d\n", rc);
479                         RETURN(rc);
480                 } else if (acl) {
481                         rc = posix_acl_valid(acl);
482                         if (rc) {
483                                 CERROR("acl valid error: %d\n", rc);
484                                 posix_acl_release(acl);
485                                 RETURN(rc);
486                         }
487                 }
488
489                 md->posix_acl = acl;
490         }
491
492         RETURN(0);
493 }
494
495 static int mdc_unpack_gskey(struct obd_export *exp_lmv, struct ptlrpc_request *req, 
496                             unsigned int *offset, struct lustre_md *md)
497
498         int key_off = 0, rc = 0, size = 0;
499         void *buf;
500         
501         key_off = *offset;
502         if (md->body->valid & OBD_MD_FLKEY) {
503                 size = le32_to_cpu(*(__u32 *) lustre_msg_buf(req->rq_repmsg, 
504                                    key_off++, 4));
505                 buf = lustre_msg_buf(req->rq_repmsg, key_off++, size);
506                 
507                 CDEBUG(D_INFO, "buf %p key_off %d size %d \n", 
508                        buf, key_off, size);
509                 md->key = (struct lustre_key *)buf; 
510                 *offset = key_off; 
511         } else {
512                 *offset += 2;
513         } 
514         RETURN(rc);
515 }
516
517 int mdc_req2lustre_md(struct obd_export *exp_lmv, struct ptlrpc_request *req, 
518                       unsigned int offset, struct obd_export *exp_lov, 
519                       struct lustre_md *md)
520 {
521         struct lov_mds_md *lmm;
522         int rc = 0, reply_off;
523         ENTRY;
524
525         LASSERT(md != NULL);
526         memset(md, 0, sizeof(*md));
527
528         md->body = lustre_msg_buf(req->rq_repmsg, offset,
529                                   sizeof(*md->body));
530         if (!md->body)
531                 RETURN(-ENOMEM);
532
533         LASSERT_REPSWABBED(req, offset);
534
535         if (!(md->body->valid & OBD_MD_FLEASIZE) &&
536             !(md->body->valid & OBD_MD_FLDIREA))
537                 RETURN(0);
538
539         if (S_ISREG(md->body->mode)) {
540                 if (md->body->eadatasize == 0) {
541                         CERROR("invalid EA size (0) is detected\n");
542                         RETURN(-EPROTO);
543                 }
544
545                 lmm = lustre_msg_buf(req->rq_repmsg, offset + 1,
546                                      md->body->eadatasize);
547                 if (!lmm)
548                         RETURN(-EINVAL);
549
550                 LASSERT(exp_lov != NULL);
551                 
552                 rc = obd_unpackmd(exp_lov, &md->lsm, lmm,
553                                   md->body->eadatasize);
554                 if (rc > 0) {
555                         LASSERT(rc >= sizeof(*md->lsm));
556                         rc = 0;
557                 }
558         } else if (S_ISDIR(md->body->mode)) {
559                 /* dir can be non-splitted */
560                 if (md->body->eadatasize == 0)
561                         RETURN(0);
562
563                 lmm = lustre_msg_buf(req->rq_repmsg, offset + 1,
564                                      md->body->eadatasize);
565                 if (!lmm)
566                         RETURN(-EINVAL);
567
568                 if (md->body->valid & OBD_MD_MEA) {
569                         LASSERT(exp_lmv != NULL);
570                 
571                         rc = obd_unpackmd(exp_lmv, (void *)&md->mea,
572                                           lmm, md->body->eadatasize);
573                         if (rc > 0) {
574                                 LASSERT(rc >= sizeof(*md->mea));
575                                 rc = 0;
576                         }
577                 }
578         } else {
579                 LASSERT(S_ISCHR(md->body->mode) ||
580                         S_ISBLK(md->body->mode) ||
581                         S_ISFIFO(md->body->mode)||
582                         S_ISLNK(md->body->mode) ||
583                         S_ISSOCK(md->body->mode));
584         }
585
586         /* if anything wrong when unpacking md, we don't check acl
587          * stuff, for simplicity
588          */
589         if (rc)
590                 RETURN(rc);
591
592         reply_off = (md->body->valid & OBD_MD_FLEASIZE) ?
593                                 (offset + 2) : (offset + 1);
594         rc = mdc_unpack_acl(exp_lmv, req, reply_off, md);
595         if (rc) {
596                 CERROR("upack acl error %d \n", rc);
597                 RETURN(rc);
598         }
599         reply_off += 2;
600         
601         rc = mdc_unpack_gskey(exp_lmv, req, &reply_off, md);
602         if (rc)
603                 RETURN(rc);
604
605         RETURN(rc);
606 }
607
608 static void mdc_commit_open(struct ptlrpc_request *req)
609 {
610         struct mdc_open_data *mod = req->rq_cb_data;
611         if (mod == NULL)
612                 return;
613
614         if (mod->mod_close_req != NULL)
615                 mod->mod_close_req->rq_cb_data = NULL;
616
617         if (mod->mod_och != NULL)
618                 mod->mod_och->och_mod = NULL;
619
620         OBD_FREE(mod, sizeof(*mod));
621         req->rq_cb_data = NULL;
622         LASSERT(atomic_read(&req->rq_refcount) > 1);
623         ptlrpc_req_finished(req);
624 }
625
626 static void mdc_replay_open(struct ptlrpc_request *req)
627 {
628         struct mdc_open_data *mod = req->rq_cb_data;
629         struct obd_client_handle *och;
630         struct ptlrpc_request *close_req;
631         struct lustre_handle old;
632         struct mds_body *body;
633         ENTRY;
634
635         body = lustre_swab_repbuf(req, 1, sizeof(*body), lustre_swab_mds_body);
636         LASSERT (body != NULL);
637
638         if (mod == NULL) {
639                 DEBUG_REQ(D_ERROR, req,
640                           "can't properly replay without open data");
641                 EXIT;
642                 return;
643         }
644
645         och = mod->mod_och;
646         if (och != NULL) {
647                 struct lustre_handle *file_fh;
648                 LASSERT(och->och_magic == OBD_CLIENT_HANDLE_MAGIC);
649                 file_fh = &och->och_fh;
650                 CDEBUG(D_HA, "updating handle from "LPX64" to "LPX64"\n",
651                        file_fh->cookie, body->handle.cookie);
652                 memcpy(&old, file_fh, sizeof(old));
653                 memcpy(file_fh, &body->handle, sizeof(*file_fh));
654         }
655
656         close_req = mod->mod_close_req;
657         if (close_req != NULL) {
658                 struct mds_body *close_body;
659                 LASSERT(close_req->rq_reqmsg->opc == MDS_CLOSE);
660                 close_body = lustre_msg_buf(close_req->rq_reqmsg,
661                                             MDS_REQ_REC_OFF,
662                                             sizeof(*close_body));
663                 if (och != NULL)
664                         LASSERT(!memcmp(&old, &close_body->handle, sizeof old));
665                 DEBUG_REQ(D_HA, close_req, "updating close body with new fh");
666                 memcpy(&close_body->handle, &body->handle,
667                        sizeof(close_body->handle));
668         }
669
670         EXIT;
671 }
672
673 int mdc_set_open_replay_data(struct obd_export *exp,
674                              struct obd_client_handle *och,
675                              struct ptlrpc_request *open_req)
676 {
677         struct mdc_open_data *mod;
678         struct mds_rec_create *rec;
679         struct mds_body *body;
680
681         rec = lustre_msg_buf(open_req->rq_reqmsg, MDS_REQ_INTENT_REC_OFF,
682                              sizeof(*rec));
683         body = lustre_msg_buf(open_req->rq_repmsg, 1, sizeof(*body));
684
685         LASSERT(rec != NULL);
686         /* outgoing messages always in my byte order */
687         LASSERT(body != NULL);
688         /* incoming message in my byte order (it's been swabbed) */
689         LASSERT_REPSWABBED(open_req, 1);
690
691         OBD_ALLOC(mod, sizeof(*mod));
692         if (mod == NULL) {
693                 DEBUG_REQ(D_ERROR, open_req, "can't allocate mdc_open_data");
694                 return 0;
695         }
696
697         och->och_mod = mod;
698         mod->mod_och = och;
699         mod->mod_open_req = ptlrpc_request_addref(open_req);
700
701         memcpy(&rec->cr_replayid, &body->id1, sizeof rec->cr_replayid);
702         open_req->rq_replay_cb = mdc_replay_open;
703         open_req->rq_commit_cb = mdc_commit_open;
704         open_req->rq_cb_data = mod;
705         DEBUG_REQ(D_HA, open_req, "set up replay data");
706         return 0;
707 }
708
709 int mdc_clear_open_replay_data(struct obd_export *exp,
710                                struct obd_client_handle *och)
711 {
712         struct mdc_open_data *mod = och->och_mod;
713
714         /* Don't free the structure now (it happens in mdc_commit_open, after
715          * we're sure we won't need to fix up the close request in the future),
716          * but make sure that replay doesn't poke at the och, which is about to
717          * be freed. */
718         LASSERT(mod != LP_POISON);
719         if (mod != NULL)
720                 mod->mod_och = NULL;
721         och->och_mod = NULL;
722         return 0;
723 }
724
725 static void mdc_commit_close(struct ptlrpc_request *req)
726 {
727         struct mdc_open_data *mod = req->rq_cb_data;
728         struct obd_import *imp = req->rq_import;
729         struct ptlrpc_request *open_req;
730
731         DEBUG_REQ(D_HA, req, "close req committed");
732         if (mod == NULL)
733                 return;
734
735         mod->mod_close_req = NULL;
736         req->rq_cb_data = NULL;
737         req->rq_commit_cb = NULL;
738
739         open_req = mod->mod_open_req;
740         LASSERT(open_req != NULL);
741         LASSERT(open_req != LP_POISON);
742         LASSERT(open_req->rq_type != LI_POISON);
743
744         DEBUG_REQ(D_HA, open_req, "open req balanced");
745         if (open_req->rq_transno == 0) {
746                 DEBUG_REQ(D_ERROR, open_req, "BUG 3892  open");
747                 DEBUG_REQ(D_ERROR, req, "BUG 3892 close");
748                 LASSERTF(open_req->rq_transno != 0, "BUG 3892\n");
749         }
750         LASSERT(open_req->rq_import == imp);
751
752         /* We no longer want to preserve this for transno-unconditional
753          * replay. */
754         spin_lock(&open_req->rq_lock);
755         open_req->rq_replay = 0;
756         spin_unlock(&open_req->rq_lock);
757 }
758
759 int mdc_close(struct obd_export *exp, struct mdc_op_data *op_data,
760               struct obd_client_handle *och, struct ptlrpc_request **request)
761 {
762         struct obd_device *obd = class_exp2obd(exp);
763         struct obd_import *imp = class_exp2cliimp(exp);
764         int reqsize[3] = {0, sizeof(struct mds_body),
765                           obd->u.cli.cl_max_mds_cookiesize};
766         int rc, repsize[3] = {sizeof(struct mds_body),
767                               obd->u.cli.cl_max_mds_easize,
768                               obd->u.cli.cl_max_mds_cookiesize};
769         struct ptlrpc_request *req;
770         struct mdc_open_data *mod;
771         ENTRY;
772
773         if (imp->imp_connection == NULL) {
774                 CERROR("request on not connected import %s\n",
775                         imp->imp_obd->obd_name);
776                 RETURN(-EIO);
777         }
778
779         req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
780                               MDS_CLOSE, 3, reqsize, NULL);
781         if (req == NULL)
782                 GOTO(out, rc = -ENOMEM);
783         req->rq_request_portal = MDS_CLOSE_PORTAL;
784
785         /* ensure that this close's handle is fixed up during replay. */
786         LASSERT(och != NULL);
787         mod = och->och_mod;
788         if (likely(mod != NULL)) {
789                 mod->mod_close_req = req;
790                 LASSERT(mod->mod_open_req->rq_type != LI_POISON);
791                 DEBUG_REQ(D_HA, mod->mod_open_req, "matched open");
792         } else {
793                 CDEBUG(D_HA, "couldn't find open req; "
794                        "expecting close error\n");
795         }
796
797         mdc_close_pack(req, 1, op_data, och);
798
799         req->rq_replen = lustre_msg_size(3, repsize);
800         req->rq_commit_cb = mdc_commit_close;
801         LASSERT(req->rq_cb_data == NULL);
802         req->rq_cb_data = mod;
803
804         mdc_get_rpc_lock(obd->u.cli.cl_close_lock, NULL);
805         rc = ptlrpc_queue_wait(req);
806         mdc_put_rpc_lock(obd->u.cli.cl_close_lock, NULL);
807
808         if (req->rq_repmsg == NULL) {
809                 CDEBUG(D_HA, "request failed to send: %p, %d\n", req,
810                        req->rq_status);
811                 if (rc == 0)
812                         rc = req->rq_status ? req->rq_status : -EIO;
813         } else if (rc == 0) {
814                 rc = req->rq_repmsg->status;
815                 if (req->rq_repmsg->type == PTL_RPC_MSG_ERR) {
816                         DEBUG_REQ(D_ERROR, req, "type == PTL_RPC_MSG_ERR, "
817                                   "err = %d", rc);
818                         if (rc > 0)
819                                 rc = -rc;
820                 } else {
821                         if (mod == NULL)
822                                 CERROR("Unexpected: can't find mdc_open_data, but "
823                                        "close succeeded. Please tell CFS.\n");
824                         if (!lustre_swab_repbuf(req, 0, sizeof(struct mds_body),
825                                                 lustre_swab_mds_body))
826                         {
827                                 CERROR("Error unpacking mds_body\n");
828                                 rc = -EPROTO;
829                         }
830                 }
831         }
832
833         EXIT;
834  out:
835         *request = req;
836         return rc;
837 }
838
839 int mdc_done_writing(struct obd_export *exp, struct obdo *obdo)
840 {
841         struct ptlrpc_request *req;
842         struct mds_body *body;
843         int rc, size[2] = {0, sizeof(*body)};
844         ENTRY;
845
846         size[0] = lustre_secdesc_size();
847
848         req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
849                               MDS_DONE_WRITING, 2, size, NULL);
850         if (req == NULL)
851                 RETURN(-ENOMEM);
852
853         lustre_pack_secdesc(req, size[0]);
854
855         body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF, 
856                               sizeof(*body));
857         
858         mdc_pack_id(&body->id1, obdo->o_id, 0, obdo->o_mode, 
859                     obdo->o_mds, obdo->o_fid);
860         
861         body->size = obdo->o_size;
862         body->blocks = obdo->o_blocks;
863         body->flags = obdo->o_flags;
864         body->valid = obdo->o_valid;
865
866         req->rq_replen = lustre_msg_size(1, &size[1]);
867
868         rc = ptlrpc_queue_wait(req);
869         ptlrpc_req_finished(req);
870         RETURN(rc);
871 }
872
873 int mdc_readpage(struct obd_export *exp,
874                  struct lustre_id *id,
875                  __u64 offset, struct page *page,
876                  struct ptlrpc_request **request)
877 {
878         struct obd_import *imp = class_exp2cliimp(exp);
879         struct ptlrpc_request *req = NULL;
880         struct ptlrpc_bulk_desc *desc = NULL;
881         struct mds_body *body;
882         int rc, size[2] = {0, sizeof(*body)};
883         ENTRY;
884
885         CDEBUG(D_INODE, "inode: %ld\n", (long)id->li_stc.u.e3s.l3s_ino);
886
887         size[0] = lustre_secdesc_size();
888
889         req = ptlrpc_prep_req(imp, LUSTRE_MDS_VERSION, MDS_READPAGE,
890                               2, size, NULL);
891         if (req == NULL)
892                 GOTO(out, rc = -ENOMEM);
893         /* XXX FIXME bug 249 */
894         req->rq_request_portal = MDS_READPAGE_PORTAL;
895
896         lustre_pack_secdesc(req, size[0]);
897
898         desc = ptlrpc_prep_bulk_imp(req, 1, BULK_PUT_SINK, MDS_BULK_PORTAL);
899         if (desc == NULL)
900                 GOTO(out, rc = -ENOMEM);
901         /* NB req now owns desc and will free it when it gets freed */
902
903         ptlrpc_prep_bulk_page(desc, page, 0, PAGE_CACHE_SIZE);
904         mdc_readdir_pack(req, 1, offset, PAGE_CACHE_SIZE, id);
905
906         req->rq_replen = lustre_msg_size(1, &size[1]);
907         rc = ptlrpc_queue_wait(req);
908
909         if (rc == 0) {
910                 body = lustre_swab_repbuf(req, 0, sizeof (*body),
911                                           lustre_swab_mds_body);
912                 if (body == NULL) {
913                         CERROR("Can't unpack mds_body\n");
914                         GOTO(out, rc = -EPROTO);
915                 }
916
917                 if (req->rq_bulk->bd_nob_transferred != PAGE_CACHE_SIZE) {
918                         CERROR ("Unexpected # bytes transferred: %d"
919                                 " (%ld expected)\n",
920                                 req->rq_bulk->bd_nob_transferred,
921                                 PAGE_CACHE_SIZE);
922                         GOTO (out, rc = -EPROTO);
923                 }
924         }
925
926         EXIT;
927  out:
928         *request = req;
929         return rc;
930 }
931
932 static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
933                          void *karg, void *uarg)
934 {
935         struct obd_device *obd = exp->exp_obd;
936         struct obd_ioctl_data *data = karg;
937         struct obd_import *imp = obd->u.cli.cl_import;
938         struct llog_ctxt *ctxt;
939         int rc;
940         ENTRY;
941
942 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
943         MOD_INC_USE_COUNT;
944 #else
945         if (!try_module_get(THIS_MODULE)) {
946                 CERROR("Can't get module. Is it alive?");
947                 return -EINVAL;
948         }
949 #endif
950         switch (cmd) {
951         case OBD_IOC_CLIENT_RECOVER:
952                 rc = ptlrpc_recover_import(imp, data->ioc_inlbuf1);
953                 if (rc < 0)
954                         GOTO(out, rc);
955                 GOTO(out, rc = 0);
956         case IOC_OSC_SET_ACTIVE:
957                 rc = ptlrpc_set_import_active(imp, data->ioc_offset);
958                 GOTO(out, rc);
959         case IOC_OSC_CTL_RECOVERY:
960                 rc = ptlrpc_import_control_recovery(imp, data->ioc_offset);
961                 GOTO(out, rc);
962         case OBD_IOC_PARSE: {
963                 ctxt = llog_get_context(&exp->exp_obd->obd_llogs,
964                                         LLOG_CONFIG_REPL_CTXT);
965                 rc = class_config_process_llog(ctxt, data->ioc_inlbuf1, NULL);
966                 GOTO(out, rc);
967         }
968 #ifdef __KERNEL__
969         case OBD_IOC_LLOG_INFO:
970         case OBD_IOC_LLOG_PRINT: {
971                 ctxt = llog_get_context(&obd->obd_llogs, LLOG_CONFIG_REPL_CTXT);
972                 rc = llog_ioctl(ctxt, cmd, data);
973
974                 GOTO(out, rc);
975         }
976 #endif
977         default:
978                 CERROR("mdc_ioctl(): unrecognised ioctl %#x\n", cmd);
979                 GOTO(out, rc = -ENOTTY);
980         }
981 out:
982 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
983         MOD_DEC_USE_COUNT;
984 #else
985         module_put(THIS_MODULE);
986 #endif
987
988         return rc;
989 }
990
991 int mdc_set_info(struct obd_export *exp, obd_count keylen,
992                  void *key, obd_count vallen, void *val)
993 {
994         int rc = -EINVAL;
995
996         if (keylen == strlen("initial_recov") &&
997             memcmp(key, "initial_recov", strlen("initial_recov")) == 0) {
998                 struct obd_import *imp = exp->exp_obd->u.cli.cl_import;
999                 if (vallen != sizeof(int))
1000                         RETURN(-EINVAL);
1001                 imp->imp_initial_recov = *(int *)val;
1002                 CDEBUG(D_HA, "%s: set imp_no_init_recov = %d\n",
1003                        exp->exp_obd->obd_name,
1004                        imp->imp_initial_recov);
1005                 RETURN(0);
1006         } else if ((keylen >= strlen("crypto_type")) && 
1007                     strcmp(key, "crypto_type") == 0) {
1008                 struct ptlrpc_request *req;
1009                 char *bufs[2] = {key, val};
1010                 int rc, size[2] = {keylen, vallen};
1011
1012                 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OBD_VERSION,
1013                                       OST_SET_INFO, 2, size, bufs);
1014                 if (req == NULL)
1015                         RETURN(-ENOMEM);
1016
1017                 req->rq_replen = lustre_msg_size(0, NULL);
1018                 rc = ptlrpc_queue_wait(req);
1019                 ptlrpc_req_finished(req);
1020                 RETURN(rc);
1021         } else if (keylen >= strlen("inter_mds") && strcmp(key, "inter_mds") == 0) {
1022                 struct obd_import *imp = class_exp2cliimp(exp);
1023                 imp->imp_server_timeout = 1;
1024                 CDEBUG(D_OTHER, "%s: timeout / 2\n", exp->exp_obd->obd_name);
1025                 RETURN(0);
1026         } else if (keylen == strlen("sec") &&
1027                    memcmp(key, "sec", keylen) == 0) {
1028                 struct client_obd *cli = &exp->exp_obd->u.cli;
1029
1030                 cli->cl_sec_flavor = ptlrpcs_name2flavor(val);
1031                 if (cli->cl_sec_flavor == PTLRPCS_FLVR_INVALID) {
1032                         CERROR("unrecognized security type %s\n", (char*) val);
1033                         RETURN(-EINVAL);
1034                 }
1035
1036                 RETURN(0);
1037         } else if (keylen == strlen("sec_flags") &&
1038                    memcmp(key, "sec_flags", keylen) == 0) {
1039                 struct client_obd *cli = &exp->exp_obd->u.cli;
1040
1041                 cli->cl_sec_flags = *((unsigned long *) val);
1042                 RETURN(0);
1043         } else if (keylen == strlen("flush_cred") &&
1044                    memcmp(key, "flush_cred", keylen) == 0) {
1045                 struct client_obd *cli = &exp->exp_obd->u.cli;
1046
1047                 if (cli->cl_import)
1048                         ptlrpcs_import_flush_current_creds(cli->cl_import);
1049                 RETURN(0);
1050         } else if (keylen == strlen("async") && memcmp(key, "async", keylen) == 0) {
1051                 struct client_obd *cl = &exp->exp_obd->u.cli;
1052                 if (vallen != sizeof(int))
1053                         RETURN(-EINVAL);
1054                 cl->cl_async = *(int *)val;
1055                 CDEBUG(D_HA, "%s: set async = %d\n",
1056                        exp->exp_obd->obd_name, cl->cl_async);
1057                 RETURN(0);
1058         } else if (keylen == strlen("setext") && memcmp(key, "setext", keylen) == 0) {
1059                 struct ptlrpc_request *req;
1060                 char *bufs[2] = {key, val};
1061                 int rc, size[2] = {keylen, vallen};
1062
1063                 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OBD_VERSION,
1064                                       OST_SET_INFO, 2, size, bufs);
1065                 if (req == NULL)
1066                         RETURN(-ENOMEM);
1067
1068                 req->rq_replen = lustre_msg_size(0, NULL);
1069                 rc = ptlrpc_queue_wait(req);
1070                 ptlrpc_req_finished(req);
1071                 RETURN(rc);
1072         } else if (keylen == 5 && strcmp(key, "audit") == 0) {
1073                 struct ptlrpc_request *req;
1074                 char *bufs[2] = {key, val};
1075                 int rc, size[2] = {keylen, vallen};
1076
1077                 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OBD_VERSION,
1078                                       OST_SET_INFO, 2, size, bufs);
1079                 if (req == NULL)
1080                         RETURN(-ENOMEM);
1081
1082                 req->rq_replen = lustre_msg_size(0, NULL);
1083                 lustre_swab_reqbuf(req, 1, sizeof(struct audit_attr_msg),
1084                                    lustre_swab_audit_attr);
1085                 rc = ptlrpc_queue_wait(req);
1086                 ptlrpc_req_finished(req);
1087
1088                 RETURN(rc);
1089         } else if (keylen == strlen("ids") && memcmp(key, "ids", keylen) == 0) {
1090                 struct ptlrpc_request *req;
1091                 struct lustre_id *ids = (struct lustre_id *)val;
1092                 char *bufs[3] = {key, (char *)ids, (char *)(ids + 1)};
1093                 int rc, size[3] = {keylen, sizeof(struct lustre_id), 
1094                                    sizeof(struct lustre_id)};
1095
1096                 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OBD_VERSION,
1097                                       OST_SET_INFO, 3, size, bufs);
1098                 if (req == NULL)
1099                         RETURN(-ENOMEM);
1100
1101                 req->rq_replen = lustre_msg_size(0, NULL);
1102                 rc = ptlrpc_queue_wait(req);
1103                 ptlrpc_req_finished(req);
1104                 RETURN(rc);
1105         }
1106         RETURN(rc);
1107 }
1108
1109 static int mdc_statfs(struct obd_device *obd, struct obd_statfs *osfs,
1110                       unsigned long max_age)
1111 {
1112         struct obd_statfs *msfs;
1113         struct ptlrpc_request *req;
1114         int rc, size = sizeof(*msfs);
1115         ENTRY;
1116
1117         /* We could possibly pass max_age in the request (as an absolute
1118          * timestamp or a "seconds.usec ago") so the target can avoid doing
1119          * extra calls into the filesystem if that isn't necessary (e.g.
1120          * during mount that would help a bit).  Having relative timestamps
1121          * is not so great if request processing is slow, while absolute
1122          * timestamps are not ideal because they need time synchronization. */
1123         req = ptlrpc_prep_req(obd->u.cli.cl_import, LUSTRE_MDS_VERSION,
1124                               MDS_STATFS, 0, NULL, NULL);
1125         if (!req)
1126                 RETURN(-ENOMEM);
1127
1128         req->rq_replen = lustre_msg_size(1, &size);
1129
1130         mdc_get_rpc_lock(obd->u.cli.cl_rpc_lock, NULL);
1131         rc = ptlrpc_queue_wait(req);
1132         mdc_put_rpc_lock(obd->u.cli.cl_rpc_lock, NULL);
1133
1134         if (rc) {
1135                 /* this can be LMV fake import, whcih is not connected. */
1136                 if (!req->rq_import->imp_connection)
1137                         memset(osfs, 0, sizeof(*osfs));
1138                 GOTO(out, rc);
1139         }
1140
1141         msfs = lustre_swab_repbuf(req, 0, sizeof(*msfs),
1142                                   lustre_swab_obd_statfs);
1143         if (msfs == NULL) {
1144                 CERROR("Can't unpack obd_statfs\n");
1145                 GOTO(out, rc = -EPROTO);
1146         }
1147
1148         memcpy(osfs, msfs, sizeof (*msfs));
1149         EXIT;
1150 out:
1151         ptlrpc_req_finished(req);
1152         return rc;
1153 }
1154
1155 static int mdc_pin(struct obd_export *exp, obd_id ino, __u32 gen, int type,
1156                    struct obd_client_handle *handle, int flag)
1157 {
1158         struct ptlrpc_request *req;
1159         struct mds_body *body;
1160         int rc, size[2] = {0, sizeof(*body)};
1161         ENTRY;
1162
1163         //size[0] = lustre_secdesc_size();
1164
1165         req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
1166                               MDS_PIN, 2, size, NULL);
1167         if (req == NULL)
1168                 RETURN(-ENOMEM);
1169
1170         //lustre_pack_secdesc(req, size[0]);
1171
1172         body = lustre_msg_buf(req->rq_reqmsg, 
1173                               MDS_REQ_REC_OFF, sizeof(*body));
1174
1175         /* FIXME-UMKA: here should be also mdsnum and fid. */
1176         mdc_pack_id(&body->id1, ino, gen, type, 0, 0);
1177         body->flags = flag;
1178
1179         req->rq_replen = lustre_msg_size(1, &size[1]);
1180
1181         mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
1182         rc = ptlrpc_queue_wait(req);
1183         mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
1184         if (rc) {
1185                 CERROR("pin failed: %d\n", rc);
1186                 ptlrpc_req_finished(req);
1187                 RETURN(rc);
1188         }
1189
1190         body = lustre_swab_repbuf(req, 0, sizeof(*body), lustre_swab_mds_body);
1191         if (body == NULL) {
1192                 ptlrpc_req_finished(req);
1193                 RETURN(rc);
1194         }
1195
1196         memcpy(&handle->och_fh, &body->handle, sizeof(body->handle));
1197         handle->och_magic = OBD_CLIENT_HANDLE_MAGIC;
1198
1199         OBD_ALLOC(handle->och_mod, sizeof(*handle->och_mod));
1200         if (handle->och_mod == NULL) {
1201                 DEBUG_REQ(D_ERROR, req, "can't allocate mdc_open_data");
1202                 RETURN(-ENOMEM);
1203         }
1204         handle->och_mod->mod_open_req = req; /* will be dropped by unpin */
1205
1206         RETURN(rc);
1207 }
1208
1209 static int mdc_unpin(struct obd_export *exp,
1210                      struct obd_client_handle *handle, int flag)
1211 {
1212         struct ptlrpc_request *req;
1213         struct mds_body *body;
1214         int rc, size[2] = {0, sizeof(*body)};
1215         ENTRY;
1216
1217         if (handle->och_magic != OBD_CLIENT_HANDLE_MAGIC)
1218                 RETURN(0);
1219
1220         //size[0] = lustre_secdesc_size();
1221
1222         req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
1223                               MDS_CLOSE, 2, size, NULL);
1224         if (req == NULL)
1225                 RETURN(-ENOMEM);
1226
1227         //lustre_pack_secdesc(req, size[0]);
1228
1229         body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF, sizeof(*body));
1230         memcpy(&body->handle, &handle->och_fh, sizeof(body->handle));
1231         body->flags = flag;
1232
1233         req->rq_replen = lustre_msg_size(0, NULL);
1234         mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
1235         rc = ptlrpc_queue_wait(req);
1236         mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
1237
1238         if (rc != 0)
1239                 CERROR("unpin failed: %d\n", rc);
1240
1241         ptlrpc_req_finished(req);
1242         ptlrpc_req_finished(handle->och_mod->mod_open_req);
1243         OBD_FREE(handle->och_mod, sizeof(*handle->och_mod));
1244         RETURN(rc);
1245 }
1246
1247 int mdc_sync(struct obd_export *exp, struct lustre_id *id,
1248              struct ptlrpc_request **request)
1249 {
1250         struct ptlrpc_request *req;
1251         struct mds_body *body;
1252         int size[2] = {0, sizeof(*body)};
1253         int rc;
1254         ENTRY;
1255
1256         //size[0] = lustre_secdesc_size();
1257
1258         req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
1259                               MDS_SYNC, 2, size, NULL);
1260         if (!req)
1261                 RETURN(rc = -ENOMEM);
1262
1263         //lustre_pack_secdesc(req, size[0]);
1264
1265         if (id) {
1266                 body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF,
1267                                       sizeof (*body));
1268                 memcpy(&body->id1, id, sizeof(*id));
1269         }
1270
1271         req->rq_replen = lustre_msg_size(1, &size[1]);
1272
1273         rc = ptlrpc_queue_wait(req);
1274         if (rc || request == NULL)
1275                 ptlrpc_req_finished(req);
1276         else
1277                 *request = req;
1278
1279         RETURN(rc);
1280 }
1281
1282 static int mdc_import_event(struct obd_device *obd, struct obd_import *imp,
1283                             enum obd_import_event event)
1284 {
1285         int rc = 0;
1286
1287         LASSERT(imp->imp_obd == obd);
1288
1289         switch (event) {
1290         case IMP_EVENT_DISCON: {
1291                 break;
1292         }
1293         case IMP_EVENT_INACTIVE: {
1294                 if (obd->obd_observer)
1295                         rc = obd_notify(obd->obd_observer, obd, 0, 0);
1296                 break;
1297         }
1298         case IMP_EVENT_INVALIDATE: {
1299                 struct ldlm_namespace *ns = obd->obd_namespace;
1300
1301                 ldlm_namespace_cleanup(ns, LDLM_FL_LOCAL_ONLY);
1302
1303                 break;
1304         }
1305         case IMP_EVENT_ACTIVE: {
1306                 if (obd->obd_observer)
1307                         rc = obd_notify(obd->obd_observer, obd, 1, 0);
1308                 break;
1309         }
1310         default:
1311                 CERROR("Unknown import event %d\n", event);
1312                 LBUG();
1313         }
1314         RETURN(rc);
1315 }
1316
1317 static int mdc_attach(struct obd_device *dev, obd_count len, void *data)
1318 {
1319         struct lprocfs_static_vars lvars;
1320
1321         lprocfs_init_vars(mdc, &lvars);
1322         return lprocfs_obd_attach(dev, lvars.obd_vars);
1323 }
1324
1325 static int mdc_detach(struct obd_device *dev)
1326 {
1327         return lprocfs_obd_detach(dev);
1328 }
1329
1330 static int mdc_setup(struct obd_device *obd, obd_count len, void *buf)
1331 {
1332         struct client_obd *cli = &obd->u.cli;
1333         int rc;
1334         ENTRY;
1335
1336         OBD_ALLOC(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock));
1337         if (!cli->cl_rpc_lock)
1338                 RETURN(-ENOMEM);
1339         mdc_init_rpc_lock(cli->cl_rpc_lock);
1340
1341         ptlrpcd_addref();
1342
1343         OBD_ALLOC(cli->cl_setattr_lock, sizeof (*cli->cl_setattr_lock));
1344         if (!cli->cl_setattr_lock)
1345                 GOTO(err_rpc_lock, rc = -ENOMEM);
1346         mdc_init_rpc_lock(cli->cl_setattr_lock);
1347
1348         OBD_ALLOC(cli->cl_close_lock, sizeof (*cli->cl_close_lock));
1349         if (!cli->cl_close_lock)
1350                 GOTO(err_setattr_lock, rc = -ENOMEM);
1351         mdc_init_rpc_lock(cli->cl_close_lock);
1352
1353         rc = client_obd_setup(obd, len, buf);
1354         if (rc)
1355                 GOTO(err_close_lock, rc);
1356
1357         rc = obd_llog_init(obd, &obd->obd_llogs, obd, 0, NULL);
1358         if (rc) {
1359                 mdc_cleanup(obd, 0);
1360                 CERROR("failed to setup llogging subsystems\n");
1361         }
1362
1363         RETURN(rc);
1364
1365 err_close_lock:
1366         OBD_FREE(cli->cl_close_lock, sizeof (*cli->cl_close_lock));
1367 err_setattr_lock:
1368         OBD_FREE(cli->cl_setattr_lock, sizeof (*cli->cl_setattr_lock));
1369 err_rpc_lock:
1370         OBD_FREE(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock));
1371         ptlrpcd_decref();
1372         RETURN(rc);
1373 }
1374
1375 static int mdc_init_ea_size(struct obd_export *exp, int easize, int cookiesize)
1376 {
1377         struct obd_device *obd = exp->exp_obd;
1378         struct client_obd *cli = &obd->u.cli;
1379         ENTRY;
1380
1381         if (cli->cl_max_mds_easize < easize)
1382                 cli->cl_max_mds_easize = easize;
1383         if (cli->cl_max_mds_cookiesize < cookiesize)
1384                 cli->cl_max_mds_cookiesize = cookiesize;
1385         RETURN(0);
1386 }
1387
1388 static int mdc_precleanup(struct obd_device *obd, int flags)
1389 {
1390         int rc = 0;
1391         
1392         rc = obd_llog_finish(obd, &obd->obd_llogs, 0);
1393         if (rc != 0)
1394                 CERROR("failed to cleanup llogging subsystems\n");
1395
1396         RETURN(rc);
1397 }
1398
1399 static int mdc_cleanup(struct obd_device *obd, int flags)
1400 {
1401         struct client_obd *cli = &obd->u.cli;
1402
1403         OBD_FREE(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock));
1404         OBD_FREE(cli->cl_setattr_lock, sizeof (*cli->cl_setattr_lock));
1405         OBD_FREE(cli->cl_close_lock, sizeof (*cli->cl_close_lock));
1406
1407         ptlrpcd_decref();
1408
1409         return client_obd_cleanup(obd, flags);
1410 }
1411
1412
1413 static int mdc_llog_init(struct obd_device *obd, struct obd_llogs *llogs, 
1414                          struct obd_device *tgt, int count,
1415                          struct llog_catid *logid)
1416 {
1417         struct llog_ctxt *ctxt;
1418         int rc;
1419         ENTRY;
1420
1421         rc = obd_llog_setup(obd, llogs, LLOG_CONFIG_REPL_CTXT, tgt, 0, NULL,
1422                             &llog_client_ops);
1423         if (rc == 0) {
1424                 ctxt = llog_get_context(llogs, LLOG_CONFIG_REPL_CTXT);
1425                 ctxt->loc_imp = obd->u.cli.cl_import;
1426         }
1427
1428         RETURN(rc);
1429 }
1430
1431 static int mdc_llog_finish(struct obd_device *obd,
1432                            struct obd_llogs *llogs, int count)
1433 {
1434         int rc;
1435         ENTRY;
1436
1437         rc = obd_llog_cleanup(llog_get_context(llogs, LLOG_CONFIG_REPL_CTXT));
1438         RETURN(rc);
1439 }
1440
1441 static struct obd_device *mdc_get_real_obd(struct obd_export *exp,
1442                                            struct lustre_id *id)
1443 {
1444        ENTRY;
1445        RETURN(exp->exp_obd);
1446 }
1447
1448 static int mdc_get_info(struct obd_export *exp, __u32 keylen,
1449                         void *key, __u32 *valsize, void *val)
1450 {
1451         struct ptlrpc_request *req;
1452         char *bufs[1] = {key};
1453         int rc = 0;
1454         ENTRY;
1455         
1456         if (!valsize || !val)
1457                 RETURN(-EFAULT);
1458
1459         if (keylen >= strlen("remote_flag") && !strcmp(key, "remote_flag")) {
1460                 struct obd_import *imp;
1461                 struct obd_connect_data *data;
1462
1463                 imp = class_exp2cliimp(exp);
1464                 if (!imp) {
1465                         LBUG();
1466                         RETURN(-EINVAL);
1467                 }
1468
1469                 if (imp->imp_state != LUSTRE_IMP_FULL) {
1470                         CERROR("import state not full\n");
1471                         RETURN(-EINVAL);
1472                 }
1473
1474                 data = &imp->imp_connect_data;
1475                 if (data->ocd_connect_flags & OBD_CONNECT_REMOTE) {
1476                         *((int *)val) = 1;
1477                         RETURN(0);
1478                 } else if (data->ocd_connect_flags & OBD_CONNECT_LOCAL) {
1479                         *((int *)val) = 0;
1480                         RETURN(0);
1481                 }
1482                 CERROR("no remote flag set?\n");
1483                 RETURN(-EINVAL);
1484         }
1485
1486         if ((keylen < strlen("mdsize") || strcmp(key, "mdsize") != 0) &&
1487             (keylen < strlen("mdsnum") || strcmp(key, "mdsnum") != 0) &&
1488             (keylen < strlen("lovdesc") || strcmp(key, "lovdesc") != 0) &&
1489             (keylen < strlen("getext") || strcmp(key, "getext") != 0) &&
1490             (keylen < strlen("rootid") || strcmp(key, "rootid") != 0) &&
1491             (keylen < strlen("auditid") || strcmp(key, "auditid") != 0))
1492                 RETURN(-EPROTO);
1493                 
1494         req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OBD_VERSION,
1495                               OST_GET_INFO, 1, (int *)&keylen, bufs);
1496         if (req == NULL)
1497                 RETURN(-ENOMEM);
1498
1499         req->rq_replen = lustre_msg_size(1, (int *)valsize);
1500         rc = ptlrpc_queue_wait(req);
1501         if (rc)
1502                 GOTO(out_req, rc);
1503
1504         if ((keylen >= strlen("rootid") && !strcmp(key, "rootid")) ||
1505             (keylen >= strlen("auditid") && !strcmp(key, "auditid"))) {
1506                 struct lustre_id *reply;
1507                 
1508                 reply = lustre_swab_repbuf(req, 0, sizeof(*reply),
1509                                            lustre_swab_lustre_id);
1510                 if (reply == NULL) {
1511                         CERROR("Can't unpack %s\n", (char *)key);
1512                         GOTO(out_req, rc = -EPROTO);
1513                 }
1514
1515                 *(struct lustre_id *)val = *reply;
1516         } else if (keylen >= strlen("lovdesc") && !strcmp(key, "lovdesc")) {
1517                 struct lov_desc *reply;
1518                 
1519                 reply = lustre_swab_repbuf(req, 0, sizeof(*reply),
1520                                            lustre_swab_lov_desc);
1521                 if (reply == NULL) {
1522                         CERROR("Can't unpack %s\n", (char *)key);
1523                         GOTO(out_req, rc = -EPROTO);
1524                 }
1525
1526                 *(struct lov_desc *)val = *reply;
1527                 RETURN(0);
1528         } else if (keylen >= strlen("getext") && !strcmp(key, "getext")) {
1529                 struct fid_extent *reply;
1530                 
1531                 reply = lustre_swab_repbuf(req, 0, sizeof(*reply),
1532                                            lustre_swab_fid_extent);
1533                 if (reply == NULL) {
1534                         CERROR("Can't unpack %s\n", (char *)key);
1535                         GOTO(out_req, rc = -EPROTO);
1536                 }
1537
1538                 *(struct fid_extent *)val = *reply;
1539                 RETURN(0);
1540         } else {
1541                 __u32 *reply;
1542                 
1543                 reply = lustre_swab_repbuf(req, 0, sizeof(*reply),
1544                                            lustre_swab_generic_32s);
1545                 if (reply == NULL) {
1546                         CERROR("Can't unpack %s\n", (char *)key);
1547                         GOTO(out_req, rc = -EPROTO);
1548                 }
1549                 *((__u32 *)val) = *reply;
1550         }
1551 out_req:
1552         ptlrpc_req_finished(req);
1553         RETURN(rc);
1554 }
1555
1556 int mdc_obj_create(struct obd_export *exp, struct obdo *oa,
1557                    void *acl, int acl_size, struct lov_stripe_md **ea,
1558                    struct obd_trans_info *oti)
1559 {
1560         struct ptlrpc_request *request;
1561         struct ost_body *body;
1562         char *acl_buf;
1563         int rc, size[2] = { sizeof(*body), acl_size };
1564         ENTRY;
1565
1566         LASSERT(oa);
1567
1568         request = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OBD_VERSION,
1569                                   OST_CREATE, 2, size, NULL);
1570         if (!request)
1571                 GOTO(out_req, rc = -ENOMEM);
1572
1573         body = lustre_msg_buf(request->rq_reqmsg, 0, sizeof (*body));
1574         memcpy(&body->oa, oa, sizeof(body->oa));
1575
1576         if (acl_size) {
1577                 acl_buf = lustre_msg_buf(request->rq_reqmsg, 1, acl_size);
1578                 memcpy(acl_buf, acl, acl_size);
1579         }
1580
1581         request->rq_replen = lustre_msg_size(1, size);
1582         rc = ptlrpc_queue_wait(request);
1583         if (rc)
1584                 GOTO(out_req, rc);
1585
1586         body = lustre_swab_repbuf(request, 0, sizeof(*body),
1587                                   lustre_swab_ost_body);
1588         if (body == NULL) {
1589                 CERROR ("can't unpack ost_body\n");
1590                 GOTO (out_req, rc = -EPROTO);
1591         }
1592
1593         memcpy(oa, &body->oa, sizeof(*oa));
1594
1595         /* store ino/generation for recovery */
1596         body = lustre_msg_buf(request->rq_reqmsg, 0, sizeof (*body));
1597         body->oa.o_id = oa->o_id;
1598         body->oa.o_generation = oa->o_generation;
1599         body->oa.o_fid = oa->o_fid;
1600         body->oa.o_mds = oa->o_mds;
1601
1602         CDEBUG(D_HA, "transno: "LPD64"\n", request->rq_repmsg->transno);
1603         EXIT;
1604 out_req:
1605         ptlrpc_req_finished(request);
1606         return rc;
1607 }
1608
1609 int mdc_brw(int rw, struct obd_export *exp, struct obdo *oa,
1610             struct lov_stripe_md *ea, obd_count oa_bufs,
1611             struct brw_page *pgarr, struct obd_trans_info *oti)
1612 {
1613         struct ptlrpc_bulk_desc *desc;
1614         struct niobuf_remote *niobuf;
1615         struct ptlrpc_request *req;
1616         struct obd_ioobj *ioobj;
1617         struct ost_body *body;
1618         int err, opc, i;
1619         int size[3];
1620
1621         opc = ((rw & OBD_BRW_WRITE) != 0) ? OST_WRITE : OST_READ;
1622         
1623         size[0] = sizeof(*body);
1624         size[1] = sizeof(*ioobj);
1625         size[2] = oa_bufs * sizeof(*niobuf);
1626
1627         req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OBD_VERSION, opc,
1628                               3, size, NULL);
1629         LASSERT(req != NULL);
1630
1631         if (opc == OST_WRITE)
1632                 desc = ptlrpc_prep_bulk_imp(req, oa_bufs, BULK_GET_SOURCE,
1633                                             OST_BULK_PORTAL);
1634         else
1635                 desc = ptlrpc_prep_bulk_imp(req, oa_bufs, BULK_PUT_SINK,
1636                                             OST_BULK_PORTAL);
1637         LASSERT(desc != NULL);
1638
1639         body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof(*body));
1640         ioobj = lustre_msg_buf(req->rq_reqmsg, 1, sizeof(*ioobj));
1641         niobuf = lustre_msg_buf(req->rq_reqmsg, 2, oa_bufs * sizeof(*niobuf));
1642
1643         memcpy(&body->oa, oa, sizeof(*oa));
1644         obdo_to_ioobj(oa, ioobj);
1645         ioobj->ioo_bufcnt = oa_bufs;
1646
1647         for (i = 0; i < oa_bufs; i++, niobuf++) {
1648                 struct brw_page *pg = &pgarr[i];
1649
1650                 LASSERT(pg->count > 0);
1651                 LASSERT((pg->disk_offset & ~PAGE_MASK) + pg->count <= PAGE_SIZE);
1652
1653                 ptlrpc_prep_bulk_page(desc, pg->pg, pg->disk_offset & ~PAGE_MASK,
1654                                       pg->count);
1655
1656                 niobuf->offset = pg->disk_offset;
1657                 niobuf->len = pg->count;
1658                 niobuf->flags = pg->flag;
1659         }
1660
1661         /* size[0] still sizeof (*body) */
1662         if (opc == OST_WRITE) {
1663                 /* 1 RC per niobuf */
1664                 size[1] = sizeof(__u32) * oa_bufs;
1665                 req->rq_replen = lustre_msg_size(2, size);
1666         } else {
1667                 /* 1 RC for the whole I/O */
1668                 req->rq_replen = lustre_msg_size(1, size);
1669         }
1670         err = ptlrpc_queue_wait(req);
1671         LASSERT(err == 0);
1672
1673         ptlrpc_req_finished(req);
1674         return 0;
1675 }
1676
1677 static int mdc_valid_attrs(struct obd_export *exp,
1678                            struct lustre_id *id)
1679 {
1680         struct ldlm_res_id res_id = { .name = {0} };
1681         struct obd_device *obd = exp->exp_obd;
1682         struct lustre_handle lockh;
1683         ldlm_policy_data_t policy;
1684         int flags;
1685         ENTRY;
1686
1687         res_id.name[0] = id_fid(id);
1688         res_id.name[1] = id_group(id);
1689         policy.l_inodebits.bits = MDS_INODELOCK_UPDATE;
1690
1691         CDEBUG(D_INFO, "trying to match res "LPU64"\n",
1692                res_id.name[0]);
1693
1694         /* FIXME use LDLM_FL_TEST_LOCK instead */
1695         flags = LDLM_FL_BLOCK_GRANTED | LDLM_FL_CBPENDING;
1696         if (ldlm_lock_match(obd->obd_namespace, flags, &res_id,
1697                             LDLM_IBITS, &policy, LCK_PR, &lockh)) {
1698                 ldlm_lock_decref(&lockh, LCK_PR);
1699                 RETURN(1);
1700         }
1701
1702         if (ldlm_lock_match(obd->obd_namespace, flags, &res_id,
1703                             LDLM_IBITS, &policy, LCK_PW, &lockh)) {
1704                 ldlm_lock_decref(&lockh, LCK_PW);
1705                 RETURN(1);
1706         }
1707         RETURN(0);
1708 }
1709
1710 static int mdc_change_cbdata_name(struct obd_export *exp,
1711                                   struct lustre_id *pid,
1712                                   char *name, int len,
1713                                   struct lustre_id *cid,
1714                                   ldlm_iterator_t it, void *data)
1715 {
1716         int rc;
1717         rc = mdc_change_cbdata(exp, cid, it, data);
1718         RETURN(rc);
1719 }
1720
1721 struct obd_ops mdc_obd_ops = {
1722         .o_owner         = THIS_MODULE,
1723         .o_attach        = mdc_attach,
1724         .o_detach        = mdc_detach,
1725         .o_setup         = mdc_setup,
1726         .o_precleanup    = mdc_precleanup,
1727         .o_cleanup       = mdc_cleanup,
1728         .o_add_conn      = client_import_add_conn,
1729         .o_del_conn      = client_import_del_conn,
1730         .o_connect       = client_connect_import,
1731         .o_disconnect    = client_disconnect_export,
1732         .o_iocontrol     = mdc_iocontrol,
1733         .o_packmd        = mdc_packmd,
1734         .o_unpackmd      = mdc_unpackmd,
1735         .o_statfs        = mdc_statfs,
1736         .o_pin           = mdc_pin,
1737         .o_unpin         = mdc_unpin,
1738         .o_import_event  = mdc_import_event,
1739         .o_llog_init     = mdc_llog_init,
1740         .o_llog_finish   = mdc_llog_finish,
1741         .o_create        = mdc_obj_create,
1742         .o_set_info      = mdc_set_info,
1743         .o_get_info      = mdc_get_info,
1744         .o_brw           = mdc_brw,
1745         .o_cancel_unused = mdc_cancel_unused,
1746         .o_init_ea_size  = mdc_init_ea_size,
1747 };
1748
1749 struct md_ops mdc_md_ops = {
1750         .m_getstatus     = mdc_getstatus,
1751         .m_getattr       = mdc_getattr,
1752         .m_close         = mdc_close,
1753         .m_create        = mdc_create,
1754         .m_done_writing  = mdc_done_writing,
1755         .m_enqueue       = mdc_enqueue,
1756         .m_getattr_lock  = mdc_getattr_lock,
1757         .m_intent_lock   = mdc_intent_lock,
1758         .m_link          = mdc_link,
1759         .m_rename        = mdc_rename,
1760         .m_setattr       = mdc_setattr,
1761         .m_sync          = mdc_sync,
1762         .m_readpage      = mdc_readpage,
1763         .m_unlink        = mdc_unlink,
1764         .m_valid_attrs   = mdc_valid_attrs,
1765         .m_req2lustre_md = mdc_req2lustre_md,
1766         .m_set_open_replay_data   = mdc_set_open_replay_data,
1767         .m_clear_open_replay_data = mdc_clear_open_replay_data,
1768         .m_store_inode_generation = mdc_store_inode_generation,
1769         .m_set_lock_data = mdc_set_lock_data,
1770         .m_get_real_obd  = mdc_get_real_obd,
1771         .m_change_cbdata_name = mdc_change_cbdata_name,
1772         .m_change_cbdata = mdc_change_cbdata,
1773         .m_access_check  = mdc_access_check,
1774 };
1775
1776 int __init mdc_init(void)
1777 {
1778         struct lprocfs_static_vars lvars;
1779         
1780         lprocfs_init_vars(mdc, &lvars);
1781         return class_register_type(&mdc_obd_ops, &mdc_md_ops,
1782                                    lvars.module_vars, OBD_MDC_DEVICENAME);
1783 }
1784
1785 #ifdef __KERNEL__
1786 static void /*__exit*/ mdc_exit(void)
1787 {
1788         class_unregister_type(OBD_MDC_DEVICENAME);
1789 }
1790
1791 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
1792 MODULE_DESCRIPTION("Lustre Metadata Client");
1793 MODULE_LICENSE("GPL");
1794
1795 EXPORT_SYMBOL(mdc_req2lustre_md);
1796 EXPORT_SYMBOL(mdc_req2lustre_capa);
1797 EXPORT_SYMBOL(mdc_change_cbdata);
1798 EXPORT_SYMBOL(mdc_getstatus);
1799 EXPORT_SYMBOL(mdc_getattr);
1800 EXPORT_SYMBOL(mdc_getattr_lock);
1801 EXPORT_SYMBOL(mdc_create);
1802 EXPORT_SYMBOL(mdc_unlink);
1803 EXPORT_SYMBOL(mdc_rename);
1804 EXPORT_SYMBOL(mdc_link);
1805 EXPORT_SYMBOL(mdc_readpage);
1806 EXPORT_SYMBOL(mdc_setattr);
1807 EXPORT_SYMBOL(mdc_close);
1808 EXPORT_SYMBOL(mdc_done_writing);
1809 EXPORT_SYMBOL(mdc_sync);
1810 EXPORT_SYMBOL(mdc_set_open_replay_data);
1811 EXPORT_SYMBOL(mdc_clear_open_replay_data);
1812 EXPORT_SYMBOL(mdc_store_inode_generation);
1813
1814 module_init(mdc_init);
1815 module_exit(mdc_exit);
1816 #endif