1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * linux/mds/mds_reint.c
6 * Lustre Metadata Server (mds) reintegration routines
8 * Copyright (C) 2002 Cluster File Systems, Inc.
9 * author: Peter Braam <braam@clusterfs.com>
11 * This code is issued under the GNU General Public License.
12 * See the file COPYING in this distribution
16 // XXX - add transaction sequence numbers
19 #define DEBUG_SUBSYSTEM S_MDS
21 #include <linux/obd_support.h>
22 #include <linux/obd_class.h>
23 #include <linux/obd.h>
24 #include <linux/lustre_lib.h>
25 #include <linux/lustre_idl.h>
26 #include <linux/lustre_mds.h>
27 #include <linux/lustre_dlm.h>
28 #include <linux/obd_class.h>
30 extern inline struct mds_obd *mds_req2mds(struct ptlrpc_request *req);
32 struct mds_client_info *mds_uuid_to_mci(struct mds_obd *mds, __u8 *uuid)
39 list_for_each(p, &mds->mds_client_info) {
40 struct mds_client_info *mci;
42 mci = list_entry(p, struct mds_client_info, mci_list);
43 CDEBUG(D_INFO, "checking client UUID '%s'\n",
44 mci->mci_mcd->mcd_uuid);
45 if (!strncmp(mci->mci_mcd->mcd_uuid, uuid,
46 sizeof(mci->mci_mcd->mcd_uuid)))
49 CDEBUG(D_INFO, "no mds client info found for UUID '%s'\n", uuid);
53 /* Assumes caller has already pushed us into the kernel context. */
54 int mds_update_last_rcvd(struct mds_obd *mds, void *handle,
55 struct ptlrpc_request *req)
57 /* get from req->rq_connection-> or req->rq_client */
58 struct mds_client_info *mci;
62 mci = mds_uuid_to_mci(mds, req->rq_connection->c_remote_uuid);
64 CERROR("unable to locate MDS client data for UUID '%s'\n",
65 ptlrpc_req_to_uuid(req));
66 /* This will be a real error once everything is working */
71 off = MDS_LR_CLIENT + mci->mci_off * MDS_LR_SIZE;
73 ++mds->mds_last_rcvd; /* lock this, or make it an LDLM function? */
74 req->rq_repmsg->transno = HTON__u64(mds->mds_last_rcvd);
75 mci->mci_mcd->mcd_last_rcvd = cpu_to_le64(mds->mds_last_rcvd);
76 mci->mci_mcd->mcd_mount_count = cpu_to_le64(mds->mds_mount_count);
77 mci->mci_mcd->mcd_last_xid = cpu_to_le64(req->rq_xid);
79 mds_fs_set_last_rcvd(mds, handle);
80 rc = lustre_fwrite(mds->mds_rcvd_filp, (char *)mci->mci_mcd,
81 sizeof(*mci->mci_mcd), &off);
82 CDEBUG(D_INODE, "wrote trans #%Ld for client '%s' at #%d: rc = %d\n",
83 mds->mds_last_rcvd, mci->mci_mcd->mcd_uuid, mci->mci_off, rc);
84 // store new value and last committed value in req struct
86 if (rc == sizeof(*mci->mci_mcd))
89 CERROR("error writing to last_rcvd file: rc = %d\n", rc);
97 static int mds_reint_setattr(struct mds_update_record *rec, int offset,
98 struct ptlrpc_request *req)
100 struct mds_obd *mds = mds_req2mds(req);
106 de = mds_fid2dentry(mds, rec->ur_fid1, NULL);
107 if (IS_ERR(de) || OBD_FAIL_CHECK(OBD_FAIL_MDS_REINT_SETATTR)) {
108 GOTO(out_setattr, rc = -ESTALE);
111 CDEBUG(D_INODE, "ino %ld\n", de->d_inode->i_ino);
113 OBD_FAIL_WRITE(OBD_FAIL_MDS_REINT_SETATTR_WRITE,
114 de->d_inode->i_sb->s_dev);
116 handle = mds_fs_start(mds, de->d_inode, MDS_FSOP_SETATTR);
118 GOTO(out_setattr_de, rc = PTR_ERR(handle));
119 rc = mds_fs_setattr(mds, de, handle, &rec->ur_iattr);
122 rc = mds_update_last_rcvd(mds, handle, req);
124 err = mds_fs_commit(mds, de->d_inode, handle);
126 CERROR("error on commit: err = %d\n", err);
138 static int mds_reint_recreate(struct mds_update_record *rec, int offset,
139 struct ptlrpc_request *req)
141 struct dentry *de = NULL;
142 struct mds_obd *mds = mds_req2mds(req);
143 struct dentry *dchild = NULL;
148 de = mds_fid2dentry(mds, rec->ur_fid1, NULL);
149 if (IS_ERR(de) || OBD_FAIL_CHECK(OBD_FAIL_MDS_REINT_CREATE)) {
151 GOTO(out_create_de, rc = -ESTALE);
154 CDEBUG(D_INODE, "parent ino %ld\n", dir->i_ino);
157 dchild = lookup_one_len(rec->ur_name, de, rec->ur_namelen - 1);
158 if (IS_ERR(dchild)) {
159 CERROR("child lookup error %ld\n", PTR_ERR(dchild));
162 GOTO(out_create_dchild, rc = -ESTALE);
165 if (dchild->d_inode) {
166 struct mds_body *body;
168 body = lustre_msg_buf(req->rq_repmsg, 0);
169 body->ino = dchild->d_inode->i_ino;
170 body->generation = dchild->d_inode->i_generation;
172 CERROR("child doesn't exist (dir %ld, name %s)\n",
173 dir->i_ino, rec->ur_name);
187 static int mds_reint_create(struct mds_update_record *rec, int offset,
188 struct ptlrpc_request *req)
190 struct dentry *de = NULL;
191 struct mds_obd *mds = mds_req2mds(req);
192 struct dentry *dchild = NULL;
195 struct lustre_handle lockh;
196 int rc = 0, err, flags, lock_mode, type = rec->ur_mode & S_IFMT;
197 __u64 res_id[3] = {0,0,0};
200 /* requests were at offset 2, replies go back at 1 */
204 if (strcmp(req->rq_export->export_obd->obd_type->typ_name, "mds") != 0)
207 de = mds_fid2dentry(mds, rec->ur_fid1, NULL);
208 if (IS_ERR(de) || OBD_FAIL_CHECK(OBD_FAIL_MDS_REINT_CREATE)) {
210 GOTO(out_create_de, rc = -ESTALE);
213 CDEBUG(D_INODE, "parent ino %ld name %s mode %o\n",
214 dir->i_ino, rec->ur_name, rec->ur_mode);
216 lock_mode = (req->rq_reqmsg->opc == MDS_REINT) ? LCK_CW : LCK_PW;
217 res_id[0] = dir->i_ino;
219 rc = ldlm_lock_match(mds->mds_local_namespace, res_id, LDLM_PLAIN,
220 NULL, 0, lock_mode, &lockh);
222 LDLM_DEBUG_NOLOCK("enqueue res %Lu", res_id[0]);
223 rc = ldlm_cli_enqueue(mds->mds_ldlm_client, mds->mds_ldlm_conn,
224 (struct lustre_handle *)&mds->mds_connh,
225 NULL, mds->mds_local_namespace, NULL,
226 res_id, LDLM_PLAIN, NULL, 0, lock_mode,
227 &flags, (void *)mds_lock_callback, NULL,
229 if (rc != ELDLM_OK) {
230 CERROR("lock enqueue: err: %d\n", rc);
231 GOTO(out_create_de, rc = -EIO);
234 ldlm_lock_dump((void *)(unsigned long)lockh.addr);
237 dchild = lookup_one_len(rec->ur_name, de, rec->ur_namelen - 1);
238 if (IS_ERR(dchild)) {
239 CERROR("child lookup error %ld\n", PTR_ERR(dchild));
242 GOTO(out_create_dchild, rc = -ESTALE);
245 if (dchild->d_inode) {
246 struct mds_body *body;
248 struct inode *inode = dchild->d_inode;
249 CDEBUG(D_INODE, "child exists (dir %ld, name %s, ino %ld)\n",
250 dir->i_ino, rec->ur_name, dchild->d_inode->i_ino);
252 body = lustre_msg_buf(req->rq_repmsg, offset);
253 mds_pack_inode2fid(&body->fid1, inode);
254 mds_pack_inode2body(body, inode);
255 #warning FIXME: This ext3/N-specific code does not belong here
256 /* If i_file_acl is set, this inode has an EA */
257 if (S_ISREG(inode->i_mode) && inode->u.ext3_i.i_file_acl) {
258 obdo = lustre_msg_buf(req->rq_repmsg, offset + 1);
259 mds_fs_get_obdo(mds, inode, obdo);
261 /* now a normal case for intent locking */
262 GOTO(out_create_dchild, rc = -EEXIST);
265 OBD_FAIL_WRITE(OBD_FAIL_MDS_REINT_CREATE_WRITE, dir->i_sb->s_dev);
267 if (dir->i_mode & S_ISGID) {
268 rec->ur_gid = dir->i_gid;
269 if (S_ISDIR(rec->ur_mode))
270 rec->ur_mode |= S_ISGID;
275 handle = mds_fs_start(mds, dir, MDS_FSOP_CREATE);
277 GOTO(out_create_dchild, PTR_ERR(handle));
278 rc = vfs_create(dir, dchild, rec->ur_mode);
283 handle = mds_fs_start(mds, dir, MDS_FSOP_MKDIR);
285 GOTO(out_create_dchild, PTR_ERR(handle));
286 rc = vfs_mkdir(dir, dchild, rec->ur_mode);
291 handle = mds_fs_start(mds, dir, MDS_FSOP_SYMLINK);
293 GOTO(out_create_dchild, PTR_ERR(handle));
294 rc = vfs_symlink(dir, dchild, rec->ur_tgt);
302 int rdev = rec->ur_rdev;
303 handle = mds_fs_start(mds, dir, MDS_FSOP_MKNOD);
305 GOTO(out_create_dchild, PTR_ERR(handle));
306 rc = vfs_mknod(dir, dchild, rec->ur_mode, rdev);
311 CERROR("bad file type %d for create of %s\n",type,rec->ur_name);
312 GOTO(out_create_dchild, rc = -EINVAL);
316 CERROR("error during create: %d\n", rc);
319 GOTO(out_create_commit, rc);
322 struct inode *inode = dchild->d_inode;
323 struct mds_body *body;
325 CDEBUG(D_INODE, "created ino %ld\n", dchild->d_inode->i_ino);
326 if (!offset && type == S_IFREG) {
328 obdo = lustre_msg_buf(req->rq_reqmsg, 2);
329 rc = mds_fs_set_obdo(mds, inode, handle, obdo);
331 CERROR("error %d setting obdo for %ld\n",
333 GOTO(out_create_unlink, rc);
337 iattr.ia_atime = rec->ur_time;
338 iattr.ia_ctime = rec->ur_time;
339 iattr.ia_mtime = rec->ur_time;
340 iattr.ia_uid = rec->ur_uid;
341 iattr.ia_gid = rec->ur_gid;
342 iattr.ia_valid = ATTR_UID | ATTR_GID | ATTR_ATIME |
343 ATTR_MTIME | ATTR_CTIME;
345 rc = mds_fs_setattr(mds, dchild, handle, &iattr);
347 CERROR("error on setattr: rc = %d\n", rc);
348 /* XXX should we abort here in case of error? */
351 rc = mds_update_last_rcvd(mds, handle, req);
353 CERROR("error on update_last_rcvd: rc = %d\n", rc);
354 /* XXX should we abort here in case of error? */
357 body = lustre_msg_buf(req->rq_repmsg, offset);
358 body->ino = inode->i_ino;
359 body->generation = inode->i_generation;
363 err = mds_fs_commit(mds, dir, handle);
365 CERROR("error on commit: err = %d\n", err);
372 ldlm_lock_decref(&lockh, lock_mode);
379 /* Destroy the file we just created. This should not need extra
380 * journal credits, as we have already modified all of the blocks
381 * needed in order to create the file in the first place.
385 err = vfs_rmdir(dir, dchild);
387 CERROR("failed rmdir in error path: rc = %d\n", err);
390 err = vfs_unlink(dir, dchild);
392 CERROR("failed unlink in error path: rc = %d\n", err);
395 goto out_create_commit;
398 static int mds_reint_unlink(struct mds_update_record *rec, int offset,
399 struct ptlrpc_request *req)
401 struct dentry *de = NULL;
402 struct dentry *dchild = NULL;
403 struct mds_obd *mds = mds_req2mds(req);
405 struct inode *dir, *inode;
406 int lock_mode, flags;
407 __u64 res_id[3] = {0};
408 struct lustre_handle lockh;
414 de = mds_fid2dentry(mds, rec->ur_fid1, NULL);
415 if (IS_ERR(de) || OBD_FAIL_CHECK(OBD_FAIL_MDS_REINT_UNLINK)) {
417 GOTO(out_unlink, rc = -ESTALE);
421 CDEBUG(D_INODE, "parent ino %ld\n", dir->i_ino);
422 lock_mode = (req->rq_reqmsg->opc == MDS_REINT) ? LCK_CW : LCK_PW;
423 res_id[0] = dir->i_ino;
425 rc = ldlm_lock_match(mds->mds_local_namespace, res_id, LDLM_PLAIN,
426 NULL, 0, lock_mode, &lockh);
428 LDLM_DEBUG_NOLOCK("enqueue res %Lu", res_id[0]);
429 rc = ldlm_cli_enqueue(mds->mds_ldlm_client, mds->mds_ldlm_conn,
430 (struct lustre_handle *)&mds->mds_connh,
431 NULL, mds->mds_local_namespace, NULL,
432 res_id, LDLM_PLAIN, NULL, 0, lock_mode,
433 &flags, (void *)mds_lock_callback, NULL,
435 if (rc != ELDLM_OK) {
436 CERROR("lock enqueue: err: %d\n", rc);
437 GOTO(out_unlink_de, rc = -EIO);
440 ldlm_lock_dump((void *)(unsigned long)lockh.addr);
443 dchild = lookup_one_len(rec->ur_name, de, rec->ur_namelen - 1);
444 if (IS_ERR(dchild)) {
445 CERROR("child lookup error %ld\n", PTR_ERR(dchild));
447 GOTO(out_unlink_de, rc = -ESTALE);
450 inode = dchild->d_inode;
452 CERROR("child doesn't exist (dir %ld, name %s\n",
453 dir->i_ino, rec->ur_name);
454 GOTO(out_unlink_dchild, rc = -ENOENT);
457 #if 0 /* in intent case the client doesn't have the inode */
458 if (inode->i_ino != rec->ur_fid2->id) {
459 CERROR("inode and FID ID do not match (%ld != %Ld)\n",
460 inode->i_ino, rec->ur_fid2->id);
462 GOTO(out_unlink_dchild, rc = -ESTALE);
464 if (inode->i_generation != rec->ur_fid2->generation) {
465 CERROR("inode and FID GENERATION do not match (%d != %d)\n",
466 inode->i_generation, rec->ur_fid2->generation);
468 GOTO(out_unlink_dchild, rc = -ESTALE);
472 OBD_FAIL_WRITE(OBD_FAIL_MDS_REINT_UNLINK_WRITE, dir->i_sb->s_dev);
474 switch (inode->i_mode & S_IFMT) {
476 handle = mds_fs_start(mds, dir, MDS_FSOP_RMDIR);
478 GOTO(out_unlink_dchild, rc = PTR_ERR(handle));
479 rc = vfs_rmdir(dir, dchild);
483 obdo = lustre_msg_buf(req->rq_repmsg, 1);
484 rc = mds_fs_get_obdo(mds, inode, obdo);
486 CDEBUG(D_INFO, "No obdo for ino %ld err %d\n",
490 handle = mds_fs_start(mds, dir, MDS_FSOP_UNLINK);
492 GOTO(out_unlink_dchild, rc = PTR_ERR(handle));
493 rc = vfs_unlink(dir, dchild);
498 rc = mds_update_last_rcvd(mds, handle, req);
499 err = mds_fs_commit(mds, dir, handle);
501 CERROR("error on commit: err = %d\n", err);
509 res_id[0] = inode->i_ino;
513 ldlm_lock_decref(&lockh, lock_mode);
515 /* Take an exclusive lock on the resource that we're
516 * about to free, to force everyone to drop their
518 LDLM_DEBUG_NOLOCK("getting EX lock res %Lu", res_id[0]);
519 rc = ldlm_cli_enqueue(mds->mds_ldlm_client, mds->mds_ldlm_conn,
520 (struct lustre_handle *)&mds->mds_connh,
521 NULL, mds->mds_local_namespace, NULL,
523 LDLM_PLAIN, NULL, 0, LCK_EX, &flags,
524 (void *)mds_lock_callback, NULL, 0,
527 CERROR("failed to get child inode lock (child ino %Ld, "
529 res_id[0], de->d_inode->i_ino);
535 ldlm_lock_decref(&lockh, LCK_EX);
536 rc = ldlm_cli_cancel(&lockh, NULL);
538 CERROR("failed to cancel child inode lock ino "
539 "%Ld: %d\n", res_id[0], rc);
547 static int mds_reint_link(struct mds_update_record *rec, int offset,
548 struct ptlrpc_request *req)
550 struct dentry *de_src = NULL;
551 struct dentry *de_tgt_dir = NULL;
552 struct dentry *dchild = NULL;
553 struct mds_obd *mds = mds_req2mds(req);
559 de_src = mds_fid2dentry(mds, rec->ur_fid1, NULL);
560 if (IS_ERR(de_src) || OBD_FAIL_CHECK(OBD_FAIL_MDS_REINT_LINK)) {
561 GOTO(out_link, rc = -ESTALE);
564 de_tgt_dir = mds_fid2dentry(mds, rec->ur_fid2, NULL);
565 if (IS_ERR(de_tgt_dir)) {
566 GOTO(out_link_de_src, rc = -ESTALE);
569 down(&de_tgt_dir->d_inode->i_sem);
570 dchild = lookup_one_len(rec->ur_name, de_tgt_dir, rec->ur_namelen - 1);
571 if (IS_ERR(dchild)) {
572 CERROR("child lookup error %ld\n", PTR_ERR(dchild));
573 GOTO(out_link_de_tgt_dir, rc = -ESTALE);
576 if (dchild->d_inode) {
577 CERROR("child exists (dir %ld, name %s\n",
578 de_tgt_dir->d_inode->i_ino, rec->ur_name);
579 GOTO(out_link_dchild, rc = -EEXIST);
582 OBD_FAIL_WRITE(OBD_FAIL_MDS_REINT_LINK_WRITE,
583 de_src->d_inode->i_sb->s_dev);
585 handle = mds_fs_start(mds, de_tgt_dir->d_inode, MDS_FSOP_LINK);
587 GOTO(out_link_dchild, rc = PTR_ERR(handle));
589 rc = vfs_link(de_src, de_tgt_dir->d_inode, dchild);
592 rc = mds_update_last_rcvd(mds, handle, req);
594 err = mds_fs_commit(mds, de_tgt_dir->d_inode, handle);
596 CERROR("error on commit: err = %d\n", err);
605 up(&de_tgt_dir->d_inode->i_sem);
614 static int mds_reint_rename(struct mds_update_record *rec, int offset,
615 struct ptlrpc_request *req)
617 struct dentry *de_srcdir = NULL;
618 struct dentry *de_tgtdir = NULL;
619 struct dentry *de_old = NULL;
620 struct dentry *de_new = NULL;
621 struct mds_obd *mds = mds_req2mds(req);
622 struct lustre_handle tgtlockh, srclockh, oldhandle;
623 int flags, lock_mode, rc = 0, err;
625 __u64 res_id[3] = {0};
628 de_srcdir = mds_fid2dentry(mds, rec->ur_fid1, NULL);
629 if (IS_ERR(de_srcdir))
630 GOTO(out_rename, rc = -ESTALE);
632 lock_mode = (req->rq_reqmsg->opc == MDS_REINT) ? LCK_CW : LCK_PW;
633 res_id[0] = de_srcdir->d_inode->i_ino;
635 rc = ldlm_lock_match(mds->mds_local_namespace, res_id, LDLM_PLAIN,
636 NULL, 0, lock_mode, &srclockh);
638 LDLM_DEBUG_NOLOCK("enqueue res %Lu", res_id[0]);
639 rc = ldlm_cli_enqueue(mds->mds_ldlm_client, mds->mds_ldlm_conn,
640 (struct lustre_handle *)&mds->mds_connh,
641 NULL, mds->mds_local_namespace, NULL,
642 res_id, LDLM_PLAIN, NULL, 0, lock_mode,
643 &flags, (void *)mds_lock_callback, NULL,
645 if (rc != ELDLM_OK) {
646 CERROR("lock enqueue: err: %d\n", rc);
647 GOTO(out_rename_srcput, rc = -EIO);
650 ldlm_lock_dump((void *)(unsigned long)srclockh.addr);
652 de_tgtdir = mds_fid2dentry(mds, rec->ur_fid2, NULL);
653 if (IS_ERR(de_tgtdir))
654 GOTO(out_rename_srcdir, rc = -ESTALE);
656 lock_mode = (req->rq_reqmsg->opc == MDS_REINT) ? LCK_CW : LCK_PW;
657 res_id[0] = de_tgtdir->d_inode->i_ino;
659 rc = ldlm_lock_match(mds->mds_local_namespace, res_id, LDLM_PLAIN,
660 NULL, 0, lock_mode, &tgtlockh);
662 LDLM_DEBUG_NOLOCK("enqueue res %Lu", res_id[0]);
663 rc = ldlm_cli_enqueue(mds->mds_ldlm_client, mds->mds_ldlm_conn,
664 (struct lustre_handle *)&mds->mds_connh,
665 NULL, mds->mds_local_namespace, NULL,
666 res_id, LDLM_PLAIN, NULL, 0, lock_mode,
667 &flags, (void *)mds_lock_callback, NULL,
669 if (rc != ELDLM_OK) {
670 CERROR("lock enqueue: err: %d\n", rc);
671 GOTO(out_rename_tgtput, rc = -EIO);
674 ldlm_lock_dump((void *)(unsigned long)tgtlockh.addr);
676 double_lock(de_tgtdir, de_srcdir);
678 de_old = lookup_one_len(rec->ur_name, de_srcdir, rec->ur_namelen - 1);
679 if (IS_ERR(de_old)) {
680 CERROR("old child lookup error (%*s): %ld\n",
681 rec->ur_namelen - 1, rec->ur_name, PTR_ERR(de_old));
682 GOTO(out_rename_tgtdir, rc = -ENOENT);
685 de_new = lookup_one_len(rec->ur_tgt, de_tgtdir, rec->ur_tgtlen - 1);
686 if (IS_ERR(de_new)) {
687 CERROR("new child lookup error (%*s): %ld\n",
688 rec->ur_tgtlen - 1, rec->ur_tgt, PTR_ERR(de_new));
689 GOTO(out_rename_deold, rc = -ENOENT);
692 OBD_FAIL_WRITE(OBD_FAIL_MDS_REINT_RENAME_WRITE,
693 de_srcdir->d_inode->i_sb->s_dev);
695 handle = mds_fs_start(mds, de_tgtdir->d_inode, MDS_FSOP_RENAME);
697 GOTO(out_rename_denew, rc = PTR_ERR(handle));
699 rc = vfs_rename(de_srcdir->d_inode, de_old, de_tgtdir->d_inode, de_new,
704 rc = mds_update_last_rcvd(mds, handle, req);
706 err = mds_fs_commit(mds, de_tgtdir->d_inode, handle);
708 CERROR("error on commit: err = %d\n", err);
718 res_id[0] = de_old->d_inode->i_ino;
719 /* Take an exclusive lock on the resource that we're
720 * about to free, to force everyone to drop their
722 LDLM_DEBUG_NOLOCK("getting EX lock res %Lu", res_id[0]);
723 rc = ldlm_cli_enqueue(mds->mds_ldlm_client, mds->mds_ldlm_conn,
724 (struct lustre_handle *)&mds->mds_connh,
725 NULL, mds->mds_local_namespace, NULL,
727 LDLM_PLAIN, NULL, 0, LCK_EX, &flags,
728 (void *)mds_lock_callback, NULL, 0,
731 CERROR("failed to get child inode lock (child ino %Ld, "
733 res_id[0], de_old->d_inode->i_ino);
739 ldlm_lock_decref(&oldhandle, LCK_EX);
740 rc = ldlm_cli_cancel(&oldhandle, NULL);
742 CERROR("failed to cancel child inode lock ino "
743 "%Ld: %d\n", res_id[0], rc);
746 double_up(&de_srcdir->d_inode->i_sem, &de_tgtdir->d_inode->i_sem);
747 ldlm_lock_decref(&tgtlockh, lock_mode);
751 ldlm_lock_decref(&srclockh, lock_mode);
759 typedef int (*mds_reinter)(struct mds_update_record *, int offset,
760 struct ptlrpc_request *);
762 static mds_reinter reinters[REINT_MAX+1] = {
763 [REINT_SETATTR] mds_reint_setattr,
764 [REINT_CREATE] mds_reint_create,
765 [REINT_UNLINK] mds_reint_unlink,
766 [REINT_LINK] mds_reint_link,
767 [REINT_RENAME] mds_reint_rename,
768 [REINT_RECREATE] mds_reint_recreate,
771 int mds_reint_rec(struct mds_update_record *rec, int offset,
772 struct ptlrpc_request *req)
774 struct mds_obd *mds = mds_req2mds(req);
775 struct obd_run_ctxt saved;
779 if (rec->ur_opcode < 1 || rec->ur_opcode > REINT_MAX) {
780 CERROR("opcode %d not valid\n", rec->ur_opcode);
781 rc = req->rq_status = -EINVAL;
785 push_ctxt(&saved, &mds->mds_ctxt);
786 rc = reinters[rec->ur_opcode](rec, offset, req);