1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * linux/mds/mds_reint.c
5 * Lustre Metadata Server (mds) reintegration routines
7 * Copyright (C) 2002, 2003 Cluster File Systems, Inc.
8 * Author: Peter Braam <braam@clusterfs.com>
9 * Author: Andreas Dilger <adilger@clusterfs.com>
10 * Author: Phil Schwan <phil@clusterfs.com>
12 * This file is part of Lustre, http://www.lustre.org.
14 * Lustre is free software; you can redistribute it and/or
15 * modify it under the terms of version 2 of the GNU General Public
16 * License as published by the Free Software Foundation.
18 * Lustre is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with Lustre; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 # define EXPORT_SYMTAB
31 #define DEBUG_SUBSYSTEM S_MDS
34 #include <linux/obd_support.h>
35 #include <linux/obd_class.h>
36 #include <linux/obd.h>
37 #include <linux/lustre_lib.h>
38 #include <linux/lustre_idl.h>
39 #include <linux/lustre_mds.h>
40 #include <linux/lustre_dlm.h>
41 #include <linux/lustre_fsfilt.h>
43 #include "mds_internal.h"
45 void mds_commit_cb(struct obd_device *obd, __u64 transno, void *data,
48 obd_transno_commit_cb(obd, transno, error);
51 struct mds_logcancel_data {
52 struct lov_mds_md *mlcd_lmm;
56 struct llog_cookie mlcd_cookies[0];
60 static void mds_cancel_cookies_cb(struct obd_device *obd, __u64 transno,
61 void *cb_data, int error)
63 struct mds_logcancel_data *mlcd = cb_data;
64 struct lov_stripe_md *lsm = NULL;
66 struct llog_ctxt *ctxt;
70 obd_transno_commit_cb(obd, transno, error);
72 CDEBUG(D_HA, "cancelling %d cookies\n",
73 (int)(mlcd->mlcd_cookielen / sizeof(*mlcd->mlcd_cookies)));
75 rc = obd_unpackmd(obd->u.mds.mds_osc_exp, &lsm, mlcd->mlcd_lmm,
76 mlcd->mlcd_eadatalen);
78 CERROR("bad LSM cancelling %d log cookies: rc %d\n",
79 (int)(mlcd->mlcd_cookielen/sizeof(*mlcd->mlcd_cookies)),
83 ///* XXX 0 normally, SENDNOW for debug */);
84 ctxt = llog_get_context(obd, mlcd->mlcd_cookies[0].lgc_subsys + 1);
85 rc = llog_cancel(ctxt, lsm,
86 mlcd->mlcd_cookielen /
87 sizeof(*mlcd->mlcd_cookies),
88 mlcd->mlcd_cookies, OBD_LLOG_FL_SENDNOW);
90 CERROR("error cancelling %d log cookies: rc %d\n",
91 (int)(mlcd->mlcd_cookielen /
92 sizeof(*mlcd->mlcd_cookies)), rc);
96 OBD_FREE(mlcd, mlcd->mlcd_size);
99 /* Assumes caller has already pushed us into the kernel context. */
100 int mds_finish_transno(struct mds_obd *mds, struct inode *inode, void *handle,
101 struct ptlrpc_request *req, int rc, __u32 op_data)
103 struct mds_export_data *med = &req->rq_export->exp_mds_data;
104 struct mds_client_data *mcd = med->med_mcd;
105 struct obd_device *obd = req->rq_export->exp_obd;
112 /* if the export has already been failed, we have no last_rcvd slot */
113 if (req->rq_export->exp_failed) {
114 CERROR("committing transaction for disconnected client\n");
123 if (handle == NULL) {
124 /* if we're starting our own xaction, use our own inode */
125 inode = mds->mds_rcvd_filp->f_dentry->d_inode;
126 handle = fsfilt_start(obd, inode, FSFILT_OP_SETATTR, NULL);
127 if (IS_ERR(handle)) {
128 CERROR("fsfilt_start: %ld\n", PTR_ERR(handle));
129 RETURN(PTR_ERR(handle));
135 transno = req->rq_reqmsg->transno;
137 spin_lock(&mds->mds_transno_lock);
138 transno = ++mds->mds_last_transno;
139 spin_unlock(&mds->mds_transno_lock);
141 spin_lock(&mds->mds_transno_lock);
142 if (transno > mds->mds_last_transno)
143 mds->mds_last_transno = transno;
144 spin_unlock(&mds->mds_transno_lock);
146 req->rq_repmsg->transno = req->rq_transno = transno;
147 mcd->mcd_last_transno = cpu_to_le64(transno);
148 mcd->mcd_mount_count = cpu_to_le64(mds->mds_mount_count);
149 mcd->mcd_last_xid = cpu_to_le64(req->rq_xid);
150 mcd->mcd_last_result = cpu_to_le32(rc);
151 mcd->mcd_last_data = cpu_to_le32(op_data);
153 fsfilt_add_journal_cb(req->rq_export->exp_obd, transno, handle,
154 mds_commit_cb, NULL);
155 err = fsfilt_write_record(obd, mds->mds_rcvd_filp, mcd, sizeof(*mcd),
164 DEBUG_REQ(log_pri, req,
165 "wrote trans #"LPU64" client %s at idx %u: err = %d\n",
166 transno, mcd->mcd_uuid, med->med_idx, err);
168 err = mds_lov_write_objids(obd);
174 CDEBUG(log_pri, "wrote objids: err = %d\n", err);
177 err = fsfilt_commit(obd, inode, handle, 0);
179 CERROR("error committing transaction: %d\n", err);
187 /* this gives the same functionality as the code between
188 * sys_chmod and inode_setattr
189 * chown_common and inode_setattr
190 * utimes and inode_setattr
192 int mds_fix_attr(struct inode *inode, struct mds_update_record *rec)
194 time_t now = LTIME_S(CURRENT_TIME);
195 struct iattr *attr = &rec->ur_iattr;
196 unsigned int ia_valid = attr->ia_valid;
200 /* only fix up attrs if the client VFS didn't already */
201 if (!(ia_valid & ATTR_RAW))
204 if (!(ia_valid & ATTR_CTIME_SET))
205 LTIME_S(attr->ia_ctime) = now;
206 if (!(ia_valid & ATTR_ATIME_SET))
207 LTIME_S(attr->ia_atime) = now;
208 if (!(ia_valid & ATTR_MTIME_SET))
209 LTIME_S(attr->ia_mtime) = now;
211 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
215 if ((ia_valid & (ATTR_MTIME|ATTR_ATIME)) == (ATTR_MTIME|ATTR_ATIME)) {
216 if (rec->ur_fsuid != inode->i_uid &&
217 (error = ll_permission(inode, MAY_WRITE, NULL)) != 0)
221 if (ia_valid & ATTR_SIZE) {
222 if ((error = ll_permission(inode, MAY_WRITE, NULL)) != 0)
226 if (ia_valid & ATTR_UID) {
229 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
231 if (attr->ia_uid == (uid_t) -1)
232 attr->ia_uid = inode->i_uid;
233 if (attr->ia_gid == (gid_t) -1)
234 attr->ia_gid = inode->i_gid;
235 attr->ia_mode = inode->i_mode;
237 * If the user or group of a non-directory has been
238 * changed by a non-root user, remove the setuid bit.
239 * 19981026 David C Niemi <niemi@tux.org>
241 * Changed this to apply to all users, including root,
242 * to avoid some races. This is the behavior we had in
243 * 2.0. The check for non-root was definitely wrong
244 * for 2.2 anyway, as it should have been using
245 * CAP_FSETID rather than fsuid -- 19990830 SD.
247 if ((inode->i_mode & S_ISUID) == S_ISUID &&
248 !S_ISDIR(inode->i_mode)) {
249 attr->ia_mode &= ~S_ISUID;
250 attr->ia_valid |= ATTR_MODE;
253 * Likewise, if the user or group of a non-directory
254 * has been changed by a non-root user, remove the
255 * setgid bit UNLESS there is no group execute bit
256 * (this would be a file marked for mandatory
257 * locking). 19981026 David C Niemi <niemi@tux.org>
259 * Removed the fsuid check (see the comment above) --
262 if (((inode->i_mode & (S_ISGID | S_IXGRP)) ==
263 (S_ISGID | S_IXGRP)) && !S_ISDIR(inode->i_mode)) {
264 attr->ia_mode &= ~S_ISGID;
265 attr->ia_valid |= ATTR_MODE;
267 } else if (ia_valid & ATTR_MODE) {
268 int mode = attr->ia_mode;
270 if (attr->ia_mode == (mode_t) -1)
271 attr->ia_mode = inode->i_mode;
273 (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
278 void mds_req_from_mcd(struct ptlrpc_request *req, struct mds_client_data *mcd)
280 DEBUG_REQ(D_HA, req, "restoring transno "LPD64"/status %d",
281 mcd->mcd_last_transno, mcd->mcd_last_result);
282 req->rq_repmsg->transno = req->rq_transno = mcd->mcd_last_transno;
283 req->rq_repmsg->status = req->rq_status = mcd->mcd_last_result;
285 if (req->rq_export->exp_outstanding_reply)
286 mds_steal_ack_locks(req->rq_export, req);
289 static void reconstruct_reint_setattr(struct mds_update_record *rec,
290 int offset, struct ptlrpc_request *req)
292 struct mds_export_data *med = &req->rq_export->exp_mds_data;
293 struct mds_obd *obd = &req->rq_export->exp_obd->u.mds;
295 struct mds_body *body;
297 mds_req_from_mcd(req, med->med_mcd);
299 if (req->rq_export->exp_outstanding_reply)
300 mds_steal_ack_locks(req->rq_export, req);
302 de = mds_fid2dentry(obd, rec->ur_fid1, NULL);
304 LASSERT(PTR_ERR(de) == req->rq_status);
308 body = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*body));
309 mds_pack_inode2fid(&body->fid1, de->d_inode);
310 mds_pack_inode2body(body, de->d_inode);
312 /* Don't return OST-specific attributes if we didn't just set them */
313 if (rec->ur_iattr.ia_valid & ATTR_SIZE)
314 body->valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS;
315 if (rec->ur_iattr.ia_valid & (ATTR_MTIME | ATTR_MTIME_SET))
316 body->valid |= OBD_MD_FLMTIME;
317 if (rec->ur_iattr.ia_valid & (ATTR_ATIME | ATTR_ATIME_SET))
318 body->valid |= OBD_MD_FLATIME;
323 /* In the raw-setattr case, we lock the child inode.
324 * In the write-back case or if being called from open, the client holds a lock
327 * We use the ATTR_FROM_OPEN flag to tell these cases apart. */
328 static int mds_reint_setattr(struct mds_update_record *rec, int offset,
329 struct ptlrpc_request *req,
330 struct lustre_handle *lh)
332 struct mds_obd *mds = mds_req2mds(req);
333 struct obd_device *obd = req->rq_export->exp_obd;
334 struct mds_body *body;
336 struct inode *inode = NULL;
337 struct lustre_handle lockh;
339 struct mds_logcancel_data *mlcd = NULL;
340 int rc = 0, cleanup_phase = 0, err, locked = 0;
343 LASSERT(offset == 0);
345 MDS_CHECK_RESENT(req, reconstruct_reint_setattr(rec, offset, req));
347 if (rec->ur_iattr.ia_valid & ATTR_FROM_OPEN) {
348 de = mds_fid2dentry(mds, rec->ur_fid1, NULL);
350 GOTO(cleanup, rc = PTR_ERR(de));
352 de = mds_fid2locked_dentry(obd, rec->ur_fid1, NULL, LCK_PW,
355 GOTO(cleanup, rc = PTR_ERR(de));
362 if (S_ISREG(inode->i_mode) && rec->ur_eadata != NULL)
365 CDEBUG(D_INODE, "ino %lu\n", inode->i_ino);
366 OBD_FAIL_WRITE(OBD_FAIL_MDS_REINT_SETATTR_WRITE, inode->i_sb);
368 handle = fsfilt_start(obd, inode, FSFILT_OP_SETATTR, NULL);
370 GOTO(cleanup, rc = PTR_ERR(handle));
372 if (rec->ur_iattr.ia_valid & (ATTR_MTIME | ATTR_CTIME))
373 CDEBUG(D_INODE, "setting mtime %lu, ctime %lu\n",
374 LTIME_S(rec->ur_iattr.ia_mtime),
375 LTIME_S(rec->ur_iattr.ia_ctime));
376 rc = mds_fix_attr(inode, rec);
380 if (rec->ur_iattr.ia_valid & ATTR_ATTR_FLAG) /* ioctl */
381 rc = fsfilt_iocontrol(obd, inode, NULL, EXT3_IOC_SETFLAGS,
382 (long)&rec->ur_iattr.ia_attr_flags);
384 rc = fsfilt_setattr(obd, de, handle, &rec->ur_iattr, 0);
386 if (rc == 0 && S_ISREG(inode->i_mode) && rec->ur_eadata != NULL) {
387 rc = fsfilt_set_md(obd, inode, handle,
388 rec->ur_eadata, rec->ur_eadatalen);
391 body = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*body));
392 mds_pack_inode2fid(&body->fid1, inode);
393 mds_pack_inode2body(body, inode);
395 /* Don't return OST-specific attributes if we didn't just set them */
396 if (rec->ur_iattr.ia_valid & ATTR_SIZE)
397 body->valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS;
398 if (rec->ur_iattr.ia_valid & (ATTR_MTIME | ATTR_MTIME_SET))
399 body->valid |= OBD_MD_FLMTIME;
400 if (rec->ur_iattr.ia_valid & (ATTR_ATIME | ATTR_ATIME_SET))
401 body->valid |= OBD_MD_FLATIME;
403 if (rc == 0 && rec->ur_cookielen && !IS_ERR(mds->mds_osc_obd)) {
404 OBD_ALLOC(mlcd, sizeof(*mlcd) + rec->ur_cookielen +
407 mlcd->mlcd_size = sizeof(*mlcd) + rec->ur_cookielen +
409 mlcd->mlcd_eadatalen = rec->ur_eadatalen;
410 mlcd->mlcd_cookielen = rec->ur_cookielen;
411 mlcd->mlcd_lmm = (void *)&mlcd->mlcd_cookies +
412 mlcd->mlcd_cookielen;
413 memcpy(&mlcd->mlcd_cookies, rec->ur_logcookies,
414 mlcd->mlcd_cookielen);
415 memcpy(mlcd->mlcd_lmm, rec->ur_eadata,
416 mlcd->mlcd_eadatalen);
418 CERROR("unable to allocate log cancel data\n");
424 fsfilt_add_journal_cb(req->rq_export->exp_obd, 0, handle,
425 mds_cancel_cookies_cb, mlcd);
426 err = mds_finish_transno(mds, inode, handle, req, rc, 0);
427 switch (cleanup_phase) {
429 if (S_ISREG(inode->i_mode) && rec->ur_eadata != NULL)
434 ldlm_lock_decref(&lockh, LCK_PW);
436 ldlm_put_lock_into_req(req, &lockh, LCK_PW);
451 static void reconstruct_reint_create(struct mds_update_record *rec, int offset,
452 struct ptlrpc_request *req)
454 struct mds_export_data *med = &req->rq_export->exp_mds_data;
455 struct mds_obd *obd = &req->rq_export->exp_obd->u.mds;
456 struct dentry *parent, *child;
457 struct mds_body *body;
459 mds_req_from_mcd(req, med->med_mcd);
464 parent = mds_fid2dentry(obd, rec->ur_fid1, NULL);
465 LASSERT(!IS_ERR(parent));
466 child = ll_lookup_one_len(rec->ur_name, parent, rec->ur_namelen - 1);
467 LASSERT(!IS_ERR(child));
468 body = lustre_msg_buf(req->rq_repmsg, offset, sizeof (*body));
469 mds_pack_inode2fid(&body->fid1, child->d_inode);
470 mds_pack_inode2body(body, child->d_inode);
475 static int mds_reint_create(struct mds_update_record *rec, int offset,
476 struct ptlrpc_request *req,
477 struct lustre_handle *lh)
479 struct dentry *dparent = NULL;
480 struct mds_obd *mds = mds_req2mds(req);
481 struct obd_device *obd = req->rq_export->exp_obd;
482 struct dentry *dchild = NULL;
483 struct inode *dir = NULL;
485 struct lustre_handle lockh;
486 int rc = 0, err, type = rec->ur_mode & S_IFMT, cleanup_phase = 0;
488 struct dentry_params dp;
491 LASSERT(offset == 0);
492 LASSERT(!strcmp(req->rq_export->exp_obd->obd_type->typ_name, "mds"));
494 MDS_CHECK_RESENT(req, reconstruct_reint_create(rec, offset, req));
496 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_REINT_CREATE))
497 GOTO(cleanup, rc = -ESTALE);
499 dparent = mds_fid2locked_dentry(obd, rec->ur_fid1, NULL, LCK_PW, &lockh,
500 rec->ur_name, rec->ur_namelen - 1);
501 if (IS_ERR(dparent)) {
502 rc = PTR_ERR(dparent);
503 CERROR("parent lookup error %d\n", rc);
506 cleanup_phase = 1; /* locked parent dentry */
507 dir = dparent->d_inode;
509 CDEBUG(D_INODE, "parent ino %lu creating name %s mode %o\n",
510 dir->i_ino, rec->ur_name, rec->ur_mode);
512 ldlm_lock_dump_handle(D_OTHER, &lockh);
514 dchild = ll_lookup_one_len(rec->ur_name, dparent, rec->ur_namelen - 1);
515 if (IS_ERR(dchild)) {
516 rc = PTR_ERR(dchild);
517 CERROR("child lookup error %d\n", rc);
521 cleanup_phase = 2; /* child dentry */
523 OBD_FAIL_WRITE(OBD_FAIL_MDS_REINT_CREATE_WRITE, dir->i_sb);
525 if (dir->i_mode & S_ISGID) {
526 if (S_ISDIR(rec->ur_mode))
527 rec->ur_mode |= S_ISGID;
530 dchild->d_fsdata = (void *)&dp;
531 dp.p_inum = (unsigned long)rec->ur_fid2->id;
536 handle = fsfilt_start(obd, dir, FSFILT_OP_CREATE, NULL);
538 GOTO(cleanup, rc = PTR_ERR(handle));
539 rc = ll_vfs_create(dir, dchild, rec->ur_mode, NULL);
544 handle = fsfilt_start(obd, dir, FSFILT_OP_MKDIR, NULL);
546 GOTO(cleanup, rc = PTR_ERR(handle));
547 rc = vfs_mkdir(dir, dchild, rec->ur_mode);
552 handle = fsfilt_start(obd, dir, FSFILT_OP_SYMLINK, NULL);
554 GOTO(cleanup, rc = PTR_ERR(handle));
555 if (rec->ur_tgt == NULL) /* no target supplied */
556 rc = -EINVAL; /* -EPROTO? */
558 rc = vfs_symlink(dir, dchild, rec->ur_tgt);
566 int rdev = rec->ur_rdev;
567 handle = fsfilt_start(obd, dir, FSFILT_OP_MKNOD, NULL);
569 GOTO(cleanup, (handle = NULL, rc = PTR_ERR(handle)));
570 rc = vfs_mknod(dir, dchild, rec->ur_mode, rdev);
575 CERROR("bad file type %o creating %s\n", type, rec->ur_name);
576 dchild->d_fsdata = NULL;
577 GOTO(cleanup, rc = -EINVAL);
580 /* In case we stored the desired inum in here, we want to clean up. */
581 if (dchild->d_fsdata == (void *)(unsigned long)rec->ur_fid2->id)
582 dchild->d_fsdata = NULL;
585 CDEBUG(D_INODE, "error during create: %d\n", rc);
589 struct inode *inode = dchild->d_inode;
590 struct mds_body *body;
593 LTIME_S(iattr.ia_atime) = rec->ur_time;
594 LTIME_S(iattr.ia_ctime) = rec->ur_time;
595 LTIME_S(iattr.ia_mtime) = rec->ur_time;
596 iattr.ia_uid = rec->ur_fsuid;
597 if (dir->i_mode & S_ISGID)
598 iattr.ia_gid = dir->i_gid;
600 iattr.ia_gid = rec->ur_fsgid;
601 iattr.ia_valid = ATTR_UID | ATTR_GID | ATTR_ATIME |
602 ATTR_MTIME | ATTR_CTIME;
604 if (rec->ur_fid2->id) {
605 LASSERT(rec->ur_fid2->id == inode->i_ino);
606 inode->i_generation = rec->ur_fid2->generation;
607 /* Dirtied and committed by the upcoming setattr. */
608 CDEBUG(D_INODE, "recreated ino %lu with gen %u\n",
609 inode->i_ino, inode->i_generation);
611 struct lustre_handle child_ino_lockh;
612 struct ldlm_res_id child_res_id =
613 { .name = { inode->i_ino, 0 } };
616 CDEBUG(D_INODE, "created ino %lu with gen %x\n",
617 inode->i_ino, inode->i_generation);
619 /* The inode we were allocated may have just been freed
620 * by an unlink operation. We take this lock to
621 * synchronize against the matching reply-ack-lock taken
622 * in unlink, to avoid replay problems if this reply
623 * makes it out to the client but the unlink's does not.
624 * See bug 2029 for more detail.*/
625 rc = ldlm_cli_enqueue(NULL, NULL, obd->obd_namespace,
626 NULL, child_res_id, LDLM_PLAIN,
627 NULL, 0, LCK_EX, &lock_flags,
629 mds_blocking_ast, NULL,
631 if (rc != ELDLM_OK) {
632 CERROR("error locking for unlink/create sync: "
635 ldlm_lock_decref(&child_ino_lockh, LCK_EX);
639 rc = fsfilt_setattr(obd, dchild, handle, &iattr, 0);
641 CERROR("error on child setattr: rc = %d\n", rc);
643 iattr.ia_valid = ATTR_MTIME | ATTR_CTIME;
644 rc = fsfilt_setattr(obd, dparent, handle, &iattr, 0);
646 CERROR("error on parent setattr: rc = %d\n", rc);
648 body = lustre_msg_buf(req->rq_repmsg, offset, sizeof (*body));
649 mds_pack_inode2fid(&body->fid1, inode);
650 mds_pack_inode2body(body, inode);
655 err = mds_finish_transno(mds, dir, handle, req, rc, 0);
658 /* Destroy the file we just created. This should not need
659 * extra journal credits, as we have already modified all of
660 * the blocks needed in order to create the file in the first
665 err = vfs_rmdir(dir, dchild);
667 CERROR("rmdir in error path: %d\n", err);
670 err = vfs_unlink(dir, dchild);
672 CERROR("unlink in error path: %d\n", err);
678 switch (cleanup_phase) {
679 case 2: /* child dentry */
681 case 1: /* locked parent dentry */
683 ldlm_lock_decref(&lockh, LCK_PW);
685 ldlm_put_lock_into_req(req, &lockh, LCK_PW);
691 CERROR("invalid cleanup_phase %d\n", cleanup_phase);
698 /* This function doesn't use ldlm_match_or_enqueue because we're always called
699 * with EX or PW locks, and the MDS is no longer allowed to match write locks,
700 * because they take the place of local semaphores.
702 * Two locks are taken in numerical order */
703 int enqueue_ordered_locks(int lock_mode, struct obd_device *obd,
704 struct ldlm_res_id *p1_res_id,
705 struct ldlm_res_id *p2_res_id,
706 struct lustre_handle *p1_lockh,
707 struct lustre_handle *p2_lockh)
709 struct ldlm_res_id res_id[2];
710 struct lustre_handle *handles[2] = {p1_lockh, p2_lockh};
714 LASSERT(p1_res_id != NULL && p2_res_id != NULL);
716 CDEBUG(D_INFO, "locks before: "LPU64"/"LPU64"\n",
717 p1_res_id[0].name[0], p2_res_id[0].name[0]);
719 if (p1_res_id->name[0] < p2_res_id->name[0]) {
720 handles[0] = p1_lockh;
721 handles[1] = p2_lockh;
722 res_id[0] = *p1_res_id;
723 res_id[1] = *p2_res_id;
725 handles[1] = p1_lockh;
726 handles[0] = p2_lockh;
727 res_id[1] = *p1_res_id;
728 res_id[0] = *p2_res_id;
731 CDEBUG(D_INFO, "lock order: "LPU64"/"LPU64"\n",
732 p1_res_id[0].name[0], p2_res_id[0].name[0]);
734 flags = LDLM_FL_LOCAL_ONLY;
735 rc = ldlm_cli_enqueue(NULL, NULL, obd->obd_namespace, NULL, res_id[0],
736 LDLM_PLAIN, NULL, 0, lock_mode, &flags,
737 ldlm_completion_ast, mds_blocking_ast, NULL,
741 ldlm_lock_dump_handle(D_OTHER, handles[0]);
743 if (memcmp(&res_id[0], &res_id[1], sizeof(res_id[0])) == 0) {
744 memcpy(handles[1], handles[0], sizeof(*(handles[1])));
745 ldlm_lock_addref(handles[1], lock_mode);
747 flags = LDLM_FL_LOCAL_ONLY;
748 rc = ldlm_cli_enqueue(NULL, NULL, obd->obd_namespace, NULL,
749 res_id[1], LDLM_PLAIN, NULL, 0, lock_mode,
750 &flags, ldlm_completion_ast,
751 mds_blocking_ast, NULL, handles[1]);
752 if (rc != ELDLM_OK) {
753 ldlm_lock_decref(handles[0], lock_mode);
757 ldlm_lock_dump_handle(D_OTHER, handles[1]);
762 void mds_reconstruct_generic(struct ptlrpc_request *req)
764 struct mds_export_data *med = &req->rq_export->exp_mds_data;
766 mds_req_from_mcd(req, med->med_mcd);
769 static int mds_reint_unlink(struct mds_update_record *rec, int offset,
770 struct ptlrpc_request *req,
771 struct lustre_handle *lh)
773 struct dentry *dparent = NULL;
774 struct dentry *dchild = NULL;
775 struct mds_obd *mds = mds_req2mds(req);
776 struct obd_device *obd = req->rq_export->exp_obd;
777 struct mds_body *body = NULL;
778 struct inode *child_inode;
779 struct lustre_handle parent_lockh, child_lockh, child_reuse_lockh;
781 struct ldlm_res_id child_res_id = { .name = {0} };
782 int rc = 0, flags = 0, log_unlink = 0, cleanup_phase = 0;
785 LASSERT(offset == 0 || offset == 2);
787 MDS_CHECK_RESENT(req, mds_reconstruct_generic(req));
789 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_REINT_UNLINK))
790 GOTO(cleanup, rc = -ENOENT);
792 /* Step 1: Lookup the parent by FID */
793 dparent = mds_fid2locked_dentry(obd, rec->ur_fid1, NULL, LCK_PW,
794 &parent_lockh, rec->ur_name,
795 rec->ur_namelen - 1);
797 GOTO(cleanup, rc = PTR_ERR(dparent));
798 LASSERT(dparent->d_inode);
800 cleanup_phase = 1; /* Have parent dentry lock */
802 /* Step 2: Lookup the child */
803 dchild = ll_lookup_one_len(rec->ur_name, dparent, rec->ur_namelen - 1);
805 GOTO(cleanup, rc = PTR_ERR(dchild));
807 cleanup_phase = 2; /* child dentry */
809 child_inode = dchild->d_inode;
810 if (child_inode == NULL) {
811 CDEBUG(D_INODE, "child doesn't exist (dir %lu, name %s)\n",
812 dparent->d_inode->i_ino, rec->ur_name);
813 GOTO(cleanup, rc = -ENOENT);
816 DEBUG_REQ(D_INODE, req, "parent ino %lu, child ino %lu",
817 dparent->d_inode->i_ino, child_inode->i_ino);
819 /* Step 3: Get a lock on the child */
820 child_res_id.name[0] = child_inode->i_ino;
821 child_res_id.name[1] = child_inode->i_generation;
823 rc = ldlm_cli_enqueue(NULL, NULL, obd->obd_namespace, NULL,
824 child_res_id, LDLM_PLAIN, NULL, 0, LCK_EX,
825 &flags, ldlm_completion_ast, mds_blocking_ast,
830 cleanup_phase = 3; /* child lock */
832 /* Step 4: Get a lock on the ino to sync with creation WRT inode
833 * reuse (see bug 2029). */
834 child_res_id.name[1] = 0;
836 rc = ldlm_cli_enqueue(NULL, NULL, obd->obd_namespace, NULL,
837 child_res_id, LDLM_PLAIN, NULL, 0, LCK_EX,
838 &flags, ldlm_completion_ast, mds_blocking_ast,
839 NULL, &child_reuse_lockh);
843 cleanup_phase = 4; /* child lock */
845 OBD_FAIL_WRITE(OBD_FAIL_MDS_REINT_UNLINK_WRITE, dparent->d_inode->i_sb);
847 /* ldlm_reply in buf[0] if called via intent */
851 body = lustre_msg_buf(req->rq_repmsg, offset, sizeof (*body));
852 LASSERT(body != NULL);
854 /* If this is the last reference to this inode, get the OBD EA
855 * data first so the client can destroy OST objects.
856 * we only do the object removal if no open files remain.
857 * Nobody can get at this name anymore because of the locks so
858 * we make decisions here as to whether to remove the inode */
859 if (S_ISREG(child_inode->i_mode) && child_inode->i_nlink == 1 &&
860 mds_open_orphan_count(child_inode) == 0) {
861 mds_pack_inode2fid(&body->fid1, child_inode);
862 mds_pack_inode2body(body, child_inode);
863 mds_pack_md(obd, req->rq_repmsg, offset + 1, body,
865 if (!(body->valid & OBD_MD_FLEASIZE)) {
866 body->valid |= (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS |
867 OBD_MD_FLATIME | OBD_MD_FLMTIME);
873 /* We have to do these checks ourselves, in case we are making an
874 * orphan. The client tells us whether rmdir() or unlink() was called,
875 * so we need to return appropriate errors (bug 72).
877 * We don't have to check permissions, because vfs_rename (called from
878 * mds_open_unlink_rename) also calls may_delete. */
879 if ((rec->ur_mode & S_IFMT) == S_IFDIR) {
880 if (!S_ISDIR(child_inode->i_mode))
881 GOTO(cleanup, rc = -ENOTDIR);
883 if (S_ISDIR(child_inode->i_mode))
884 GOTO(cleanup, rc = -EISDIR);
887 if (child_inode->i_nlink == (S_ISDIR(child_inode->i_mode) ? 2 : 1) &&
888 mds_open_orphan_count(child_inode) > 0) {
889 rc = mds_open_unlink_rename(rec, obd, dparent, dchild, &handle);
890 cleanup_phase = 5; /* transaction */
894 /* Step 4: Do the unlink: we already verified ur_mode above (bug 72) */
895 switch (child_inode->i_mode & S_IFMT) {
897 /* Drop any lingering child directories before we start our
898 * transaction, to avoid doing multiple inode dirty/delete
899 * in our compound transaction (bug 1321). */
900 shrink_dcache_parent(dchild);
901 handle = fsfilt_start(obd, dparent->d_inode, FSFILT_OP_RMDIR,
904 GOTO(cleanup, rc = PTR_ERR(handle));
905 cleanup_phase = 5; /* transaction */
906 rc = vfs_rmdir(dparent->d_inode, dchild);
909 handle = fsfilt_start(obd, dparent->d_inode,
910 FSFILT_OP_UNLINK_LOG, NULL);
912 GOTO(cleanup, rc = PTR_ERR(handle));
914 cleanup_phase = 5; /* transaction */
915 rc = vfs_unlink(dparent->d_inode, dchild);
917 #ifdef ENABLE_ORPHANS
919 if (!rc && log_unlink)
920 if (mds_log_op_unlink(obd, child_inode, req->rq_repmsg,
922 body->valid |= OBD_MD_FLCOOKIE;
931 handle = fsfilt_start(obd, dparent->d_inode, FSFILT_OP_UNLINK,
934 GOTO(cleanup, rc = PTR_ERR(handle));
936 rc = vfs_unlink(dparent->d_inode, dchild);
939 CERROR("bad file type %o unlinking %s\n", rec->ur_mode,
942 GOTO(cleanup, rc = -EINVAL);
950 iattr.ia_valid = ATTR_MTIME | ATTR_CTIME;
951 LTIME_S(iattr.ia_mtime) = rec->ur_time;
952 LTIME_S(iattr.ia_ctime) = rec->ur_time;
954 err = fsfilt_setattr(obd, dparent, handle, &iattr, 0);
956 CERROR("error on parent setattr: rc = %d\n", err);
959 switch(cleanup_phase) {
961 rc = mds_finish_transno(mds, dparent->d_inode, handle, req,
964 (void)obd_set_info(mds->mds_osc_exp, strlen("unlinked"),
965 "unlinked", 0, NULL);
966 case 4: /* child ino-reuse lock */
967 if (rc && body != NULL) {
968 // Don't unlink the OST objects if the MDS unlink failed
972 ldlm_lock_decref(&child_reuse_lockh, LCK_EX);
974 ldlm_put_lock_into_req(req, &child_reuse_lockh, LCK_EX);
975 case 3: /* child lock */
976 ldlm_lock_decref(&child_lockh, LCK_EX);
977 case 2: /* child dentry */
979 case 1: /* parent dentry and lock */
981 ldlm_lock_decref(&parent_lockh, LCK_PW);
983 ldlm_put_lock_into_req(req, &parent_lockh, LCK_PW);
989 CERROR("invalid cleanup_phase %d\n", cleanup_phase);
996 static int mds_reint_link(struct mds_update_record *rec, int offset,
997 struct ptlrpc_request *req,
998 struct lustre_handle *lh)
1000 struct obd_device *obd = req->rq_export->exp_obd;
1001 struct dentry *de_src = NULL;
1002 struct dentry *de_tgt_dir = NULL;
1003 struct dentry *dchild = NULL;
1004 struct mds_obd *mds = mds_req2mds(req);
1005 struct lustre_handle *handle = NULL, tgt_dir_lockh, src_lockh;
1006 struct ldlm_res_id src_res_id = { .name = {0} };
1007 struct ldlm_res_id tgt_dir_res_id = { .name = {0} };
1008 int lock_mode = 0, rc = 0, cleanup_phase = 0;
1011 LASSERT(offset == 0);
1013 MDS_CHECK_RESENT(req, mds_reconstruct_generic(req));
1015 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_REINT_LINK))
1016 GOTO(cleanup, rc = -ENOENT);
1018 /* Step 1: Lookup the source inode and target directory by FID */
1019 de_src = mds_fid2dentry(mds, rec->ur_fid1, NULL);
1021 GOTO(cleanup, rc = PTR_ERR(de_src));
1023 cleanup_phase = 1; /* source dentry */
1025 de_tgt_dir = mds_fid2dentry(mds, rec->ur_fid2, NULL);
1026 if (IS_ERR(de_tgt_dir))
1027 GOTO(cleanup, rc = PTR_ERR(de_tgt_dir));
1029 cleanup_phase = 2; /* target directory dentry */
1031 CDEBUG(D_INODE, "linking %*s/%s to inode %lu\n",
1032 de_tgt_dir->d_name.len, de_tgt_dir->d_name.name, rec->ur_name,
1033 de_src->d_inode->i_ino);
1035 /* Step 2: Take the two locks */
1037 src_res_id.name[0] = de_src->d_inode->i_ino;
1038 src_res_id.name[1] = de_src->d_inode->i_generation;
1039 tgt_dir_res_id.name[0] = de_tgt_dir->d_inode->i_ino;
1040 tgt_dir_res_id.name[1] = de_tgt_dir->d_inode->i_generation;
1042 rc = enqueue_ordered_locks(LCK_EX, obd, &src_res_id, &tgt_dir_res_id,
1043 &src_lockh, &tgt_dir_lockh);
1045 GOTO(cleanup, rc = -EIO);
1047 cleanup_phase = 3; /* locks */
1049 /* Step 3: Lookup the child */
1050 dchild = ll_lookup_one_len(rec->ur_name, de_tgt_dir, rec->ur_namelen-1);
1051 if (IS_ERR(dchild)) {
1052 rc = PTR_ERR(dchild);
1053 if (rc != -EPERM && rc != -EACCES)
1054 CERROR("child lookup error %d\n", rc);
1058 cleanup_phase = 4; /* child dentry */
1060 if (dchild->d_inode) {
1061 CDEBUG(D_INODE, "child exists (dir %lu, name %s)\n",
1062 de_tgt_dir->d_inode->i_ino, rec->ur_name);
1067 /* Step 4: Do it. */
1068 OBD_FAIL_WRITE(OBD_FAIL_MDS_REINT_LINK_WRITE, de_src->d_inode->i_sb);
1070 handle = fsfilt_start(obd, de_tgt_dir->d_inode, FSFILT_OP_LINK, NULL);
1071 if (IS_ERR(handle)) {
1072 rc = PTR_ERR(handle);
1076 rc = vfs_link(de_src, de_tgt_dir->d_inode, dchild);
1077 if (rc && rc != -EPERM && rc != -EACCES)
1078 CERROR("vfs_link error %d\n", rc);
1080 rc = mds_finish_transno(mds, de_tgt_dir ? de_tgt_dir->d_inode : NULL,
1081 handle, req, rc, 0);
1084 switch (cleanup_phase) {
1085 case 4: /* child dentry */
1089 ldlm_lock_decref(&src_lockh, lock_mode);
1090 ldlm_lock_decref(&tgt_dir_lockh, lock_mode);
1092 ldlm_put_lock_into_req(req, &src_lockh, lock_mode);
1093 ldlm_put_lock_into_req(req, &tgt_dir_lockh, lock_mode);
1095 case 2: /* target dentry */
1097 case 1: /* source dentry */
1102 CERROR("invalid cleanup_phase %d\n", cleanup_phase);
1105 req->rq_status = rc;
1110 * add a hard link in the PENDING directory, only used by rename()
1112 static int mds_add_link_orphan(struct mds_update_record *rec,
1113 struct obd_device *obd,
1114 struct dentry *dentry)
1116 struct mds_obd *mds = &obd->u.mds;
1117 struct inode *pending_dir = mds->mds_pending_dir->d_inode;
1118 struct dentry *pending_child;
1119 char fidname[LL_FID_NAMELEN];
1123 LASSERT(dentry->d_inode);
1124 LASSERT(!mds_inode_is_orphan(dentry->d_inode));
1126 down(&pending_dir->i_sem);
1127 fidlen = ll_fid2str(fidname, dentry->d_inode->i_ino,
1128 dentry->d_inode->i_generation);
1130 CDEBUG(D_ERROR, "pending destroy of %dx open file %s = %s\n",
1131 mds_open_orphan_count(dentry->d_inode),
1132 rec->ur_name, fidname);
1134 pending_child = lookup_one_len(fidname, mds->mds_pending_dir, fidlen);
1135 if (IS_ERR(pending_child))
1136 GOTO(out_lock, rc = PTR_ERR(pending_child));
1138 if (pending_child->d_inode != NULL) {
1139 CERROR("re-destroying orphan file %s?\n", rec->ur_name);
1140 LASSERT(pending_child->d_inode == dentry->d_inode);
1141 GOTO(out_dput, rc = 0);
1145 rc = vfs_link(dentry, pending_dir, pending_child);
1148 CERROR("error addlink orphan %s to PENDING: rc = %d\n",
1151 mds_inode_set_orphan(dentry->d_inode);
1153 l_dput(pending_child);
1155 up(&pending_dir->i_sem);
1159 static int mds_reint_rename(struct mds_update_record *rec, int offset,
1160 struct ptlrpc_request *req,
1161 struct lustre_handle *lockh)
1163 struct obd_device *obd = req->rq_export->exp_obd;
1164 struct dentry *de_srcdir = NULL;
1165 struct dentry *de_tgtdir = NULL;
1166 struct dentry *de_old = NULL;
1167 struct dentry *de_new = NULL;
1168 struct mds_obd *mds = mds_req2mds(req);
1169 struct lustre_handle dlm_handles[4];
1170 struct ldlm_res_id p1_res_id = { .name = {0} };
1171 struct ldlm_res_id p2_res_id = { .name = {0} };
1172 struct ldlm_res_id c1_res_id = { .name = {0} };
1173 struct ldlm_res_id c2_res_id = { .name = {0} };
1174 struct mds_body *body = NULL;
1175 int rc = 0, lock_count = 3, flags = LDLM_FL_LOCAL_ONLY;
1176 int cleanup_phase = 0;
1177 void *handle = NULL;
1180 LASSERT(offset == 0);
1182 MDS_CHECK_RESENT(req, mds_reconstruct_generic(req));
1184 de_srcdir = mds_fid2dentry(mds, rec->ur_fid1, NULL);
1185 if (IS_ERR(de_srcdir))
1186 GOTO(cleanup, rc = PTR_ERR(de_srcdir));
1188 cleanup_phase = 1; /* source directory dentry */
1190 de_tgtdir = mds_fid2dentry(mds, rec->ur_fid2, NULL);
1191 if (IS_ERR(de_tgtdir))
1192 GOTO(cleanup, rc = PTR_ERR(de_tgtdir));
1194 cleanup_phase = 2; /* target directory dentry */
1196 /* The idea here is that we need to get four locks in the end:
1197 * one on each parent directory, one on each child. We need to take
1198 * these locks in some kind of order (to avoid deadlocks), and the order
1199 * I selected is "increasing resource number" order. We need to take
1200 * the locks on the parent directories, however, before we can lookup
1201 * the children. Thus the following plan:
1203 * 1. Take locks on the parent(s), in order
1204 * 2. Lookup the children
1205 * 3. Take locks on the children, in order
1206 * 4. Execute the rename
1209 /* Step 1: Take locks on the parent(s), in order */
1210 p1_res_id.name[0] = de_srcdir->d_inode->i_ino;
1211 p1_res_id.name[1] = de_srcdir->d_inode->i_generation;
1213 p2_res_id.name[0] = de_tgtdir->d_inode->i_ino;
1214 p2_res_id.name[1] = de_tgtdir->d_inode->i_generation;
1216 rc = enqueue_ordered_locks(LCK_EX, obd, &p1_res_id, &p2_res_id,
1217 &(dlm_handles[0]), &(dlm_handles[1]));
1221 cleanup_phase = 3; /* parent locks */
1223 /* Step 2: Lookup the children */
1224 de_old = ll_lookup_one_len(rec->ur_name, de_srcdir, rec->ur_namelen-1);
1225 if (IS_ERR(de_old)) {
1226 CERROR("old child lookup error (%*s): %ld\n",
1227 rec->ur_namelen - 1, rec->ur_name, PTR_ERR(de_old));
1228 GOTO(cleanup, rc = PTR_ERR(de_old));
1231 cleanup_phase = 4; /* original name dentry */
1233 if (de_old->d_inode == NULL)
1234 GOTO(cleanup, rc = -ENOENT);
1236 /* sanity check for src inode */
1237 if (de_old->d_inode->i_ino == de_srcdir->d_inode->i_ino ||
1238 de_old->d_inode->i_ino == de_tgtdir->d_inode->i_ino)
1239 GOTO(cleanup, rc = -EINVAL);
1241 de_new = ll_lookup_one_len(rec->ur_tgt, de_tgtdir, rec->ur_tgtlen - 1);
1242 if (IS_ERR(de_new)) {
1243 CERROR("new child lookup error (%*s): %ld\n",
1244 rec->ur_tgtlen - 1, rec->ur_tgt, PTR_ERR(de_new));
1245 GOTO(cleanup, rc = PTR_ERR(de_new));
1248 cleanup_phase = 5; /* target dentry */
1250 /* sanity check for dest inode */
1251 if (de_new->d_inode &&
1252 (de_new->d_inode->i_ino == de_srcdir->d_inode->i_ino ||
1253 de_new->d_inode->i_ino == de_tgtdir->d_inode->i_ino))
1254 GOTO(cleanup, rc = -EINVAL);
1256 /* Step 3: Take locks on the children */
1257 c1_res_id.name[0] = de_old->d_inode->i_ino;
1258 c1_res_id.name[1] = de_old->d_inode->i_generation;
1259 if (de_new->d_inode == NULL) {
1260 flags = LDLM_FL_LOCAL_ONLY;
1261 rc = ldlm_cli_enqueue(NULL, NULL, obd->obd_namespace, NULL,
1262 c1_res_id, LDLM_PLAIN, NULL, 0, LCK_EX,
1263 &flags, ldlm_completion_ast,
1264 mds_blocking_ast, NULL,
1268 c2_res_id.name[0] = de_new->d_inode->i_ino;
1269 c2_res_id.name[1] = de_new->d_inode->i_generation;
1270 rc = enqueue_ordered_locks(LCK_EX, obd, &c1_res_id, &c2_res_id,
1278 cleanup_phase = 6; /* child locks */
1280 /* if we are about to remove the target at first, pass the EA of
1281 * that inode to client to perform and cleanup on OST */
1282 body = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*body));
1283 LASSERT(body != NULL);
1285 if (de_new->d_inode &&
1286 S_ISREG(de_new->d_inode->i_mode) &&
1287 de_new->d_inode->i_nlink == 1 &&
1288 mds_open_orphan_count(de_new->d_inode) == 0) {
1289 mds_pack_inode2fid(&body->fid1, de_new->d_inode);
1290 mds_pack_inode2body(body, de_new->d_inode);
1291 mds_pack_md(obd, req->rq_repmsg, 1, body, de_new->d_inode, 1);
1292 if (!(body->valid & OBD_MD_FLEASIZE)) {
1293 body->valid |= (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS |
1294 OBD_MD_FLATIME | OBD_MD_FLMTIME);
1296 /* XXX need log unlink? */
1300 /* Step 4: Execute the rename */
1301 OBD_FAIL_WRITE(OBD_FAIL_MDS_REINT_RENAME_WRITE,de_srcdir->d_inode->i_sb);
1303 handle = fsfilt_start(obd, de_tgtdir->d_inode, FSFILT_OP_RENAME, NULL);
1305 GOTO(cleanup, rc = PTR_ERR(handle));
1307 /* FIXME need adjust the journal block count? */
1308 /* if the target should be moved to PENDING, we at first increase the
1309 * link and later vfs_rename() will decrease the link count again */
1310 if (de_new->d_inode &&
1311 S_ISREG(de_new->d_inode->i_mode) &&
1312 de_new->d_inode->i_nlink == 1 &&
1313 mds_open_orphan_count(de_new->d_inode) > 0) {
1314 rc = mds_add_link_orphan(rec, obd, de_new);
1320 de_old->d_fsdata = req;
1321 de_new->d_fsdata = req;
1322 rc = vfs_rename(de_srcdir->d_inode, de_old, de_tgtdir->d_inode, de_new);
1327 rc = mds_finish_transno(mds, de_tgtdir ? de_tgtdir->d_inode : NULL,
1328 handle, req, rc, 0);
1329 switch (cleanup_phase) {
1330 case 6: /* child locks */
1332 ldlm_lock_decref(&(dlm_handles[2]), LCK_EX);
1333 if (lock_count == 4)
1334 ldlm_lock_decref(&(dlm_handles[3]), LCK_EX);
1336 ldlm_put_lock_into_req(req, &(dlm_handles[2]), LCK_EX);
1337 if (lock_count == 4)
1338 ldlm_put_lock_into_req(req,
1339 &(dlm_handles[3]), LCK_EX);
1341 case 5: /* target dentry */
1343 case 4: /* source dentry */
1345 case 3: /* parent locks */
1347 ldlm_lock_decref(&(dlm_handles[0]), LCK_EX);
1348 ldlm_lock_decref(&(dlm_handles[1]), LCK_EX);
1350 ldlm_put_lock_into_req(req, &(dlm_handles[0]), LCK_EX);
1351 ldlm_put_lock_into_req(req, &(dlm_handles[1]), LCK_EX);
1353 case 2: /* target directory dentry */
1355 case 1: /* source directry dentry */
1360 CERROR("invalid cleanup_phase %d\n", cleanup_phase);
1363 req->rq_status = rc;
1367 typedef int (*mds_reinter)(struct mds_update_record *, int offset,
1368 struct ptlrpc_request *, struct lustre_handle *);
1370 static mds_reinter reinters[REINT_MAX + 1] = {
1371 [REINT_SETATTR] mds_reint_setattr,
1372 [REINT_CREATE] mds_reint_create,
1373 [REINT_UNLINK] mds_reint_unlink,
1374 [REINT_LINK] mds_reint_link,
1375 [REINT_RENAME] mds_reint_rename,
1376 [REINT_OPEN] mds_open
1379 int mds_reint_rec(struct mds_update_record *rec, int offset,
1380 struct ptlrpc_request *req, struct lustre_handle *lockh)
1382 struct obd_device *obd = req->rq_export->exp_obd;
1383 struct obd_run_ctxt saved;
1387 /* checked by unpacker */
1388 LASSERT(rec->ur_opcode <= REINT_MAX &&
1389 reinters[rec->ur_opcode] != NULL);
1391 push_ctxt(&saved, &obd->obd_ctxt, &rec->ur_uc);
1392 rc = reinters[rec->ur_opcode] (rec, offset, req, lockh);
1393 pop_ctxt(&saved, &obd->obd_ctxt, &rec->ur_uc);