aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_vnodeops.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2010-06-23 21:36:58 -0400
committerAlex Elder <aelder@sgi.com>2010-07-26 14:16:36 -0400
commit898621d5a72c6799a9a13fce20443b4b6699899c (patch)
tree6cd994bd8d24f4f4f6ac5b5b57e0b99ee02d4ba6 /fs/xfs/xfs_vnodeops.c
parent4d16e9246fc3b3cf7bc95609eff66929a39daa06 (diff)
xfs: simplify inode to transaction joining
Currently we need to either call IHOLD or xfs_trans_ihold on an inode when joining it to a transaction via xfs_trans_ijoin. This patches instead makes xfs_trans_ijoin usable on it's own by doing an implicity xfs_trans_ihold, which also allows us to drop the third argument. For the case where we want to hold a reference on the inode a xfs_trans_ijoin_ref wrapper is added which does the IHOLD and marks the inode for needing an xfs_iput. In addition to the cleaner interface to the caller this also simplifies the implementation. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <dchinner@redhat.com>
Diffstat (limited to 'fs/xfs/xfs_vnodeops.c')
-rw-r--r--fs/xfs/xfs_vnodeops.c69
1 files changed, 19 insertions, 50 deletions
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index 161444e768b6..130343a5d22d 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -268,8 +268,7 @@ xfs_setattr(
268 commit_flags = XFS_TRANS_RELEASE_LOG_RES; 268 commit_flags = XFS_TRANS_RELEASE_LOG_RES;
269 xfs_ilock(ip, XFS_ILOCK_EXCL); 269 xfs_ilock(ip, XFS_ILOCK_EXCL);
270 270
271 xfs_trans_ijoin(tp, ip, lock_flags); 271 xfs_trans_ijoin(tp, ip);
272 xfs_trans_ihold(tp, ip);
273 272
274 /* 273 /*
275 * Only change the c/mtime if we are changing the size 274 * Only change the c/mtime if we are changing the size
@@ -319,8 +318,7 @@ xfs_setattr(
319 xfs_iflags_set(ip, XFS_ITRUNCATED); 318 xfs_iflags_set(ip, XFS_ITRUNCATED);
320 } 319 }
321 } else if (tp) { 320 } else if (tp) {
322 xfs_trans_ijoin(tp, ip, lock_flags); 321 xfs_trans_ijoin(tp, ip);
323 xfs_trans_ihold(tp, ip);
324 } 322 }
325 323
326 /* 324 /*
@@ -653,10 +651,7 @@ xfs_free_eofblocks(
653 } 651 }
654 652
655 xfs_ilock(ip, XFS_ILOCK_EXCL); 653 xfs_ilock(ip, XFS_ILOCK_EXCL);
656 xfs_trans_ijoin(tp, ip, 654 xfs_trans_ijoin(tp, ip);
657 XFS_IOLOCK_EXCL |
658 XFS_ILOCK_EXCL);
659 xfs_trans_ihold(tp, ip);
660 655
661 error = xfs_itruncate_finish(&tp, ip, 656 error = xfs_itruncate_finish(&tp, ip,
662 ip->i_size, 657 ip->i_size,
@@ -728,8 +723,7 @@ xfs_inactive_symlink_rmt(
728 xfs_ilock(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL); 723 xfs_ilock(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL);
729 size = (int)ip->i_d.di_size; 724 size = (int)ip->i_d.di_size;
730 ip->i_d.di_size = 0; 725 ip->i_d.di_size = 0;
731 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL); 726 xfs_trans_ijoin(tp, ip);
732 xfs_trans_ihold(tp, ip);
733 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); 727 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
734 /* 728 /*
735 * Find the block(s) so we can inval and unmap them. 729 * Find the block(s) so we can inval and unmap them.
@@ -773,8 +767,7 @@ xfs_inactive_symlink_rmt(
773 * Mark it dirty so it will be logged and moved forward in the log as 767 * Mark it dirty so it will be logged and moved forward in the log as
774 * part of every commit. 768 * part of every commit.
775 */ 769 */
776 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL); 770 xfs_trans_ijoin(tp, ip);
777 xfs_trans_ihold(tp, ip);
778 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); 771 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
779 /* 772 /*
780 * Get a new, empty transaction to return to our caller. 773 * Get a new, empty transaction to return to our caller.
@@ -907,8 +900,7 @@ xfs_inactive_attrs(
907 goto error_cancel; 900 goto error_cancel;
908 901
909 xfs_ilock(ip, XFS_ILOCK_EXCL); 902 xfs_ilock(ip, XFS_ILOCK_EXCL);
910 xfs_trans_ijoin(tp, ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL); 903 xfs_trans_ijoin(tp, ip);
911 xfs_trans_ihold(tp, ip);
912 xfs_idestroy_fork(ip, XFS_ATTR_FORK); 904 xfs_idestroy_fork(ip, XFS_ATTR_FORK);
913 905
914 ASSERT(ip->i_d.di_anextents == 0); 906 ASSERT(ip->i_d.di_anextents == 0);
@@ -1095,8 +1087,7 @@ xfs_inactive(
1095 } 1087 }
1096 1088
1097 xfs_ilock(ip, XFS_ILOCK_EXCL); 1089 xfs_ilock(ip, XFS_ILOCK_EXCL);
1098 xfs_trans_ijoin(tp, ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL); 1090 xfs_trans_ijoin(tp, ip);
1099 xfs_trans_ihold(tp, ip);
1100 1091
1101 /* 1092 /*
1102 * normally, we have to run xfs_itruncate_finish sync. 1093 * normally, we have to run xfs_itruncate_finish sync.
@@ -1129,8 +1120,7 @@ xfs_inactive(
1129 return VN_INACTIVE_CACHE; 1120 return VN_INACTIVE_CACHE;
1130 } 1121 }
1131 1122
1132 xfs_trans_ijoin(tp, ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL); 1123 xfs_trans_ijoin(tp, ip);
1133 xfs_trans_ihold(tp, ip);
1134 } else { 1124 } else {
1135 error = xfs_trans_reserve(tp, 0, 1125 error = xfs_trans_reserve(tp, 0,
1136 XFS_IFREE_LOG_RES(mp), 1126 XFS_IFREE_LOG_RES(mp),
@@ -1143,8 +1133,7 @@ xfs_inactive(
1143 } 1133 }
1144 1134
1145 xfs_ilock(ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL); 1135 xfs_ilock(ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL);
1146 xfs_trans_ijoin(tp, ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL); 1136 xfs_trans_ijoin(tp, ip);
1147 xfs_trans_ihold(tp, ip);
1148 } 1137 }
1149 1138
1150 /* 1139 /*
@@ -1392,8 +1381,7 @@ xfs_create(
1392 * the transaction cancel unlocking dp so don't do it explicitly in the 1381 * the transaction cancel unlocking dp so don't do it explicitly in the
1393 * error path. 1382 * error path.
1394 */ 1383 */
1395 IHOLD(dp); 1384 xfs_trans_ijoin_ref(tp, dp, XFS_ILOCK_EXCL);
1396 xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL);
1397 unlock_dp_on_error = B_FALSE; 1385 unlock_dp_on_error = B_FALSE;
1398 1386
1399 error = xfs_dir_createname(tp, dp, name, ip->i_ino, 1387 error = xfs_dir_createname(tp, dp, name, ip->i_ino,
@@ -1730,15 +1718,8 @@ xfs_remove(
1730 1718
1731 xfs_lock_two_inodes(dp, ip, XFS_ILOCK_EXCL); 1719 xfs_lock_two_inodes(dp, ip, XFS_ILOCK_EXCL);
1732 1720
1733 /* 1721 xfs_trans_ijoin_ref(tp, dp, XFS_ILOCK_EXCL);
1734 * At this point, we've gotten both the directory and the entry 1722 xfs_trans_ijoin_ref(tp, ip, XFS_ILOCK_EXCL);
1735 * inodes locked.
1736 */
1737 IHOLD(ip);
1738 xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL);
1739
1740 IHOLD(dp);
1741 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
1742 1723
1743 /* 1724 /*
1744 * If we're removing a directory perform some additional validation. 1725 * If we're removing a directory perform some additional validation.
@@ -1884,15 +1865,8 @@ xfs_link(
1884 1865
1885 xfs_lock_two_inodes(sip, tdp, XFS_ILOCK_EXCL); 1866 xfs_lock_two_inodes(sip, tdp, XFS_ILOCK_EXCL);
1886 1867
1887 /* 1868 xfs_trans_ijoin_ref(tp, sip, XFS_ILOCK_EXCL);
1888 * Increment vnode ref counts since xfs_trans_commit & 1869 xfs_trans_ijoin_ref(tp, tdp, XFS_ILOCK_EXCL);
1889 * xfs_trans_cancel will both unlock the inodes and
1890 * decrement the associated ref counts.
1891 */
1892 IHOLD(sip);
1893 IHOLD(tdp);
1894 xfs_trans_ijoin(tp, sip, XFS_ILOCK_EXCL);
1895 xfs_trans_ijoin(tp, tdp, XFS_ILOCK_EXCL);
1896 1870
1897 /* 1871 /*
1898 * If the source has too many links, we can't make any more to it. 1872 * If the source has too many links, we can't make any more to it.
@@ -2087,8 +2061,7 @@ xfs_symlink(
2087 * transaction cancel unlocking dp so don't do it explicitly in the 2061 * transaction cancel unlocking dp so don't do it explicitly in the
2088 * error path. 2062 * error path.
2089 */ 2063 */
2090 IHOLD(dp); 2064 xfs_trans_ijoin_ref(tp, dp, XFS_ILOCK_EXCL);
2091 xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL);
2092 unlock_dp_on_error = B_FALSE; 2065 unlock_dp_on_error = B_FALSE;
2093 2066
2094 /* 2067 /*
@@ -2227,13 +2200,12 @@ xfs_set_dmattrs(
2227 return error; 2200 return error;
2228 } 2201 }
2229 xfs_ilock(ip, XFS_ILOCK_EXCL); 2202 xfs_ilock(ip, XFS_ILOCK_EXCL);
2230 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); 2203 xfs_trans_ijoin_ref(tp, ip, XFS_ILOCK_EXCL);
2231 2204
2232 ip->i_d.di_dmevmask = evmask; 2205 ip->i_d.di_dmevmask = evmask;
2233 ip->i_d.di_dmstate = state; 2206 ip->i_d.di_dmstate = state;
2234 2207
2235 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); 2208 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
2236 IHOLD(ip);
2237 error = xfs_trans_commit(tp, 0); 2209 error = xfs_trans_commit(tp, 0);
2238 2210
2239 return error; 2211 return error;
@@ -2366,8 +2338,7 @@ xfs_alloc_file_space(
2366 if (error) 2338 if (error)
2367 goto error1; 2339 goto error1;
2368 2340
2369 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); 2341 xfs_trans_ijoin(tp, ip);
2370 xfs_trans_ihold(tp, ip);
2371 2342
2372 /* 2343 /*
2373 * Issue the xfs_bmapi() call to allocate the blocks 2344 * Issue the xfs_bmapi() call to allocate the blocks
@@ -2668,8 +2639,7 @@ xfs_free_file_space(
2668 if (error) 2639 if (error)
2669 goto error1; 2640 goto error1;
2670 2641
2671 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); 2642 xfs_trans_ijoin(tp, ip);
2672 xfs_trans_ihold(tp, ip);
2673 2643
2674 /* 2644 /*
2675 * issue the bunmapi() call to free the blocks 2645 * issue the bunmapi() call to free the blocks
@@ -2839,8 +2809,7 @@ xfs_change_file_space(
2839 2809
2840 xfs_ilock(ip, XFS_ILOCK_EXCL); 2810 xfs_ilock(ip, XFS_ILOCK_EXCL);
2841 2811
2842 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); 2812 xfs_trans_ijoin(tp, ip);
2843 xfs_trans_ihold(tp, ip);
2844 2813
2845 if ((attr_flags & XFS_ATTR_DMI) == 0) { 2814 if ((attr_flags & XFS_ATTR_DMI) == 0) {
2846 ip->i_d.di_mode &= ~S_ISUID; 2815 ip->i_d.di_mode &= ~S_ISUID;