xfs_rename.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. /*
  2. * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
  3. * All Rights Reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it would be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write the Free Software Foundation,
  16. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #include "xfs.h"
  19. #include "xfs_fs.h"
  20. #include "xfs_types.h"
  21. #include "xfs_log.h"
  22. #include "xfs_inum.h"
  23. #include "xfs_trans.h"
  24. #include "xfs_sb.h"
  25. #include "xfs_dir.h"
  26. #include "xfs_dir2.h"
  27. #include "xfs_dmapi.h"
  28. #include "xfs_mount.h"
  29. #include "xfs_da_btree.h"
  30. #include "xfs_bmap_btree.h"
  31. #include "xfs_dir_sf.h"
  32. #include "xfs_dir2_sf.h"
  33. #include "xfs_attr_sf.h"
  34. #include "xfs_dinode.h"
  35. #include "xfs_inode.h"
  36. #include "xfs_inode_item.h"
  37. #include "xfs_bmap.h"
  38. #include "xfs_error.h"
  39. #include "xfs_quota.h"
  40. #include "xfs_refcache.h"
  41. #include "xfs_utils.h"
  42. #include "xfs_trans_space.h"
  43. #include "xfs_dir_leaf.h"
  44. /*
  45. * Given an array of up to 4 inode pointers, unlock the pointed to inodes.
  46. * If there are fewer than 4 entries in the array, the empty entries will
  47. * be at the end and will have NULL pointers in them.
  48. */
  49. STATIC void
  50. xfs_rename_unlock4(
  51. xfs_inode_t **i_tab,
  52. uint lock_mode)
  53. {
  54. int i;
  55. xfs_iunlock(i_tab[0], lock_mode);
  56. for (i = 1; i < 4; i++) {
  57. if (i_tab[i] == NULL) {
  58. break;
  59. }
  60. /*
  61. * Watch out for duplicate entries in the table.
  62. */
  63. if (i_tab[i] != i_tab[i-1]) {
  64. xfs_iunlock(i_tab[i], lock_mode);
  65. }
  66. }
  67. }
  68. #ifdef DEBUG
  69. int xfs_rename_skip, xfs_rename_nskip;
  70. #endif
  71. /*
  72. * The following routine will acquire the locks required for a rename
  73. * operation. The code understands the semantics of renames and will
  74. * validate that name1 exists under dp1 & that name2 may or may not
  75. * exist under dp2.
  76. *
  77. * We are renaming dp1/name1 to dp2/name2.
  78. *
  79. * Return ENOENT if dp1 does not exist, other lookup errors, or 0 for success.
  80. */
  81. STATIC int
  82. xfs_lock_for_rename(
  83. xfs_inode_t *dp1, /* old (source) directory inode */
  84. xfs_inode_t *dp2, /* new (target) directory inode */
  85. vname_t *vname1,/* old entry name */
  86. vname_t *vname2,/* new entry name */
  87. xfs_inode_t **ipp1, /* inode of old entry */
  88. xfs_inode_t **ipp2, /* inode of new entry, if it
  89. already exists, NULL otherwise. */
  90. xfs_inode_t **i_tab,/* array of inode returned, sorted */
  91. int *num_inodes) /* number of inodes in array */
  92. {
  93. xfs_inode_t *ip1, *ip2, *temp;
  94. xfs_ino_t inum1, inum2;
  95. int error;
  96. int i, j;
  97. uint lock_mode;
  98. int diff_dirs = (dp1 != dp2);
  99. ip2 = NULL;
  100. /*
  101. * First, find out the current inums of the entries so that we
  102. * can determine the initial locking order. We'll have to
  103. * sanity check stuff after all the locks have been acquired
  104. * to see if we still have the right inodes, directories, etc.
  105. */
  106. lock_mode = xfs_ilock_map_shared(dp1);
  107. error = xfs_get_dir_entry(vname1, &ip1);
  108. if (error) {
  109. xfs_iunlock_map_shared(dp1, lock_mode);
  110. return error;
  111. }
  112. inum1 = ip1->i_ino;
  113. ASSERT(ip1);
  114. ITRACE(ip1);
  115. /*
  116. * Unlock dp1 and lock dp2 if they are different.
  117. */
  118. if (diff_dirs) {
  119. xfs_iunlock_map_shared(dp1, lock_mode);
  120. lock_mode = xfs_ilock_map_shared(dp2);
  121. }
  122. error = xfs_dir_lookup_int(XFS_ITOBHV(dp2), lock_mode,
  123. vname2, &inum2, &ip2);
  124. if (error == ENOENT) { /* target does not need to exist. */
  125. inum2 = 0;
  126. } else if (error) {
  127. /*
  128. * If dp2 and dp1 are the same, the next line unlocks dp1.
  129. * Got it?
  130. */
  131. xfs_iunlock_map_shared(dp2, lock_mode);
  132. IRELE (ip1);
  133. return error;
  134. } else {
  135. ITRACE(ip2);
  136. }
  137. /*
  138. * i_tab contains a list of pointers to inodes. We initialize
  139. * the table here & we'll sort it. We will then use it to
  140. * order the acquisition of the inode locks.
  141. *
  142. * Note that the table may contain duplicates. e.g., dp1 == dp2.
  143. */
  144. i_tab[0] = dp1;
  145. i_tab[1] = dp2;
  146. i_tab[2] = ip1;
  147. if (inum2 == 0) {
  148. *num_inodes = 3;
  149. i_tab[3] = NULL;
  150. } else {
  151. *num_inodes = 4;
  152. i_tab[3] = ip2;
  153. }
  154. /*
  155. * Sort the elements via bubble sort. (Remember, there are at
  156. * most 4 elements to sort, so this is adequate.)
  157. */
  158. for (i=0; i < *num_inodes; i++) {
  159. for (j=1; j < *num_inodes; j++) {
  160. if (i_tab[j]->i_ino < i_tab[j-1]->i_ino) {
  161. temp = i_tab[j];
  162. i_tab[j] = i_tab[j-1];
  163. i_tab[j-1] = temp;
  164. }
  165. }
  166. }
  167. /*
  168. * We have dp2 locked. If it isn't first, unlock it.
  169. * If it is first, tell xfs_lock_inodes so it can skip it
  170. * when locking. if dp1 == dp2, xfs_lock_inodes will skip both
  171. * since they are equal. xfs_lock_inodes needs all these inodes
  172. * so that it can unlock and retry if there might be a dead-lock
  173. * potential with the log.
  174. */
  175. if (i_tab[0] == dp2 && lock_mode == XFS_ILOCK_SHARED) {
  176. #ifdef DEBUG
  177. xfs_rename_skip++;
  178. #endif
  179. xfs_lock_inodes(i_tab, *num_inodes, 1, XFS_ILOCK_SHARED);
  180. } else {
  181. #ifdef DEBUG
  182. xfs_rename_nskip++;
  183. #endif
  184. xfs_iunlock_map_shared(dp2, lock_mode);
  185. xfs_lock_inodes(i_tab, *num_inodes, 0, XFS_ILOCK_SHARED);
  186. }
  187. /*
  188. * Set the return value. Null out any unused entries in i_tab.
  189. */
  190. *ipp1 = *ipp2 = NULL;
  191. for (i=0; i < *num_inodes; i++) {
  192. if (i_tab[i]->i_ino == inum1) {
  193. *ipp1 = i_tab[i];
  194. }
  195. if (i_tab[i]->i_ino == inum2) {
  196. *ipp2 = i_tab[i];
  197. }
  198. }
  199. for (;i < 4; i++) {
  200. i_tab[i] = NULL;
  201. }
  202. return 0;
  203. }
  204. /*
  205. * xfs_rename
  206. */
  207. int
  208. xfs_rename(
  209. bhv_desc_t *src_dir_bdp,
  210. vname_t *src_vname,
  211. vnode_t *target_dir_vp,
  212. vname_t *target_vname,
  213. cred_t *credp)
  214. {
  215. xfs_trans_t *tp;
  216. xfs_inode_t *src_dp, *target_dp, *src_ip, *target_ip;
  217. xfs_mount_t *mp;
  218. int new_parent; /* moving to a new dir */
  219. int src_is_directory; /* src_name is a directory */
  220. int error;
  221. xfs_bmap_free_t free_list;
  222. xfs_fsblock_t first_block;
  223. int cancel_flags;
  224. int committed;
  225. xfs_inode_t *inodes[4];
  226. int target_ip_dropped = 0; /* dropped target_ip link? */
  227. vnode_t *src_dir_vp;
  228. int spaceres;
  229. int target_link_zero = 0;
  230. int num_inodes;
  231. char *src_name = VNAME(src_vname);
  232. char *target_name = VNAME(target_vname);
  233. int src_namelen = VNAMELEN(src_vname);
  234. int target_namelen = VNAMELEN(target_vname);
  235. src_dir_vp = BHV_TO_VNODE(src_dir_bdp);
  236. vn_trace_entry(src_dir_vp, "xfs_rename", (inst_t *)__return_address);
  237. vn_trace_entry(target_dir_vp, "xfs_rename", (inst_t *)__return_address);
  238. /*
  239. * Find the XFS behavior descriptor for the target directory
  240. * vnode since it was not handed to us.
  241. */
  242. target_dp = xfs_vtoi(target_dir_vp);
  243. if (target_dp == NULL) {
  244. return XFS_ERROR(EXDEV);
  245. }
  246. src_dp = XFS_BHVTOI(src_dir_bdp);
  247. mp = src_dp->i_mount;
  248. if (DM_EVENT_ENABLED(src_dir_vp->v_vfsp, src_dp, DM_EVENT_RENAME) ||
  249. DM_EVENT_ENABLED(target_dir_vp->v_vfsp,
  250. target_dp, DM_EVENT_RENAME)) {
  251. error = XFS_SEND_NAMESP(mp, DM_EVENT_RENAME,
  252. src_dir_vp, DM_RIGHT_NULL,
  253. target_dir_vp, DM_RIGHT_NULL,
  254. src_name, target_name,
  255. 0, 0, 0);
  256. if (error) {
  257. return error;
  258. }
  259. }
  260. /* Return through std_return after this point. */
  261. /*
  262. * Lock all the participating inodes. Depending upon whether
  263. * the target_name exists in the target directory, and
  264. * whether the target directory is the same as the source
  265. * directory, we can lock from 2 to 4 inodes.
  266. * xfs_lock_for_rename() will return ENOENT if src_name
  267. * does not exist in the source directory.
  268. */
  269. tp = NULL;
  270. error = xfs_lock_for_rename(src_dp, target_dp, src_vname,
  271. target_vname, &src_ip, &target_ip, inodes,
  272. &num_inodes);
  273. if (error) {
  274. /*
  275. * We have nothing locked, no inode references, and
  276. * no transaction, so just get out.
  277. */
  278. goto std_return;
  279. }
  280. ASSERT(src_ip != NULL);
  281. if ((src_ip->i_d.di_mode & S_IFMT) == S_IFDIR) {
  282. /*
  283. * Check for link count overflow on target_dp
  284. */
  285. if (target_ip == NULL && (src_dp != target_dp) &&
  286. target_dp->i_d.di_nlink >= XFS_MAXLINK) {
  287. error = XFS_ERROR(EMLINK);
  288. xfs_rename_unlock4(inodes, XFS_ILOCK_SHARED);
  289. goto rele_return;
  290. }
  291. }
  292. /*
  293. * If we are using project inheritance, we only allow renames
  294. * into our tree when the project IDs are the same; else the
  295. * tree quota mechanism would be circumvented.
  296. */
  297. if (unlikely((target_dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
  298. (target_dp->i_d.di_projid != src_ip->i_d.di_projid))) {
  299. error = XFS_ERROR(EXDEV);
  300. xfs_rename_unlock4(inodes, XFS_ILOCK_SHARED);
  301. goto rele_return;
  302. }
  303. new_parent = (src_dp != target_dp);
  304. src_is_directory = ((src_ip->i_d.di_mode & S_IFMT) == S_IFDIR);
  305. /*
  306. * Drop the locks on our inodes so that we can start the transaction.
  307. */
  308. xfs_rename_unlock4(inodes, XFS_ILOCK_SHARED);
  309. XFS_BMAP_INIT(&free_list, &first_block);
  310. tp = xfs_trans_alloc(mp, XFS_TRANS_RENAME);
  311. cancel_flags = XFS_TRANS_RELEASE_LOG_RES;
  312. spaceres = XFS_RENAME_SPACE_RES(mp, target_namelen);
  313. error = xfs_trans_reserve(tp, spaceres, XFS_RENAME_LOG_RES(mp), 0,
  314. XFS_TRANS_PERM_LOG_RES, XFS_RENAME_LOG_COUNT);
  315. if (error == ENOSPC) {
  316. spaceres = 0;
  317. error = xfs_trans_reserve(tp, 0, XFS_RENAME_LOG_RES(mp), 0,
  318. XFS_TRANS_PERM_LOG_RES, XFS_RENAME_LOG_COUNT);
  319. }
  320. if (error) {
  321. xfs_trans_cancel(tp, 0);
  322. goto rele_return;
  323. }
  324. /*
  325. * Attach the dquots to the inodes
  326. */
  327. if ((error = XFS_QM_DQVOPRENAME(mp, inodes))) {
  328. xfs_trans_cancel(tp, cancel_flags);
  329. goto rele_return;
  330. }
  331. /*
  332. * Reacquire the inode locks we dropped above.
  333. */
  334. xfs_lock_inodes(inodes, num_inodes, 0, XFS_ILOCK_EXCL);
  335. /*
  336. * Join all the inodes to the transaction. From this point on,
  337. * we can rely on either trans_commit or trans_cancel to unlock
  338. * them. Note that we need to add a vnode reference to the
  339. * directories since trans_commit & trans_cancel will decrement
  340. * them when they unlock the inodes. Also, we need to be careful
  341. * not to add an inode to the transaction more than once.
  342. */
  343. VN_HOLD(src_dir_vp);
  344. xfs_trans_ijoin(tp, src_dp, XFS_ILOCK_EXCL);
  345. if (new_parent) {
  346. VN_HOLD(target_dir_vp);
  347. xfs_trans_ijoin(tp, target_dp, XFS_ILOCK_EXCL);
  348. }
  349. if ((src_ip != src_dp) && (src_ip != target_dp)) {
  350. xfs_trans_ijoin(tp, src_ip, XFS_ILOCK_EXCL);
  351. }
  352. if ((target_ip != NULL) &&
  353. (target_ip != src_ip) &&
  354. (target_ip != src_dp) &&
  355. (target_ip != target_dp)) {
  356. xfs_trans_ijoin(tp, target_ip, XFS_ILOCK_EXCL);
  357. }
  358. /*
  359. * Set up the target.
  360. */
  361. if (target_ip == NULL) {
  362. /*
  363. * If there's no space reservation, check the entry will
  364. * fit before actually inserting it.
  365. */
  366. if (spaceres == 0 &&
  367. (error = XFS_DIR_CANENTER(mp, tp, target_dp, target_name,
  368. target_namelen))) {
  369. goto error_return;
  370. }
  371. /*
  372. * If target does not exist and the rename crosses
  373. * directories, adjust the target directory link count
  374. * to account for the ".." reference from the new entry.
  375. */
  376. error = XFS_DIR_CREATENAME(mp, tp, target_dp, target_name,
  377. target_namelen, src_ip->i_ino,
  378. &first_block, &free_list, spaceres);
  379. if (error == ENOSPC) {
  380. goto error_return;
  381. }
  382. if (error) {
  383. goto abort_return;
  384. }
  385. xfs_ichgtime(target_dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
  386. if (new_parent && src_is_directory) {
  387. error = xfs_bumplink(tp, target_dp);
  388. if (error) {
  389. goto abort_return;
  390. }
  391. }
  392. } else { /* target_ip != NULL */
  393. /*
  394. * If target exists and it's a directory, check that both
  395. * target and source are directories and that target can be
  396. * destroyed, or that neither is a directory.
  397. */
  398. if ((target_ip->i_d.di_mode & S_IFMT) == S_IFDIR) {
  399. /*
  400. * Make sure target dir is empty.
  401. */
  402. if (!(XFS_DIR_ISEMPTY(target_ip->i_mount, target_ip)) ||
  403. (target_ip->i_d.di_nlink > 2)) {
  404. error = XFS_ERROR(EEXIST);
  405. goto error_return;
  406. }
  407. }
  408. /*
  409. * Link the source inode under the target name.
  410. * If the source inode is a directory and we are moving
  411. * it across directories, its ".." entry will be
  412. * inconsistent until we replace that down below.
  413. *
  414. * In case there is already an entry with the same
  415. * name at the destination directory, remove it first.
  416. */
  417. error = XFS_DIR_REPLACE(mp, tp, target_dp, target_name,
  418. target_namelen, src_ip->i_ino, &first_block,
  419. &free_list, spaceres);
  420. if (error) {
  421. goto abort_return;
  422. }
  423. xfs_ichgtime(target_dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
  424. /*
  425. * Decrement the link count on the target since the target
  426. * dir no longer points to it.
  427. */
  428. error = xfs_droplink(tp, target_ip);
  429. if (error) {
  430. goto abort_return;
  431. }
  432. target_ip_dropped = 1;
  433. if (src_is_directory) {
  434. /*
  435. * Drop the link from the old "." entry.
  436. */
  437. error = xfs_droplink(tp, target_ip);
  438. if (error) {
  439. goto abort_return;
  440. }
  441. }
  442. /* Do this test while we still hold the locks */
  443. target_link_zero = (target_ip)->i_d.di_nlink==0;
  444. } /* target_ip != NULL */
  445. /*
  446. * Remove the source.
  447. */
  448. if (new_parent && src_is_directory) {
  449. /*
  450. * Rewrite the ".." entry to point to the new
  451. * directory.
  452. */
  453. error = XFS_DIR_REPLACE(mp, tp, src_ip, "..", 2,
  454. target_dp->i_ino, &first_block,
  455. &free_list, spaceres);
  456. ASSERT(error != EEXIST);
  457. if (error) {
  458. goto abort_return;
  459. }
  460. xfs_ichgtime(src_ip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
  461. } else {
  462. /*
  463. * We always want to hit the ctime on the source inode.
  464. * We do it in the if clause above for the 'new_parent &&
  465. * src_is_directory' case, and here we get all the other
  466. * cases. This isn't strictly required by the standards
  467. * since the source inode isn't really being changed,
  468. * but old unix file systems did it and some incremental
  469. * backup programs won't work without it.
  470. */
  471. xfs_ichgtime(src_ip, XFS_ICHGTIME_CHG);
  472. }
  473. /*
  474. * Adjust the link count on src_dp. This is necessary when
  475. * renaming a directory, either within one parent when
  476. * the target existed, or across two parent directories.
  477. */
  478. if (src_is_directory && (new_parent || target_ip != NULL)) {
  479. /*
  480. * Decrement link count on src_directory since the
  481. * entry that's moved no longer points to it.
  482. */
  483. error = xfs_droplink(tp, src_dp);
  484. if (error) {
  485. goto abort_return;
  486. }
  487. }
  488. error = XFS_DIR_REMOVENAME(mp, tp, src_dp, src_name, src_namelen,
  489. src_ip->i_ino, &first_block, &free_list, spaceres);
  490. if (error) {
  491. goto abort_return;
  492. }
  493. xfs_ichgtime(src_dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
  494. /*
  495. * Update the generation counts on all the directory inodes
  496. * that we're modifying.
  497. */
  498. src_dp->i_gen++;
  499. xfs_trans_log_inode(tp, src_dp, XFS_ILOG_CORE);
  500. if (new_parent) {
  501. target_dp->i_gen++;
  502. xfs_trans_log_inode(tp, target_dp, XFS_ILOG_CORE);
  503. }
  504. /*
  505. * If there was a target inode, take an extra reference on
  506. * it here so that it doesn't go to xfs_inactive() from
  507. * within the commit.
  508. */
  509. if (target_ip != NULL) {
  510. IHOLD(target_ip);
  511. }
  512. /*
  513. * If this is a synchronous mount, make sure that the
  514. * rename transaction goes to disk before returning to
  515. * the user.
  516. */
  517. if (mp->m_flags & (XFS_MOUNT_WSYNC|XFS_MOUNT_DIRSYNC)) {
  518. xfs_trans_set_sync(tp);
  519. }
  520. /*
  521. * Take refs. for vop_link_removed calls below. No need to worry
  522. * about directory refs. because the caller holds them.
  523. *
  524. * Do holds before the xfs_bmap_finish since it might rele them down
  525. * to zero.
  526. */
  527. if (target_ip_dropped)
  528. IHOLD(target_ip);
  529. IHOLD(src_ip);
  530. error = xfs_bmap_finish(&tp, &free_list, first_block, &committed);
  531. if (error) {
  532. xfs_bmap_cancel(&free_list);
  533. xfs_trans_cancel(tp, (XFS_TRANS_RELEASE_LOG_RES |
  534. XFS_TRANS_ABORT));
  535. if (target_ip != NULL) {
  536. IRELE(target_ip);
  537. }
  538. if (target_ip_dropped) {
  539. IRELE(target_ip);
  540. }
  541. IRELE(src_ip);
  542. goto std_return;
  543. }
  544. /*
  545. * trans_commit will unlock src_ip, target_ip & decrement
  546. * the vnode references.
  547. */
  548. error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES, NULL);
  549. if (target_ip != NULL) {
  550. xfs_refcache_purge_ip(target_ip);
  551. IRELE(target_ip);
  552. }
  553. /*
  554. * Let interposed file systems know about removed links.
  555. */
  556. if (target_ip_dropped) {
  557. VOP_LINK_REMOVED(XFS_ITOV(target_ip), target_dir_vp,
  558. target_link_zero);
  559. IRELE(target_ip);
  560. }
  561. IRELE(src_ip);
  562. /* Fall through to std_return with error = 0 or errno from
  563. * xfs_trans_commit */
  564. std_return:
  565. if (DM_EVENT_ENABLED(src_dir_vp->v_vfsp, src_dp, DM_EVENT_POSTRENAME) ||
  566. DM_EVENT_ENABLED(target_dir_vp->v_vfsp,
  567. target_dp, DM_EVENT_POSTRENAME)) {
  568. (void) XFS_SEND_NAMESP (mp, DM_EVENT_POSTRENAME,
  569. src_dir_vp, DM_RIGHT_NULL,
  570. target_dir_vp, DM_RIGHT_NULL,
  571. src_name, target_name,
  572. 0, error, 0);
  573. }
  574. return error;
  575. abort_return:
  576. cancel_flags |= XFS_TRANS_ABORT;
  577. /* FALLTHROUGH */
  578. error_return:
  579. xfs_bmap_cancel(&free_list);
  580. xfs_trans_cancel(tp, cancel_flags);
  581. goto std_return;
  582. rele_return:
  583. IRELE(src_ip);
  584. if (target_ip != NULL) {
  585. IRELE(target_ip);
  586. }
  587. goto std_return;
  588. }