xfs_rename.c 17 KB

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