1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
5 * Lustre Metadata Server (mds) request handler
7 * Copyright (c) 2001, 2002 Cluster File Systems, Inc.
8 * Author: Peter Braam <braam@clusterfs.com>
9 * Author: Andreas Dilger <adilger@clusterfs.com>
10 * Author: Phil Schwan <phil@clusterfs.com>
12 * This file is part of Lustre, http://www.lustre.org.
14 * Lustre is free software; you can redistribute it and/or
15 * modify it under the terms of version 2 of the GNU General Public
16 * License as published by the Free Software Foundation.
18 * Lustre is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with Lustre; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 #define DEBUG_SUBSYSTEM S_MDS
31 #include <linux/module.h>
32 #include <linux/lustre_mds.h>
33 #include <linux/lustre_dlm.h>
34 #include <linux/init.h>
35 #include <linux/obd_class.h>
36 #include <linux/random.h>
37 #include <linux/locks.h>
38 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
39 #include <linux/buffer_head.h>
41 #include <linux/obd_lov.h>
42 #include <linux/lprocfs_status.h>
44 static kmem_cache_t *mds_file_cache;
46 extern int mds_get_lovtgts(struct mds_obd *obd, int tgt_count,
47 obd_uuid_t *uuidarray);
48 extern int mds_get_lovdesc(struct mds_obd *obd, struct lov_desc *desc);
49 extern int mds_update_last_rcvd(struct mds_obd *mds, void *handle,
50 struct ptlrpc_request *req);
51 static int mds_cleanup(struct obd_device * obddev);
53 extern struct lprocfs_vars status_var_nm_1[];
54 extern struct lprocfs_vars status_class_var[];
56 inline struct mds_obd *mds_req2mds(struct ptlrpc_request *req)
58 return &req->rq_export->exp_obd->u.mds;
61 static int mds_bulk_timeout(void *data)
63 struct ptlrpc_bulk_desc *desc = data;
66 CERROR("(not yet) starting recovery of client %p\n", desc->bd_client);
70 /* Assumes caller has already pushed into the kernel filesystem context */
71 static int mds_sendpage(struct ptlrpc_request *req, struct file *file,
75 struct mds_obd *mds = mds_req2mds(req);
76 struct ptlrpc_bulk_desc *desc;
77 struct ptlrpc_bulk_page *bulk;
78 struct l_wait_info lwi;
82 desc = ptlrpc_prep_bulk(req->rq_connection);
84 GOTO(out, rc = -ENOMEM);
86 bulk = ptlrpc_prep_bulk_page(desc);
88 GOTO(cleanup_bulk, rc = -ENOMEM);
90 OBD_ALLOC(buf, PAGE_SIZE);
92 GOTO(cleanup_bulk, rc = -ENOMEM);
94 rc = mds_fs_readpage(mds, file, buf, PAGE_SIZE, (loff_t *)&offset);
97 GOTO(cleanup_buf, rc = -EIO);
99 bulk->bp_xid = req->rq_xid;
101 bulk->bp_buflen = PAGE_SIZE;
102 desc->bd_portal = MDS_BULK_PORTAL;
104 rc = ptlrpc_send_bulk(desc);
106 GOTO(cleanup_buf, rc);
108 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_SENDPAGE)) {
109 CERROR("obd_fail_loc=%x, fail operation rc=%d\n",
110 OBD_FAIL_MDS_SENDPAGE, rc);
111 ptlrpc_abort_bulk(desc);
112 GOTO(cleanup_buf, rc);
115 lwi = LWI_TIMEOUT(obd_timeout * HZ, mds_bulk_timeout, desc);
116 rc = l_wait_event(desc->bd_waitq, desc->bd_flags & PTL_BULK_FL_SENT, &lwi);
118 if (rc != -ETIMEDOUT)
120 GOTO(cleanup_buf, rc);
125 OBD_FREE(buf, PAGE_SIZE);
127 ptlrpc_free_bulk(desc);
133 * Look up a named entry in a directory, and get an LDLM lock on it.
134 * 'dir' is a inode for which an LDLM lock has already been taken.
136 * If we do not need an exclusive or write lock on this entry (e.g.
137 * a read lock for attribute lookup only) then we do not hold the
138 * directory on return. It is up to the caller to know what type
139 * of lock it is getting, and clean up appropriately.
141 struct dentry *mds_name2locked_dentry(struct obd_device *obd,
142 struct dentry *dir, struct vfsmount **mnt,
143 char *name, int namelen, int lock_mode,
144 struct lustre_handle *lockh,
147 struct dentry *dchild;
149 __u64 res_id[3] = {0};
152 down(&dir->d_inode->i_sem);
153 dchild = lookup_one_len(name, dir, namelen);
154 if (IS_ERR(dchild)) {
155 CERROR("child lookup error %ld\n", PTR_ERR(dchild));
156 up(&dir->d_inode->i_sem);
160 if (dir_lock_mode != LCK_EX && dir_lock_mode != LCK_PW) {
161 up(&dir->d_inode->i_sem);
162 ldlm_lock_decref(lockh, dir_lock_mode);
165 if (lock_mode == 0 || !dchild->d_inode)
168 res_id[0] = dchild->d_inode->i_ino;
169 res_id[1] = dchild->d_inode->i_generation;
170 rc = ldlm_match_or_enqueue(NULL, NULL, obd->obd_namespace, NULL,
171 res_id, LDLM_PLAIN, NULL, 0, lock_mode,
172 &flags, ldlm_completion_ast,
173 mds_blocking_ast, NULL, 0, lockh);
174 if (rc != ELDLM_OK) {
176 up(&dir->d_inode->i_sem);
177 RETURN(ERR_PTR(-ENOLCK)); /* XXX translate ldlm code */
183 struct dentry *mds_fid2locked_dentry(struct obd_device *obd, struct ll_fid *fid,
184 struct vfsmount **mnt, int lock_mode,
185 struct lustre_handle *lockh)
187 struct mds_obd *mds = &obd->u.mds;
188 struct dentry *de = mds_fid2dentry(mds, fid, mnt), *retval = de;
190 __u64 res_id[3] = {0};
196 res_id[0] = de->d_inode->i_ino;
197 res_id[1] = de->d_inode->i_generation;
198 rc = ldlm_match_or_enqueue(NULL, NULL, obd->obd_namespace, NULL,
199 res_id, LDLM_PLAIN, NULL, 0, lock_mode,
200 &flags, ldlm_completion_ast,
201 mds_blocking_ast, NULL, 0, lockh);
202 if (rc != ELDLM_OK) {
204 retval = ERR_PTR(-ENOLCK); /* XXX translate ldlm code */
210 #ifndef DCACHE_DISCONNECTED
211 #define DCACHE_DISCONNECTED DCACHE_NFSD_DISCONNECTED
214 /* Look up an entry by inode number. */
215 struct dentry *mds_fid2dentry(struct mds_obd *mds, struct ll_fid *fid,
216 struct vfsmount **mnt)
218 /* stolen from NFS */
219 struct super_block *sb = mds->mds_sb;
220 unsigned long ino = fid->id;
221 __u32 generation = fid->generation;
223 struct list_head *lp;
224 struct dentry *result;
227 RETURN(ERR_PTR(-ESTALE));
229 inode = iget(sb, ino);
231 RETURN(ERR_PTR(-ENOMEM));
233 CDEBUG(D_DENTRY, "--> mds_fid2dentry: sb %p\n", inode->i_sb);
235 if (is_bad_inode(inode) ||
236 (generation && inode->i_generation != generation)) {
237 /* we didn't find the right inode.. */
238 CERROR("bad inode %lu, link: %d ct: %d or version %u/%u\n",
239 inode->i_ino, inode->i_nlink,
240 atomic_read(&inode->i_count), inode->i_generation,
244 RETURN(ERR_PTR(-ESTALE));
247 /* now to find a dentry. If possible, get a well-connected one */
249 *mnt = mds->mds_vfsmnt;
250 spin_lock(&dcache_lock);
251 list_for_each(lp, &inode->i_dentry) {
252 result = list_entry(lp, struct dentry, d_alias);
253 if (!(result->d_flags & DCACHE_DISCONNECTED)) {
255 result->d_vfs_flags |= DCACHE_REFERENCED;
256 spin_unlock(&dcache_lock);
263 spin_unlock(&dcache_lock);
264 result = d_alloc_root(inode);
265 if (result == NULL) {
267 return ERR_PTR(-ENOMEM);
271 result->d_flags |= DCACHE_DISCONNECTED;
275 /* Establish a connection to the MDS.
277 * This will set up an export structure for the client to hold state data
278 * about that client, like open files, the last operation number it did
279 * on the server, etc.
281 static int mds_connect(struct lustre_handle *conn, struct obd_device *obd,
282 obd_uuid_t cluuid, struct recovd_obd *recovd,
283 ptlrpc_recovery_cb_t recover)
285 struct obd_export *exp;
286 struct mds_export_data *med;
287 struct mds_client_data *mcd;
292 if (!conn || !obd || !cluuid)
297 spin_lock(&obd->obd_dev_lock);
298 list_for_each(p, &obd->obd_exports) {
299 exp = list_entry(p, struct obd_export, exp_obd_chain);
300 mcd = exp->exp_mds_data.med_mcd;
302 CERROR("FYI: NULL mcd - simultaneous connects\n");
305 if (!memcmp(cluuid, mcd->mcd_uuid, sizeof(mcd->mcd_uuid))) {
306 LASSERT(exp->exp_obd == obd);
308 if (!list_empty(&exp->exp_conn_chain)) {
309 CERROR("existing uuid/export, list not empty!\n");
310 spin_unlock(&obd->obd_dev_lock);
314 conn->addr = (__u64) (unsigned long)exp;
315 conn->cookie = exp->exp_cookie;
316 spin_unlock(&obd->obd_dev_lock);
317 CDEBUG(D_INFO, "existing export for UUID '%s' at %p\n",
319 CDEBUG(D_IOCTL,"connect: addr %Lx cookie %Lx\n",
320 (long long)conn->addr, (long long)conn->cookie);
325 spin_unlock(&obd->obd_dev_lock);
326 /* XXX There is a small race between checking the list and adding a
327 * new connection for the same UUID, but the real threat (list
328 * corruption when multiple different clients connect) is solved.
330 * There is a second race between adding the export to the list,
331 * and filling in the client data below. Hence skipping the case
332 * of NULL mcd above. We should already be controlling multiple
333 * connects at the client, and we can't hold the spinlock over
334 * memory allocations without risk of deadlocking.
336 rc = class_connect(conn, obd, cluuid);
339 exp = class_conn2export(conn);
341 med = &exp->exp_mds_data;
343 OBD_ALLOC(mcd, sizeof(*mcd));
345 CERROR("mds: out of memory for client data\n");
346 GOTO(out_export, rc = -ENOMEM);
349 memcpy(mcd->mcd_uuid, cluuid, sizeof(mcd->mcd_uuid));
352 INIT_LIST_HEAD(&med->med_open_head);
353 spin_lock_init(&med->med_open_lock);
355 rc = mds_client_add(med, -1);
362 OBD_FREE(mcd, sizeof(*mcd));
364 class_disconnect(conn);
371 /* Call with med->med_open_lock held, please. */
372 inline int mds_close_mfd(struct mds_file_data *mfd, struct mds_export_data *med)
374 struct file *file = mfd->mfd_file;
375 LASSERT(file->private_data == mfd);
377 list_del(&mfd->mfd_list);
378 mfd->mfd_servercookie = DEAD_HANDLE_MAGIC;
379 kmem_cache_free(mds_file_cache, mfd);
381 return filp_close(file, 0);
384 static int mds_disconnect(struct lustre_handle *conn)
386 struct obd_export *export = class_conn2export(conn);
387 struct list_head *tmp, *n;
388 struct mds_export_data *med = &export->exp_mds_data;
393 * Close any open files.
395 spin_lock(&med->med_open_lock);
396 list_for_each_safe(tmp, n, &med->med_open_head) {
397 struct mds_file_data *mfd =
398 list_entry(tmp, struct mds_file_data, mfd_list);
399 rc = mds_close_mfd(mfd, med);
401 /* XXX better diagnostics, with file path and stuff */
402 CDEBUG(D_INODE, "Error %d closing mfd %p\n", rc, mfd);
405 spin_unlock(&med->med_open_lock);
407 ldlm_cancel_locks_for_export(export);
408 mds_client_free(export);
410 rc = class_disconnect(conn);
418 * XXX This is NOT guaranteed to flush all transactions to disk (even though
419 * it is equivalent to calling sync()) because it only _starts_ the flush
420 * and does not wait for completion. It's better than nothing though.
421 * What we really want is a mild form of fsync_dev_lockfs(), but it is
422 * non-standard, or enabling do_sync_supers in ext3, just for this call.
424 static void mds_fsync_super(struct super_block *sb)
428 if (sb->s_dirt && sb->s_op && sb->s_op->write_super)
429 sb->s_op->write_super(sb);
434 static int mds_getstatus(struct ptlrpc_request *req)
436 struct mds_obd *mds = mds_req2mds(req);
437 struct mds_body *body;
438 int rc, size = sizeof(*body);
441 rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen, &req->rq_repmsg);
442 if (rc || OBD_FAIL_CHECK(OBD_FAIL_MDS_GETSTATUS_PACK)) {
443 CERROR("mds: out of memory for message: size=%d\n", size);
444 req->rq_status = -ENOMEM;
448 /* Flush any outstanding transactions to disk so the client will
449 * get the latest last_committed value and can drop their local
450 * requests if they have any. This would be fsync_super() if it
453 mds_fsync_super(mds->mds_sb);
455 body = lustre_msg_buf(req->rq_repmsg, 0);
456 memcpy(&body->fid1, &mds->mds_rootfid, sizeof(body->fid1));
458 /* the last_committed and last_xid fields are filled in for all
459 * replies already - no need to do so here also.
464 static int mds_getlovinfo(struct ptlrpc_request *req)
466 struct mds_obd *mds = mds_req2mds(req);
467 struct mds_status_req *streq;
468 struct lov_desc *desc;
470 int rc, size[2] = {sizeof(*desc)};
473 streq = lustre_msg_buf(req->rq_reqmsg, 0);
474 streq->flags = NTOH__u32(streq->flags);
475 streq->repbuf = NTOH__u32(streq->repbuf);
476 size[1] = streq->repbuf;
478 rc = lustre_pack_msg(2, size, NULL, &req->rq_replen, &req->rq_repmsg);
480 CERROR("mds: out of memory for message: size=%d\n", size[1]);
481 req->rq_status = -ENOMEM;
485 desc = lustre_msg_buf(req->rq_repmsg, 0);
486 rc = mds_get_lovdesc(mds, desc);
488 CERROR("mds_get_lovdesc error %d", rc);
493 tgt_count = le32_to_cpu(desc->ld_tgt_count);
494 if (tgt_count * sizeof(obd_uuid_t) > streq->repbuf) {
495 CERROR("too many targets, enlarge client buffers\n");
496 req->rq_status = -ENOSPC;
500 /* XXX the MDS should not really know about this */
501 mds->mds_max_mdsize = lov_mds_md_size(tgt_count);
502 rc = mds_get_lovtgts(mds, tgt_count,
503 lustre_msg_buf(req->rq_repmsg, 1));
505 CERROR("get_lovtgts error %d\n", rc);
512 int mds_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
513 void *data, __u32 data_len, int flag)
518 if (flag == LDLM_CB_CANCELING) {
519 /* Don't need to do anything here. */
523 /* XXX layering violation! -phil */
524 l_lock(&lock->l_resource->lr_namespace->ns_lock);
525 lock->l_flags |= LDLM_FL_CBPENDING;
526 do_ast = (!lock->l_readers && !lock->l_writers);
527 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
530 struct lustre_handle lockh;
533 LDLM_DEBUG(lock, "already unused, calling ldlm_cli_cancel");
534 ldlm_lock2handle(lock, &lockh);
535 rc = ldlm_cli_cancel(&lockh);
537 CERROR("ldlm_cli_cancel: %d\n", rc);
539 LDLM_DEBUG(lock, "Lock still has references, will be"
544 int mds_pack_md(struct mds_obd *mds, struct ptlrpc_request *req,
545 int offset, struct mds_body *body, struct inode *inode)
547 struct lov_mds_md *lmm;
548 int lmm_size = req->rq_repmsg->buflens[offset];
552 CERROR("no space reserved for inode %u MD\n", inode->i_ino);
556 lmm = lustre_msg_buf(req->rq_repmsg, offset);
558 /* I don't really like this, but it is a sanity check on the client
559 * MD request. However, if the client doesn't know how much space
560 * to reserve for the MD, this shouldn't be fatal either...
562 if (lmm_size > mds->mds_max_mdsize) {
563 CERROR("Reading MD for inode %u of %d bytes > max %d\n",
564 inode->i_ino, lmm_size, mds->mds_max_mdsize);
568 /* We don't need to store the reply size, because this buffer is
569 * discarded right after unpacking, and the LOV can figure out the
570 * size itself from the ost count.
572 if ((rc = mds_fs_get_md(mds, inode, lmm, lmm_size)) < 0) {
573 CDEBUG(D_INFO, "No md for ino %u: rc = %d\n", inode->i_ino, rc);
575 body->valid |= OBD_MD_FLEASIZE;
582 static int mds_getattr_internal(struct mds_obd *mds, struct dentry *dentry,
583 struct ptlrpc_request *req,
584 struct mds_body *reqbody, int reply_off)
586 struct mds_body *body;
587 struct inode *inode = dentry->d_inode;
594 body = lustre_msg_buf(req->rq_repmsg, reply_off);
596 mds_pack_inode2fid(&body->fid1, inode);
597 mds_pack_inode2body(body, inode);
599 if (S_ISREG(inode->i_mode)) {
600 rc = mds_pack_md(mds, req, reply_off + 1, body, inode);
601 } else if (S_ISLNK(inode->i_mode) && reqbody->valid & OBD_MD_LINKNAME) {
602 char *symname = lustre_msg_buf(req->rq_repmsg, reply_off + 1);
603 int len = req->rq_repmsg->buflens[reply_off + 1];
605 rc = inode->i_op->readlink(dentry, symname, len);
607 CERROR("readlink failed: %d\n", rc);
609 CDEBUG(D_INODE, "read symlink dest %s\n", symname);
610 body->valid |= OBD_MD_LINKNAME;
616 static int mds_getattr_name(int offset, struct ptlrpc_request *req)
618 struct mds_obd *mds = mds_req2mds(req);
619 struct obd_device *obd = req->rq_export->exp_obd;
620 struct obd_run_ctxt saved;
621 struct mds_body *body;
622 struct dentry *de = NULL, *dchild = NULL;
624 struct lustre_handle lockh;
626 int namelen, flags = 0, lock_mode, rc = 0;
628 __u64 res_id[3] = {0, 0, 0};
631 LASSERT(!strcmp(req->rq_export->exp_obd->obd_type->typ_name, "mds"));
633 if (req->rq_reqmsg->bufcount <= offset + 1) {
635 GOTO(out_pre_de, rc = -EINVAL);
638 body = lustre_msg_buf(req->rq_reqmsg, offset);
639 name = lustre_msg_buf(req->rq_reqmsg, offset + 1);
640 namelen = req->rq_reqmsg->buflens[offset + 1];
641 /* requests were at offset 2, replies go back at 1 */
645 uc.ouc_fsuid = body->fsuid;
646 uc.ouc_fsgid = body->fsgid;
647 uc.ouc_cap = body->capability;
648 push_ctxt(&saved, &mds->mds_ctxt, &uc);
649 de = mds_fid2dentry(mds, &body->fid1, NULL);
652 GOTO(out_pre_de, rc = -ESTALE);
656 CDEBUG(D_INODE, "parent ino %ld, name %*s\n", dir->i_ino,namelen,name);
659 res_id[0] = dir->i_ino;
660 res_id[1] = dir->i_generation;
662 rc = ldlm_lock_match(obd->obd_namespace, res_id, LDLM_PLAIN,
663 NULL, 0, lock_mode, &lockh);
665 LDLM_DEBUG_NOLOCK("enqueue res "LPU64, res_id[0]);
666 rc = ldlm_cli_enqueue(NULL, NULL, obd->obd_namespace, NULL,
667 res_id, LDLM_PLAIN, NULL, 0, lock_mode,
668 &flags, ldlm_completion_ast,
669 mds_blocking_ast, NULL, 0, &lockh);
670 if (rc != ELDLM_OK) {
671 CERROR("lock enqueue: err: %d\n", rc);
672 GOTO(out_create_de, rc = -EIO);
675 ldlm_lock_dump((void *)(unsigned long)lockh.addr);
678 dchild = lookup_one_len(name, de, namelen - 1);
679 if (IS_ERR(dchild)) {
680 CDEBUG(D_INODE, "child lookup error %ld\n", PTR_ERR(dchild));
682 GOTO(out_create_dchild, rc = PTR_ERR(dchild));
685 rc = mds_getattr_internal(mds, dchild, req, body, offset);
691 ldlm_lock_decref(&lockh, lock_mode);
700 static int mds_getattr(int offset, struct ptlrpc_request *req)
702 struct mds_obd *mds = mds_req2mds(req);
703 struct obd_run_ctxt saved;
706 struct mds_body *body;
708 int rc = 0, size[2] = {sizeof(*body)}, bufcount = 1;
711 body = lustre_msg_buf(req->rq_reqmsg, offset);
712 uc.ouc_fsuid = body->fsuid;
713 uc.ouc_fsgid = body->fsgid;
714 uc.ouc_cap = body->capability;
715 push_ctxt(&saved, &mds->mds_ctxt, &uc);
716 de = mds_fid2dentry(mds, &body->fid1, NULL);
718 rc = req->rq_status = -ENOENT;
719 GOTO(out_pop, PTR_ERR(de));
723 if (S_ISREG(body->fid1.f_type)) {
724 int rc = mds_fs_get_md(mds, inode, NULL, 0);
725 CDEBUG(D_INODE, "got %d bytes MD data for inode %u\n",
729 CERROR("error getting inode %u MD: rc = %d\n",
732 } else if (rc < mds->mds_max_mdsize) {
734 CERROR("MD size %d larger than maximum possible %u\n",
735 rc, mds->mds_max_mdsize);
739 } else if (body->valid & OBD_MD_LINKNAME) {
740 size[bufcount] = MIN(inode->i_size + 1, body->size);
742 CDEBUG(D_INODE, "symlink size: %d, reply space: %d\n",
743 inode->i_size + 1, body->size);
746 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_GETATTR_PACK)) {
747 CERROR("failed MDS_GETATTR_PACK test\n");
748 req->rq_status = -ENOMEM;
749 GOTO(out, rc = -ENOMEM);
752 rc = lustre_pack_msg(bufcount, size, NULL, &req->rq_replen,
755 CERROR("out of memoryK\n");
760 req->rq_status = mds_getattr_internal(mds, de, req, body, 0);
769 static int mds_statfs(struct ptlrpc_request *req)
771 struct mds_obd *mds = mds_req2mds(req);
772 struct obd_statfs *osfs;
774 int rc, size = sizeof(*osfs);
777 rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen, &req->rq_repmsg);
778 if (rc || OBD_FAIL_CHECK(OBD_FAIL_MDS_STATFS_PACK)) {
779 CERROR("mds: statfs lustre_pack_msg failed: rc = %d\n", rc);
783 rc = mds_fs_statfs(mds, &sfs);
785 CERROR("mds: statfs failed: rc %d\n", rc);
788 osfs = lustre_msg_buf(req->rq_repmsg, 0);
789 memset(osfs, 0, size);
790 statfs_pack(osfs, &sfs);
791 obd_statfs_pack(osfs, osfs);
798 static struct mds_file_data *mds_handle2mfd(struct lustre_handle *handle)
800 struct mds_file_data *mfd = NULL;
802 if (!handle || !handle->addr)
805 mfd = (struct mds_file_data *)(unsigned long)(handle->addr);
806 if (!kmem_cache_validate(mds_file_cache, mfd))
809 if (mfd->mfd_servercookie != handle->cookie)
815 static int mds_store_md(struct mds_obd *mds, struct ptlrpc_request *req,
816 int offset, struct mds_body *body, struct inode *inode)
818 struct lov_mds_md *lmm = lustre_msg_buf(req->rq_reqmsg, offset);
819 int lmm_size = req->rq_reqmsg->buflens[offset];
820 struct obd_run_ctxt saved;
826 /* I don't really like this, but it is a sanity check on the client
829 if (lmm_size > mds->mds_max_mdsize) {
830 CERROR("Saving MD for inode %u of %d bytes > max %d\n",
831 inode->i_ino, lmm_size, mds->mds_max_mdsize);
835 CDEBUG(D_INODE, "storing %d bytes MD for inode %u\n",
836 lmm_size, inode->i_ino);
837 uc.ouc_fsuid = body->fsuid;
838 uc.ouc_fsgid = body->fsgid;
839 uc.ouc_cap = body->capability;
840 push_ctxt(&saved, &mds->mds_ctxt, &uc);
841 handle = mds_fs_start(mds, inode, MDS_FSOP_SETATTR);
843 GOTO(out_ea, rc = -ENOMEM);
845 rc = mds_fs_set_md(mds, inode, handle, lmm, lmm_size);
847 rc = mds_update_last_rcvd(mds, handle, req);
849 rc2 = mds_fs_commit(mds, inode, handle);
858 static int mds_open(struct ptlrpc_request *req)
860 struct mds_obd *mds = mds_req2mds(req);
861 struct mds_body *body;
862 struct mds_export_data *med;
863 struct mds_file_data *mfd;
866 struct vfsmount *mnt;
868 struct list_head *tmp;
869 int rc, size = sizeof(*body);
872 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_OPEN_PACK)) {
873 CERROR("test case OBD_FAIL_MDS_OPEN_PACK\n");
874 req->rq_status = -ENOMEM;
878 rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen, &req->rq_repmsg);
880 CERROR("mds: pack error: rc = %d\n", rc);
885 body = lustre_msg_buf(req->rq_reqmsg, 0);
887 /* was this animal open already and the client lost the reply? */
888 /* XXX need some way to detect a reopen, to avoid locked list walks */
889 med = &req->rq_export->exp_mds_data;
890 spin_lock(&med->med_open_lock);
891 list_for_each(tmp, &med->med_open_head) {
892 mfd = list_entry(tmp, typeof(*mfd), mfd_list);
893 if (!memcmp(&mfd->mfd_clienthandle, &body->handle,
894 sizeof(mfd->mfd_clienthandle)) &&
895 body->fid1.id == mfd->mfd_file->f_dentry->d_inode->i_ino) {
896 de = mfd->mfd_file->f_dentry;
897 spin_unlock(&med->med_open_lock);
898 CERROR("Re opening "LPD64"\n", body->fid1.id);
899 GOTO(out_pack, rc = 0);
902 spin_unlock(&med->med_open_lock);
904 mfd = kmem_cache_alloc(mds_file_cache, GFP_KERNEL);
906 CERROR("mds: out of memory\n");
907 req->rq_status = -ENOMEM;
911 de = mds_fid2dentry(mds, &body->fid1, &mnt);
913 GOTO(out_free, rc = PTR_ERR(de));
915 /* check if this inode has seen a delayed object creation */
916 if (lustre_msg_get_op_flags(req->rq_reqmsg) & MDS_OPEN_HAS_EA) {
917 rc = mds_store_md(mds, req, 1, body, de->d_inode);
926 /* dentry_open does a dput(de) and mntput(mnt) on error */
927 file = dentry_open(de, mnt, flags & ~O_DIRECT);
933 file->private_data = mfd;
934 mfd->mfd_file = file;
935 memcpy(&mfd->mfd_clienthandle, &body->handle, sizeof(body->handle));
936 get_random_bytes(&mfd->mfd_servercookie, sizeof(mfd->mfd_servercookie));
937 spin_lock(&med->med_open_lock);
938 list_add(&mfd->mfd_list, &med->med_open_head);
939 spin_unlock(&med->med_open_lock);
942 body = lustre_msg_buf(req->rq_repmsg, 0);
943 mds_pack_inode2fid(&body->fid1, de->d_inode);
944 mds_pack_inode2body(body, de->d_inode);
945 body->handle.addr = (__u64)(unsigned long)mfd;
946 body->handle.cookie = mfd->mfd_servercookie;
947 CDEBUG(D_INODE, "llite file "LPX64": addr %p, cookie "LPX64"\n",
948 mfd->mfd_clienthandle.addr, mfd, mfd->mfd_servercookie);
952 mfd->mfd_servercookie = DEAD_HANDLE_MAGIC;
953 kmem_cache_free(mds_file_cache, mfd);
958 static int mds_close(struct ptlrpc_request *req)
960 struct mds_export_data *med = &req->rq_export->exp_mds_data;
961 struct mds_body *body;
962 struct mds_file_data *mfd;
966 body = lustre_msg_buf(req->rq_reqmsg, 0);
968 mfd = mds_handle2mfd(&body->handle);
970 CERROR("no handle for file close "LPD64
971 ": addr "LPX64", cookie "LPX64"\n",
972 body->fid1.id, body->handle.addr, body->handle.cookie);
976 spin_lock(&med->med_open_lock);
977 req->rq_status = mds_close_mfd(mfd, med);
978 spin_unlock(&med->med_open_lock);
980 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_CLOSE_PACK)) {
981 CERROR("test case OBD_FAIL_MDS_CLOSE_PACK\n");
982 req->rq_status = -ENOMEM;
986 rc = lustre_pack_msg(0, NULL, NULL, &req->rq_replen, &req->rq_repmsg);
988 CERROR("mds: lustre_pack_msg: rc = %d\n", rc);
995 static int mds_readpage(struct ptlrpc_request *req)
997 struct mds_obd *mds = mds_req2mds(req);
998 struct vfsmount *mnt;
1001 struct mds_body *body, *repbody;
1002 struct obd_run_ctxt saved;
1003 int rc, size = sizeof(*body);
1004 struct obd_ucred uc;
1007 rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen, &req->rq_repmsg);
1008 if (rc || OBD_FAIL_CHECK(OBD_FAIL_MDS_READPAGE_PACK)) {
1009 CERROR("mds: out of memory\n");
1010 GOTO(out, rc = -ENOMEM);
1013 body = lustre_msg_buf(req->rq_reqmsg, 0);
1014 uc.ouc_fsuid = body->fsuid;
1015 uc.ouc_fsgid = body->fsgid;
1016 uc.ouc_cap = body->capability;
1017 push_ctxt(&saved, &mds->mds_ctxt, &uc);
1018 de = mds_fid2dentry(mds, &body->fid1, &mnt);
1020 GOTO(out_pop, rc = PTR_ERR(de));
1022 CDEBUG(D_INODE, "ino %ld\n", de->d_inode->i_ino);
1024 file = dentry_open(de, mnt, O_RDONLY | O_LARGEFILE);
1025 /* note: in case of an error, dentry_open puts dentry */
1027 GOTO(out_pop, rc = PTR_ERR(file));
1029 repbody = lustre_msg_buf(req->rq_repmsg, 0);
1030 repbody->size = file->f_dentry->d_inode->i_size;
1031 repbody->valid = OBD_MD_FLSIZE;
1033 /* to make this asynchronous make sure that the handling function
1034 doesn't send a reply when this function completes. Instead a
1035 callback function would send the reply */
1036 /* note: in case of an error, dentry_open puts dentry */
1037 rc = mds_sendpage(req, file, body->size);
1039 filp_close(file, 0);
1043 req->rq_status = rc;
1047 int mds_reint(struct ptlrpc_request *req, int offset)
1050 struct mds_update_record rec;
1052 rc = mds_update_unpack(req, offset, &rec);
1053 if (rc || OBD_FAIL_CHECK(OBD_FAIL_MDS_REINT_UNPACK)) {
1054 CERROR("invalid record\n");
1055 req->rq_status = -EINVAL;
1058 /* rc will be used to interrupt a for loop over multiple records */
1059 rc = mds_reint_rec(&rec, offset, req);
1063 int mds_handle(struct ptlrpc_request *req)
1068 rc = lustre_unpack_msg(req->rq_reqmsg, req->rq_reqlen);
1069 if (rc || OBD_FAIL_CHECK(OBD_FAIL_MDS_HANDLE_UNPACK)) {
1070 CERROR("lustre_mds: Invalid request\n");
1074 if (req->rq_reqmsg->opc != MDS_CONNECT && req->rq_export == NULL)
1075 GOTO(out, rc = -ENOTCONN);
1077 LASSERT(!strcmp(req->rq_obd->obd_type->typ_name, LUSTRE_MDT_NAME));
1079 switch (req->rq_reqmsg->opc) {
1081 CDEBUG(D_INODE, "connect\n");
1082 OBD_FAIL_RETURN(OBD_FAIL_MDS_CONNECT_NET, 0);
1083 rc = target_handle_connect(req);
1086 case MDS_DISCONNECT:
1087 CDEBUG(D_INODE, "disconnect\n");
1088 OBD_FAIL_RETURN(OBD_FAIL_MDS_DISCONNECT_NET, 0);
1089 rc = target_handle_disconnect(req);
1093 CDEBUG(D_INODE, "getstatus\n");
1094 OBD_FAIL_RETURN(OBD_FAIL_MDS_GETSTATUS_NET, 0);
1095 rc = mds_getstatus(req);
1098 case MDS_GETLOVINFO:
1099 CDEBUG(D_INODE, "getlovinfo\n");
1100 rc = mds_getlovinfo(req);
1104 CDEBUG(D_INODE, "getattr\n");
1105 OBD_FAIL_RETURN(OBD_FAIL_MDS_GETATTR_NET, 0);
1106 rc = mds_getattr(0, req);
1110 CDEBUG(D_INODE, "statfs\n");
1111 OBD_FAIL_RETURN(OBD_FAIL_MDS_STATFS_NET, 0);
1112 rc = mds_statfs(req);
1116 CDEBUG(D_INODE, "readpage\n");
1117 OBD_FAIL_RETURN(OBD_FAIL_MDS_READPAGE_NET, 0);
1118 rc = mds_readpage(req);
1120 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_SENDPAGE))
1125 int size = sizeof(struct mds_body);
1126 CDEBUG(D_INODE, "reint\n");
1127 OBD_FAIL_RETURN(OBD_FAIL_MDS_REINT_NET, 0);
1129 rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen,
1132 req->rq_status = rc;
1135 rc = mds_reint(req, 0);
1136 OBD_FAIL_RETURN(OBD_FAIL_MDS_REINT_NET_REP, 0);
1141 CDEBUG(D_INODE, "open\n");
1142 OBD_FAIL_RETURN(OBD_FAIL_MDS_OPEN_NET, 0);
1147 CDEBUG(D_INODE, "close\n");
1148 OBD_FAIL_RETURN(OBD_FAIL_MDS_CLOSE_NET, 0);
1149 rc = mds_close(req);
1153 CDEBUG(D_INODE, "enqueue\n");
1154 OBD_FAIL_RETURN(OBD_FAIL_LDLM_ENQUEUE, 0);
1155 rc = ldlm_handle_enqueue(req);
1158 CDEBUG(D_INODE, "convert\n");
1159 OBD_FAIL_RETURN(OBD_FAIL_LDLM_CONVERT, 0);
1160 rc = ldlm_handle_convert(req);
1162 case LDLM_BL_CALLBACK:
1163 case LDLM_CP_CALLBACK:
1164 CDEBUG(D_INODE, "callback\n");
1165 CERROR("callbacks should not happen on MDS\n");
1167 OBD_FAIL_RETURN(OBD_FAIL_LDLM_BL_CALLBACK, 0);
1170 rc = ptlrpc_error(req->rq_svc, req);
1177 struct mds_export_data *med = &req->rq_export->exp_mds_data;
1178 struct mds_obd *mds = mds_req2mds(req);
1180 req->rq_repmsg->last_xid =
1181 HTON__u64(le64_to_cpu(med->med_mcd->mcd_last_xid));
1182 req->rq_repmsg->last_committed =
1183 HTON__u64(mds->mds_last_committed);
1184 CDEBUG(D_INFO, "last_rcvd ~%Lu, last_committed %Lu, xid %d\n",
1185 (unsigned long long)mds->mds_last_rcvd,
1186 (unsigned long long)mds->mds_last_committed,
1187 cpu_to_le32(req->rq_xid));
1191 CERROR("mds: processing error (opcode %d): %d\n",
1192 req->rq_reqmsg->opc, rc);
1193 ptlrpc_error(req->rq_svc, req);
1195 CDEBUG(D_NET, "sending reply\n");
1196 ptlrpc_reply(req->rq_svc, req);
1201 /* Update the server data on disk. This stores the new mount_count and
1202 * also the last_rcvd value to disk. If we don't have a clean shutdown,
1203 * then the server last_rcvd value may be less than that of the clients.
1204 * This will alert us that we may need to do client recovery.
1206 * Assumes we are already in the server filesystem context.
1208 * Also assumes for mds_last_rcvd that we are not modifying it (no locking).
1211 int mds_update_server_data(struct mds_obd *mds)
1213 struct mds_server_data *msd = mds->mds_server_data;
1214 struct file *filp = mds->mds_rcvd_filp;
1218 msd->msd_last_rcvd = cpu_to_le64(mds->mds_last_rcvd);
1219 msd->msd_mount_count = cpu_to_le64(mds->mds_mount_count);
1221 CDEBUG(D_SUPER, "MDS mount_count is %Lu, last_rcvd is %Lu\n",
1222 (unsigned long long)mds->mds_mount_count,
1223 (unsigned long long)mds->mds_last_rcvd);
1224 rc = lustre_fwrite(filp, (char *)msd, sizeof(*msd), &off);
1225 if (rc != sizeof(*msd)) {
1226 CERROR("error writing MDS server data: rc = %d\n", rc);
1231 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
1232 rc = fsync_dev(filp->f_dentry->d_inode->i_rdev);
1234 rc = file_fsync(filp, filp->f_dentry, 1);
1237 CERROR("error flushing MDS server data: rc = %d\n", rc);
1242 /* Do recovery actions for the MDS */
1243 static int mds_recover(struct obd_device *obddev)
1245 struct mds_obd *mds = &obddev->u.mds;
1246 struct obd_run_ctxt saved;
1249 /* This happens at the end when recovery is complete */
1250 ++mds->mds_mount_count;
1251 push_ctxt(&saved, &mds->mds_ctxt, NULL);
1252 rc = mds_update_server_data(mds);
1258 /* mount the file system (secretly) */
1259 static int mds_setup(struct obd_device *obddev, obd_count len, void *buf)
1261 struct obd_ioctl_data* data = buf;
1262 struct mds_obd *mds = &obddev->u.mds;
1263 struct vfsmount *mnt;
1268 #ifdef CONFIG_DEV_RDONLY
1269 dev_clear_rdonly(2);
1271 if (!data->ioc_inlbuf1 || !data->ioc_inlbuf2)
1272 GOTO(err_dec, rc = -EINVAL);
1274 mds->mds_fstype = strdup(data->ioc_inlbuf2);
1276 mnt = do_kern_mount(mds->mds_fstype, 0, data->ioc_inlbuf1, NULL);
1279 CERROR("do_kern_mount failed: rc = %d\n", rc);
1280 GOTO(err_kfree, rc);
1283 CERROR("%s: mnt is %p\n", data->ioc_inlbuf1, mnt);
1284 mds->mds_sb = mnt->mnt_root->d_inode->i_sb;
1286 GOTO(err_put, rc = -ENODEV);
1288 spin_lock_init(&mds->mds_last_lock);
1289 mds->mds_max_mdsize = sizeof(struct lov_mds_md);
1290 rc = mds_fs_setup(obddev, mnt);
1292 CERROR("MDS filesystem method init failed: rc = %d\n", rc);
1296 obddev->obd_namespace =
1297 ldlm_namespace_new("mds_server", LDLM_NAMESPACE_SERVER);
1298 if (obddev->obd_namespace == NULL) {
1299 mds_cleanup(obddev);
1300 GOTO(err_fs, rc = -ENOMEM);
1304 rc = mds_recover(obddev);
1308 ptlrpc_init_client(LDLM_CB_REQUEST_PORTAL, LDLM_CB_REPLY_PORTAL,
1309 "mds_ldlm_client", &obddev->obd_ldlm_client);
1314 mds_fs_cleanup(obddev);
1317 mntput(mds->mds_vfsmnt);
1321 kfree(mds->mds_fstype);
1327 static int mds_cleanup(struct obd_device *obddev)
1329 struct super_block *sb;
1330 struct mds_obd *mds = &obddev->u.mds;
1331 struct obd_run_ctxt saved;
1338 push_ctxt(&saved, &mds->mds_ctxt, NULL);
1339 mds_update_server_data(mds);
1341 if (mds->mds_rcvd_filp) {
1342 int rc = filp_close(mds->mds_rcvd_filp, 0);
1343 mds->mds_rcvd_filp = NULL;
1346 CERROR("last_rcvd file won't close, rc=%d\n", rc);
1351 mntput(mds->mds_vfsmnt);
1353 kfree(mds->mds_fstype);
1355 ldlm_namespace_free(obddev->obd_namespace);
1358 #ifdef CONFIG_DEV_RDONLY
1359 dev_clear_rdonly(2);
1361 mds_fs_cleanup(obddev);
1367 static int ldlm_intent_policy(struct ldlm_lock *lock, void *req_cookie,
1368 ldlm_mode_t mode, int flags, void *data)
1370 struct ptlrpc_request *req = req_cookie;
1377 if (req->rq_reqmsg->bufcount > 1) {
1378 /* an intent needs to be considered */
1379 struct ldlm_intent *it = lustre_msg_buf(req->rq_reqmsg, 1);
1380 struct mds_obd *mds= &req->rq_export->exp_obd->u.mds;
1381 struct mds_body *mds_rep;
1382 struct ldlm_reply *rep;
1383 __u64 new_resid[3] = {0, 0, 0}, old_res;
1384 int rc, size[3] = {sizeof(struct ldlm_reply),
1385 sizeof(struct mds_body),
1386 mds->mds_max_mdsize};
1388 it->opc = NTOH__u64(it->opc);
1390 LDLM_DEBUG(lock, "intent policy, opc: %s",
1391 ldlm_it2str(it->opc));
1393 rc = lustre_pack_msg(3, size, NULL, &req->rq_replen,
1396 rc = req->rq_status = -ENOMEM;
1400 rep = lustre_msg_buf(req->rq_repmsg, 0);
1401 rep->lock_policy_res1 = 1;
1403 /* execute policy */
1404 switch ((long)it->opc) {
1405 case IT_CREAT|IT_OPEN:
1406 rc = mds_reint(req, 2);
1407 if (rc || (req->rq_status != 0 &&
1408 req->rq_status != -EEXIST)) {
1409 rep->lock_policy_res2 = req->rq_status;
1410 RETURN(ELDLM_LOCK_ABORTED);
1421 rc = mds_reint(req, 2);
1422 if (rc || (req->rq_status != 0 &&
1423 req->rq_status != -EISDIR &&
1424 req->rq_status != -ENOTDIR)) {
1425 rep->lock_policy_res2 = req->rq_status;
1426 RETURN(ELDLM_LOCK_ABORTED);
1437 rc = mds_getattr_name(2, req);
1438 /* FIXME: we need to sit down and decide on who should
1439 * set req->rq_status, who should return negative and
1440 * positive return values, and what they all mean. */
1441 if (rc || req->rq_status != 0) {
1442 rep->lock_policy_res2 = req->rq_status;
1443 RETURN(ELDLM_LOCK_ABORTED);
1446 case IT_READDIR|IT_OPEN:
1450 CERROR("Unhandled intent "LPD64"\n", it->opc);
1454 /* We don't bother returning a lock to the client for a file
1455 * or directory we are removing.
1457 * As for link and rename, there is no reason for the client
1458 * to get a lock on the target at this point. If they are
1459 * going to modify the file/directory later they will get a
1460 * lock at that time.
1462 if (it->opc & (IT_UNLINK | IT_RMDIR | IT_LINK | IT_LINK2 |
1463 IT_RENAME | IT_RENAME2))
1464 RETURN(ELDLM_LOCK_ABORTED);
1466 rep->lock_policy_res2 = req->rq_status;
1467 mds_rep = lustre_msg_buf(req->rq_repmsg, 1);
1469 /* If the client is about to open a file that doesn't have an MD
1470 * stripe record, it's going to need a write lock. */
1471 if (it->opc & IT_OPEN &&
1472 !(lustre_msg_get_op_flags(req->rq_reqmsg)&MDS_OPEN_HAS_EA)){
1473 LDLM_DEBUG(lock, "open with no EA; returning PW lock");
1474 lock->l_req_mode = LCK_PW;
1477 if (flags & LDLM_FL_INTENT_ONLY) {
1478 LDLM_DEBUG(lock, "INTENT_ONLY, aborting lock");
1479 RETURN(ELDLM_LOCK_ABORTED);
1481 /* Give the client a lock on the child object, instead of the
1482 * parent that it requested. */
1483 new_resid[0] = NTOH__u32(mds_rep->ino);
1484 new_resid[1] = NTOH__u32(mds_rep->generation);
1485 if (new_resid[0] == 0)
1487 old_res = lock->l_resource->lr_name[0];
1489 ldlm_lock_change_resource(lock, new_resid);
1490 if (lock->l_resource == NULL) {
1494 LDLM_DEBUG(lock, "intent policy, old res %ld",
1496 RETURN(ELDLM_LOCK_CHANGED);
1498 int size = sizeof(struct ldlm_reply);
1499 rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen,
1509 int mds_attach(struct obd_device *dev, obd_count len, void *data)
1511 return lprocfs_reg_obd(dev, status_var_nm_1, dev);
1514 int mds_detach(struct obd_device *dev)
1516 return lprocfs_dereg_obd(dev);
1519 static int mdt_setup(struct obd_device *obddev, obd_count len, void *buf)
1522 // struct obd_ioctl_data* data = buf;
1523 struct mds_obd *mds = &obddev->u.mds;
1529 mds->mds_service = ptlrpc_init_svc(MDS_NEVENTS, MDS_NBUFS,
1530 MDS_BUFSIZE, MDS_MAXREQSIZE,
1531 MDS_REQUEST_PORTAL, MDC_REPLY_PORTAL,
1532 "self", mds_handle, "mds");
1533 if (!mds->mds_service) {
1534 CERROR("failed to start service\n");
1535 GOTO(err_dec, rc = -EINVAL);
1538 for (i = 0; i < MDT_NUM_THREADS; i++) {
1540 sprintf(name, "ll_mdt_%02d", i);
1541 rc = ptlrpc_start_thread(obddev, mds->mds_service, name);
1543 CERROR("cannot start MDT thread #%d: rc %d\n", i, rc);
1544 GOTO(err_thread, rc);
1551 ptlrpc_stop_all_threads(mds->mds_service);
1552 ptlrpc_unregister_service(mds->mds_service);
1559 static int mdt_cleanup(struct obd_device *obddev)
1561 struct mds_obd *mds = &obddev->u.mds;
1564 ptlrpc_stop_all_threads(mds->mds_service);
1565 ptlrpc_unregister_service(mds->mds_service);
1571 extern int mds_iocontrol(long cmd, struct lustre_handle *conn,
1572 int len, void *karg, void *uarg);
1574 /* use obd ops to offer management infrastructure */
1575 static struct obd_ops mds_obd_ops = {
1576 o_attach: mds_attach,
1577 o_detach: mds_detach,
1578 o_connect: mds_connect,
1579 o_disconnect: mds_disconnect,
1581 o_cleanup: mds_cleanup,
1582 o_iocontrol: mds_iocontrol
1585 static struct obd_ops mdt_obd_ops = {
1587 o_cleanup: mdt_cleanup,
1591 static int __init mds_init(void)
1594 mds_file_cache = kmem_cache_create("ll_mds_file_data",
1595 sizeof(struct mds_file_data),
1597 if (mds_file_cache == NULL)
1600 class_register_type(&mds_obd_ops, status_class_var, LUSTRE_MDS_NAME);
1601 class_register_type(&mdt_obd_ops, 0, LUSTRE_MDT_NAME);
1602 ldlm_register_intent(ldlm_intent_policy);
1607 static void __exit mds_exit(void)
1611 ldlm_unregister_intent();
1612 class_unregister_type(LUSTRE_MDS_NAME);
1613 class_unregister_type(LUSTRE_MDT_NAME);
1614 if (kmem_cache_destroy(mds_file_cache))
1615 CERROR("couldn't free MDS file cache\n");
1619 MODULE_AUTHOR("Cluster File Systems <info@clusterfs.com>");
1620 MODULE_DESCRIPTION("Lustre Metadata Server (MDS) v0.01");
1621 MODULE_LICENSE("GPL");
1623 module_init(mds_init);
1624 module_exit(mds_exit);