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-2005 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>
11 * Author: Mike Shaver <shaver@clusterfs.com>
13 * This file is part of the Lustre file system, http://www.lustre.org
14 * Lustre is a trademark of Cluster File Systems, Inc.
16 * You may have signed or agreed to another license before downloading
17 * this software. If so, you are bound by the terms and conditions
18 * of that agreement, and the following does not apply to you. See the
19 * LICENSE file included with this distribution for more information.
21 * If you did not agree to a different license, then this copy of Lustre
22 * is open source software; you can redistribute it and/or modify it
23 * under the terms of version 2 of the GNU General Public License as
24 * published by the Free Software Foundation.
26 * In either case, Lustre is distributed in the hope that it will be
27 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
28 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * license text for more details.
33 # define EXPORT_SYMTAB
35 #define DEBUG_SUBSYSTEM S_MDS
37 #include <lustre_mds.h>
38 #include <linux/module.h>
39 #include <linux/init.h>
40 #include <linux/random.h>
42 #include <linux/jbd.h>
43 #include <linux/smp_lock.h>
44 #include <linux/buffer_head.h>
45 #include <linux/workqueue.h>
46 #include <linux/mount.h>
48 #include <linux/lustre_acl.h>
49 #include <obd_class.h>
50 #include <lustre_dlm.h>
52 #include <lustre_fsfilt.h>
53 #include <lprocfs_status.h>
54 #include <lustre_commit_confd.h>
55 #include <lustre_quota.h>
56 #include <lustre_disk.h>
57 #include <lustre_param.h>
59 #include "mds_internal.h"
62 CFS_MODULE_PARM(mds_num_threads, "i", int, 0444,
63 "number of MDS service threads to start");
65 __u32 mds_max_ost_index=0xFFFF;
66 CFS_MODULE_PARM(mds_max_ost_index, "i", int, 0444,
69 static int mds_intent_policy(struct ldlm_namespace *ns,
70 struct ldlm_lock **lockp, void *req_cookie,
71 ldlm_mode_t mode, int flags, void *data);
72 static int mds_postsetup(struct obd_device *obd);
73 static int mds_cleanup(struct obd_device *obd);
75 /* Assumes caller has already pushed into the kernel filesystem context */
76 static int mds_sendpage(struct ptlrpc_request *req, struct file *file,
77 loff_t offset, int count)
79 struct ptlrpc_bulk_desc *desc;
80 struct l_wait_info lwi;
82 int rc = 0, npages, i, tmpcount, tmpsize = 0;
85 LASSERT((offset & ~CFS_PAGE_MASK) == 0); /* I'm dubious about this */
87 npages = (count + CFS_PAGE_SIZE - 1) >> CFS_PAGE_SHIFT;
88 OBD_ALLOC(pages, sizeof(*pages) * npages);
90 GOTO(out, rc = -ENOMEM);
92 desc = ptlrpc_prep_bulk_exp(req, npages, BULK_PUT_SOURCE,
95 GOTO(out_free, rc = -ENOMEM);
97 for (i = 0, tmpcount = count; i < npages; i++, tmpcount -= tmpsize) {
98 tmpsize = tmpcount > CFS_PAGE_SIZE ? CFS_PAGE_SIZE : tmpcount;
100 OBD_PAGE_ALLOC(pages[i], CFS_ALLOC_STD);
101 if (pages[i] == NULL)
102 GOTO(cleanup_buf, rc = -ENOMEM);
104 ptlrpc_prep_bulk_page(desc, pages[i], 0, tmpsize);
107 for (i = 0, tmpcount = count; i < npages; i++, tmpcount -= tmpsize) {
108 tmpsize = tmpcount > CFS_PAGE_SIZE ? CFS_PAGE_SIZE : tmpcount;
109 CDEBUG(D_EXT2, "reading %u@%llu from dir %lu (size %llu)\n",
110 tmpsize, offset, file->f_dentry->d_inode->i_ino,
111 i_size_read(file->f_dentry->d_inode));
113 rc = fsfilt_readpage(req->rq_export->exp_obd, file,
114 kmap(pages[i]), tmpsize, &offset);
118 GOTO(cleanup_buf, rc = -EIO);
121 LASSERT(desc->bd_nob == count);
123 rc = ptlrpc_start_bulk_transfer(desc);
125 GOTO(cleanup_buf, rc);
127 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_SENDPAGE)) {
128 CERROR("obd_fail_loc=%x, fail operation rc=%d\n",
129 OBD_FAIL_MDS_SENDPAGE, rc);
130 GOTO(abort_bulk, rc);
133 lwi = LWI_TIMEOUT(obd_timeout * HZ / 4, NULL, NULL);
134 rc = l_wait_event(desc->bd_waitq, !ptlrpc_bulk_active(desc), &lwi);
135 LASSERT (rc == 0 || rc == -ETIMEDOUT);
138 if (desc->bd_success &&
139 desc->bd_nob_transferred == count)
140 GOTO(cleanup_buf, rc);
142 rc = -ETIMEDOUT; /* XXX should this be a different errno? */
145 DEBUG_REQ(D_ERROR, req, "bulk failed: %s %d(%d), evicting %s@%s",
146 (rc == -ETIMEDOUT) ? "timeout" : "network error",
147 desc->bd_nob_transferred, count,
148 req->rq_export->exp_client_uuid.uuid,
149 req->rq_export->exp_connection->c_remote_uuid.uuid);
151 class_fail_export(req->rq_export);
155 ptlrpc_abort_bulk (desc);
157 for (i = 0; i < npages; i++)
159 OBD_PAGE_FREE(pages[i]);
161 ptlrpc_free_bulk(desc);
163 OBD_FREE(pages, sizeof(*pages) * npages);
168 /* only valid locked dentries or errors should be returned */
169 struct dentry *mds_fid2locked_dentry(struct obd_device *obd, struct ll_fid *fid,
170 struct vfsmount **mnt, int lock_mode,
171 struct lustre_handle *lockh,
174 struct mds_obd *mds = &obd->u.mds;
175 struct dentry *de = mds_fid2dentry(mds, fid, mnt), *retval = de;
176 struct ldlm_res_id res_id = { .name = {0} };
177 int flags = LDLM_FL_ATOMIC_CB, rc;
178 ldlm_policy_data_t policy = { .l_inodebits = { lockpart} };
184 res_id.name[0] = de->d_inode->i_ino;
185 res_id.name[1] = de->d_inode->i_generation;
186 rc = ldlm_cli_enqueue_local(obd->obd_namespace, &res_id,
187 LDLM_IBITS, &policy, lock_mode, &flags,
188 ldlm_blocking_ast, ldlm_completion_ast,
189 NULL, NULL, 0, NULL, lockh);
190 if (rc != ELDLM_OK) {
192 retval = ERR_PTR(-EIO); /* XXX translate ldlm code */
198 /* Look up an entry by inode number. */
199 /* this function ONLY returns valid dget'd dentries with an initialized inode
201 struct dentry *mds_fid2dentry(struct mds_obd *mds, struct ll_fid *fid,
202 struct vfsmount **mnt)
205 unsigned long ino = fid->id;
206 __u32 generation = fid->generation;
208 struct dentry *result;
211 RETURN(ERR_PTR(-ESTALE));
213 snprintf(fid_name, sizeof(fid_name), "0x%lx", ino);
215 CDEBUG(D_DENTRY, "--> mds_fid2dentry: ino/gen %lu/%u, sb %p\n",
216 ino, generation, mds->mds_obt.obt_sb);
218 /* under ext3 this is neither supposed to return bad inodes
220 result = ll_lookup_one_len(fid_name, mds->mds_fid_de, strlen(fid_name));
224 inode = result->d_inode;
226 RETURN(ERR_PTR(-ENOENT));
228 if (inode->i_generation == 0 || inode->i_nlink == 0) {
229 LCONSOLE_WARN("Found inode with zero generation or link -- this"
230 " may indicate disk corruption (inode: %lu/%u, "
231 "link %lu, count %d)\n", inode->i_ino,
232 inode->i_generation,(unsigned long)inode->i_nlink,
233 atomic_read(&inode->i_count));
235 RETURN(ERR_PTR(-ENOENT));
238 if (generation && inode->i_generation != generation) {
239 /* we didn't find the right inode.. */
240 CDEBUG(D_INODE, "found wrong generation: inode %lu, link: %lu, "
241 "count: %d, generation %u/%u\n", inode->i_ino,
242 (unsigned long)inode->i_nlink,
243 atomic_read(&inode->i_count), inode->i_generation,
246 RETURN(ERR_PTR(-ENOENT));
250 *mnt = mds->mds_vfsmnt;
257 static int mds_connect_internal(struct obd_export *exp,
258 struct obd_connect_data *data)
260 struct obd_device *obd = exp->exp_obd;
262 data->ocd_connect_flags &= MDT_CONNECT_SUPPORTED;
263 data->ocd_ibits_known &= MDS_INODELOCK_FULL;
265 /* If no known bits (which should not happen, probably,
266 as everybody should support LOOKUP and UPDATE bits at least)
267 revert to compat mode with plain locks. */
268 if (!data->ocd_ibits_known &&
269 data->ocd_connect_flags & OBD_CONNECT_IBITS)
270 data->ocd_connect_flags &= ~OBD_CONNECT_IBITS;
272 if (!obd->u.mds.mds_fl_acl)
273 data->ocd_connect_flags &= ~OBD_CONNECT_ACL;
275 if (!obd->u.mds.mds_fl_user_xattr)
276 data->ocd_connect_flags &= ~OBD_CONNECT_XATTR;
278 exp->exp_connect_flags = data->ocd_connect_flags;
279 data->ocd_version = LUSTRE_VERSION_CODE;
280 exp->exp_mds_data.med_ibits_known = data->ocd_ibits_known;
283 if (obd->u.mds.mds_fl_acl &&
284 ((exp->exp_connect_flags & OBD_CONNECT_ACL) == 0)) {
285 CWARN("%s: MDS requires ACL support but client does not\n",
292 static int mds_reconnect(const struct lu_env *env,
293 struct obd_export *exp, struct obd_device *obd,
294 struct obd_uuid *cluuid,
295 struct obd_connect_data *data)
300 if (exp == NULL || obd == NULL || cluuid == NULL)
303 rc = mds_connect_internal(exp, data);
308 /* Establish a connection to the MDS.
310 * This will set up an export structure for the client to hold state data
311 * about that client, like open files, the last operation number it did
312 * on the server, etc.
314 static int mds_connect(const struct lu_env *env,
315 struct lustre_handle *conn, struct obd_device *obd,
316 struct obd_uuid *cluuid, struct obd_connect_data *data)
318 struct obd_export *exp;
319 struct mds_export_data *med;
320 struct mds_client_data *mcd = NULL;
324 if (!conn || !obd || !cluuid)
327 /* XXX There is a small race between checking the list and adding a
328 * new connection for the same UUID, but the real threat (list
329 * corruption when multiple different clients connect) is solved.
331 * There is a second race between adding the export to the list,
332 * and filling in the client data below. Hence skipping the case
333 * of NULL mcd above. We should already be controlling multiple
334 * connects at the client, and we can't hold the spinlock over
335 * memory allocations without risk of deadlocking.
337 rc = class_connect(conn, obd, cluuid);
340 exp = class_conn2export(conn);
342 med = &exp->exp_mds_data;
344 exp->exp_flvr.sf_rpc = SPTLRPC_FLVR_NULL;
346 rc = mds_connect_internal(exp, data);
350 OBD_ALLOC(mcd, sizeof(*mcd));
352 GOTO(out, rc = -ENOMEM);
354 memcpy(mcd->mcd_uuid, cluuid, sizeof(mcd->mcd_uuid));
357 rc = mds_client_add(obd, exp, -1);
363 OBD_FREE(mcd, sizeof(*mcd));
366 class_disconnect(exp);
368 class_export_put(exp);
374 int mds_init_export(struct obd_export *exp)
376 struct mds_export_data *med = &exp->exp_mds_data;
378 INIT_LIST_HEAD(&med->med_open_head);
379 spin_lock_init(&med->med_open_lock);
381 spin_lock(&exp->exp_lock);
382 exp->exp_connecting = 1;
383 spin_unlock(&exp->exp_lock);
388 static int mds_destroy_export(struct obd_export *export)
390 struct mds_export_data *med;
391 struct obd_device *obd = export->exp_obd;
392 struct mds_obd *mds = &obd->u.mds;
393 struct lvfs_run_ctxt saved;
394 struct lov_mds_md *lmm;
395 struct llog_cookie *logcookies;
399 med = &export->exp_mds_data;
400 target_destroy_export(export);
402 if (obd_uuid_equals(&export->exp_client_uuid, &obd->obd_uuid))
405 push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
406 /* Close any open files (which may also cause orphan unlinking). */
408 OBD_ALLOC(lmm, mds->mds_max_mdsize);
410 CWARN("%s: allocation failure during cleanup; can not force "
411 "close file handles on this service.\n", obd->obd_name);
412 GOTO(out, rc = -ENOMEM);
415 OBD_ALLOC(logcookies, mds->mds_max_cookiesize);
416 if (logcookies == NULL) {
417 CWARN("%s: allocation failure during cleanup; can not force "
418 "close file handles on this service.\n", obd->obd_name);
419 OBD_FREE(lmm, mds->mds_max_mdsize);
420 GOTO(out_lmm, rc = -ENOMEM);
423 spin_lock(&med->med_open_lock);
424 while (!list_empty(&med->med_open_head)) {
425 struct list_head *tmp = med->med_open_head.next;
426 struct mds_file_data *mfd =
427 list_entry(tmp, struct mds_file_data, mfd_list);
428 int lmm_size = mds->mds_max_mdsize;
429 umode_t mode = mfd->mfd_dentry->d_inode->i_mode;
432 /* Remove mfd handle so it can't be found again.
433 * We are consuming the mfd_list reference here. */
434 mds_mfd_unlink(mfd, 0);
435 spin_unlock(&med->med_open_lock);
437 /* If you change this message, be sure to update
438 * replay_single:test_46 */
439 CDEBUG(D_INODE|D_IOCTL, "%s: force closing file handle for "
440 "%.*s (ino %lu)\n", obd->obd_name,
441 mfd->mfd_dentry->d_name.len,mfd->mfd_dentry->d_name.name,
442 mfd->mfd_dentry->d_inode->i_ino);
444 rc = mds_get_md(obd, mfd->mfd_dentry->d_inode, lmm, &lmm_size, 1);
446 CWARN("mds_get_md failure, rc=%d\n", rc);
448 valid |= OBD_MD_FLEASIZE;
450 /* child orphan sem protects orphan_dec_test and
451 * is_orphan race, mds_mfd_close drops it */
452 MDS_DOWN_WRITE_ORPHAN_SEM(mfd->mfd_dentry->d_inode);
453 rc = mds_mfd_close(NULL, REQ_REC_OFF, obd, mfd,
454 !(export->exp_flags & OBD_OPT_FAILOVER),
455 lmm, lmm_size, logcookies,
456 mds->mds_max_cookiesize,
460 CDEBUG(D_INODE|D_IOCTL, "Error closing file: %d\n", rc);
462 if (valid & OBD_MD_FLCOOKIE) {
463 rc = mds_osc_destroy_orphan(obd, mode, lmm,
464 lmm_size, logcookies, 1);
466 CDEBUG(D_INODE, "%s: destroy of orphan failed,"
467 " rc = %d\n", obd->obd_name, rc);
470 valid &= ~OBD_MD_FLCOOKIE;
473 spin_lock(&med->med_open_lock);
475 spin_unlock(&med->med_open_lock);
477 OBD_FREE(logcookies, mds->mds_max_cookiesize);
479 OBD_FREE(lmm, mds->mds_max_mdsize);
481 pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
482 mds_client_free(export);
486 static int mds_disconnect(struct obd_export *exp)
492 class_export_get(exp);
494 /* Disconnect early so that clients can't keep using export */
495 rc = class_disconnect(exp);
496 if (exp->exp_obd->obd_namespace != NULL)
497 ldlm_cancel_locks_for_export(exp);
499 /* complete all outstanding replies */
500 spin_lock(&exp->exp_lock);
501 while (!list_empty(&exp->exp_outstanding_replies)) {
502 struct ptlrpc_reply_state *rs =
503 list_entry(exp->exp_outstanding_replies.next,
504 struct ptlrpc_reply_state, rs_exp_list);
505 struct ptlrpc_service *svc = rs->rs_service;
507 spin_lock(&svc->srv_lock);
508 list_del_init(&rs->rs_exp_list);
509 ptlrpc_schedule_difficult_reply(rs);
510 spin_unlock(&svc->srv_lock);
512 spin_unlock(&exp->exp_lock);
514 class_export_put(exp);
518 static int mds_getstatus(struct ptlrpc_request *req)
520 struct mds_obd *mds = mds_req2mds(req);
521 struct mds_body *body;
522 int rc, size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
525 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_GETSTATUS_PACK))
526 RETURN(req->rq_status = -ENOMEM);
527 rc = lustre_pack_reply(req, 2, size, NULL);
529 RETURN(req->rq_status = rc);
531 body = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF, sizeof(*body));
532 memcpy(&body->fid1, &mds->mds_rootfid, sizeof(body->fid1));
534 /* the last_committed and last_xid fields are filled in for all
535 * replies already - no need to do so here also.
540 /* get the LOV EA from @inode and store it into @md. It can be at most
541 * @size bytes, and @size is updated with the actual EA size.
542 * The EA size is also returned on success, and -ve errno on failure.
543 * If there is no EA then 0 is returned. */
544 int mds_get_md(struct obd_device *obd, struct inode *inode, void *md,
551 LOCK_INODE_MUTEX(inode);
552 rc = fsfilt_get_md(obd, inode, md, *size, "lov");
555 CERROR("Error %d reading eadata for ino %lu\n",
559 rc = mds_convert_lov_ea(obd, inode, md, lmm_size);
571 UNLOCK_INODE_MUTEX(inode);
577 /* Call with lock=1 if you want mds_pack_md to take the i_mutex.
578 * Call with lock=0 if the caller has already taken the i_mutex. */
579 int mds_pack_md(struct obd_device *obd, struct lustre_msg *msg, int offset,
580 struct mds_body *body, struct inode *inode, int lock)
582 struct mds_obd *mds = &obd->u.mds;
588 lmm = lustre_msg_buf(msg, offset, 0);
590 /* Some problem with getting eadata when I sized the reply
592 CDEBUG(D_INFO, "no space reserved for inode %lu MD\n",
596 lmm_size = lustre_msg_buflen(msg, offset);
598 /* I don't really like this, but it is a sanity check on the client
599 * MD request. However, if the client doesn't know how much space
600 * to reserve for the MD, it shouldn't be bad to have too much space.
602 if (lmm_size > mds->mds_max_mdsize) {
603 CWARN("Reading MD for inode %lu of %d bytes > max %d\n",
604 inode->i_ino, lmm_size, mds->mds_max_mdsize);
608 rc = mds_get_md(obd, inode, lmm, &lmm_size, lock);
610 if (S_ISDIR(inode->i_mode))
611 body->valid |= OBD_MD_FLDIREA;
613 body->valid |= OBD_MD_FLEASIZE;
614 body->eadatasize = lmm_size;
621 #ifdef CONFIG_FS_POSIX_ACL
623 int mds_pack_posix_acl(struct inode *inode, struct lustre_msg *repmsg,
624 struct mds_body *repbody, int repoff)
626 struct dentry de = { .d_inode = inode };
630 LASSERT(repbody->aclsize == 0);
631 LASSERT(lustre_msg_bufcount(repmsg) > repoff);
633 buflen = lustre_msg_buflen(repmsg, repoff);
637 if (!inode->i_op || !inode->i_op->getxattr)
640 rc = inode->i_op->getxattr(&de, MDS_XATTR_NAME_ACL_ACCESS,
641 lustre_msg_buf(repmsg, repoff, buflen),
645 repbody->aclsize = rc;
646 else if (rc != -ENODATA) {
647 CERROR("buflen %d, get acl: %d\n", buflen, rc);
652 repbody->valid |= OBD_MD_FLACL;
656 #define mds_pack_posix_acl(inode, repmsg, repbody, repoff) 0
659 int mds_pack_acl(struct mds_export_data *med, struct inode *inode,
660 struct lustre_msg *repmsg, struct mds_body *repbody,
663 return mds_pack_posix_acl(inode, repmsg, repbody, repoff);
666 static int mds_getattr_internal(struct obd_device *obd, struct dentry *dentry,
667 struct ptlrpc_request *req,
668 struct mds_body *reqbody, int reply_off)
670 struct mds_body *body;
671 struct inode *inode = dentry->d_inode;
678 body = lustre_msg_buf(req->rq_repmsg, reply_off, sizeof(*body));
679 LASSERT(body != NULL); /* caller prepped reply */
681 mds_pack_inode2fid(&body->fid1, inode);
682 body->flags = reqbody->flags; /* copy MDS_BFLAG_EXT_FLAGS if present */
683 mds_pack_inode2body(body, inode);
686 if ((S_ISREG(inode->i_mode) && (reqbody->valid & OBD_MD_FLEASIZE)) ||
687 (S_ISDIR(inode->i_mode) && (reqbody->valid & OBD_MD_FLDIREA))) {
688 rc = mds_pack_md(obd, req->rq_repmsg, reply_off, body,
691 /* If we have LOV EA data, the OST holds size, atime, mtime */
692 if (!(body->valid & OBD_MD_FLEASIZE) &&
693 !(body->valid & OBD_MD_FLDIREA))
694 body->valid |= (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS |
695 OBD_MD_FLATIME | OBD_MD_FLMTIME);
697 lustre_shrink_reply(req, reply_off, body->eadatasize, 0);
698 if (body->eadatasize)
700 } else if (S_ISLNK(inode->i_mode) &&
701 (reqbody->valid & OBD_MD_LINKNAME) != 0) {
702 char *symname = lustre_msg_buf(req->rq_repmsg, reply_off, 0);
705 LASSERT (symname != NULL); /* caller prepped reply */
706 len = lustre_msg_buflen(req->rq_repmsg, reply_off);
708 rc = inode->i_op->readlink(dentry, symname, len);
710 CERROR("readlink failed: %d\n", rc);
711 } else if (rc != len - 1) {
712 CERROR ("Unexpected readlink rc %d: expecting %d\n",
716 CDEBUG(D_INODE, "read symlink dest %s\n", symname);
717 body->valid |= OBD_MD_LINKNAME;
718 body->eadatasize = rc + 1;
719 symname[rc] = 0; /* NULL terminate */
723 } else if (reqbody->valid == OBD_MD_FLFLAGS &&
724 reqbody->flags & MDS_BFLAG_EXT_FLAGS) {
727 /* We only return the full set of flags on ioctl, otherwise we
728 * get enough flags from the inode in mds_pack_inode2body(). */
729 rc = fsfilt_iocontrol(obd, inode, NULL, EXT3_IOC_GETFLAGS,
732 body->flags = flags | MDS_BFLAG_EXT_FLAGS;
735 if (reqbody->valid & OBD_MD_FLMODEASIZE) {
736 struct mds_obd *mds = mds_req2mds(req);
737 body->max_cookiesize = mds->mds_max_cookiesize;
738 body->max_mdsize = mds->mds_max_mdsize;
739 body->valid |= OBD_MD_FLMODEASIZE;
745 #ifdef CONFIG_FS_POSIX_ACL
746 if ((req->rq_export->exp_connect_flags & OBD_CONNECT_ACL) &&
747 (reqbody->valid & OBD_MD_FLACL)) {
748 rc = mds_pack_acl(&req->rq_export->exp_mds_data,
749 inode, req->rq_repmsg,
752 lustre_shrink_reply(req, reply_off, body->aclsize, 0);
761 static int mds_getattr_pack_msg(struct ptlrpc_request *req, struct inode *inode,
764 struct mds_obd *mds = mds_req2mds(req);
765 struct mds_body *body;
766 int rc, bufcount = 2;
767 int size[4] = { sizeof(struct ptlrpc_body), sizeof(*body) };
770 LASSERT(offset == REQ_REC_OFF); /* non-intent */
772 body = lustre_msg_buf(req->rq_reqmsg, offset, sizeof(*body));
773 LASSERT(body != NULL); /* checked by caller */
774 LASSERT(lustre_req_swabbed(req, offset)); /* swabbed by caller */
776 if ((S_ISREG(inode->i_mode) && (body->valid & OBD_MD_FLEASIZE)) ||
777 (S_ISDIR(inode->i_mode) && (body->valid & OBD_MD_FLDIREA))) {
778 LOCK_INODE_MUTEX(inode);
779 rc = fsfilt_get_md(req->rq_export->exp_obd, inode, NULL, 0,
781 UNLOCK_INODE_MUTEX(inode);
782 CDEBUG(D_INODE, "got %d bytes MD data for inode %lu\n",
785 if (rc != -ENODATA) {
786 CERROR("error getting inode %lu MD: rc = %d\n",
791 } else if (rc > mds->mds_max_mdsize) {
793 CERROR("MD size %d larger than maximum possible %u\n",
794 rc, mds->mds_max_mdsize);
799 } else if (S_ISLNK(inode->i_mode) && (body->valid & OBD_MD_LINKNAME)) {
800 if (i_size_read(inode) + 1 != body->eadatasize)
801 CERROR("symlink size: %Lu, reply space: %d\n",
802 i_size_read(inode) + 1, body->eadatasize);
803 size[bufcount] = min_t(int, i_size_read(inode) + 1,
806 CDEBUG(D_INODE, "symlink size: %Lu, reply space: %d\n",
807 i_size_read(inode) + 1, body->eadatasize);
810 #ifdef CONFIG_FS_POSIX_ACL
811 if ((req->rq_export->exp_connect_flags & OBD_CONNECT_ACL) &&
812 (body->valid & OBD_MD_FLACL)) {
813 struct dentry de = { .d_inode = inode };
816 if (inode->i_op && inode->i_op->getxattr) {
817 rc = inode->i_op->getxattr(&de, MDS_XATTR_NAME_ACL_ACCESS,
821 if (rc != -ENODATA) {
822 CERROR("got acl size: %d\n", rc);
832 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_GETATTR_PACK)) {
833 CERROR("failed MDS_GETATTR_PACK test\n");
834 req->rq_status = -ENOMEM;
838 rc = lustre_pack_reply(req, bufcount, size, NULL);
847 static int mds_getattr_lock(struct ptlrpc_request *req, int offset,
848 int child_part, struct lustre_handle *child_lockh)
850 struct obd_device *obd = req->rq_export->exp_obd;
851 struct mds_obd *mds = &obd->u.mds;
852 struct ldlm_reply *rep = NULL;
853 struct lvfs_run_ctxt saved;
854 struct mds_body *body;
855 struct dentry *dparent = NULL, *dchild = NULL;
856 struct lvfs_ucred uc = {0,};
857 struct lustre_handle parent_lockh;
859 int rc = 0, cleanup_phase = 0, resent_req = 0;
863 LASSERT(!strcmp(obd->obd_type->typ_name, LUSTRE_MDS_NAME));
865 /* Swab now, before anyone looks inside the request */
866 body = lustre_swab_reqbuf(req, offset, sizeof(*body),
867 lustre_swab_mds_body);
869 CERROR("Can't swab mds_body\n");
873 lustre_set_req_swabbed(req, offset + 1);
874 name = lustre_msg_string(req->rq_reqmsg, offset + 1, 0);
876 CERROR("Can't unpack name\n");
879 namesize = lustre_msg_buflen(req->rq_reqmsg, offset + 1);
880 /* namesize less than 2 means we have empty name, probably came from
881 revalidate by cfid, so no point in having name to be set */
885 rc = mds_init_ucred(&uc, req, offset);
889 LASSERT(offset == REQ_REC_OFF || offset == DLM_INTENT_REC_OFF);
890 /* if requests were at offset 2, the getattr reply goes back at 1 */
891 if (offset == DLM_INTENT_REC_OFF) {
892 rep = lustre_msg_buf(req->rq_repmsg, DLM_LOCKREPLY_OFF,
894 offset = DLM_REPLY_REC_OFF;
897 push_ctxt(&saved, &obd->obd_lvfs_ctxt, &uc);
898 cleanup_phase = 1; /* kernel context */
899 intent_set_disposition(rep, DISP_LOOKUP_EXECD);
901 /* FIXME: handle raw lookup */
903 if (body->valid == OBD_MD_FLID) {
904 struct mds_body *mds_reply;
905 int size = sizeof(*mds_reply);
907 // The user requested ONLY the inode number, so do a raw lookup
908 rc = lustre_pack_reply(req, 1, &size, NULL);
910 CERROR("out of memory\n");
914 rc = dir->i_op->lookup_raw(dir, name, namesize - 1, &inum);
916 mds_reply = lustre_msg_buf(req->rq_repmsg, offset,
918 mds_reply->fid1.id = inum;
919 mds_reply->valid = OBD_MD_FLID;
924 if (lustre_handle_is_used(child_lockh)) {
925 LASSERT(lustre_msg_get_flags(req->rq_reqmsg) & MSG_RESENT);
929 if (resent_req == 0) {
931 OBD_FAIL_TIMEOUT(OBD_FAIL_MDS_RESEND, obd_timeout * 2);
932 rc = mds_get_parent_child_locked(obd, &obd->u.mds,
936 MDS_INODELOCK_UPDATE,
938 child_lockh, &dchild,
941 /* For revalidate by fid we always take UPDATE lock */
942 dchild = mds_fid2locked_dentry(obd, &body->fid2, NULL,
947 rc = PTR_ERR(dchild);
952 struct ldlm_lock *granted_lock;
953 struct ll_fid child_fid;
954 struct ldlm_resource *res;
955 DEBUG_REQ(D_DLMTRACE, req, "resent, not enqueuing new locks");
956 granted_lock = ldlm_handle2lock(child_lockh);
957 LASSERTF(granted_lock != NULL, LPU64"/%u lockh "LPX64"\n",
958 body->fid1.id, body->fid1.generation,
959 child_lockh->cookie);
962 res = granted_lock->l_resource;
963 child_fid.id = res->lr_name.name[0];
964 child_fid.generation = res->lr_name.name[1];
965 dchild = mds_fid2dentry(&obd->u.mds, &child_fid, NULL);
966 LASSERT(!IS_ERR(dchild));
967 LDLM_LOCK_PUT(granted_lock);
970 cleanup_phase = 2; /* dchild, dparent, locks */
972 if (dchild->d_inode == NULL) {
973 intent_set_disposition(rep, DISP_LOOKUP_NEG);
974 /* in the intent case, the policy clears this error:
975 the disposition is enough */
976 GOTO(cleanup, rc = -ENOENT);
978 intent_set_disposition(rep, DISP_LOOKUP_POS);
981 if (req->rq_repmsg == NULL) {
982 rc = mds_getattr_pack_msg(req, dchild->d_inode, offset);
984 CERROR ("mds_getattr_pack_msg: %d\n", rc);
989 rc = mds_getattr_internal(obd, dchild, req, body, offset);
990 GOTO(cleanup, rc); /* returns the lock to the client */
993 switch (cleanup_phase) {
995 if (resent_req == 0) {
996 if (rc && dchild->d_inode)
997 ldlm_lock_decref(child_lockh, LCK_CR);
999 ldlm_lock_decref(&parent_lockh, LCK_CR);
1005 pop_ctxt(&saved, &obd->obd_lvfs_ctxt, &uc);
1007 mds_exit_ucred(&uc, mds);
1008 if (req->rq_reply_state == NULL) {
1009 int rc2 = lustre_pack_reply(req, 1, NULL, NULL);
1012 req->rq_status = rc;
1018 static int mds_getattr(struct ptlrpc_request *req, int offset)
1020 struct mds_obd *mds = mds_req2mds(req);
1021 struct obd_device *obd = req->rq_export->exp_obd;
1022 struct lvfs_run_ctxt saved;
1024 struct mds_body *body;
1025 struct lvfs_ucred uc = {0,};
1029 OBD_COUNTER_INCREMENT(obd, getattr);
1031 body = lustre_swab_reqbuf(req, offset, sizeof(*body),
1032 lustre_swab_mds_body);
1036 rc = mds_init_ucred(&uc, req, offset);
1038 GOTO(out_ucred, rc);
1040 push_ctxt(&saved, &obd->obd_lvfs_ctxt, &uc);
1041 de = mds_fid2dentry(mds, &body->fid1, NULL);
1043 rc = req->rq_status = PTR_ERR(de);
1047 rc = mds_getattr_pack_msg(req, de->d_inode, offset);
1049 CERROR("mds_getattr_pack_msg: %d\n", rc);
1053 req->rq_status = mds_getattr_internal(obd, de, req, body,
1059 pop_ctxt(&saved, &obd->obd_lvfs_ctxt, &uc);
1061 if (req->rq_reply_state == NULL) {
1062 int rc2 = lustre_pack_reply(req, 1, NULL, NULL);
1065 req->rq_status = rc;
1067 mds_exit_ucred(&uc, mds);
1071 static int mds_obd_statfs(struct obd_device *obd, struct obd_statfs *osfs,
1072 __u64 max_age, __u32 flags)
1076 spin_lock(&obd->obd_osfs_lock);
1077 rc = fsfilt_statfs(obd, obd->u.obt.obt_sb, max_age);
1079 memcpy(osfs, &obd->obd_osfs, sizeof(*osfs));
1080 spin_unlock(&obd->obd_osfs_lock);
1085 static int mds_statfs(struct ptlrpc_request *req)
1087 struct obd_device *obd = req->rq_export->exp_obd;
1088 int rc, size[2] = { sizeof(struct ptlrpc_body),
1089 sizeof(struct obd_statfs) };
1092 /* This will trigger a watchdog timeout */
1093 OBD_FAIL_TIMEOUT(OBD_FAIL_MDS_STATFS_LCW_SLEEP,
1094 (MDS_SERVICE_WATCHDOG_TIMEOUT / 1000) + 1);
1095 OBD_COUNTER_INCREMENT(obd, statfs);
1097 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_STATFS_PACK))
1098 GOTO(out, rc = -ENOMEM);
1099 rc = lustre_pack_reply(req, 2, size, NULL);
1103 /* We call this so that we can cache a bit - 1 jiffie worth */
1104 rc = mds_obd_statfs(obd, lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
1105 size[REPLY_REC_OFF]),
1106 cfs_time_current_64() - HZ, 0);
1108 CERROR("mds_obd_statfs failed: rc %d\n", rc);
1114 req->rq_status = rc;
1118 static int mds_sync(struct ptlrpc_request *req, int offset)
1120 struct obd_device *obd = req->rq_export->exp_obd;
1121 struct mds_obd *mds = &obd->u.mds;
1122 struct mds_body *body;
1123 int rc, size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
1126 body = lustre_swab_reqbuf(req, offset, sizeof(*body),
1127 lustre_swab_mds_body);
1129 GOTO(out, rc = -EFAULT);
1131 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_SYNC_PACK))
1132 GOTO(out, rc = -ENOMEM);
1133 rc = lustre_pack_reply(req, 2, size, NULL);
1137 rc = fsfilt_sync(obd, obd->u.obt.obt_sb);
1138 if (rc == 0 && body->fid1.id != 0) {
1141 de = mds_fid2dentry(mds, &body->fid1, NULL);
1143 GOTO(out, rc = PTR_ERR(de));
1145 body = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
1147 mds_pack_inode2fid(&body->fid1, de->d_inode);
1148 mds_pack_inode2body(body, de->d_inode);
1154 req->rq_status = rc;
1158 /* mds_readpage does not take a DLM lock on the inode, because the client must
1159 * already have a PR lock.
1161 * If we were to take another one here, a deadlock will result, if another
1162 * thread is already waiting for a PW lock. */
1163 static int mds_readpage(struct ptlrpc_request *req, int offset)
1165 struct obd_device *obd = req->rq_export->exp_obd;
1166 struct mds_obd *mds = &obd->u.mds;
1167 struct vfsmount *mnt;
1170 struct mds_body *body, *repbody;
1171 struct lvfs_run_ctxt saved;
1172 int rc, size[2] = { sizeof(struct ptlrpc_body), sizeof(*repbody) };
1173 struct lvfs_ucred uc = {0,};
1176 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_READPAGE_PACK))
1178 rc = lustre_pack_reply(req, 2, size, NULL);
1182 body = lustre_swab_reqbuf(req, offset, sizeof(*body),
1183 lustre_swab_mds_body);
1185 GOTO (out, rc = -EFAULT);
1187 rc = mds_init_ucred(&uc, req, offset);
1191 push_ctxt(&saved, &obd->obd_lvfs_ctxt, &uc);
1192 de = mds_fid2dentry(&obd->u.mds, &body->fid1, &mnt);
1194 GOTO(out_pop, rc = PTR_ERR(de));
1196 CDEBUG(D_INODE, "ino %lu\n", de->d_inode->i_ino);
1198 file = dentry_open(de, mnt, O_RDONLY | O_LARGEFILE);
1199 /* note: in case of an error, dentry_open puts dentry */
1201 GOTO(out_pop, rc = PTR_ERR(file));
1203 /* body->size is actually the offset -eeb */
1204 if ((body->size & (de->d_inode->i_sb->s_blocksize - 1)) != 0) {
1205 CERROR("offset "LPU64" not on a block boundary of %lu\n",
1206 body->size, de->d_inode->i_sb->s_blocksize);
1207 GOTO(out_file, rc = -EFAULT);
1210 /* body->nlink is actually the #bytes to read -eeb */
1211 if (body->nlink & (de->d_inode->i_sb->s_blocksize - 1)) {
1212 CERROR("size %u is not multiple of blocksize %lu\n",
1213 body->nlink, de->d_inode->i_sb->s_blocksize);
1214 GOTO(out_file, rc = -EFAULT);
1217 repbody = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
1219 repbody->size = i_size_read(file->f_dentry->d_inode);
1220 repbody->valid = OBD_MD_FLSIZE;
1222 /* to make this asynchronous make sure that the handling function
1223 doesn't send a reply when this function completes. Instead a
1224 callback function would send the reply */
1225 /* body->size is actually the offset -eeb */
1226 rc = mds_sendpage(req, file, body->size, body->nlink);
1229 filp_close(file, 0);
1231 pop_ctxt(&saved, &obd->obd_lvfs_ctxt, &uc);
1233 mds_exit_ucred(&uc, mds);
1234 req->rq_status = rc;
1238 int mds_reint(struct ptlrpc_request *req, int offset,
1239 struct lustre_handle *lockh)
1241 struct mds_update_record *rec; /* 116 bytes on the stack? no sir! */
1244 OBD_ALLOC(rec, sizeof(*rec));
1248 rc = mds_update_unpack(req, offset, rec);
1249 if (rc || OBD_FAIL_CHECK(OBD_FAIL_MDS_REINT_UNPACK)) {
1250 CERROR("invalid record\n");
1251 GOTO(out, req->rq_status = -EINVAL);
1254 /* rc will be used to interrupt a for loop over multiple records */
1255 rc = mds_reint_rec(rec, offset, req, lockh);
1257 OBD_FREE(rec, sizeof(*rec));
1261 int mds_filter_recovery_request(struct ptlrpc_request *req,
1262 struct obd_device *obd, int *process)
1264 switch (lustre_msg_get_opc(req->rq_reqmsg)) {
1265 case MDS_CONNECT: /* This will never get here, but for completeness. */
1266 case OST_CONNECT: /* This will never get here, but for completeness. */
1267 case MDS_DISCONNECT:
1268 case OST_DISCONNECT:
1273 case MDS_DONE_WRITING:
1274 case MDS_SYNC: /* used in unmounting */
1280 *process = target_queue_recovery_request(req, obd);
1284 DEBUG_REQ(D_ERROR, req, "not permitted during recovery");
1289 EXPORT_SYMBOL(mds_filter_recovery_request);
1291 static char *reint_names[] = {
1292 [REINT_SETATTR] "setattr",
1293 [REINT_CREATE] "create",
1294 [REINT_LINK] "link",
1295 [REINT_UNLINK] "unlink",
1296 [REINT_RENAME] "rename",
1297 [REINT_OPEN] "open",
1300 static int mds_set_info_rpc(struct obd_export *exp, struct ptlrpc_request *req)
1303 int keylen, vallen, rc = 0;
1306 key = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, 1);
1308 DEBUG_REQ(D_HA, req, "no set_info key");
1311 keylen = lustre_msg_buflen(req->rq_reqmsg, REQ_REC_OFF);
1313 val = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF + 1, 0);
1314 vallen = lustre_msg_buflen(req->rq_reqmsg, REQ_REC_OFF + 1);
1316 rc = lustre_pack_reply(req, 1, NULL, NULL);
1320 lustre_msg_set_status(req->rq_repmsg, 0);
1322 if (KEY_IS("read-only")) {
1323 if (val == NULL || vallen < sizeof(__u32)) {
1324 DEBUG_REQ(D_HA, req, "no set_info val");
1329 exp->exp_connect_flags |= OBD_CONNECT_RDONLY;
1331 exp->exp_connect_flags &= ~OBD_CONNECT_RDONLY;
1339 static int mds_handle_quotacheck(struct ptlrpc_request *req)
1341 struct obd_quotactl *oqctl;
1345 oqctl = lustre_swab_reqbuf(req, REQ_REC_OFF, sizeof(*oqctl),
1346 lustre_swab_obd_quotactl);
1350 rc = lustre_pack_reply(req, 1, NULL, NULL);
1354 req->rq_status = obd_quotacheck(req->rq_export, oqctl);
1358 static int mds_handle_quotactl(struct ptlrpc_request *req)
1360 struct obd_quotactl *oqctl, *repoqc;
1361 int rc, size[2] = { sizeof(struct ptlrpc_body), sizeof(*repoqc) };
1364 oqctl = lustre_swab_reqbuf(req, REQ_REC_OFF, sizeof(*oqctl),
1365 lustre_swab_obd_quotactl);
1369 rc = lustre_pack_reply(req, 2, size, NULL);
1373 repoqc = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF, sizeof(*repoqc));
1375 req->rq_status = obd_quotactl(req->rq_export, oqctl);
1380 int mds_msg_check_version(struct lustre_msg *msg)
1384 switch (lustre_msg_get_opc(msg)) {
1386 case MDS_DISCONNECT:
1389 case SEC_CTX_INIT_CONT:
1391 rc = lustre_msg_check_version(msg, LUSTRE_OBD_VERSION);
1393 CERROR("bad opc %u version %08x, expecting %08x\n",
1394 lustre_msg_get_opc(msg),
1395 lustre_msg_get_version(msg),
1396 LUSTRE_OBD_VERSION);
1400 case MDS_GETATTR_NAME:
1407 case MDS_DONE_WRITING:
1413 case MDS_QUOTACHECK:
1419 rc = lustre_msg_check_version(msg, LUSTRE_MDS_VERSION);
1421 CERROR("bad opc %u version %08x, expecting %08x\n",
1422 lustre_msg_get_opc(msg),
1423 lustre_msg_get_version(msg),
1424 LUSTRE_MDS_VERSION);
1428 case LDLM_BL_CALLBACK:
1429 case LDLM_CP_CALLBACK:
1430 rc = lustre_msg_check_version(msg, LUSTRE_DLM_VERSION);
1432 CERROR("bad opc %u version %08x, expecting %08x\n",
1433 lustre_msg_get_opc(msg),
1434 lustre_msg_get_version(msg),
1435 LUSTRE_DLM_VERSION);
1437 case OBD_LOG_CANCEL:
1438 case LLOG_ORIGIN_HANDLE_CREATE:
1439 case LLOG_ORIGIN_HANDLE_NEXT_BLOCK:
1440 case LLOG_ORIGIN_HANDLE_READ_HEADER:
1441 case LLOG_ORIGIN_HANDLE_CLOSE:
1442 case LLOG_ORIGIN_HANDLE_DESTROY:
1443 case LLOG_ORIGIN_HANDLE_PREV_BLOCK:
1445 rc = lustre_msg_check_version(msg, LUSTRE_LOG_VERSION);
1447 CERROR("bad opc %u version %08x, expecting %08x\n",
1448 lustre_msg_get_opc(msg),
1449 lustre_msg_get_version(msg),
1450 LUSTRE_LOG_VERSION);
1453 CERROR("MDS unknown opcode %d\n", lustre_msg_get_opc(msg));
1458 EXPORT_SYMBOL(mds_msg_check_version);
1460 int mds_handle(struct ptlrpc_request *req)
1462 int should_process, fail = OBD_FAIL_MDS_ALL_REPLY_NET;
1464 struct mds_obd *mds = NULL; /* quell gcc overwarning */
1465 struct obd_device *obd = NULL;
1468 if (OBD_FAIL_CHECK_ORSET(OBD_FAIL_MDS_ALL_REQUEST_NET, OBD_FAIL_ONCE))
1471 LASSERT(current->journal_info == NULL);
1473 rc = mds_msg_check_version(req->rq_reqmsg);
1475 CERROR("MDS drop mal-formed request\n");
1479 /* XXX identical to OST */
1480 if (lustre_msg_get_opc(req->rq_reqmsg) != MDS_CONNECT) {
1481 struct mds_export_data *med;
1484 if (req->rq_export == NULL) {
1485 CERROR("operation %d on unconnected MDS from %s\n",
1486 lustre_msg_get_opc(req->rq_reqmsg),
1487 libcfs_id2str(req->rq_peer));
1488 req->rq_status = -ENOTCONN;
1489 GOTO(out, rc = -ENOTCONN);
1492 med = &req->rq_export->exp_mds_data;
1493 obd = req->rq_export->exp_obd;
1494 mds = mds_req2mds(req);
1496 /* sanity check: if the xid matches, the request must
1497 * be marked as a resent or replayed */
1498 if (req->rq_xid == le64_to_cpu(med->med_mcd->mcd_last_xid) ||
1499 req->rq_xid == le64_to_cpu(med->med_mcd->mcd_last_close_xid))
1500 if (!(lustre_msg_get_flags(req->rq_reqmsg) &
1501 (MSG_RESENT | MSG_REPLAY))) {
1502 CERROR("rq_xid "LPU64" matches last_xid, "
1503 "expected RESENT flag\n",
1505 req->rq_status = -ENOTCONN;
1506 GOTO(out, rc = -EFAULT);
1508 /* else: note the opposite is not always true; a
1509 * RESENT req after a failover will usually not match
1510 * the last_xid, since it was likely never
1511 * committed. A REPLAYed request will almost never
1512 * match the last xid, however it could for a
1513 * committed, but still retained, open. */
1515 /* Check for aborted recovery. */
1516 spin_lock_bh(&obd->obd_processing_task_lock);
1517 recovering = obd->obd_recovering;
1518 spin_unlock_bh(&obd->obd_processing_task_lock);
1520 rc = mds_filter_recovery_request(req, obd,
1522 if (rc || !should_process)
1524 else if (should_process < 0) {
1525 req->rq_status = should_process;
1526 rc = ptlrpc_error(req);
1532 switch (lustre_msg_get_opc(req->rq_reqmsg)) {
1534 DEBUG_REQ(D_INODE, req, "connect");
1535 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_CONNECT_NET))
1537 rc = target_handle_connect(req);
1539 /* Now that we have an export, set mds. */
1541 * XXX nikita: these assignments are useless: mds is
1542 * never used below, and obd is only used for
1543 * MSG_LAST_REPLAY case, which never happens for
1546 obd = req->rq_export->exp_obd;
1547 mds = mds_req2mds(req);
1551 case MDS_DISCONNECT:
1552 DEBUG_REQ(D_INODE, req, "disconnect");
1553 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_DISCONNECT_NET))
1555 rc = target_handle_disconnect(req);
1556 req->rq_status = rc; /* superfluous? */
1560 DEBUG_REQ(D_INODE, req, "getstatus");
1561 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_GETSTATUS_NET))
1563 rc = mds_getstatus(req);
1567 DEBUG_REQ(D_INODE, req, "getattr");
1568 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_GETATTR_NET))
1570 rc = mds_getattr(req, REQ_REC_OFF);
1574 DEBUG_REQ(D_INODE, req, "setxattr");
1575 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_SETXATTR_NET))
1577 rc = mds_setxattr(req);
1581 DEBUG_REQ(D_INODE, req, "getxattr");
1582 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_GETXATTR_NET))
1584 rc = mds_getxattr(req);
1587 case MDS_GETATTR_NAME: {
1588 struct lustre_handle lockh = { 0 };
1589 DEBUG_REQ(D_INODE, req, "getattr_name");
1590 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_GETATTR_NAME_NET))
1593 /* If this request gets a reconstructed reply, we won't be
1594 * acquiring any new locks in mds_getattr_lock, so we don't
1597 rc = mds_getattr_lock(req, REQ_REC_OFF, MDS_INODELOCK_UPDATE,
1599 /* this non-intent call (from an ioctl) is special */
1600 req->rq_status = rc;
1601 if (rc == 0 && lustre_handle_is_used(&lockh))
1602 ldlm_lock_decref(&lockh, LCK_CR);
1606 DEBUG_REQ(D_INODE, req, "statfs");
1607 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_STATFS_NET))
1609 rc = mds_statfs(req);
1613 DEBUG_REQ(D_INODE, req, "readpage");
1614 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_READPAGE_NET))
1616 rc = mds_readpage(req, REQ_REC_OFF);
1618 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_SENDPAGE)) {
1625 __u32 *opcp = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF,
1629 int size[4] = { sizeof(struct ptlrpc_body),
1630 sizeof(struct mds_body),
1631 mds->mds_max_mdsize,
1632 mds->mds_max_cookiesize };
1635 /* NB only peek inside req now; mds_reint() will swab it */
1637 CERROR ("Can't inspect opcode\n");
1642 if (lustre_msg_swabbed(req->rq_reqmsg))
1645 DEBUG_REQ(D_INODE, req, "reint %d (%s)", opc,
1646 (opc < sizeof(reint_names) / sizeof(reint_names[0]) ||
1647 reint_names[opc] == NULL) ? reint_names[opc] :
1651 op = PTLRPC_LAST_CNTR + MDS_REINT_CREATE;
1654 op = PTLRPC_LAST_CNTR + MDS_REINT_LINK;
1657 op = PTLRPC_LAST_CNTR + MDS_REINT_OPEN;
1660 op = PTLRPC_LAST_CNTR + MDS_REINT_SETATTR;
1663 op = PTLRPC_LAST_CNTR + MDS_REINT_RENAME;
1666 op = PTLRPC_LAST_CNTR + MDS_REINT_UNLINK;
1673 if (op && req->rq_rqbd->rqbd_service->srv_stats)
1674 lprocfs_counter_incr(
1675 req->rq_rqbd->rqbd_service->srv_stats, op);
1677 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_REINT_NET))
1680 if (opc == REINT_UNLINK || opc == REINT_RENAME)
1682 else if (opc == REINT_OPEN)
1687 rc = lustre_pack_reply(req, bufcount, size, NULL);
1691 rc = mds_reint(req, REQ_REC_OFF, NULL);
1692 fail = OBD_FAIL_MDS_REINT_NET_REP;
1697 DEBUG_REQ(D_INODE, req, "close");
1698 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_CLOSE_NET))
1700 rc = mds_close(req, REQ_REC_OFF);
1701 fail = OBD_FAIL_MDS_CLOSE_NET_REP;
1704 case MDS_DONE_WRITING:
1705 DEBUG_REQ(D_INODE, req, "done_writing");
1706 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_DONE_WRITING_NET))
1708 rc = mds_done_writing(req, REQ_REC_OFF);
1712 DEBUG_REQ(D_INODE, req, "pin");
1713 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_PIN_NET))
1715 rc = mds_pin(req, REQ_REC_OFF);
1719 DEBUG_REQ(D_INODE, req, "sync");
1720 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_SYNC_NET))
1722 rc = mds_sync(req, REQ_REC_OFF);
1726 DEBUG_REQ(D_INODE, req, "set_info");
1727 rc = mds_set_info_rpc(req->rq_export, req);
1730 case MDS_QUOTACHECK:
1731 DEBUG_REQ(D_INODE, req, "quotacheck");
1732 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_QUOTACHECK_NET))
1734 rc = mds_handle_quotacheck(req);
1738 DEBUG_REQ(D_INODE, req, "quotactl");
1739 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_QUOTACTL_NET))
1741 rc = mds_handle_quotactl(req);
1745 DEBUG_REQ(D_INODE, req, "ping");
1746 rc = target_handle_ping(req);
1749 case OBD_LOG_CANCEL:
1750 CDEBUG(D_INODE, "log cancel\n");
1751 if (OBD_FAIL_CHECK(OBD_FAIL_OBD_LOG_CANCEL_NET))
1753 rc = -ENOTSUPP; /* la la la */
1757 DEBUG_REQ(D_INODE, req, "enqueue");
1758 if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_ENQUEUE))
1760 rc = ldlm_handle_enqueue(req, ldlm_server_completion_ast,
1761 ldlm_server_blocking_ast, NULL);
1762 fail = OBD_FAIL_LDLM_REPLY;
1765 DEBUG_REQ(D_INODE, req, "convert");
1766 if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_CONVERT))
1768 rc = ldlm_handle_convert(req);
1770 case LDLM_BL_CALLBACK:
1771 case LDLM_CP_CALLBACK:
1772 DEBUG_REQ(D_INODE, req, "callback");
1773 CERROR("callbacks should not happen on MDS\n");
1775 if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_BL_CALLBACK))
1778 case LLOG_ORIGIN_HANDLE_CREATE:
1779 DEBUG_REQ(D_INODE, req, "llog_init");
1780 if (OBD_FAIL_CHECK(OBD_FAIL_OBD_LOGD_NET))
1782 rc = llog_origin_handle_create(req);
1784 case LLOG_ORIGIN_HANDLE_DESTROY:
1785 DEBUG_REQ(D_INODE, req, "llog_init");
1786 if (OBD_FAIL_CHECK(OBD_FAIL_OBD_LOGD_NET))
1788 rc = llog_origin_handle_destroy(req);
1790 case LLOG_ORIGIN_HANDLE_NEXT_BLOCK:
1791 DEBUG_REQ(D_INODE, req, "llog next block");
1792 if (OBD_FAIL_CHECK(OBD_FAIL_OBD_LOGD_NET))
1794 rc = llog_origin_handle_next_block(req);
1796 case LLOG_ORIGIN_HANDLE_PREV_BLOCK:
1797 DEBUG_REQ(D_INODE, req, "llog prev block");
1798 if (OBD_FAIL_CHECK(OBD_FAIL_OBD_LOGD_NET))
1800 rc = llog_origin_handle_prev_block(req);
1802 case LLOG_ORIGIN_HANDLE_READ_HEADER:
1803 DEBUG_REQ(D_INODE, req, "llog read header");
1804 if (OBD_FAIL_CHECK(OBD_FAIL_OBD_LOGD_NET))
1806 rc = llog_origin_handle_read_header(req);
1808 case LLOG_ORIGIN_HANDLE_CLOSE:
1809 DEBUG_REQ(D_INODE, req, "llog close");
1810 if (OBD_FAIL_CHECK(OBD_FAIL_OBD_LOGD_NET))
1812 rc = llog_origin_handle_close(req);
1815 DEBUG_REQ(D_INODE, req, "llog catinfo");
1816 if (OBD_FAIL_CHECK(OBD_FAIL_OBD_LOGD_NET))
1818 rc = llog_catinfo(req);
1821 req->rq_status = -ENOTSUPP;
1822 rc = ptlrpc_error(req);
1826 LASSERT(current->journal_info == NULL);
1828 /* If we're DISCONNECTing, the mds_export_data is already freed */
1829 if (!rc && lustre_msg_get_opc(req->rq_reqmsg) != MDS_DISCONNECT) {
1830 struct mds_export_data *med = &req->rq_export->exp_mds_data;
1832 /* I don't think last_xid is used for anyway, so I'm not sure
1833 if we need to care about last_close_xid here.*/
1834 lustre_msg_set_last_xid(req->rq_repmsg,
1835 le64_to_cpu(med->med_mcd->mcd_last_xid));
1837 target_committed_to_req(req);
1843 target_send_reply(req, rc, fail);
1847 /* Update the server data on disk. This stores the new mount_count and
1848 * also the last_rcvd value to disk. If we don't have a clean shutdown,
1849 * then the server last_rcvd value may be less than that of the clients.
1850 * This will alert us that we may need to do client recovery.
1852 * Also assumes for mds_last_transno that we are not modifying it (no locking).
1854 int mds_update_server_data(struct obd_device *obd, int force_sync)
1856 struct mds_obd *mds = &obd->u.mds;
1857 struct lr_server_data *lsd = mds->mds_server_data;
1858 struct file *filp = mds->mds_rcvd_filp;
1859 struct lvfs_run_ctxt saved;
1864 CDEBUG(D_SUPER, "MDS mount_count is "LPU64", last_transno is "LPU64"\n",
1865 mds->mds_mount_count, mds->mds_last_transno);
1867 spin_lock(&mds->mds_transno_lock);
1868 lsd->lsd_last_transno = cpu_to_le64(mds->mds_last_transno);
1869 spin_unlock(&mds->mds_transno_lock);
1871 push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
1872 rc = fsfilt_write_record(obd, filp, lsd, sizeof(*lsd), &off,force_sync);
1873 pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
1875 CERROR("error writing MDS server data: rc = %d\n", rc);
1879 static void fsoptions_to_mds_flags(struct mds_obd *mds, char *options)
1889 while (*p && *p != ',')
1893 if (len == sizeof("user_xattr") - 1 &&
1894 memcmp(options, "user_xattr", len) == 0) {
1895 mds->mds_fl_user_xattr = 1;
1896 LCONSOLE_INFO("Enabling user_xattr\n");
1897 } else if (len == sizeof("nouser_xattr") - 1 &&
1898 memcmp(options, "nouser_xattr", len) == 0) {
1899 mds->mds_fl_user_xattr = 0;
1900 LCONSOLE_INFO("Disabling user_xattr\n");
1901 } else if (len == sizeof("acl") - 1 &&
1902 memcmp(options, "acl", len) == 0) {
1903 #ifdef CONFIG_FS_POSIX_ACL
1904 mds->mds_fl_acl = 1;
1905 LCONSOLE_INFO("Enabling ACL\n");
1907 CWARN("ignoring unsupported acl mount option\n");
1909 } else if (len == sizeof("noacl") - 1 &&
1910 memcmp(options, "noacl", len) == 0) {
1911 #ifdef CONFIG_FS_POSIX_ACL
1912 mds->mds_fl_acl = 0;
1913 LCONSOLE_INFO("Disabling ACL\n");
1920 static int mds_lov_presetup (struct mds_obd *mds, struct lustre_cfg *lcfg)
1925 if (lcfg->lcfg_bufcount >= 4 && LUSTRE_CFG_BUFLEN(lcfg, 3) > 0) {
1928 ll_generate_random_uuid(uuid);
1929 class_uuid_unparse(uuid, &mds->mds_lov_uuid);
1931 OBD_ALLOC(mds->mds_profile, LUSTRE_CFG_BUFLEN(lcfg, 3));
1932 if (mds->mds_profile == NULL)
1935 strncpy(mds->mds_profile, lustre_cfg_string(lcfg, 3),
1936 LUSTRE_CFG_BUFLEN(lcfg, 3));
1941 /* mount the file system (secretly). lustre_cfg parameters are:
1947 static int mds_setup(struct obd_device *obd, struct lustre_cfg* lcfg)
1949 struct lprocfs_static_vars lvars;
1950 struct mds_obd *mds = &obd->u.mds;
1951 struct lustre_mount_info *lmi;
1952 struct vfsmount *mnt;
1953 struct lustre_sb_info *lsi;
1954 struct obd_uuid uuid;
1961 /* setup 1:/dev/loop/0 2:ext3 3:mdsA 4:errors=remount-ro,iopen_nopriv */
1963 CLASSERT(offsetof(struct obd_device, u.obt) ==
1964 offsetof(struct obd_device, u.mds.mds_obt));
1966 if (lcfg->lcfg_bufcount < 3)
1969 if (LUSTRE_CFG_BUFLEN(lcfg, 1) == 0 || LUSTRE_CFG_BUFLEN(lcfg, 2) == 0)
1972 lmi = server_get_mount(obd->obd_name);
1974 CERROR("Not mounted in lustre_fill_super?\n");
1978 /* We mounted in lustre_fill_super.
1979 lcfg bufs 1, 2, 4 (device, fstype, mount opts) are ignored.*/
1981 lsi = s2lsi(lmi->lmi_sb);
1982 fsoptions_to_mds_flags(mds, lsi->lsi_ldd->ldd_mount_opts);
1983 fsoptions_to_mds_flags(mds, lsi->lsi_lmd->lmd_opts);
1985 obd->obd_fsops = fsfilt_get_ops(MT_STR(lsi->lsi_ldd));
1986 if (IS_ERR(obd->obd_fsops))
1987 GOTO(err_put, rc = PTR_ERR(obd->obd_fsops));
1989 CDEBUG(D_SUPER, "%s: mnt = %p\n", lustre_cfg_string(lcfg, 1), mnt);
1991 LASSERT(!lvfs_check_rdonly(lvfs_sbdev(mnt->mnt_sb)));
1993 sema_init(&mds->mds_epoch_sem, 1);
1994 spin_lock_init(&mds->mds_transno_lock);
1995 mds->mds_max_mdsize = sizeof(struct lov_mds_md);
1996 mds->mds_max_cookiesize = sizeof(struct llog_cookie);
1997 mds->mds_atime_diff = MAX_ATIME_DIFF;
1998 mds->mds_evict_ost_nids = 1;
2000 sprintf(ns_name, "mds-%s", obd->obd_uuid.uuid);
2001 obd->obd_namespace = ldlm_namespace_new(ns_name, LDLM_NAMESPACE_SERVER,
2002 LDLM_NAMESPACE_GREEDY);
2003 if (obd->obd_namespace == NULL) {
2005 GOTO(err_ops, rc = -ENOMEM);
2007 ldlm_register_intent(obd->obd_namespace, mds_intent_policy);
2009 lprocfs_mds_init_vars(&lvars);
2010 if (lprocfs_obd_setup(obd, lvars.obd_vars) == 0 &&
2011 lprocfs_alloc_obd_stats(obd, LPROC_MDS_LAST) == 0) {
2012 /* Init private stats here */
2013 mds_stats_counter_init(obd->obd_stats);
2014 obd->obd_proc_exports = proc_mkdir("exports",
2015 obd->obd_proc_entry);
2018 rc = mds_fs_setup(obd, mnt);
2020 CERROR("%s: MDS filesystem method init failed: rc = %d\n",
2025 rc = mds_lov_presetup(mds, lcfg);
2029 ptlrpc_init_client(LDLM_CB_REQUEST_PORTAL, LDLM_CB_REPLY_PORTAL,
2030 "mds_ldlm_client", &obd->obd_ldlm_client);
2031 obd->obd_replayable = 1;
2033 rc = lquota_setup(mds_quota_interface_ref, obd);
2038 mds->mds_group_hash = upcall_cache_init(obd->obd_name);
2039 if (IS_ERR(mds->mds_group_hash)) {
2040 rc = PTR_ERR(mds->mds_group_hash);
2041 mds->mds_group_hash = NULL;
2042 GOTO(err_qctxt, rc);
2046 /* Don't wait for mds_postrecov trying to clear orphans */
2047 obd->obd_async_recov = 1;
2048 rc = mds_postsetup(obd);
2049 /* Bug 11557 - allow async abort_recov start
2050 FIXME can remove most of this obd_async_recov plumbing
2051 obd->obd_async_recov = 0;
2054 GOTO(err_qctxt, rc);
2056 uuid_ptr = fsfilt_uuid(obd, obd->u.obt.obt_sb);
2057 if (uuid_ptr != NULL) {
2058 class_uuid_unparse(uuid_ptr, &uuid);
2064 label = fsfilt_get_label(obd, obd->u.obt.obt_sb);
2065 if (obd->obd_recovering) {
2066 LCONSOLE_WARN("MDT %s now serving %s (%s%s%s), but will be in "
2067 "recovery until %d %s reconnect, or if no clients"
2068 " reconnect for %d:%.02d; during that time new "
2069 "clients will not be allowed to connect. "
2070 "Recovery progress can be monitored by watching "
2071 "/proc/fs/lustre/mds/%s/recovery_status.\n",
2072 obd->obd_name, lustre_cfg_string(lcfg, 1),
2073 label ?: "", label ? "/" : "", str,
2074 obd->obd_max_recoverable_clients,
2075 (obd->obd_max_recoverable_clients == 1) ?
2076 "client" : "clients",
2077 (int)(OBD_RECOVERY_TIMEOUT) / 60,
2078 (int)(OBD_RECOVERY_TIMEOUT) % 60,
2081 LCONSOLE_INFO("MDT %s now serving %s (%s%s%s) with recovery "
2082 "%s\n", obd->obd_name, lustre_cfg_string(lcfg, 1),
2083 label ?: "", label ? "/" : "", str,
2084 obd->obd_replayable ? "enabled" : "disabled");
2087 if (ldlm_timeout == LDLM_TIMEOUT_DEFAULT)
2093 lquota_cleanup(mds_quota_interface_ref, obd);
2095 /* No extra cleanup needed for llog_init_commit_thread() */
2096 mds_fs_cleanup(obd);
2098 upcall_cache_cleanup(mds->mds_group_hash);
2099 mds->mds_group_hash = NULL;
2102 lprocfs_obd_cleanup(obd);
2103 lprocfs_free_obd_stats(obd);
2104 ldlm_namespace_free(obd->obd_namespace, 0);
2105 obd->obd_namespace = NULL;
2107 fsfilt_put_ops(obd->obd_fsops);
2109 server_put_mount(obd->obd_name, mnt);
2110 obd->u.obt.obt_sb = NULL;
2114 static int mds_lov_clean(struct obd_device *obd)
2116 struct mds_obd *mds = &obd->u.mds;
2117 struct obd_device *osc = mds->mds_osc_obd;
2120 if (mds->mds_profile) {
2121 class_del_profile(mds->mds_profile);
2122 OBD_FREE(mds->mds_profile, strlen(mds->mds_profile) + 1);
2123 mds->mds_profile = NULL;
2126 /* There better be a lov */
2130 RETURN(PTR_ERR(osc));
2132 obd_register_observer(osc, NULL);
2134 /* Give lov our same shutdown flags */
2135 osc->obd_force = obd->obd_force;
2136 osc->obd_fail = obd->obd_fail;
2138 /* Cleanup the lov */
2139 obd_disconnect(mds->mds_osc_exp);
2140 class_manual_cleanup(osc);
2141 mds->mds_osc_exp = NULL;
2146 static int mds_postsetup(struct obd_device *obd)
2148 struct mds_obd *mds = &obd->u.mds;
2152 rc = llog_setup(obd, &obd->obd_olg, LLOG_CONFIG_ORIG_CTXT, obd, 0, NULL,
2157 rc = llog_setup(obd, &obd->obd_olg, LLOG_LOVEA_ORIG_CTXT, obd, 0, NULL,
2162 if (mds->mds_profile) {
2163 struct lustre_profile *lprof;
2164 /* The profile defines which osc and mdc to connect to, for a
2165 client. We reuse that here to figure out the name of the
2166 lov to use (and ignore lprof->lp_md).
2167 The profile was set in the config log with
2168 LCFG_MOUNTOPT profilenm oscnm mdcnm */
2169 lprof = class_get_profile(mds->mds_profile);
2170 if (lprof == NULL) {
2171 CERROR("No profile found: %s\n", mds->mds_profile);
2172 GOTO(err_cleanup, rc = -ENOENT);
2174 rc = mds_lov_connect(obd, lprof->lp_dt);
2176 GOTO(err_cleanup, rc);
2183 llog_cleanup(llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT));
2184 llog_cleanup(llog_get_context(obd, LLOG_LOVEA_ORIG_CTXT));
2188 int mds_postrecov(struct obd_device *obd)
2196 LASSERT(!obd->obd_recovering);
2197 LASSERT(!llog_ctxt_null(obd, LLOG_MDS_OST_ORIG_CTXT));
2199 /* clean PENDING dir */
2200 if (strncmp(obd->obd_name, MDD_OBD_NAME, strlen(MDD_OBD_NAME)))
2201 rc = mds_cleanup_pending(obd);
2205 /* FIXME Does target_finish_recovery really need this to block? */
2206 /* Notify the LOV, which will in turn call mds_notify for each tgt */
2207 /* This means that we have to hack obd_notify to think we're obd_set_up
2208 during mds_lov_connect. */
2209 obd_notify(obd->u.mds.mds_osc_obd, NULL,
2210 obd->obd_async_recov ? OBD_NOTIFY_SYNC_NONBLOCK :
2211 OBD_NOTIFY_SYNC, NULL);
2213 /* quota recovery */
2214 lquota_recovery(mds_quota_interface_ref, obd);
2220 /* We need to be able to stop an mds_lov_synchronize */
2221 static int mds_lov_early_clean(struct obd_device *obd)
2223 struct mds_obd *mds = &obd->u.mds;
2224 struct obd_device *osc = mds->mds_osc_obd;
2226 if (!osc || (!obd->obd_force && !obd->obd_fail))
2229 CDEBUG(D_HA, "abort inflight\n");
2230 return (obd_precleanup(osc, OBD_CLEANUP_EARLY));
2233 static int mds_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
2239 case OBD_CLEANUP_EARLY:
2241 case OBD_CLEANUP_EXPORTS:
2242 /*XXX Use this for mdd mds cleanup, so comment out
2243 *this target_cleanup_recovery for this tmp MDD MDS
2245 if (strncmp(obd->obd_name, MDD_OBD_NAME, strlen(MDD_OBD_NAME)))
2246 target_cleanup_recovery(obd);
2247 mds_lov_early_clean(obd);
2249 case OBD_CLEANUP_SELF_EXP:
2250 mds_lov_disconnect(obd);
2252 llog_cleanup(llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT));
2253 llog_cleanup(llog_get_context(obd, LLOG_LOVEA_ORIG_CTXT));
2254 rc = obd_llog_finish(obd, 0);
2256 case OBD_CLEANUP_OBD:
2262 static int mds_cleanup(struct obd_device *obd)
2264 struct mds_obd *mds = &obd->u.mds;
2265 lvfs_sbdev_type save_dev;
2268 if (obd->u.obt.obt_sb == NULL)
2270 save_dev = lvfs_sbdev(obd->u.obt.obt_sb);
2272 if (mds->mds_osc_exp)
2273 /* lov export was disconnected by mds_lov_clean;
2274 we just need to drop our ref */
2275 class_export_put(mds->mds_osc_exp);
2277 lprocfs_obd_cleanup(obd);
2278 lprocfs_free_obd_stats(obd);
2280 lquota_cleanup(mds_quota_interface_ref, obd);
2282 mds_update_server_data(obd, 1);
2284 mds_lov_destroy_objids(obd);
2286 mds_fs_cleanup(obd);
2289 upcall_cache_cleanup(mds->mds_group_hash);
2290 mds->mds_group_hash = NULL;
2293 server_put_mount(obd->obd_name, mds->mds_vfsmnt);
2294 obd->u.obt.obt_sb = NULL;
2296 ldlm_namespace_free(obd->obd_namespace, obd->obd_force);
2298 spin_lock_bh(&obd->obd_processing_task_lock);
2299 if (obd->obd_recovering) {
2300 target_cancel_recovery_timer(obd);
2301 obd->obd_recovering = 0;
2303 spin_unlock_bh(&obd->obd_processing_task_lock);
2305 fsfilt_put_ops(obd->obd_fsops);
2307 LCONSOLE_INFO("MDT %s has stopped.\n", obd->obd_name);
2312 static void fixup_handle_for_resent_req(struct ptlrpc_request *req, int offset,
2313 struct ldlm_lock *new_lock,
2314 struct ldlm_lock **old_lock,
2315 struct lustre_handle *lockh)
2317 struct obd_export *exp = req->rq_export;
2318 struct ldlm_request *dlmreq =
2319 lustre_msg_buf(req->rq_reqmsg, offset, sizeof(*dlmreq));
2320 struct lustre_handle remote_hdl = dlmreq->lock_handle[0];
2321 struct list_head *iter;
2323 if (!(lustre_msg_get_flags(req->rq_reqmsg) & MSG_RESENT))
2326 spin_lock(&exp->exp_ldlm_data.led_lock);
2327 list_for_each(iter, &exp->exp_ldlm_data.led_held_locks) {
2328 struct ldlm_lock *lock;
2329 lock = list_entry(iter, struct ldlm_lock, l_export_chain);
2330 if (lock == new_lock)
2332 if (lock->l_remote_handle.cookie == remote_hdl.cookie) {
2333 lockh->cookie = lock->l_handle.h_cookie;
2334 LDLM_DEBUG(lock, "restoring lock cookie");
2335 DEBUG_REQ(D_DLMTRACE, req,"restoring lock cookie "LPX64,
2338 *old_lock = LDLM_LOCK_GET(lock);
2339 spin_unlock(&exp->exp_ldlm_data.led_lock);
2343 spin_unlock(&exp->exp_ldlm_data.led_lock);
2345 /* If the xid matches, then we know this is a resent request,
2346 * and allow it. (It's probably an OPEN, for which we don't
2349 le64_to_cpu(exp->exp_mds_data.med_mcd->mcd_last_xid))
2353 le64_to_cpu(exp->exp_mds_data.med_mcd->mcd_last_close_xid))
2356 /* This remote handle isn't enqueued, so we never received or
2357 * processed this request. Clear MSG_RESENT, because it can
2358 * be handled like any normal request now. */
2360 lustre_msg_clear_flags(req->rq_reqmsg, MSG_RESENT);
2362 DEBUG_REQ(D_DLMTRACE, req, "no existing lock with rhandle "LPX64,
2366 int intent_disposition(struct ldlm_reply *rep, int flag)
2370 return (rep->lock_policy_res1 & flag);
2373 void intent_set_disposition(struct ldlm_reply *rep, int flag)
2377 rep->lock_policy_res1 |= flag;
2380 static int mds_intent_policy(struct ldlm_namespace *ns,
2381 struct ldlm_lock **lockp, void *req_cookie,
2382 ldlm_mode_t mode, int flags, void *data)
2384 struct ptlrpc_request *req = req_cookie;
2385 struct ldlm_lock *lock = *lockp;
2386 struct ldlm_intent *it;
2387 struct mds_obd *mds = &req->rq_export->exp_obd->u.mds;
2388 struct ldlm_reply *rep;
2389 struct lustre_handle lockh = { 0 };
2390 struct ldlm_lock *new_lock = NULL;
2391 int getattr_part = MDS_INODELOCK_UPDATE;
2392 int repsize[5] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
2393 [DLM_LOCKREPLY_OFF] = sizeof(struct ldlm_reply),
2394 [DLM_REPLY_REC_OFF] = sizeof(struct mds_body),
2395 [DLM_REPLY_REC_OFF+1] = mds->mds_max_mdsize };
2396 int repbufcnt = 4, rc;
2399 LASSERT(req != NULL);
2401 if (lustre_msg_bufcount(req->rq_reqmsg) <= DLM_INTENT_IT_OFF) {
2402 /* No intent was provided */
2403 rc = lustre_pack_reply(req, 2, repsize, NULL);
2409 it = lustre_swab_reqbuf(req, DLM_INTENT_IT_OFF, sizeof(*it),
2410 lustre_swab_ldlm_intent);
2412 CERROR("Intent missing\n");
2413 RETURN(req->rq_status = -EFAULT);
2416 LDLM_DEBUG(lock, "intent policy, opc: %s", ldlm_it2str(it->opc));
2418 if ((req->rq_export->exp_connect_flags & OBD_CONNECT_ACL) &&
2419 (it->opc & (IT_OPEN | IT_GETATTR | IT_LOOKUP)))
2420 /* we should never allow OBD_CONNECT_ACL if not configured */
2421 repsize[repbufcnt++] = LUSTRE_POSIX_ACL_MAX_SIZE;
2422 else if (it->opc & IT_UNLINK)
2423 repsize[repbufcnt++] = mds->mds_max_cookiesize;
2425 rc = lustre_pack_reply(req, repbufcnt, repsize, NULL);
2427 RETURN(req->rq_status = rc);
2429 rep = lustre_msg_buf(req->rq_repmsg, DLM_LOCKREPLY_OFF, sizeof(*rep));
2430 intent_set_disposition(rep, DISP_IT_EXECD);
2433 /* execute policy */
2434 switch ((long)it->opc) {
2436 case IT_CREAT|IT_OPEN:
2437 mds_counter_incr(req->rq_export, LPROC_MDS_OPEN);
2438 fixup_handle_for_resent_req(req, DLM_LOCKREQ_OFF, lock, NULL,
2440 /* XXX swab here to assert that an mds_open reint
2441 * packet is following */
2442 rep->lock_policy_res2 = mds_reint(req, DLM_INTENT_REC_OFF,
2445 /* We abort the lock if the lookup was negative and
2446 * we did not make it to the OPEN portion */
2447 if (!intent_disposition(rep, DISP_LOOKUP_EXECD))
2448 RETURN(ELDLM_LOCK_ABORTED);
2449 if (intent_disposition(rep, DISP_LOOKUP_NEG) &&
2450 !intent_disposition(rep, DISP_OPEN_OPEN))
2453 /* If there was an error of some sort or if we are not
2454 * returning any locks */
2455 if (rep->lock_policy_res2 ||
2456 !intent_disposition(rep, DISP_OPEN_LOCK))
2457 RETURN(ELDLM_LOCK_ABORTED);
2460 getattr_part = MDS_INODELOCK_LOOKUP;
2462 getattr_part |= MDS_INODELOCK_LOOKUP;
2463 OBD_COUNTER_INCREMENT(req->rq_export->exp_obd, getattr);
2465 fixup_handle_for_resent_req(req, DLM_LOCKREQ_OFF, lock,
2468 /* INODEBITS_INTEROP: if this lock was converted from a
2469 * plain lock (client does not support inodebits), then
2470 * child lock must be taken with both lookup and update
2471 * bits set for all operations.
2473 if (!(req->rq_export->exp_connect_flags & OBD_CONNECT_IBITS))
2474 getattr_part = MDS_INODELOCK_LOOKUP |
2475 MDS_INODELOCK_UPDATE;
2477 rep->lock_policy_res2 = mds_getattr_lock(req,DLM_INTENT_REC_OFF,
2478 getattr_part, &lockh);
2479 /* FIXME: LDLM can set req->rq_status. MDS sets
2480 policy_res{1,2} with disposition and status.
2481 - replay: returns 0 & req->status is old status
2482 - otherwise: returns req->status */
2483 if (intent_disposition(rep, DISP_LOOKUP_NEG))
2484 rep->lock_policy_res2 = 0;
2485 if (!intent_disposition(rep, DISP_LOOKUP_POS) ||
2486 rep->lock_policy_res2)
2487 RETURN(ELDLM_LOCK_ABORTED);
2488 if (req->rq_status != 0) {
2490 rep->lock_policy_res2 = req->rq_status;
2491 RETURN(ELDLM_LOCK_ABORTED);
2495 CERROR("Unhandled intent "LPD64"\n", it->opc);
2499 /* By this point, whatever function we called above must have either
2500 * filled in 'lockh', been an intent replay, or returned an error. We
2501 * want to allow replayed RPCs to not get a lock, since we would just
2502 * drop it below anyways because lock replay is done separately by the
2503 * client afterwards. For regular RPCs we want to give the new lock to
2504 * the client instead of whatever lock it was about to get. */
2505 if (new_lock == NULL)
2506 new_lock = ldlm_handle2lock(&lockh);
2507 if (new_lock == NULL && (flags & LDLM_FL_INTENT_ONLY))
2510 LASSERTF(new_lock != NULL, "op "LPX64" lockh "LPX64"\n",
2511 it->opc, lockh.cookie);
2513 /* If we've already given this lock to a client once, then we should
2514 * have no readers or writers. Otherwise, we should have one reader
2515 * _or_ writer ref (which will be zeroed below) before returning the
2516 * lock to a client. */
2517 if (new_lock->l_export == req->rq_export) {
2518 LASSERT(new_lock->l_readers + new_lock->l_writers == 0);
2520 LASSERT(new_lock->l_export == NULL);
2521 LASSERT(new_lock->l_readers + new_lock->l_writers == 1);
2526 if (new_lock->l_export == req->rq_export) {
2527 /* Already gave this to the client, which means that we
2528 * reconstructed a reply. */
2529 LASSERT(lustre_msg_get_flags(req->rq_reqmsg) &
2531 RETURN(ELDLM_LOCK_REPLACED);
2534 /* Fixup the lock to be given to the client */
2535 lock_res_and_lock(new_lock);
2536 new_lock->l_readers = 0;
2537 new_lock->l_writers = 0;
2539 new_lock->l_export = class_export_get(req->rq_export);
2540 spin_lock(&req->rq_export->exp_ldlm_data.led_lock);
2541 list_add(&new_lock->l_export_chain,
2542 &new_lock->l_export->exp_ldlm_data.led_held_locks);
2543 spin_unlock(&req->rq_export->exp_ldlm_data.led_lock);
2545 new_lock->l_blocking_ast = lock->l_blocking_ast;
2546 new_lock->l_completion_ast = lock->l_completion_ast;
2548 memcpy(&new_lock->l_remote_handle, &lock->l_remote_handle,
2549 sizeof(lock->l_remote_handle));
2551 new_lock->l_flags &= ~LDLM_FL_LOCAL;
2553 unlock_res_and_lock(new_lock);
2554 LDLM_LOCK_PUT(new_lock);
2556 RETURN(ELDLM_LOCK_REPLACED);
2559 static int mdt_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
2561 struct mds_obd *mds = &obd->u.mds;
2562 struct lprocfs_static_vars lvars;
2563 int mds_min_threads;
2564 int mds_max_threads;
2568 lprocfs_mdt_init_vars(&lvars);
2569 lprocfs_obd_setup(obd, lvars.obd_vars);
2571 sema_init(&mds->mds_health_sem, 1);
2573 if (mds_num_threads) {
2574 /* If mds_num_threads is set, it is the min and the max. */
2575 if (mds_num_threads > MDS_THREADS_MAX)
2576 mds_num_threads = MDS_THREADS_MAX;
2577 if (mds_num_threads < MDS_THREADS_MIN)
2578 mds_num_threads = MDS_THREADS_MIN;
2579 mds_max_threads = mds_min_threads = mds_num_threads;
2581 /* Base min threads on memory and cpus */
2582 mds_min_threads = num_possible_cpus() * num_physpages >>
2583 (27 - CFS_PAGE_SHIFT);
2584 if (mds_min_threads < MDS_THREADS_MIN)
2585 mds_min_threads = MDS_THREADS_MIN;
2586 /* Largest auto threads start value */
2587 if (mds_min_threads > 32)
2588 mds_min_threads = 32;
2589 mds_max_threads = min(MDS_THREADS_MAX, mds_min_threads * 4);
2593 ptlrpc_init_svc(MDS_NBUFS, MDS_BUFSIZE, MDS_MAXREQSIZE,
2594 MDS_MAXREPSIZE, MDS_REQUEST_PORTAL,
2595 MDC_REPLY_PORTAL, MDS_SERVICE_WATCHDOG_TIMEOUT,
2596 mds_handle, LUSTRE_MDS_NAME,
2597 obd->obd_proc_entry, NULL,
2598 mds_min_threads, mds_max_threads, "ll_mdt", 0);
2600 if (!mds->mds_service) {
2601 CERROR("failed to start service\n");
2602 GOTO(err_lprocfs, rc = -ENOMEM);
2605 rc = ptlrpc_start_threads(obd, mds->mds_service);
2607 GOTO(err_thread, rc);
2609 mds->mds_setattr_service =
2610 ptlrpc_init_svc(MDS_NBUFS, MDS_BUFSIZE, MDS_MAXREQSIZE,
2611 MDS_MAXREPSIZE, MDS_SETATTR_PORTAL,
2612 MDC_REPLY_PORTAL, MDS_SERVICE_WATCHDOG_TIMEOUT,
2613 mds_handle, "mds_setattr",
2614 obd->obd_proc_entry, NULL,
2615 mds_min_threads, mds_max_threads,
2617 if (!mds->mds_setattr_service) {
2618 CERROR("failed to start getattr service\n");
2619 GOTO(err_thread, rc = -ENOMEM);
2622 rc = ptlrpc_start_threads(obd, mds->mds_setattr_service);
2624 GOTO(err_thread2, rc);
2626 mds->mds_readpage_service =
2627 ptlrpc_init_svc(MDS_NBUFS, MDS_BUFSIZE, MDS_MAXREQSIZE,
2628 MDS_MAXREPSIZE, MDS_READPAGE_PORTAL,
2629 MDC_REPLY_PORTAL, MDS_SERVICE_WATCHDOG_TIMEOUT,
2630 mds_handle, "mds_readpage",
2631 obd->obd_proc_entry, NULL,
2632 MDS_THREADS_MIN_READPAGE, mds_max_threads,
2634 if (!mds->mds_readpage_service) {
2635 CERROR("failed to start readpage service\n");
2636 GOTO(err_thread2, rc = -ENOMEM);
2639 rc = ptlrpc_start_threads(obd, mds->mds_readpage_service);
2642 GOTO(err_thread3, rc);
2644 ping_evictor_start();
2649 ptlrpc_unregister_service(mds->mds_readpage_service);
2650 mds->mds_readpage_service = NULL;
2652 ptlrpc_unregister_service(mds->mds_setattr_service);
2653 mds->mds_setattr_service = NULL;
2655 ptlrpc_unregister_service(mds->mds_service);
2656 mds->mds_service = NULL;
2658 lprocfs_obd_cleanup(obd);
2662 static int mdt_cleanup(struct obd_device *obd)
2664 struct mds_obd *mds = &obd->u.mds;
2667 ping_evictor_stop();
2669 down(&mds->mds_health_sem);
2670 ptlrpc_unregister_service(mds->mds_readpage_service);
2671 ptlrpc_unregister_service(mds->mds_setattr_service);
2672 ptlrpc_unregister_service(mds->mds_service);
2673 mds->mds_readpage_service = NULL;
2674 mds->mds_setattr_service = NULL;
2675 mds->mds_service = NULL;
2676 up(&mds->mds_health_sem);
2678 lprocfs_obd_cleanup(obd);
2683 static int mdt_health_check(struct obd_device *obd)
2685 struct mds_obd *mds = &obd->u.mds;
2688 down(&mds->mds_health_sem);
2689 rc |= ptlrpc_service_health_check(mds->mds_readpage_service);
2690 rc |= ptlrpc_service_health_check(mds->mds_setattr_service);
2691 rc |= ptlrpc_service_health_check(mds->mds_service);
2692 up(&mds->mds_health_sem);
2695 * health_check to return 0 on healthy
2696 * and 1 on unhealthy.
2704 static struct dentry *mds_lvfs_fid2dentry(__u64 id, __u32 gen, __u64 gr,
2707 struct obd_device *obd = data;
2710 fid.generation = gen;
2711 return mds_fid2dentry(&obd->u.mds, &fid, NULL);
2714 static int mds_health_check(struct obd_device *obd)
2716 struct obd_device_target *odt = &obd->u.obt;
2717 #ifdef USE_HEALTH_CHECK_WRITE
2718 struct mds_obd *mds = &obd->u.mds;
2722 if (odt->obt_sb->s_flags & MS_RDONLY)
2725 #ifdef USE_HEALTH_CHECK_WRITE
2726 LASSERT(mds->mds_health_check_filp != NULL);
2727 rc |= !!lvfs_check_io_health(obd, mds->mds_health_check_filp);
2732 static int mds_process_config(struct obd_device *obd, obd_count len, void *buf)
2734 struct lustre_cfg *lcfg = buf;
2735 struct lprocfs_static_vars lvars;
2738 lprocfs_mds_init_vars(&lvars);
2740 rc = class_process_proc_param(PARAM_MDT, lvars.obd_vars, lcfg, obd);
2744 struct lvfs_callback_ops mds_lvfs_ops = {
2745 l_fid2dentry: mds_lvfs_fid2dentry,
2748 /* use obd ops to offer management infrastructure */
2749 static struct obd_ops mds_obd_ops = {
2750 .o_owner = THIS_MODULE,
2751 .o_connect = mds_connect,
2752 .o_reconnect = mds_reconnect,
2753 .o_init_export = mds_init_export,
2754 .o_destroy_export = mds_destroy_export,
2755 .o_disconnect = mds_disconnect,
2756 .o_setup = mds_setup,
2757 .o_precleanup = mds_precleanup,
2758 .o_cleanup = mds_cleanup,
2759 .o_postrecov = mds_postrecov,
2760 .o_statfs = mds_obd_statfs,
2761 .o_iocontrol = mds_iocontrol,
2762 .o_create = mds_obd_create,
2763 .o_destroy = mds_obd_destroy,
2764 .o_llog_init = mds_llog_init,
2765 .o_llog_finish = mds_llog_finish,
2766 .o_notify = mds_notify,
2767 .o_health_check = mds_health_check,
2768 .o_process_config = mds_process_config,
2771 static struct obd_ops mdt_obd_ops = {
2772 .o_owner = THIS_MODULE,
2773 .o_setup = mdt_setup,
2774 .o_cleanup = mdt_cleanup,
2775 .o_health_check = mdt_health_check,
2778 quota_interface_t *mds_quota_interface_ref;
2779 extern quota_interface_t mds_quota_interface;
2781 static __attribute__((unused)) int __init mds_init(void)
2784 struct lprocfs_static_vars lvars;
2786 request_module("lquota");
2787 mds_quota_interface_ref = PORTAL_SYMBOL_GET(mds_quota_interface);
2788 rc = lquota_init(mds_quota_interface_ref);
2790 if (mds_quota_interface_ref)
2791 PORTAL_SYMBOL_PUT(mds_quota_interface);
2794 init_obd_quota_ops(mds_quota_interface_ref, &mds_obd_ops);
2796 lprocfs_mds_init_vars(&lvars);
2797 class_register_type(&mds_obd_ops, NULL,
2798 lvars.module_vars, LUSTRE_MDS_NAME, NULL);
2799 lprocfs_mds_init_vars(&lvars);
2800 mdt_obd_ops = mdt_obd_ops; //make compiler happy
2801 // class_register_type(&mdt_obd_ops, NULL,
2802 // lvars.module_vars, LUSTRE_MDT_NAME, NULL);
2807 static __attribute__((unused)) void /*__exit*/ mds_exit(void)
2809 lquota_exit(mds_quota_interface_ref);
2810 if (mds_quota_interface_ref)
2811 PORTAL_SYMBOL_PUT(mds_quota_interface);
2813 class_unregister_type(LUSTRE_MDS_NAME);
2814 // class_unregister_type(LUSTRE_MDT_NAME);
2816 /*mds still need lov setup here*/
2817 static int mds_cmd_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
2819 struct mds_obd *mds = &obd->u.mds;
2820 struct lvfs_run_ctxt saved;
2822 struct vfsmount *mnt;
2823 struct lustre_sb_info *lsi;
2824 struct lustre_mount_info *lmi;
2825 struct dentry *dentry;
2829 CDEBUG(D_INFO, "obd %s setup \n", obd->obd_name);
2830 if (strncmp(obd->obd_name, MDD_OBD_NAME, strlen(MDD_OBD_NAME)))
2833 if (lcfg->lcfg_bufcount < 5) {
2834 CERROR("invalid arg for setup %s\n", MDD_OBD_NAME);
2837 dev = lustre_cfg_string(lcfg, 4);
2838 lmi = server_get_mount(dev);
2839 LASSERT(lmi != NULL);
2841 lsi = s2lsi(lmi->lmi_sb);
2843 /* FIXME: MDD LOV initialize objects.
2844 * we need only lmi here but not get mount
2845 * OSD did mount already, so put mount back
2847 atomic_dec(&lsi->lsi_mounts);
2850 obd->obd_fsops = fsfilt_get_ops(MT_STR(lsi->lsi_ldd));
2851 mds_init_ctxt(obd, mnt);
2853 push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
2854 dentry = simple_mkdir(current->fs->pwd, "OBJECTS", 0777, 1);
2855 if (IS_ERR(dentry)) {
2856 rc = PTR_ERR(dentry);
2857 CERROR("cannot create OBJECTS directory: rc = %d\n", rc);
2858 GOTO(err_putfs, rc);
2860 mds->mds_objects_dir = dentry;
2862 dentry = lookup_one_len("__iopen__", current->fs->pwd,
2863 strlen("__iopen__"));
2864 if (IS_ERR(dentry)) {
2865 rc = PTR_ERR(dentry);
2866 CERROR("cannot lookup __iopen__ directory: rc = %d\n", rc);
2867 GOTO(err_objects, rc);
2870 mds->mds_fid_de = dentry;
2871 if (!dentry->d_inode || is_bad_inode(dentry->d_inode)) {
2873 CERROR("__iopen__ directory has no inode? rc = %d\n", rc);
2876 rc = mds_lov_init_objids(obd);
2878 CERROR("cannot init lov objid rc = %d\n", rc);
2882 rc = mds_lov_presetup(mds, lcfg);
2884 GOTO(err_objects, rc);
2886 /* Don't wait for mds_postrecov trying to clear orphans */
2887 obd->obd_async_recov = 1;
2888 rc = mds_postsetup(obd);
2889 /* Bug 11557 - allow async abort_recov start
2890 FIXME can remove most of this obd_async_recov plumbing
2891 obd->obd_async_recov = 0;
2895 GOTO(err_objects, rc);
2897 mds->mds_max_mdsize = sizeof(struct lov_mds_md);
2898 mds->mds_max_cookiesize = sizeof(struct llog_cookie);
2901 pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
2904 dput(mds->mds_fid_de);
2906 dput(mds->mds_objects_dir);
2908 fsfilt_put_ops(obd->obd_fsops);
2912 static int mds_cmd_cleanup(struct obd_device *obd)
2914 struct mds_obd *mds = &obd->u.mds;
2915 struct lvfs_run_ctxt saved;
2920 LCONSOLE_WARN("%s: shutting down for failover; client state "
2921 "will be preserved.\n", obd->obd_name);
2923 push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
2925 mds_lov_destroy_objids(obd);
2927 if (mds->mds_objects_dir != NULL) {
2928 l_dput(mds->mds_objects_dir);
2929 mds->mds_objects_dir = NULL;
2932 shrink_dcache_parent(mds->mds_fid_de);
2933 dput(mds->mds_fid_de);
2934 LL_DQUOT_OFF(obd->u.obt.obt_sb);
2935 fsfilt_put_ops(obd->obd_fsops);
2937 pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
2942 static int mds_cmd_health_check(struct obd_device *obd)
2947 static struct obd_ops mds_cmd_obd_ops = {
2948 .o_owner = THIS_MODULE,
2949 .o_setup = mds_cmd_setup,
2950 .o_cleanup = mds_cmd_cleanup,
2951 .o_precleanup = mds_precleanup,
2952 .o_create = mds_obd_create,
2953 .o_destroy = mds_obd_destroy,
2954 .o_llog_init = mds_llog_init,
2955 .o_llog_finish = mds_llog_finish,
2956 .o_notify = mds_notify,
2957 .o_postrecov = mds_postrecov,
2958 // .o_health_check = mds_cmd_health_check,
2961 static int __init mds_cmd_init(void)
2963 struct lprocfs_static_vars lvars;
2965 lprocfs_mds_init_vars(&lvars);
2966 class_register_type(&mds_cmd_obd_ops, NULL, lvars.module_vars,
2967 LUSTRE_MDS_NAME, NULL);
2972 static void /*__exit*/ mds_cmd_exit(void)
2974 class_unregister_type(LUSTRE_MDS_NAME);
2977 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
2978 MODULE_DESCRIPTION("Lustre Metadata Server (MDS)");
2979 MODULE_LICENSE("GPL");
2981 module_init(mds_cmd_init);
2982 module_exit(mds_cmd_exit);