Whamcloud - gitweb
b=22637 MDS returns OBD_MD_FLSIZE to client only when no OSS object allocated
[fs/lustre-release.git] / lustre / mdt / mdt_reint.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * GPL HEADER START
5  *
6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 only,
10  * as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License version 2 for more details (a copy is included
16  * in the LICENSE file that accompanied this code).
17  *
18  * You should have received a copy of the GNU General Public License
19  * version 2 along with this program; If not, see
20  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
21  *
22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23  * CA 95054 USA or visit www.sun.com if you need additional information or
24  * have any questions.
25  *
26  * GPL HEADER END
27  */
28 /*
29  * Copyright  2008 Sun Microsystems, Inc. All rights reserved
30  * Use is subject to license terms.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  *
36  * lustre/mdt/mdt_reint.c
37  *
38  * Lustre Metadata Target (mdt) reintegration routines
39  *
40  * Author: Peter Braam <braam@clusterfs.com>
41  * Author: Andreas Dilger <adilger@clusterfs.com>
42  * Author: Phil Schwan <phil@clusterfs.com>
43  * Author: Huang Hua <huanghua@clusterfs.com>
44  * Author: Yury Umanets <umka@clusterfs.com>
45  */
46
47 #ifndef EXPORT_SYMTAB
48 # define EXPORT_SYMTAB
49 #endif
50 #define DEBUG_SUBSYSTEM S_MDS
51
52 #include "mdt_internal.h"
53 #include "lu_time.h"
54
55 static inline void mdt_reint_init_ma(struct mdt_thread_info *info,
56                                      struct md_attr *ma)
57 {
58         ma->ma_lmm = req_capsule_server_get(info->mti_pill, &RMF_MDT_MD);
59         ma->ma_lmm_size = req_capsule_get_size(info->mti_pill,
60                                                &RMF_MDT_MD, RCL_SERVER);
61
62         ma->ma_cookie = req_capsule_server_get(info->mti_pill,
63                                                &RMF_LOGCOOKIES);
64         ma->ma_cookie_size = req_capsule_get_size(info->mti_pill,
65                                                   &RMF_LOGCOOKIES,
66                                                   RCL_SERVER);
67
68         ma->ma_need = MA_INODE | MA_LOV | MA_COOKIE;
69         ma->ma_valid = 0;
70 }
71
72 static int mdt_create_pack_capa(struct mdt_thread_info *info, int rc,
73                                 struct mdt_object *object,
74                                 struct mdt_body *repbody)
75 {
76         ENTRY;
77
78         /* for cross-ref mkdir, mds capa has been fetched from remote obj, then
79          * we won't go to below*/
80         if (repbody->valid & OBD_MD_FLMDSCAPA)
81                 RETURN(rc);
82
83         if (rc == 0 && info->mti_mdt->mdt_opts.mo_mds_capa &&
84             info->mti_exp->exp_connect_flags & OBD_CONNECT_MDS_CAPA) {
85                 struct lustre_capa *capa;
86
87                 capa = req_capsule_server_get(info->mti_pill, &RMF_CAPA1);
88                 LASSERT(capa);
89                 capa->lc_opc = CAPA_OPC_MDS_DEFAULT;
90                 rc = mo_capa_get(info->mti_env, mdt_object_child(object), capa,
91                                  0);
92                 if (rc == 0)
93                         repbody->valid |= OBD_MD_FLMDSCAPA;
94         }
95
96         RETURN(rc);
97 }
98
99 int mdt_version_get_check(struct mdt_thread_info *info, int index)
100 {
101         /** version recovery */
102         struct md_object *mo;
103         struct ptlrpc_request *req = mdt_info_req(info);
104         __u64 curr_version, *pre_versions;
105         ENTRY;
106
107         if (!exp_connect_vbr(req->rq_export))
108                 RETURN(0);
109
110         LASSERT(info->mti_mos[index]);
111         if (mdt_object_exists(info->mti_mos[index]) == 0)
112                 RETURN(-ESTALE);
113         mo = mdt_object_child(info->mti_mos[index]);
114
115         curr_version = mo_version_get(info->mti_env, mo);
116         CDEBUG(D_INODE, "Version is "LPX64"\n", curr_version);
117         /** VBR: version is checked always because costs nothing */
118         if (lustre_msg_get_transno(req->rq_reqmsg) != 0) {
119                 pre_versions = lustre_msg_get_versions(req->rq_reqmsg);
120                 LASSERT(index < PTLRPC_NUM_VERSIONS);
121                 /** Sanity check for malformed buffers */
122                 if (pre_versions == NULL) {
123                         CERROR("No versions in request buffer\n");
124                         cfs_spin_lock(&req->rq_export->exp_lock);
125                         req->rq_export->exp_vbr_failed = 1;
126                         cfs_spin_unlock(&req->rq_export->exp_lock);
127                         RETURN(-EOVERFLOW);
128                 } else if (pre_versions[index] != curr_version) {
129                         CDEBUG(D_INODE, "Version mismatch "LPX64" != "LPX64"\n",
130                                pre_versions[index], curr_version);
131                         cfs_spin_lock(&req->rq_export->exp_lock);
132                         req->rq_export->exp_vbr_failed = 1;
133                         cfs_spin_unlock(&req->rq_export->exp_lock);
134                         RETURN(-EOVERFLOW);
135                 }
136         }
137         /** save pre-versions in reply */
138         LASSERT(req->rq_repmsg != NULL);
139         pre_versions = lustre_msg_get_versions(req->rq_repmsg);
140         if (pre_versions)
141                 pre_versions[index] = curr_version;
142         RETURN(0);
143 }
144
145 static int mdt_md_create(struct mdt_thread_info *info)
146 {
147         struct mdt_device       *mdt = info->mti_mdt;
148         struct mdt_object       *parent;
149         struct mdt_object       *child;
150         struct mdt_lock_handle  *lh;
151         struct mdt_body         *repbody;
152         struct md_attr          *ma = &info->mti_attr;
153         struct mdt_reint_record *rr = &info->mti_rr;
154         struct lu_name          *lname;
155         int rc;
156         ENTRY;
157
158         DEBUG_REQ(D_INODE, mdt_info_req(info), "Create  (%s->"DFID") in "DFID,
159                   rr->rr_name, PFID(rr->rr_fid2), PFID(rr->rr_fid1));
160
161         repbody = req_capsule_server_get(info->mti_pill, &RMF_MDT_BODY);
162
163         lh = &info->mti_lh[MDT_LH_PARENT];
164         mdt_lock_pdo_init(lh, LCK_PW, rr->rr_name, rr->rr_namelen);
165
166         parent = mdt_object_find_lock(info, rr->rr_fid1, lh,
167                                       MDS_INODELOCK_UPDATE);
168         if (IS_ERR(parent))
169                 RETURN(PTR_ERR(parent));
170
171         child = mdt_object_find(info->mti_env, mdt, rr->rr_fid2);
172         if (likely(!IS_ERR(child))) {
173                 struct md_object *next = mdt_object_child(parent);
174
175                 ma->ma_need = MA_INODE;
176                 ma->ma_valid = 0;
177                 /* capa for cross-ref will be stored here */
178                 ma->ma_capa = req_capsule_server_get(info->mti_pill,
179                                                      &RMF_CAPA1);
180                 LASSERT(ma->ma_capa);
181
182                 mdt_fail_write(info->mti_env, info->mti_mdt->mdt_bottom,
183                                OBD_FAIL_MDS_REINT_CREATE_WRITE);
184
185                 info->mti_mos[0] = parent;
186                 info->mti_mos[1] = child;
187                 rc = mdt_version_get_check(info, 0);
188                 if (rc)
189                         GOTO(out_put_child, rc);
190
191                 /* Let lower layer know current lock mode. */
192                 info->mti_spec.sp_cr_mode =
193                         mdt_dlm_mode2mdl_mode(lh->mlh_pdo_mode);
194
195                 /*
196                  * Do perform lookup sanity check. We do not know if name exists
197                  * or not.
198                  */
199                 info->mti_spec.sp_cr_lookup = 1;
200                 info->mti_spec.sp_feat = &dt_directory_features;
201
202                 lname = mdt_name(info->mti_env, (char *)rr->rr_name,
203                                  rr->rr_namelen);
204                 rc = mdo_create(info->mti_env, next, lname,
205                                 mdt_object_child(child),
206                                 &info->mti_spec, ma);
207                 if (rc == 0) {
208                         /* Return fid & attr to client. */
209                         if (ma->ma_valid & MA_INODE)
210                                 mdt_pack_attr2body(info, repbody, &ma->ma_attr,
211                                                    mdt_object_fid(child));
212                 }
213 out_put_child:
214                 mdt_object_put(info->mti_env, child);
215         } else
216                 rc = PTR_ERR(child);
217
218         mdt_create_pack_capa(info, rc, child, repbody);
219         mdt_object_unlock_put(info, parent, lh, rc);
220         RETURN(rc);
221 }
222
223 /* Partial request to create object only */
224 static int mdt_md_mkobj(struct mdt_thread_info *info)
225 {
226         struct mdt_device      *mdt = info->mti_mdt;
227         struct mdt_object      *o;
228         struct mdt_body        *repbody;
229         struct md_attr         *ma = &info->mti_attr;
230         int rc;
231         ENTRY;
232
233         DEBUG_REQ(D_INODE, mdt_info_req(info), "Partial create "DFID"",
234                   PFID(info->mti_rr.rr_fid2));
235
236         repbody = req_capsule_server_get(info->mti_pill, &RMF_MDT_BODY);
237
238         o = mdt_object_find(info->mti_env, mdt, info->mti_rr.rr_fid2);
239         if (!IS_ERR(o)) {
240                 struct md_object *next = mdt_object_child(o);
241
242                 ma->ma_need = MA_INODE;
243                 ma->ma_valid = 0;
244
245                 /*
246                  * Cross-ref create can encounter already created obj in case of
247                  * recovery, just get attr in that case.
248                  */
249                 if (mdt_object_exists(o) == 1) {
250                         rc = mo_attr_get(info->mti_env, next, ma);
251                 } else {
252                         /*
253                          * Here, NO permission check for object_create,
254                          * such check has been done on the original MDS.
255                          */
256                         rc = mo_object_create(info->mti_env, next,
257                                               &info->mti_spec, ma);
258                 }
259                 if (rc == 0) {
260                         /* Return fid & attr to client. */
261                         if (ma->ma_valid & MA_INODE)
262                                 mdt_pack_attr2body(info, repbody, &ma->ma_attr,
263                                                    mdt_object_fid(o));
264                 }
265                 mdt_object_put(info->mti_env, o);
266         } else
267                 rc = PTR_ERR(o);
268
269         mdt_create_pack_capa(info, rc, o, repbody);
270         RETURN(rc);
271 }
272
273 /* In the raw-setattr case, we lock the child inode.
274  * In the write-back case or if being called from open,
275  *               the client holds a lock already.
276  * We use the ATTR_FROM_OPEN (translated into MRF_SETATTR_LOCKED by
277  * mdt_setattr_unpack()) flag to tell these cases apart. */
278 int mdt_attr_set(struct mdt_thread_info *info, struct mdt_object *mo,
279                  struct md_attr *ma, int flags)
280 {
281         struct mdt_lock_handle  *lh;
282         int do_vbr = ma->ma_attr.la_valid & (LA_MODE|LA_UID|LA_GID|LA_FLAGS);
283         int rc;
284         ENTRY;
285
286         /* attr shouldn't be set on remote object */
287         LASSERT(mdt_object_exists(mo) >= 0);
288
289         lh = &info->mti_lh[MDT_LH_PARENT];
290         mdt_lock_reg_init(lh, LCK_PW);
291
292         if (!(flags & MRF_SETATTR_LOCKED)) {
293                 __u64 lockpart = MDS_INODELOCK_UPDATE;
294                 if (ma->ma_attr.la_valid & (LA_MODE|LA_UID|LA_GID))
295                         lockpart |= MDS_INODELOCK_LOOKUP;
296
297                 rc = mdt_object_lock(info, mo, lh, lockpart, MDT_LOCAL_LOCK);
298                 if (rc != 0)
299                         RETURN(rc);
300         }
301
302         if (mdt_object_exists(mo) == 0)
303                 GOTO(out_unlock, rc = -ENOENT);
304
305         /* all attrs are packed into mti_attr in unpack_setattr */
306         mdt_fail_write(info->mti_env, info->mti_mdt->mdt_bottom,
307                        OBD_FAIL_MDS_REINT_SETATTR_WRITE);
308
309         /* This is only for set ctime when rename's source is on remote MDS. */
310         if (unlikely(ma->ma_attr.la_valid == LA_CTIME))
311                 ma->ma_attr_flags |= MDS_VTX_BYPASS;
312
313         /* VBR: update version if attr changed are important for recovery */
314         if (do_vbr) {
315                 info->mti_mos[0] = mo;
316                 rc = mdt_version_get_check(info, 0);
317                 if (rc)
318                         GOTO(out_unlock, rc);
319         }
320
321         /* all attrs are packed into mti_attr in unpack_setattr */
322         rc = mo_attr_set(info->mti_env, mdt_object_child(mo), ma);
323         if (rc != 0)
324                 GOTO(out_unlock, rc);
325
326         EXIT;
327 out_unlock:
328         mdt_object_unlock(info, mo, lh, rc);
329         return rc;
330 }
331
332 static int mdt_reint_setattr(struct mdt_thread_info *info,
333                              struct mdt_lock_handle *lhc)
334 {
335         struct md_attr          *ma = &info->mti_attr;
336         struct mdt_reint_record *rr = &info->mti_rr;
337         struct ptlrpc_request   *req = mdt_info_req(info);
338         struct mdt_export_data  *med = &req->rq_export->exp_mdt_data;
339         struct mdt_file_data    *mfd;
340         struct mdt_object       *mo;
341         struct md_object        *next;
342         struct mdt_body         *repbody;
343         int                      som_au, rc;
344         ENTRY;
345
346         DEBUG_REQ(D_INODE, req, "setattr "DFID" %x", PFID(rr->rr_fid1),
347                   (unsigned int)ma->ma_attr.la_valid);
348
349         if (info->mti_dlm_req)
350                 ldlm_request_cancel(req, info->mti_dlm_req, 0);
351
352         repbody = req_capsule_server_get(info->mti_pill, &RMF_MDT_BODY);
353         mo = mdt_object_find(info->mti_env, info->mti_mdt, rr->rr_fid1);
354         if (IS_ERR(mo))
355                 GOTO(out, rc = PTR_ERR(mo));
356
357         /* start a log jounal handle if needed */
358         if (!(mdt_conn_flags(info) & OBD_CONNECT_SOM)) {
359                 if ((ma->ma_attr.la_valid & LA_SIZE) ||
360                     (rr->rr_flags & MRF_SETATTR_LOCKED)) {
361                         /* Check write access for the O_TRUNC case */
362                         if (mdt_write_read(mo) < 0)
363                                 GOTO(out_put, rc = -ETXTBSY);
364                 }
365         } else if (info->mti_ioepoch &&
366                    (info->mti_ioepoch->flags & MF_EPOCH_OPEN)) {
367                 /* Truncate case. IOEpoch is opened. */
368                 rc = mdt_write_get(mo);
369                 if (rc)
370                         GOTO(out_put, rc);
371
372                 mfd = mdt_mfd_new();
373                 if (mfd == NULL) {
374                         mdt_write_put(mo);
375                         GOTO(out_put, rc = -ENOMEM);
376                 }
377
378                 mdt_ioepoch_open(info, mo, 0);
379                 repbody->ioepoch = mo->mot_ioepoch;
380
381                 mdt_object_get(info->mti_env, mo);
382                 mdt_mfd_set_mode(mfd, FMODE_TRUNC);
383                 mfd->mfd_object = mo;
384                 mfd->mfd_xid = req->rq_xid;
385
386                 cfs_spin_lock(&med->med_open_lock);
387                 cfs_list_add(&mfd->mfd_list, &med->med_open_head);
388                 cfs_spin_unlock(&med->med_open_lock);
389                 repbody->handle.cookie = mfd->mfd_handle.h_cookie;
390         }
391
392         som_au = info->mti_ioepoch && info->mti_ioepoch->flags & MF_SOM_CHANGE;
393         if (som_au) {
394                 /* SOM Attribute update case. Find the proper mfd and update
395                  * SOM attributes on the proper object. */
396                 LASSERT(mdt_conn_flags(info) & OBD_CONNECT_SOM);
397                 LASSERT(info->mti_ioepoch);
398
399                 cfs_spin_lock(&med->med_open_lock);
400                 mfd = mdt_handle2mfd(info, &info->mti_ioepoch->handle);
401                 if (mfd == NULL) {
402                         cfs_spin_unlock(&med->med_open_lock);
403                         CDEBUG(D_INODE, "no handle for file close: "
404                                "fid = "DFID": cookie = "LPX64"\n",
405                                PFID(info->mti_rr.rr_fid1),
406                                info->mti_ioepoch->handle.cookie);
407                         GOTO(out_put, rc = -ESTALE);
408                 }
409                 LASSERT(mfd->mfd_mode == FMODE_SOM);
410                 LASSERT(!(info->mti_ioepoch->flags & MF_EPOCH_CLOSE));
411
412                 class_handle_unhash(&mfd->mfd_handle);
413                 cfs_list_del_init(&mfd->mfd_list);
414                 cfs_spin_unlock(&med->med_open_lock);
415
416                 /* Close the found mfd, update attributes. */
417                 ma->ma_lmm_size = info->mti_mdt->mdt_max_mdsize;
418                 OBD_ALLOC(ma->ma_lmm, info->mti_mdt->mdt_max_mdsize);
419                 if (ma->ma_lmm == NULL)
420                         GOTO(out_put, rc = -ENOMEM);
421
422                 mdt_mfd_close(info, mfd);
423
424                 OBD_FREE(ma->ma_lmm, info->mti_mdt->mdt_max_mdsize);
425         } else {
426                 rc = mdt_attr_set(info, mo, ma, rr->rr_flags);
427                 if (rc)
428                         GOTO(out_put, rc);
429         }
430
431         ma->ma_need = MA_INODE;
432         ma->ma_valid = 0;
433         next = mdt_object_child(mo);
434         rc = mo_attr_get(info->mti_env, next, ma);
435         if (rc != 0)
436                 GOTO(out_put, rc);
437
438         mdt_pack_attr2body(info, repbody, &ma->ma_attr, mdt_object_fid(mo));
439
440         if (info->mti_mdt->mdt_opts.mo_oss_capa &&
441             info->mti_exp->exp_connect_flags & OBD_CONNECT_OSS_CAPA &&
442             S_ISREG(lu_object_attr(&mo->mot_obj.mo_lu)) &&
443             (ma->ma_attr.la_valid & LA_SIZE) && !som_au) {
444                 struct lustre_capa *capa;
445
446                 capa = req_capsule_server_get(info->mti_pill, &RMF_CAPA2);
447                 LASSERT(capa);
448                 capa->lc_opc = CAPA_OPC_OSS_DEFAULT | CAPA_OPC_OSS_TRUNC;
449                 rc = mo_capa_get(info->mti_env, mdt_object_child(mo), capa, 0);
450                 if (rc)
451                         GOTO(out_put, rc);
452                 repbody->valid |= OBD_MD_FLOSSCAPA;
453         }
454
455         EXIT;
456 out_put:
457         mdt_object_put(info->mti_env, mo);
458 out:
459         mdt_shrink_reply(info);
460         return rc;
461 }
462
463 static int mdt_reint_create(struct mdt_thread_info *info,
464                             struct mdt_lock_handle *lhc)
465 {
466         int rc;
467         ENTRY;
468
469         if (OBD_FAIL_CHECK(OBD_FAIL_MDS_REINT_CREATE))
470                 RETURN(err_serious(-ESTALE));
471
472         if (info->mti_dlm_req)
473                 ldlm_request_cancel(mdt_info_req(info), info->mti_dlm_req, 0);
474
475         switch (info->mti_attr.ma_attr.la_mode & S_IFMT) {
476         case S_IFDIR:{
477                 /* Cross-ref case. */
478                 if (info->mti_cross_ref) {
479                         rc = mdt_md_mkobj(info);
480                         break;
481                 }
482         }
483         case S_IFREG:
484         case S_IFLNK:
485         case S_IFCHR:
486         case S_IFBLK:
487         case S_IFIFO:
488         case S_IFSOCK:{
489                 /* Special file should stay on the same node as parent. */
490                 LASSERT(info->mti_rr.rr_namelen > 0);
491                 rc = mdt_md_create(info);
492                 break;
493         }
494         default:
495                 rc = err_serious(-EOPNOTSUPP);
496         }
497         RETURN(rc);
498 }
499
500 static int mdt_reint_unlink(struct mdt_thread_info *info,
501                             struct mdt_lock_handle *lhc)
502 {
503         struct mdt_reint_record *rr = &info->mti_rr;
504         struct ptlrpc_request   *req = mdt_info_req(info);
505         struct md_attr          *ma = &info->mti_attr;
506         struct lu_fid           *child_fid = &info->mti_tmp_fid1;
507         struct mdt_object       *mp;
508         struct mdt_object       *mc;
509         struct mdt_lock_handle  *parent_lh;
510         struct mdt_lock_handle  *child_lh;
511         struct lu_name          *lname;
512         int                      rc;
513         ENTRY;
514
515         DEBUG_REQ(D_INODE, req, "unlink "DFID"/%s", PFID(rr->rr_fid1),
516                   rr->rr_name);
517
518         if (info->mti_dlm_req)
519                 ldlm_request_cancel(req, info->mti_dlm_req, 0);
520
521         if (OBD_FAIL_CHECK(OBD_FAIL_MDS_REINT_UNLINK))
522                 RETURN(err_serious(-ENOENT));
523
524         /*
525          * step 1: lock the parent. Note, this may be child in case of
526          * remote operation denoted by ->mti_cross_ref flag.
527          */
528         parent_lh = &info->mti_lh[MDT_LH_PARENT];
529         if (info->mti_cross_ref) {
530                 /*
531                  * Init reg lock for cross ref case when we need to do only
532                  * ref del locally.
533                  */
534                 mdt_lock_reg_init(parent_lh, LCK_PW);
535         } else {
536                 mdt_lock_pdo_init(parent_lh, LCK_PW, rr->rr_name,
537                                   rr->rr_namelen);
538         }
539         mp = mdt_object_find_lock(info, rr->rr_fid1, parent_lh,
540                                   MDS_INODELOCK_UPDATE);
541         if (IS_ERR(mp)) {
542                 rc = PTR_ERR(mp);
543                 /* errors are possible here in cross-ref cases, see below */
544                 if (info->mti_cross_ref)
545                         rc = 0;
546                 GOTO(out, rc);
547         }
548
549         info->mti_mos[0] = mp;
550         rc = mdt_version_get_check(info, 0);
551         if (rc)
552                 GOTO(out_unlock_parent, rc);
553
554         mdt_reint_init_ma(info, ma);
555         if (!ma->ma_lmm || !ma->ma_cookie)
556                 GOTO(out_unlock_parent, rc = -EINVAL);
557
558         if (info->mti_cross_ref) {
559                 /*
560                  * Remote partial operation. It is possible that replay may
561                  * happen on parent MDT and this operation will be repeated.
562                  * Therefore the object absense is allowed case and nothing
563                  * should be done here.
564                  */
565                 if (mdt_object_exists(mp) > 0) {
566                         mdt_set_capainfo(info, 0, rr->rr_fid1, BYPASS_CAPA);
567                         rc = mo_ref_del(info->mti_env,
568                                         mdt_object_child(mp), ma);
569                         if (rc == 0)
570                                 mdt_handle_last_unlink(info, mp, ma);
571                 } else
572                         rc = 0;
573                 GOTO(out_unlock_parent, rc);
574         }
575
576         /* step 2: find & lock the child */
577         lname = mdt_name(info->mti_env, (char *)rr->rr_name, rr->rr_namelen);
578         rc = mdo_lookup(info->mti_env, mdt_object_child(mp),
579                         lname, child_fid, &info->mti_spec);
580         if (rc != 0)
581                  GOTO(out_unlock_parent, rc);
582
583         /* We will lock the child regardless it is local or remote. No harm. */
584         mc = mdt_object_find(info->mti_env, info->mti_mdt, child_fid);
585         if (IS_ERR(mc))
586                 GOTO(out_unlock_parent, rc = PTR_ERR(mc));
587         child_lh = &info->mti_lh[MDT_LH_CHILD];
588         mdt_lock_reg_init(child_lh, LCK_EX);
589         rc = mdt_object_lock(info, mc, child_lh, MDS_INODELOCK_FULL,
590                              MDT_CROSS_LOCK);
591         if (rc != 0) {
592                 mdt_object_put(info->mti_env, mc);
593                 GOTO(out_unlock_parent, rc);
594         }
595
596         mdt_fail_write(info->mti_env, info->mti_mdt->mdt_bottom,
597                        OBD_FAIL_MDS_REINT_UNLINK_WRITE);
598
599         info->mti_mos[1] = mc;
600         rc = mdt_version_get_check(info, 1);
601         if (rc)
602                 GOTO(out_unlock_child, rc);
603
604         /*
605          * Now we can only make sure we need MA_INODE, in mdd layer, will check
606          * whether need MA_LOV and MA_COOKIE.
607          */
608         ma->ma_need = MA_INODE;
609         ma->ma_valid = 0;
610         mdt_set_capainfo(info, 1, child_fid, BYPASS_CAPA);
611         rc = mdo_unlink(info->mti_env, mdt_object_child(mp),
612                         mdt_object_child(mc), lname, ma);
613         if (rc == 0)
614                 mdt_handle_last_unlink(info, mc, ma);
615
616         EXIT;
617 out_unlock_child:
618         mdt_object_unlock_put(info, mc, child_lh, rc);
619 out_unlock_parent:
620         mdt_object_unlock_put(info, mp, parent_lh, rc);
621 out:
622         return rc;
623 }
624
625 static int mdt_reint_link(struct mdt_thread_info *info,
626                           struct mdt_lock_handle *lhc)
627 {
628         struct mdt_reint_record *rr = &info->mti_rr;
629         struct ptlrpc_request   *req = mdt_info_req(info);
630         struct md_attr          *ma = &info->mti_attr;
631         struct mdt_object       *ms;
632         struct mdt_object       *mp;
633         struct mdt_lock_handle  *lhs;
634         struct mdt_lock_handle  *lhp;
635         struct lu_name          *lname;
636         int rc;
637         ENTRY;
638
639         DEBUG_REQ(D_INODE, req, "link "DFID" to "DFID"/%s",
640                   PFID(rr->rr_fid1), PFID(rr->rr_fid2), rr->rr_name);
641
642         if (OBD_FAIL_CHECK(OBD_FAIL_MDS_REINT_LINK))
643                 RETURN(err_serious(-ENOENT));
644
645         if (info->mti_dlm_req)
646                 ldlm_request_cancel(req, info->mti_dlm_req, 0);
647
648         if (info->mti_cross_ref) {
649                 /* MDT holding name ask us to add ref. */
650                 lhs = &info->mti_lh[MDT_LH_CHILD];
651                 mdt_lock_reg_init(lhs, LCK_EX);
652                 ms = mdt_object_find_lock(info, rr->rr_fid1, lhs,
653                                           MDS_INODELOCK_UPDATE);
654                 if (IS_ERR(ms))
655                         RETURN(PTR_ERR(ms));
656
657                 mdt_set_capainfo(info, 0, rr->rr_fid1, BYPASS_CAPA);
658                 rc = mo_ref_add(info->mti_env, mdt_object_child(ms), ma);
659                 mdt_object_unlock_put(info, ms, lhs, rc);
660                 RETURN(rc);
661         }
662
663         /* Invalid case so return error immediately instead of
664          * processing it */
665         if (lu_fid_eq(rr->rr_fid1, rr->rr_fid2))
666                 RETURN(-EPERM);
667
668         /* step 1: find & lock the target parent dir */
669         lhp = &info->mti_lh[MDT_LH_PARENT];
670         mdt_lock_pdo_init(lhp, LCK_PW, rr->rr_name,
671                           rr->rr_namelen);
672         mp = mdt_object_find_lock(info, rr->rr_fid2, lhp,
673                                   MDS_INODELOCK_UPDATE);
674         if (IS_ERR(mp))
675                 RETURN(PTR_ERR(mp));
676
677         info->mti_mos[0] = mp;
678         rc = mdt_version_get_check(info, 0);
679         if (rc)
680                 GOTO(out_unlock_parent, rc);
681
682         /* step 2: find & lock the source */
683         lhs = &info->mti_lh[MDT_LH_CHILD];
684         mdt_lock_reg_init(lhs, LCK_EX);
685
686         ms = mdt_object_find(info->mti_env, info->mti_mdt, rr->rr_fid1);
687         if (IS_ERR(ms))
688                 GOTO(out_unlock_parent, rc = PTR_ERR(ms));
689
690         rc = mdt_object_lock(info, ms, lhs, MDS_INODELOCK_UPDATE,
691                             MDT_CROSS_LOCK);
692         if (rc != 0) {
693                 mdt_object_put(info->mti_env, ms);
694                 GOTO(out_unlock_parent, rc);
695         }
696
697         /* step 3: link it */
698         mdt_fail_write(info->mti_env, info->mti_mdt->mdt_bottom,
699                        OBD_FAIL_MDS_REINT_LINK_WRITE);
700
701         info->mti_mos[1] = ms;
702         rc = mdt_version_get_check(info, 1);
703         if (rc)
704                 GOTO(out_unlock_child, rc);
705
706         lname = mdt_name(info->mti_env, (char *)rr->rr_name, rr->rr_namelen);
707         rc = mdo_link(info->mti_env, mdt_object_child(mp),
708                       mdt_object_child(ms), lname, ma);
709
710         EXIT;
711 out_unlock_child:
712         mdt_object_unlock_put(info, ms, lhs, rc);
713 out_unlock_parent:
714         mdt_object_unlock_put(info, mp, lhp, rc);
715         return rc;
716 }
717 /**
718  * lock the part of the directory according to the hash of the name
719  * (lh->mlh_pdo_hash) in parallel directory lock.
720  */
721 static int mdt_pdir_hash_lock(struct mdt_thread_info *info,
722                        struct mdt_lock_handle *lh,
723                        struct mdt_object *obj, __u64 ibits)
724 {
725         struct ldlm_res_id *res_id = &info->mti_res_id;
726         struct ldlm_namespace *ns = info->mti_mdt->mdt_namespace;
727         ldlm_policy_data_t *policy = &info->mti_policy;
728         int rc;
729
730         /*
731          * Finish res_id initializing by name hash marking part of
732          * directory which is taking modification.
733          */
734         LASSERT(lh->mlh_pdo_hash != 0);
735         fid_build_pdo_res_name(mdt_object_fid(obj), lh->mlh_pdo_hash, res_id);
736         memset(policy, 0, sizeof(*policy));
737         policy->l_inodebits.bits = ibits;
738         /*
739          * Use LDLM_FL_LOCAL_ONLY for this lock. We do not know yet if it is
740          * going to be sent to client. If it is - mdt_intent_policy() path will
741          * fix it up and turn FL_LOCAL flag off.
742          */
743         rc = mdt_fid_lock(ns, &lh->mlh_reg_lh, lh->mlh_reg_mode, policy,
744                           res_id, LDLM_FL_LOCAL_ONLY | LDLM_FL_ATOMIC_CB,
745                           &info->mti_exp->exp_handle.h_cookie);
746         return rc;
747 }
748
749 /* partial operation for rename */
750 static int mdt_reint_rename_tgt(struct mdt_thread_info *info)
751 {
752         struct mdt_reint_record *rr = &info->mti_rr;
753         struct ptlrpc_request   *req = mdt_info_req(info);
754         struct md_attr          *ma = &info->mti_attr;
755         struct mdt_object       *mtgtdir;
756         struct mdt_object       *mtgt = NULL;
757         struct mdt_lock_handle  *lh_tgtdir;
758         struct mdt_lock_handle  *lh_tgt = NULL;
759         struct lu_fid           *tgt_fid = &info->mti_tmp_fid1;
760         struct lu_name          *lname;
761         int                      rc;
762         ENTRY;
763
764         DEBUG_REQ(D_INODE, req, "rename_tgt: insert (%s->"DFID") in "DFID,
765                   rr->rr_tgt, PFID(rr->rr_fid2), PFID(rr->rr_fid1));
766
767         /* step 1: lookup & lock the tgt dir. */
768         lh_tgtdir = &info->mti_lh[MDT_LH_PARENT];
769         mdt_lock_pdo_init(lh_tgtdir, LCK_PW, rr->rr_tgt,
770                           rr->rr_tgtlen);
771         mtgtdir = mdt_object_find_lock(info, rr->rr_fid1, lh_tgtdir,
772                                        MDS_INODELOCK_UPDATE);
773         if (IS_ERR(mtgtdir))
774                 RETURN(PTR_ERR(mtgtdir));
775
776         /* step 2: find & lock the target object if exists. */
777         mdt_set_capainfo(info, 0, rr->rr_fid1, BYPASS_CAPA);
778         lname = mdt_name(info->mti_env, (char *)rr->rr_tgt, rr->rr_tgtlen);
779         rc = mdo_lookup(info->mti_env, mdt_object_child(mtgtdir),
780                         lname, tgt_fid, &info->mti_spec);
781         if (rc != 0 && rc != -ENOENT) {
782                 GOTO(out_unlock_tgtdir, rc);
783         } else if (rc == 0) {
784                 /*
785                  * In case of replay that name can be already inserted, check
786                  * that and do nothing if so.
787                  */
788                 if (lu_fid_eq(tgt_fid, rr->rr_fid2))
789                         GOTO(out_unlock_tgtdir, rc);
790
791                 lh_tgt = &info->mti_lh[MDT_LH_CHILD];
792                 mdt_lock_reg_init(lh_tgt, LCK_EX);
793
794                 mtgt = mdt_object_find_lock(info, tgt_fid, lh_tgt,
795                                             MDS_INODELOCK_LOOKUP);
796                 if (IS_ERR(mtgt))
797                         GOTO(out_unlock_tgtdir, rc = PTR_ERR(mtgt));
798
799                 mdt_reint_init_ma(info, ma);
800                 if (!ma->ma_lmm || !ma->ma_cookie)
801                         GOTO(out_unlock_tgt, rc = -EINVAL);
802
803                 rc = mdo_rename_tgt(info->mti_env, mdt_object_child(mtgtdir),
804                                     mdt_object_child(mtgt), rr->rr_fid2,
805                                     lname, ma);
806         } else /* -ENOENT */ {
807                 rc = mdo_name_insert(info->mti_env, mdt_object_child(mtgtdir),
808                                      lname, rr->rr_fid2, ma);
809         }
810
811         /* handle last link of tgt object */
812         if (rc == 0 && mtgt)
813                 mdt_handle_last_unlink(info, mtgt, ma);
814
815         EXIT;
816 out_unlock_tgt:
817         if (mtgt)
818                 mdt_object_unlock_put(info, mtgt, lh_tgt, rc);
819 out_unlock_tgtdir:
820         mdt_object_unlock_put(info, mtgtdir, lh_tgtdir, rc);
821         return rc;
822 }
823
824 static int mdt_rename_lock(struct mdt_thread_info *info,
825                            struct lustre_handle *lh)
826 {
827         struct ldlm_namespace *ns     = info->mti_mdt->mdt_namespace;
828         ldlm_policy_data_t    *policy = &info->mti_policy;
829         struct ldlm_res_id    *res_id = &info->mti_res_id;
830         struct md_site        *ms;
831         int rc;
832         ENTRY;
833
834         ms = mdt_md_site(info->mti_mdt);
835         fid_build_reg_res_name(&LUSTRE_BFL_FID, res_id);
836
837         memset(policy, 0, sizeof *policy);
838         policy->l_inodebits.bits = MDS_INODELOCK_UPDATE;
839
840         if (ms->ms_control_exp == NULL) {
841                 int flags = LDLM_FL_LOCAL_ONLY | LDLM_FL_ATOMIC_CB;
842
843                 /*
844                  * Current node is controller, that is mdt0, where we should
845                  * take BFL lock.
846                  */
847                 rc = ldlm_cli_enqueue_local(ns, res_id, LDLM_IBITS, policy,
848                                             LCK_EX, &flags, ldlm_blocking_ast,
849                                             ldlm_completion_ast, NULL, NULL, 0,
850                                             &info->mti_exp->exp_handle.h_cookie,
851                                             lh);
852         } else {
853                 struct ldlm_enqueue_info einfo = { LDLM_IBITS, LCK_EX,
854                      ldlm_blocking_ast, ldlm_completion_ast, NULL, NULL, NULL };
855                 int flags = 0;
856
857                 /*
858                  * This is the case mdt0 is remote node, issue DLM lock like
859                  * other clients.
860                  */
861                 rc = ldlm_cli_enqueue(ms->ms_control_exp, NULL, &einfo, res_id,
862                                       policy, &flags, NULL, 0, lh, 0);
863         }
864
865         RETURN(rc);
866 }
867
868 static void mdt_rename_unlock(struct lustre_handle *lh)
869 {
870         ENTRY;
871         LASSERT(lustre_handle_is_used(lh));
872         ldlm_lock_decref(lh, LCK_EX);
873         EXIT;
874 }
875
876 /*
877  * This is is_subdir() variant, it is CMD if cmm forwards it to correct
878  * target. Source should not be ancestor of target dir. May be other rename
879  * checks can be moved here later.
880  */
881 static int mdt_rename_sanity(struct mdt_thread_info *info, struct lu_fid *fid)
882 {
883         struct mdt_reint_record *rr = &info->mti_rr;
884         struct lu_fid dst_fid = *rr->rr_fid2;
885         struct mdt_object *dst;
886         int rc = 0;
887         ENTRY;
888
889         do {
890                 LASSERT(fid_is_sane(&dst_fid));
891                 dst = mdt_object_find(info->mti_env, info->mti_mdt, &dst_fid);
892                 if (!IS_ERR(dst)) {
893                         rc = mdo_is_subdir(info->mti_env,
894                                            mdt_object_child(dst), fid,
895                                            &dst_fid);
896                         mdt_object_put(info->mti_env, dst);
897                         if (rc != -EREMOTE && rc < 0) {
898                                 CERROR("Failed mdo_is_subdir(), rc %d\n", rc);
899                         } else {
900                                 /* check the found fid */
901                                 if (lu_fid_eq(&dst_fid, fid))
902                                         rc = -EINVAL;
903                         }
904                 } else {
905                         rc = PTR_ERR(dst);
906                 }
907         } while (rc == -EREMOTE);
908
909         RETURN(rc);
910 }
911
912 static int mdt_reint_rename(struct mdt_thread_info *info,
913                             struct mdt_lock_handle *lhc)
914 {
915         struct mdt_reint_record *rr = &info->mti_rr;
916         struct md_attr          *ma = &info->mti_attr;
917         struct ptlrpc_request   *req = mdt_info_req(info);
918         struct mdt_object       *msrcdir;
919         struct mdt_object       *mtgtdir;
920         struct mdt_object       *mold;
921         struct mdt_object       *mnew = NULL;
922         struct mdt_lock_handle  *lh_srcdirp;
923         struct mdt_lock_handle  *lh_tgtdirp;
924         struct mdt_lock_handle  *lh_oldp;
925         struct mdt_lock_handle  *lh_newp;
926         struct lu_fid           *old_fid = &info->mti_tmp_fid1;
927         struct lu_fid           *new_fid = &info->mti_tmp_fid2;
928         struct lustre_handle     rename_lh = { 0 };
929         struct lu_name           slname = { 0 };
930         struct lu_name          *lname;
931         int                      rc;
932         ENTRY;
933
934         if (info->mti_dlm_req)
935                 ldlm_request_cancel(mdt_info_req(info), info->mti_dlm_req, 0);
936
937         if (info->mti_cross_ref) {
938                 rc = mdt_reint_rename_tgt(info);
939                 RETURN(rc);
940         }
941
942         DEBUG_REQ(D_INODE, req, "rename "DFID"/%s to "DFID"/%s",
943                   PFID(rr->rr_fid1), rr->rr_name,
944                   PFID(rr->rr_fid2), rr->rr_tgt);
945
946         rc = mdt_rename_lock(info, &rename_lh);
947         if (rc) {
948                 CERROR("Can't lock FS for rename, rc %d\n", rc);
949                 RETURN(rc);
950         }
951
952         lh_newp = &info->mti_lh[MDT_LH_NEW];
953
954         /* step 1: lock the source dir. */
955         lh_srcdirp = &info->mti_lh[MDT_LH_PARENT];
956         mdt_lock_pdo_init(lh_srcdirp, LCK_PW, rr->rr_name,
957                           rr->rr_namelen);
958         msrcdir = mdt_object_find_lock(info, rr->rr_fid1, lh_srcdirp,
959                                        MDS_INODELOCK_UPDATE);
960         if (IS_ERR(msrcdir))
961                 GOTO(out_rename_lock, rc = PTR_ERR(msrcdir));
962
963         info->mti_mos[0] = msrcdir;
964         rc = mdt_version_get_check(info, 0);
965         if (rc)
966                 GOTO(out_unlock_source, rc);
967
968         /* step 2: find & lock the target dir. */
969         lh_tgtdirp = &info->mti_lh[MDT_LH_CHILD];
970         mdt_lock_pdo_init(lh_tgtdirp, LCK_PW, rr->rr_tgt,
971                           rr->rr_tgtlen);
972         if (lu_fid_eq(rr->rr_fid1, rr->rr_fid2)) {
973                 mdt_object_get(info->mti_env, msrcdir);
974                 mtgtdir = msrcdir;
975                 if (lh_tgtdirp->mlh_pdo_hash != lh_srcdirp->mlh_pdo_hash) {
976                          rc = mdt_pdir_hash_lock(info, lh_tgtdirp, mtgtdir,
977                                                  MDS_INODELOCK_UPDATE);
978                          if (rc)
979                                  GOTO(out_unlock_source, rc);
980                          OBD_FAIL_TIMEOUT(OBD_FAIL_MDS_PDO_LOCK2, 10);
981                 }
982         } else {
983                 mtgtdir = mdt_object_find(info->mti_env, info->mti_mdt,
984                                           rr->rr_fid2);
985                 if (IS_ERR(mtgtdir))
986                         GOTO(out_unlock_source, rc = PTR_ERR(mtgtdir));
987
988                 rc = mdt_object_exists(mtgtdir);
989                 if (rc == 0)
990                         GOTO(out_unlock_target, rc = -ESTALE);
991                 else if (rc > 0) {
992                         /* we lock the target dir if it is local */
993                         rc = mdt_object_lock(info, mtgtdir, lh_tgtdirp,
994                                              MDS_INODELOCK_UPDATE,
995                                              MDT_LOCAL_LOCK);
996                         if (rc != 0) {
997                                 mdt_object_put(info->mti_env, mtgtdir);
998                                 GOTO(out_unlock_source, rc);
999                         }
1000
1001                         info->mti_mos[1] = mtgtdir;
1002                         rc = mdt_version_get_check(info, 1);
1003                         if (rc)
1004                                 GOTO(out_unlock_target, rc);
1005                 }
1006         }
1007
1008         /* step 3: find & lock the old object. */
1009         lname = mdt_name(info->mti_env, (char *)rr->rr_name, rr->rr_namelen);
1010         mdt_name_copy(&slname, lname);
1011         rc = mdo_lookup(info->mti_env, mdt_object_child(msrcdir),
1012                         &slname, old_fid, &info->mti_spec);
1013         if (rc != 0)
1014                 GOTO(out_unlock_target, rc);
1015
1016         if (lu_fid_eq(old_fid, rr->rr_fid1) || lu_fid_eq(old_fid, rr->rr_fid2))
1017                 GOTO(out_unlock_target, rc = -EINVAL);
1018
1019         mold = mdt_object_find(info->mti_env, info->mti_mdt, old_fid);
1020         if (IS_ERR(mold))
1021                 GOTO(out_unlock_target, rc = PTR_ERR(mold));
1022
1023         lh_oldp = &info->mti_lh[MDT_LH_OLD];
1024         mdt_lock_reg_init(lh_oldp, LCK_EX);
1025         rc = mdt_object_lock(info, mold, lh_oldp, MDS_INODELOCK_LOOKUP,
1026                              MDT_CROSS_LOCK);
1027         if (rc != 0) {
1028                 mdt_object_put(info->mti_env, mold);
1029                 GOTO(out_unlock_target, rc);
1030         }
1031
1032         info->mti_mos[2] = mold;
1033         rc = mdt_version_get_check(info, 2);
1034         if (rc)
1035                 GOTO(out_unlock_old, rc);
1036
1037         mdt_set_capainfo(info, 2, old_fid, BYPASS_CAPA);
1038
1039         /* step 4: find & lock the new object. */
1040         /* new target object may not exist now */
1041         lname = mdt_name(info->mti_env, (char *)rr->rr_tgt, rr->rr_tgtlen);
1042         rc = mdo_lookup(info->mti_env, mdt_object_child(mtgtdir),
1043                         lname, new_fid, &info->mti_spec);
1044         if (rc == 0) {
1045                 /* the new_fid should have been filled at this moment */
1046                 if (lu_fid_eq(old_fid, new_fid))
1047                        GOTO(out_unlock_old, rc);
1048
1049                 if (lu_fid_eq(new_fid, rr->rr_fid1) ||
1050                     lu_fid_eq(new_fid, rr->rr_fid2))
1051                         GOTO(out_unlock_old, rc = -EINVAL);
1052
1053                 mdt_lock_reg_init(lh_newp, LCK_EX);
1054                 mnew = mdt_object_find(info->mti_env, info->mti_mdt, new_fid);
1055                 if (IS_ERR(mnew))
1056                         GOTO(out_unlock_old, rc = PTR_ERR(mnew));
1057
1058                 rc = mdt_object_lock(info, mnew, lh_newp,
1059                                      MDS_INODELOCK_FULL, MDT_CROSS_LOCK);
1060                 if (rc != 0) {
1061                         mdt_object_put(info->mti_env, mnew);
1062                         GOTO(out_unlock_old, rc);
1063                 }
1064
1065                 info->mti_mos[3] = mnew;
1066                 rc = mdt_version_get_check(info, 3);
1067                 if (rc)
1068                         GOTO(out_unlock_new, rc);
1069
1070                 mdt_set_capainfo(info, 3, new_fid, BYPASS_CAPA);
1071         } else if (rc != -EREMOTE && rc != -ENOENT)
1072                 GOTO(out_unlock_old, rc);
1073
1074         /* step 5: rename it */
1075         mdt_reint_init_ma(info, ma);
1076         if (!ma->ma_lmm || !ma->ma_cookie)
1077                 GOTO(out_unlock_new, rc = -EINVAL);
1078
1079         mdt_fail_write(info->mti_env, info->mti_mdt->mdt_bottom,
1080                        OBD_FAIL_MDS_REINT_RENAME_WRITE);
1081
1082
1083         /* Check if @dst is subdir of @src. */
1084         rc = mdt_rename_sanity(info, old_fid);
1085         if (rc)
1086                 GOTO(out_unlock_new, rc);
1087
1088         rc = mdo_rename(info->mti_env, mdt_object_child(msrcdir),
1089                         mdt_object_child(mtgtdir), old_fid, &slname,
1090                         (mnew ? mdt_object_child(mnew) : NULL),
1091                         lname, ma);
1092
1093         /* handle last link of tgt object */
1094         if (rc == 0 && mnew)
1095                 mdt_handle_last_unlink(info, mnew, ma);
1096
1097         EXIT;
1098 out_unlock_new:
1099         if (mnew)
1100                 mdt_object_unlock_put(info, mnew, lh_newp, rc);
1101 out_unlock_old:
1102         mdt_object_unlock_put(info, mold, lh_oldp, rc);
1103 out_unlock_target:
1104         mdt_object_unlock_put(info, mtgtdir, lh_tgtdirp, rc);
1105 out_unlock_source:
1106         mdt_object_unlock_put(info, msrcdir, lh_srcdirp, rc);
1107 out_rename_lock:
1108         mdt_rename_unlock(&rename_lh);
1109         return rc;
1110 }
1111
1112 typedef int (*mdt_reinter)(struct mdt_thread_info *info,
1113                            struct mdt_lock_handle *lhc);
1114
1115 static mdt_reinter reinters[REINT_MAX] = {
1116         [REINT_SETATTR]  = mdt_reint_setattr,
1117         [REINT_CREATE]   = mdt_reint_create,
1118         [REINT_LINK]     = mdt_reint_link,
1119         [REINT_UNLINK]   = mdt_reint_unlink,
1120         [REINT_RENAME]   = mdt_reint_rename,
1121         [REINT_OPEN]     = mdt_reint_open,
1122         [REINT_SETXATTR] = mdt_reint_setxattr
1123 };
1124
1125 int mdt_reint_rec(struct mdt_thread_info *info,
1126                   struct mdt_lock_handle *lhc)
1127 {
1128         int rc;
1129         ENTRY;
1130
1131         rc = reinters[info->mti_rr.rr_opcode](info, lhc);
1132
1133         RETURN(rc);
1134 }