Whamcloud - gitweb
- move the peter branch changes to the head
[fs/lustre-release.git] / lustre / mds / handler.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  linux/mds/handler.c
5  *
6  *  Lustre Metadata Server (mds) request handler
7  *
8  *  Copyright (C) 2001, 2002 Cluster File Systems, Inc.
9  *
10  *  This code is issued under the GNU General Public License.
11  *  See the file COPYING in this distribution
12  *
13  *  by Peter Braam <braam@clusterfs.com> &
14  *     Andreas Dilger <braam@clusterfs.com>
15  *
16  */
17
18 #define EXPORT_SYMTAB
19 #define DEBUG_SUBSYSTEM S_MDS
20
21 #include <linux/module.h>
22 #include <linux/lustre_mds.h>
23 #include <linux/lustre_dlm.h>
24 #include <linux/init.h>
25
26 extern int mds_get_lovtgts(struct obd_device *obd, int tgt_count,
27                            uuid_t *uuidarray);
28 extern int mds_get_lovdesc(struct obd_device *obd, struct lov_desc *desc);
29 extern int mds_update_last_rcvd(struct mds_obd *mds, void *handle,
30                                 struct ptlrpc_request *req);
31 static int mds_cleanup(struct obd_device * obddev);
32
33 inline struct mds_obd *mds_req2mds(struct ptlrpc_request *req)
34 {
35         return &req->rq_export->exp_obd->u.mds;
36 }
37
38
39 /* Assumes caller has already pushed into the kernel filesystem context */
40 static int mds_sendpage(struct ptlrpc_request *req, struct file *file,
41                         __u64 offset)
42 {
43         int rc = 0;
44         struct mds_obd *mds = mds_req2mds(req); 
45         struct ptlrpc_bulk_desc *desc;
46         struct ptlrpc_bulk_page *bulk;
47         char *buf;
48         ENTRY;
49
50         desc = ptlrpc_prep_bulk(req->rq_connection);
51         if (desc == NULL)
52                 GOTO(out, rc = -ENOMEM);
53
54         bulk = ptlrpc_prep_bulk_page(desc);
55         if (bulk == NULL)
56                 GOTO(cleanup_bulk, rc = -ENOMEM);
57
58         OBD_ALLOC(buf, PAGE_SIZE);
59         if (buf == NULL)
60                 GOTO(cleanup_bulk, rc = -ENOMEM);
61
62         rc = mds_fs_readpage(mds, file, buf, PAGE_SIZE, (loff_t *)&offset);
63
64         if (rc != PAGE_SIZE)
65                 GOTO(cleanup_buf, rc = -EIO);
66
67         bulk->b_xid = req->rq_xid;
68         bulk->b_buf = buf;
69         bulk->b_buflen = PAGE_SIZE;
70         desc->b_portal = MDS_BULK_PORTAL;
71
72         rc = ptlrpc_send_bulk(desc);
73         if (rc)
74                 GOTO(cleanup_buf, rc);
75
76         if (OBD_FAIL_CHECK(OBD_FAIL_MDS_SENDPAGE)) {
77                 CERROR("obd_fail_loc=%x, fail operation rc=%d\n",
78                        OBD_FAIL_MDS_SENDPAGE, rc);
79                 ptlrpc_abort_bulk(desc);
80                 GOTO(cleanup_buf, rc);
81         }
82
83         wait_event(desc->b_waitq, ptlrpc_check_bulk_sent(desc));
84         if (desc->b_flags & PTL_RPC_FL_INTR)
85                 GOTO(cleanup_buf, rc = -EINTR);
86
87         EXIT;
88  cleanup_buf:
89         OBD_FREE(buf, PAGE_SIZE);
90  cleanup_bulk:
91         ptlrpc_free_bulk(desc);
92  out:
93         return rc;
94 }
95
96 /* 'dir' is a inode for which a lock has already been taken */
97 struct dentry *mds_name2locked_dentry(struct obd_device *obd, struct dentry *dir,
98                                       struct vfsmount **mnt, char *name,
99                                       int namelen, int lock_mode,
100                                       struct lustre_handle *lockh,
101                                       int dir_lock_mode)
102 {
103         struct dentry *dchild;
104         int flags, rc;
105         __u64 res_id[3] = {0};
106         ENTRY;
107
108         down(&dir->d_inode->i_sem);
109         dchild = lookup_one_len(name, dir, namelen);
110         if (IS_ERR(dchild)) {
111                 CERROR("child lookup error %ld\n", PTR_ERR(dchild));
112                 up(&dir->d_inode->i_sem);
113                 LBUG();
114                 RETURN(dchild);
115         }
116         if (dir_lock_mode != LCK_EX && dir_lock_mode != LCK_PW) {
117                 up(&dir->d_inode->i_sem);
118                 ldlm_lock_decref(lockh, dir_lock_mode);
119         }
120
121         if (lock_mode == 0 || !dchild->d_inode)
122                 RETURN(dchild);
123
124         res_id[0] = dchild->d_inode->i_ino;
125         rc = ldlm_match_or_enqueue(NULL, NULL, obd->obd_namespace, NULL,
126                                    res_id, LDLM_PLAIN, NULL, 0, lock_mode,
127                                    &flags, ldlm_completion_ast, (void *)mds_lock_callback, NULL,
128                                    0, lockh);
129         if (rc != ELDLM_OK) {
130                 l_dput(dchild);
131                 up(&dir->d_inode->i_sem);
132                 RETURN(ERR_PTR(-ENOLCK)); /* XXX translate ldlm code */
133         }
134
135         RETURN(dchild);
136 }
137
138 struct dentry *mds_fid2locked_dentry(struct obd_device *obd, struct ll_fid *fid,
139                                      struct vfsmount **mnt, int lock_mode,
140                                      struct lustre_handle *lockh)
141 {
142         struct mds_obd *mds = &obd->u.mds;
143         struct dentry *de = mds_fid2dentry(mds, fid, mnt), *retval = de;
144         int flags, rc;
145         __u64 res_id[3] = {0};
146         ENTRY;
147
148         if (IS_ERR(de))
149                 RETURN(de);
150
151         res_id[0] = de->d_inode->i_ino;
152         rc = ldlm_match_or_enqueue(NULL, NULL, obd->obd_namespace, NULL,
153                                    res_id, LDLM_PLAIN, NULL, 0, lock_mode,
154                                    &flags, ldlm_completion_ast, (void *)mds_lock_callback, NULL,
155                                    0, lockh);
156         if (rc != ELDLM_OK) {
157                 l_dput(de);
158                 retval = ERR_PTR(-ENOLCK); /* XXX translate ldlm code */
159         }
160
161         RETURN(retval);
162 }
163
164 struct dentry *mds_fid2dentry(struct mds_obd *mds, struct ll_fid *fid,
165                               struct vfsmount **mnt)
166 {
167         /* stolen from NFS */
168         struct super_block *sb = mds->mds_sb;
169         unsigned long ino = fid->id;
170         __u32 generation = fid->generation;
171         struct inode *inode;
172         struct list_head *lp;
173         struct dentry *result;
174
175         if (ino == 0)
176                 RETURN(ERR_PTR(-ESTALE));
177
178         inode = iget(sb, ino);
179         if (inode == NULL)
180                 RETURN(ERR_PTR(-ENOMEM));
181
182         CDEBUG(D_DENTRY, "--> mds_fid2dentry: sb %p\n", inode->i_sb);
183
184         if (is_bad_inode(inode) ||
185             (generation && inode->i_generation != generation)) {
186                 /* we didn't find the right inode.. */
187                 CERROR("bad inode %lu, link: %d ct: %d or version  %u/%u\n",
188                        inode->i_ino, inode->i_nlink,
189                        atomic_read(&inode->i_count), inode->i_generation,
190                        generation);
191                 LBUG();
192                 iput(inode);
193                 RETURN(ERR_PTR(-ESTALE));
194         }
195
196         /* now to find a dentry. If possible, get a well-connected one */
197         if (mnt)
198                 *mnt = mds->mds_vfsmnt;
199         spin_lock(&dcache_lock);
200         for (lp = inode->i_dentry.next; lp != &inode->i_dentry ; lp=lp->next) {
201                 result = list_entry(lp,struct dentry, d_alias);
202                 if (! (result->d_flags & DCACHE_NFSD_DISCONNECTED)) {
203                         dget_locked(result);
204                         result->d_vfs_flags |= DCACHE_REFERENCED;
205                         spin_unlock(&dcache_lock);
206                         iput(inode);
207                         if (mnt)
208                                 mntget(*mnt);
209                         return result;
210                 }
211         }
212         spin_unlock(&dcache_lock);
213         result = d_alloc_root(inode);
214         if (result == NULL) {
215                 iput(inode);
216                 return ERR_PTR(-ENOMEM);
217         }
218         if (mnt)
219                 mntget(*mnt);
220         result->d_flags |= DCACHE_NFSD_DISCONNECTED;
221         return result;
222 }
223
224 static int mds_connect(struct lustre_handle *conn, struct obd_device *obd)
225 {
226         int rc;
227
228         MOD_INC_USE_COUNT;
229         rc = class_connect(conn, obd);
230
231         if (rc)
232                 MOD_DEC_USE_COUNT;
233
234         return rc;
235 }
236
237 static int mds_disconnect(struct lustre_handle *conn)
238 {
239         int rc;
240
241         rc = class_disconnect(conn);
242         if (!rc)
243                 MOD_DEC_USE_COUNT;
244
245         return rc;
246 }
247
248 /* FIXME: the error cases need fixing to avoid leaks */
249 static int mds_getstatus(struct ptlrpc_request *req)
250 {
251         struct mds_obd *mds = mds_req2mds(req);
252         struct mds_body *body;
253         struct mds_client_info *mci;
254         struct mds_client_data *mcd;
255         int rc, size = sizeof(*body);
256         ENTRY;
257
258         rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen, &req->rq_repmsg);
259         if (rc || OBD_FAIL_CHECK(OBD_FAIL_MDS_GETSTATUS_PACK)) {
260                 CERROR("mds: out of memory for message: size=%d\n", size);
261                 req->rq_status = -ENOMEM;
262                 RETURN(0);
263         }
264
265         body = lustre_msg_buf(req->rq_reqmsg, 0);
266         mds_unpack_body(body);
267
268         /* Anything we need to do here with the client's trans no or so? */
269         body = lustre_msg_buf(req->rq_repmsg, 0);
270         memcpy(&body->fid1, &mds->mds_rootfid, sizeof(body->fid1));
271
272         mci = mds_uuid_to_mci(mds, ptlrpc_req_to_uuid(req));
273         if (!mci) {
274                 /* We don't have any old connection data for this client */
275                 int rc;
276
277                 CDEBUG(D_INFO, "allocating new client data for UUID '%s'",
278                        ptlrpc_req_to_uuid(req));
279
280                 OBD_ALLOC(mcd, sizeof(*mcd));
281                 if (!mcd) {
282                         CERROR("mds: out of memory for client data\n");
283                         req->rq_status = -ENOMEM;
284                         RETURN(0);
285                 }
286                 memcpy(mcd->mcd_uuid, ptlrpc_req_to_uuid(req),
287                        sizeof(mcd->mcd_uuid));
288                 rc = mds_client_add(mds, mcd, -1);
289                 if (rc) {
290                         req->rq_status = rc;
291                         RETURN(0);
292                 }
293         } else {
294                 /* We have old connection data for this client... */
295                 mcd = mci->mci_mcd;
296                 CDEBUG(D_INFO, "found existing data for UUID '%s' at #%d\n",
297                        mcd->mcd_uuid, mci->mci_off);
298         }
299         /* mcd_last_xid is is stored in little endian on the disk and
300            mds_pack_rep_body converts it to network order */
301         body->last_xid = le32_to_cpu(mcd->mcd_last_xid);
302         mds_pack_rep_body(req);
303         RETURN(0);
304 }
305
306 static int mds_getlovinfo(struct ptlrpc_request *req)
307 {
308         struct mds_obd *mds = mds_req2mds(req);
309         struct mds_status_req *streq;
310         struct lov_desc *desc; 
311         int tgt_count;
312         int rc, size[2] = {sizeof(*desc)};
313         ENTRY;
314
315         streq = lustre_msg_buf(req->rq_reqmsg, 0); 
316         streq->flags = NTOH__u32(streq->flags); 
317         streq->repbuf = NTOH__u32(streq->repbuf); 
318         size[1] = streq->repbuf;
319
320         rc = lustre_pack_msg(2, size, NULL, &req->rq_replen, &req->rq_repmsg);
321         if (rc) { 
322                 CERROR("mds: out of memory for message: size=%d\n", size[1]);
323                 req->rq_status = -ENOMEM;
324                 RETURN(0);
325         }
326
327         desc = lustre_msg_buf(req->rq_repmsg, 0); 
328         rc = mds_get_lovdesc(req->rq_obd, desc);
329         if (rc != 0 ) { 
330                 CERROR("mds_get_lovdesc error %d", rc);
331                 req->rq_status = rc;
332                 RETURN(0);
333         }
334
335         tgt_count = NTOH__u32(desc->ld_tgt_count);
336         if (tgt_count * sizeof(uuid_t) > streq->repbuf) {
337                 CERROR("too many targets, enlarge client buffers\n");
338                 req->rq_status = -ENOSPC;
339                 RETURN(0);
340         }
341
342         mds->mds_max_mdsize = sizeof(desc) + tgt_count * sizeof(uuid_t);
343         rc = mds_get_lovtgts(req->rq_obd, tgt_count,
344                              lustre_msg_buf(req->rq_repmsg, 1));
345         if (rc) {
346                 CERROR("get_lovtgts error %d\n", rc);
347                 req->rq_status = rc;
348                 RETURN(0);
349         }
350         RETURN(0);
351 }
352
353 int mds_lock_callback(struct lustre_handle *lockh, struct ldlm_lock_desc *desc,
354                       void *data, int data_len, struct ptlrpc_request **reqp)
355 {
356         ENTRY;
357
358         if (desc == NULL) {
359                 /* Completion AST.  Do nothing */
360                 RETURN(0);
361         }
362
363         if (ldlm_cli_cancel(lockh) < 0)
364                 LBUG();
365         RETURN(0);
366 }
367
368 static int mds_getattr_name(int offset, struct ptlrpc_request *req)
369 {
370         struct mds_obd *mds = mds_req2mds(req);
371         struct obd_device *obd = req->rq_export->exp_obd;
372         struct obd_run_ctxt saved;
373         struct mds_body *body;
374         struct dentry *de = NULL, *dchild = NULL;
375         struct inode *dir;
376         struct lustre_handle lockh;
377         char *name;
378         int namelen, flags, lock_mode, rc = 0;
379         __u64 res_id[3] = {0, 0, 0};
380         ENTRY;
381
382         if (strcmp(req->rq_export->exp_obd->obd_type->typ_name, "mds") != 0)
383                 LBUG();
384
385         if (req->rq_reqmsg->bufcount <= offset + 1) {
386                 LBUG();
387                 GOTO(out_pre_de, rc = -EINVAL);
388         }
389
390         body = lustre_msg_buf(req->rq_reqmsg, offset);
391         name = lustre_msg_buf(req->rq_reqmsg, offset + 1);
392         namelen = req->rq_reqmsg->buflens[offset + 1];
393         /* requests were at offset 2, replies go back at 1 */
394         if (offset)
395                 offset = 1;
396
397         push_ctxt(&saved, &mds->mds_ctxt);
398         de = mds_fid2dentry(mds, &body->fid1, NULL);
399         if (IS_ERR(de)) {
400                 LBUG();
401                 GOTO(out_pre_de, rc = -ESTALE);
402         }
403
404         dir = de->d_inode;
405         CDEBUG(D_INODE, "parent ino %ld\n", dir->i_ino);
406
407         lock_mode = (req->rq_reqmsg->opc == MDS_REINT) ? LCK_CW : LCK_PW;
408         res_id[0] = dir->i_ino;
409
410         rc = ldlm_lock_match(obd->obd_namespace, res_id, LDLM_PLAIN,
411                              NULL, 0, lock_mode, &lockh);
412         if (rc == 0) {
413                 LDLM_DEBUG_NOLOCK("enqueue res %Lu", res_id[0]);
414                 rc = ldlm_cli_enqueue(NULL, NULL, obd->obd_namespace, NULL,
415                                       res_id, LDLM_PLAIN, NULL, 0, lock_mode,
416                                       &flags, ldlm_completion_ast, (void *)mds_lock_callback,
417                                       NULL, 0, &lockh);
418                 if (rc != ELDLM_OK) {
419                         CERROR("lock enqueue: err: %d\n", rc);
420                         GOTO(out_create_de, rc = -EIO);
421                 }
422         }
423         ldlm_lock_dump((void *)(unsigned long)lockh.addr);
424
425         down(&dir->i_sem);
426         dchild = lookup_one_len(name, de, namelen - 1);
427         if (IS_ERR(dchild)) {
428                 CDEBUG(D_INODE, "child lookup error %ld\n", PTR_ERR(dchild));
429                 up(&dir->i_sem);
430                 LBUG();
431                 GOTO(out_create_dchild, rc = -ESTALE);
432         }
433
434         if (dchild->d_inode) {
435                 struct mds_body *body;
436                 struct inode *inode = dchild->d_inode;
437                 CDEBUG(D_INODE, "child exists (dir %ld, name %s, ino %ld)\n",
438                        dir->i_ino, name, dchild->d_inode->i_ino);
439
440                 body = lustre_msg_buf(req->rq_repmsg, offset);
441                 mds_pack_inode2fid(&body->fid1, inode);
442                 mds_pack_inode2body(body, inode);
443                 if (S_ISREG(inode->i_mode)) {
444                         struct lov_stripe_md *md;
445                         md = lustre_msg_buf(req->rq_repmsg, offset + 1);
446                         md->lmd_easize = mds->mds_max_mdsize;
447                         mds_fs_get_md(mds, inode, md);
448                 }
449                 /* now a normal case for intent locking */
450                 rc = 0;
451         } else
452                 rc = -ENOENT;
453
454         EXIT;
455 out_create_dchild:
456         l_dput(dchild);
457         up(&dir->i_sem);
458         ldlm_lock_decref(&lockh, lock_mode);
459 out_create_de:
460         l_dput(de);
461 out_pre_de:
462         req->rq_status = rc;
463         pop_ctxt(&saved);
464         return 0;
465 }
466
467
468 static int mds_getattr(int offset, struct ptlrpc_request *req)
469 {
470         struct mds_obd *mds = mds_req2mds(req);
471         struct obd_run_ctxt saved;
472         struct dentry *de;
473         struct inode *inode;
474         struct mds_body *body;
475         int rc, size[2] = {sizeof(*body)}, bufcount = 1;
476         ENTRY;
477
478         body = lustre_msg_buf(req->rq_reqmsg, offset);
479         push_ctxt(&saved, &mds->mds_ctxt);
480         de = mds_fid2dentry(mds, &body->fid1, NULL);
481         if (IS_ERR(de)) {
482                 GOTO(out_pop, rc = -ENOENT);
483         }
484
485         inode = de->d_inode;
486         if (S_ISREG(body->fid1.f_type)) {
487                 bufcount = 2;
488                 size[1] = mds->mds_max_mdsize;
489         } else if (body->valid & OBD_MD_LINKNAME) {
490                 bufcount = 2;
491                 size[1] = inode->i_size;
492         }
493
494         rc = lustre_pack_msg(bufcount, size, NULL, &req->rq_replen,
495                              &req->rq_repmsg);
496         if (rc || OBD_FAIL_CHECK(OBD_FAIL_MDS_GETATTR_PACK)) {
497                 CERROR("mds: out of memory\n");
498                 GOTO(out, rc);
499         }
500
501         if (body->valid & OBD_MD_LINKNAME) {
502                 char *tmp = lustre_msg_buf(req->rq_repmsg, 1);
503
504                 rc = inode->i_op->readlink(de, tmp, size[1]);
505
506                 if (rc < 0) {
507                         CERROR("readlink failed: %d\n", rc);
508                         GOTO(out, rc);
509                 }
510         }
511
512         body = lustre_msg_buf(req->rq_repmsg, 0);
513         body->ino = inode->i_ino;
514         body->generation = inode->i_generation;
515         body->atime = inode->i_atime;
516         body->ctime = inode->i_ctime;
517         body->mtime = inode->i_mtime;
518         body->uid = inode->i_uid;
519         body->gid = inode->i_gid;
520         body->size = inode->i_size;
521         body->mode = inode->i_mode;
522         body->nlink = inode->i_nlink;
523         body->valid = ~0; /* FIXME: should be more selective */
524
525         if (S_ISREG(inode->i_mode)) {
526                 rc = mds_fs_get_md(mds, inode,
527                                      lustre_msg_buf(req->rq_repmsg, 1));
528                 if (rc < 0) {
529                         CERROR("mds_fs_get_md failed: %d\n", rc);
530                         GOTO(out, rc);
531                 }
532         }
533 out:
534         l_dput(de);
535 out_pop:
536         pop_ctxt(&saved);
537         req->rq_status = rc;
538         RETURN(0);
539 }
540
541 static int mds_statfs(struct ptlrpc_request *req)
542 {
543         struct mds_obd *mds = mds_req2mds(req);
544         struct obd_statfs *osfs;
545         struct statfs sfs;
546         int rc, size = sizeof(*osfs);
547         ENTRY;
548
549         rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen,
550                              &req->rq_repmsg);
551         if (rc || OBD_FAIL_CHECK(OBD_FAIL_MDS_STATFS_PACK)) {
552                 CERROR("mds: statfs lustre_pack_msg failed: rc = %d\n", rc);
553                 GOTO(out, rc);
554         }
555
556         rc = vfs_statfs(mds->mds_sb, &sfs);
557         if (rc) {
558                 CERROR("mds: statfs failed: rc %d\n", rc);
559                 GOTO(out, rc);
560         }
561         osfs = lustre_msg_buf(req->rq_repmsg, 0);
562         memset(osfs, 0, size);
563         obd_statfs_pack(osfs, &sfs);
564
565 out:
566         req->rq_status = rc;
567         RETURN(0);
568 }
569
570 static int mds_open(struct ptlrpc_request *req)
571 {
572         struct dentry *de;
573         struct mds_body *body;
574         struct file *file;
575         struct vfsmount *mnt;
576         struct mds_obd *mds = mds_req2mds(req);
577         struct mds_client_info *mci;
578         __u32 flags;
579         struct list_head *tmp;
580         struct mds_file_data *mfd;
581         int rc, size = sizeof(*body);
582         ENTRY;
583
584         rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen, &req->rq_repmsg);
585         if (rc || OBD_FAIL_CHECK(OBD_FAIL_MDS_OPEN_PACK)) {
586                 CERROR("mds: out of memory\n");
587                 req->rq_status = -ENOMEM;
588                 RETURN(0);
589         }
590
591         mci = mds_uuid_to_mci(mds, ptlrpc_req_to_uuid(req));
592         if (!mci) {
593                 CERROR("mds: no mci!\n");
594                 req->rq_status = -ENOTCONN;
595                 RETURN(0);
596         }
597
598         body = lustre_msg_buf(req->rq_reqmsg, 0);
599
600         /* was this animal open already? */
601         /* XXX we should only check on re-open, or do a refcount... */
602         list_for_each(tmp, &mci->mci_open_head) {
603                 struct mds_file_data *fd;
604                 fd = list_entry(tmp, struct mds_file_data, mfd_list);
605                 if (body->extra == fd->mfd_clientfd &&
606                     body->fid1.id == fd->mfd_file->f_dentry->d_inode->i_ino) {
607                         CERROR("Re opening %Ld\n", body->fid1.id);
608                         RETURN(0);
609                 }
610         }
611
612         OBD_ALLOC(mfd, sizeof(*mfd));
613         if (!mfd) {
614                 CERROR("mds: out of memory\n");
615                 req->rq_status = -ENOMEM;
616                 RETURN(0);
617         }
618
619         de = mds_fid2dentry(mds, &body->fid1, &mnt);
620         if (IS_ERR(de)) {
621                 req->rq_status = -ENOENT;
622                 RETURN(0);
623         }
624
625         /* check if this inode has seen a delayed object creation */
626         if (req->rq_reqmsg->bufcount > 1) {
627                 void *handle;
628                 struct lov_stripe_md *md;
629                 struct inode *inode = de->d_inode;
630                 int rc;
631
632                 md = lustre_msg_buf(req->rq_reqmsg, 1);
633
634                 handle = mds_fs_start(mds, de->d_inode, MDS_FSOP_SETATTR);
635                 if (!handle) {
636                         req->rq_status = -ENOMEM;
637                         RETURN(0);
638                 }
639
640                 /* XXX error handling */
641                 rc = mds_fs_set_md(mds, inode, handle, md);
642                 if (!rc) {
643                         struct obd_run_ctxt saved;
644                         push_ctxt(&saved, &mds->mds_ctxt);
645                         rc = mds_update_last_rcvd(mds, handle, req);
646                         pop_ctxt(&saved);
647                 } else {
648                         req->rq_status = rc;
649                         RETURN(0);
650                 }
651                 /* FIXME: need to return last_rcvd, last_committed */
652
653                 /* FIXME: keep rc intact */
654                 rc = mds_fs_commit(mds, de->d_inode, handle);
655                 if (rc) {
656                         req->rq_status = rc;
657                         RETURN(0);
658                 }
659         }
660
661         flags = body->flags;
662         file = dentry_open(de, mnt, flags & ~O_DIRECT);
663         if (!file || IS_ERR(file)) {
664                 req->rq_status = -EINVAL;
665                 OBD_FREE(mfd, sizeof(*mfd));
666                 RETURN(0);
667         }
668
669         file->private_data = mfd;
670         mfd->mfd_file = file;
671         mfd->mfd_clientfd = body->extra;
672         list_add(&mfd->mfd_list, &mci->mci_open_head);
673
674         body = lustre_msg_buf(req->rq_repmsg, 0);
675         body->extra = (__u64) (unsigned long)file;
676         RETURN(0);
677 }
678
679 static int mds_close(struct ptlrpc_request *req)
680 {
681         struct dentry *de;
682         struct mds_body *body;
683         struct file *file;
684         struct mds_obd *mds = mds_req2mds(req);
685         struct vfsmount *mnt;
686         struct mds_file_data *mfd;
687         int rc;
688         ENTRY;
689
690         rc = lustre_pack_msg(0, NULL, NULL, &req->rq_replen, &req->rq_repmsg);
691         if (rc || OBD_FAIL_CHECK(OBD_FAIL_MDS_CLOSE_PACK)) {
692                 CERROR("mds: out of memory\n");
693                 req->rq_status = -ENOMEM;
694                 RETURN(0);
695         }
696
697         body = lustre_msg_buf(req->rq_reqmsg, 0);
698         de = mds_fid2dentry(mds, &body->fid1, &mnt);
699         if (IS_ERR(de)) {
700                 req->rq_status = -ENOENT;
701                 RETURN(0);
702         }
703
704         file = (struct file *)(unsigned long)body->extra;
705         if (!file->f_dentry)
706                 LBUG();
707         mfd = (struct mds_file_data *)file->private_data;
708         list_del(&mfd->mfd_list);
709         OBD_FREE(mfd, sizeof(*mfd));
710
711         req->rq_status = filp_close(file, 0);
712         l_dput(de);
713         mntput(mnt);
714
715         RETURN(0);
716 }
717
718 static int mds_readpage(struct ptlrpc_request *req)
719 {
720         struct mds_obd *mds = mds_req2mds(req);
721         struct vfsmount *mnt;
722         struct dentry *de;
723         struct file *file;
724         struct mds_body *body;
725         struct obd_run_ctxt saved;
726         int rc, size = sizeof(*body);
727         ENTRY;
728
729         rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen, &req->rq_repmsg);
730         if (rc || OBD_FAIL_CHECK(OBD_FAIL_MDS_READPAGE_PACK)) {
731                 CERROR("mds: out of memory\n");
732                 GOTO(out, rc = -ENOMEM);
733         }
734
735         body = lustre_msg_buf(req->rq_reqmsg, 0);
736         push_ctxt(&saved, &mds->mds_ctxt);
737         de = mds_fid2dentry(mds, &body->fid1, &mnt);
738         if (IS_ERR(de))
739                 GOTO(out_pop, rc = PTR_ERR(de));
740
741         CDEBUG(D_INODE, "ino %ld\n", de->d_inode->i_ino);
742
743         file = dentry_open(de, mnt, O_RDONLY | O_LARGEFILE);
744         /* note: in case of an error, dentry_open puts dentry */
745         if (IS_ERR(file))
746                 GOTO(out_pop, rc = PTR_ERR(file));
747
748         /* to make this asynchronous make sure that the handling function
749            doesn't send a reply when this function completes. Instead a
750            callback function would send the reply */
751         rc = mds_sendpage(req, file, body->size);
752
753         filp_close(file, 0);
754 out_pop:
755         pop_ctxt(&saved);
756 out:
757         req->rq_status = rc;
758         RETURN(0);
759 }
760
761 int mds_reint(int offset, struct ptlrpc_request *req)
762 {
763         int rc;
764         struct mds_update_record rec;
765
766         rc = mds_update_unpack(req, offset, &rec);
767         if (rc || OBD_FAIL_CHECK(OBD_FAIL_MDS_REINT_UNPACK)) {
768                 CERROR("invalid record\n");
769                 req->rq_status = -EINVAL;
770                 RETURN(0);
771         }
772         /* rc will be used to interrupt a for loop over multiple records */
773         rc = mds_reint_rec(&rec, offset, req);
774         return rc;
775 }
776
777 int mds_handle(struct ptlrpc_request *req)
778 {
779         int rc;
780         ENTRY;
781
782         rc = lustre_unpack_msg(req->rq_reqmsg, req->rq_reqlen);
783         if (rc || OBD_FAIL_CHECK(OBD_FAIL_MDS_HANDLE_UNPACK)) {
784                 CERROR("lustre_mds: Invalid request\n");
785                 GOTO(out, rc);
786         }
787
788         if (req->rq_reqmsg->type != PTL_RPC_MSG_REQUEST) {
789                 CERROR("lustre_mds: wrong packet type sent %d\n",
790                        req->rq_reqmsg->type);
791                 GOTO(out, rc = -EINVAL);
792         }
793
794         if (req->rq_reqmsg->opc != MDS_CONNECT &&
795             req->rq_export == NULL)
796                 GOTO(out, rc = -ENOTCONN);
797
798         if (strcmp(req->rq_obd->obd_type->typ_name, "mds") != 0)
799                 GOTO(out, rc = -EINVAL);
800
801         switch (req->rq_reqmsg->opc) {
802         case MDS_CONNECT:
803                 CDEBUG(D_INODE, "connect\n");
804                 OBD_FAIL_RETURN(OBD_FAIL_MDS_CONNECT_NET, 0);
805                 rc = target_handle_connect(req);
806                 break;
807
808         case MDS_DISCONNECT:
809                 CDEBUG(D_INODE, "disconnect\n");
810                 OBD_FAIL_RETURN(OBD_FAIL_MDS_DISCONNECT_NET, 0);
811                 rc = target_handle_disconnect(req);
812                 goto out;
813
814         case MDS_GETSTATUS:
815                 CDEBUG(D_INODE, "getstatus\n");
816                 OBD_FAIL_RETURN(OBD_FAIL_MDS_GETSTATUS_NET, 0);
817                 rc = mds_getstatus(req);
818                 break;
819
820         case MDS_GETLOVINFO:
821                 CDEBUG(D_INODE, "getlovinfo\n");
822                 rc = mds_getlovinfo(req);
823                 break;
824
825         case MDS_GETATTR:
826                 CDEBUG(D_INODE, "getattr\n");
827                 OBD_FAIL_RETURN(OBD_FAIL_MDS_GETATTR_NET, 0);
828                 rc = mds_getattr(0, req);
829                 break;
830
831         case MDS_STATFS:
832                 CDEBUG(D_INODE, "statfs\n");
833                 OBD_FAIL_RETURN(OBD_FAIL_MDS_STATFS_NET, 0);
834                 rc = mds_statfs(req);
835                 break;
836
837         case MDS_READPAGE:
838                 CDEBUG(D_INODE, "readpage\n");
839                 OBD_FAIL_RETURN(OBD_FAIL_MDS_READPAGE_NET, 0);
840                 rc = mds_readpage(req);
841
842                 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_SENDPAGE))
843                         return 0;
844                 break;
845
846         case MDS_REINT: {
847                 int size = sizeof(struct mds_body);
848                 CDEBUG(D_INODE, "reint\n");
849                 OBD_FAIL_RETURN(OBD_FAIL_MDS_REINT_NET, 0);
850
851                 rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen,
852                                      &req->rq_repmsg);
853                 if (rc) {
854                         rc = req->rq_status = -ENOMEM;
855                         break;
856                 }
857                 rc = mds_reint(0, req);
858                 OBD_FAIL_RETURN(OBD_FAIL_MDS_REINT_NET_REP, 0);
859                 break;
860         }
861
862         case MDS_OPEN:
863                 CDEBUG(D_INODE, "open\n");
864                 OBD_FAIL_RETURN(OBD_FAIL_MDS_OPEN_NET, 0);
865                 rc = mds_open(req);
866                 break;
867
868         case MDS_CLOSE:
869                 CDEBUG(D_INODE, "close\n");
870                 OBD_FAIL_RETURN(OBD_FAIL_MDS_CLOSE_NET, 0);
871                 rc = mds_close(req);
872                 break;
873
874         case LDLM_ENQUEUE:
875                 CDEBUG(D_INODE, "enqueue\n");
876                 OBD_FAIL_RETURN(OBD_FAIL_LDLM_ENQUEUE, 0);
877                 rc = ldlm_handle_enqueue(req);
878                 if (rc)
879                         break;
880                 RETURN(0);
881
882         case LDLM_CONVERT:
883                 CDEBUG(D_INODE, "convert\n");
884                 OBD_FAIL_RETURN(OBD_FAIL_LDLM_CONVERT, 0);
885                 rc = ldlm_handle_convert(req);
886                 if (rc)
887                         break;
888                 RETURN(0);
889
890         case LDLM_CANCEL:
891                 CDEBUG(D_INODE, "cancel\n");
892                 OBD_FAIL_RETURN(OBD_FAIL_LDLM_CANCEL, 0);
893                 rc = ldlm_handle_cancel(req);
894                 if (rc)
895                         break;
896                 RETURN(0);
897         case LDLM_CALLBACK:
898                 CDEBUG(D_INODE, "callback\n");
899                 CERROR("callbacks should not happen on MDS\n");
900                 LBUG();
901                 OBD_FAIL_RETURN(OBD_FAIL_LDLM_CALLBACK, 0);
902                 break;
903
904
905         default:
906                 rc = ptlrpc_error(req->rq_svc, req);
907                 RETURN(rc);
908         }
909
910         EXIT;
911
912         if (!rc) { 
913                 struct mds_obd *mds = mds_req2mds(req);
914                 req->rq_repmsg->last_rcvd = HTON__u64(mds->mds_last_rcvd);
915                 req->rq_repmsg->last_committed =
916                         HTON__u64(mds->mds_last_committed);
917                 CDEBUG(D_INFO, "last_rcvd %Lu, last_committed %Lu, xid %d\n",
918                        (unsigned long long)mds->mds_last_rcvd,
919                        (unsigned long long)mds->mds_last_committed,
920                        cpu_to_le32(req->rq_xid));
921         }
922  out:
923         /* Still not 100% sure whether we should reply with the server
924          * last_rcvd or that of this client.  I'm not sure it even makes
925          * a difference on a per-client basis, because last_rcvd is global
926          * and we are not supposed to allow transactions while in recovery.
927          */
928         if (rc) {
929                 CERROR("mds: processing error %d\n", rc);
930                 ptlrpc_error(req->rq_svc, req);
931         } else {
932                 CDEBUG(D_NET, "sending reply\n");
933                 ptlrpc_reply(req->rq_svc, req);
934         }
935         return 0;
936 }
937
938 /* Update the server data on disk.  This stores the new mount_count and
939  * also the last_rcvd value to disk.  If we don't have a clean shutdown,
940  * then the server last_rcvd value may be less than that of the clients.
941  * This will alert us that we may need to do client recovery.
942  */
943 static
944 int mds_update_server_data(struct mds_obd *mds)
945 {
946         struct obd_run_ctxt saved;
947         struct mds_server_data *msd = mds->mds_server_data;
948         struct file *filp = mds->mds_rcvd_filp;
949         loff_t off = 0;
950         int rc;
951
952         msd->msd_last_rcvd = cpu_to_le64(mds->mds_last_rcvd);
953         msd->msd_mount_count = cpu_to_le64(mds->mds_mount_count);
954
955         CDEBUG(D_SUPER, "MDS mount_count is %Lu, last_rcvd is %Lu\n",
956                (unsigned long long)mds->mds_mount_count,
957                (unsigned long long)mds->mds_last_rcvd);
958         push_ctxt(&saved, &mds->mds_ctxt);
959         rc = lustre_fwrite(filp, (char *)msd, sizeof(*msd), &off);
960         if (rc != sizeof(*msd)) {
961                 CERROR("error writing MDS server data: rc = %d\n", rc);
962                 if (rc > 0)
963                         RETURN(-EIO);
964                 RETURN(rc);
965         }
966         rc = fsync_dev(filp->f_dentry->d_inode->i_rdev);
967         pop_ctxt(&saved);
968         if (rc)
969                 CERROR("error flushing MDS server data: rc = %d\n", rc);
970
971         return 0;
972 }
973
974 /* Do recovery actions for the MDS */
975 static int mds_recover(struct obd_device *obddev)
976 {
977         struct mds_obd *mds = &obddev->u.mds;
978         int rc;
979
980         /* This happens at the end when recovery is complete */
981         ++mds->mds_mount_count;
982         rc = mds_update_server_data(mds);
983
984         return rc;
985 }
986
987 #define MDS_NUM_THREADS 8
988 /* mount the file system (secretly) */
989 static int mds_setup(struct obd_device *obddev, obd_count len, void *buf)
990 {
991         int i;
992         struct obd_ioctl_data* data = buf;
993         struct mds_obd *mds = &obddev->u.mds;
994         struct vfsmount *mnt;
995         int rc = 0;
996         ENTRY;
997
998         MOD_INC_USE_COUNT;
999 #ifdef CONFIG_DEV_RDONLY
1000         dev_clear_rdonly(2);
1001 #endif
1002         if (!data->ioc_inlbuf1 || !data->ioc_inlbuf2)
1003                 GOTO(err_dec, rc = -EINVAL);
1004
1005         mds->mds_fstype = strdup(data->ioc_inlbuf2);
1006
1007         mnt = do_kern_mount(mds->mds_fstype, 0, data->ioc_inlbuf1, NULL);
1008         if (IS_ERR(mnt)) {
1009                 rc = PTR_ERR(mnt);
1010                 CERROR("do_kern_mount failed: rc = %d\n", rc);
1011                 GOTO(err_kfree, rc);
1012         }
1013
1014         mds->mds_sb = mnt->mnt_root->d_inode->i_sb;
1015         if (!mds->mds_sb)
1016                 GOTO(err_put, rc = -ENODEV);
1017
1018         mds->mds_max_mdsize = sizeof(struct lov_stripe_md);
1019         rc = mds_fs_setup(mds, mnt);
1020         if (rc) {
1021                 CERROR("MDS filesystem method init failed: rc = %d\n", rc);
1022                 GOTO(err_put, rc);
1023         }
1024
1025         mds->mds_service = ptlrpc_init_svc(64 * 1024, MDS_REQUEST_PORTAL,
1026                                            MDC_REPLY_PORTAL, "self",mds_handle);
1027         if (!mds->mds_service) {
1028                 CERROR("failed to start service\n");
1029                 GOTO(err_fs, rc = -EINVAL);
1030         }
1031
1032         rc = -ENOENT;
1033         obddev->obd_namespace =
1034                 ldlm_namespace_new("mds_server", LDLM_NAMESPACE_SERVER);
1035         if (obddev->obd_namespace == NULL) {
1036                 LBUG();
1037                 mds_cleanup(obddev);
1038                 GOTO(err_svc, rc);
1039         }
1040
1041         for (i = 0; i < MDS_NUM_THREADS; i++) {
1042                 char name[32];
1043                 sprintf(name, "lustre_MDS_%2d", i); 
1044                 rc = ptlrpc_start_thread(obddev, mds->mds_service, name);
1045                 if (rc) {
1046                         CERROR("cannot start MDS thread #%d: rc %d\n", i, rc);
1047                         LBUG();
1048                         GOTO(err_thread, rc);
1049                 }
1050         }
1051
1052         rc = mds_recover(obddev);
1053         if (rc)
1054                 GOTO(err_thread, rc);
1055
1056         RETURN(0);
1057
1058         
1059
1060 err_thread:
1061         ptlrpc_stop_all_threads(mds->mds_service);
1062 err_svc:
1063         ptlrpc_unregister_service(mds->mds_service);
1064 err_fs:
1065         mds_fs_cleanup(mds);
1066 err_put:
1067         unlock_kernel();
1068         mntput(mds->mds_vfsmnt);
1069         mds->mds_sb = 0;
1070         lock_kernel();
1071 err_kfree:
1072         kfree(mds->mds_fstype);
1073 err_dec:
1074         MOD_DEC_USE_COUNT;
1075         return rc;
1076 }
1077
1078 static int mds_cleanup(struct obd_device * obddev)
1079 {
1080         struct super_block *sb;
1081         struct mds_obd *mds = &obddev->u.mds;
1082
1083         ENTRY;
1084
1085         if ( !list_empty(&obddev->obd_exports) ) {
1086                 CERROR("still has exports!\n");
1087                 RETURN(-EBUSY);
1088         }
1089
1090         ptlrpc_stop_all_threads(mds->mds_service);
1091         ptlrpc_unregister_service(mds->mds_service);
1092
1093         sb = mds->mds_sb;
1094         if (!mds->mds_sb)
1095                 RETURN(0);
1096
1097         mds_update_server_data(mds);
1098
1099         if (mds->mds_rcvd_filp) {
1100                 int rc = filp_close(mds->mds_rcvd_filp, 0);
1101                 mds->mds_rcvd_filp = NULL;
1102
1103                 if (rc)
1104                         CERROR("last_rcvd file won't close, rc=%d\n", rc);
1105         }
1106
1107         unlock_kernel();
1108         mntput(mds->mds_vfsmnt);
1109         mds->mds_sb = 0;
1110         kfree(mds->mds_fstype);
1111
1112         ldlm_namespace_free(obddev->obd_namespace);
1113
1114         lock_kernel();
1115 #ifdef CONFIG_DEV_RDONLY
1116         dev_clear_rdonly(2);
1117 #endif
1118         mds_fs_cleanup(mds);
1119
1120         MOD_DEC_USE_COUNT;
1121         RETURN(0);
1122 }
1123
1124 static int ldlm_intent_policy(struct ldlm_lock *lock, void *req_cookie,
1125                               ldlm_mode_t mode, void *data)
1126 {
1127         struct ptlrpc_request *req = req_cookie;
1128         int rc = 0;
1129         ENTRY;
1130
1131         if (!req_cookie)
1132                 RETURN(0);
1133
1134         if (req->rq_reqmsg->bufcount > 1) {
1135                 /* an intent needs to be considered */
1136                 struct ldlm_intent *it = lustre_msg_buf(req->rq_reqmsg, 1);
1137                 struct mds_obd *mds= &req->rq_export->exp_obd->u.mds;
1138                 struct mds_body *mds_rep;
1139                 struct ldlm_reply *rep;
1140                 __u64 new_resid[3] = {0, 0, 0}, old_res;
1141                 int bufcount = -1, rc, size[3] = {sizeof(struct ldlm_reply),
1142                                                   sizeof(struct mds_body),
1143                                                   mds->mds_max_mdsize};
1144
1145                 it->opc = NTOH__u64(it->opc);
1146
1147                 LDLM_DEBUG(lock, "intent policy, opc: %s", ldlm_it2str(it->opc));
1148
1149                 /* prepare reply */
1150                 switch((long)it->opc) {
1151                 case IT_GETATTR:
1152                         /* Note that in the negative case you may be returning
1153                          * a file and its obdo */
1154                 case IT_CREAT:
1155                 case IT_CREAT|IT_OPEN:
1156                 case IT_LINK:
1157                 case IT_LOOKUP:
1158                 case IT_MKDIR:
1159                 case IT_MKNOD:
1160                 case IT_OPEN:
1161                 case IT_READLINK:
1162                 case IT_RENAME:
1163                 case IT_RMDIR:
1164                 case IT_SETATTR:
1165                 case IT_SYMLINK:
1166                 case IT_UNLINK:
1167                         bufcount = 3;
1168                         break;
1169                 case IT_RENAME2:
1170                         bufcount = 1;
1171                         break;
1172                 default:
1173                         LBUG();
1174                 }
1175
1176                 rc = lustre_pack_msg(bufcount, size, NULL, &req->rq_replen,
1177                                      &req->rq_repmsg);
1178                 if (rc) {
1179                         rc = req->rq_status = -ENOMEM;
1180                         RETURN(rc);
1181                 }
1182
1183                 rep = lustre_msg_buf(req->rq_repmsg, 0);
1184                 rep->lock_policy_res1 = 1;
1185
1186                 /* execute policy */
1187                 switch ((long)it->opc) {
1188                 case IT_CREAT:
1189                 case IT_CREAT|IT_OPEN:
1190                 case IT_LINK:
1191                 case IT_MKDIR:
1192                 case IT_MKNOD:
1193                 case IT_RENAME2:
1194                 case IT_RMDIR:
1195                 case IT_SYMLINK:
1196                 case IT_UNLINK:
1197                         rc = mds_reint(2, req);
1198                         if (rc || req->rq_status != 0) {
1199                                 rep->lock_policy_res2 = req->rq_status;
1200                                 RETURN(ELDLM_LOCK_ABORTED);
1201                         }
1202                         break;
1203                 case IT_GETATTR:
1204                 case IT_LOOKUP:
1205                 case IT_OPEN:
1206                 case IT_READDIR:
1207                 case IT_READLINK:
1208                 case IT_RENAME:
1209                 case IT_SETATTR:
1210                         rc = mds_getattr_name(2, req);
1211                         /* FIXME: we need to sit down and decide on who should
1212                          * set req->rq_status, who should return negative and
1213                          * positive return values, and what they all mean. */
1214                         if (rc || req->rq_status != 0) {
1215                                 rep->lock_policy_res2 = req->rq_status;
1216                                 RETURN(ELDLM_LOCK_ABORTED);
1217                         }
1218                         break;
1219                 case IT_READDIR|IT_OPEN:
1220                         LBUG();
1221                         break;
1222                 default:
1223                         CERROR("Unhandled intent\n");
1224                         LBUG();
1225                 }
1226
1227                 if (it->opc == IT_UNLINK || it->opc == IT_RMDIR ||
1228                     it->opc == IT_RENAME || it->opc == IT_RENAME2)
1229                         RETURN(ELDLM_LOCK_ABORTED);
1230
1231                 rep->lock_policy_res2 = req->rq_status;
1232                 mds_rep = lustre_msg_buf(req->rq_repmsg, 1);
1233                 new_resid[0] = NTOH__u32(mds_rep->ino);
1234                 if (new_resid[0] == 0)
1235                         LBUG();
1236                 old_res = lock->l_resource->lr_name[0];
1237
1238                 CDEBUG(D_INFO, "remote intent: locking %d instead of"
1239                        "%ld\n", mds_rep->ino, (long)old_res);
1240
1241                 ldlm_lock_change_resource(lock, new_resid);
1242                 if (lock->l_resource == NULL) {
1243                         LBUG();
1244                         RETURN(-ENOMEM);
1245                 }
1246                 LDLM_DEBUG(lock, "intent policy, old res %ld",
1247                            (long)old_res);
1248                 RETURN(ELDLM_LOCK_CHANGED);
1249         } else {
1250                 int size = sizeof(struct ldlm_reply);
1251                 rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen,
1252                                      &req->rq_repmsg);
1253                 if (rc) {
1254                         CERROR("out of memory\n");
1255                         LBUG();
1256                         RETURN(-ENOMEM);
1257                 }
1258         }
1259         RETURN(rc);
1260 }
1261
1262
1263 extern int mds_iocontrol(long cmd, struct lustre_handle *conn, 
1264                           int len, void *karg, void *uarg);
1265
1266 /* use obd ops to offer management infrastructure */
1267 static struct obd_ops mds_obd_ops = {
1268         o_connect:     mds_connect,
1269         o_disconnect:  mds_disconnect,
1270         o_setup:       mds_setup,
1271         o_cleanup:     mds_cleanup,
1272         o_iocontrol:   mds_iocontrol
1273 };
1274
1275 static int __init mds_init(void)
1276 {
1277         class_register_type(&mds_obd_ops, LUSTRE_MDS_NAME);
1278         ldlm_register_intent(ldlm_intent_policy);
1279         return 0;
1280 }
1281
1282 static void __exit mds_exit(void)
1283 {
1284         ldlm_unregister_intent();
1285         class_unregister_type(LUSTRE_MDS_NAME);
1286 }
1287
1288 MODULE_AUTHOR("Cluster File Systems <info@clusterfs.com>");
1289 MODULE_DESCRIPTION("Lustre Metadata Server (MDS) v0.01");
1290 MODULE_LICENSE("GPL");
1291
1292 module_init(mds_init);
1293 module_exit(mds_exit);