aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/alloc.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.osdl.org>2006-12-04 22:33:45 -0500
committerLinus Torvalds <torvalds@woody.osdl.org>2006-12-04 22:33:45 -0500
commit651857a1ecaf97a8ad9d324dd2a61675c53e541e (patch)
treef5b7e4915b25ae6910ede2bf37614ca98ab4f6e5 /fs/ocfs2/alloc.c
parentee28b0da1069ced1688aa9d0b7b378353b988321 (diff)
parentd38eb8db6aa359c060dfb72a29cf8d94a96657d8 (diff)
Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mfasheh/ocfs2
* 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mfasheh/ocfs2: (31 commits) ocfs2: implement i_op->permission configfs: make configfs_dirent_exists() static ocfs2: update file system paths to set atime ocfs2: core atime update functions ocfs2: Add splice support ocfs2: Remove ocfs2_write_should_remove_suid() [PATCH] Export should_remove_suid() configfs: mutex_lock_nested() fix ocfs2: Remove struct ocfs2_journal_handle in favor of handle_t ocfs2: remove handle argument to ocfs2_start_trans() ocfs2: remove ocfs2_journal_handle journal field ocfs2: pass ocfs2_super * into ocfs2_commit_trans() ocfs2: remove unused handle argument from ocfs2_meta_lock_full() ocfs2: make ocfs2_alloc_handle() static ocfs2: remove unused ocfs2_handle_add_lock() ocfs2: remove unused ocfs2_handle_add_inode() ocfs2: Don't allocate handle early in ocfs2_rename() ocfs2: don't use handle for locking in allocation functions ocfs2: don't pass handle to ocfs2_meta_lock in ocfs2_rename() ocfs2: don't pass handle to ocfs2_meta_lock in ocfs2_symlink() ...
Diffstat (limited to 'fs/ocfs2/alloc.c')
-rw-r--r--fs/ocfs2/alloc.c90
1 files changed, 39 insertions, 51 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index f43bc5f18a35..85a048b7a67b 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -52,14 +52,14 @@ static int ocfs2_extent_contig(struct inode *inode,
52 u64 blkno); 52 u64 blkno);
53 53
54static int ocfs2_create_new_meta_bhs(struct ocfs2_super *osb, 54static int ocfs2_create_new_meta_bhs(struct ocfs2_super *osb,
55 struct ocfs2_journal_handle *handle, 55 handle_t *handle,
56 struct inode *inode, 56 struct inode *inode,
57 int wanted, 57 int wanted,
58 struct ocfs2_alloc_context *meta_ac, 58 struct ocfs2_alloc_context *meta_ac,
59 struct buffer_head *bhs[]); 59 struct buffer_head *bhs[]);
60 60
61static int ocfs2_add_branch(struct ocfs2_super *osb, 61static int ocfs2_add_branch(struct ocfs2_super *osb,
62 struct ocfs2_journal_handle *handle, 62 handle_t *handle,
63 struct inode *inode, 63 struct inode *inode,
64 struct buffer_head *fe_bh, 64 struct buffer_head *fe_bh,
65 struct buffer_head *eb_bh, 65 struct buffer_head *eb_bh,
@@ -67,14 +67,14 @@ static int ocfs2_add_branch(struct ocfs2_super *osb,
67 struct ocfs2_alloc_context *meta_ac); 67 struct ocfs2_alloc_context *meta_ac);
68 68
69static int ocfs2_shift_tree_depth(struct ocfs2_super *osb, 69static int ocfs2_shift_tree_depth(struct ocfs2_super *osb,
70 struct ocfs2_journal_handle *handle, 70 handle_t *handle,
71 struct inode *inode, 71 struct inode *inode,
72 struct buffer_head *fe_bh, 72 struct buffer_head *fe_bh,
73 struct ocfs2_alloc_context *meta_ac, 73 struct ocfs2_alloc_context *meta_ac,
74 struct buffer_head **ret_new_eb_bh); 74 struct buffer_head **ret_new_eb_bh);
75 75
76static int ocfs2_do_insert_extent(struct ocfs2_super *osb, 76static int ocfs2_do_insert_extent(struct ocfs2_super *osb,
77 struct ocfs2_journal_handle *handle, 77 handle_t *handle,
78 struct inode *inode, 78 struct inode *inode,
79 struct buffer_head *fe_bh, 79 struct buffer_head *fe_bh,
80 u64 blkno, 80 u64 blkno,
@@ -152,7 +152,7 @@ bail:
152 * l_count for you 152 * l_count for you
153 */ 153 */
154static int ocfs2_create_new_meta_bhs(struct ocfs2_super *osb, 154static int ocfs2_create_new_meta_bhs(struct ocfs2_super *osb,
155 struct ocfs2_journal_handle *handle, 155 handle_t *handle,
156 struct inode *inode, 156 struct inode *inode,
157 int wanted, 157 int wanted,
158 struct ocfs2_alloc_context *meta_ac, 158 struct ocfs2_alloc_context *meta_ac,
@@ -253,7 +253,7 @@ bail:
253 * contain a single record with e_clusters == 0. 253 * contain a single record with e_clusters == 0.
254 */ 254 */
255static int ocfs2_add_branch(struct ocfs2_super *osb, 255static int ocfs2_add_branch(struct ocfs2_super *osb,
256 struct ocfs2_journal_handle *handle, 256 handle_t *handle,
257 struct inode *inode, 257 struct inode *inode,
258 struct buffer_head *fe_bh, 258 struct buffer_head *fe_bh,
259 struct buffer_head *eb_bh, 259 struct buffer_head *eb_bh,
@@ -418,7 +418,7 @@ bail:
418 * after this call. 418 * after this call.
419 */ 419 */
420static int ocfs2_shift_tree_depth(struct ocfs2_super *osb, 420static int ocfs2_shift_tree_depth(struct ocfs2_super *osb,
421 struct ocfs2_journal_handle *handle, 421 handle_t *handle,
422 struct inode *inode, 422 struct inode *inode,
423 struct buffer_head *fe_bh, 423 struct buffer_head *fe_bh,
424 struct ocfs2_alloc_context *meta_ac, 424 struct ocfs2_alloc_context *meta_ac,
@@ -520,7 +520,7 @@ bail:
520 * down. 520 * down.
521 */ 521 */
522static int ocfs2_do_insert_extent(struct ocfs2_super *osb, 522static int ocfs2_do_insert_extent(struct ocfs2_super *osb,
523 struct ocfs2_journal_handle *handle, 523 handle_t *handle,
524 struct inode *inode, 524 struct inode *inode,
525 struct buffer_head *fe_bh, 525 struct buffer_head *fe_bh,
526 u64 start_blk, 526 u64 start_blk,
@@ -809,7 +809,7 @@ bail:
809 809
810/* the caller needs to update fe->i_clusters */ 810/* the caller needs to update fe->i_clusters */
811int ocfs2_insert_extent(struct ocfs2_super *osb, 811int ocfs2_insert_extent(struct ocfs2_super *osb,
812 struct ocfs2_journal_handle *handle, 812 handle_t *handle,
813 struct inode *inode, 813 struct inode *inode,
814 struct buffer_head *fe_bh, 814 struct buffer_head *fe_bh,
815 u64 start_blk, 815 u64 start_blk,
@@ -951,7 +951,7 @@ static int ocfs2_truncate_log_can_coalesce(struct ocfs2_truncate_log *tl,
951} 951}
952 952
953static int ocfs2_truncate_log_append(struct ocfs2_super *osb, 953static int ocfs2_truncate_log_append(struct ocfs2_super *osb,
954 struct ocfs2_journal_handle *handle, 954 handle_t *handle,
955 u64 start_blk, 955 u64 start_blk,
956 unsigned int num_clusters) 956 unsigned int num_clusters)
957{ 957{
@@ -1034,7 +1034,7 @@ bail:
1034} 1034}
1035 1035
1036static int ocfs2_replay_truncate_records(struct ocfs2_super *osb, 1036static int ocfs2_replay_truncate_records(struct ocfs2_super *osb,
1037 struct ocfs2_journal_handle *handle, 1037 handle_t *handle,
1038 struct inode *data_alloc_inode, 1038 struct inode *data_alloc_inode,
1039 struct buffer_head *data_alloc_bh) 1039 struct buffer_head *data_alloc_bh)
1040{ 1040{
@@ -1113,7 +1113,7 @@ static int __ocfs2_flush_truncate_log(struct ocfs2_super *osb)
1113{ 1113{
1114 int status; 1114 int status;
1115 unsigned int num_to_flush; 1115 unsigned int num_to_flush;
1116 struct ocfs2_journal_handle *handle = NULL; 1116 handle_t *handle;
1117 struct inode *tl_inode = osb->osb_tl_inode; 1117 struct inode *tl_inode = osb->osb_tl_inode;
1118 struct inode *data_alloc_inode = NULL; 1118 struct inode *data_alloc_inode = NULL;
1119 struct buffer_head *tl_bh = osb->osb_tl_bh; 1119 struct buffer_head *tl_bh = osb->osb_tl_bh;
@@ -1130,7 +1130,7 @@ static int __ocfs2_flush_truncate_log(struct ocfs2_super *osb)
1130 if (!OCFS2_IS_VALID_DINODE(di)) { 1130 if (!OCFS2_IS_VALID_DINODE(di)) {
1131 OCFS2_RO_ON_INVALID_DINODE(osb->sb, di); 1131 OCFS2_RO_ON_INVALID_DINODE(osb->sb, di);
1132 status = -EIO; 1132 status = -EIO;
1133 goto bail; 1133 goto out;
1134 } 1134 }
1135 1135
1136 num_to_flush = le16_to_cpu(tl->tl_used); 1136 num_to_flush = le16_to_cpu(tl->tl_used);
@@ -1138,14 +1138,7 @@ static int __ocfs2_flush_truncate_log(struct ocfs2_super *osb)
1138 num_to_flush, (unsigned long long)OCFS2_I(tl_inode)->ip_blkno); 1138 num_to_flush, (unsigned long long)OCFS2_I(tl_inode)->ip_blkno);
1139 if (!num_to_flush) { 1139 if (!num_to_flush) {
1140 status = 0; 1140 status = 0;
1141 goto bail; 1141 goto out;
1142 }
1143
1144 handle = ocfs2_alloc_handle(osb);
1145 if (!handle) {
1146 status = -ENOMEM;
1147 mlog_errno(status);
1148 goto bail;
1149 } 1142 }
1150 1143
1151 data_alloc_inode = ocfs2_get_system_file_inode(osb, 1144 data_alloc_inode = ocfs2_get_system_file_inode(osb,
@@ -1154,41 +1147,40 @@ static int __ocfs2_flush_truncate_log(struct ocfs2_super *osb)
1154 if (!data_alloc_inode) { 1147 if (!data_alloc_inode) {
1155 status = -EINVAL; 1148 status = -EINVAL;
1156 mlog(ML_ERROR, "Could not get bitmap inode!\n"); 1149 mlog(ML_ERROR, "Could not get bitmap inode!\n");
1157 goto bail; 1150 goto out;
1158 } 1151 }
1159 1152
1160 ocfs2_handle_add_inode(handle, data_alloc_inode); 1153 mutex_lock(&data_alloc_inode->i_mutex);
1161 status = ocfs2_meta_lock(data_alloc_inode, handle, &data_alloc_bh, 1); 1154
1155 status = ocfs2_meta_lock(data_alloc_inode, &data_alloc_bh, 1);
1162 if (status < 0) { 1156 if (status < 0) {
1163 mlog_errno(status); 1157 mlog_errno(status);
1164 goto bail; 1158 goto out_mutex;
1165 } 1159 }
1166 1160
1167 handle = ocfs2_start_trans(osb, handle, OCFS2_TRUNCATE_LOG_UPDATE); 1161 handle = ocfs2_start_trans(osb, OCFS2_TRUNCATE_LOG_UPDATE);
1168 if (IS_ERR(handle)) { 1162 if (IS_ERR(handle)) {
1169 status = PTR_ERR(handle); 1163 status = PTR_ERR(handle);
1170 handle = NULL;
1171 mlog_errno(status); 1164 mlog_errno(status);
1172 goto bail; 1165 goto out_unlock;
1173 } 1166 }
1174 1167
1175 status = ocfs2_replay_truncate_records(osb, handle, data_alloc_inode, 1168 status = ocfs2_replay_truncate_records(osb, handle, data_alloc_inode,
1176 data_alloc_bh); 1169 data_alloc_bh);
1177 if (status < 0) { 1170 if (status < 0)
1178 mlog_errno(status); 1171 mlog_errno(status);
1179 goto bail;
1180 }
1181 1172
1182bail: 1173 ocfs2_commit_trans(osb, handle);
1183 if (handle)
1184 ocfs2_commit_trans(handle);
1185 1174
1186 if (data_alloc_inode) 1175out_unlock:
1187 iput(data_alloc_inode); 1176 brelse(data_alloc_bh);
1177 ocfs2_meta_unlock(data_alloc_inode, 1);
1188 1178
1189 if (data_alloc_bh) 1179out_mutex:
1190 brelse(data_alloc_bh); 1180 mutex_unlock(&data_alloc_inode->i_mutex);
1181 iput(data_alloc_inode);
1191 1182
1183out:
1192 mlog_exit(status); 1184 mlog_exit(status);
1193 return status; 1185 return status;
1194} 1186}
@@ -1347,7 +1339,7 @@ int ocfs2_complete_truncate_log_recovery(struct ocfs2_super *osb,
1347 int i; 1339 int i;
1348 unsigned int clusters, num_recs, start_cluster; 1340 unsigned int clusters, num_recs, start_cluster;
1349 u64 start_blk; 1341 u64 start_blk;
1350 struct ocfs2_journal_handle *handle; 1342 handle_t *handle;
1351 struct inode *tl_inode = osb->osb_tl_inode; 1343 struct inode *tl_inode = osb->osb_tl_inode;
1352 struct ocfs2_truncate_log *tl; 1344 struct ocfs2_truncate_log *tl;
1353 1345
@@ -1373,8 +1365,7 @@ int ocfs2_complete_truncate_log_recovery(struct ocfs2_super *osb,
1373 } 1365 }
1374 } 1366 }
1375 1367
1376 handle = ocfs2_start_trans(osb, NULL, 1368 handle = ocfs2_start_trans(osb, OCFS2_TRUNCATE_LOG_UPDATE);
1377 OCFS2_TRUNCATE_LOG_UPDATE);
1378 if (IS_ERR(handle)) { 1369 if (IS_ERR(handle)) {
1379 status = PTR_ERR(handle); 1370 status = PTR_ERR(handle);
1380 mlog_errno(status); 1371 mlog_errno(status);
@@ -1387,7 +1378,7 @@ int ocfs2_complete_truncate_log_recovery(struct ocfs2_super *osb,
1387 1378
1388 status = ocfs2_truncate_log_append(osb, handle, 1379 status = ocfs2_truncate_log_append(osb, handle,
1389 start_blk, clusters); 1380 start_blk, clusters);
1390 ocfs2_commit_trans(handle); 1381 ocfs2_commit_trans(osb, handle);
1391 if (status < 0) { 1382 if (status < 0) {
1392 mlog_errno(status); 1383 mlog_errno(status);
1393 goto bail_up; 1384 goto bail_up;
@@ -1543,7 +1534,7 @@ static int ocfs2_do_truncate(struct ocfs2_super *osb,
1543 struct inode *inode, 1534 struct inode *inode,
1544 struct buffer_head *fe_bh, 1535 struct buffer_head *fe_bh,
1545 struct buffer_head *old_last_eb_bh, 1536 struct buffer_head *old_last_eb_bh,
1546 struct ocfs2_journal_handle *handle, 1537 handle_t *handle,
1547 struct ocfs2_truncate_context *tc) 1538 struct ocfs2_truncate_context *tc)
1548{ 1539{
1549 int status, i, depth; 1540 int status, i, depth;
@@ -1782,7 +1773,7 @@ int ocfs2_commit_truncate(struct ocfs2_super *osb,
1782 struct ocfs2_extent_block *eb; 1773 struct ocfs2_extent_block *eb;
1783 struct ocfs2_extent_list *el; 1774 struct ocfs2_extent_list *el;
1784 struct buffer_head *last_eb_bh; 1775 struct buffer_head *last_eb_bh;
1785 struct ocfs2_journal_handle *handle = NULL; 1776 handle_t *handle = NULL;
1786 struct inode *tl_inode = osb->osb_tl_inode; 1777 struct inode *tl_inode = osb->osb_tl_inode;
1787 1778
1788 mlog_entry_void(); 1779 mlog_entry_void();
@@ -1868,7 +1859,7 @@ start:
1868 1859
1869 credits = ocfs2_calc_tree_trunc_credits(osb->sb, clusters_to_del, 1860 credits = ocfs2_calc_tree_trunc_credits(osb->sb, clusters_to_del,
1870 fe, el); 1861 fe, el);
1871 handle = ocfs2_start_trans(osb, NULL, credits); 1862 handle = ocfs2_start_trans(osb, credits);
1872 if (IS_ERR(handle)) { 1863 if (IS_ERR(handle)) {
1873 status = PTR_ERR(handle); 1864 status = PTR_ERR(handle);
1874 handle = NULL; 1865 handle = NULL;
@@ -1891,7 +1882,7 @@ start:
1891 mutex_unlock(&tl_inode->i_mutex); 1882 mutex_unlock(&tl_inode->i_mutex);
1892 tl_sem = 0; 1883 tl_sem = 0;
1893 1884
1894 ocfs2_commit_trans(handle); 1885 ocfs2_commit_trans(osb, handle);
1895 handle = NULL; 1886 handle = NULL;
1896 1887
1897 BUG_ON(le32_to_cpu(fe->i_clusters) < target_i_clusters); 1888 BUG_ON(le32_to_cpu(fe->i_clusters) < target_i_clusters);
@@ -1906,7 +1897,7 @@ bail:
1906 mutex_unlock(&tl_inode->i_mutex); 1897 mutex_unlock(&tl_inode->i_mutex);
1907 1898
1908 if (handle) 1899 if (handle)
1909 ocfs2_commit_trans(handle); 1900 ocfs2_commit_trans(osb, handle);
1910 1901
1911 if (last_eb_bh) 1902 if (last_eb_bh)
1912 brelse(last_eb_bh); 1903 brelse(last_eb_bh);
@@ -2011,10 +2002,7 @@ int ocfs2_prepare_truncate(struct ocfs2_super *osb,
2011 mutex_lock(&ext_alloc_inode->i_mutex); 2002 mutex_lock(&ext_alloc_inode->i_mutex);
2012 (*tc)->tc_ext_alloc_inode = ext_alloc_inode; 2003 (*tc)->tc_ext_alloc_inode = ext_alloc_inode;
2013 2004
2014 status = ocfs2_meta_lock(ext_alloc_inode, 2005 status = ocfs2_meta_lock(ext_alloc_inode, &ext_alloc_bh, 1);
2015 NULL,
2016 &ext_alloc_bh,
2017 1);
2018 if (status < 0) { 2006 if (status < 0) {
2019 mlog_errno(status); 2007 mlog_errno(status);
2020 goto bail; 2008 goto bail;